@wcstack/debounce 3.3.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.esm.js +33 -0
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/auto.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const t={triggerAttribute:"data-debouncetarget",tagNames:{debounce:"wcs-debounce",throttle:"wcs-throttle"}};function
|
|
1
|
+
const t={triggerAttribute:"data-debouncetarget",tagNames:{debounce:"wcs-debounce",throttle:"wcs-throttle"}},e=t;function i(t){return[{name:"value",event:`${t}:settled`,semantics:"state",getter:t=>t.detail.value},{name:"fired",event:`${t}:fired`,semantics:"event",getter:t=>t.detail.args},{name:"pending",event:`${t}:pending-changed`,semantics:"state"}]}class n extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:i("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 s=!1;function a(t){const i=t.target;if(!(i instanceof Element))return;const n=i.closest(`[${e.triggerAttribute}]`);if(!n)return;const s=n.getAttribute(e.triggerAttribute);if(!s)return;const a=customElements.get(e.tagNames.debounce),r=customElements.get(e.tagNames.throttle),l=document.getElementById(s);if(!l)return;(a&&l instanceof a||r&&l instanceof r)&&(t.preventDefault(),l.trigger())}function r(t,e){let i=Object.getPrototypeOf(t);for(;null!==i;){const t=Object.getOwnPropertyDescriptor(i,e);if(void 0!==t)return"function"==typeof t.get||"function"==typeof t.set;i=Object.getPrototypeOf(i)}return!1}class l extends HTMLElement{static hasConnectedCallbackPromise=!0;static eventPrefix="wcs-debounce";static wcBindable={protocol:"wc-bindable",version:1,properties:i("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 n(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,a]of Object.entries(n(t.detail))){try{a?e.add(s):e.delete(s)}catch{}i&&this.toggleAttribute(`data-wcs-state-${s}`,a)}})}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(){!function(t){const e=t.constructor?.wcBindable,i=e?.inputs;if(void 0!==i)for(const e of i){const i=e.name;if(!Object.prototype.hasOwnProperty.call(t,i))continue;if(!r(t,i))continue;const n=t,s=n[i];delete n[i],n[i]=s}}(this),this.style.display="none",s||(s=!0,document.addEventListener("click",a)),this._connectedCallbackPromise=this._core.observe()}disconnectedCallback(){this._core.dispose()}}class o extends l{static eventPrefix="wcs-throttle";static wcBindable={...l.wcBindable,properties:i("wcs-throttle")};_resolveLeading(){return!this.hasAttribute("no-leading")}_defaultMaxWait(){return this.wait}}var h;!function(t=customElements){t.get(e.tagNames.debounce)||t.define(e.tagNames.debounce,l),t.get(e.tagNames.throttle)||t.define(e.tagNames.throttle,o)}(h);
|
|
2
2
|
//# sourceMappingURL=auto.min.js.map
|
package/dist/auto.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto.min.js","sources":["../src/config.ts","../src/wcBindableFactory.ts","../src/core/DebounceCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.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`, semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.value },\n { name: \"fired\", event: `${prefix}:fired`, semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail.args },\n { name: \"pending\", event: `${prefix}:pending-changed`, semantics: \"state\" },\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","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n for (const input of inputs) {\n const name = input.name;\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\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\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.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 // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\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, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n","import { Debounce } from \"./components/Debounce.js\";\nimport { Throttle } from \"./components/Throttle.js\";\nimport { config } from \"./config.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n if (!registry.get(config.tagNames.debounce)) {\n registry.define(config.tagNames.debounce, Debounce);\n }\n if (!registry.get(config.tagNames.throttle)) {\n registry.define(config.tagNames.throttle, Throttle);\n }\n}\n"],"names":["config","triggerAttribute","tagNames","debounce","throttle","makeDebounceProperties","prefix","name","event","semantics","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","hasAccessorOnPrototype","proto","Object","getPrototypeOf","descriptor","getOwnPropertyDescriptor","set","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","element","declaration","wcBindable","input","prototype","hasOwnProperty","call","record","upgradeProperties","style","display","disconnectedCallback","Throttle","registry","define","registerComponents"],"mappings":"AAWA,MA6BaA,EA7BoB,CAE/BC,iBAAkB,sBAClBC,SAAU,CACRC,SAAU,eACVC,SAAU,iBCER,SAAUC,EAAuBC,GACrC,MAAO,CACL,CAAEC,KAAM,QAASC,MAAO,GAAGF,YAAkBG,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOC,OACjH,CAAEN,KAAM,QAASC,MAAO,GAAGF,UAAgBG,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOE,MAC/G,CAAEP,KAAM,UAAWC,MAAO,GAAGF,oBAA0BG,UAAW,SAEtE,CCKM,MAAOM,UAAqBC,YAOhCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAYf,EAAuB,gBACnCgB,SAAU,CACR,CAAEd,KAAM,WACR,CAAEA,KAAM,UACR,CAAEA,KAAM,WAIKe,QACTC,QAGAC,MAAgB,EAChBC,UAAoB,EACpBC,WAAqB,EACrBC,SAAmB,EACnBC,aAAuB,EAGvBC,mBAAoCC,EACpCC,gBAA0B,EAC1BC,SAAiD,KAGjDC,UAAoB,EAMpBC,aAA4B,KAC5BC,mBAAqBL,EACrBM,kBAAkCN,EAGlCO,YAAcP,EACdQ,UAAmB,GACnBC,UAAoB,EAOpBC,KAAO,EAGPC,OAAwBC,QAAQC,UAExC,WAAAC,CAAYtC,EAAiB,eAAgBuC,EAAsBC,GACjEC,QACAC,KAAK1B,QAAUhB,EACf0C,KAAKzB,QAAUsB,GAAUG,KACrBF,GACFE,KAAKC,UAAUH,EAEnB,CAIA,SAAII,GACF,OAAOF,KAAKP,MACd,CAKA,OAAAU,GACE,OAAOH,KAAKP,MACd,C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GAAO,SAC1D,IAAKsG,EAAuB8C,EAASpJ,GAAO,SAC5C,MAAM2J,EAASP,EACT9I,EAAQqJ,EAAO3J,UACd2J,EAAO3J,GACd2J,EAAO3J,GAAQM,CACjB,CACF,CCmLIsJ,CAAkBnH,MAClBA,KAAKoH,MAAMC,QAAU,OF3MnBvE,IACJA,GAAa,EACbY,SAAS+B,iBAAiB,QAAS1C,IE+MjC/C,KAAK0E,0BAA4B1E,KAAKwE,MAAMrE,SAC9C,CAEA,oBAAAmH,GAGEtH,KAAKwE,MAAMpE,SACb,ECjPI,MAAOmH,UAAiBnD,EAClBnG,mBAAqB,eAC/BA,kBAAiC,IAC5BmG,EAASyC,WACZzI,WAAYf,EAAuB,iBAK3B,eAAAoJ,GACR,OAAQzG,KAAK2F,aAAa,aAC5B,CAIU,eAAAW,GACR,OAAOtG,KAAKM,IACd,ECxBI,IAA0DkH,GCK1D,SAA6BA,EAAkClE,gBAC9DkE,EAASjE,IAAIvG,EAAOE,SAASC,WAChCqK,EAASC,OAAOzK,EAAOE,SAASC,SAAUiH,GAEvCoD,EAASjE,IAAIvG,EAAOE,SAASE,WAChCoK,EAASC,OAAOzK,EAAOE,SAASE,SAAUmK,EAE9C,CDREG,CAAmBF"}
|
|
1
|
+
{"version":3,"file":"auto.min.js","sources":["../src/config.ts","../src/wcBindableFactory.ts","../src/core/DebounceCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.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\n// The defaults as shipped, for warnInvalid: a value 3.x lets through unchecked must not change\n// what a later call is compared against.\nconst defaults: Record<string, unknown> = { ..._config, tagNames: { ..._config.tagNames } };\nconst warned = new Set<string>();\n\n/**\n * 3.5 forward-compat check. Warns, once per key per page, about an option that 4.0's\n * bootstrapDebounce throws on: one this package does not have, a value of another type than its\n * default (null, or an array for an object, included), or a tag name it does not define or that is\n * not a string. An undefined value is left out, as in 4.0. It only warns: setConfig then goes on\n * exactly as in 3.x. Bootstrap-time only, never on a hot path.\n */\nfunction warnInvalid(given: Record<string, unknown>, known: Record<string, unknown>, path = \"\"): void {\n for (const [key, value] of Object.entries(given)) {\n const name = path + key;\n const current = known[key];\n if (value === undefined) {\n continue;\n }\n if (\n !Object.prototype.hasOwnProperty.call(known, key) ||\n value === null ||\n typeof value !== typeof current ||\n Array.isArray(value) !== Array.isArray(current)\n ) {\n if (!warned.has(name)) {\n warned.add(name);\n console.warn(`[@wcstack/debounce] bootstrapDebounce: \"${name}\" is not one of its options, or not of the option's type. 3.x ignores it or applies it unchecked; 4.0 throws on it.`);\n }\n } else if (name === \"tagNames\") {\n warnInvalid(value as Record<string, unknown>, current as Record<string, unknown>, \"tagNames.\");\n }\n }\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n warnInvalid(partialConfig as Record<string, unknown>, defaults);\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`, semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.value },\n { name: \"fired\", event: `${prefix}:fired`, semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail.args },\n { name: \"pending\", event: `${prefix}:pending-changed`, semantics: \"state\" },\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","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n for (const input of inputs) {\n const name = input.name;\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\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\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.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 // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\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, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n","import { Debounce } from \"./components/Debounce.js\";\nimport { Throttle } from \"./components/Throttle.js\";\nimport { config } from \"./config.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n if (!registry.get(config.tagNames.debounce)) {\n registry.define(config.tagNames.debounce, Debounce);\n }\n if (!registry.get(config.tagNames.throttle)) {\n registry.define(config.tagNames.throttle, Throttle);\n }\n}\n"],"names":["_config","triggerAttribute","tagNames","debounce","throttle","config","makeDebounceProperties","prefix","name","event","semantics","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","hasAccessorOnPrototype","proto","Object","getPrototypeOf","descriptor","getOwnPropertyDescriptor","set","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","element","declaration","wcBindable","input","prototype","hasOwnProperty","call","record","upgradeProperties","style","display","disconnectedCallback","Throttle","registry","define","registerComponents"],"mappings":"AAWA,MAAMA,EAA2B,CAE/BC,iBAAkB,sBAClBC,SAAU,CACRC,SAAU,eACVC,SAAU,iBAwBDC,EAAkBL,ECtBzB,SAAUM,EAAuBC,GACrC,MAAO,CACL,CAAEC,KAAM,QAASC,MAAO,GAAGF,YAAkBG,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOC,OACjH,CAAEN,KAAM,QAASC,MAAO,GAAGF,UAAgBG,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOE,MAC/G,CAAEP,KAAM,UAAWC,MAAO,GAAGF,oBAA0BG,UAAW,SAEtE,CCKM,MAAOM,UAAqBC,YAOhCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAYf,EAAuB,gBACnCgB,SAAU,CACR,CAAEd,KAAM,WACR,CAAEA,KAAM,UACR,CAAEA,KAAM,WAIKe,QACTC,QAGAC,MAAgB,EAChBC,UAAoB,EACpBC,WAAqB,EACrBC,SAAmB,EACnBC,aAAuB,EAGvBC,mBAAoCC,EACpCC,gBAA0B,EAC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fig;
|
|
34
34
|
}
|
|
35
|
+
// The defaults as shipped, for warnInvalid: a value 3.x lets through unchecked must not change
|
|
36
|
+
// what a later call is compared against.
|
|
37
|
+
const defaults = { ..._config, tagNames: { ..._config.tagNames } };
|
|
38
|
+
const warned = new Set();
|
|
39
|
+
/**
|
|
40
|
+
* 3.5 forward-compat check. Warns, once per key per page, about an option that 4.0's
|
|
41
|
+
* bootstrapDebounce throws on: one this package does not have, a value of another type than its
|
|
42
|
+
* default (null, or an array for an object, included), or a tag name it does not define or that is
|
|
43
|
+
* not a string. An undefined value is left out, as in 4.0. It only warns: setConfig then goes on
|
|
44
|
+
* exactly as in 3.x. Bootstrap-time only, never on a hot path.
|
|
45
|
+
*/
|
|
46
|
+
function warnInvalid(given, known, path = "") {
|
|
47
|
+
for (const [key, value] of Object.entries(given)) {
|
|
48
|
+
const name = path + key;
|
|
49
|
+
const current = known[key];
|
|
50
|
+
if (value === undefined) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (!Object.prototype.hasOwnProperty.call(known, key) ||
|
|
54
|
+
value === null ||
|
|
55
|
+
typeof value !== typeof current ||
|
|
56
|
+
Array.isArray(value) !== Array.isArray(current)) {
|
|
57
|
+
if (!warned.has(name)) {
|
|
58
|
+
warned.add(name);
|
|
59
|
+
console.warn(`[@wcstack/debounce] bootstrapDebounce: "${name}" is not one of its options, or not of the option's type. 3.x ignores it or applies it unchecked; 4.0 throws on it.`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (name === "tagNames") {
|
|
63
|
+
warnInvalid(value, current, "tagNames.");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
35
67
|
function setConfig(partialConfig) {
|
|
68
|
+
warnInvalid(partialConfig, defaults);
|
|
36
69
|
if (typeof partialConfig.autoTrigger === "boolean") {
|
|
37
70
|
_config.autoTrigger = partialConfig.autoTrigger;
|
|
38
71
|
}
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/wcBindableFactory.ts","../src/core/DebounceCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.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`, semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.value },\n { name: \"fired\", event: `${prefix}:fired`, semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail.args },\n { name: \"pending\", event: `${prefix}:pending-changed`, semantics: \"state\" },\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","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n for (const input of inputs) {\n const name = input.name;\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\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\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.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 // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\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\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n if (!registry.get(config.tagNames.debounce)) {\n registry.define(config.tagNames.debounce, Debounce);\n }\n if (!registry.get(config.tagNames.throttle)) {\n registry.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, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\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,GA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AE;IACtB;;;ACxPF;;;;;;AAMG;AACG,MAAO,QAAS,SAAQ,QAAQ,CAAA;AAC1B,IAAA,OAAO,WAAW,GAAG,cAAc;IAC7C,OAAO,UAAU,GAAgB;QAC/B,GAAG,QAAQ,CAAC,UAAU;AACtB,QAAA,UAAU,EAAE,sBAAsB,CAAC,cAAc,CAAC;KACnD;;;IAIS,eAAe,GAAA;AACvB,QAAA,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;IACzC;;;IAIU,eAAe,GAAA;QACvB,OAAO,IAAI,CAAC,IAAI;IAClB;;;ACxBF;;;;AAIG;AACG,SAAU,kBAAkB,CAAC,QAAA,GAAkC,cAAc,EAAA;AACjF,IAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAC3C,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACrD;AACA,IAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAC3C,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACrD;AACF;;ACZM,SAAU,iBAAiB,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAC9F,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;IACA,kBAAkB,CAAC,QAAQ,CAAC;AAC9B;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/wcBindableFactory.ts","../src/core/DebounceCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.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\n// The defaults as shipped, for warnInvalid: a value 3.x lets through unchecked must not change\n// what a later call is compared against.\nconst defaults: Record<string, unknown> = { ..._config, tagNames: { ..._config.tagNames } };\nconst warned = new Set<string>();\n\n/**\n * 3.5 forward-compat check. Warns, once per key per page, about an option that 4.0's\n * bootstrapDebounce throws on: one this package does not have, a value of another type than its\n * default (null, or an array for an object, included), or a tag name it does not define or that is\n * not a string. An undefined value is left out, as in 4.0. It only warns: setConfig then goes on\n * exactly as in 3.x. Bootstrap-time only, never on a hot path.\n */\nfunction warnInvalid(given: Record<string, unknown>, known: Record<string, unknown>, path = \"\"): void {\n for (const [key, value] of Object.entries(given)) {\n const name = path + key;\n const current = known[key];\n if (value === undefined) {\n continue;\n }\n if (\n !Object.prototype.hasOwnProperty.call(known, key) ||\n value === null ||\n typeof value !== typeof current ||\n Array.isArray(value) !== Array.isArray(current)\n ) {\n if (!warned.has(name)) {\n warned.add(name);\n console.warn(`[@wcstack/debounce] bootstrapDebounce: \"${name}\" is not one of its options, or not of the option's type. 3.x ignores it or applies it unchecked; 4.0 throws on it.`);\n }\n } else if (name === \"tagNames\") {\n warnInvalid(value as Record<string, unknown>, current as Record<string, unknown>, \"tagNames.\");\n }\n }\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n warnInvalid(partialConfig as Record<string, unknown>, defaults);\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`, semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.value },\n { name: \"fired\", event: `${prefix}:fired`, semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail.args },\n { name: \"pending\", event: `${prefix}:pending-changed`, semantics: \"state\" },\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","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n for (const input of inputs) {\n const name = input.name;\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\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\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.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 // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\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\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n if (!registry.get(config.tagNames.debounce)) {\n registry.define(config.tagNames.debounce, Debounce);\n }\n if (!registry.get(config.tagNames.throttle)) {\n registry.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, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\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;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;;ACZM,SAAU,iBAAiB,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAC9F,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;IACA,kBAAkB,CAAC,QAAQ,CAAC;AAC9B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/debounce",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.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",
|