@wcstack/clipboard 1.14.0 → 1.16.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
@@ -138,6 +138,17 @@ DOM の autoTrigger は書き込み(`writeText`)のみを起動します。
138
138
 
139
139
  > DOM トリガによる `writeText` は fire-and-forget(`Promise` を await しません)ですが、決して reject しません。コピー失敗は他の書き込みと同様 `error` プロパティに現れます。autoTrigger の失敗を観測するには `error` をバインドしてください(例: `text: error.message@cb`)。
140
140
 
141
+ > **autoTrigger は既定で有効。** 最初に接続した `<wcs-clipboard>` が document レベルの `click` リスナーを 1 つ設置します(`data-clipboardtarget` 要素のクリックで `writeText` を起動)。DOM ショートカットを使わないなら bootstrap エントリで無効化してください:
142
+ >
143
+ > ```js
144
+ > import { bootstrapClipboard, getConfig } from "@wcstack/clipboard";
145
+ > bootstrapClipboard({ autoTrigger: false }); // document クリックリスナーを設置しない
146
+ > bootstrapClipboard({ triggerAttribute: "data-copy" }); // トリガ属性名を変更(既定: data-clipboardtarget)
147
+ > getConfig(); // 実効設定(deep-frozen)を読む
148
+ > ```
149
+ >
150
+ > `bootstrapClipboard()` は要素が接続される前に呼んでください。(`setConfig` は内部用。設定は `bootstrapClipboard` 経由で行います。)
151
+
141
152
  ## 観測可能なプロパティ(出力)
142
153
 
143
154
  | プロパティ | イベント | 説明 |
@@ -173,7 +184,7 @@ DOM の autoTrigger は書き込み(`writeText`)のみを起動します。
173
184
  ## 注意点と制約
174
185
 
175
186
  - **属性は接続時に読み取られ、監視されない。** `<wcs-clipboard>` は `observedAttributes` / `attributeChangedCallback` を実装していません。`monitor` 属性は要素の接続時に読み取られます。接続*後*に命令的にトグルしても、それだけでは監視は開始/停止しません。`startMonitor()` / `stopMonitor()` を呼ぶか、要素を再接続してください。
176
- - **接続時の読み取りは無い。** `<wcs-geo>` と異なり、クリップボードは接続時に自動読み取りできません(読み取りにはユーザージェスチャとパーミッションが必要)。そのため `connectedCallbackPromise` / SSR スナップショットはありません。接続時の唯一のアクションは任意の監視です。
187
+ - **接続時の読み取りは無い。** `<wcs-geo>` と異なり、クリップボードは接続時に自動読み取りできません(読み取りにはユーザージェスチャとパーミッションが必要)。接続時のアクションは初回パーミッション照会と任意の監視です。ただし `connectedCallbackPromise`(`hasConnectedCallbackPromise = true`)は公開しており、state バインダ / SSR はこれを await して初回パーミッションスナップショットの確定を待ってからバインドできます。
177
188
  - **再接続で再購読する。** 要素を削除して再挿入すると `connectedCallback` が再度実行されるため、パーミッション追跡が復活し、`monitor` 属性を持つ要素は監視を再開します(切断時に解体するのと対称です)。監視の永続性は**属性駆動のみ**です。`monitor` 属性*なし*の要素で `startMonitor()` を使って命令的に監視を開始した場合、再接続では復元されません(属性が真実の源)。リペアレント間で監視を永続させたい場合は `monitor` 属性を付けてください。
178
189
  - **`copy` / `cut` のテキストは選択範囲から取得する。** `copy` / `cut` イベント中はクリップボードのペイロードがまだ読めない(セキュリティ上ブラウザは空文字列を返す)ため、`copied` / `cut` は `document.getSelection().toString()` — ユーザーの選択テキストを報告します。ページが `clipboardData.setData(...)` でペイロードを上書きするカスタム `copy` ハンドラを設置している場合、その上書きは `copied` / `cut` に**反映されません**。`pasted` は `event.clipboardData.getData("text/plain")` を読み取ります。
179
190
  - **無言のエラー処理(ゼロログ)。** wcstack 全体のゼロ依存・最小主義に従い、`<wcs-clipboard>` は実行時の失敗に対して一切ログ出力も throw もしません。パーミッション照会の失敗(クリップボードのパーミッション名を持たない Firefox など)は無言で `"unsupported"` にフォールバックします。read/write の失敗(パーミッション拒否・フォーカス無し・Clipboard API 欠如)は `error` プロパティ / `wcs-clipboard:error` イベントを通じてのみ表面化します — コマンドは resolve し、決して reject しません。観測・対処するには `error`(および `*Permission` プロパティ)をバインドしてください。
package/README.md CHANGED
@@ -140,6 +140,17 @@ Add the `monitor` attribute to republish document `copy` / `cut` / `paste` as re
140
140
 
141
141
  > A DOM-triggered `writeText` is fire-and-forget (its `Promise` is not awaited), but it never rejects: a failed copy surfaces through the `error` property like any other write. Bind `error` (e.g. `text: error.message@cb`) to observe autoTrigger failures.
142
142
 
143
+ > **autoTrigger is on by default.** The first `<wcs-clipboard>` to connect installs a single **document-level `click` listener** (a click on a `data-clipboardtarget` element runs `writeText`). If you don't use the DOM shortcut, opt out via the bootstrap entry:
144
+ >
145
+ > ```js
146
+ > import { bootstrapClipboard, getConfig } from "@wcstack/clipboard";
147
+ > bootstrapClipboard({ autoTrigger: false }); // no document click listener
148
+ > bootstrapClipboard({ triggerAttribute: "data-copy" }); // rename the trigger attribute (default: data-clipboardtarget)
149
+ > getConfig(); // read the effective (deep-frozen) config
150
+ > ```
151
+ >
152
+ > Call `bootstrapClipboard()` before the elements connect. (`setConfig` is internal; configure through `bootstrapClipboard`.)
153
+
143
154
  ## Observable Properties (outputs)
144
155
 
145
156
  | Property | Event | Description |
@@ -175,7 +186,7 @@ State-driven invocation uses the command-token protocol:
175
186
  ## Notes & limitations
176
187
 
177
188
  - **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.
178
- - **No connect-time read.** Unlike `<wcs-geo>`, the clipboard cannot auto-read on connect (reads need a user gesture and permission), so there is no `connectedCallbackPromise` / SSR snapshot. The only connect-time action is optional monitoring.
189
+ - **No connect-time read.** Unlike `<wcs-geo>`, the clipboard cannot auto-read on connect (reads need a user gesture and permission); the connect-time actions are an initial permission probe and optional monitoring. It still exposes `connectedCallbackPromise` (`hasConnectedCallbackPromise = true`) — a state binder / SSR awaits it so the initial permission snapshot has settled before binding.
179
190
  - **Reconnect re-subscribes.** Removing and re-inserting the element runs `connectedCallback` again, so permission tracking is revived and a `monitor`-attribute element restarts monitoring (matching how it tears them down on disconnect). Monitoring persistence is **attribute-driven only**: if you started monitoring imperatively with `startMonitor()` on an element *without* the `monitor` attribute, a reconnect does not restore it (the attribute is the source of truth). Add the `monitor` attribute for persistent monitoring across reparents.
180
191
  - **`copy` / `cut` text comes from the selection.** During a `copy` / `cut` event the clipboard payload is not yet readable (the browser returns an empty string for security reasons), so `copied` / `cut` report `document.getSelection().toString()` — the user's selected text. If the page installs a custom `copy` handler that overrides the payload via `clipboardData.setData(...)`, that override is **not** reflected in `copied` / `cut`. `pasted` reads `event.clipboardData.getData("text/plain")`.
181
192
  - **Silent failure handling (zero-log).** Consistent with the rest of wcstack's zero-dependency, minimal philosophy, `<wcs-clipboard>` never logs or throws for runtime failures. A failed permission query (e.g. Firefox, which has no clipboard permission names) silently falls back to `"unsupported"`. Read/write failures (denied permission, no focus, missing Clipboard API) are surfaced only through the `error` property / `wcs-clipboard:error` event — the commands resolve and never reject. Bind `error` (and the `*Permission` properties) to observe and react.
package/dist/index.d.ts CHANGED
@@ -1,19 +1,3 @@
1
- interface ITagNames {
2
- readonly clipboard: string;
3
- }
4
- interface IWritableTagNames {
5
- clipboard?: string;
6
- }
7
- interface IConfig {
8
- readonly autoTrigger: boolean;
9
- readonly triggerAttribute: string;
10
- readonly tagNames: ITagNames;
11
- }
12
- interface IWritableConfig {
13
- autoTrigger?: boolean;
14
- triggerAttribute?: string;
15
- tagNames?: IWritableTagNames;
16
- }
17
1
  interface IWcBindableProperty {
18
2
  readonly name: string;
19
3
  readonly event: string;
@@ -29,11 +13,29 @@ interface IWcBindableCommand {
29
13
  }
30
14
  interface IWcBindable {
31
15
  readonly protocol: "wc-bindable";
32
- readonly version: number;
33
- readonly properties: IWcBindableProperty[];
34
- readonly inputs?: IWcBindableInput[];
35
- readonly commands?: IWcBindableCommand[];
16
+ readonly version: 1;
17
+ readonly properties: readonly IWcBindableProperty[];
18
+ readonly inputs?: readonly IWcBindableInput[];
19
+ readonly commands?: readonly IWcBindableCommand[];
20
+ }
21
+
22
+ interface ITagNames {
23
+ readonly clipboard: string;
36
24
  }
25
+ interface IWritableTagNames {
26
+ clipboard?: string;
27
+ }
28
+ interface IConfig {
29
+ readonly autoTrigger: boolean;
30
+ readonly triggerAttribute: string;
31
+ readonly tagNames: ITagNames;
32
+ }
33
+ interface IWritableConfig {
34
+ autoTrigger?: boolean;
35
+ triggerAttribute?: string;
36
+ tagNames?: IWritableTagNames;
37
+ }
38
+
37
39
  /**
38
40
  * Permission state for the Clipboard API, mirroring the Permissions API
39
41
  * `PermissionState` plus `"unsupported"` for environments without
@@ -79,7 +81,7 @@ interface WcsClipboardErrorDetail {
79
81
  }
80
82
  /**
81
83
  * Value types for ClipboardCore (headless) — the observable state properties.
82
- * Use with `bind()` from `@wc-bindable/core` for compile-time type checking.
84
+ * Use with `bind()` from `a wc-bindable binding core` for compile-time type checking.
83
85
  *
84
86
  * @example
85
87
  * ```typescript
@@ -167,7 +169,10 @@ declare class ClipboardCore extends EventTarget {
167
169
  private _permissionSubscribed;
168
170
  private _permGen;
169
171
  private _acqGen;
172
+ private _ready;
170
173
  constructor(target?: EventTarget);
174
+ get ready(): Promise<void>;
175
+ observe(): Promise<void>;
171
176
  get text(): string | null;
172
177
  get items(): WcsClipboardReadItem[] | null;
173
178
  get loading(): boolean;
@@ -255,9 +260,12 @@ declare class ClipboardCore extends EventTarget {
255
260
  }
256
261
 
257
262
  declare class WcsClipboard extends HTMLElement {
263
+ static hasConnectedCallbackPromise: boolean;
258
264
  static wcBindable: IWcBindable;
259
265
  private _core;
266
+ private _connectedCallbackPromise;
260
267
  constructor();
268
+ get connectedCallbackPromise(): Promise<void>;
261
269
  get monitor(): boolean;
262
270
  /**
263
271
  * Reflects the `monitor` boolean attribute only — it does NOT start or stop
package/dist/index.esm.js CHANGED
@@ -126,6 +126,10 @@ class ClipboardCore extends EventTarget {
126
126
  // The Clipboard API has no AbortController, so a generation guard is the only
127
127
  // way to neutralize an in-flight op.
128
128
  _acqGen = 0;
129
+ // SSR (§3.8): resolves once the first permission probe settles, so the state
130
+ // binder can await a real snapshot before reading. Set by _initPermissions();
131
+ // Promise.resolve() when the Permissions API is unsupported (no async probe).
132
+ _ready = Promise.resolve();
129
133
  constructor(target) {
130
134
  super();
131
135
  this._target = target ?? this;
@@ -133,6 +137,19 @@ class ClipboardCore extends EventTarget {
133
137
  // before the first read, then keep them live.
134
138
  this._initPermissions();
135
139
  }
140
+ // SSR (§3.8): the first permission probe's settle promise.
141
+ get ready() {
142
+ return this._ready;
143
+ }
144
+ // Lifecycle (§3.5). Clipboard reads/writes are command-driven (they need a
145
+ // user gesture), so observe() establishes no acquisition; it only (re)subscribes
146
+ // to permission `change` events — idempotent while a subscription is live, and
147
+ // reviving it after a dispose() (reconnect/reparent). Returns ready so the Shell
148
+ // can expose it as connectedCallbackPromise.
149
+ observe() {
150
+ this.reinitPermission();
151
+ return this._ready;
152
+ }
136
153
  get text() {
137
154
  return this._text;
138
155
  }
@@ -300,6 +317,9 @@ class ClipboardCore extends EventTarget {
300
317
  if (this._monitoring)
301
318
  return;
302
319
  this._setMonitoring(true);
320
+ // §4 deviation: document-scoped Web API; no element-free alternative.
321
+ // copy/cut/paste fire on `document`, so monitoring necessarily listens there
322
+ // rather than on a Core-owned element. Registered as an allowed deviation.
303
323
  document.addEventListener("copy", this._onCopy);
304
324
  document.addEventListener("cut", this._onCut);
305
325
  document.addEventListener("paste", this._onPaste);
@@ -411,11 +431,13 @@ class ClipboardCore extends EventTarget {
411
431
  this._setPasted(text);
412
432
  };
413
433
  _removeMonitorListeners() {
434
+ // §4 deviation: document-scoped Web API; no element-free alternative.
414
435
  document.removeEventListener("copy", this._onCopy);
415
436
  document.removeEventListener("cut", this._onCut);
416
437
  document.removeEventListener("paste", this._onPaste);
417
438
  }
418
439
  _selectionText() {
440
+ // §4 deviation: document-scoped Web API; no element-free alternative.
419
441
  const selection = document.getSelection();
420
442
  return selection ? selection.toString() : "";
421
443
  }
@@ -432,15 +454,19 @@ class ClipboardCore extends EventTarget {
432
454
  if (typeof navigator === "undefined" || !navigator.permissions || typeof navigator.permissions.query !== "function") {
433
455
  this._setReadPermission("unsupported");
434
456
  this._setWritePermission("unsupported");
457
+ // No async probe: readiness is immediate (§3.8).
458
+ this._ready = Promise.resolve();
435
459
  return;
436
460
  }
437
461
  this._permissionSubscribed = true;
438
462
  const gen = ++this._permGen;
439
- this._queryPermission("clipboard-read", gen, (s) => { this._readStatus = s; }, (state) => this._setReadPermission(state), this._onReadChange);
440
- this._queryPermission("clipboard-write", gen, (s) => { this._writeStatus = s; }, (state) => this._setWritePermission(state), this._onWriteChange);
463
+ const readProbe = this._queryPermission("clipboard-read", gen, (s) => { this._readStatus = s; }, (state) => this._setReadPermission(state), this._onReadChange);
464
+ const writeProbe = this._queryPermission("clipboard-write", gen, (s) => { this._writeStatus = s; }, (state) => this._setWritePermission(state), this._onWriteChange);
465
+ // SSR (§3.8): ready resolves once both initial permission probes settle.
466
+ this._ready = Promise.all([readProbe, writeProbe]).then(() => undefined);
441
467
  }
442
468
  _queryPermission(name, gen, assignStatus, setState, onChange) {
443
- navigator.permissions.query({ name: name }).then((status) => {
469
+ return navigator.permissions.query({ name: name }).then((status) => {
444
470
  // Stale resolution: this query was superseded (rapid reconnect) or the
445
471
  // element was disposed while it was in flight. Drop it so only the
446
472
  // current subscription attaches a listener.
@@ -581,6 +607,7 @@ function registerAutoTrigger() {
581
607
  // DOM `Clipboard` interface (the type of `navigator.clipboard`), matching the
582
608
  // <wcs-geo> WcsGeolocation / <wcs-ws> WcsWebSocket convention.
583
609
  class WcsClipboard extends HTMLElement {
610
+ static hasConnectedCallbackPromise = true;
584
611
  static wcBindable = {
585
612
  ...ClipboardCore.wcBindable,
586
613
  // Shell-level settable surface. `monitor` mirrors its boolean attribute
@@ -599,10 +626,16 @@ class WcsClipboard extends HTMLElement {
599
626
  commands: ClipboardCore.wcBindable.commands,
600
627
  };
601
628
  _core;
629
+ _connectedCallbackPromise = Promise.resolve();
602
630
  constructor() {
603
631
  super();
604
632
  this._core = new ClipboardCore(this);
605
633
  }
634
+ // SSR (§4.4): the state binder awaits this before snapshotting, so the first
635
+ // permission probe has settled. Backed by _core.observe() (see connectedCallback).
636
+ get connectedCallbackPromise() {
637
+ return this._connectedCallbackPromise;
638
+ }
606
639
  // --- Attribute accessors ---
607
640
  get monitor() {
608
641
  return this.hasAttribute("monitor");
@@ -678,10 +711,10 @@ class WcsClipboard extends HTMLElement {
678
711
  if (config.autoTrigger) {
679
712
  registerAutoTrigger();
680
713
  }
681
- // Revive permission tracking after a reconnect (reparenting). No-op on the
682
- // first connect since the constructor already subscribed; only re-subscribes
683
- // when disconnectedCallback's dispose() tore the subscription down.
684
- this._core.reinitPermission();
714
+ // observe() revives permission tracking after a reconnect (reparenting)
715
+ // a no-op on the first connect since the constructor already subscribed and
716
+ // returns the readiness promise exposed as connectedCallbackPromise (§4.4).
717
+ this._connectedCallbackPromise = this._core.observe();
685
718
  // Unlike <wcs-geo>, there is no connect-time acquisition: reads require a
686
719
  // user gesture, so the only connect-time action is optional monitoring.
687
720
  if (this.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 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 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 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 document.removeEventListener(\"copy\", this._onCopy);\n document.removeEventListener(\"cut\", this._onCut);\n document.removeEventListener(\"paste\", this._onPaste);\n }\n\n private _selectionText(): string {\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 return;\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n this._queryPermission(\n \"clipboard-read\", gen,\n (s) => { this._readStatus = s; },\n (state) => this._setReadPermission(state),\n this._onReadChange,\n );\n this._queryPermission(\n \"clipboard-write\", gen,\n (s) => { this._writeStatus = s; },\n (state) => this._setWritePermission(state),\n this._onWriteChange,\n );\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 ): void {\n 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 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\n constructor() {\n super();\n this._core = new ClipboardCore(this);\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 // Revive permission tracking after a reconnect (reparenting). No-op on the\n // first connect since the constructor already subscribed; only re-subscribes\n // when disconnectedCallback's dispose() tore the subscription down.\n this._core.reinitPermission();\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,SAAS,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IAC/D;AACA,IAAA,OAAO,KAAU;AACnB;AAEA,IAAI,YAAY,GAAmB,IAAI;AAEhC,MAAM,MAAM,GA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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;;;SChJc,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
+ {"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,sBAAs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A,IAAI,MAAM,CAAC,WAAW,EAAE;AACtB,YAAA,mBAAmB,EAAE;QACvB;;;;QAIA,IAAI,CAAC,yBAAyB,GAAG,IAAI,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;;;SCxJc,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 i of Object.keys(t))e(t[i]);return t}function i(t){if(null===t||"object"!=typeof t)return t;const e={};for(const r of Object.keys(t))e[r]=i(t[r]);return e}let r=null;const s=t;function n(){return r||(r=e(i(t))),r}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;constructor(t){super(),this._target=t??this,this._initPermissions()}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 i=await t();if(e!==this._acqGen)return;this._setLoading(!1),i&&this._setRead(i)}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,i=e?e.getData("text/plain"):"";this._setPasted(i)};_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"),void this._setWritePermission("unsupported");this._permissionSubscribed=!0;const t=++this._permGen;this._queryPermission("clipboard-read",t,t=>{this._readStatus=t},t=>this._setReadPermission(t),this._onReadChange),this._queryPermission("clipboard-write",t,t=>{this._writeStatus=t},t=>this._setWritePermission(t),this._onWriteChange)}_queryPermission(t,e,i,r,s){navigator.permissions.query({name:t}).then(t=>{e===this._permGen&&(i(t),r(t.state),t.addEventListener("change",s))},()=>{e===this._permGen&&r("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})))),i=[];let r=null;for(const{item:t,blobs:s}of e){const e={};if(t.types.forEach((t,i)=>{e[t]=s[i]}),null===r){const e=t.types.indexOf("text/plain");-1!==e&&(r=await s[e].text())}i.push({types:[...t.types],data:e})}return{text:r,items:i}}_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 i=e.closest(`[${s.triggerAttribute}]`);if(!i)return;const r=i.getAttribute(s.triggerAttribute);if(!r)return;const n=customElements.get(s.tagNames.clipboard),o=document.getElementById(r);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 i=document.querySelector(e);return i?i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement?i.value:i.textContent??"":null}(i);null!==a&&(t.preventDefault(),o.writeText(a))}class u extends HTMLElement{static wcBindable={...o.wcBindable,inputs:[{name:"monitor",attribute:"monitor"}],commands:o.wcBindable.commands};_core;constructor(){super(),this._core=new o(this)}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._core.reinitPermission(),this.monitor&&this._core.startMonitor()}disconnectedCallback(){this._core.stopMonitor(),this._core.dispose()}}function m(e){var i;e&&("boolean"==typeof(i=e).autoTrigger&&(t.autoTrigger=i.autoTrigger),"string"==typeof i.triggerAttribute&&(t.triggerAttribute=i.triggerAttribute),i.tagNames&&Object.assign(t.tagNames,i.tagNames),r=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();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};
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 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 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 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 document.removeEventListener(\"copy\", this._onCopy);\n document.removeEventListener(\"cut\", this._onCut);\n document.removeEventListener(\"paste\", this._onPaste);\n }\n\n private _selectionText(): string {\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 return;\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n this._queryPermission(\n \"clipboard-read\", gen,\n (s) => { this._readStatus = s; },\n (state) => this._setReadPermission(state),\n this._onReadChange,\n );\n this._queryPermission(\n \"clipboard-write\", gen,\n (s) => { this._writeStatus = s; },\n (state) => this._setWritePermission(state),\n this._onWriteChange,\n );\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 ): void {\n 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 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\n constructor() {\n super();\n this._core = new ClipboardCore(this);\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 // Revive permission tracking after a reconnect (reparenting). No-op on the\n // first connect since the constructor already subscribed; only re-subscribes\n // when disconnectedCallback's dispose() tore the subscription down.\n this._core.reinitPermission();\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","constructor","target","super","this","_initPermissions","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","reinitPermission","dispose","removeEventListener","_onReadChange","_onWriteChange","op","_runOp","_hasClipboard","_unsupportedError","gen","err","_normalizeError","_selectionText","data","clipboardData","getData","selection","getSelection","toString","permissions","query","_queryPermission","s","state","assignStatus","setState","onChange","then","status","resolved","Promise","all","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","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,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,OAAQC,MAAO,qBAAsBC,OAASC,GAAcA,EAAkBC,OAAOC,MAC7F,CAAEL,KAAM,QAASC,MAAO,qBAAsBC,OAASC,GAAcA,EAAkBC,OAAOE,OAC9F,CAAEN,KAAM,UAAWC,MAAO,iCAC1B,CAAED,KAAM,QAASC,MAAO,uBACxB,CAAED,KAAM,iBAAkBC,MA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OwK,OAAO/K,EAAQG,SAAU2K,EAAc3K,UAEhDU,EAAe,MKrDVmI,eAAeC,IAAInI,EAAOX,SAASC,YACtC4I,eAAegC,OAAOlK,EAAOX,SAASC,UAAW2J,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\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,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAA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qH,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/clipboard",
3
- "version": "1.14.0",
3
+ "version": "1.16.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",