@wcstack/clipboard 1.16.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ja.md CHANGED
@@ -181,6 +181,66 @@ DOM の autoTrigger は書き込み(`writeText`)のみを起動します。
181
181
  <wcs-clipboard data-wcs="command.writeText: $command.copy"></wcs-clipboard>
182
182
  ```
183
183
 
184
+ ## `:state()` による CSS スタイリング
185
+
186
+ `<wcs-clipboard>` は 3 つの boolean 出力ステートを
187
+ [`ElementInternals` の `CustomStateSet`](https://developer.mozilla.org/ja/docs/Web/API/CustomStateSet)
188
+ に反映します。そのため `data-wcs` バインディングやクラスの手動トグルなしに、CSS の
189
+ `:state()` 疑似クラスで直接スタイリングできます。
190
+
191
+ | ステート | on になる条件 |
192
+ |----------|----------------|
193
+ | `loading` | `wcs-clipboard:loading-changed` が `true` で発火(`false` でクリア) |
194
+ | `monitoring` | `wcs-clipboard:monitoring-changed` が `true` で発火(`false` でクリア) |
195
+ | `error` | `wcs-clipboard:error` が非 `null` の detail で発火(`null` でクリア) |
196
+
197
+ > `readPermission` / `writePermission` は v1 では反映**しません** — 単一のステート名に
198
+ > マップできる boolean 派生 getter が無いためです(
199
+ > [async-io-node-guidelines.md](../../docs/async-io-node-guidelines.md) §4.2 参照)。
200
+ > これらは従来どおり `data-wcs` でバインドしてください。
201
+
202
+ ```css
203
+ wcs-clipboard:state(loading) ~ .spinner { display: block; }
204
+ wcs-clipboard:state(loading) ~ .spinner { display: none; } /* デフォルト */
205
+
206
+ wcs-clipboard:state(monitoring) ~ .live-badge { display: inline-block; }
207
+
208
+ form:has(wcs-clipboard:state(error)) .banner { display: block; }
209
+ ```
210
+
211
+ 属性やクラスと異なり `:state()` は要素の外部から書き込めないため、この出力ステートが
212
+ 入力と混同される心配がありません。
213
+
214
+ **対応ブラウザ**(新構文 `:state(x)`): Chrome/Edge 125+、Safari 17.4+、Firefox 126+。
215
+ 非対応の環境ではステートが一切 set されないだけです — `:state()` セレクタがマッチしなく
216
+ なりますが、`<wcs-clipboard>` 自体は通常どおり動作し続けます(graceful degradation・never-throw)。
217
+
218
+ **SSR:** `:state()` は HTML にシリアライズできないため、サーバーレンダリングされた
219
+ マークアップの初期ペイントにはこれらのステートは乗りません(`@wcstack/server` は無改変)。
220
+ ハイドレーション前の見た目を制御したい場合は、代わりに `wcs-clipboard:not(:defined)` と組み合わせてください。
221
+
222
+ ### デバッグ
223
+
224
+ カスタムステートは DevTools の Elements パネルには表示されず、`attachInternals()`
225
+ は同一要素に 2 回呼べないため、コンソールから直接覗く手段がありません。そのための
226
+ デバッグ専用の補助を 2 つ用意しています:
227
+
228
+ - `el.debugStates` — 現在 on になっているステート名の**スナップショット**配列
229
+ (例: `["loading"]`)。`wc-bindable` の一部ではなく(バインド対象ではない)、
230
+ 形状も契約として保証されません — デバッグ用途にのみ使ってください。
231
+ - `debug-states` 属性(opt-in・既定 OFF)は、ステート変化を要素の
232
+ `data-wcs-state-loading` / `data-wcs-state-monitoring` /
233
+ `data-wcs-state-error` 属性にミラーします。Elements パネルを開いておけば、
234
+ トグルのたびにハイライトされます:
235
+
236
+ ```html
237
+ <wcs-clipboard monitor debug-states></wcs-clipboard>
238
+ ```
239
+
240
+ **CSS は `data-wcs-state-*` ではなく `:state()` に書いてください。** ミラーされた
241
+ 属性は、DevTools を開いた状態でステート変化を可視化するためだけのものであり、
242
+ スタイリング用の正式なフックではありません。
243
+
184
244
  ## 注意点と制約
185
245
 
186
246
  - **属性は接続時に読み取られ、監視されない。** `<wcs-clipboard>` は `observedAttributes` / `attributeChangedCallback` を実装していません。`monitor` 属性は要素の接続時に読み取られます。接続*後*に命令的にトグルしても、それだけでは監視は開始/停止しません。`startMonitor()` / `stopMonitor()` を呼ぶか、要素を再接続してください。
package/README.md CHANGED
@@ -183,6 +183,68 @@ State-driven invocation uses the command-token protocol:
183
183
  <wcs-clipboard data-wcs="command.writeText: $command.copy"></wcs-clipboard>
184
184
  ```
185
185
 
186
+ ## CSS styling with `:state()`
187
+
188
+ `<wcs-clipboard>` reflects three boolean output states onto its
189
+ [`ElementInternals` `CustomStateSet`](https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet),
190
+ so you can style it directly from CSS with the `:state()` pseudo-class — no
191
+ `data-wcs` binding or extra class toggling required.
192
+
193
+ | State | On when |
194
+ |-------|---------|
195
+ | `loading` | `wcs-clipboard:loading-changed` fires with `true` (cleared on `false`) |
196
+ | `monitoring` | `wcs-clipboard:monitoring-changed` fires with `true` (cleared on `false`) |
197
+ | `error` | `wcs-clipboard:error` fires with a non-`null` detail (cleared on `null`) |
198
+
199
+ > `readPermission` / `writePermission` are **not** reflected in v1 — they have
200
+ > no boolean derived getter to map onto a single state name (see
201
+ > [async-io-node-guidelines.md](../../docs/async-io-node-guidelines.md) §4.2).
202
+ > Bind them via `data-wcs` as usual.
203
+
204
+ ```css
205
+ wcs-clipboard:state(loading) ~ .spinner { display: block; }
206
+ wcs-clipboard:state(loading) ~ .spinner { display: none; } /* default */
207
+
208
+ wcs-clipboard:state(monitoring) ~ .live-badge { display: inline-block; }
209
+
210
+ form:has(wcs-clipboard:state(error)) .banner { display: block; }
211
+ ```
212
+
213
+ Unlike attributes or classes, `:state()` cannot be written from outside the
214
+ element, so there is no risk of confusing this output state with an input.
215
+
216
+ **Browser support** (`:state(x)` syntax): Chrome/Edge 125+, Safari 17.4+,
217
+ Firefox 126+. In older browsers the states are simply never set — `:state()`
218
+ selectors never match, but `<wcs-clipboard>` itself keeps working normally
219
+ (graceful degradation, never-throw).
220
+
221
+ **SSR**: `:state()` cannot be serialized into HTML, so server-rendered markup
222
+ never carries these states on first paint (`@wcstack/server` is unaffected).
223
+ If you need to style the pre-hydration gap, pair your rule with
224
+ `wcs-clipboard:not(:defined)` instead.
225
+
226
+ ### Debugging
227
+
228
+ Custom states are invisible in DevTools' Elements panel and `attachInternals()`
229
+ cannot be called twice, so there is no console way to inspect them directly.
230
+ Two debug-only aids are provided for that:
231
+
232
+ - `el.debugStates` — a **snapshot** array of the currently-on state names
233
+ (e.g. `["loading"]`). It is not part of `wc-bindable` (not a bind target)
234
+ and its shape is not a guaranteed contract — use it for debugging only.
235
+ - The `debug-states` attribute (opt-in, default off) mirrors state changes
236
+ onto `data-wcs-state-loading` / `data-wcs-state-monitoring` /
237
+ `data-wcs-state-error` attributes on the element, so the Elements panel
238
+ highlights them as they toggle:
239
+
240
+ ```html
241
+ <wcs-clipboard monitor debug-states></wcs-clipboard>
242
+ ```
243
+
244
+ **Write your CSS against `:state()`, not `data-wcs-state-*`.** The mirrored
245
+ attributes exist purely to make state changes visible while debugging with
246
+ DevTools open; they are not a supported styling hook.
247
+
186
248
  ## Notes & limitations
187
249
 
188
250
  - **Attributes are read at connect time, not observed.** `<wcs-clipboard>` does not implement `observedAttributes` / `attributeChangedCallback`. The `monitor` attribute is read when the element connects — toggling it imperatively after connect does not start/stop monitoring by itself; call `startMonitor()` / `stopMonitor()`, or re-connect the element.
package/dist/index.d.ts CHANGED
@@ -264,8 +264,12 @@ declare class WcsClipboard extends HTMLElement {
264
264
  static wcBindable: IWcBindable;
265
265
  private _core;
266
266
  private _connectedCallbackPromise;
267
+ private _internals;
267
268
  constructor();
268
269
  get connectedCallbackPromise(): Promise<void>;
270
+ get debugStates(): string[];
271
+ private _initInternals;
272
+ private _wireStates;
269
273
  get monitor(): boolean;
270
274
  /**
271
275
  * Reflects the `monitor` boolean attribute only — it does NOT start or stop
package/dist/index.esm.js CHANGED
@@ -627,15 +627,70 @@ class WcsClipboard extends HTMLElement {
627
627
  };
628
628
  _core;
629
629
  _connectedCallbackPromise = Promise.resolve();
630
+ _internals = null;
630
631
  constructor() {
631
632
  super();
632
633
  this._core = new ClipboardCore(this);
634
+ this._internals = this._initInternals();
635
+ this._wireStates({
636
+ "wcs-clipboard:loading-changed": (d) => ({ loading: d === true }),
637
+ "wcs-clipboard:monitoring-changed": (d) => ({ monitoring: d === true }),
638
+ "wcs-clipboard:error": (d) => ({ error: d != null }),
639
+ });
633
640
  }
634
641
  // SSR (§4.4): the state binder awaits this before snapshotting, so the first
635
642
  // permission probe has settled. Backed by _core.observe() (see connectedCallback).
636
643
  get connectedCallbackPromise() {
637
644
  return this._connectedCallbackPromise;
638
645
  }
646
+ // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of
647
+ // wc-bindable (not a bind target); see README "CSS styling with :state()".
648
+ // MUST NOT return the live CustomStateSet (that would let callers write
649
+ // states from outside, defeating the point of :state() being read-only).
650
+ get debugStates() {
651
+ return this._internals ? [...this._internals.states] : [];
652
+ }
653
+ _initInternals() {
654
+ // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent
655
+ // in happy-dom / older environments, and pre-125 Chromium rejects
656
+ // non-dashed state names from states.add() (probed and discarded here).
657
+ // Either case silently disables reflection — the component still works,
658
+ // it just doesn't expose :state() selectors.
659
+ try {
660
+ if (typeof this.attachInternals !== "function")
661
+ return null;
662
+ const internals = this.attachInternals();
663
+ internals.states.add("wcs-probe");
664
+ internals.states.delete("wcs-probe");
665
+ return internals;
666
+ }
667
+ catch {
668
+ return null;
669
+ }
670
+ }
671
+ _wireStates(map) {
672
+ if (this._internals === null)
673
+ return;
674
+ const states = this._internals.states;
675
+ for (const [event, toStates] of Object.entries(map)) {
676
+ this.addEventListener(event, (e) => {
677
+ const debug = this.hasAttribute("debug-states");
678
+ for (const [name, on] of Object.entries(toStates(e.detail))) {
679
+ try {
680
+ if (on) {
681
+ states.add(name);
682
+ }
683
+ else {
684
+ states.delete(name);
685
+ }
686
+ }
687
+ catch { /* never-throw */ }
688
+ if (debug)
689
+ this.toggleAttribute(`data-wcs-state-${name}`, on);
690
+ }
691
+ });
692
+ }
693
+ }
639
694
  // --- Attribute accessors ---
640
695
  get monitor() {
641
696
  return this.hasAttribute("monitor");
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/ClipboardCore.ts","../src/autoTrigger.ts","../src/components/Clipboard.ts","../src/registerComponents.ts","../src/bootstrapClipboard.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n clipboard: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-clipboardtarget\",\n tagNames: {\n clipboard: \"wcs-clipboard\",\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 {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardReadDetail, WcsClipboardErrorDetail,\n} from \"../types.js\";\n\n/**\n * Headless clipboard primitive. A thin, framework-agnostic wrapper around the\n * Clipboard API exposed through the wc-bindable protocol.\n *\n * It has two surfaces, mirroring the two distinct shapes of clipboard access:\n * - **commands** — `writeText()` / `write()` push to the clipboard;\n * `readText()` / `read()` pull from it. These are the `state → element`\n * (command-token) and `element → state` (read result) paths. All four are\n * async and never reject: failures surface through the `error` property so\n * they flow into the declarative state, symmetrical with FetchCore /\n * GeolocationCore.\n * - **monitor** — `startMonitor()` / `stopMonitor()` subscribe to the document's\n * `copy` / `cut` / `paste` events and republish them as the `copied` / `cut` /\n * `pasted` properties (like TimerCore's continuous `start()` / `stop()`),\n * toggling the `monitoring` flag. This is the event-token showcase: a user\n * paste flows element → state declaratively.\n *\n * Clipboard also has permission gates, like GeolocationCore but doubled: read\n * and write are separate permissions (`clipboard-read` / `clipboard-write`).\n * `readPermission` / `writePermission` reflect `navigator.permissions.query`\n * (`prompt` / `granted` / `denied`, or `unsupported`) and track their live\n * `change` events.\n */\nexport class ClipboardCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"text\", event: \"wcs-clipboard:read\", getter: (e: Event) => (e as CustomEvent).detail.text },\n { name: \"items\", event: \"wcs-clipboard:read\", getter: (e: Event) => (e as CustomEvent).detail.items },\n { name: \"loading\", event: \"wcs-clipboard:loading-changed\" },\n { name: \"error\", event: \"wcs-clipboard:error\" },\n { name: \"readPermission\", event: \"wcs-clipboard:read-permission-changed\" },\n { name: \"writePermission\", event: \"wcs-clipboard:write-permission-changed\" },\n { name: \"monitoring\", event: \"wcs-clipboard:monitoring-changed\" },\n { name: \"copied\", event: \"wcs-clipboard:copied\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"cut\", event: \"wcs-clipboard:cut\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"pasted\", event: \"wcs-clipboard:pasted\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"writeText\", async: true },\n { name: \"write\", async: true },\n { name: \"readText\", async: true },\n { name: \"read\", async: true },\n { name: \"startMonitor\" },\n { name: \"stopMonitor\" },\n ],\n };\n\n private _target: EventTarget;\n\n private _text: string | null = null;\n private _items: WcsClipboardReadItem[] | null = null;\n private _loading: boolean = false;\n private _error: WcsClipboardErrorDetail | null = null;\n private _readPermission: ClipboardPermissionState = \"prompt\";\n private _writePermission: ClipboardPermissionState = \"prompt\";\n\n private _monitoring: boolean = false;\n private _copied: string | null = null;\n private _cut: string | null = null;\n private _pasted: string | null = null;\n\n // Live PermissionStatus handles (when the Permissions API is available), kept\n // so the `change` listeners can be removed on dispose(). Read and write are\n // separate permissions, hence two handles.\n private _readStatus: PermissionStatus | null = null;\n private _writeStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards reinitPermission() so the first connect after\n // construction does not double-subscribe, while a reconnect after dispose()\n // does re-subscribe. (Mirrors GeolocationCore.)\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query round. Bumped by every\n // _initPermissions() and by dispose(). Each in-flight query captures it and,\n // on resolve, bails unless it is still current — so a query superseded by a\n // rapid (synchronous) disconnect→reconnect, or one that resolves after\n // dispose(), never attaches a listener.\n private _permGen: number = 0;\n\n // Monotonic id of the current async acquisition lifecycle (read/write),\n // bumped only by dispose(). Each command captures it at start; the resolution\n // bails (no setters) if it is stale, so an op that settles after the element\n // was disconnected does not dispatch wcs-clipboard:* on a torn-down element.\n // The Clipboard API has no AbortController, so a generation guard is the only\n // way to neutralize an in-flight op.\n private _acqGen: number = 0;\n\n // SSR (§3.8): resolves once the first permission probe settles, so the state\n // binder can await a real snapshot before reading. Set by _initPermissions();\n // Promise.resolve() when the Permissions API is unsupported (no async probe).\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Probe the permission states up front so observers see the real values\n // before the first read, then keep them live.\n this._initPermissions();\n }\n\n // SSR (§3.8): the first permission probe's settle promise.\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). Clipboard reads/writes are command-driven (they need a\n // user gesture), so observe() establishes no acquisition; it only (re)subscribes\n // to permission `change` events — idempotent while a subscription is live, and\n // reviving it after a dispose() (reconnect/reparent). Returns ready so the Shell\n // can expose it as connectedCallbackPromise.\n observe(): Promise<void> {\n this.reinitPermission();\n return this._ready;\n }\n\n get text(): string | null {\n return this._text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._items;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._error;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._writePermission;\n }\n\n get monitoring(): boolean {\n return this._monitoring;\n }\n\n get copied(): string | null {\n return this._copied;\n }\n\n get cut(): string | null {\n return this._cut;\n }\n\n get pasted(): string | null {\n return this._pasted;\n }\n\n // --- State setters with event dispatch ---\n\n // Deliberately NO same-value guard (unlike error/loading/permission/monitoring).\n // A read is a result event, not idempotent state: reading the same text twice is\n // two distinct user/command actions and must re-fire wcs-clipboard:read each time\n // so a `text:`/`items:` binding and command-result consumers see every read.\n private _setRead(detail: WcsClipboardReadDetail): void {\n this._text = detail.text;\n this._items = detail.items;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read\", {\n detail,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n if (this._loading === loading) return;\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsClipboardErrorDetail | null): void {\n // Same-value guard. `error` has no derived state, so suppressing redundant\n // null→null dispatches (e.g. a successful op clearing an already-null error)\n // avoids spurious events. Reference identity is sufficient: each failure\n // builds a fresh object, and the clear path always passes the literal null.\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _setReadPermission(permission: ClipboardPermissionState): void {\n if (this._readPermission === permission) return;\n this._readPermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setWritePermission(permission: ClipboardPermissionState): void {\n if (this._writePermission === permission) return;\n this._writePermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:write-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setMonitoring(monitoring: boolean): void {\n if (this._monitoring === monitoring) return;\n this._monitoring = monitoring;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:monitoring-changed\", {\n detail: monitoring,\n bubbles: true,\n }));\n }\n\n // Deliberately NO same-value guard on the copied/cut/pasted setters (unlike\n // error/loading/permission/monitoring above). These are events, not state:\n // copying the same text twice is two distinct user actions and must re-fire\n // both times so an event-token subscriber (`eventToken.pasted: ...`) sees each\n // occurrence. Do not add a `===` guard here.\n private _setCopied(text: string): void {\n this._copied = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:copied\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setCut(text: string): void {\n this._cut = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:cut\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setPasted(text: string): void {\n this._pasted = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:pasted\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n // --- Public API: write ---\n\n /**\n * Write plain text to the clipboard. Resolves once the write settles or fails\n * — never rejects: failures surface through `error`. Requires transient\n * activation (a user gesture), so call from a click handler / command-token.\n */\n writeText(text: string): Promise<void> {\n return this._runWrite(() => navigator.clipboard.writeText(text));\n }\n\n /**\n * Write rich `ClipboardItem`s (images, HTML, multiple MIME types) to the\n * clipboard. Resolves once the write settles or fails — never rejects.\n */\n write(items: ClipboardItem[]): Promise<void> {\n return this._runWrite(() => navigator.clipboard.write(items));\n }\n\n // --- Public API: read ---\n\n /**\n * Read plain text from the clipboard, publishing it via `text` and the\n * `wcs-clipboard:read` event. Resolves once the read settles or fails — never\n * rejects. Requires focus + read permission.\n */\n readText(): Promise<void> {\n return this._runRead(async () => {\n const text = await navigator.clipboard.readText();\n return { text, items: null };\n });\n }\n\n /**\n * Read rich `ClipboardItem`s from the clipboard, eagerly resolving every\n * representation to a `Blob`. A `text/plain` representation is also surfaced\n * via `text`. Resolves once the read settles or fails — never rejects.\n */\n read(): Promise<void> {\n return this._runRead(async () => {\n const items = await navigator.clipboard.read();\n return this._normalizeItems(items);\n });\n }\n\n // --- Public API: monitor ---\n\n /**\n * Begin monitoring document `copy` / `cut` / `paste` events, republishing\n * them as the `copied` / `cut` / `pasted` properties. Idempotent while already\n * monitoring (mirrors GeolocationCore.watch()).\n */\n startMonitor(): void {\n if (this._monitoring) return;\n this._setMonitoring(true);\n // §4 deviation: document-scoped Web API; no element-free alternative.\n // copy/cut/paste fire on `document`, so monitoring necessarily listens there\n // rather than on a Core-owned element. Registered as an allowed deviation.\n document.addEventListener(\"copy\", this._onCopy);\n document.addEventListener(\"cut\", this._onCut);\n document.addEventListener(\"paste\", this._onPaste);\n }\n\n stopMonitor(): void {\n this._removeMonitorListeners();\n this._setMonitoring(false);\n }\n\n // --- Permission lifecycle ---\n\n /**\n * Re-establish the permission `change` subscriptions after a dispose() — e.g.\n * the Shell element was disconnected and then reconnected (reparented). No-op\n * while a subscription is already live, so the first connect after\n * construction does not double-subscribe.\n */\n reinitPermission(): void {\n if (!this._permissionSubscribed) {\n this._initPermissions();\n }\n }\n\n /**\n * Detach the live permission `change` listeners and any monitor listeners, and\n * neutralize in-flight async ops. Call from the Shell's `disconnectedCallback`\n * so a removed element does not leak subscriptions or dispatch on a torn-down\n * element. A later reconnect can re-subscribe via reinitPermission().\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight permission query so its .then() bails instead of\n // attaching a listener after teardown.\n this._permGen++;\n // Invalidate any in-flight read/write so its resolution bails instead of\n // dispatching on a disconnected element.\n this._acqGen++;\n // Reset the loading shadow silently (no dispatch on a disposed element). The\n // bailed resolution will not clear it, and leaving it true would let the\n // same-value guard swallow the loading=true edge of the next op after a\n // reconnect.\n this._loading = false;\n if (this._readStatus) {\n this._readStatus.removeEventListener(\"change\", this._onReadChange);\n this._readStatus = null;\n }\n if (this._writeStatus) {\n this._writeStatus.removeEventListener(\"change\", this._onWriteChange);\n this._writeStatus = null;\n }\n // Remove monitor listeners silently. The Shell calls stopMonitor() before\n // dispose(), but a direct headless dispose() still tears them down.\n this._removeMonitorListeners();\n this._monitoring = false;\n }\n\n // --- Internal: write/read runners ---\n\n private _runWrite(op: () => Promise<void>): Promise<void> {\n return this._runOp(async () => {\n await op();\n return null;\n });\n }\n\n private _runRead(op: () => Promise<WcsClipboardReadDetail>): Promise<void> {\n return this._runOp(op);\n }\n\n /**\n * Shared async-op lifecycle for read/write: capability check, loading toggle,\n * generation guard, never-reject error handling. When `op` returns a read\n * detail it is published; when it returns null (a write) nothing is published.\n */\n private async _runOp(op: () => Promise<WcsClipboardReadDetail | null>): Promise<void> {\n if (!this._hasClipboard()) {\n this._setError(this._unsupportedError());\n return;\n }\n const gen = this._acqGen;\n this._setLoading(true);\n this._setError(null);\n try {\n const detail = await op();\n // Stale: the element was disposed (disconnected) while this op was in\n // flight. Drop it so a torn-down element never dispatches wcs-clipboard:*.\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n if (detail) this._setRead(detail);\n } catch (err) {\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n this._setError(this._normalizeError(err));\n }\n }\n\n // --- Internal: monitor handlers ---\n\n // During a `copy` / `cut` event the clipboard payload is not yet readable —\n // the browser returns an empty string for security reasons — so we report the\n // user's selected text (`document.getSelection().toString()`) instead. A page\n // that overrides the payload with a custom handler via clipboardData.setData()\n // is therefore NOT reflected here. (See README \"copy / cut text comes from the\n // selection\".) `paste` differs: clipboardData is readable, so _onPaste reads it.\n private _onCopy = (): void => {\n this._setCopied(this._selectionText());\n };\n\n private _onCut = (): void => {\n this._setCut(this._selectionText());\n };\n\n private _onPaste = (event: Event): void => {\n const data = (event as ClipboardEvent).clipboardData;\n const text = data ? data.getData(\"text/plain\") : \"\";\n this._setPasted(text);\n };\n\n private _removeMonitorListeners(): void {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n document.removeEventListener(\"copy\", this._onCopy);\n document.removeEventListener(\"cut\", this._onCut);\n document.removeEventListener(\"paste\", this._onPaste);\n }\n\n private _selectionText(): string {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n const selection = document.getSelection();\n return selection ? selection.toString() : \"\";\n }\n\n // --- Internal: permission ---\n\n private _initPermissions(): void {\n // The Permissions API is optional. When absent (or it rejects, e.g. Firefox\n // does not expose the clipboard permission names), report \"unsupported\" and\n // leave reads/writes to fail loudly via the error property if attempted.\n // Note: we deliberately do NOT set _permissionSubscribed here — there is no\n // live subscription to tear down, so reinitPermission() re-runs this branch\n // on every reconnect. That is harmless: the same-value guard in\n // _setReadPermission/_setWritePermission swallows the redundant\n // unsupported→unsupported dispatch. (Mirrors GeolocationCore.)\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n this._setReadPermission(\"unsupported\");\n this._setWritePermission(\"unsupported\");\n // No async probe: readiness is immediate (§3.8).\n this._ready = Promise.resolve();\n return;\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n const readProbe = this._queryPermission(\n \"clipboard-read\", gen,\n (s) => { this._readStatus = s; },\n (state) => this._setReadPermission(state),\n this._onReadChange,\n );\n const writeProbe = this._queryPermission(\n \"clipboard-write\", gen,\n (s) => { this._writeStatus = s; },\n (state) => this._setWritePermission(state),\n this._onWriteChange,\n );\n // SSR (§3.8): ready resolves once both initial permission probes settle.\n this._ready = Promise.all([readProbe, writeProbe]).then(() => undefined);\n }\n\n private _queryPermission(\n name: string,\n gen: number,\n assignStatus: (status: PermissionStatus) => void,\n setState: (state: ClipboardPermissionState) => void,\n onChange: (event: Event) => void,\n ): Promise<void> {\n return navigator.permissions.query({ name: name as PermissionName }).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the\n // current subscription attaches a listener.\n if (gen !== this._permGen) return;\n assignStatus(status);\n setState(status.state as ClipboardPermissionState);\n status.addEventListener(\"change\", onChange);\n },\n () => {\n if (gen !== this._permGen) return;\n setState(\"unsupported\");\n },\n );\n }\n\n private _onReadChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setReadPermission(status.state as ClipboardPermissionState);\n };\n\n private _onWriteChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setWritePermission(status.state as ClipboardPermissionState);\n };\n\n // --- Internal: normalization ---\n\n private _hasClipboard(): boolean {\n return typeof navigator !== \"undefined\" && !!navigator.clipboard;\n }\n\n private async _normalizeItems(items: ClipboardItem[]): Promise<WcsClipboardReadDetail> {\n // Resolve every representation of every item in parallel. getType() calls are\n // independent, so awaiting them serially only adds latency. The trade-off is\n // intentional and unchanged from the serial version: if any getType() rejects\n // the whole read errors (no partial success), consistent with the never-reject\n // design where a failed op surfaces a single `error` rather than a half-filled\n // snapshot. Order is preserved so the `text` pick below stays deterministic.\n const resolved = await Promise.all(\n items.map((item) =>\n Promise.all(item.types.map((type) => item.getType(type))).then((blobs) => ({ item, blobs })),\n ),\n );\n\n const normalized: WcsClipboardReadItem[] = [];\n let text: string | null = null;\n for (const { item, blobs } of resolved) {\n const data: Record<string, Blob> = {};\n item.types.forEach((type, i) => {\n data[type] = blobs[i];\n });\n // Surface the first text/plain representation through `text` for the\n // common \"read whatever text is there\" case (first item, first match).\n if (text === null) {\n const i = item.types.indexOf(\"text/plain\");\n if (i !== -1) {\n text = await blobs[i].text();\n }\n }\n normalized.push({ types: [...item.types], data });\n }\n return { text, items: normalized };\n }\n\n private _normalizeError(err: unknown): WcsClipboardErrorDetail {\n if (err instanceof Error) {\n // DOMException is an Error subclass; its `name` (NotAllowedError, etc.) is\n // the meaningful discriminator for consumers switching on failure kind.\n return { name: err.name, message: err.message };\n }\n return { name: \"Error\", message: String(err) };\n }\n\n private _unsupportedError(): WcsClipboardErrorDetail {\n return {\n name: \"NotSupportedError\",\n message: \"Clipboard API is not available in this environment.\",\n };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsClipboard } from \"./components/Clipboard.js\";\n\nlet registered = false;\n\n// Attribute names for the optional copy-on-click DOM trigger (clipboard.js-style\n// DX). The element carrying `data-clipboardtarget` points at a <wcs-clipboard>\n// by id; the text to copy comes from either a literal `data-clipboard-text` or\n// a `data-clipboard-from` CSS selector resolving to a source element.\nconst TEXT_ATTRIBUTE = \"data-clipboard-text\";\nconst FROM_ATTRIBUTE = \"data-clipboard-from\";\n\nfunction resolveText(triggerElement: Element): string | null {\n // Literal text wins when present (including an empty string — copying \"\" is a\n // legitimate request).\n if (triggerElement.hasAttribute(TEXT_ATTRIBUTE)) {\n return triggerElement.getAttribute(TEXT_ATTRIBUTE) ?? \"\";\n }\n const selector = triggerElement.getAttribute(FROM_ATTRIBUTE);\n if (!selector) return null;\n const source = document.querySelector(selector);\n if (!source) return null;\n // Read a form control's `value`; fall back to text content. A bare\n // `\"value\" in source` check is too broad — it also matches <button>,\n // <li value>, <progress>, etc. (which carry an unrelated `value`), copying\n // the wrong thing. Narrow to the text-bearing controls a user actually points\n // `data-clipboard-from` at; everything else falls through to textContent.\n if (\n source instanceof HTMLInputElement ||\n source instanceof HTMLTextAreaElement ||\n source instanceof HTMLSelectElement\n ) {\n return source.value;\n }\n return source.textContent ?? \"\";\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 clipboardId = triggerElement.getAttribute(config.triggerAttribute);\n if (!clipboardId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // WcsClipboard as a value (avoids a components ⇄ autoTrigger import cycle:\n // Clipboard.connectedCallback() calls registerAutoTrigger()). instanceof\n // against the customElements registry keeps the same identity guarantee.\n const ClipboardCtor = customElements.get(config.tagNames.clipboard);\n const clipboardElement = document.getElementById(clipboardId);\n if (!ClipboardCtor || !(clipboardElement instanceof ClipboardCtor)) return;\n\n const text = resolveText(triggerElement);\n // No resolvable source: leave the click alone (do not preventDefault) so the\n // element's default action is unaffected.\n if (text === null) return;\n\n // Suppress the default action so a copy can run without navigating. Intentional:\n // do not attach data-clipboardtarget to an element whose default action you\n // also want (real <a href> link). See README \"Optional DOM Triggering\".\n event.preventDefault();\n (clipboardElement as WcsClipboard).writeText(text);\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { ClipboardCore } from \"../core/ClipboardCore.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n// Named WcsClipboard (not `Clipboard`) so the class does not shadow the global\n// DOM `Clipboard` interface (the type of `navigator.clipboard`), matching the\n// <wcs-geo> WcsGeolocation / <wcs-ws> WcsWebSocket convention.\nexport class WcsClipboard extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...ClipboardCore.wcBindable,\n // Shell-level settable surface. `monitor` mirrors its boolean attribute\n // (reflects idempotently), following the <wcs-ws> / <wcs-geo> convention.\n // There is no momentary `trigger` property: writes need an argument (the\n // text/items), so element actions are driven via command-token\n // (`command.writeText: $command.copy`) or the DOM autoTrigger, not a\n // false→true boolean pulse.\n inputs: [\n { name: \"monitor\", attribute: \"monitor\" },\n ],\n // Commands are identical to the Core's — no rename is needed because the\n // `monitor` boolean attribute accessor does not collide with the\n // `startMonitor` / `stopMonitor` command names (unlike <wcs-geo>, whose\n // `watch` attribute forced the Core's `watch` command to `watchPosition`).\n commands: ClipboardCore.wcBindable.commands,\n };\n\n private _core: ClipboardCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n\n constructor() {\n super();\n this._core = new ClipboardCore(this);\n }\n\n // SSR (§4.4): the state binder awaits this before snapshotting, so the first\n // permission probe has settled. Backed by _core.observe() (see connectedCallback).\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n\n get monitor(): boolean {\n return this.hasAttribute(\"monitor\");\n }\n\n /**\n * Reflects the `monitor` boolean attribute only — it does NOT start or stop\n * monitoring by itself. The attribute is read at connect time (see\n * connectedCallback); toggling `el.monitor` after connect just flips the\n * attribute. To start/stop monitoring imperatively, call `startMonitor()` /\n * `stopMonitor()`.\n */\n set monitor(value: boolean) {\n if (value) {\n this.setAttribute(\"monitor\", \"\");\n } else {\n this.removeAttribute(\"monitor\");\n }\n }\n\n // --- Core delegated getters ---\n\n get text(): string | null {\n return this._core.text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._core.items;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._core.error;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._core.readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._core.writePermission;\n }\n\n get monitoring(): boolean {\n return this._core.monitoring;\n }\n\n get copied(): string | null {\n return this._core.copied;\n }\n\n get cut(): string | null {\n return this._core.cut;\n }\n\n get pasted(): string | null {\n return this._core.pasted;\n }\n\n // --- Commands ---\n\n writeText(text: string): Promise<void> {\n return this._core.writeText(text);\n }\n\n write(items: ClipboardItem[]): Promise<void> {\n return this._core.write(items);\n }\n\n readText(): Promise<void> {\n return this._core.readText();\n }\n\n read(): Promise<void> {\n return this._core.read();\n }\n\n startMonitor(): void {\n this._core.startMonitor();\n }\n\n stopMonitor(): void {\n this._core.stopMonitor();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // observe() revives permission tracking after a reconnect (reparenting) —\n // a no-op on the first connect since the constructor already subscribed — and\n // returns the readiness promise exposed as connectedCallbackPromise (§4.4).\n this._connectedCallbackPromise = this._core.observe();\n // Unlike <wcs-geo>, there is no connect-time acquisition: reads require a\n // user gesture, so the only connect-time action is optional monitoring.\n if (this.monitor) {\n this._core.startMonitor();\n }\n }\n\n disconnectedCallback(): void {\n this._core.stopMonitor();\n this._core.dispose();\n }\n}\n","import { WcsClipboard } from \"./components/Clipboard.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.clipboard)) {\n customElements.define(config.tagNames.clipboard, WcsClipboard);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapClipboard(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n"],"names":[],"mappings":"AAUA,MAAM,OAAO,GAAoB;AAC/B,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,gBAAgB,EAAE,sBAAsB;AACxC,IAAA,QAAQ,EAAE;AACR,QAAA,SAAS,EAAE,eAAe;AAC3B,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,C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A;IAC7D,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;AACA,IAAA,kBAAkB,EAAE;AACtB;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/ClipboardCore.ts","../src/autoTrigger.ts","../src/components/Clipboard.ts","../src/registerComponents.ts","../src/bootstrapClipboard.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n clipboard: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-clipboardtarget\",\n tagNames: {\n clipboard: \"wcs-clipboard\",\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 {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardReadDetail, WcsClipboardErrorDetail,\n} from \"../types.js\";\n\n/**\n * Headless clipboard primitive. A thin, framework-agnostic wrapper around the\n * Clipboard API exposed through the wc-bindable protocol.\n *\n * It has two surfaces, mirroring the two distinct shapes of clipboard access:\n * - **commands** — `writeText()` / `write()` push to the clipboard;\n * `readText()` / `read()` pull from it. These are the `state → element`\n * (command-token) and `element → state` (read result) paths. All four are\n * async and never reject: failures surface through the `error` property so\n * they flow into the declarative state, symmetrical with FetchCore /\n * GeolocationCore.\n * - **monitor** — `startMonitor()` / `stopMonitor()` subscribe to the document's\n * `copy` / `cut` / `paste` events and republish them as the `copied` / `cut` /\n * `pasted` properties (like TimerCore's continuous `start()` / `stop()`),\n * toggling the `monitoring` flag. This is the event-token showcase: a user\n * paste flows element → state declaratively.\n *\n * Clipboard also has permission gates, like GeolocationCore but doubled: read\n * and write are separate permissions (`clipboard-read` / `clipboard-write`).\n * `readPermission` / `writePermission` reflect `navigator.permissions.query`\n * (`prompt` / `granted` / `denied`, or `unsupported`) and track their live\n * `change` events.\n */\nexport class ClipboardCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"text\", event: \"wcs-clipboard:read\", getter: (e: Event) => (e as CustomEvent).detail.text },\n { name: \"items\", event: \"wcs-clipboard:read\", getter: (e: Event) => (e as CustomEvent).detail.items },\n { name: \"loading\", event: \"wcs-clipboard:loading-changed\" },\n { name: \"error\", event: \"wcs-clipboard:error\" },\n { name: \"readPermission\", event: \"wcs-clipboard:read-permission-changed\" },\n { name: \"writePermission\", event: \"wcs-clipboard:write-permission-changed\" },\n { name: \"monitoring\", event: \"wcs-clipboard:monitoring-changed\" },\n { name: \"copied\", event: \"wcs-clipboard:copied\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"cut\", event: \"wcs-clipboard:cut\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"pasted\", event: \"wcs-clipboard:pasted\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"writeText\", async: true },\n { name: \"write\", async: true },\n { name: \"readText\", async: true },\n { name: \"read\", async: true },\n { name: \"startMonitor\" },\n { name: \"stopMonitor\" },\n ],\n };\n\n private _target: EventTarget;\n\n private _text: string | null = null;\n private _items: WcsClipboardReadItem[] | null = null;\n private _loading: boolean = false;\n private _error: WcsClipboardErrorDetail | null = null;\n private _readPermission: ClipboardPermissionState = \"prompt\";\n private _writePermission: ClipboardPermissionState = \"prompt\";\n\n private _monitoring: boolean = false;\n private _copied: string | null = null;\n private _cut: string | null = null;\n private _pasted: string | null = null;\n\n // Live PermissionStatus handles (when the Permissions API is available), kept\n // so the `change` listeners can be removed on dispose(). Read and write are\n // separate permissions, hence two handles.\n private _readStatus: PermissionStatus | null = null;\n private _writeStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards reinitPermission() so the first connect after\n // construction does not double-subscribe, while a reconnect after dispose()\n // does re-subscribe. (Mirrors GeolocationCore.)\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query round. Bumped by every\n // _initPermissions() and by dispose(). Each in-flight query captures it and,\n // on resolve, bails unless it is still current — so a query superseded by a\n // rapid (synchronous) disconnect→reconnect, or one that resolves after\n // dispose(), never attaches a listener.\n private _permGen: number = 0;\n\n // Monotonic id of the current async acquisition lifecycle (read/write),\n // bumped only by dispose(). Each command captures it at start; the resolution\n // bails (no setters) if it is stale, so an op that settles after the element\n // was disconnected does not dispatch wcs-clipboard:* on a torn-down element.\n // The Clipboard API has no AbortController, so a generation guard is the only\n // way to neutralize an in-flight op.\n private _acqGen: number = 0;\n\n // SSR (§3.8): resolves once the first permission probe settles, so the state\n // binder can await a real snapshot before reading. Set by _initPermissions();\n // Promise.resolve() when the Permissions API is unsupported (no async probe).\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Probe the permission states up front so observers see the real values\n // before the first read, then keep them live.\n this._initPermissions();\n }\n\n // SSR (§3.8): the first permission probe's settle promise.\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). Clipboard reads/writes are command-driven (they need a\n // user gesture), so observe() establishes no acquisition; it only (re)subscribes\n // to permission `change` events — idempotent while a subscription is live, and\n // reviving it after a dispose() (reconnect/reparent). Returns ready so the Shell\n // can expose it as connectedCallbackPromise.\n observe(): Promise<void> {\n this.reinitPermission();\n return this._ready;\n }\n\n get text(): string | null {\n return this._text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._items;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._error;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._writePermission;\n }\n\n get monitoring(): boolean {\n return this._monitoring;\n }\n\n get copied(): string | null {\n return this._copied;\n }\n\n get cut(): string | null {\n return this._cut;\n }\n\n get pasted(): string | null {\n return this._pasted;\n }\n\n // --- State setters with event dispatch ---\n\n // Deliberately NO same-value guard (unlike error/loading/permission/monitoring).\n // A read is a result event, not idempotent state: reading the same text twice is\n // two distinct user/command actions and must re-fire wcs-clipboard:read each time\n // so a `text:`/`items:` binding and command-result consumers see every read.\n private _setRead(detail: WcsClipboardReadDetail): void {\n this._text = detail.text;\n this._items = detail.items;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read\", {\n detail,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n if (this._loading === loading) return;\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsClipboardErrorDetail | null): void {\n // Same-value guard. `error` has no derived state, so suppressing redundant\n // null→null dispatches (e.g. a successful op clearing an already-null error)\n // avoids spurious events. Reference identity is sufficient: each failure\n // builds a fresh object, and the clear path always passes the literal null.\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _setReadPermission(permission: ClipboardPermissionState): void {\n if (this._readPermission === permission) return;\n this._readPermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setWritePermission(permission: ClipboardPermissionState): void {\n if (this._writePermission === permission) return;\n this._writePermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:write-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setMonitoring(monitoring: boolean): void {\n if (this._monitoring === monitoring) return;\n this._monitoring = monitoring;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:monitoring-changed\", {\n detail: monitoring,\n bubbles: true,\n }));\n }\n\n // Deliberately NO same-value guard on the copied/cut/pasted setters (unlike\n // error/loading/permission/monitoring above). These are events, not state:\n // copying the same text twice is two distinct user actions and must re-fire\n // both times so an event-token subscriber (`eventToken.pasted: ...`) sees each\n // occurrence. Do not add a `===` guard here.\n private _setCopied(text: string): void {\n this._copied = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:copied\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setCut(text: string): void {\n this._cut = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:cut\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setPasted(text: string): void {\n this._pasted = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:pasted\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n // --- Public API: write ---\n\n /**\n * Write plain text to the clipboard. Resolves once the write settles or fails\n * — never rejects: failures surface through `error`. Requires transient\n * activation (a user gesture), so call from a click handler / command-token.\n */\n writeText(text: string): Promise<void> {\n return this._runWrite(() => navigator.clipboard.writeText(text));\n }\n\n /**\n * Write rich `ClipboardItem`s (images, HTML, multiple MIME types) to the\n * clipboard. Resolves once the write settles or fails — never rejects.\n */\n write(items: ClipboardItem[]): Promise<void> {\n return this._runWrite(() => navigator.clipboard.write(items));\n }\n\n // --- Public API: read ---\n\n /**\n * Read plain text from the clipboard, publishing it via `text` and the\n * `wcs-clipboard:read` event. Resolves once the read settles or fails — never\n * rejects. Requires focus + read permission.\n */\n readText(): Promise<void> {\n return this._runRead(async () => {\n const text = await navigator.clipboard.readText();\n return { text, items: null };\n });\n }\n\n /**\n * Read rich `ClipboardItem`s from the clipboard, eagerly resolving every\n * representation to a `Blob`. A `text/plain` representation is also surfaced\n * via `text`. Resolves once the read settles or fails — never rejects.\n */\n read(): Promise<void> {\n return this._runRead(async () => {\n const items = await navigator.clipboard.read();\n return this._normalizeItems(items);\n });\n }\n\n // --- Public API: monitor ---\n\n /**\n * Begin monitoring document `copy` / `cut` / `paste` events, republishing\n * them as the `copied` / `cut` / `pasted` properties. Idempotent while already\n * monitoring (mirrors GeolocationCore.watch()).\n */\n startMonitor(): void {\n if (this._monitoring) return;\n this._setMonitoring(true);\n // §4 deviation: document-scoped Web API; no element-free alternative.\n // copy/cut/paste fire on `document`, so monitoring necessarily listens there\n // rather than on a Core-owned element. Registered as an allowed deviation.\n document.addEventListener(\"copy\", this._onCopy);\n document.addEventListener(\"cut\", this._onCut);\n document.addEventListener(\"paste\", this._onPaste);\n }\n\n stopMonitor(): void {\n this._removeMonitorListeners();\n this._setMonitoring(false);\n }\n\n // --- Permission lifecycle ---\n\n /**\n * Re-establish the permission `change` subscriptions after a dispose() — e.g.\n * the Shell element was disconnected and then reconnected (reparented). No-op\n * while a subscription is already live, so the first connect after\n * construction does not double-subscribe.\n */\n reinitPermission(): void {\n if (!this._permissionSubscribed) {\n this._initPermissions();\n }\n }\n\n /**\n * Detach the live permission `change` listeners and any monitor listeners, and\n * neutralize in-flight async ops. Call from the Shell's `disconnectedCallback`\n * so a removed element does not leak subscriptions or dispatch on a torn-down\n * element. A later reconnect can re-subscribe via reinitPermission().\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight permission query so its .then() bails instead of\n // attaching a listener after teardown.\n this._permGen++;\n // Invalidate any in-flight read/write so its resolution bails instead of\n // dispatching on a disconnected element.\n this._acqGen++;\n // Reset the loading shadow silently (no dispatch on a disposed element). The\n // bailed resolution will not clear it, and leaving it true would let the\n // same-value guard swallow the loading=true edge of the next op after a\n // reconnect.\n this._loading = false;\n if (this._readStatus) {\n this._readStatus.removeEventListener(\"change\", this._onReadChange);\n this._readStatus = null;\n }\n if (this._writeStatus) {\n this._writeStatus.removeEventListener(\"change\", this._onWriteChange);\n this._writeStatus = null;\n }\n // Remove monitor listeners silently. The Shell calls stopMonitor() before\n // dispose(), but a direct headless dispose() still tears them down.\n this._removeMonitorListeners();\n this._monitoring = false;\n }\n\n // --- Internal: write/read runners ---\n\n private _runWrite(op: () => Promise<void>): Promise<void> {\n return this._runOp(async () => {\n await op();\n return null;\n });\n }\n\n private _runRead(op: () => Promise<WcsClipboardReadDetail>): Promise<void> {\n return this._runOp(op);\n }\n\n /**\n * Shared async-op lifecycle for read/write: capability check, loading toggle,\n * generation guard, never-reject error handling. When `op` returns a read\n * detail it is published; when it returns null (a write) nothing is published.\n */\n private async _runOp(op: () => Promise<WcsClipboardReadDetail | null>): Promise<void> {\n if (!this._hasClipboard()) {\n this._setError(this._unsupportedError());\n return;\n }\n const gen = this._acqGen;\n this._setLoading(true);\n this._setError(null);\n try {\n const detail = await op();\n // Stale: the element was disposed (disconnected) while this op was in\n // flight. Drop it so a torn-down element never dispatches wcs-clipboard:*.\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n if (detail) this._setRead(detail);\n } catch (err) {\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n this._setError(this._normalizeError(err));\n }\n }\n\n // --- Internal: monitor handlers ---\n\n // During a `copy` / `cut` event the clipboard payload is not yet readable —\n // the browser returns an empty string for security reasons — so we report the\n // user's selected text (`document.getSelection().toString()`) instead. A page\n // that overrides the payload with a custom handler via clipboardData.setData()\n // is therefore NOT reflected here. (See README \"copy / cut text comes from the\n // selection\".) `paste` differs: clipboardData is readable, so _onPaste reads it.\n private _onCopy = (): void => {\n this._setCopied(this._selectionText());\n };\n\n private _onCut = (): void => {\n this._setCut(this._selectionText());\n };\n\n private _onPaste = (event: Event): void => {\n const data = (event as ClipboardEvent).clipboardData;\n const text = data ? data.getData(\"text/plain\") : \"\";\n this._setPasted(text);\n };\n\n private _removeMonitorListeners(): void {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n document.removeEventListener(\"copy\", this._onCopy);\n document.removeEventListener(\"cut\", this._onCut);\n document.removeEventListener(\"paste\", this._onPaste);\n }\n\n private _selectionText(): string {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n const selection = document.getSelection();\n return selection ? selection.toString() : \"\";\n }\n\n // --- Internal: permission ---\n\n private _initPermissions(): void {\n // The Permissions API is optional. When absent (or it rejects, e.g. Firefox\n // does not expose the clipboard permission names), report \"unsupported\" and\n // leave reads/writes to fail loudly via the error property if attempted.\n // Note: we deliberately do NOT set _permissionSubscribed here — there is no\n // live subscription to tear down, so reinitPermission() re-runs this branch\n // on every reconnect. That is harmless: the same-value guard in\n // _setReadPermission/_setWritePermission swallows the redundant\n // unsupported→unsupported dispatch. (Mirrors GeolocationCore.)\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n this._setReadPermission(\"unsupported\");\n this._setWritePermission(\"unsupported\");\n // No async probe: readiness is immediate (§3.8).\n this._ready = Promise.resolve();\n return;\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n const readProbe = this._queryPermission(\n \"clipboard-read\", gen,\n (s) => { this._readStatus = s; },\n (state) => this._setReadPermission(state),\n this._onReadChange,\n );\n const writeProbe = this._queryPermission(\n \"clipboard-write\", gen,\n (s) => { this._writeStatus = s; },\n (state) => this._setWritePermission(state),\n this._onWriteChange,\n );\n // SSR (§3.8): ready resolves once both initial permission probes settle.\n this._ready = Promise.all([readProbe, writeProbe]).then(() => undefined);\n }\n\n private _queryPermission(\n name: string,\n gen: number,\n assignStatus: (status: PermissionStatus) => void,\n setState: (state: ClipboardPermissionState) => void,\n onChange: (event: Event) => void,\n ): Promise<void> {\n return navigator.permissions.query({ name: name as PermissionName }).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the\n // current subscription attaches a listener.\n if (gen !== this._permGen) return;\n assignStatus(status);\n setState(status.state as ClipboardPermissionState);\n status.addEventListener(\"change\", onChange);\n },\n () => {\n if (gen !== this._permGen) return;\n setState(\"unsupported\");\n },\n );\n }\n\n private _onReadChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setReadPermission(status.state as ClipboardPermissionState);\n };\n\n private _onWriteChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setWritePermission(status.state as ClipboardPermissionState);\n };\n\n // --- Internal: normalization ---\n\n private _hasClipboard(): boolean {\n return typeof navigator !== \"undefined\" && !!navigator.clipboard;\n }\n\n private async _normalizeItems(items: ClipboardItem[]): Promise<WcsClipboardReadDetail> {\n // Resolve every representation of every item in parallel. getType() calls are\n // independent, so awaiting them serially only adds latency. The trade-off is\n // intentional and unchanged from the serial version: if any getType() rejects\n // the whole read errors (no partial success), consistent with the never-reject\n // design where a failed op surfaces a single `error` rather than a half-filled\n // snapshot. Order is preserved so the `text` pick below stays deterministic.\n const resolved = await Promise.all(\n items.map((item) =>\n Promise.all(item.types.map((type) => item.getType(type))).then((blobs) => ({ item, blobs })),\n ),\n );\n\n const normalized: WcsClipboardReadItem[] = [];\n let text: string | null = null;\n for (const { item, blobs } of resolved) {\n const data: Record<string, Blob> = {};\n item.types.forEach((type, i) => {\n data[type] = blobs[i];\n });\n // Surface the first text/plain representation through `text` for the\n // common \"read whatever text is there\" case (first item, first match).\n if (text === null) {\n const i = item.types.indexOf(\"text/plain\");\n if (i !== -1) {\n text = await blobs[i].text();\n }\n }\n normalized.push({ types: [...item.types], data });\n }\n return { text, items: normalized };\n }\n\n private _normalizeError(err: unknown): WcsClipboardErrorDetail {\n if (err instanceof Error) {\n // DOMException is an Error subclass; its `name` (NotAllowedError, etc.) is\n // the meaningful discriminator for consumers switching on failure kind.\n return { name: err.name, message: err.message };\n }\n return { name: \"Error\", message: String(err) };\n }\n\n private _unsupportedError(): WcsClipboardErrorDetail {\n return {\n name: \"NotSupportedError\",\n message: \"Clipboard API is not available in this environment.\",\n };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsClipboard } from \"./components/Clipboard.js\";\n\nlet registered = false;\n\n// Attribute names for the optional copy-on-click DOM trigger (clipboard.js-style\n// DX). The element carrying `data-clipboardtarget` points at a <wcs-clipboard>\n// by id; the text to copy comes from either a literal `data-clipboard-text` or\n// a `data-clipboard-from` CSS selector resolving to a source element.\nconst TEXT_ATTRIBUTE = \"data-clipboard-text\";\nconst FROM_ATTRIBUTE = \"data-clipboard-from\";\n\nfunction resolveText(triggerElement: Element): string | null {\n // Literal text wins when present (including an empty string — copying \"\" is a\n // legitimate request).\n if (triggerElement.hasAttribute(TEXT_ATTRIBUTE)) {\n return triggerElement.getAttribute(TEXT_ATTRIBUTE) ?? \"\";\n }\n const selector = triggerElement.getAttribute(FROM_ATTRIBUTE);\n if (!selector) return null;\n const source = document.querySelector(selector);\n if (!source) return null;\n // Read a form control's `value`; fall back to text content. A bare\n // `\"value\" in source` check is too broad — it also matches <button>,\n // <li value>, <progress>, etc. (which carry an unrelated `value`), copying\n // the wrong thing. Narrow to the text-bearing controls a user actually points\n // `data-clipboard-from` at; everything else falls through to textContent.\n if (\n source instanceof HTMLInputElement ||\n source instanceof HTMLTextAreaElement ||\n source instanceof HTMLSelectElement\n ) {\n return source.value;\n }\n return source.textContent ?? \"\";\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 clipboardId = triggerElement.getAttribute(config.triggerAttribute);\n if (!clipboardId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // WcsClipboard as a value (avoids a components ⇄ autoTrigger import cycle:\n // Clipboard.connectedCallback() calls registerAutoTrigger()). instanceof\n // against the customElements registry keeps the same identity guarantee.\n const ClipboardCtor = customElements.get(config.tagNames.clipboard);\n const clipboardElement = document.getElementById(clipboardId);\n if (!ClipboardCtor || !(clipboardElement instanceof ClipboardCtor)) return;\n\n const text = resolveText(triggerElement);\n // No resolvable source: leave the click alone (do not preventDefault) so the\n // element's default action is unaffected.\n if (text === null) return;\n\n // Suppress the default action so a copy can run without navigating. Intentional:\n // do not attach data-clipboardtarget to an element whose default action you\n // also want (real <a href> link). See README \"Optional DOM Triggering\".\n event.preventDefault();\n (clipboardElement as WcsClipboard).writeText(text);\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { ClipboardCore } from \"../core/ClipboardCore.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n// Named WcsClipboard (not `Clipboard`) so the class does not shadow the global\n// DOM `Clipboard` interface (the type of `navigator.clipboard`), matching the\n// <wcs-geo> WcsGeolocation / <wcs-ws> WcsWebSocket convention.\nexport class WcsClipboard extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...ClipboardCore.wcBindable,\n // Shell-level settable surface. `monitor` mirrors its boolean attribute\n // (reflects idempotently), following the <wcs-ws> / <wcs-geo> convention.\n // There is no momentary `trigger` property: writes need an argument (the\n // text/items), so element actions are driven via command-token\n // (`command.writeText: $command.copy`) or the DOM autoTrigger, not a\n // false→true boolean pulse.\n inputs: [\n { name: \"monitor\", attribute: \"monitor\" },\n ],\n // Commands are identical to the Core's — no rename is needed because the\n // `monitor` boolean attribute accessor does not collide with the\n // `startMonitor` / `stopMonitor` command names (unlike <wcs-geo>, whose\n // `watch` attribute forced the Core's `watch` command to `watchPosition`).\n commands: ClipboardCore.wcBindable.commands,\n };\n\n private _core: ClipboardCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new ClipboardCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-clipboard:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-clipboard:monitoring-changed\": (d) => ({ monitoring: d === true }),\n \"wcs-clipboard:error\": (d) => ({ error: d != null }),\n });\n }\n\n // SSR (§4.4): the state binder awaits this before snapshotting, so the first\n // permission probe has settled. Backed by _core.observe() (see connectedCallback).\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\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 // --- Attribute accessors ---\n\n get monitor(): boolean {\n return this.hasAttribute(\"monitor\");\n }\n\n /**\n * Reflects the `monitor` boolean attribute only — it does NOT start or stop\n * monitoring by itself. The attribute is read at connect time (see\n * connectedCallback); toggling `el.monitor` after connect just flips the\n * attribute. To start/stop monitoring imperatively, call `startMonitor()` /\n * `stopMonitor()`.\n */\n set monitor(value: boolean) {\n if (value) {\n this.setAttribute(\"monitor\", \"\");\n } else {\n this.removeAttribute(\"monitor\");\n }\n }\n\n // --- Core delegated getters ---\n\n get text(): string | null {\n return this._core.text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._core.items;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._core.error;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._core.readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._core.writePermission;\n }\n\n get monitoring(): boolean {\n return this._core.monitoring;\n }\n\n get copied(): string | null {\n return this._core.copied;\n }\n\n get cut(): string | null {\n return this._core.cut;\n }\n\n get pasted(): string | null {\n return this._core.pasted;\n }\n\n // --- Commands ---\n\n writeText(text: string): Promise<void> {\n return this._core.writeText(text);\n }\n\n write(items: ClipboardItem[]): Promise<void> {\n return this._core.write(items);\n }\n\n readText(): Promise<void> {\n return this._core.readText();\n }\n\n read(): Promise<void> {\n return this._core.read();\n }\n\n startMonitor(): void {\n this._core.startMonitor();\n }\n\n stopMonitor(): void {\n this._core.stopMonitor();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // observe() revives permission tracking after a reconnect (reparenting) —\n // a no-op on the first connect since the constructor already subscribed — and\n // returns the readiness promise exposed as connectedCallbackPromise (§4.4).\n this._connectedCallbackPromise = this._core.observe();\n // Unlike <wcs-geo>, there is no connect-time acquisition: reads require a\n // user gesture, so the only connect-time action is optional monitoring.\n if (this.monitor) {\n this._core.startMonitor();\n }\n }\n\n disconnectedCallback(): void {\n this._core.stopMonitor();\n this._core.dispose();\n }\n}\n","import { WcsClipboard } from \"./components/Clipboard.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.clipboard)) {\n customElements.define(config.tagNames.clipboard, WcsClipboard);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapClipboard(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n"],"names":[],"mappings":"AAUA,MAAM,OAAO,GAAoB;AAC/B,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,gBAAgB,EAAE,sBAAsB;AACxC,IAAA,QAAQ,EAAE;AACR,QAAA,SAAS,EAAE,eAAe;AAC3B,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,KAAK,CAAC,GAAG,CAAC,GAAG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AI,CAAC,KAAK,CAAC,OAAO,EAAE;;;AAGrD,QAAA,IAAI,IAAI,CAAC,OAAO,EAAE;AAChB,YAAA,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;QAC3B;IACF;IAEA,oBAAoB,GAAA;AAClB,QAAA,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;AACxB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACtB;;;SCxMc,kBAAkB,GAAA;AAChC,IAAA,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QAClD,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IAChE;AACF;;ACHM,SAAU,kBAAkB,CAAC,UAA4B,EAAA;IAC7D,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;AACA,IAAA,kBAAkB,EAAE;AACtB;;;;"}
@@ -1,2 +1,2 @@
1
- const t={autoTrigger:!0,triggerAttribute:"data-clipboardtarget",tagNames:{clipboard:"wcs-clipboard"}};function e(t){if(null===t||"object"!=typeof t)return t;Object.freeze(t);for(const r of Object.keys(t))e(t[r]);return t}function r(t){if(null===t||"object"!=typeof t)return t;const e={};for(const i of Object.keys(t))e[i]=r(t[i]);return e}let i=null;const s=t;function n(){return i||(i=e(r(t))),i}class o extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"text",event:"wcs-clipboard:read",getter:t=>t.detail.text},{name:"items",event:"wcs-clipboard:read",getter:t=>t.detail.items},{name:"loading",event:"wcs-clipboard:loading-changed"},{name:"error",event:"wcs-clipboard:error"},{name:"readPermission",event:"wcs-clipboard:read-permission-changed"},{name:"writePermission",event:"wcs-clipboard:write-permission-changed"},{name:"monitoring",event:"wcs-clipboard:monitoring-changed"},{name:"copied",event:"wcs-clipboard:copied",getter:t=>t.detail},{name:"cut",event:"wcs-clipboard:cut",getter:t=>t.detail},{name:"pasted",event:"wcs-clipboard:pasted",getter:t=>t.detail}],commands:[{name:"writeText",async:!0},{name:"write",async:!0},{name:"readText",async:!0},{name:"read",async:!0},{name:"startMonitor"},{name:"stopMonitor"}]};_target;_text=null;_items=null;_loading=!1;_error=null;_readPermission="prompt";_writePermission="prompt";_monitoring=!1;_copied=null;_cut=null;_pasted=null;_readStatus=null;_writeStatus=null;_permissionSubscribed=!1;_permGen=0;_acqGen=0;_ready=Promise.resolve();constructor(t){super(),this._target=t??this,this._initPermissions()}get ready(){return this._ready}observe(){return this.reinitPermission(),this._ready}get text(){return this._text}get items(){return this._items}get loading(){return this._loading}get error(){return this._error}get readPermission(){return this._readPermission}get writePermission(){return this._writePermission}get monitoring(){return this._monitoring}get copied(){return this._copied}get cut(){return this._cut}get pasted(){return this._pasted}_setRead(t){this._text=t.text,this._items=t.items,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:read",{detail:t,bubbles:!0}))}_setLoading(t){this._loading!==t&&(this._loading=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:loading-changed",{detail:t,bubbles:!0})))}_setError(t){this._error!==t&&(this._error=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:error",{detail:t,bubbles:!0})))}_setReadPermission(t){this._readPermission!==t&&(this._readPermission=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:read-permission-changed",{detail:t,bubbles:!0})))}_setWritePermission(t){this._writePermission!==t&&(this._writePermission=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:write-permission-changed",{detail:t,bubbles:!0})))}_setMonitoring(t){this._monitoring!==t&&(this._monitoring=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:monitoring-changed",{detail:t,bubbles:!0})))}_setCopied(t){this._copied=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:copied",{detail:t,bubbles:!0}))}_setCut(t){this._cut=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:cut",{detail:t,bubbles:!0}))}_setPasted(t){this._pasted=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:pasted",{detail:t,bubbles:!0}))}writeText(t){return this._runWrite(()=>navigator.clipboard.writeText(t))}write(t){return this._runWrite(()=>navigator.clipboard.write(t))}readText(){return this._runRead(async()=>({text:await navigator.clipboard.readText(),items:null}))}read(){return this._runRead(async()=>{const t=await navigator.clipboard.read();return this._normalizeItems(t)})}startMonitor(){this._monitoring||(this._setMonitoring(!0),document.addEventListener("copy",this._onCopy),document.addEventListener("cut",this._onCut),document.addEventListener("paste",this._onPaste))}stopMonitor(){this._removeMonitorListeners(),this._setMonitoring(!1)}reinitPermission(){this._permissionSubscribed||this._initPermissions()}dispose(){this._permissionSubscribed=!1,this._permGen++,this._acqGen++,this._loading=!1,this._readStatus&&(this._readStatus.removeEventListener("change",this._onReadChange),this._readStatus=null),this._writeStatus&&(this._writeStatus.removeEventListener("change",this._onWriteChange),this._writeStatus=null),this._removeMonitorListeners(),this._monitoring=!1}_runWrite(t){return this._runOp(async()=>(await t(),null))}_runRead(t){return this._runOp(t)}async _runOp(t){if(!this._hasClipboard())return void this._setError(this._unsupportedError());const e=this._acqGen;this._setLoading(!0),this._setError(null);try{const r=await t();if(e!==this._acqGen)return;this._setLoading(!1),r&&this._setRead(r)}catch(t){if(e!==this._acqGen)return;this._setLoading(!1),this._setError(this._normalizeError(t))}}_onCopy=()=>{this._setCopied(this._selectionText())};_onCut=()=>{this._setCut(this._selectionText())};_onPaste=t=>{const e=t.clipboardData,r=e?e.getData("text/plain"):"";this._setPasted(r)};_removeMonitorListeners(){document.removeEventListener("copy",this._onCopy),document.removeEventListener("cut",this._onCut),document.removeEventListener("paste",this._onPaste)}_selectionText(){const t=document.getSelection();return t?t.toString():""}_initPermissions(){if("undefined"==typeof navigator||!navigator.permissions||"function"!=typeof navigator.permissions.query)return this._setReadPermission("unsupported"),this._setWritePermission("unsupported"),void(this._ready=Promise.resolve());this._permissionSubscribed=!0;const t=++this._permGen,e=this._queryPermission("clipboard-read",t,t=>{this._readStatus=t},t=>this._setReadPermission(t),this._onReadChange),r=this._queryPermission("clipboard-write",t,t=>{this._writeStatus=t},t=>this._setWritePermission(t),this._onWriteChange);this._ready=Promise.all([e,r]).then(()=>{})}_queryPermission(t,e,r,i,s){return navigator.permissions.query({name:t}).then(t=>{e===this._permGen&&(r(t),i(t.state),t.addEventListener("change",s))},()=>{e===this._permGen&&i("unsupported")})}_onReadChange=t=>{const e=t.target;this._setReadPermission(e.state)};_onWriteChange=t=>{const e=t.target;this._setWritePermission(e.state)};_hasClipboard(){return"undefined"!=typeof navigator&&!!navigator.clipboard}async _normalizeItems(t){const e=await Promise.all(t.map(t=>Promise.all(t.types.map(e=>t.getType(e))).then(e=>({item:t,blobs:e})))),r=[];let i=null;for(const{item:t,blobs:s}of e){const e={};if(t.types.forEach((t,r)=>{e[t]=s[r]}),null===i){const e=t.types.indexOf("text/plain");-1!==e&&(i=await s[e].text())}r.push({types:[...t.types],data:e})}return{text:i,items:r}}_normalizeError(t){return t instanceof Error?{name:t.name,message:t.message}:{name:"Error",message:String(t)}}_unsupportedError(){return{name:"NotSupportedError",message:"Clipboard API is not available in this environment."}}}let a=!1;const c="data-clipboard-text";function d(t){const e=t.target;if(!(e instanceof Element))return;const r=e.closest(`[${s.triggerAttribute}]`);if(!r)return;const i=r.getAttribute(s.triggerAttribute);if(!i)return;const n=customElements.get(s.tagNames.clipboard),o=document.getElementById(i);if(!(n&&o instanceof n))return;const a=function(t){if(t.hasAttribute(c))return t.getAttribute(c)??"";const e=t.getAttribute("data-clipboard-from");if(!e)return null;const r=document.querySelector(e);return r?r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement?r.value:r.textContent??"":null}(r);null!==a&&(t.preventDefault(),o.writeText(a))}class u extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...o.wcBindable,inputs:[{name:"monitor",attribute:"monitor"}],commands:o.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();constructor(){super(),this._core=new o(this)}get connectedCallbackPromise(){return this._connectedCallbackPromise}get monitor(){return this.hasAttribute("monitor")}set monitor(t){t?this.setAttribute("monitor",""):this.removeAttribute("monitor")}get text(){return this._core.text}get items(){return this._core.items}get loading(){return this._core.loading}get error(){return this._core.error}get readPermission(){return this._core.readPermission}get writePermission(){return this._core.writePermission}get monitoring(){return this._core.monitoring}get copied(){return this._core.copied}get cut(){return this._core.cut}get pasted(){return this._core.pasted}writeText(t){return this._core.writeText(t)}write(t){return this._core.write(t)}readText(){return this._core.readText()}read(){return this._core.read()}startMonitor(){this._core.startMonitor()}stopMonitor(){this._core.stopMonitor()}connectedCallback(){this.style.display="none",s.autoTrigger&&(a||(a=!0,document.addEventListener("click",d))),this._connectedCallbackPromise=this._core.observe(),this.monitor&&this._core.startMonitor()}disconnectedCallback(){this._core.stopMonitor(),this._core.dispose()}}function m(e){var r;e&&("boolean"==typeof(r=e).autoTrigger&&(t.autoTrigger=r.autoTrigger),"string"==typeof r.triggerAttribute&&(t.triggerAttribute=r.triggerAttribute),r.tagNames&&Object.assign(t.tagNames,r.tagNames),i=null),customElements.get(s.tagNames.clipboard)||customElements.define(s.tagNames.clipboard,u)}export{o as ClipboardCore,u as WcsClipboard,m as bootstrapClipboard,n as getConfig};
1
+ const t={autoTrigger:!0,triggerAttribute:"data-clipboardtarget",tagNames:{clipboard:"wcs-clipboard"}};function e(t){if(null===t||"object"!=typeof t)return t;Object.freeze(t);for(const r of Object.keys(t))e(t[r]);return t}function r(t){if(null===t||"object"!=typeof t)return t;const e={};for(const i of Object.keys(t))e[i]=r(t[i]);return e}let i=null;const s=t;function n(){return i||(i=e(r(t))),i}class o extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"text",event:"wcs-clipboard:read",getter:t=>t.detail.text},{name:"items",event:"wcs-clipboard:read",getter:t=>t.detail.items},{name:"loading",event:"wcs-clipboard:loading-changed"},{name:"error",event:"wcs-clipboard:error"},{name:"readPermission",event:"wcs-clipboard:read-permission-changed"},{name:"writePermission",event:"wcs-clipboard:write-permission-changed"},{name:"monitoring",event:"wcs-clipboard:monitoring-changed"},{name:"copied",event:"wcs-clipboard:copied",getter:t=>t.detail},{name:"cut",event:"wcs-clipboard:cut",getter:t=>t.detail},{name:"pasted",event:"wcs-clipboard:pasted",getter:t=>t.detail}],commands:[{name:"writeText",async:!0},{name:"write",async:!0},{name:"readText",async:!0},{name:"read",async:!0},{name:"startMonitor"},{name:"stopMonitor"}]};_target;_text=null;_items=null;_loading=!1;_error=null;_readPermission="prompt";_writePermission="prompt";_monitoring=!1;_copied=null;_cut=null;_pasted=null;_readStatus=null;_writeStatus=null;_permissionSubscribed=!1;_permGen=0;_acqGen=0;_ready=Promise.resolve();constructor(t){super(),this._target=t??this,this._initPermissions()}get ready(){return this._ready}observe(){return this.reinitPermission(),this._ready}get text(){return this._text}get items(){return this._items}get loading(){return this._loading}get error(){return this._error}get readPermission(){return this._readPermission}get writePermission(){return this._writePermission}get monitoring(){return this._monitoring}get copied(){return this._copied}get cut(){return this._cut}get pasted(){return this._pasted}_setRead(t){this._text=t.text,this._items=t.items,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:read",{detail:t,bubbles:!0}))}_setLoading(t){this._loading!==t&&(this._loading=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:loading-changed",{detail:t,bubbles:!0})))}_setError(t){this._error!==t&&(this._error=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:error",{detail:t,bubbles:!0})))}_setReadPermission(t){this._readPermission!==t&&(this._readPermission=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:read-permission-changed",{detail:t,bubbles:!0})))}_setWritePermission(t){this._writePermission!==t&&(this._writePermission=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:write-permission-changed",{detail:t,bubbles:!0})))}_setMonitoring(t){this._monitoring!==t&&(this._monitoring=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:monitoring-changed",{detail:t,bubbles:!0})))}_setCopied(t){this._copied=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:copied",{detail:t,bubbles:!0}))}_setCut(t){this._cut=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:cut",{detail:t,bubbles:!0}))}_setPasted(t){this._pasted=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:pasted",{detail:t,bubbles:!0}))}writeText(t){return this._runWrite(()=>navigator.clipboard.writeText(t))}write(t){return this._runWrite(()=>navigator.clipboard.write(t))}readText(){return this._runRead(async()=>({text:await navigator.clipboard.readText(),items:null}))}read(){return this._runRead(async()=>{const t=await navigator.clipboard.read();return this._normalizeItems(t)})}startMonitor(){this._monitoring||(this._setMonitoring(!0),document.addEventListener("copy",this._onCopy),document.addEventListener("cut",this._onCut),document.addEventListener("paste",this._onPaste))}stopMonitor(){this._removeMonitorListeners(),this._setMonitoring(!1)}reinitPermission(){this._permissionSubscribed||this._initPermissions()}dispose(){this._permissionSubscribed=!1,this._permGen++,this._acqGen++,this._loading=!1,this._readStatus&&(this._readStatus.removeEventListener("change",this._onReadChange),this._readStatus=null),this._writeStatus&&(this._writeStatus.removeEventListener("change",this._onWriteChange),this._writeStatus=null),this._removeMonitorListeners(),this._monitoring=!1}_runWrite(t){return this._runOp(async()=>(await t(),null))}_runRead(t){return this._runOp(t)}async _runOp(t){if(!this._hasClipboard())return void this._setError(this._unsupportedError());const e=this._acqGen;this._setLoading(!0),this._setError(null);try{const r=await t();if(e!==this._acqGen)return;this._setLoading(!1),r&&this._setRead(r)}catch(t){if(e!==this._acqGen)return;this._setLoading(!1),this._setError(this._normalizeError(t))}}_onCopy=()=>{this._setCopied(this._selectionText())};_onCut=()=>{this._setCut(this._selectionText())};_onPaste=t=>{const e=t.clipboardData,r=e?e.getData("text/plain"):"";this._setPasted(r)};_removeMonitorListeners(){document.removeEventListener("copy",this._onCopy),document.removeEventListener("cut",this._onCut),document.removeEventListener("paste",this._onPaste)}_selectionText(){const t=document.getSelection();return t?t.toString():""}_initPermissions(){if("undefined"==typeof navigator||!navigator.permissions||"function"!=typeof navigator.permissions.query)return this._setReadPermission("unsupported"),this._setWritePermission("unsupported"),void(this._ready=Promise.resolve());this._permissionSubscribed=!0;const t=++this._permGen,e=this._queryPermission("clipboard-read",t,t=>{this._readStatus=t},t=>this._setReadPermission(t),this._onReadChange),r=this._queryPermission("clipboard-write",t,t=>{this._writeStatus=t},t=>this._setWritePermission(t),this._onWriteChange);this._ready=Promise.all([e,r]).then(()=>{})}_queryPermission(t,e,r,i,s){return navigator.permissions.query({name:t}).then(t=>{e===this._permGen&&(r(t),i(t.state),t.addEventListener("change",s))},()=>{e===this._permGen&&i("unsupported")})}_onReadChange=t=>{const e=t.target;this._setReadPermission(e.state)};_onWriteChange=t=>{const e=t.target;this._setWritePermission(e.state)};_hasClipboard(){return"undefined"!=typeof navigator&&!!navigator.clipboard}async _normalizeItems(t){const e=await Promise.all(t.map(t=>Promise.all(t.types.map(e=>t.getType(e))).then(e=>({item:t,blobs:e})))),r=[];let i=null;for(const{item:t,blobs:s}of e){const e={};if(t.types.forEach((t,r)=>{e[t]=s[r]}),null===i){const e=t.types.indexOf("text/plain");-1!==e&&(i=await s[e].text())}r.push({types:[...t.types],data:e})}return{text:i,items:r}}_normalizeError(t){return t instanceof Error?{name:t.name,message:t.message}:{name:"Error",message:String(t)}}_unsupportedError(){return{name:"NotSupportedError",message:"Clipboard API is not available in this environment."}}}let a=!1;const c="data-clipboard-text";function d(t){const e=t.target;if(!(e instanceof Element))return;const r=e.closest(`[${s.triggerAttribute}]`);if(!r)return;const i=r.getAttribute(s.triggerAttribute);if(!i)return;const n=customElements.get(s.tagNames.clipboard),o=document.getElementById(i);if(!(n&&o instanceof n))return;const a=function(t){if(t.hasAttribute(c))return t.getAttribute(c)??"";const e=t.getAttribute("data-clipboard-from");if(!e)return null;const r=document.querySelector(e);return r?r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement?r.value:r.textContent??"":null}(r);null!==a&&(t.preventDefault(),o.writeText(a))}class u extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...o.wcBindable,inputs:[{name:"monitor",attribute:"monitor"}],commands:o.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new o(this),this._internals=this._initInternals(),this._wireStates({"wcs-clipboard:loading-changed":t=>({loading:!0===t}),"wcs-clipboard:monitoring-changed":t=>({monitoring:!0===t}),"wcs-clipboard:error":t=>({error:null!=t})})}get connectedCallbackPromise(){return this._connectedCallbackPromise}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[r,i]of Object.entries(t))this.addEventListener(r,t=>{const r=this.hasAttribute("debug-states");for(const[s,n]of Object.entries(i(t.detail))){try{n?e.add(s):e.delete(s)}catch{}r&&this.toggleAttribute(`data-wcs-state-${s}`,n)}})}get monitor(){return this.hasAttribute("monitor")}set monitor(t){t?this.setAttribute("monitor",""):this.removeAttribute("monitor")}get text(){return this._core.text}get items(){return this._core.items}get loading(){return this._core.loading}get error(){return this._core.error}get readPermission(){return this._core.readPermission}get writePermission(){return this._core.writePermission}get monitoring(){return this._core.monitoring}get copied(){return this._core.copied}get cut(){return this._core.cut}get pasted(){return this._core.pasted}writeText(t){return this._core.writeText(t)}write(t){return this._core.write(t)}readText(){return this._core.readText()}read(){return this._core.read()}startMonitor(){this._core.startMonitor()}stopMonitor(){this._core.stopMonitor()}connectedCallback(){this.style.display="none",s.autoTrigger&&(a||(a=!0,document.addEventListener("click",d))),this._connectedCallbackPromise=this._core.observe(),this.monitor&&this._core.startMonitor()}disconnectedCallback(){this._core.stopMonitor(),this._core.dispose()}}function l(e){var r;e&&("boolean"==typeof(r=e).autoTrigger&&(t.autoTrigger=r.autoTrigger),"string"==typeof r.triggerAttribute&&(t.triggerAttribute=r.triggerAttribute),r.tagNames&&Object.assign(t.tagNames,r.tagNames),i=null),customElements.get(s.tagNames.clipboard)||customElements.define(s.tagNames.clipboard,u)}export{o as ClipboardCore,u as WcsClipboard,l as bootstrapClipboard,n as getConfig};
2
2
  //# sourceMappingURL=index.esm.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/core/ClipboardCore.ts","../src/autoTrigger.ts","../src/components/Clipboard.ts","../src/bootstrapClipboard.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 clipboard: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-clipboardtarget\",\n tagNames: {\n clipboard: \"wcs-clipboard\",\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 {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardReadDetail, WcsClipboardErrorDetail,\n} from \"../types.js\";\n\n/**\n * Headless clipboard primitive. A thin, framework-agnostic wrapper around the\n * Clipboard API exposed through the wc-bindable protocol.\n *\n * It has two surfaces, mirroring the two distinct shapes of clipboard access:\n * - **commands** — `writeText()` / `write()` push to the clipboard;\n * `readText()` / `read()` pull from it. These are the `state → element`\n * (command-token) and `element → state` (read result) paths. All four are\n * async and never reject: failures surface through the `error` property so\n * they flow into the declarative state, symmetrical with FetchCore /\n * GeolocationCore.\n * - **monitor** — `startMonitor()` / `stopMonitor()` subscribe to the document's\n * `copy` / `cut` / `paste` events and republish them as the `copied` / `cut` /\n * `pasted` properties (like TimerCore's continuous `start()` / `stop()`),\n * toggling the `monitoring` flag. This is the event-token showcase: a user\n * paste flows element → state declaratively.\n *\n * Clipboard also has permission gates, like GeolocationCore but doubled: read\n * and write are separate permissions (`clipboard-read` / `clipboard-write`).\n * `readPermission` / `writePermission` reflect `navigator.permissions.query`\n * (`prompt` / `granted` / `denied`, or `unsupported`) and track their live\n * `change` events.\n */\nexport class ClipboardCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"text\", event: \"wcs-clipboard:read\", getter: (e: Event) => (e as CustomEvent).detail.text },\n { name: \"items\", event: \"wcs-clipboard:read\", getter: (e: Event) => (e as CustomEvent).detail.items },\n { name: \"loading\", event: \"wcs-clipboard:loading-changed\" },\n { name: \"error\", event: \"wcs-clipboard:error\" },\n { name: \"readPermission\", event: \"wcs-clipboard:read-permission-changed\" },\n { name: \"writePermission\", event: \"wcs-clipboard:write-permission-changed\" },\n { name: \"monitoring\", event: \"wcs-clipboard:monitoring-changed\" },\n { name: \"copied\", event: \"wcs-clipboard:copied\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"cut\", event: \"wcs-clipboard:cut\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"pasted\", event: \"wcs-clipboard:pasted\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"writeText\", async: true },\n { name: \"write\", async: true },\n { name: \"readText\", async: true },\n { name: \"read\", async: true },\n { name: \"startMonitor\" },\n { name: \"stopMonitor\" },\n ],\n };\n\n private _target: EventTarget;\n\n private _text: string | null = null;\n private _items: WcsClipboardReadItem[] | null = null;\n private _loading: boolean = false;\n private _error: WcsClipboardErrorDetail | null = null;\n private _readPermission: ClipboardPermissionState = \"prompt\";\n private _writePermission: ClipboardPermissionState = \"prompt\";\n\n private _monitoring: boolean = false;\n private _copied: string | null = null;\n private _cut: string | null = null;\n private _pasted: string | null = null;\n\n // Live PermissionStatus handles (when the Permissions API is available), kept\n // so the `change` listeners can be removed on dispose(). Read and write are\n // separate permissions, hence two handles.\n private _readStatus: PermissionStatus | null = null;\n private _writeStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards reinitPermission() so the first connect after\n // construction does not double-subscribe, while a reconnect after dispose()\n // does re-subscribe. (Mirrors GeolocationCore.)\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query round. Bumped by every\n // _initPermissions() and by dispose(). Each in-flight query captures it and,\n // on resolve, bails unless it is still current — so a query superseded by a\n // rapid (synchronous) disconnect→reconnect, or one that resolves after\n // dispose(), never attaches a listener.\n private _permGen: number = 0;\n\n // Monotonic id of the current async acquisition lifecycle (read/write),\n // bumped only by dispose(). Each command captures it at start; the resolution\n // bails (no setters) if it is stale, so an op that settles after the element\n // was disconnected does not dispatch wcs-clipboard:* on a torn-down element.\n // The Clipboard API has no AbortController, so a generation guard is the only\n // way to neutralize an in-flight op.\n private _acqGen: number = 0;\n\n // SSR (§3.8): resolves once the first permission probe settles, so the state\n // binder can await a real snapshot before reading. Set by _initPermissions();\n // Promise.resolve() when the Permissions API is unsupported (no async probe).\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Probe the permission states up front so observers see the real values\n // before the first read, then keep them live.\n this._initPermissions();\n }\n\n // SSR (§3.8): the first permission probe's settle promise.\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). Clipboard reads/writes are command-driven (they need a\n // user gesture), so observe() establishes no acquisition; it only (re)subscribes\n // to permission `change` events — idempotent while a subscription is live, and\n // reviving it after a dispose() (reconnect/reparent). Returns ready so the Shell\n // can expose it as connectedCallbackPromise.\n observe(): Promise<void> {\n this.reinitPermission();\n return this._ready;\n }\n\n get text(): string | null {\n return this._text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._items;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._error;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._writePermission;\n }\n\n get monitoring(): boolean {\n return this._monitoring;\n }\n\n get copied(): string | null {\n return this._copied;\n }\n\n get cut(): string | null {\n return this._cut;\n }\n\n get pasted(): string | null {\n return this._pasted;\n }\n\n // --- State setters with event dispatch ---\n\n // Deliberately NO same-value guard (unlike error/loading/permission/monitoring).\n // A read is a result event, not idempotent state: reading the same text twice is\n // two distinct user/command actions and must re-fire wcs-clipboard:read each time\n // so a `text:`/`items:` binding and command-result consumers see every read.\n private _setRead(detail: WcsClipboardReadDetail): void {\n this._text = detail.text;\n this._items = detail.items;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read\", {\n detail,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n if (this._loading === loading) return;\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsClipboardErrorDetail | null): void {\n // Same-value guard. `error` has no derived state, so suppressing redundant\n // null→null dispatches (e.g. a successful op clearing an already-null error)\n // avoids spurious events. Reference identity is sufficient: each failure\n // builds a fresh object, and the clear path always passes the literal null.\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _setReadPermission(permission: ClipboardPermissionState): void {\n if (this._readPermission === permission) return;\n this._readPermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setWritePermission(permission: ClipboardPermissionState): void {\n if (this._writePermission === permission) return;\n this._writePermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:write-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setMonitoring(monitoring: boolean): void {\n if (this._monitoring === monitoring) return;\n this._monitoring = monitoring;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:monitoring-changed\", {\n detail: monitoring,\n bubbles: true,\n }));\n }\n\n // Deliberately NO same-value guard on the copied/cut/pasted setters (unlike\n // error/loading/permission/monitoring above). These are events, not state:\n // copying the same text twice is two distinct user actions and must re-fire\n // both times so an event-token subscriber (`eventToken.pasted: ...`) sees each\n // occurrence. Do not add a `===` guard here.\n private _setCopied(text: string): void {\n this._copied = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:copied\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setCut(text: string): void {\n this._cut = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:cut\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setPasted(text: string): void {\n this._pasted = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:pasted\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n // --- Public API: write ---\n\n /**\n * Write plain text to the clipboard. Resolves once the write settles or fails\n * — never rejects: failures surface through `error`. Requires transient\n * activation (a user gesture), so call from a click handler / command-token.\n */\n writeText(text: string): Promise<void> {\n return this._runWrite(() => navigator.clipboard.writeText(text));\n }\n\n /**\n * Write rich `ClipboardItem`s (images, HTML, multiple MIME types) to the\n * clipboard. Resolves once the write settles or fails — never rejects.\n */\n write(items: ClipboardItem[]): Promise<void> {\n return this._runWrite(() => navigator.clipboard.write(items));\n }\n\n // --- Public API: read ---\n\n /**\n * Read plain text from the clipboard, publishing it via `text` and the\n * `wcs-clipboard:read` event. Resolves once the read settles or fails — never\n * rejects. Requires focus + read permission.\n */\n readText(): Promise<void> {\n return this._runRead(async () => {\n const text = await navigator.clipboard.readText();\n return { text, items: null };\n });\n }\n\n /**\n * Read rich `ClipboardItem`s from the clipboard, eagerly resolving every\n * representation to a `Blob`. A `text/plain` representation is also surfaced\n * via `text`. Resolves once the read settles or fails — never rejects.\n */\n read(): Promise<void> {\n return this._runRead(async () => {\n const items = await navigator.clipboard.read();\n return this._normalizeItems(items);\n });\n }\n\n // --- Public API: monitor ---\n\n /**\n * Begin monitoring document `copy` / `cut` / `paste` events, republishing\n * them as the `copied` / `cut` / `pasted` properties. Idempotent while already\n * monitoring (mirrors GeolocationCore.watch()).\n */\n startMonitor(): void {\n if (this._monitoring) return;\n this._setMonitoring(true);\n // §4 deviation: document-scoped Web API; no element-free alternative.\n // copy/cut/paste fire on `document`, so monitoring necessarily listens there\n // rather than on a Core-owned element. Registered as an allowed deviation.\n document.addEventListener(\"copy\", this._onCopy);\n document.addEventListener(\"cut\", this._onCut);\n document.addEventListener(\"paste\", this._onPaste);\n }\n\n stopMonitor(): void {\n this._removeMonitorListeners();\n this._setMonitoring(false);\n }\n\n // --- Permission lifecycle ---\n\n /**\n * Re-establish the permission `change` subscriptions after a dispose() — e.g.\n * the Shell element was disconnected and then reconnected (reparented). No-op\n * while a subscription is already live, so the first connect after\n * construction does not double-subscribe.\n */\n reinitPermission(): void {\n if (!this._permissionSubscribed) {\n this._initPermissions();\n }\n }\n\n /**\n * Detach the live permission `change` listeners and any monitor listeners, and\n * neutralize in-flight async ops. Call from the Shell's `disconnectedCallback`\n * so a removed element does not leak subscriptions or dispatch on a torn-down\n * element. A later reconnect can re-subscribe via reinitPermission().\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight permission query so its .then() bails instead of\n // attaching a listener after teardown.\n this._permGen++;\n // Invalidate any in-flight read/write so its resolution bails instead of\n // dispatching on a disconnected element.\n this._acqGen++;\n // Reset the loading shadow silently (no dispatch on a disposed element). The\n // bailed resolution will not clear it, and leaving it true would let the\n // same-value guard swallow the loading=true edge of the next op after a\n // reconnect.\n this._loading = false;\n if (this._readStatus) {\n this._readStatus.removeEventListener(\"change\", this._onReadChange);\n this._readStatus = null;\n }\n if (this._writeStatus) {\n this._writeStatus.removeEventListener(\"change\", this._onWriteChange);\n this._writeStatus = null;\n }\n // Remove monitor listeners silently. The Shell calls stopMonitor() before\n // dispose(), but a direct headless dispose() still tears them down.\n this._removeMonitorListeners();\n this._monitoring = false;\n }\n\n // --- Internal: write/read runners ---\n\n private _runWrite(op: () => Promise<void>): Promise<void> {\n return this._runOp(async () => {\n await op();\n return null;\n });\n }\n\n private _runRead(op: () => Promise<WcsClipboardReadDetail>): Promise<void> {\n return this._runOp(op);\n }\n\n /**\n * Shared async-op lifecycle for read/write: capability check, loading toggle,\n * generation guard, never-reject error handling. When `op` returns a read\n * detail it is published; when it returns null (a write) nothing is published.\n */\n private async _runOp(op: () => Promise<WcsClipboardReadDetail | null>): Promise<void> {\n if (!this._hasClipboard()) {\n this._setError(this._unsupportedError());\n return;\n }\n const gen = this._acqGen;\n this._setLoading(true);\n this._setError(null);\n try {\n const detail = await op();\n // Stale: the element was disposed (disconnected) while this op was in\n // flight. Drop it so a torn-down element never dispatches wcs-clipboard:*.\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n if (detail) this._setRead(detail);\n } catch (err) {\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n this._setError(this._normalizeError(err));\n }\n }\n\n // --- Internal: monitor handlers ---\n\n // During a `copy` / `cut` event the clipboard payload is not yet readable —\n // the browser returns an empty string for security reasons — so we report the\n // user's selected text (`document.getSelection().toString()`) instead. A page\n // that overrides the payload with a custom handler via clipboardData.setData()\n // is therefore NOT reflected here. (See README \"copy / cut text comes from the\n // selection\".) `paste` differs: clipboardData is readable, so _onPaste reads it.\n private _onCopy = (): void => {\n this._setCopied(this._selectionText());\n };\n\n private _onCut = (): void => {\n this._setCut(this._selectionText());\n };\n\n private _onPaste = (event: Event): void => {\n const data = (event as ClipboardEvent).clipboardData;\n const text = data ? data.getData(\"text/plain\") : \"\";\n this._setPasted(text);\n };\n\n private _removeMonitorListeners(): void {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n document.removeEventListener(\"copy\", this._onCopy);\n document.removeEventListener(\"cut\", this._onCut);\n document.removeEventListener(\"paste\", this._onPaste);\n }\n\n private _selectionText(): string {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n const selection = document.getSelection();\n return selection ? selection.toString() : \"\";\n }\n\n // --- Internal: permission ---\n\n private _initPermissions(): void {\n // The Permissions API is optional. When absent (or it rejects, e.g. Firefox\n // does not expose the clipboard permission names), report \"unsupported\" and\n // leave reads/writes to fail loudly via the error property if attempted.\n // Note: we deliberately do NOT set _permissionSubscribed here — there is no\n // live subscription to tear down, so reinitPermission() re-runs this branch\n // on every reconnect. That is harmless: the same-value guard in\n // _setReadPermission/_setWritePermission swallows the redundant\n // unsupported→unsupported dispatch. (Mirrors GeolocationCore.)\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n this._setReadPermission(\"unsupported\");\n this._setWritePermission(\"unsupported\");\n // No async probe: readiness is immediate (§3.8).\n this._ready = Promise.resolve();\n return;\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n const readProbe = this._queryPermission(\n \"clipboard-read\", gen,\n (s) => { this._readStatus = s; },\n (state) => this._setReadPermission(state),\n this._onReadChange,\n );\n const writeProbe = this._queryPermission(\n \"clipboard-write\", gen,\n (s) => { this._writeStatus = s; },\n (state) => this._setWritePermission(state),\n this._onWriteChange,\n );\n // SSR (§3.8): ready resolves once both initial permission probes settle.\n this._ready = Promise.all([readProbe, writeProbe]).then(() => undefined);\n }\n\n private _queryPermission(\n name: string,\n gen: number,\n assignStatus: (status: PermissionStatus) => void,\n setState: (state: ClipboardPermissionState) => void,\n onChange: (event: Event) => void,\n ): Promise<void> {\n return navigator.permissions.query({ name: name as PermissionName }).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the\n // current subscription attaches a listener.\n if (gen !== this._permGen) return;\n assignStatus(status);\n setState(status.state as ClipboardPermissionState);\n status.addEventListener(\"change\", onChange);\n },\n () => {\n if (gen !== this._permGen) return;\n setState(\"unsupported\");\n },\n );\n }\n\n private _onReadChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setReadPermission(status.state as ClipboardPermissionState);\n };\n\n private _onWriteChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setWritePermission(status.state as ClipboardPermissionState);\n };\n\n // --- Internal: normalization ---\n\n private _hasClipboard(): boolean {\n return typeof navigator !== \"undefined\" && !!navigator.clipboard;\n }\n\n private async _normalizeItems(items: ClipboardItem[]): Promise<WcsClipboardReadDetail> {\n // Resolve every representation of every item in parallel. getType() calls are\n // independent, so awaiting them serially only adds latency. The trade-off is\n // intentional and unchanged from the serial version: if any getType() rejects\n // the whole read errors (no partial success), consistent with the never-reject\n // design where a failed op surfaces a single `error` rather than a half-filled\n // snapshot. Order is preserved so the `text` pick below stays deterministic.\n const resolved = await Promise.all(\n items.map((item) =>\n Promise.all(item.types.map((type) => item.getType(type))).then((blobs) => ({ item, blobs })),\n ),\n );\n\n const normalized: WcsClipboardReadItem[] = [];\n let text: string | null = null;\n for (const { item, blobs } of resolved) {\n const data: Record<string, Blob> = {};\n item.types.forEach((type, i) => {\n data[type] = blobs[i];\n });\n // Surface the first text/plain representation through `text` for the\n // common \"read whatever text is there\" case (first item, first match).\n if (text === null) {\n const i = item.types.indexOf(\"text/plain\");\n if (i !== -1) {\n text = await blobs[i].text();\n }\n }\n normalized.push({ types: [...item.types], data });\n }\n return { text, items: normalized };\n }\n\n private _normalizeError(err: unknown): WcsClipboardErrorDetail {\n if (err instanceof Error) {\n // DOMException is an Error subclass; its `name` (NotAllowedError, etc.) is\n // the meaningful discriminator for consumers switching on failure kind.\n return { name: err.name, message: err.message };\n }\n return { name: \"Error\", message: String(err) };\n }\n\n private _unsupportedError(): WcsClipboardErrorDetail {\n return {\n name: \"NotSupportedError\",\n message: \"Clipboard API is not available in this environment.\",\n };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsClipboard } from \"./components/Clipboard.js\";\n\nlet registered = false;\n\n// Attribute names for the optional copy-on-click DOM trigger (clipboard.js-style\n// DX). The element carrying `data-clipboardtarget` points at a <wcs-clipboard>\n// by id; the text to copy comes from either a literal `data-clipboard-text` or\n// a `data-clipboard-from` CSS selector resolving to a source element.\nconst TEXT_ATTRIBUTE = \"data-clipboard-text\";\nconst FROM_ATTRIBUTE = \"data-clipboard-from\";\n\nfunction resolveText(triggerElement: Element): string | null {\n // Literal text wins when present (including an empty string — copying \"\" is a\n // legitimate request).\n if (triggerElement.hasAttribute(TEXT_ATTRIBUTE)) {\n return triggerElement.getAttribute(TEXT_ATTRIBUTE) ?? \"\";\n }\n const selector = triggerElement.getAttribute(FROM_ATTRIBUTE);\n if (!selector) return null;\n const source = document.querySelector(selector);\n if (!source) return null;\n // Read a form control's `value`; fall back to text content. A bare\n // `\"value\" in source` check is too broad — it also matches <button>,\n // <li value>, <progress>, etc. (which carry an unrelated `value`), copying\n // the wrong thing. Narrow to the text-bearing controls a user actually points\n // `data-clipboard-from` at; everything else falls through to textContent.\n if (\n source instanceof HTMLInputElement ||\n source instanceof HTMLTextAreaElement ||\n source instanceof HTMLSelectElement\n ) {\n return source.value;\n }\n return source.textContent ?? \"\";\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 clipboardId = triggerElement.getAttribute(config.triggerAttribute);\n if (!clipboardId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // WcsClipboard as a value (avoids a components ⇄ autoTrigger import cycle:\n // Clipboard.connectedCallback() calls registerAutoTrigger()). instanceof\n // against the customElements registry keeps the same identity guarantee.\n const ClipboardCtor = customElements.get(config.tagNames.clipboard);\n const clipboardElement = document.getElementById(clipboardId);\n if (!ClipboardCtor || !(clipboardElement instanceof ClipboardCtor)) return;\n\n const text = resolveText(triggerElement);\n // No resolvable source: leave the click alone (do not preventDefault) so the\n // element's default action is unaffected.\n if (text === null) return;\n\n // Suppress the default action so a copy can run without navigating. Intentional:\n // do not attach data-clipboardtarget to an element whose default action you\n // also want (real <a href> link). See README \"Optional DOM Triggering\".\n event.preventDefault();\n (clipboardElement as WcsClipboard).writeText(text);\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { ClipboardCore } from \"../core/ClipboardCore.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n// Named WcsClipboard (not `Clipboard`) so the class does not shadow the global\n// DOM `Clipboard` interface (the type of `navigator.clipboard`), matching the\n// <wcs-geo> WcsGeolocation / <wcs-ws> WcsWebSocket convention.\nexport class WcsClipboard extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...ClipboardCore.wcBindable,\n // Shell-level settable surface. `monitor` mirrors its boolean attribute\n // (reflects idempotently), following the <wcs-ws> / <wcs-geo> convention.\n // There is no momentary `trigger` property: writes need an argument (the\n // text/items), so element actions are driven via command-token\n // (`command.writeText: $command.copy`) or the DOM autoTrigger, not a\n // false→true boolean pulse.\n inputs: [\n { name: \"monitor\", attribute: \"monitor\" },\n ],\n // Commands are identical to the Core's — no rename is needed because the\n // `monitor` boolean attribute accessor does not collide with the\n // `startMonitor` / `stopMonitor` command names (unlike <wcs-geo>, whose\n // `watch` attribute forced the Core's `watch` command to `watchPosition`).\n commands: ClipboardCore.wcBindable.commands,\n };\n\n private _core: ClipboardCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n\n constructor() {\n super();\n this._core = new ClipboardCore(this);\n }\n\n // SSR (§4.4): the state binder awaits this before snapshotting, so the first\n // permission probe has settled. Backed by _core.observe() (see connectedCallback).\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n\n get monitor(): boolean {\n return this.hasAttribute(\"monitor\");\n }\n\n /**\n * Reflects the `monitor` boolean attribute only — it does NOT start or stop\n * monitoring by itself. The attribute is read at connect time (see\n * connectedCallback); toggling `el.monitor` after connect just flips the\n * attribute. To start/stop monitoring imperatively, call `startMonitor()` /\n * `stopMonitor()`.\n */\n set monitor(value: boolean) {\n if (value) {\n this.setAttribute(\"monitor\", \"\");\n } else {\n this.removeAttribute(\"monitor\");\n }\n }\n\n // --- Core delegated getters ---\n\n get text(): string | null {\n return this._core.text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._core.items;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._core.error;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._core.readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._core.writePermission;\n }\n\n get monitoring(): boolean {\n return this._core.monitoring;\n }\n\n get copied(): string | null {\n return this._core.copied;\n }\n\n get cut(): string | null {\n return this._core.cut;\n }\n\n get pasted(): string | null {\n return this._core.pasted;\n }\n\n // --- Commands ---\n\n writeText(text: string): Promise<void> {\n return this._core.writeText(text);\n }\n\n write(items: ClipboardItem[]): Promise<void> {\n return this._core.write(items);\n }\n\n readText(): Promise<void> {\n return this._core.readText();\n }\n\n read(): Promise<void> {\n return this._core.read();\n }\n\n startMonitor(): void {\n this._core.startMonitor();\n }\n\n stopMonitor(): void {\n this._core.stopMonitor();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // observe() revives permission tracking after a reconnect (reparenting) —\n // a no-op on the first connect since the constructor already subscribed — and\n // returns the readiness promise exposed as connectedCallbackPromise (§4.4).\n this._connectedCallbackPromise = this._core.observe();\n // Unlike <wcs-geo>, there is no connect-time acquisition: reads require a\n // user gesture, so the only connect-time action is optional monitoring.\n if (this.monitor) {\n this._core.startMonitor();\n }\n }\n\n disconnectedCallback(): void {\n this._core.stopMonitor();\n this._core.dispose();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapClipboard(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { WcsClipboard } from \"./components/Clipboard.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.clipboard)) {\n customElements.define(config.tagNames.clipboard, WcsClipboard);\n }\n}\n"],"names":["_config","autoTrigger","triggerAttribute","tagNames","clipboard","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","ClipboardCore","EventTarget","static","protocol","version","properties","name","event","getter","e","detail","text","items","commands","async","_target","_text","_items","_loading","_error","_readPermission","_writePermission","_monitoring","_copied","_cut","_pasted","_readStatus","_writeStatus","_permissionSubscribed","_permGen","_acqGen","_ready","Promise","resolve","constructor","target","super","this","_initPermissions","ready","observe","reinitPermission","loading","error","readPermission","writePermission","monitoring","copied","cut","pasted","_setRead","dispatchEvent","CustomEvent","bubbles","_setLoading","_setError","_setReadPermission","permission","_setWritePermission","_setMonitoring","_setCopied","_setCut","_setPasted","writeText","_runWrite","navigator","write","readText","_runRead","read","_normalizeItems","startMonitor","document","addEventListener","_onCopy","_onCut","_onPaste","stopMonitor","_removeMonitorListeners","dispose","removeEventListener","_onReadChange","_onWriteChange","op","_runOp","_hasClipboard","_unsupportedError","gen","err","_normalizeError","_selectionText","data","clipboardData","getData","selection","getSelection","toString","permissions","query","readProbe","_queryPermission","s","state","writeProbe","all","then","assignStatus","setState","onChange","status","resolved","map","item","types","type","getType","blobs","normalized","forEach","i","indexOf","push","Error","message","String","registered","TEXT_ATTRIBUTE","handleClick","Element","triggerElement","closest","clipboardId","getAttribute","ClipboardCtor","customElements","get","clipboardElement","getElementById","hasAttribute","selector","source","querySelector","HTMLInputElement","HTMLTextAreaElement","HTMLSelectElement","value","textContent","resolveText","preventDefault","WcsClipboard","HTMLElement","wcBindable","inputs","attribute","_core","_connectedCallbackPromise","connectedCallbackPromise","monitor","setAttribute","removeAttribute","connectedCallback","style","display","disconnectedCallback","bootstrapClipboard","userConfig","partialConfig","assign","define"],"mappings":"AAUA,MAAMA,EAA2B,CAC/BC,aAAa,EACbC,iBAAkB,uBAClBC,SAAU,CACRC,UAAW,kBAIf,SAASC,EAAcC,GACrB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpDC,OAAOC,OAAOF,GACd,IAAK,MAAMG,KAAOF,OAAOG,KAAKJ,GAC5BD,EAAYC,EAAgCG,IAE9C,OAAOH,CACT,CAEA,SAASK,EAAaL,GACpB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpD,MAAMM,EAAiC,CAAA,EACvC,IAAK,MAAMH,KAAOF,OAAOG,KAAKJ,GAC5BM,EAAMH,GAAOE,EAAWL,EAAgCG,IAE1D,OAAOG,CACT,CAEA,IAAIC,EAA+B,KAE5B,MAAMC,EAAkBd,WAEfe,IAId,OAHKF,IACHA,EAAeR,EAAWM,EAAUX,KAE/Ba,CACT,CCjBM,MAAOG,UAAsBC,YACjCC,kBAAiC,CAC/BC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F,UACpB,CAEA,IAAAE,GACE,OAAOhC,KAAKqH,MAAMrF,MACpB,CAEA,YAAAE,GACElC,KAAKqH,MAAMnF,cACb,CAEA,WAAAM,GACExC,KAAKqH,MAAM7E,aACb,CAIA,iBAAAmF,GACE3H,KAAK4H,MAAMC,QAAU,OACjBpK,EAAOb,cDtET4I,IACJA,GAAa,EACbrD,SAASC,iBAAiB,QAASsD,KC0EjC1F,KAAKsH,0BAA4BtH,KAAKqH,MAAMlH,UAGxCH,KAAKwH,SACPxH,KAAKqH,MAAMnF,cAEf,CAEA,oBAAA4F,GACE9H,KAAKqH,MAAM7E,cACXxC,KAAKqH,MAAM3E,SACb,ECvJI,SAAUqF,EAAmBC,GJ2C7B,IAAoBC,EI1CpBD,IJ2CqC,kBADjBC,EIzCZD,GJ0CapL,cACvBD,EAAQC,YAAcqL,EAAcrL,aAEQ,iBAAnCqL,EAAcpL,mBACvBF,EAAQE,iBAAmBoL,EAAcpL,kBAEvCoL,EAAcnL,UAChBI,OAAOgL,OAAOvL,EAAQG,SAAUmL,EAAcnL,UAEhDU,EAAe,MKrDVyI,eAAeC,IAAIzI,EAAOX,SAASC,YACtCkJ,eAAekC,OAAO1K,EAAOX,SAASC,UAAWiK,EDIrD"}
1
+ {"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/core/ClipboardCore.ts","../src/autoTrigger.ts","../src/components/Clipboard.ts","../src/bootstrapClipboard.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 clipboard: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-clipboardtarget\",\n tagNames: {\n clipboard: \"wcs-clipboard\",\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 {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardReadDetail, WcsClipboardErrorDetail,\n} from \"../types.js\";\n\n/**\n * Headless clipboard primitive. A thin, framework-agnostic wrapper around the\n * Clipboard API exposed through the wc-bindable protocol.\n *\n * It has two surfaces, mirroring the two distinct shapes of clipboard access:\n * - **commands** — `writeText()` / `write()` push to the clipboard;\n * `readText()` / `read()` pull from it. These are the `state → element`\n * (command-token) and `element → state` (read result) paths. All four are\n * async and never reject: failures surface through the `error` property so\n * they flow into the declarative state, symmetrical with FetchCore /\n * GeolocationCore.\n * - **monitor** — `startMonitor()` / `stopMonitor()` subscribe to the document's\n * `copy` / `cut` / `paste` events and republish them as the `copied` / `cut` /\n * `pasted` properties (like TimerCore's continuous `start()` / `stop()`),\n * toggling the `monitoring` flag. This is the event-token showcase: a user\n * paste flows element → state declaratively.\n *\n * Clipboard also has permission gates, like GeolocationCore but doubled: read\n * and write are separate permissions (`clipboard-read` / `clipboard-write`).\n * `readPermission` / `writePermission` reflect `navigator.permissions.query`\n * (`prompt` / `granted` / `denied`, or `unsupported`) and track their live\n * `change` events.\n */\nexport class ClipboardCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"text\", event: \"wcs-clipboard:read\", getter: (e: Event) => (e as CustomEvent).detail.text },\n { name: \"items\", event: \"wcs-clipboard:read\", getter: (e: Event) => (e as CustomEvent).detail.items },\n { name: \"loading\", event: \"wcs-clipboard:loading-changed\" },\n { name: \"error\", event: \"wcs-clipboard:error\" },\n { name: \"readPermission\", event: \"wcs-clipboard:read-permission-changed\" },\n { name: \"writePermission\", event: \"wcs-clipboard:write-permission-changed\" },\n { name: \"monitoring\", event: \"wcs-clipboard:monitoring-changed\" },\n { name: \"copied\", event: \"wcs-clipboard:copied\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"cut\", event: \"wcs-clipboard:cut\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"pasted\", event: \"wcs-clipboard:pasted\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"writeText\", async: true },\n { name: \"write\", async: true },\n { name: \"readText\", async: true },\n { name: \"read\", async: true },\n { name: \"startMonitor\" },\n { name: \"stopMonitor\" },\n ],\n };\n\n private _target: EventTarget;\n\n private _text: string | null = null;\n private _items: WcsClipboardReadItem[] | null = null;\n private _loading: boolean = false;\n private _error: WcsClipboardErrorDetail | null = null;\n private _readPermission: ClipboardPermissionState = \"prompt\";\n private _writePermission: ClipboardPermissionState = \"prompt\";\n\n private _monitoring: boolean = false;\n private _copied: string | null = null;\n private _cut: string | null = null;\n private _pasted: string | null = null;\n\n // Live PermissionStatus handles (when the Permissions API is available), kept\n // so the `change` listeners can be removed on dispose(). Read and write are\n // separate permissions, hence two handles.\n private _readStatus: PermissionStatus | null = null;\n private _writeStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards reinitPermission() so the first connect after\n // construction does not double-subscribe, while a reconnect after dispose()\n // does re-subscribe. (Mirrors GeolocationCore.)\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query round. Bumped by every\n // _initPermissions() and by dispose(). Each in-flight query captures it and,\n // on resolve, bails unless it is still current — so a query superseded by a\n // rapid (synchronous) disconnect→reconnect, or one that resolves after\n // dispose(), never attaches a listener.\n private _permGen: number = 0;\n\n // Monotonic id of the current async acquisition lifecycle (read/write),\n // bumped only by dispose(). Each command captures it at start; the resolution\n // bails (no setters) if it is stale, so an op that settles after the element\n // was disconnected does not dispatch wcs-clipboard:* on a torn-down element.\n // The Clipboard API has no AbortController, so a generation guard is the only\n // way to neutralize an in-flight op.\n private _acqGen: number = 0;\n\n // SSR (§3.8): resolves once the first permission probe settles, so the state\n // binder can await a real snapshot before reading. Set by _initPermissions();\n // Promise.resolve() when the Permissions API is unsupported (no async probe).\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Probe the permission states up front so observers see the real values\n // before the first read, then keep them live.\n this._initPermissions();\n }\n\n // SSR (§3.8): the first permission probe's settle promise.\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). Clipboard reads/writes are command-driven (they need a\n // user gesture), so observe() establishes no acquisition; it only (re)subscribes\n // to permission `change` events — idempotent while a subscription is live, and\n // reviving it after a dispose() (reconnect/reparent). Returns ready so the Shell\n // can expose it as connectedCallbackPromise.\n observe(): Promise<void> {\n this.reinitPermission();\n return this._ready;\n }\n\n get text(): string | null {\n return this._text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._items;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._error;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._writePermission;\n }\n\n get monitoring(): boolean {\n return this._monitoring;\n }\n\n get copied(): string | null {\n return this._copied;\n }\n\n get cut(): string | null {\n return this._cut;\n }\n\n get pasted(): string | null {\n return this._pasted;\n }\n\n // --- State setters with event dispatch ---\n\n // Deliberately NO same-value guard (unlike error/loading/permission/monitoring).\n // A read is a result event, not idempotent state: reading the same text twice is\n // two distinct user/command actions and must re-fire wcs-clipboard:read each time\n // so a `text:`/`items:` binding and command-result consumers see every read.\n private _setRead(detail: WcsClipboardReadDetail): void {\n this._text = detail.text;\n this._items = detail.items;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read\", {\n detail,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n if (this._loading === loading) return;\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsClipboardErrorDetail | null): void {\n // Same-value guard. `error` has no derived state, so suppressing redundant\n // null→null dispatches (e.g. a successful op clearing an already-null error)\n // avoids spurious events. Reference identity is sufficient: each failure\n // builds a fresh object, and the clear path always passes the literal null.\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _setReadPermission(permission: ClipboardPermissionState): void {\n if (this._readPermission === permission) return;\n this._readPermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setWritePermission(permission: ClipboardPermissionState): void {\n if (this._writePermission === permission) return;\n this._writePermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:write-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setMonitoring(monitoring: boolean): void {\n if (this._monitoring === monitoring) return;\n this._monitoring = monitoring;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:monitoring-changed\", {\n detail: monitoring,\n bubbles: true,\n }));\n }\n\n // Deliberately NO same-value guard on the copied/cut/pasted setters (unlike\n // error/loading/permission/monitoring above). These are events, not state:\n // copying the same text twice is two distinct user actions and must re-fire\n // both times so an event-token subscriber (`eventToken.pasted: ...`) sees each\n // occurrence. Do not add a `===` guard here.\n private _setCopied(text: string): void {\n this._copied = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:copied\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setCut(text: string): void {\n this._cut = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:cut\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setPasted(text: string): void {\n this._pasted = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:pasted\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n // --- Public API: write ---\n\n /**\n * Write plain text to the clipboard. Resolves once the write settles or fails\n * — never rejects: failures surface through `error`. Requires transient\n * activation (a user gesture), so call from a click handler / command-token.\n */\n writeText(text: string): Promise<void> {\n return this._runWrite(() => navigator.clipboard.writeText(text));\n }\n\n /**\n * Write rich `ClipboardItem`s (images, HTML, multiple MIME types) to the\n * clipboard. Resolves once the write settles or fails — never rejects.\n */\n write(items: ClipboardItem[]): Promise<void> {\n return this._runWrite(() => navigator.clipboard.write(items));\n }\n\n // --- Public API: read ---\n\n /**\n * Read plain text from the clipboard, publishing it via `text` and the\n * `wcs-clipboard:read` event. Resolves once the read settles or fails — never\n * rejects. Requires focus + read permission.\n */\n readText(): Promise<void> {\n return this._runRead(async () => {\n const text = await navigator.clipboard.readText();\n return { text, items: null };\n });\n }\n\n /**\n * Read rich `ClipboardItem`s from the clipboard, eagerly resolving every\n * representation to a `Blob`. A `text/plain` representation is also surfaced\n * via `text`. Resolves once the read settles or fails — never rejects.\n */\n read(): Promise<void> {\n return this._runRead(async () => {\n const items = await navigator.clipboard.read();\n return this._normalizeItems(items);\n });\n }\n\n // --- Public API: monitor ---\n\n /**\n * Begin monitoring document `copy` / `cut` / `paste` events, republishing\n * them as the `copied` / `cut` / `pasted` properties. Idempotent while already\n * monitoring (mirrors GeolocationCore.watch()).\n */\n startMonitor(): void {\n if (this._monitoring) return;\n this._setMonitoring(true);\n // §4 deviation: document-scoped Web API; no element-free alternative.\n // copy/cut/paste fire on `document`, so monitoring necessarily listens there\n // rather than on a Core-owned element. Registered as an allowed deviation.\n document.addEventListener(\"copy\", this._onCopy);\n document.addEventListener(\"cut\", this._onCut);\n document.addEventListener(\"paste\", this._onPaste);\n }\n\n stopMonitor(): void {\n this._removeMonitorListeners();\n this._setMonitoring(false);\n }\n\n // --- Permission lifecycle ---\n\n /**\n * Re-establish the permission `change` subscriptions after a dispose() — e.g.\n * the Shell element was disconnected and then reconnected (reparented). No-op\n * while a subscription is already live, so the first connect after\n * construction does not double-subscribe.\n */\n reinitPermission(): void {\n if (!this._permissionSubscribed) {\n this._initPermissions();\n }\n }\n\n /**\n * Detach the live permission `change` listeners and any monitor listeners, and\n * neutralize in-flight async ops. Call from the Shell's `disconnectedCallback`\n * so a removed element does not leak subscriptions or dispatch on a torn-down\n * element. A later reconnect can re-subscribe via reinitPermission().\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight permission query so its .then() bails instead of\n // attaching a listener after teardown.\n this._permGen++;\n // Invalidate any in-flight read/write so its resolution bails instead of\n // dispatching on a disconnected element.\n this._acqGen++;\n // Reset the loading shadow silently (no dispatch on a disposed element). The\n // bailed resolution will not clear it, and leaving it true would let the\n // same-value guard swallow the loading=true edge of the next op after a\n // reconnect.\n this._loading = false;\n if (this._readStatus) {\n this._readStatus.removeEventListener(\"change\", this._onReadChange);\n this._readStatus = null;\n }\n if (this._writeStatus) {\n this._writeStatus.removeEventListener(\"change\", this._onWriteChange);\n this._writeStatus = null;\n }\n // Remove monitor listeners silently. The Shell calls stopMonitor() before\n // dispose(), but a direct headless dispose() still tears them down.\n this._removeMonitorListeners();\n this._monitoring = false;\n }\n\n // --- Internal: write/read runners ---\n\n private _runWrite(op: () => Promise<void>): Promise<void> {\n return this._runOp(async () => {\n await op();\n return null;\n });\n }\n\n private _runRead(op: () => Promise<WcsClipboardReadDetail>): Promise<void> {\n return this._runOp(op);\n }\n\n /**\n * Shared async-op lifecycle for read/write: capability check, loading toggle,\n * generation guard, never-reject error handling. When `op` returns a read\n * detail it is published; when it returns null (a write) nothing is published.\n */\n private async _runOp(op: () => Promise<WcsClipboardReadDetail | null>): Promise<void> {\n if (!this._hasClipboard()) {\n this._setError(this._unsupportedError());\n return;\n }\n const gen = this._acqGen;\n this._setLoading(true);\n this._setError(null);\n try {\n const detail = await op();\n // Stale: the element was disposed (disconnected) while this op was in\n // flight. Drop it so a torn-down element never dispatches wcs-clipboard:*.\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n if (detail) this._setRead(detail);\n } catch (err) {\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n this._setError(this._normalizeError(err));\n }\n }\n\n // --- Internal: monitor handlers ---\n\n // During a `copy` / `cut` event the clipboard payload is not yet readable —\n // the browser returns an empty string for security reasons — so we report the\n // user's selected text (`document.getSelection().toString()`) instead. A page\n // that overrides the payload with a custom handler via clipboardData.setData()\n // is therefore NOT reflected here. (See README \"copy / cut text comes from the\n // selection\".) `paste` differs: clipboardData is readable, so _onPaste reads it.\n private _onCopy = (): void => {\n this._setCopied(this._selectionText());\n };\n\n private _onCut = (): void => {\n this._setCut(this._selectionText());\n };\n\n private _onPaste = (event: Event): void => {\n const data = (event as ClipboardEvent).clipboardData;\n const text = data ? data.getData(\"text/plain\") : \"\";\n this._setPasted(text);\n };\n\n private _removeMonitorListeners(): void {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n document.removeEventListener(\"copy\", this._onCopy);\n document.removeEventListener(\"cut\", this._onCut);\n document.removeEventListener(\"paste\", this._onPaste);\n }\n\n private _selectionText(): string {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n const selection = document.getSelection();\n return selection ? selection.toString() : \"\";\n }\n\n // --- Internal: permission ---\n\n private _initPermissions(): void {\n // The Permissions API is optional. When absent (or it rejects, e.g. Firefox\n // does not expose the clipboard permission names), report \"unsupported\" and\n // leave reads/writes to fail loudly via the error property if attempted.\n // Note: we deliberately do NOT set _permissionSubscribed here — there is no\n // live subscription to tear down, so reinitPermission() re-runs this branch\n // on every reconnect. That is harmless: the same-value guard in\n // _setReadPermission/_setWritePermission swallows the redundant\n // unsupported→unsupported dispatch. (Mirrors GeolocationCore.)\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n this._setReadPermission(\"unsupported\");\n this._setWritePermission(\"unsupported\");\n // No async probe: readiness is immediate (§3.8).\n this._ready = Promise.resolve();\n return;\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n const readProbe = this._queryPermission(\n \"clipboard-read\", gen,\n (s) => { this._readStatus = s; },\n (state) => this._setReadPermission(state),\n this._onReadChange,\n );\n const writeProbe = this._queryPermission(\n \"clipboard-write\", gen,\n (s) => { this._writeStatus = s; },\n (state) => this._setWritePermission(state),\n this._onWriteChange,\n );\n // SSR (§3.8): ready resolves once both initial permission probes settle.\n this._ready = Promise.all([readProbe, writeProbe]).then(() => undefined);\n }\n\n private _queryPermission(\n name: string,\n gen: number,\n assignStatus: (status: PermissionStatus) => void,\n setState: (state: ClipboardPermissionState) => void,\n onChange: (event: Event) => void,\n ): Promise<void> {\n return navigator.permissions.query({ name: name as PermissionName }).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the\n // current subscription attaches a listener.\n if (gen !== this._permGen) return;\n assignStatus(status);\n setState(status.state as ClipboardPermissionState);\n status.addEventListener(\"change\", onChange);\n },\n () => {\n if (gen !== this._permGen) return;\n setState(\"unsupported\");\n },\n );\n }\n\n private _onReadChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setReadPermission(status.state as ClipboardPermissionState);\n };\n\n private _onWriteChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setWritePermission(status.state as ClipboardPermissionState);\n };\n\n // --- Internal: normalization ---\n\n private _hasClipboard(): boolean {\n return typeof navigator !== \"undefined\" && !!navigator.clipboard;\n }\n\n private async _normalizeItems(items: ClipboardItem[]): Promise<WcsClipboardReadDetail> {\n // Resolve every representation of every item in parallel. getType() calls are\n // independent, so awaiting them serially only adds latency. The trade-off is\n // intentional and unchanged from the serial version: if any getType() rejects\n // the whole read errors (no partial success), consistent with the never-reject\n // design where a failed op surfaces a single `error` rather than a half-filled\n // snapshot. Order is preserved so the `text` pick below stays deterministic.\n const resolved = await Promise.all(\n items.map((item) =>\n Promise.all(item.types.map((type) => item.getType(type))).then((blobs) => ({ item, blobs })),\n ),\n );\n\n const normalized: WcsClipboardReadItem[] = [];\n let text: string | null = null;\n for (const { item, blobs } of resolved) {\n const data: Record<string, Blob> = {};\n item.types.forEach((type, i) => {\n data[type] = blobs[i];\n });\n // Surface the first text/plain representation through `text` for the\n // common \"read whatever text is there\" case (first item, first match).\n if (text === null) {\n const i = item.types.indexOf(\"text/plain\");\n if (i !== -1) {\n text = await blobs[i].text();\n }\n }\n normalized.push({ types: [...item.types], data });\n }\n return { text, items: normalized };\n }\n\n private _normalizeError(err: unknown): WcsClipboardErrorDetail {\n if (err instanceof Error) {\n // DOMException is an Error subclass; its `name` (NotAllowedError, etc.) is\n // the meaningful discriminator for consumers switching on failure kind.\n return { name: err.name, message: err.message };\n }\n return { name: \"Error\", message: String(err) };\n }\n\n private _unsupportedError(): WcsClipboardErrorDetail {\n return {\n name: \"NotSupportedError\",\n message: \"Clipboard API is not available in this environment.\",\n };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsClipboard } from \"./components/Clipboard.js\";\n\nlet registered = false;\n\n// Attribute names for the optional copy-on-click DOM trigger (clipboard.js-style\n// DX). The element carrying `data-clipboardtarget` points at a <wcs-clipboard>\n// by id; the text to copy comes from either a literal `data-clipboard-text` or\n// a `data-clipboard-from` CSS selector resolving to a source element.\nconst TEXT_ATTRIBUTE = \"data-clipboard-text\";\nconst FROM_ATTRIBUTE = \"data-clipboard-from\";\n\nfunction resolveText(triggerElement: Element): string | null {\n // Literal text wins when present (including an empty string — copying \"\" is a\n // legitimate request).\n if (triggerElement.hasAttribute(TEXT_ATTRIBUTE)) {\n return triggerElement.getAttribute(TEXT_ATTRIBUTE) ?? \"\";\n }\n const selector = triggerElement.getAttribute(FROM_ATTRIBUTE);\n if (!selector) return null;\n const source = document.querySelector(selector);\n if (!source) return null;\n // Read a form control's `value`; fall back to text content. A bare\n // `\"value\" in source` check is too broad — it also matches <button>,\n // <li value>, <progress>, etc. (which carry an unrelated `value`), copying\n // the wrong thing. Narrow to the text-bearing controls a user actually points\n // `data-clipboard-from` at; everything else falls through to textContent.\n if (\n source instanceof HTMLInputElement ||\n source instanceof HTMLTextAreaElement ||\n source instanceof HTMLSelectElement\n ) {\n return source.value;\n }\n return source.textContent ?? \"\";\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 clipboardId = triggerElement.getAttribute(config.triggerAttribute);\n if (!clipboardId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // WcsClipboard as a value (avoids a components ⇄ autoTrigger import cycle:\n // Clipboard.connectedCallback() calls registerAutoTrigger()). instanceof\n // against the customElements registry keeps the same identity guarantee.\n const ClipboardCtor = customElements.get(config.tagNames.clipboard);\n const clipboardElement = document.getElementById(clipboardId);\n if (!ClipboardCtor || !(clipboardElement instanceof ClipboardCtor)) return;\n\n const text = resolveText(triggerElement);\n // No resolvable source: leave the click alone (do not preventDefault) so the\n // element's default action is unaffected.\n if (text === null) return;\n\n // Suppress the default action so a copy can run without navigating. Intentional:\n // do not attach data-clipboardtarget to an element whose default action you\n // also want (real <a href> link). See README \"Optional DOM Triggering\".\n event.preventDefault();\n (clipboardElement as WcsClipboard).writeText(text);\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { ClipboardCore } from \"../core/ClipboardCore.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n// Named WcsClipboard (not `Clipboard`) so the class does not shadow the global\n// DOM `Clipboard` interface (the type of `navigator.clipboard`), matching the\n// <wcs-geo> WcsGeolocation / <wcs-ws> WcsWebSocket convention.\nexport class WcsClipboard extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...ClipboardCore.wcBindable,\n // Shell-level settable surface. `monitor` mirrors its boolean attribute\n // (reflects idempotently), following the <wcs-ws> / <wcs-geo> convention.\n // There is no momentary `trigger` property: writes need an argument (the\n // text/items), so element actions are driven via command-token\n // (`command.writeText: $command.copy`) or the DOM autoTrigger, not a\n // false→true boolean pulse.\n inputs: [\n { name: \"monitor\", attribute: \"monitor\" },\n ],\n // Commands are identical to the Core's — no rename is needed because the\n // `monitor` boolean attribute accessor does not collide with the\n // `startMonitor` / `stopMonitor` command names (unlike <wcs-geo>, whose\n // `watch` attribute forced the Core's `watch` command to `watchPosition`).\n commands: ClipboardCore.wcBindable.commands,\n };\n\n private _core: ClipboardCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new ClipboardCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-clipboard:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-clipboard:monitoring-changed\": (d) => ({ monitoring: d === true }),\n \"wcs-clipboard:error\": (d) => ({ error: d != null }),\n });\n }\n\n // SSR (§4.4): the state binder awaits this before snapshotting, so the first\n // permission probe has settled. Backed by _core.observe() (see connectedCallback).\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\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 // --- Attribute accessors ---\n\n get monitor(): boolean {\n return this.hasAttribute(\"monitor\");\n }\n\n /**\n * Reflects the `monitor` boolean attribute only — it does NOT start or stop\n * monitoring by itself. The attribute is read at connect time (see\n * connectedCallback); toggling `el.monitor` after connect just flips the\n * attribute. To start/stop monitoring imperatively, call `startMonitor()` /\n * `stopMonitor()`.\n */\n set monitor(value: boolean) {\n if (value) {\n this.setAttribute(\"monitor\", \"\");\n } else {\n this.removeAttribute(\"monitor\");\n }\n }\n\n // --- Core delegated getters ---\n\n get text(): string | null {\n return this._core.text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._core.items;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._core.error;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._core.readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._core.writePermission;\n }\n\n get monitoring(): boolean {\n return this._core.monitoring;\n }\n\n get copied(): string | null {\n return this._core.copied;\n }\n\n get cut(): string | null {\n return this._core.cut;\n }\n\n get pasted(): string | null {\n return this._core.pasted;\n }\n\n // --- Commands ---\n\n writeText(text: string): Promise<void> {\n return this._core.writeText(text);\n }\n\n write(items: ClipboardItem[]): Promise<void> {\n return this._core.write(items);\n }\n\n readText(): Promise<void> {\n return this._core.readText();\n }\n\n read(): Promise<void> {\n return this._core.read();\n }\n\n startMonitor(): void {\n this._core.startMonitor();\n }\n\n stopMonitor(): void {\n this._core.stopMonitor();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // observe() revives permission tracking after a reconnect (reparenting) —\n // a no-op on the first connect since the constructor already subscribed — and\n // returns the readiness promise exposed as connectedCallbackPromise (§4.4).\n this._connectedCallbackPromise = this._core.observe();\n // Unlike <wcs-geo>, there is no connect-time acquisition: reads require a\n // user gesture, so the only connect-time action is optional monitoring.\n if (this.monitor) {\n this._core.startMonitor();\n }\n }\n\n disconnectedCallback(): void {\n this._core.stopMonitor();\n this._core.dispose();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapClipboard(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { WcsClipboard } from \"./components/Clipboard.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.clipboard)) {\n customElements.define(config.tagNames.clipboard, WcsClipboard);\n }\n}\n"],"names":["_config","autoTrigger","triggerAttribute","tagNames","clipboard","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","ClipboardCore","EventTarget","static","protocol","version","properties","name","event","getter","e","detail","text","items","commands","async","_target","_text","_items","_loading","_error","_readPermission","_writePermission","_monitoring","_copied","_cut","_pasted","_readStatus","_writeStatus","_permissionSubscribed","_permGen","_acqGen","_ready","Promise","resolve","constructor","target","super","this","_initPermissions","ready","observe","reinitPermission","loading","error","readPermission","writePermission","monitoring","copied","cut","pasted","_setRead","dispatchEvent","CustomEvent","bubbles","_setLoading","_setError","_setReadPermission","permission","_setWritePermission","_setMonitoring","_setCopied","_setCut","_setPasted","writeText","_runWrite","navigator","write","readText","_runRead","read","_normalizeItems","startMonitor","document","addEventListener","_onCopy","_onCut","_onPaste","stopMonitor","_removeMonitorListeners","dispose","removeEventListener","_onReadChange","_onWriteChange","op","_runOp","_hasClipboard","_unsupportedError","gen","err","_normalizeError","_selectionText","data","clipboardData","getData","selection","getSelection","toString","permissions","query","readProbe","_queryPermission","s","state","writeProbe","all","then","assignStatus","setState","onChange","status","resolved","map","item","types","type","getType","blobs","normalized","forEach","i","indexOf","push","Error","message","String","registered","TEXT_ATTRIBUTE","handleClick","Element","triggerElement","closest","clipboardId","getAttribute","ClipboardCtor","customElements","get","clipboardElement","getElementById","hasAttribute","selector","source","querySelector","HTMLInputElement","HTMLTextAreaElement","HTMLSelectElement","value","textContent","resolveText","preventDefault","WcsClipboard","HTMLElement","wcBindable","inputs","attribute","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","connectedCallbackPromise","debugStates","states","attachInternals","internals","add","delete","toStates","entries","debug","on","toggleAttribute","monitor","setAttribute","removeAttribute","connectedCallback","style","display","disconnectedCallback","bootstrapClipboard","userConfig","partialConfig","assign","define"],"mappings":"AAUA,MAAMA,EAA2B,CAC/BC,aAAa,EACbC,iBAAkB,uBAClBC,SAAU,CACRC,UAAW,kBAIf,SAASC,EAAcC,GACrB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpDC,OAAOC,OAAOF,GACd,IAAK,MAAMG,KAAOF,OAAOG,KAAKJ,GAC5BD,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yB,KAAKqH,MAAMxF,MAAMtD,EAC1B,CAEA,QAAAuD,GACE,OAAO9B,KAAKqH,MAAMvF,UACpB,CAEA,IAAAE,GACE,OAAOhC,KAAKqH,MAAMrF,MACpB,CAEA,YAAAE,GACElC,KAAKqH,MAAMnF,cACb,CAEA,WAAAM,GACExC,KAAKqH,MAAM7E,aACb,CAIA,iBAAAkG,GACE1I,KAAK2I,MAAMC,QAAU,OACjBnL,EAAOb,cDtHT4I,IACJA,GAAa,EACbrD,SAASC,iBAAiB,QAASsD,KC0HjC1F,KAAKsH,0BAA4BtH,KAAKqH,MAAMlH,UAGxCH,KAAKuI,SACPvI,KAAKqH,MAAMnF,cAEf,CAEA,oBAAA2G,GACE7I,KAAKqH,MAAM7E,cACXxC,KAAKqH,MAAM3E,SACb,ECvMI,SAAUoG,EAAmBC,GJ2C7B,IAAoBC,EI1CpBD,IJ2CqC,kBADjBC,EIzCZD,GJ0CanM,cACvBD,EAAQC,YAAcoM,EAAcpM,aAEQ,iBAAnCoM,EAAcnM,mBACvBF,EAAQE,iBAAmBmM,EAAcnM,kBAEvCmM,EAAclM,UAChBI,OAAO+L,OAAOtM,EAAQG,SAAUkM,EAAclM,UAEhDU,EAAe,MKrDVyI,eAAeC,IAAIzI,EAAOX,SAASC,YACtCkJ,eAAeiD,OAAOzL,EAAOX,SAASC,UAAWiK,EDIrD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/clipboard",
3
- "version": "1.16.0",
3
+ "version": "1.17.0",
4
4
  "description": "Declarative clipboard component for Web Components. Framework-agnostic Clipboard API primitive via wc-bindable-protocol.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.esm.js",