@wcstack/clipboard 1.20.0 → 1.21.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
@@ -157,6 +157,7 @@ DOM の autoTrigger は書き込み(`writeText`)のみを起動します。
157
157
  | `items` | `wcs-clipboard:read` | `read()` から正規化した `ClipboardItem` スナップショット(`{ types, data }[]`)、なければ `null`。 |
158
158
  | `loading` | `wcs-clipboard:loading-changed` | 非同期の read/write 中は `true`。 |
159
159
  | `error` | `wcs-clipboard:error` | 正規化された `{ name, message }`(例: `NotAllowedError`, `NotSupportedError`)。 |
160
+ | `errorInfo` | `wcs-clipboard:error-info-changed` | serializable な失敗 taxonomy(`WcsIoErrorInfo`)、または `null`。追加的で `error.name` から導出(`NotSupportedError` → `capability-missing`、`NotAllowedError` → `not-allowed`、その他 → `clipboard-error`)。`error` の shape は不変。 |
160
161
  | `readPermission` | `wcs-clipboard:read-permission-changed` | `clipboard-read` の `"prompt"` / `"granted"` / `"denied"` / `"unsupported"`。 |
161
162
  | `writePermission` | `wcs-clipboard:write-permission-changed` | `clipboard-write` について同様の状態。 |
162
163
  | `monitoring` | `wcs-clipboard:monitoring-changed` | ドキュメントのクリップボードイベントを監視中は `true`。 |
package/README.md CHANGED
@@ -159,6 +159,7 @@ Add the `monitor` attribute to republish document `copy` / `cut` / `paste` as re
159
159
  | `items` | `wcs-clipboard:read` | Normalized `ClipboardItem` snapshot from `read()` (`{ types, data }[]`), or `null`. |
160
160
  | `loading` | `wcs-clipboard:loading-changed` | `true` during any async read/write. |
161
161
  | `error` | `wcs-clipboard:error` | Normalized `{ name, message }` (e.g. `NotAllowedError`, `NotSupportedError`). |
162
+ | `errorInfo` | `wcs-clipboard:error-info-changed` | Serializable failure taxonomy (`WcsIoErrorInfo`), or `null`. Additive — derived from `error.name` (`NotSupportedError` → `capability-missing`, `NotAllowedError` → `not-allowed`, else → `clipboard-error`). The `error` shape is unchanged. |
162
163
  | `readPermission` | `wcs-clipboard:read-permission-changed` | `"prompt"` / `"granted"` / `"denied"` / `"unsupported"` for `clipboard-read`. |
163
164
  | `writePermission`| `wcs-clipboard:write-permission-changed` | Same states for `clipboard-write`. |
164
165
  | `monitoring` | `wcs-clipboard:monitoring-changed` | `true` while monitoring document clipboard events. |
package/dist/index.d.ts CHANGED
@@ -1,3 +1,14 @@
1
+ /** operation error の phase(taxonomy)。 */
2
+ type WcsIoErrorPhase = "probe" | "start" | "execute" | "decode" | "commit" | "dispose";
3
+ /** serializable な error info(non-cloneable な cause とは分離。DevTools / remote へは info のみ)。 */
4
+ interface WcsIoErrorInfo {
5
+ readonly code: string;
6
+ readonly phase: WcsIoErrorPhase;
7
+ readonly recoverable: boolean;
8
+ readonly capabilityId?: string;
9
+ readonly message: string;
10
+ }
11
+
1
12
  interface IWcBindableProperty {
2
13
  readonly name: string;
3
14
  readonly event: string;
@@ -13,7 +24,8 @@ interface IWcBindableCommand {
13
24
  }
14
25
  interface IWcBindable {
15
26
  readonly protocol: "wc-bindable";
16
- readonly version: 1;
27
+ /** Integer protocol version. All versions >= 1 are core-compatible. */
28
+ readonly version: number;
17
29
  readonly properties: readonly IWcBindableProperty[];
18
30
  readonly inputs?: readonly IWcBindableInput[];
19
31
  readonly commands?: readonly IWcBindableCommand[];
@@ -94,6 +106,8 @@ interface WcsClipboardCoreValues {
94
106
  items: WcsClipboardReadItem[] | null;
95
107
  loading: boolean;
96
108
  error: WcsClipboardErrorDetail | null;
109
+ /** Last failure's serializable taxonomy (stable code/phase/recoverable), or null. */
110
+ errorInfo: WcsIoErrorInfo | null;
97
111
  readPermission: ClipboardPermissionState;
98
112
  writePermission: ClipboardPermissionState;
99
113
  monitoring: boolean;
@@ -158,6 +172,7 @@ declare class ClipboardCore extends EventTarget {
158
172
  private _items;
159
173
  private _loading;
160
174
  private _error;
175
+ private _errorInfo;
161
176
  private _readPermission;
162
177
  private _writePermission;
163
178
  private _monitoring;
@@ -177,6 +192,13 @@ declare class ClipboardCore extends EventTarget {
177
192
  get items(): WcsClipboardReadItem[] | null;
178
193
  get loading(): boolean;
179
194
  get error(): WcsClipboardErrorDetail | null;
195
+ /**
196
+ * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /
197
+ * `recoverable`), or null. Exposed as an additive wc-bindable property (event
198
+ * `wcs-clipboard:error-info-changed`), derived from the normalized `error`; the
199
+ * existing `error` property/event are unchanged.
200
+ */
201
+ get errorInfo(): WcsIoErrorInfo | null;
180
202
  get readPermission(): ClipboardPermissionState;
181
203
  get writePermission(): ClipboardPermissionState;
182
204
  get monitoring(): boolean;
@@ -186,6 +208,7 @@ declare class ClipboardCore extends EventTarget {
186
208
  private _setRead;
187
209
  private _setLoading;
188
210
  private _setError;
211
+ private _commitErrorInfo;
189
212
  private _setReadPermission;
190
213
  private _setWritePermission;
191
214
  private _setMonitoring;
@@ -283,6 +306,7 @@ declare class WcsClipboard extends HTMLElement {
283
306
  get items(): WcsClipboardReadItem[] | null;
284
307
  get loading(): boolean;
285
308
  get error(): WcsClipboardErrorDetail | null;
309
+ get errorInfo(): WcsIoErrorInfo | null;
286
310
  get readPermission(): ClipboardPermissionState;
287
311
  get writePermission(): ClipboardPermissionState;
288
312
  get monitoring(): boolean;
@@ -299,5 +323,21 @@ declare class WcsClipboard extends HTMLElement {
299
323
  disconnectedCallback(): void;
300
324
  }
301
325
 
302
- export { ClipboardCore, WcsClipboard, bootstrapClipboard, getConfig };
303
- export type { ClipboardPermissionState, IWritableConfig, IWritableTagNames, WcsClipboardCommands, WcsClipboardCoreCommands, WcsClipboardCoreValues, WcsClipboardErrorDetail, WcsClipboardInputs, WcsClipboardReadDetail, WcsClipboardReadItem, WcsClipboardValues };
326
+ /**
327
+ * clipboardCapabilities.ts
328
+ *
329
+ * Clipboard node 固有の error code(taxonomy)と derivation。汎用の error info 型は
330
+ * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から
331
+ * import する。clipboard の read/write は concurrent-independent(競合しない)ため lane
332
+ * は持たず、error taxonomy(errorInfo)のみを採用する。
333
+ */
334
+
335
+ /** 安定した clipboard error code(taxonomy)。値は公開キーとして固定。 */
336
+ declare const WCS_CLIPBOARD_ERROR_CODE: {
337
+ readonly CapabilityMissing: "capability-missing";
338
+ readonly NotAllowed: "not-allowed";
339
+ readonly ClipboardError: "clipboard-error";
340
+ };
341
+
342
+ export { ClipboardCore, WCS_CLIPBOARD_ERROR_CODE, WcsClipboard, bootstrapClipboard, getConfig };
343
+ export type { ClipboardPermissionState, IWritableConfig, IWritableTagNames, WcsClipboardCommands, WcsClipboardCoreCommands, WcsClipboardCoreValues, WcsClipboardErrorDetail, WcsClipboardInputs, WcsClipboardReadDetail, WcsClipboardReadItem, WcsClipboardValues, WcsIoErrorInfo, WcsIoErrorPhase };
package/dist/index.esm.js CHANGED
@@ -44,6 +44,35 @@ function setConfig(partialConfig) {
44
44
  frozenConfig = null;
45
45
  }
46
46
 
47
+ /**
48
+ * clipboardCapabilities.ts
49
+ *
50
+ * Clipboard node 固有の error code(taxonomy)と derivation。汎用の error info 型は
51
+ * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から
52
+ * import する。clipboard の read/write は concurrent-independent(競合しない)ため lane
53
+ * は持たず、error taxonomy(errorInfo)のみを採用する。
54
+ */
55
+ /** 安定した clipboard error code(taxonomy)。値は公開キーとして固定。 */
56
+ const WCS_CLIPBOARD_ERROR_CODE = {
57
+ CapabilityMissing: "capability-missing",
58
+ NotAllowed: "not-allowed",
59
+ ClipboardError: "clipboard-error",
60
+ };
61
+ /**
62
+ * 正規化済み error(`{ name, message }`)を serializable な error taxonomy に写す。
63
+ * `NotSupportedError`(Clipboard API 不在)→ capability-missing、`NotAllowedError`
64
+ * (permission 拒否、retry では回復しない)→ not-allowed、その他 → clipboard-error。
65
+ */
66
+ function deriveClipboardErrorInfo(name, message) {
67
+ if (name === "NotSupportedError") {
68
+ return { code: WCS_CLIPBOARD_ERROR_CODE.CapabilityMissing, phase: "start", recoverable: false, message };
69
+ }
70
+ if (name === "NotAllowedError") {
71
+ return { code: WCS_CLIPBOARD_ERROR_CODE.NotAllowed, phase: "execute", recoverable: false, message };
72
+ }
73
+ return { code: WCS_CLIPBOARD_ERROR_CODE.ClipboardError, phase: "execute", recoverable: true, message };
74
+ }
75
+
47
76
  /**
48
77
  * Headless clipboard primitive. A thin, framework-agnostic wrapper around the
49
78
  * Clipboard API exposed through the wc-bindable protocol.
@@ -79,6 +108,11 @@ class ClipboardCore extends EventTarget {
79
108
  { name: "readPermission", event: "wcs-clipboard:read-permission-changed" },
80
109
  { name: "writePermission", event: "wcs-clipboard:write-permission-changed" },
81
110
  { name: "monitoring", event: "wcs-clipboard:monitoring-changed" },
111
+ // Serializable failure taxonomy (stable code / phase / recoverable), or null.
112
+ // Additive bindable output derived from the normalized `error` (`name` →
113
+ // capability-missing / not-allowed / clipboard-error); the existing `error`
114
+ // property/event are unchanged. Fires `wcs-clipboard:error-info-changed`.
115
+ { name: "errorInfo", event: "wcs-clipboard:error-info-changed" },
82
116
  { name: "copied", event: "wcs-clipboard:copied", getter: (e) => e.detail },
83
117
  { name: "cut", event: "wcs-clipboard:cut", getter: (e) => e.detail },
84
118
  { name: "pasted", event: "wcs-clipboard:pasted", getter: (e) => e.detail },
@@ -97,6 +131,7 @@ class ClipboardCore extends EventTarget {
97
131
  _items = null;
98
132
  _loading = false;
99
133
  _error = null;
134
+ _errorInfo = null;
100
135
  _readPermission = "prompt";
101
136
  _writePermission = "prompt";
102
137
  _monitoring = false;
@@ -162,6 +197,15 @@ class ClipboardCore extends EventTarget {
162
197
  get error() {
163
198
  return this._error;
164
199
  }
200
+ /**
201
+ * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /
202
+ * `recoverable`), or null. Exposed as an additive wc-bindable property (event
203
+ * `wcs-clipboard:error-info-changed`), derived from the normalized `error`; the
204
+ * existing `error` property/event are unchanged.
205
+ */
206
+ get errorInfo() {
207
+ return this._errorInfo;
208
+ }
165
209
  get readPermission() {
166
210
  return this._readPermission;
167
211
  }
@@ -210,11 +254,26 @@ class ClipboardCore extends EventTarget {
210
254
  if (this._error === error)
211
255
  return;
212
256
  this._error = error;
257
+ // Keep the additive `errorInfo` taxonomy in sync with `error`: derive it from
258
+ // the normalized error (or null on clear). Fires before the `error` event so an
259
+ // observer binding both sees the classification first, mirroring the io-node
260
+ // family. No lane here — clipboard's read/write ops don't compete.
261
+ this._commitErrorInfo(error === null ? null : deriveClipboardErrorInfo(error.name, error.message));
213
262
  this._target.dispatchEvent(new CustomEvent("wcs-clipboard:error", {
214
263
  detail: error,
215
264
  bubbles: true,
216
265
  }));
217
266
  }
267
+ // Called only from _setError (which already same-value-guards on the error
268
+ // reference), so errorInfo transitions exactly when error does — no separate
269
+ // guard needed here.
270
+ _commitErrorInfo(info) {
271
+ this._errorInfo = info;
272
+ this._target.dispatchEvent(new CustomEvent("wcs-clipboard:error-info-changed", {
273
+ detail: info,
274
+ bubbles: true,
275
+ }));
276
+ }
218
277
  _setReadPermission(permission) {
219
278
  if (this._readPermission === permission)
220
279
  return;
@@ -723,6 +782,9 @@ class WcsClipboard extends HTMLElement {
723
782
  get error() {
724
783
  return this._core.error;
725
784
  }
785
+ get errorInfo() {
786
+ return this._core.errorInfo;
787
+ }
726
788
  get readPermission() {
727
789
  return this._core.readPermission;
728
790
  }
@@ -795,5 +857,5 @@ function bootstrapClipboard(userConfig) {
795
857
  registerComponents();
796
858
  }
797
859
 
798
- export { ClipboardCore, WcsClipboard, bootstrapClipboard, getConfig };
860
+ export { ClipboardCore, WCS_CLIPBOARD_ERROR_CODE, WcsClipboard, bootstrapClipboard, getConfig };
799
861
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/ClipboardCore.ts","../src/autoTrigger.ts","../src/components/Clipboard.ts","../src/registerComponents.ts","../src/bootstrapClipboard.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n clipboard: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-clipboardtarget\",\n tagNames: {\n clipboard: \"wcs-clipboard\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardReadDetail, WcsClipboardErrorDetail,\n} from \"../types.js\";\n\n/**\n * Headless clipboard primitive. A thin, framework-agnostic wrapper around the\n * Clipboard API exposed through the wc-bindable protocol.\n *\n * It has two surfaces, mirroring the two distinct shapes of clipboard access:\n * - **commands** — `writeText()` / `write()` push to the clipboard;\n * `readText()` / `read()` pull from it. These are the `state → element`\n * (command-token) and `element → state` (read result) paths. All four are\n * async and never reject: failures surface through the `error` property so\n * they flow into the declarative state, symmetrical with FetchCore /\n * GeolocationCore.\n * - **monitor** — `startMonitor()` / `stopMonitor()` subscribe to the document's\n * `copy` / `cut` / `paste` events and republish them as the `copied` / `cut` /\n * `pasted` properties (like TimerCore's continuous `start()` / `stop()`),\n * toggling the `monitoring` flag. This is the event-token showcase: a user\n * paste flows element → state declaratively.\n *\n * Clipboard also has permission gates, like GeolocationCore but doubled: read\n * and write are separate permissions (`clipboard-read` / `clipboard-write`).\n * `readPermission` / `writePermission` reflect `navigator.permissions.query`\n * (`prompt` / `granted` / `denied`, or `unsupported`) and track their live\n * `change` events.\n */\nexport class ClipboardCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"text\", event: \"wcs-clipboard:read\", getter: (e: Event) => (e as CustomEvent).detail.text },\n { name: \"items\", event: \"wcs-clipboard:read\", getter: (e: Event) => (e as CustomEvent).detail.items },\n { name: \"loading\", event: \"wcs-clipboard:loading-changed\" },\n { name: \"error\", event: \"wcs-clipboard:error\" },\n { name: \"readPermission\", event: \"wcs-clipboard:read-permission-changed\" },\n { name: \"writePermission\", event: \"wcs-clipboard:write-permission-changed\" },\n { name: \"monitoring\", event: \"wcs-clipboard:monitoring-changed\" },\n { name: \"copied\", event: \"wcs-clipboard:copied\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"cut\", event: \"wcs-clipboard:cut\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"pasted\", event: \"wcs-clipboard:pasted\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"writeText\", async: true },\n { name: \"write\", async: true },\n { name: \"readText\", async: true },\n { name: \"read\", async: true },\n { name: \"startMonitor\" },\n { name: \"stopMonitor\" },\n ],\n };\n\n private _target: EventTarget;\n\n private _text: string | null = null;\n private _items: WcsClipboardReadItem[] | null = null;\n private _loading: boolean = false;\n private _error: WcsClipboardErrorDetail | null = null;\n private _readPermission: ClipboardPermissionState = \"prompt\";\n private _writePermission: ClipboardPermissionState = \"prompt\";\n\n private _monitoring: boolean = false;\n private _copied: string | null = null;\n private _cut: string | null = null;\n private _pasted: string | null = null;\n\n // Live PermissionStatus handles (when the Permissions API is available), kept\n // so the `change` listeners can be removed on dispose(). Read and write are\n // separate permissions, hence two handles.\n private _readStatus: PermissionStatus | null = null;\n private _writeStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards reinitPermission() so the first connect after\n // construction does not double-subscribe, while a reconnect after dispose()\n // does re-subscribe. (Mirrors GeolocationCore.)\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query round. Bumped by every\n // _initPermissions() and by dispose(). Each in-flight query captures it and,\n // on resolve, bails unless it is still current — so a query superseded by a\n // rapid (synchronous) disconnect→reconnect, or one that resolves after\n // dispose(), never attaches a listener.\n private _permGen: number = 0;\n\n // Monotonic id of the current async acquisition lifecycle (read/write),\n // bumped only by dispose(). Each command captures it at start; the resolution\n // bails (no setters) if it is stale, so an op that settles after the element\n // was disconnected does not dispatch wcs-clipboard:* on a torn-down element.\n // The Clipboard API has no AbortController, so a generation guard is the only\n // way to neutralize an in-flight op.\n private _acqGen: number = 0;\n\n // SSR (§3.8): resolves once the first permission probe settles, so the state\n // binder can await a real snapshot before reading. Set by _initPermissions();\n // Promise.resolve() when the Permissions API is unsupported (no async probe).\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Probe the permission states up front so observers see the real values\n // before the first read, then keep them live.\n this._initPermissions();\n }\n\n // SSR (§3.8): the first permission probe's settle promise.\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). Clipboard reads/writes are command-driven (they need a\n // user gesture), so observe() establishes no acquisition; it only (re)subscribes\n // to permission `change` events — idempotent while a subscription is live, and\n // reviving it after a dispose() (reconnect/reparent). Returns ready so the Shell\n // can expose it as connectedCallbackPromise.\n observe(): Promise<void> {\n this.reinitPermission();\n return this._ready;\n }\n\n get text(): string | null {\n return this._text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._items;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._error;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._writePermission;\n }\n\n get monitoring(): boolean {\n return this._monitoring;\n }\n\n get copied(): string | null {\n return this._copied;\n }\n\n get cut(): string | null {\n return this._cut;\n }\n\n get pasted(): string | null {\n return this._pasted;\n }\n\n // --- State setters with event dispatch ---\n\n // Deliberately NO same-value guard (unlike error/loading/permission/monitoring).\n // A read is a result event, not idempotent state: reading the same text twice is\n // two distinct user/command actions and must re-fire wcs-clipboard:read each time\n // so a `text:`/`items:` binding and command-result consumers see every read.\n private _setRead(detail: WcsClipboardReadDetail): void {\n this._text = detail.text;\n this._items = detail.items;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read\", {\n detail,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n if (this._loading === loading) return;\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsClipboardErrorDetail | null): void {\n // Same-value guard. `error` has no derived state, so suppressing redundant\n // null→null dispatches (e.g. a successful op clearing an already-null error)\n // avoids spurious events. Reference identity is sufficient: each failure\n // builds a fresh object, and the clear path always passes the literal null.\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _setReadPermission(permission: ClipboardPermissionState): void {\n if (this._readPermission === permission) return;\n this._readPermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setWritePermission(permission: ClipboardPermissionState): void {\n if (this._writePermission === permission) return;\n this._writePermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:write-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setMonitoring(monitoring: boolean): void {\n if (this._monitoring === monitoring) return;\n this._monitoring = monitoring;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:monitoring-changed\", {\n detail: monitoring,\n bubbles: true,\n }));\n }\n\n // Deliberately NO same-value guard on the copied/cut/pasted setters (unlike\n // error/loading/permission/monitoring above). These are events, not state:\n // copying the same text twice is two distinct user actions and must re-fire\n // both times so an event-token subscriber (`eventToken.pasted: ...`) sees each\n // occurrence. Do not add a `===` guard here.\n private _setCopied(text: string): void {\n this._copied = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:copied\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setCut(text: string): void {\n this._cut = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:cut\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setPasted(text: string): void {\n this._pasted = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:pasted\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n // --- Public API: write ---\n\n /**\n * Write plain text to the clipboard. Resolves once the write settles or fails\n * — never rejects: failures surface through `error`. Requires transient\n * activation (a user gesture), so call from a click handler / command-token.\n */\n writeText(text: string): Promise<void> {\n return this._runWrite(() => navigator.clipboard.writeText(text));\n }\n\n /**\n * Write rich `ClipboardItem`s (images, HTML, multiple MIME types) to the\n * clipboard. Resolves once the write settles or fails — never rejects.\n */\n write(items: ClipboardItem[]): Promise<void> {\n return this._runWrite(() => navigator.clipboard.write(items));\n }\n\n // --- Public API: read ---\n\n /**\n * Read plain text from the clipboard, publishing it via `text` and the\n * `wcs-clipboard:read` event. Resolves once the read settles or fails — never\n * rejects. Requires focus + read permission.\n */\n readText(): Promise<void> {\n return this._runRead(async () => {\n const text = await navigator.clipboard.readText();\n return { text, items: null };\n });\n }\n\n /**\n * Read rich `ClipboardItem`s from the clipboard, eagerly resolving every\n * representation to a `Blob`. A `text/plain` representation is also surfaced\n * via `text`. Resolves once the read settles or fails — never rejects.\n */\n read(): Promise<void> {\n return this._runRead(async () => {\n const items = await navigator.clipboard.read();\n return this._normalizeItems(items);\n });\n }\n\n // --- Public API: monitor ---\n\n /**\n * Begin monitoring document `copy` / `cut` / `paste` events, republishing\n * them as the `copied` / `cut` / `pasted` properties. Idempotent while already\n * monitoring (mirrors GeolocationCore.watch()).\n */\n startMonitor(): void {\n if (this._monitoring) return;\n this._setMonitoring(true);\n // §4 deviation: document-scoped Web API; no element-free alternative.\n // copy/cut/paste fire on `document`, so monitoring necessarily listens there\n // rather than on a Core-owned element. Registered as an allowed deviation.\n document.addEventListener(\"copy\", this._onCopy);\n document.addEventListener(\"cut\", this._onCut);\n document.addEventListener(\"paste\", this._onPaste);\n }\n\n stopMonitor(): void {\n this._removeMonitorListeners();\n this._setMonitoring(false);\n }\n\n // --- Permission lifecycle ---\n\n /**\n * Re-establish the permission `change` subscriptions after a dispose() — e.g.\n * the Shell element was disconnected and then reconnected (reparented). No-op\n * while a subscription is already live, so the first connect after\n * construction does not double-subscribe.\n */\n reinitPermission(): void {\n if (!this._permissionSubscribed) {\n this._initPermissions();\n }\n }\n\n /**\n * Detach the live permission `change` listeners and any monitor listeners, and\n * neutralize in-flight async ops. Call from the Shell's `disconnectedCallback`\n * so a removed element does not leak subscriptions or dispatch on a torn-down\n * element. A later reconnect can re-subscribe via reinitPermission().\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight permission query so its .then() bails instead of\n // attaching a listener after teardown.\n this._permGen++;\n // Invalidate any in-flight read/write so its resolution bails instead of\n // dispatching on a disconnected element.\n this._acqGen++;\n // Reset the loading shadow silently (no dispatch on a disposed element). The\n // bailed resolution will not clear it, and leaving it true would let the\n // same-value guard swallow the loading=true edge of the next op after a\n // reconnect.\n this._loading = false;\n if (this._readStatus) {\n this._readStatus.removeEventListener(\"change\", this._onReadChange);\n this._readStatus = null;\n }\n if (this._writeStatus) {\n this._writeStatus.removeEventListener(\"change\", this._onWriteChange);\n this._writeStatus = null;\n }\n // Remove monitor listeners silently. The Shell calls stopMonitor() before\n // dispose(), but a direct headless dispose() still tears them down.\n this._removeMonitorListeners();\n this._monitoring = false;\n }\n\n // --- Internal: write/read runners ---\n\n private _runWrite(op: () => Promise<void>): Promise<void> {\n return this._runOp(async () => {\n await op();\n return null;\n });\n }\n\n private _runRead(op: () => Promise<WcsClipboardReadDetail>): Promise<void> {\n return this._runOp(op);\n }\n\n /**\n * Shared async-op lifecycle for read/write: capability check, loading toggle,\n * generation guard, never-reject error handling. When `op` returns a read\n * detail it is published; when it returns null (a write) nothing is published.\n */\n private async _runOp(op: () => Promise<WcsClipboardReadDetail | null>): Promise<void> {\n if (!this._hasClipboard()) {\n this._setError(this._unsupportedError());\n return;\n }\n const gen = this._acqGen;\n this._setLoading(true);\n this._setError(null);\n try {\n const detail = await op();\n // Stale: the element was disposed (disconnected) while this op was in\n // flight. Drop it so a torn-down element never dispatches wcs-clipboard:*.\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n if (detail) this._setRead(detail);\n } catch (err) {\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n this._setError(this._normalizeError(err));\n }\n }\n\n // --- Internal: monitor handlers ---\n\n // During a `copy` / `cut` event the clipboard payload is not yet readable —\n // the browser returns an empty string for security reasons — so we report the\n // user's selected text (`document.getSelection().toString()`) instead. A page\n // that overrides the payload with a custom handler via clipboardData.setData()\n // is therefore NOT reflected here. (See README \"copy / cut text comes from the\n // selection\".) `paste` differs: clipboardData is readable, so _onPaste reads it.\n private _onCopy = (): void => {\n this._setCopied(this._selectionText());\n };\n\n private _onCut = (): void => {\n this._setCut(this._selectionText());\n };\n\n private _onPaste = (event: Event): void => {\n const data = (event as ClipboardEvent).clipboardData;\n const text = data ? data.getData(\"text/plain\") : \"\";\n this._setPasted(text);\n };\n\n private _removeMonitorListeners(): void {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n document.removeEventListener(\"copy\", this._onCopy);\n document.removeEventListener(\"cut\", this._onCut);\n document.removeEventListener(\"paste\", this._onPaste);\n }\n\n private _selectionText(): string {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n const selection = document.getSelection();\n return selection ? selection.toString() : \"\";\n }\n\n // --- Internal: permission ---\n\n private _initPermissions(): void {\n // The Permissions API is optional. When absent (or it rejects, e.g. Firefox\n // does not expose the clipboard permission names), report \"unsupported\" and\n // leave reads/writes to fail loudly via the error property if attempted.\n // Note: we deliberately do NOT set _permissionSubscribed here — there is no\n // live subscription to tear down, so reinitPermission() re-runs this branch\n // on every reconnect. That is harmless: the same-value guard in\n // _setReadPermission/_setWritePermission swallows the redundant\n // unsupported→unsupported dispatch. (Mirrors GeolocationCore.)\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n this._setReadPermission(\"unsupported\");\n this._setWritePermission(\"unsupported\");\n // No async probe: readiness is immediate (§3.8).\n this._ready = Promise.resolve();\n return;\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n const readProbe = this._queryPermission(\n \"clipboard-read\", gen,\n (s) => { this._readStatus = s; },\n (state) => this._setReadPermission(state),\n this._onReadChange,\n );\n const writeProbe = this._queryPermission(\n \"clipboard-write\", gen,\n (s) => { this._writeStatus = s; },\n (state) => this._setWritePermission(state),\n this._onWriteChange,\n );\n // SSR (§3.8): ready resolves once both initial permission probes settle.\n this._ready = Promise.all([readProbe, writeProbe]).then(() => undefined);\n }\n\n private _queryPermission(\n name: string,\n gen: number,\n assignStatus: (status: PermissionStatus) => void,\n setState: (state: ClipboardPermissionState) => void,\n onChange: (event: Event) => void,\n ): Promise<void> {\n return navigator.permissions.query({ name: name as PermissionName }).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the\n // current subscription attaches a listener.\n if (gen !== this._permGen) return;\n assignStatus(status);\n setState(status.state as ClipboardPermissionState);\n status.addEventListener(\"change\", onChange);\n },\n () => {\n if (gen !== this._permGen) return;\n setState(\"unsupported\");\n },\n );\n }\n\n private _onReadChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setReadPermission(status.state as ClipboardPermissionState);\n };\n\n private _onWriteChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setWritePermission(status.state as ClipboardPermissionState);\n };\n\n // --- Internal: normalization ---\n\n private _hasClipboard(): boolean {\n return typeof navigator !== \"undefined\" && !!navigator.clipboard;\n }\n\n private async _normalizeItems(items: ClipboardItem[]): Promise<WcsClipboardReadDetail> {\n // Resolve every representation of every item in parallel. getType() calls are\n // independent, so awaiting them serially only adds latency. The trade-off is\n // intentional and unchanged from the serial version: if any getType() rejects\n // the whole read errors (no partial success), consistent with the never-reject\n // design where a failed op surfaces a single `error` rather than a half-filled\n // snapshot. Order is preserved so the `text` pick below stays deterministic.\n const resolved = await Promise.all(\n items.map((item) =>\n Promise.all(item.types.map((type) => item.getType(type))).then((blobs) => ({ item, blobs })),\n ),\n );\n\n const normalized: WcsClipboardReadItem[] = [];\n let text: string | null = null;\n for (const { item, blobs } of resolved) {\n const data: Record<string, Blob> = {};\n item.types.forEach((type, i) => {\n data[type] = blobs[i];\n });\n // Surface the first text/plain representation through `text` for the\n // common \"read whatever text is there\" case (first item, first match).\n if (text === null) {\n const i = item.types.indexOf(\"text/plain\");\n if (i !== -1) {\n text = await blobs[i].text();\n }\n }\n normalized.push({ types: [...item.types], data });\n }\n return { text, items: normalized };\n }\n\n private _normalizeError(err: unknown): WcsClipboardErrorDetail {\n if (err instanceof Error) {\n // DOMException is an Error subclass; its `name` (NotAllowedError, etc.) is\n // the meaningful discriminator for consumers switching on failure kind.\n return { name: err.name, message: err.message };\n }\n return { name: \"Error\", message: String(err) };\n }\n\n private _unsupportedError(): WcsClipboardErrorDetail {\n return {\n name: \"NotSupportedError\",\n message: \"Clipboard API is not available in this environment.\",\n };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsClipboard } from \"./components/Clipboard.js\";\n\nlet registered = false;\n\n// Attribute names for the optional copy-on-click DOM trigger (clipboard.js-style\n// DX). The element carrying `data-clipboardtarget` points at a <wcs-clipboard>\n// by id; the text to copy comes from either a literal `data-clipboard-text` or\n// a `data-clipboard-from` CSS selector resolving to a source element.\nconst TEXT_ATTRIBUTE = \"data-clipboard-text\";\nconst FROM_ATTRIBUTE = \"data-clipboard-from\";\n\nfunction resolveText(triggerElement: Element): string | null {\n // Literal text wins when present (including an empty string — copying \"\" is a\n // legitimate request).\n if (triggerElement.hasAttribute(TEXT_ATTRIBUTE)) {\n return triggerElement.getAttribute(TEXT_ATTRIBUTE) ?? \"\";\n }\n const selector = triggerElement.getAttribute(FROM_ATTRIBUTE);\n if (!selector) return null;\n const source = document.querySelector(selector);\n if (!source) return null;\n // Read a form control's `value`; fall back to text content. A bare\n // `\"value\" in source` check is too broad — it also matches <button>,\n // <li value>, <progress>, etc. (which carry an unrelated `value`), copying\n // the wrong thing. Narrow to the text-bearing controls a user actually points\n // `data-clipboard-from` at; everything else falls through to textContent.\n if (\n source instanceof HTMLInputElement ||\n source instanceof HTMLTextAreaElement ||\n source instanceof HTMLSelectElement\n ) {\n return source.value;\n }\n return source.textContent ?? \"\";\n}\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const clipboardId = triggerElement.getAttribute(config.triggerAttribute);\n if (!clipboardId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // WcsClipboard as a value (avoids a components ⇄ autoTrigger import cycle:\n // Clipboard.connectedCallback() calls registerAutoTrigger()). instanceof\n // against the customElements registry keeps the same identity guarantee.\n const ClipboardCtor = customElements.get(config.tagNames.clipboard);\n const clipboardElement = document.getElementById(clipboardId);\n if (!ClipboardCtor || !(clipboardElement instanceof ClipboardCtor)) return;\n\n const text = resolveText(triggerElement);\n // No resolvable source: leave the click alone (do not preventDefault) so the\n // element's default action is unaffected.\n if (text === null) return;\n\n // Suppress the default action so a copy can run without navigating. Intentional:\n // do not attach data-clipboardtarget to an element whose default action you\n // also want (real <a href> link). See README \"Optional DOM Triggering\".\n event.preventDefault();\n (clipboardElement as WcsClipboard).writeText(text);\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { ClipboardCore } from \"../core/ClipboardCore.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n// Named WcsClipboard (not `Clipboard`) so the class does not shadow the global\n// DOM `Clipboard` interface (the type of `navigator.clipboard`), matching the\n// <wcs-geo> WcsGeolocation / <wcs-ws> WcsWebSocket convention.\nexport class WcsClipboard extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...ClipboardCore.wcBindable,\n // Shell-level settable surface. `monitor` mirrors its boolean attribute\n // (reflects idempotently), following the <wcs-ws> / <wcs-geo> convention.\n // There is no momentary `trigger` property: writes need an argument (the\n // text/items), so element actions are driven via command-token\n // (`command.writeText: $command.copy`) or the DOM autoTrigger, not a\n // false→true boolean pulse.\n inputs: [\n { name: \"monitor\", attribute: \"monitor\" },\n ],\n // Commands are identical to the Core's — no rename is needed because the\n // `monitor` boolean attribute accessor does not collide with the\n // `startMonitor` / `stopMonitor` command names (unlike <wcs-geo>, whose\n // `watch` attribute forced the Core's `watch` command to `watchPosition`).\n commands: ClipboardCore.wcBindable.commands,\n };\n\n private _core: ClipboardCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new ClipboardCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-clipboard:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-clipboard:monitoring-changed\": (d) => ({ monitoring: d === true }),\n \"wcs-clipboard:error\": (d) => ({ error: d != null }),\n });\n }\n\n // SSR (§4.4): the state binder awaits this before snapshotting, so the first\n // permission probe has settled. Backed by _core.observe() (see connectedCallback).\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n\n get monitor(): boolean {\n return this.hasAttribute(\"monitor\");\n }\n\n /**\n * Reflects the `monitor` boolean attribute only — it does NOT start or stop\n * monitoring by itself. The attribute is read at connect time (see\n * connectedCallback); toggling `el.monitor` after connect just flips the\n * attribute. To start/stop monitoring imperatively, call `startMonitor()` /\n * `stopMonitor()`.\n */\n set monitor(value: boolean) {\n if (value) {\n this.setAttribute(\"monitor\", \"\");\n } else {\n this.removeAttribute(\"monitor\");\n }\n }\n\n // --- Core delegated getters ---\n\n get text(): string | null {\n return this._core.text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._core.items;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._core.error;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._core.readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._core.writePermission;\n }\n\n get monitoring(): boolean {\n return this._core.monitoring;\n }\n\n get copied(): string | null {\n return this._core.copied;\n }\n\n get cut(): string | null {\n return this._core.cut;\n }\n\n get pasted(): string | null {\n return this._core.pasted;\n }\n\n // --- Commands ---\n\n writeText(text: string): Promise<void> {\n return this._core.writeText(text);\n }\n\n write(items: ClipboardItem[]): Promise<void> {\n return this._core.write(items);\n }\n\n readText(): Promise<void> {\n return this._core.readText();\n }\n\n read(): Promise<void> {\n return this._core.read();\n }\n\n startMonitor(): void {\n this._core.startMonitor();\n }\n\n stopMonitor(): void {\n this._core.stopMonitor();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // observe() revives permission tracking after a reconnect (reparenting) —\n // a no-op on the first connect since the constructor already subscribed — and\n // returns the readiness promise exposed as connectedCallbackPromise (§4.4).\n this._connectedCallbackPromise = this._core.observe();\n // Unlike <wcs-geo>, there is no connect-time acquisition: reads require a\n // user gesture, so the only connect-time action is optional monitoring.\n if (this.monitor) {\n this._core.startMonitor();\n }\n }\n\n disconnectedCallback(): void {\n this._core.stopMonitor();\n this._core.dispose();\n }\n}\n","import { WcsClipboard } from \"./components/Clipboard.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.clipboard)) {\n customElements.define(config.tagNames.clipboard, WcsClipboard);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapClipboard(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n"],"names":[],"mappings":"AAUA,MAAM,OAAO,GAAoB;AAC/B,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,gBAAgB,EAAE,sBAAsB;AACxC,IAAA,QAAQ,EAAE;AACR,QAAA,SAAS,EAAE,eAAe;AAC3B,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IAC/D;AACA,IAAA,OAAO,KAAU;AACnB;AAEA,IAAI,YAAY,GAAmB,IAAI;AAEhC,MAAM,MAAM,GAAY,OAAkB;SAEjC,SAAS,GAAA;IACvB,IAAI,CAAC,YAAY,EAAE;QACjB,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/C;AACA,IAAA,OA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AAkB,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/clipboardCapabilities.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","/**\n * clipboardCapabilities.ts\n *\n * Clipboard node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。clipboard の read/write は concurrent-independent(競合しない)ため lane\n * は持たず、error taxonomy(errorInfo)のみを採用する。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した clipboard error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_CLIPBOARD_ERROR_CODE = {\n CapabilityMissing: \"capability-missing\",\n NotAllowed: \"not-allowed\",\n ClipboardError: \"clipboard-error\",\n} as const;\n\n/**\n * 正規化済み error(`{ name, message }`)を serializable な error taxonomy に写す。\n * `NotSupportedError`(Clipboard API 不在)→ capability-missing、`NotAllowedError`\n * (permission 拒否、retry では回復しない)→ not-allowed、その他 → clipboard-error。\n */\nexport function deriveClipboardErrorInfo(name: string, message: string): WcsIoErrorInfo {\n if (name === \"NotSupportedError\") {\n return { code: WCS_CLIPBOARD_ERROR_CODE.CapabilityMissing, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NotAllowedError\") {\n return { code: WCS_CLIPBOARD_ERROR_CODE.NotAllowed, phase: \"execute\", recoverable: false, message };\n }\n return { code: WCS_CLIPBOARD_ERROR_CODE.ClipboardError, phase: \"execute\", recoverable: true, message };\n}\n","import {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardReadDetail, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveClipboardErrorInfo } from \"./clipboardCapabilities.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 // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from the normalized `error` (`name` →\n // capability-missing / not-allowed / clipboard-error); the existing `error`\n // property/event are unchanged. Fires `wcs-clipboard:error-info-changed`.\n { name: \"errorInfo\", event: \"wcs-clipboard:error-info-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 _errorInfo: WcsIoErrorInfo | 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 /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Exposed as an additive wc-bindable property (event\n * `wcs-clipboard:error-info-changed`), derived from the normalized `error`; the\n * existing `error` property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\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 // Keep the additive `errorInfo` taxonomy in sync with `error`: derive it from\n // the normalized error (or null on clear). Fires before the `error` event so an\n // observer binding both sees the classification first, mirroring the io-node\n // family. No lane here — clipboard's read/write ops don't compete.\n this._commitErrorInfo(error === null ? null : deriveClipboardErrorInfo(error.name, error.message));\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already same-value-guards on the error\n // reference), so errorInfo transitions exactly when error does — no separate\n // guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:error-info-changed\", {\n detail: info,\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 { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n// Named WcsClipboard (not `Clipboard`) so the class does not shadow the global\n// DOM `Clipboard` interface (the type of `navigator.clipboard`), matching the\n// <wcs-geo> WcsGeolocation / <wcs-ws> WcsWebSocket convention.\nexport class WcsClipboard extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...ClipboardCore.wcBindable,\n // Shell-level settable surface. `monitor` mirrors its boolean attribute\n // (reflects idempotently), following the <wcs-ws> / <wcs-geo> convention.\n // There is no momentary `trigger` property: writes need an argument (the\n // text/items), so element actions are driven via command-token\n // (`command.writeText: $command.copy`) or the DOM autoTrigger, not a\n // false→true boolean pulse.\n inputs: [\n { name: \"monitor\", attribute: \"monitor\" },\n ],\n // Commands are identical to the Core's — no rename is needed because the\n // `monitor` boolean attribute accessor does not collide with the\n // `startMonitor` / `stopMonitor` command names (unlike <wcs-geo>, whose\n // `watch` attribute forced the Core's `watch` command to `watchPosition`).\n commands: ClipboardCore.wcBindable.commands,\n };\n\n private _core: ClipboardCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new ClipboardCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-clipboard:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-clipboard:monitoring-changed\": (d) => ({ monitoring: d === true }),\n \"wcs-clipboard:error\": (d) => ({ error: d != null }),\n });\n }\n\n // SSR (§4.4): the state binder awaits this before snapshotting, so the first\n // permission probe has settled. Backed by _core.observe() (see connectedCallback).\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n\n get monitor(): boolean {\n return this.hasAttribute(\"monitor\");\n }\n\n /**\n * Reflects the `monitor` boolean attribute only — it does NOT start or stop\n * monitoring by itself. The attribute is read at connect time (see\n * connectedCallback); toggling `el.monitor` after connect just flips the\n * attribute. To start/stop monitoring imperatively, call `startMonitor()` /\n * `stopMonitor()`.\n */\n set monitor(value: boolean) {\n if (value) {\n this.setAttribute(\"monitor\", \"\");\n } else {\n this.removeAttribute(\"monitor\");\n }\n }\n\n // --- Core delegated getters ---\n\n get text(): string | null {\n return this._core.text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._core.items;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\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);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AAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QAClD,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IAChE;AACF;;ACHM,SAAU,kBAAkB,CAAC,UAA4B,EAAA;IAC7D,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;AACA,IAAA,kBAAkB,EAAE;AACtB;;;;"}
@@ -1,2 +1,2 @@
1
- const t={autoTrigger:!0,triggerAttribute:"data-clipboardtarget",tagNames:{clipboard:"wcs-clipboard"}};function e(t){if(null===t||"object"!=typeof t)return t;Object.freeze(t);for(const r of Object.keys(t))e(t[r]);return t}function r(t){if(null===t||"object"!=typeof t)return t;const e={};for(const i of Object.keys(t))e[i]=r(t[i]);return e}let i=null;const s=t;function n(){return i||(i=e(r(t))),i}class o extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"text",event:"wcs-clipboard:read",getter:t=>t.detail.text},{name:"items",event:"wcs-clipboard:read",getter:t=>t.detail.items},{name:"loading",event:"wcs-clipboard:loading-changed"},{name:"error",event:"wcs-clipboard:error"},{name:"readPermission",event:"wcs-clipboard:read-permission-changed"},{name:"writePermission",event:"wcs-clipboard:write-permission-changed"},{name:"monitoring",event:"wcs-clipboard:monitoring-changed"},{name:"copied",event:"wcs-clipboard:copied",getter:t=>t.detail},{name:"cut",event:"wcs-clipboard:cut",getter:t=>t.detail},{name:"pasted",event:"wcs-clipboard:pasted",getter:t=>t.detail}],commands:[{name:"writeText",async:!0},{name:"write",async:!0},{name:"readText",async:!0},{name:"read",async:!0},{name:"startMonitor"},{name:"stopMonitor"}]};_target;_text=null;_items=null;_loading=!1;_error=null;_readPermission="prompt";_writePermission="prompt";_monitoring=!1;_copied=null;_cut=null;_pasted=null;_readStatus=null;_writeStatus=null;_permissionSubscribed=!1;_permGen=0;_acqGen=0;_ready=Promise.resolve();constructor(t){super(),this._target=t??this,this._initPermissions()}get ready(){return this._ready}observe(){return this.reinitPermission(),this._ready}get text(){return this._text}get items(){return this._items}get loading(){return this._loading}get error(){return this._error}get readPermission(){return this._readPermission}get writePermission(){return this._writePermission}get monitoring(){return this._monitoring}get copied(){return this._copied}get cut(){return this._cut}get pasted(){return this._pasted}_setRead(t){this._text=t.text,this._items=t.items,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:read",{detail:t,bubbles:!0}))}_setLoading(t){this._loading!==t&&(this._loading=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:loading-changed",{detail:t,bubbles:!0})))}_setError(t){this._error!==t&&(this._error=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:error",{detail:t,bubbles:!0})))}_setReadPermission(t){this._readPermission!==t&&(this._readPermission=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:read-permission-changed",{detail:t,bubbles:!0})))}_setWritePermission(t){this._writePermission!==t&&(this._writePermission=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:write-permission-changed",{detail:t,bubbles:!0})))}_setMonitoring(t){this._monitoring!==t&&(this._monitoring=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:monitoring-changed",{detail:t,bubbles:!0})))}_setCopied(t){this._copied=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:copied",{detail:t,bubbles:!0}))}_setCut(t){this._cut=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:cut",{detail:t,bubbles:!0}))}_setPasted(t){this._pasted=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:pasted",{detail:t,bubbles:!0}))}writeText(t){return this._runWrite(()=>navigator.clipboard.writeText(t))}write(t){return this._runWrite(()=>navigator.clipboard.write(t))}readText(){return this._runRead(async()=>({text:await navigator.clipboard.readText(),items:null}))}read(){return this._runRead(async()=>{const t=await navigator.clipboard.read();return this._normalizeItems(t)})}startMonitor(){this._monitoring||(this._setMonitoring(!0),document.addEventListener("copy",this._onCopy),document.addEventListener("cut",this._onCut),document.addEventListener("paste",this._onPaste))}stopMonitor(){this._removeMonitorListeners(),this._setMonitoring(!1)}reinitPermission(){this._permissionSubscribed||this._initPermissions()}dispose(){this._permissionSubscribed=!1,this._permGen++,this._acqGen++,this._loading=!1,this._readStatus&&(this._readStatus.removeEventListener("change",this._onReadChange),this._readStatus=null),this._writeStatus&&(this._writeStatus.removeEventListener("change",this._onWriteChange),this._writeStatus=null),this._removeMonitorListeners(),this._monitoring=!1}_runWrite(t){return this._runOp(async()=>(await t(),null))}_runRead(t){return this._runOp(t)}async _runOp(t){if(!this._hasClipboard())return void this._setError(this._unsupportedError());const e=this._acqGen;this._setLoading(!0),this._setError(null);try{const r=await t();if(e!==this._acqGen)return;this._setLoading(!1),r&&this._setRead(r)}catch(t){if(e!==this._acqGen)return;this._setLoading(!1),this._setError(this._normalizeError(t))}}_onCopy=()=>{this._setCopied(this._selectionText())};_onCut=()=>{this._setCut(this._selectionText())};_onPaste=t=>{const e=t.clipboardData,r=e?e.getData("text/plain"):"";this._setPasted(r)};_removeMonitorListeners(){document.removeEventListener("copy",this._onCopy),document.removeEventListener("cut",this._onCut),document.removeEventListener("paste",this._onPaste)}_selectionText(){const t=document.getSelection();return t?t.toString():""}_initPermissions(){if("undefined"==typeof navigator||!navigator.permissions||"function"!=typeof navigator.permissions.query)return this._setReadPermission("unsupported"),this._setWritePermission("unsupported"),void(this._ready=Promise.resolve());this._permissionSubscribed=!0;const t=++this._permGen,e=this._queryPermission("clipboard-read",t,t=>{this._readStatus=t},t=>this._setReadPermission(t),this._onReadChange),r=this._queryPermission("clipboard-write",t,t=>{this._writeStatus=t},t=>this._setWritePermission(t),this._onWriteChange);this._ready=Promise.all([e,r]).then(()=>{})}_queryPermission(t,e,r,i,s){return navigator.permissions.query({name:t}).then(t=>{e===this._permGen&&(r(t),i(t.state),t.addEventListener("change",s))},()=>{e===this._permGen&&i("unsupported")})}_onReadChange=t=>{const e=t.target;this._setReadPermission(e.state)};_onWriteChange=t=>{const e=t.target;this._setWritePermission(e.state)};_hasClipboard(){return"undefined"!=typeof navigator&&!!navigator.clipboard}async _normalizeItems(t){const e=await Promise.all(t.map(t=>Promise.all(t.types.map(e=>t.getType(e))).then(e=>({item:t,blobs:e})))),r=[];let i=null;for(const{item:t,blobs:s}of e){const e={};if(t.types.forEach((t,r)=>{e[t]=s[r]}),null===i){const e=t.types.indexOf("text/plain");-1!==e&&(i=await s[e].text())}r.push({types:[...t.types],data:e})}return{text:i,items:r}}_normalizeError(t){return t instanceof Error?{name:t.name,message:t.message}:{name:"Error",message:String(t)}}_unsupportedError(){return{name:"NotSupportedError",message:"Clipboard API is not available in this environment."}}}let a=!1;const c="data-clipboard-text";function d(t){const e=t.target;if(!(e instanceof Element))return;const r=e.closest(`[${s.triggerAttribute}]`);if(!r)return;const i=r.getAttribute(s.triggerAttribute);if(!i)return;const n=customElements.get(s.tagNames.clipboard),o=document.getElementById(i);if(!(n&&o instanceof n))return;const a=function(t){if(t.hasAttribute(c))return t.getAttribute(c)??"";const e=t.getAttribute("data-clipboard-from");if(!e)return null;const r=document.querySelector(e);return r?r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement?r.value:r.textContent??"":null}(r);null!==a&&(t.preventDefault(),o.writeText(a))}class u extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...o.wcBindable,inputs:[{name:"monitor",attribute:"monitor"}],commands:o.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new o(this),this._internals=this._initInternals(),this._wireStates({"wcs-clipboard:loading-changed":t=>({loading:!0===t}),"wcs-clipboard:monitoring-changed":t=>({monitoring:!0===t}),"wcs-clipboard:error":t=>({error:null!=t})})}get connectedCallbackPromise(){return this._connectedCallbackPromise}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const t=this.attachInternals();return t.states.add("wcs-probe"),t.states.delete("wcs-probe"),t}catch{return null}}_wireStates(t){if(null===this._internals)return;const e=this._internals.states;for(const[r,i]of Object.entries(t))this.addEventListener(r,t=>{const r=this.hasAttribute("debug-states");for(const[s,n]of Object.entries(i(t.detail))){try{n?e.add(s):e.delete(s)}catch{}r&&this.toggleAttribute(`data-wcs-state-${s}`,n)}})}get monitor(){return this.hasAttribute("monitor")}set monitor(t){t?this.setAttribute("monitor",""):this.removeAttribute("monitor")}get text(){return this._core.text}get items(){return this._core.items}get loading(){return this._core.loading}get error(){return this._core.error}get readPermission(){return this._core.readPermission}get writePermission(){return this._core.writePermission}get monitoring(){return this._core.monitoring}get copied(){return this._core.copied}get cut(){return this._core.cut}get pasted(){return this._core.pasted}writeText(t){return this._core.writeText(t)}write(t){return this._core.write(t)}readText(){return this._core.readText()}read(){return this._core.read()}startMonitor(){this._core.startMonitor()}stopMonitor(){this._core.stopMonitor()}connectedCallback(){this.style.display="none",s.autoTrigger&&(a||(a=!0,document.addEventListener("click",d))),this._connectedCallbackPromise=this._core.observe(),this.monitor&&this._core.startMonitor()}disconnectedCallback(){this._core.stopMonitor(),this._core.dispose()}}function l(e){var r;e&&("boolean"==typeof(r=e).autoTrigger&&(t.autoTrigger=r.autoTrigger),"string"==typeof r.triggerAttribute&&(t.triggerAttribute=r.triggerAttribute),r.tagNames&&Object.assign(t.tagNames,r.tagNames),i=null),customElements.get(s.tagNames.clipboard)||customElements.define(s.tagNames.clipboard,u)}export{o as ClipboardCore,u as WcsClipboard,l as bootstrapClipboard,n as getConfig};
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}const o={CapabilityMissing:"capability-missing",NotAllowed:"not-allowed",ClipboardError:"clipboard-error"};class a 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:"errorInfo",event:"wcs-clipboard:error-info-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;_errorInfo=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 errorInfo(){return this._errorInfo}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){var e,r;this._error!==t&&(this._error=t,this._commitErrorInfo(null===t?null:(e=t.name,r=t.message,"NotSupportedError"===e?{code:o.CapabilityMissing,phase:"start",recoverable:!1,message:r}:"NotAllowedError"===e?{code:o.NotAllowed,phase:"execute",recoverable:!1,message:r}:{code:o.ClipboardError,phase:"execute",recoverable:!0,message:r})),this._target.dispatchEvent(new CustomEvent("wcs-clipboard:error",{detail:t,bubbles:!0})))}_commitErrorInfo(t){this._errorInfo=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:error-info-changed",{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 c=!1;const d="data-clipboard-text";function l(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(d))return t.getAttribute(d)??"";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={...a.wcBindable,inputs:[{name:"monitor",attribute:"monitor"}],commands:a.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new a(this),this._internals=this._initInternals(),this._wireStates({"wcs-clipboard:loading-changed":t=>({loading:!0===t}),"wcs-clipboard:monitoring-changed":t=>({monitoring:!0===t}),"wcs-clipboard:error":t=>({error:null!=t})})}get connectedCallbackPromise(){return this._connectedCallbackPromise}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const t=this.attachInternals();return t.states.add("wcs-probe"),t.states.delete("wcs-probe"),t}catch{return null}}_wireStates(t){if(null===this._internals)return;const e=this._internals.states;for(const[r,i]of Object.entries(t))this.addEventListener(r,t=>{const r=this.hasAttribute("debug-states");for(const[s,n]of Object.entries(i(t.detail))){try{n?e.add(s):e.delete(s)}catch{}r&&this.toggleAttribute(`data-wcs-state-${s}`,n)}})}get monitor(){return this.hasAttribute("monitor")}set monitor(t){t?this.setAttribute("monitor",""):this.removeAttribute("monitor")}get text(){return this._core.text}get items(){return this._core.items}get loading(){return this._core.loading}get error(){return this._core.error}get errorInfo(){return this._core.errorInfo}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&&(c||(c=!0,document.addEventListener("click",l))),this._connectedCallbackPromise=this._core.observe(),this.monitor&&this._core.startMonitor()}disconnectedCallback(){this._core.stopMonitor(),this._core.dispose()}}function h(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{a as ClipboardCore,o as WCS_CLIPBOARD_ERROR_CODE,u as WcsClipboard,h as bootstrapClipboard,n as getConfig};
2
2
  //# sourceMappingURL=index.esm.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/core/ClipboardCore.ts","../src/autoTrigger.ts","../src/components/Clipboard.ts","../src/bootstrapClipboard.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n clipboard: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-clipboardtarget\",\n tagNames: {\n clipboard: \"wcs-clipboard\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardReadDetail, WcsClipboardErrorDetail,\n} from \"../types.js\";\n\n/**\n * Headless clipboard primitive. A thin, framework-agnostic wrapper around the\n * Clipboard API exposed through the wc-bindable protocol.\n *\n * It has two surfaces, mirroring the two distinct shapes of clipboard access:\n * - **commands** — `writeText()` / `write()` push to the clipboard;\n * `readText()` / `read()` pull from it. These are the `state → element`\n * (command-token) and `element → state` (read result) paths. All four are\n * async and never reject: failures surface through the `error` property so\n * they flow into the declarative state, symmetrical with FetchCore /\n * GeolocationCore.\n * - **monitor** — `startMonitor()` / `stopMonitor()` subscribe to the document's\n * `copy` / `cut` / `paste` events and republish them as the `copied` / `cut` /\n * `pasted` properties (like TimerCore's continuous `start()` / `stop()`),\n * toggling the `monitoring` flag. This is the event-token showcase: a user\n * paste flows element → state declaratively.\n *\n * Clipboard also has permission gates, like GeolocationCore but doubled: read\n * and write are separate permissions (`clipboard-read` / `clipboard-write`).\n * `readPermission` / `writePermission` reflect `navigator.permissions.query`\n * (`prompt` / `granted` / `denied`, or `unsupported`) and track their live\n * `change` events.\n */\nexport class ClipboardCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"text\", event: \"wcs-clipboard:read\", getter: (e: Event) => (e as CustomEvent).detail.text },\n { name: \"items\", event: \"wcs-clipboard:read\", getter: (e: Event) => (e as CustomEvent).detail.items },\n { name: \"loading\", event: \"wcs-clipboard:loading-changed\" },\n { name: \"error\", event: \"wcs-clipboard:error\" },\n { name: \"readPermission\", event: \"wcs-clipboard:read-permission-changed\" },\n { name: \"writePermission\", event: \"wcs-clipboard:write-permission-changed\" },\n { name: \"monitoring\", event: \"wcs-clipboard:monitoring-changed\" },\n { name: \"copied\", event: \"wcs-clipboard:copied\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"cut\", event: \"wcs-clipboard:cut\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"pasted\", event: \"wcs-clipboard:pasted\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"writeText\", async: true },\n { name: \"write\", async: true },\n { name: \"readText\", async: true },\n { name: \"read\", async: true },\n { name: \"startMonitor\" },\n { name: \"stopMonitor\" },\n ],\n };\n\n private _target: EventTarget;\n\n private _text: string | null = null;\n private _items: WcsClipboardReadItem[] | null = null;\n private _loading: boolean = false;\n private _error: WcsClipboardErrorDetail | null = null;\n private _readPermission: ClipboardPermissionState = \"prompt\";\n private _writePermission: ClipboardPermissionState = \"prompt\";\n\n private _monitoring: boolean = false;\n private _copied: string | null = null;\n private _cut: string | null = null;\n private _pasted: string | null = null;\n\n // Live PermissionStatus handles (when the Permissions API is available), kept\n // so the `change` listeners can be removed on dispose(). Read and write are\n // separate permissions, hence two handles.\n private _readStatus: PermissionStatus | null = null;\n private _writeStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards reinitPermission() so the first connect after\n // construction does not double-subscribe, while a reconnect after dispose()\n // does re-subscribe. (Mirrors GeolocationCore.)\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query round. Bumped by every\n // _initPermissions() and by dispose(). Each in-flight query captures it and,\n // on resolve, bails unless it is still current — so a query superseded by a\n // rapid (synchronous) disconnect→reconnect, or one that resolves after\n // dispose(), never attaches a listener.\n private _permGen: number = 0;\n\n // Monotonic id of the current async acquisition lifecycle (read/write),\n // bumped only by dispose(). Each command captures it at start; the resolution\n // bails (no setters) if it is stale, so an op that settles after the element\n // was disconnected does not dispatch wcs-clipboard:* on a torn-down element.\n // The Clipboard API has no AbortController, so a generation guard is the only\n // way to neutralize an in-flight op.\n private _acqGen: number = 0;\n\n // SSR (§3.8): resolves once the first permission probe settles, so the state\n // binder can await a real snapshot before reading. Set by _initPermissions();\n // Promise.resolve() when the Permissions API is unsupported (no async probe).\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Probe the permission states up front so observers see the real values\n // before the first read, then keep them live.\n this._initPermissions();\n }\n\n // SSR (§3.8): the first permission probe's settle promise.\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). Clipboard reads/writes are command-driven (they need a\n // user gesture), so observe() establishes no acquisition; it only (re)subscribes\n // to permission `change` events — idempotent while a subscription is live, and\n // reviving it after a dispose() (reconnect/reparent). Returns ready so the Shell\n // can expose it as connectedCallbackPromise.\n observe(): Promise<void> {\n this.reinitPermission();\n return this._ready;\n }\n\n get text(): string | null {\n return this._text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._items;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._error;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._writePermission;\n }\n\n get monitoring(): boolean {\n return this._monitoring;\n }\n\n get copied(): string | null {\n return this._copied;\n }\n\n get cut(): string | null {\n return this._cut;\n }\n\n get pasted(): string | null {\n return this._pasted;\n }\n\n // --- State setters with event dispatch ---\n\n // Deliberately NO same-value guard (unlike error/loading/permission/monitoring).\n // A read is a result event, not idempotent state: reading the same text twice is\n // two distinct user/command actions and must re-fire wcs-clipboard:read each time\n // so a `text:`/`items:` binding and command-result consumers see every read.\n private _setRead(detail: WcsClipboardReadDetail): void {\n this._text = detail.text;\n this._items = detail.items;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read\", {\n detail,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n if (this._loading === loading) return;\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsClipboardErrorDetail | null): void {\n // Same-value guard. `error` has no derived state, so suppressing redundant\n // null→null dispatches (e.g. a successful op clearing an already-null error)\n // avoids spurious events. Reference identity is sufficient: each failure\n // builds a fresh object, and the clear path always passes the literal null.\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _setReadPermission(permission: ClipboardPermissionState): void {\n if (this._readPermission === permission) return;\n this._readPermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setWritePermission(permission: ClipboardPermissionState): void {\n if (this._writePermission === permission) return;\n this._writePermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:write-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setMonitoring(monitoring: boolean): void {\n if (this._monitoring === monitoring) return;\n this._monitoring = monitoring;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:monitoring-changed\", {\n detail: monitoring,\n bubbles: true,\n }));\n }\n\n // Deliberately NO same-value guard on the copied/cut/pasted setters (unlike\n // error/loading/permission/monitoring above). These are events, not state:\n // copying the same text twice is two distinct user actions and must re-fire\n // both times so an event-token subscriber (`eventToken.pasted: ...`) sees each\n // occurrence. Do not add a `===` guard here.\n private _setCopied(text: string): void {\n this._copied = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:copied\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setCut(text: string): void {\n this._cut = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:cut\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setPasted(text: string): void {\n this._pasted = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:pasted\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n // --- Public API: write ---\n\n /**\n * Write plain text to the clipboard. Resolves once the write settles or fails\n * — never rejects: failures surface through `error`. Requires transient\n * activation (a user gesture), so call from a click handler / command-token.\n */\n writeText(text: string): Promise<void> {\n return this._runWrite(() => navigator.clipboard.writeText(text));\n }\n\n /**\n * Write rich `ClipboardItem`s (images, HTML, multiple MIME types) to the\n * clipboard. Resolves once the write settles or fails — never rejects.\n */\n write(items: ClipboardItem[]): Promise<void> {\n return this._runWrite(() => navigator.clipboard.write(items));\n }\n\n // --- Public API: read ---\n\n /**\n * Read plain text from the clipboard, publishing it via `text` and the\n * `wcs-clipboard:read` event. Resolves once the read settles or fails — never\n * rejects. Requires focus + read permission.\n */\n readText(): Promise<void> {\n return this._runRead(async () => {\n const text = await navigator.clipboard.readText();\n return { text, items: null };\n });\n }\n\n /**\n * Read rich `ClipboardItem`s from the clipboard, eagerly resolving every\n * representation to a `Blob`. A `text/plain` representation is also surfaced\n * via `text`. Resolves once the read settles or fails — never rejects.\n */\n read(): Promise<void> {\n return this._runRead(async () => {\n const items = await navigator.clipboard.read();\n return this._normalizeItems(items);\n });\n }\n\n // --- Public API: monitor ---\n\n /**\n * Begin monitoring document `copy` / `cut` / `paste` events, republishing\n * them as the `copied` / `cut` / `pasted` properties. Idempotent while already\n * monitoring (mirrors GeolocationCore.watch()).\n */\n startMonitor(): void {\n if (this._monitoring) return;\n this._setMonitoring(true);\n // §4 deviation: document-scoped Web API; no element-free alternative.\n // copy/cut/paste fire on `document`, so monitoring necessarily listens there\n // rather than on a Core-owned element. Registered as an allowed deviation.\n document.addEventListener(\"copy\", this._onCopy);\n document.addEventListener(\"cut\", this._onCut);\n document.addEventListener(\"paste\", this._onPaste);\n }\n\n stopMonitor(): void {\n this._removeMonitorListeners();\n this._setMonitoring(false);\n }\n\n // --- Permission lifecycle ---\n\n /**\n * Re-establish the permission `change` subscriptions after a dispose() — e.g.\n * the Shell element was disconnected and then reconnected (reparented). No-op\n * while a subscription is already live, so the first connect after\n * construction does not double-subscribe.\n */\n reinitPermission(): void {\n if (!this._permissionSubscribed) {\n this._initPermissions();\n }\n }\n\n /**\n * Detach the live permission `change` listeners and any monitor listeners, and\n * neutralize in-flight async ops. Call from the Shell's `disconnectedCallback`\n * so a removed element does not leak subscriptions or dispatch on a torn-down\n * element. A later reconnect can re-subscribe via reinitPermission().\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight permission query so its .then() bails instead of\n // attaching a listener after teardown.\n this._permGen++;\n // Invalidate any in-flight read/write so its resolution bails instead of\n // dispatching on a disconnected element.\n this._acqGen++;\n // Reset the loading shadow silently (no dispatch on a disposed element). The\n // bailed resolution will not clear it, and leaving it true would let the\n // same-value guard swallow the loading=true edge of the next op after a\n // reconnect.\n this._loading = false;\n if (this._readStatus) {\n this._readStatus.removeEventListener(\"change\", this._onReadChange);\n this._readStatus = null;\n }\n if (this._writeStatus) {\n this._writeStatus.removeEventListener(\"change\", this._onWriteChange);\n this._writeStatus = null;\n }\n // Remove monitor listeners silently. The Shell calls stopMonitor() before\n // dispose(), but a direct headless dispose() still tears them down.\n this._removeMonitorListeners();\n this._monitoring = false;\n }\n\n // --- Internal: write/read runners ---\n\n private _runWrite(op: () => Promise<void>): Promise<void> {\n return this._runOp(async () => {\n await op();\n return null;\n });\n }\n\n private _runRead(op: () => Promise<WcsClipboardReadDetail>): Promise<void> {\n return this._runOp(op);\n }\n\n /**\n * Shared async-op lifecycle for read/write: capability check, loading toggle,\n * generation guard, never-reject error handling. When `op` returns a read\n * detail it is published; when it returns null (a write) nothing is published.\n */\n private async _runOp(op: () => Promise<WcsClipboardReadDetail | null>): Promise<void> {\n if (!this._hasClipboard()) {\n this._setError(this._unsupportedError());\n return;\n }\n const gen = this._acqGen;\n this._setLoading(true);\n this._setError(null);\n try {\n const detail = await op();\n // Stale: the element was disposed (disconnected) while this op was in\n // flight. Drop it so a torn-down element never dispatches wcs-clipboard:*.\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n if (detail) this._setRead(detail);\n } catch (err) {\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n this._setError(this._normalizeError(err));\n }\n }\n\n // --- Internal: monitor handlers ---\n\n // During a `copy` / `cut` event the clipboard payload is not yet readable —\n // the browser returns an empty string for security reasons — so we report the\n // user's selected text (`document.getSelection().toString()`) instead. A page\n // that overrides the payload with a custom handler via clipboardData.setData()\n // is therefore NOT reflected here. (See README \"copy / cut text comes from the\n // selection\".) `paste` differs: clipboardData is readable, so _onPaste reads it.\n private _onCopy = (): void => {\n this._setCopied(this._selectionText());\n };\n\n private _onCut = (): void => {\n this._setCut(this._selectionText());\n };\n\n private _onPaste = (event: Event): void => {\n const data = (event as ClipboardEvent).clipboardData;\n const text = data ? data.getData(\"text/plain\") : \"\";\n this._setPasted(text);\n };\n\n private _removeMonitorListeners(): void {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n document.removeEventListener(\"copy\", this._onCopy);\n document.removeEventListener(\"cut\", this._onCut);\n document.removeEventListener(\"paste\", this._onPaste);\n }\n\n private _selectionText(): string {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n const selection = document.getSelection();\n return selection ? selection.toString() : \"\";\n }\n\n // --- Internal: permission ---\n\n private _initPermissions(): void {\n // The Permissions API is optional. When absent (or it rejects, e.g. Firefox\n // does not expose the clipboard permission names), report \"unsupported\" and\n // leave reads/writes to fail loudly via the error property if attempted.\n // Note: we deliberately do NOT set _permissionSubscribed here — there is no\n // live subscription to tear down, so reinitPermission() re-runs this branch\n // on every reconnect. That is harmless: the same-value guard in\n // _setReadPermission/_setWritePermission swallows the redundant\n // unsupported→unsupported dispatch. (Mirrors GeolocationCore.)\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n this._setReadPermission(\"unsupported\");\n this._setWritePermission(\"unsupported\");\n // No async probe: readiness is immediate (§3.8).\n this._ready = Promise.resolve();\n return;\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n const readProbe = this._queryPermission(\n \"clipboard-read\", gen,\n (s) => { this._readStatus = s; },\n (state) => this._setReadPermission(state),\n this._onReadChange,\n );\n const writeProbe = this._queryPermission(\n \"clipboard-write\", gen,\n (s) => { this._writeStatus = s; },\n (state) => this._setWritePermission(state),\n this._onWriteChange,\n );\n // SSR (§3.8): ready resolves once both initial permission probes settle.\n this._ready = Promise.all([readProbe, writeProbe]).then(() => undefined);\n }\n\n private _queryPermission(\n name: string,\n gen: number,\n assignStatus: (status: PermissionStatus) => void,\n setState: (state: ClipboardPermissionState) => void,\n onChange: (event: Event) => void,\n ): Promise<void> {\n return navigator.permissions.query({ name: name as PermissionName }).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the\n // current subscription attaches a listener.\n if (gen !== this._permGen) return;\n assignStatus(status);\n setState(status.state as ClipboardPermissionState);\n status.addEventListener(\"change\", onChange);\n },\n () => {\n if (gen !== this._permGen) return;\n setState(\"unsupported\");\n },\n );\n }\n\n private _onReadChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setReadPermission(status.state as ClipboardPermissionState);\n };\n\n private _onWriteChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setWritePermission(status.state as ClipboardPermissionState);\n };\n\n // --- Internal: normalization ---\n\n private _hasClipboard(): boolean {\n return typeof navigator !== \"undefined\" && !!navigator.clipboard;\n }\n\n private async _normalizeItems(items: ClipboardItem[]): Promise<WcsClipboardReadDetail> {\n // Resolve every representation of every item in parallel. getType() calls are\n // independent, so awaiting them serially only adds latency. The trade-off is\n // intentional and unchanged from the serial version: if any getType() rejects\n // the whole read errors (no partial success), consistent with the never-reject\n // design where a failed op surfaces a single `error` rather than a half-filled\n // snapshot. Order is preserved so the `text` pick below stays deterministic.\n const resolved = await Promise.all(\n items.map((item) =>\n Promise.all(item.types.map((type) => item.getType(type))).then((blobs) => ({ item, blobs })),\n ),\n );\n\n const normalized: WcsClipboardReadItem[] = [];\n let text: string | null = null;\n for (const { item, blobs } of resolved) {\n const data: Record<string, Blob> = {};\n item.types.forEach((type, i) => {\n data[type] = blobs[i];\n });\n // Surface the first text/plain representation through `text` for the\n // common \"read whatever text is there\" case (first item, first match).\n if (text === null) {\n const i = item.types.indexOf(\"text/plain\");\n if (i !== -1) {\n text = await blobs[i].text();\n }\n }\n normalized.push({ types: [...item.types], data });\n }\n return { text, items: normalized };\n }\n\n private _normalizeError(err: unknown): WcsClipboardErrorDetail {\n if (err instanceof Error) {\n // DOMException is an Error subclass; its `name` (NotAllowedError, etc.) is\n // the meaningful discriminator for consumers switching on failure kind.\n return { name: err.name, message: err.message };\n }\n return { name: \"Error\", message: String(err) };\n }\n\n private _unsupportedError(): WcsClipboardErrorDetail {\n return {\n name: \"NotSupportedError\",\n message: \"Clipboard API is not available in this environment.\",\n };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsClipboard } from \"./components/Clipboard.js\";\n\nlet registered = false;\n\n// Attribute names for the optional copy-on-click DOM trigger (clipboard.js-style\n// DX). The element carrying `data-clipboardtarget` points at a <wcs-clipboard>\n// by id; the text to copy comes from either a literal `data-clipboard-text` or\n// a `data-clipboard-from` CSS selector resolving to a source element.\nconst TEXT_ATTRIBUTE = \"data-clipboard-text\";\nconst FROM_ATTRIBUTE = \"data-clipboard-from\";\n\nfunction resolveText(triggerElement: Element): string | null {\n // Literal text wins when present (including an empty string — copying \"\" is a\n // legitimate request).\n if (triggerElement.hasAttribute(TEXT_ATTRIBUTE)) {\n return triggerElement.getAttribute(TEXT_ATTRIBUTE) ?? \"\";\n }\n const selector = triggerElement.getAttribute(FROM_ATTRIBUTE);\n if (!selector) return null;\n const source = document.querySelector(selector);\n if (!source) return null;\n // Read a form control's `value`; fall back to text content. A bare\n // `\"value\" in source` check is too broad — it also matches <button>,\n // <li value>, <progress>, etc. (which carry an unrelated `value`), copying\n // the wrong thing. Narrow to the text-bearing controls a user actually points\n // `data-clipboard-from` at; everything else falls through to textContent.\n if (\n source instanceof HTMLInputElement ||\n source instanceof HTMLTextAreaElement ||\n source instanceof HTMLSelectElement\n ) {\n return source.value;\n }\n return source.textContent ?? \"\";\n}\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const clipboardId = triggerElement.getAttribute(config.triggerAttribute);\n if (!clipboardId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // WcsClipboard as a value (avoids a components ⇄ autoTrigger import cycle:\n // Clipboard.connectedCallback() calls registerAutoTrigger()). instanceof\n // against the customElements registry keeps the same identity guarantee.\n const ClipboardCtor = customElements.get(config.tagNames.clipboard);\n const clipboardElement = document.getElementById(clipboardId);\n if (!ClipboardCtor || !(clipboardElement instanceof ClipboardCtor)) return;\n\n const text = resolveText(triggerElement);\n // No resolvable source: leave the click alone (do not preventDefault) so the\n // element's default action is unaffected.\n if (text === null) return;\n\n // Suppress the default action so a copy can run without navigating. Intentional:\n // do not attach data-clipboardtarget to an element whose default action you\n // also want (real <a href> link). See README \"Optional DOM Triggering\".\n event.preventDefault();\n (clipboardElement as WcsClipboard).writeText(text);\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { ClipboardCore } from \"../core/ClipboardCore.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n// Named WcsClipboard (not `Clipboard`) so the class does not shadow the global\n// DOM `Clipboard` interface (the type of `navigator.clipboard`), matching the\n// <wcs-geo> WcsGeolocation / <wcs-ws> WcsWebSocket convention.\nexport class WcsClipboard extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...ClipboardCore.wcBindable,\n // Shell-level settable surface. `monitor` mirrors its boolean attribute\n // (reflects idempotently), following the <wcs-ws> / <wcs-geo> convention.\n // There is no momentary `trigger` property: writes need an argument (the\n // text/items), so element actions are driven via command-token\n // (`command.writeText: $command.copy`) or the DOM autoTrigger, not a\n // false→true boolean pulse.\n inputs: [\n { name: \"monitor\", attribute: \"monitor\" },\n ],\n // Commands are identical to the Core's — no rename is needed because the\n // `monitor` boolean attribute accessor does not collide with the\n // `startMonitor` / `stopMonitor` command names (unlike <wcs-geo>, whose\n // `watch` attribute forced the Core's `watch` command to `watchPosition`).\n commands: ClipboardCore.wcBindable.commands,\n };\n\n private _core: ClipboardCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new ClipboardCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-clipboard:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-clipboard:monitoring-changed\": (d) => ({ monitoring: d === true }),\n \"wcs-clipboard:error\": (d) => ({ error: d != null }),\n });\n }\n\n // SSR (§4.4): the state binder awaits this before snapshotting, so the first\n // permission probe has settled. Backed by _core.observe() (see connectedCallback).\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n\n get monitor(): boolean {\n return this.hasAttribute(\"monitor\");\n }\n\n /**\n * Reflects the `monitor` boolean attribute only — it does NOT start or stop\n * monitoring by itself. The attribute is read at connect time (see\n * connectedCallback); toggling `el.monitor` after connect just flips the\n * attribute. To start/stop monitoring imperatively, call `startMonitor()` /\n * `stopMonitor()`.\n */\n set monitor(value: boolean) {\n if (value) {\n this.setAttribute(\"monitor\", \"\");\n } else {\n this.removeAttribute(\"monitor\");\n }\n }\n\n // --- Core delegated getters ---\n\n get text(): string | null {\n return this._core.text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._core.items;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._core.error;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._core.readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._core.writePermission;\n }\n\n get monitoring(): boolean {\n return this._core.monitoring;\n }\n\n get copied(): string | null {\n return this._core.copied;\n }\n\n get cut(): string | null {\n return this._core.cut;\n }\n\n get pasted(): string | null {\n return this._core.pasted;\n }\n\n // --- Commands ---\n\n writeText(text: string): Promise<void> {\n return this._core.writeText(text);\n }\n\n write(items: ClipboardItem[]): Promise<void> {\n return this._core.write(items);\n }\n\n readText(): Promise<void> {\n return this._core.readText();\n }\n\n read(): Promise<void> {\n return this._core.read();\n }\n\n startMonitor(): void {\n this._core.startMonitor();\n }\n\n stopMonitor(): void {\n this._core.stopMonitor();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // observe() revives permission tracking after a reconnect (reparenting) —\n // a no-op on the first connect since the constructor already subscribed — and\n // returns the readiness promise exposed as connectedCallbackPromise (§4.4).\n this._connectedCallbackPromise = this._core.observe();\n // Unlike <wcs-geo>, there is no connect-time acquisition: reads require a\n // user gesture, so the only connect-time action is optional monitoring.\n if (this.monitor) {\n this._core.startMonitor();\n }\n }\n\n disconnectedCallback(): void {\n this._core.stopMonitor();\n this._core.dispose();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapClipboard(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { WcsClipboard } from \"./components/Clipboard.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.clipboard)) {\n customElements.define(config.tagNames.clipboard, WcsClipboard);\n }\n}\n"],"names":["_config","autoTrigger","triggerAttribute","tagNames","clipboard","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","ClipboardCore","EventTarget","static","protocol","version","properties","name","event","getter","e","detail","text","items","commands","async","_target","_text","_items","_loading","_error","_readPermission","_writePermission","_monitoring","_copied","_cut","_pasted","_readStatus","_writeStatus","_permissionSubscribed","_permGen","_acqGen","_ready","Promise","resolve","constructor","target","super","this","_initPermissions","ready","observe","reinitPermission","loading","error","readPermission","writePermission","monitoring","copied","cut","pasted","_setRead","dispatchEvent","CustomEvent","bubbles","_setLoading","_setError","_setReadPermission","permission","_setWritePermission","_setMonitoring","_setCopied","_setCut","_setPasted","writeText","_runWrite","navigator","write","readText","_runRead","read","_normalizeItems","startMonitor","document","addEventListener","_onCopy","_onCut","_onPaste","stopMonitor","_removeMonitorListeners","dispose","removeEventListener","_onReadChange","_onWriteChange","op","_runOp","_hasClipboard","_unsupportedError","gen","err","_normalizeError","_selectionText","data","clipboardData","getData","selection","getSelection","toString","permissions","query","readProbe","_queryPermission","s","state","writeProbe","all","then","assignStatus","setState","onChange","status","resolved","map","item","types","type","getType","blobs","normalized","forEach","i","indexOf","push","Error","message","String","registered","TEXT_ATTRIBUTE","handleClick","Element","triggerElement","closest","clipboardId","getAttribute","ClipboardCtor","customElements","get","clipboardElement","getElementById","hasAttribute","selector","source","querySelector","HTMLInputElement","HTMLTextAreaElement","HTMLSelectElement","value","textContent","resolveText","preventDefault","WcsClipboard","HTMLElement","wcBindable","inputs","attribute","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","connectedCallbackPromise","debugStates","states","attachInternals","internals","add","delete","toStates","entries","debug","on","toggleAttribute","monitor","setAttribute","removeAttribute","connectedCallback","style","display","disconnectedCallback","bootstrapClipboard","userConfig","partialConfig","assign","define"],"mappings":"AAUA,MAAMA,EAA2B,CAC/BC,aAAa,EACbC,iBAAkB,uBAClBC,SAAU,CACRC,UAAW,kBAIf,SAASC,EAAcC,GACrB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpDC,OAAOC,OAAOF,GACd,IAAK,MAAMG,KAAOF,OAAOG,KAAKJ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GACJ,OAAOyB,KAAKqH,MAAMxF,MAAMtD,EAC1B,CAEA,QAAAuD,GACE,OAAO9B,KAAKqH,MAAMvF,UACpB,CAEA,IAAAE,GACE,OAAOhC,KAAKqH,MAAMrF,MACpB,CAEA,YAAAE,GACElC,KAAKqH,MAAMnF,cACb,CAEA,WAAAM,GACExC,KAAKqH,MAAM7E,aACb,CAIA,iBAAAkG,GACE1I,KAAK2I,MAAMC,QAAU,OACjBnL,EAAOb,cDtHT4I,IACJA,GAAa,EACbrD,SAASC,iBAAiB,QAASsD,KC0HjC1F,KAAKsH,0BAA4BtH,KAAKqH,MAAMlH,UAGxCH,KAAKuI,SACPvI,KAAKqH,MAAMnF,cAEf,CAEA,oBAAA2G,GACE7I,KAAKqH,MAAM7E,cACXxC,KAAKqH,MAAM3E,SACb,ECvMI,SAAUoG,EAAmBC,GJ2C7B,IAAoBC,EI1CpBD,IJ2CqC,kBADjBC,EIzCZD,GJ0CanM,cACvBD,EAAQC,YAAcoM,EAAcpM,aAEQ,iBAAnCoM,EAAcnM,mBACvBF,EAAQE,iBAAmBmM,EAAcnM,kBAEvCmM,EAAclM,UAChBI,OAAO+L,OAAOtM,EAAQG,SAAUkM,EAAclM,UAEhDU,EAAe,MKrDVyI,eAAeC,IAAIzI,EAAOX,SAASC,YACtCkJ,eAAeiD,OAAOzL,EAAOX,SAASC,UAAWiK,EDIrD"}
1
+ {"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/core/clipboardCapabilities.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","/**\n * clipboardCapabilities.ts\n *\n * Clipboard node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。clipboard の read/write は concurrent-independent(競合しない)ため lane\n * は持たず、error taxonomy(errorInfo)のみを採用する。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した clipboard error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_CLIPBOARD_ERROR_CODE = {\n CapabilityMissing: \"capability-missing\",\n NotAllowed: \"not-allowed\",\n ClipboardError: \"clipboard-error\",\n} as const;\n\n/**\n * 正規化済み error(`{ name, message }`)を serializable な error taxonomy に写す。\n * `NotSupportedError`(Clipboard API 不在)→ capability-missing、`NotAllowedError`\n * (permission 拒否、retry では回復しない)→ not-allowed、その他 → clipboard-error。\n */\nexport function deriveClipboardErrorInfo(name: string, message: string): WcsIoErrorInfo {\n if (name === \"NotSupportedError\") {\n return { code: WCS_CLIPBOARD_ERROR_CODE.CapabilityMissing, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NotAllowedError\") {\n return { code: WCS_CLIPBOARD_ERROR_CODE.NotAllowed, phase: \"execute\", recoverable: false, message };\n }\n return { code: WCS_CLIPBOARD_ERROR_CODE.ClipboardError, phase: \"execute\", recoverable: true, message };\n}\n","import {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardReadDetail, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveClipboardErrorInfo } from \"./clipboardCapabilities.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 // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from the normalized `error` (`name` →\n // capability-missing / not-allowed / clipboard-error); the existing `error`\n // property/event are unchanged. Fires `wcs-clipboard:error-info-changed`.\n { name: \"errorInfo\", event: \"wcs-clipboard:error-info-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 _errorInfo: WcsIoErrorInfo | 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 /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Exposed as an additive wc-bindable property (event\n * `wcs-clipboard:error-info-changed`), derived from the normalized `error`; the\n * existing `error` property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\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 // Keep the additive `errorInfo` taxonomy in sync with `error`: derive it from\n // the normalized error (or null on clear). Fires before the `error` event so an\n // observer binding both sees the classification first, mirroring the io-node\n // family. No lane here — clipboard's read/write ops don't compete.\n this._commitErrorInfo(error === null ? null : deriveClipboardErrorInfo(error.name, error.message));\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already same-value-guards on the error\n // reference), so errorInfo transitions exactly when error does — no separate\n // guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:error-info-changed\", {\n detail: info,\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 { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n// Named WcsClipboard (not `Clipboard`) so the class does not shadow the global\n// DOM `Clipboard` interface (the type of `navigator.clipboard`), matching the\n// <wcs-geo> WcsGeolocation / <wcs-ws> WcsWebSocket convention.\nexport class WcsClipboard extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...ClipboardCore.wcBindable,\n // Shell-level settable surface. `monitor` mirrors its boolean attribute\n // (reflects idempotently), following the <wcs-ws> / <wcs-geo> convention.\n // There is no momentary `trigger` property: writes need an argument (the\n // text/items), so element actions are driven via command-token\n // (`command.writeText: $command.copy`) or the DOM autoTrigger, not a\n // false→true boolean pulse.\n inputs: [\n { name: \"monitor\", attribute: \"monitor\" },\n ],\n // Commands are identical to the Core's — no rename is needed because the\n // `monitor` boolean attribute accessor does not collide with the\n // `startMonitor` / `stopMonitor` command names (unlike <wcs-geo>, whose\n // `watch` attribute forced the Core's `watch` command to `watchPosition`).\n commands: ClipboardCore.wcBindable.commands,\n };\n\n private _core: ClipboardCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new ClipboardCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-clipboard:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-clipboard:monitoring-changed\": (d) => ({ monitoring: d === true }),\n \"wcs-clipboard:error\": (d) => ({ error: d != null }),\n });\n }\n\n // SSR (§4.4): the state binder awaits this before snapshotting, so the first\n // permission probe has settled. Backed by _core.observe() (see connectedCallback).\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n\n get monitor(): boolean {\n return this.hasAttribute(\"monitor\");\n }\n\n /**\n * Reflects the `monitor` boolean attribute only — it does NOT start or stop\n * monitoring by itself. The attribute is read at connect time (see\n * connectedCallback); toggling `el.monitor` after connect just flips the\n * attribute. To start/stop monitoring imperatively, call `startMonitor()` /\n * `stopMonitor()`.\n */\n set monitor(value: boolean) {\n if (value) {\n this.setAttribute(\"monitor\", \"\");\n } else {\n this.removeAttribute(\"monitor\");\n }\n }\n\n // --- Core delegated getters ---\n\n get text(): string | null {\n return this._core.text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._core.items;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\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","WCS_CLIPBOARD_ERROR_CODE","CapabilityMissing","NotAllowed","ClipboardError","ClipboardCore","EventTarget","static","protocol","version","properties","name","event","getter","e","detail","text","items","commands","async","_target","_text","_items","_loading","_error","_errorInfo","_readPermission","_writePermission","_monitoring","_copied","_cut","_pasted","_readStatus","_writeStatus","_permissionSubscribed","_permGen","_acqGen","_ready","Promise","resolve","constructor","target","super","this","_initPermissions","ready","observe","reinitPermission","loading","error","errorInfo","readPermission","writePermission","monitoring","copied","cut","pasted","_setRead","dispatchEvent","CustomEvent","bubbles","_setLoading","_setError","message","_commitErrorInfo","code","phase","recoverable","info","_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","String","registered","TEXT_ATTRIBUTE","handleClick","Element","triggerElement","closest","clipboardId","getAttribute","ClipboardCtor","customElements","get","clipboardElement","getElementById","hasAttribute","selector","source","querySelector","HTMLInputElement","HTMLTextAreaElement","HTMLSelectElement","value","textContent","resolveText","preventDefault","WcsClipboard","HTMLElement","wcBindable","inputs","attribute","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","connectedCallbackPromise","debugStates","states","attachInternals","internals","add","delete","toStates","entries","debug","on","toggleAttribute","monitor","setAttribute","removeAttribute","connectedCallback","style","display","disconnectedCallback","bootstrapClipboard","userConfig","partialConfig","assign","define"],"mappings":"AAUA,MAAMA,EAA2B,CAC/BC,aAAa,EACbC,iBAAkB,uBAClBC,SAAU,CACRC,UAAW,kBAIf,SAASC,EAAcC,GACrB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpDC,OAAOC,OAAOF,GACd,IAAK,MAAMG,KAAOF,OAAOG,KAAKJ,GAC5BD,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,CCjCO,MAAMG,EAA2B,CACtCC,kBAAmB,qBACnBC,WAAY,cACZC,eAAgB,mBCeZ,MAAOC,UAAsBC,YACjCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,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ACpB,CAEA,UAAIC,GACF,OAAOX,KAAK2H,MAAMhH,MACpB,CAEA,OAAIC,GACF,OAAOZ,KAAK2H,MAAM/G,GACpB,CAEA,UAAIC,GACF,OAAOb,KAAK2H,MAAM9G,MACpB,CAIA,SAAAoB,CAAU5D,GACR,OAAO2B,KAAK2H,MAAM1F,UAAU5D,EAC9B,CAEA,KAAA+D,CAAM9D,GACJ,OAAO0B,KAAK2H,MAAMvF,MAAM9D,EAC1B,CAEA,QAAA+D,GACE,OAAOrC,KAAK2H,MAAMtF,UACpB,CAEA,IAAAE,GACE,OAAOvC,KAAK2H,MAAMpF,MACpB,CAEA,YAAAE,GACEzC,KAAK2H,MAAMlF,cACb,CAEA,WAAAM,GACE/C,KAAK2H,MAAM5E,aACb,CAIA,iBAAAiG,GACEhJ,KAAKiJ,MAAMC,QAAU,OACjB9L,EAAOb,cD3HTuJ,IACJA,GAAa,EACbpD,SAASC,iBAAiB,QAASqD,KC+HjChG,KAAK4H,0BAA4B5H,KAAK2H,MAAMxH,UAGxCH,KAAK6I,SACP7I,KAAK2H,MAAMlF,cAEf,CAEA,oBAAA0G,GACEnJ,KAAK2H,MAAM5E,cACX/C,KAAK2H,MAAM1E,SACb,EC5MI,SAAUmG,EAAmBC,GL2C7B,IAAoBC,EK1CpBD,IL2CqC,kBADjBC,EKzCZD,GL0Ca9M,cACvBD,EAAQC,YAAc+M,EAAc/M,aAEQ,iBAAnC+M,EAAc9M,mBACvBF,EAAQE,iBAAmB8M,EAAc9M,kBAEvC8M,EAAc7M,UAChBI,OAAO0M,OAAOjN,EAAQG,SAAU6M,EAAc7M,UAEhDU,EAAe,MMrDVoJ,eAAeC,IAAIpJ,EAAOX,SAASC,YACtC6J,eAAeiD,OAAOpM,EAAOX,SAASC,UAAW4K,EDIrD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/clipboard",
3
- "version": "1.20.0",
3
+ "version": "1.21.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",