react-smart-copy 1.29.3 → 1.31.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.md +6 -3
- package/dist/chunks/copy-machine-B6apNst5.d.ts +132 -0
- package/dist/chunks/copy-machine-CmqX9J4V.d.cts +132 -0
- package/dist/chunks/copy-machine-DwdB-qva.js +292 -0
- package/dist/chunks/copy-machine-DwdB-qva.js.map +1 -0
- package/dist/chunks/copy-machine-oNmnrjMc.cjs +345 -0
- package/dist/chunks/copy-machine-oNmnrjMc.cjs.map +1 -0
- package/dist/chunks/{core-B8_wVOSU.js → core-CNSd-EgZ.js} +4 -290
- package/dist/chunks/core-CNSd-EgZ.js.map +1 -0
- package/dist/chunks/{core-BR8Jgea1.cjs → core-DsMKPNx_.cjs} +20 -348
- package/dist/chunks/core-DsMKPNx_.cjs.map +1 -0
- package/dist/chunks/{index-DjqQGsNs.d.ts → index-B4SEFtkx.d.ts} +3 -131
- package/dist/chunks/{index-uHZHddq0.d.cts → index-BDxj1EqC.d.cts} +3 -131
- package/dist/chunks/text-C2OYT-3o.cjs +478 -0
- package/dist/chunks/text-C2OYT-3o.cjs.map +1 -0
- package/dist/chunks/text-nc1LhgIh.js +413 -0
- package/dist/chunks/text-nc1LhgIh.js.map +1 -0
- package/dist/chunks/utils-C7_VlH79.cjs +53 -0
- package/dist/chunks/utils-C7_VlH79.cjs.map +1 -0
- package/dist/chunks/utils-CBBX2HN6.js +30 -0
- package/dist/chunks/utils-CBBX2HN6.js.map +1 -0
- package/dist/compat.cjs +94 -0
- package/dist/compat.cjs.map +1 -0
- package/dist/compat.d.cts +57 -0
- package/dist/compat.d.ts +57 -0
- package/dist/compat.js +88 -0
- package/dist/compat.js.map +1 -0
- package/dist/core.cjs +8 -7
- package/dist/core.d.cts +2 -1
- package/dist/core.d.ts +2 -1
- package/dist/core.js +2 -1
- package/dist/index.cjs +45 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -27
- package/dist/index.js.map +1 -1
- package/dist/markdown.cjs +38 -2
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.d.cts +5 -0
- package/dist/markdown.d.ts +5 -0
- package/dist/markdown.js +38 -2
- package/dist/markdown.js.map +1 -1
- package/dist/rich.cjs +14 -422
- package/dist/rich.cjs.map +1 -1
- package/dist/rich.js +1 -409
- package/dist/rich.js.map +1 -1
- package/package.json +23 -4
- package/dist/chunks/core-B8_wVOSU.js.map +0 -1
- package/dist/chunks/core-BR8Jgea1.cjs.map +0 -1
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
|
|
2
|
+
const require_errors = require("./errors-CF2EQNbc.cjs");
|
|
3
|
+
const require_payload = require("./payload-DjSSLonm.cjs");
|
|
4
|
+
const require_clipboard_adapter = require("./clipboard-adapter-DYo79Fdq.cjs");
|
|
5
|
+
//#region src/core/machine-shared.ts
|
|
6
|
+
/**
|
|
7
|
+
* Internals shared by the copy and paste state machines. Kept in one module so
|
|
8
|
+
* apps that use both don't ship two copies.
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULT_MAX_RETRIES = 3;
|
|
11
|
+
function resolveMaxRetries(value) {
|
|
12
|
+
if (value === Infinity) return Infinity;
|
|
13
|
+
if (value === void 0 || !Number.isFinite(value)) return 3;
|
|
14
|
+
return Math.max(0, Math.floor(value));
|
|
15
|
+
}
|
|
16
|
+
function reportCallbackError(error) {
|
|
17
|
+
const scope = globalThis;
|
|
18
|
+
if (typeof scope.reportError === "function") scope.reportError(error);
|
|
19
|
+
else setTimeout(() => {
|
|
20
|
+
throw error;
|
|
21
|
+
}, 0);
|
|
22
|
+
}
|
|
23
|
+
/** User callbacks must never corrupt machine state; their errors are reported, not swallowed. */
|
|
24
|
+
function invoke(fn, ...args) {
|
|
25
|
+
if (!fn) return;
|
|
26
|
+
try {
|
|
27
|
+
fn(...args);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
reportCallbackError(error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** One cancellable operation at a time. Signals only fire while their operation is unfinished. */
|
|
33
|
+
function createOperations() {
|
|
34
|
+
let controller;
|
|
35
|
+
const abort = () => {
|
|
36
|
+
if (!controller) return false;
|
|
37
|
+
controller.abort();
|
|
38
|
+
controller = void 0;
|
|
39
|
+
return true;
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
start: () => {
|
|
43
|
+
abort();
|
|
44
|
+
controller = new AbortController();
|
|
45
|
+
return { signal: controller.signal };
|
|
46
|
+
},
|
|
47
|
+
end: (context) => {
|
|
48
|
+
if (controller?.signal === context.signal) controller = void 0;
|
|
49
|
+
},
|
|
50
|
+
abort
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/core/source-error.ts
|
|
55
|
+
/**
|
|
56
|
+
* The error for a user-supplied source (copy source, drag source, copy transform)
|
|
57
|
+
* that threw. A thrown `CopyFailure` keeps its classification, so a helper such as
|
|
58
|
+
* `tablePayload()` can report `too-large` instead of a generic `invalid-payload`.
|
|
59
|
+
* Internal: not part of the public API.
|
|
60
|
+
*/
|
|
61
|
+
function sourceError(cause, message) {
|
|
62
|
+
return require_errors.isCopyFailure(cause) ? cause.copyError : require_errors.createCopyError("invalid-payload", message, cause);
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/core/copy-machine.ts
|
|
66
|
+
const DEFAULT_RESET_AFTER_MS = 2e3;
|
|
67
|
+
const noop = () => void 0;
|
|
68
|
+
function isThenable(value) {
|
|
69
|
+
return typeof value === "object" && value !== null && typeof value.then === "function";
|
|
70
|
+
}
|
|
71
|
+
const IDLE_STATE = /* @__PURE__ */ Object.freeze({ status: "idle" });
|
|
72
|
+
const IGNORED_IN_FLIGHT = /* @__PURE__ */ Object.freeze({
|
|
73
|
+
status: "ignored",
|
|
74
|
+
reason: "in-flight"
|
|
75
|
+
});
|
|
76
|
+
const IGNORED_NOTHING = /* @__PURE__ */ Object.freeze({
|
|
77
|
+
status: "ignored",
|
|
78
|
+
reason: "nothing-to-retry"
|
|
79
|
+
});
|
|
80
|
+
const IGNORED_NOT_RETRYABLE = /* @__PURE__ */ Object.freeze({
|
|
81
|
+
status: "ignored",
|
|
82
|
+
reason: "not-retryable"
|
|
83
|
+
});
|
|
84
|
+
const IGNORED_CANCELLED = /* @__PURE__ */ Object.freeze({
|
|
85
|
+
status: "ignored",
|
|
86
|
+
reason: "cancelled"
|
|
87
|
+
});
|
|
88
|
+
function resolveResetDelay(value) {
|
|
89
|
+
if (value === false || value === Infinity) return null;
|
|
90
|
+
if (value === void 0 || Number.isNaN(value)) return DEFAULT_RESET_AFTER_MS;
|
|
91
|
+
return Math.max(0, value);
|
|
92
|
+
}
|
|
93
|
+
/** Pure helper: can `retry()` do anything from this state? */
|
|
94
|
+
function canRetryState(state, maxRetries) {
|
|
95
|
+
return state.status === "error" && state.payload !== null && require_errors.isRetryableError(state.error) && state.retryCount < resolveMaxRetries(maxRetries);
|
|
96
|
+
}
|
|
97
|
+
let defaultAdapter;
|
|
98
|
+
const getDefaultAdapter = () => defaultAdapter ?? (defaultAdapter = require_clipboard_adapter.createBrowserClipboardAdapter());
|
|
99
|
+
/** Framework-agnostic copy state machine. */
|
|
100
|
+
function createCopyMachine(options = {}) {
|
|
101
|
+
const read = typeof options === "function" ? options : () => options;
|
|
102
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
103
|
+
let state = IDLE_STATE;
|
|
104
|
+
let generation = 0;
|
|
105
|
+
let resetTimer;
|
|
106
|
+
const operations = createOperations();
|
|
107
|
+
const now = () => (read().now ?? Date.now)();
|
|
108
|
+
let joined = null;
|
|
109
|
+
const member = { release: () => {
|
|
110
|
+
if (state.status === "copied") {
|
|
111
|
+
clearResetTimer();
|
|
112
|
+
setState(IDLE_STATE);
|
|
113
|
+
}
|
|
114
|
+
} };
|
|
115
|
+
const setState = (next) => {
|
|
116
|
+
if (next === state) return;
|
|
117
|
+
const previous = state;
|
|
118
|
+
state = next;
|
|
119
|
+
if (previous.status === "copied" && next.status !== "copied" && joined) {
|
|
120
|
+
joined.deactivate(member);
|
|
121
|
+
joined = null;
|
|
122
|
+
}
|
|
123
|
+
for (const listener of Array.from(listeners)) listener();
|
|
124
|
+
};
|
|
125
|
+
const joinCoordinator = () => {
|
|
126
|
+
joined = read().coordinator ?? null;
|
|
127
|
+
joined?.activate(member);
|
|
128
|
+
};
|
|
129
|
+
const clearResetTimer = () => {
|
|
130
|
+
if (resetTimer !== void 0) {
|
|
131
|
+
clearTimeout(resetTimer);
|
|
132
|
+
resetTimer = void 0;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const scheduleReset = (copied) => {
|
|
136
|
+
clearResetTimer();
|
|
137
|
+
const delay = resolveResetDelay(read().resetAfterMs);
|
|
138
|
+
if (delay === null) return;
|
|
139
|
+
const remaining = Math.max(0, delay - (now() - copied.at));
|
|
140
|
+
resetTimer = setTimeout(() => {
|
|
141
|
+
resetTimer = void 0;
|
|
142
|
+
setState(IDLE_STATE);
|
|
143
|
+
}, remaining);
|
|
144
|
+
};
|
|
145
|
+
const settleError = (error, payload, retryCount) => {
|
|
146
|
+
setState({
|
|
147
|
+
status: "error",
|
|
148
|
+
payload,
|
|
149
|
+
error,
|
|
150
|
+
retryCount
|
|
151
|
+
});
|
|
152
|
+
invoke(read().onError, error, payload);
|
|
153
|
+
};
|
|
154
|
+
const run = (source, retryCount) => {
|
|
155
|
+
clearResetTimer();
|
|
156
|
+
const current = ++generation;
|
|
157
|
+
const context = operations.start();
|
|
158
|
+
const fail = (error, payload) => {
|
|
159
|
+
operations.end(context);
|
|
160
|
+
settleError(error, payload, retryCount);
|
|
161
|
+
return Promise.resolve({
|
|
162
|
+
status: "error",
|
|
163
|
+
error
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
let resolved;
|
|
167
|
+
try {
|
|
168
|
+
resolved = typeof source === "function" ? source(context) : source;
|
|
169
|
+
} catch (cause) {
|
|
170
|
+
return fail(sourceError(cause, "The copy source function threw."), null);
|
|
171
|
+
}
|
|
172
|
+
const adapter = read().adapter ?? getDefaultAdapter();
|
|
173
|
+
let payload = null;
|
|
174
|
+
let pending;
|
|
175
|
+
if (isThenable(resolved)) {
|
|
176
|
+
const arrived = Promise.resolve(resolved).then((input) => {
|
|
177
|
+
if (context.signal.aborted) throw require_errors.copyFailure("aborted", "Copying was cancelled.");
|
|
178
|
+
const made = require_payload.normalizePayload(input);
|
|
179
|
+
if (made.kind !== "text" && made.kind !== "json") throw require_errors.copyFailure("invalid-payload", "An async copy source must resolve to text or JSON.");
|
|
180
|
+
const invalid = require_payload.validatePayload(made);
|
|
181
|
+
if (invalid) throw new require_errors.CopyFailure(invalid);
|
|
182
|
+
payload = made;
|
|
183
|
+
return made.kind === "text" ? made.value : require_payload.serializeJson(made);
|
|
184
|
+
}, (cause) => {
|
|
185
|
+
throw new require_errors.CopyFailure(sourceError(cause, "The copy source rejected."));
|
|
186
|
+
});
|
|
187
|
+
setState({
|
|
188
|
+
status: "copying",
|
|
189
|
+
payload: null,
|
|
190
|
+
retryCount
|
|
191
|
+
});
|
|
192
|
+
try {
|
|
193
|
+
pending = (adapter.writeDeferred ? adapter.writeDeferred(arrived, context) : arrived.then(() => adapter.write(payload, context))).then(() => arrived).then(noop);
|
|
194
|
+
} catch (cause) {
|
|
195
|
+
arrived.catch(noop);
|
|
196
|
+
pending = Promise.reject(cause);
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
payload = require_payload.normalizePayload(resolved);
|
|
200
|
+
const invalid = require_payload.validatePayload(payload);
|
|
201
|
+
if (invalid) return fail(invalid, payload);
|
|
202
|
+
setState({
|
|
203
|
+
status: "copying",
|
|
204
|
+
payload,
|
|
205
|
+
retryCount
|
|
206
|
+
});
|
|
207
|
+
try {
|
|
208
|
+
pending = adapter.write(payload, context);
|
|
209
|
+
} catch (cause) {
|
|
210
|
+
pending = Promise.reject(cause);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return pending.then(() => {
|
|
214
|
+
operations.end(context);
|
|
215
|
+
const done = payload;
|
|
216
|
+
if (current === generation) {
|
|
217
|
+
const copied = {
|
|
218
|
+
status: "copied",
|
|
219
|
+
payload: done,
|
|
220
|
+
at: now()
|
|
221
|
+
};
|
|
222
|
+
setState(copied);
|
|
223
|
+
joinCoordinator();
|
|
224
|
+
scheduleReset(copied);
|
|
225
|
+
invoke(read().onCopy, done);
|
|
226
|
+
}
|
|
227
|
+
return {
|
|
228
|
+
status: "copied",
|
|
229
|
+
payload: done
|
|
230
|
+
};
|
|
231
|
+
}, (cause) => {
|
|
232
|
+
operations.end(context);
|
|
233
|
+
if (context.signal.aborted) return IGNORED_CANCELLED;
|
|
234
|
+
const error = require_errors.toCopyError(cause);
|
|
235
|
+
settleError(error, payload, retryCount);
|
|
236
|
+
return {
|
|
237
|
+
status: "error",
|
|
238
|
+
error
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
const copy = (source) => state.status === "copying" ? Promise.resolve(IGNORED_IN_FLIGHT) : run(source, 0);
|
|
243
|
+
const retry = () => {
|
|
244
|
+
if (state.status !== "error") return Promise.resolve(IGNORED_NOTHING);
|
|
245
|
+
if (state.payload === null || !require_errors.isRetryableError(state.error)) return Promise.resolve(IGNORED_NOT_RETRYABLE);
|
|
246
|
+
if (state.retryCount >= resolveMaxRetries(read().maxRetries)) {
|
|
247
|
+
const error = require_errors.createCopyError("max-retries-exceeded", `Copy failed after ${String(state.retryCount)} retries.`, state.error);
|
|
248
|
+
settleError(error, state.payload, state.retryCount);
|
|
249
|
+
return Promise.resolve({
|
|
250
|
+
status: "error",
|
|
251
|
+
error
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
return run(state.payload, state.retryCount + 1);
|
|
255
|
+
};
|
|
256
|
+
const reset = () => {
|
|
257
|
+
++generation;
|
|
258
|
+
const cancelled = operations.abort();
|
|
259
|
+
clearResetTimer();
|
|
260
|
+
const wasIdle = state.status === "idle";
|
|
261
|
+
setState(IDLE_STATE);
|
|
262
|
+
if (cancelled) invoke(read().onCancel, "reset");
|
|
263
|
+
if (!wasIdle) invoke(read().onReset);
|
|
264
|
+
};
|
|
265
|
+
const connect = () => {
|
|
266
|
+
if (state.status === "copied") scheduleReset(state);
|
|
267
|
+
return () => {
|
|
268
|
+
++generation;
|
|
269
|
+
const cancelled = operations.abort();
|
|
270
|
+
clearResetTimer();
|
|
271
|
+
if (state.status === "copying") setState(IDLE_STATE);
|
|
272
|
+
if (cancelled) invoke(read().onCancel, "disconnect");
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
return {
|
|
276
|
+
getSnapshot: () => state,
|
|
277
|
+
subscribe: (listener) => {
|
|
278
|
+
listeners.add(listener);
|
|
279
|
+
return () => {
|
|
280
|
+
listeners.delete(listener);
|
|
281
|
+
};
|
|
282
|
+
},
|
|
283
|
+
copy,
|
|
284
|
+
retry,
|
|
285
|
+
reset,
|
|
286
|
+
connect
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
//#endregion
|
|
290
|
+
Object.defineProperty(exports, "DEFAULT_MAX_RETRIES", {
|
|
291
|
+
enumerable: true,
|
|
292
|
+
get: function() {
|
|
293
|
+
return DEFAULT_MAX_RETRIES;
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
Object.defineProperty(exports, "DEFAULT_RESET_AFTER_MS", {
|
|
297
|
+
enumerable: true,
|
|
298
|
+
get: function() {
|
|
299
|
+
return DEFAULT_RESET_AFTER_MS;
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
Object.defineProperty(exports, "IDLE_STATE", {
|
|
303
|
+
enumerable: true,
|
|
304
|
+
get: function() {
|
|
305
|
+
return IDLE_STATE;
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
Object.defineProperty(exports, "canRetryState", {
|
|
309
|
+
enumerable: true,
|
|
310
|
+
get: function() {
|
|
311
|
+
return canRetryState;
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
Object.defineProperty(exports, "createCopyMachine", {
|
|
315
|
+
enumerable: true,
|
|
316
|
+
get: function() {
|
|
317
|
+
return createCopyMachine;
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
Object.defineProperty(exports, "createOperations", {
|
|
321
|
+
enumerable: true,
|
|
322
|
+
get: function() {
|
|
323
|
+
return createOperations;
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
Object.defineProperty(exports, "invoke", {
|
|
327
|
+
enumerable: true,
|
|
328
|
+
get: function() {
|
|
329
|
+
return invoke;
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
Object.defineProperty(exports, "resolveMaxRetries", {
|
|
333
|
+
enumerable: true,
|
|
334
|
+
get: function() {
|
|
335
|
+
return resolveMaxRetries;
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
Object.defineProperty(exports, "sourceError", {
|
|
339
|
+
enumerable: true,
|
|
340
|
+
get: function() {
|
|
341
|
+
return sourceError;
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
//# sourceMappingURL=copy-machine-oNmnrjMc.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-machine-oNmnrjMc.cjs","names":["isCopyFailure","createCopyError","isRetryableError","createBrowserClipboardAdapter","copyFailure","normalizePayload","validatePayload","CopyFailure","serializeJson","toCopyError","createCopyError"],"sources":["../../src/core/machine-shared.ts","../../src/core/source-error.ts","../../src/core/copy-machine.ts"],"sourcesContent":["/**\n * Internals shared by the copy and paste state machines. Kept in one module so\n * apps that use both don't ship two copies.\n */\n\nexport const DEFAULT_MAX_RETRIES = 3;\n\n/**\n * Passed to adapters and lazy sources as their last argument. `signal` aborts\n * when the operation is superseded, `reset()`, or its host unmounts, so\n * expensive work (rasterising, decoding) can stop early.\n */\nexport interface OperationContext {\n readonly signal: AbortSignal;\n}\n\nexport function resolveMaxRetries(value: number | undefined): number {\n if (value === Infinity) return Infinity;\n if (value === undefined || !Number.isFinite(value)) return DEFAULT_MAX_RETRIES;\n return Math.max(0, Math.floor(value));\n}\n\nfunction reportCallbackError(error: unknown): void {\n const scope = globalThis as { reportError?: (error: unknown) => void };\n if (typeof scope.reportError === 'function') {\n scope.reportError(error);\n } else {\n setTimeout(() => {\n throw error;\n }, 0);\n }\n}\n\n/** User callbacks must never corrupt machine state; their errors are reported, not swallowed. */\nexport function invoke<Args extends unknown[]>(fn: ((...args: Args) => void) | undefined, ...args: Args): void {\n if (!fn) return;\n try {\n fn(...args);\n } catch (error) {\n reportCallbackError(error);\n }\n}\n\nexport interface Operations {\n /** Aborts the operation in flight (if any) and starts a new one. */\n readonly start: () => OperationContext;\n /** Marks `context` finished, so a later `abort()` never fires its signal. */\n readonly end: (context: OperationContext) => void;\n /** Cancels the operation in flight, if any. Returns whether one was cancelled. */\n readonly abort: () => boolean;\n}\n\n/** One cancellable operation at a time. Signals only fire while their operation is unfinished. */\nexport function createOperations(): Operations {\n let controller: AbortController | undefined;\n const abort = (): boolean => {\n if (!controller) return false;\n controller.abort();\n controller = undefined;\n return true;\n };\n return {\n start: () => {\n abort();\n controller = new AbortController();\n return { signal: controller.signal };\n },\n end: (context) => {\n if (controller?.signal === context.signal) controller = undefined;\n },\n abort,\n };\n}\n","import { createCopyError, isCopyFailure, type CopyError } from './errors';\n\n/**\n * The error for a user-supplied source (copy source, drag source, copy transform)\n * that threw. A thrown `CopyFailure` keeps its classification, so a helper such as\n * `tablePayload()` can report `too-large` instead of a generic `invalid-payload`.\n * Internal: not part of the public API.\n */\nexport function sourceError(cause: unknown, message: string): CopyError {\n return isCopyFailure(cause) ? cause.copyError : createCopyError('invalid-payload', message, cause);\n}\n","import { createBrowserClipboardAdapter, type ClipboardAdapter } from './clipboard-adapter';\nimport type { CopyCoordinator, CopyCoordinatorMember } from './copy-coordinator';\nimport { copyFailure, createCopyError, CopyFailure, isRetryableError, toCopyError, type CopyError } from './errors';\nimport { createOperations, invoke, resolveMaxRetries } from './machine-shared';\nimport {\n normalizePayload,\n serializeJson,\n validatePayload,\n type AsyncCopyInput,\n type CopyInput,\n type CopyPayload,\n type CopySource,\n} from './payload';\nimport { sourceError } from './source-error';\n\nexport { DEFAULT_MAX_RETRIES, resolveMaxRetries } from './machine-shared';\n\nexport const DEFAULT_RESET_AFTER_MS = 2000;\n\nconst noop = (): void => undefined;\n\nfunction isThenable(value: unknown): value is PromiseLike<unknown> {\n return typeof value === 'object' && value !== null && typeof (value as { then?: unknown }).then === 'function';\n}\n\nexport interface IdleState {\n readonly status: 'idle';\n}\nexport interface CopyingState {\n readonly status: 'copying';\n /** `null` while an async source is still producing its text. */\n readonly payload: CopyPayload | null;\n readonly retryCount: number;\n}\nexport interface CopiedState {\n readonly status: 'copied';\n readonly payload: CopyPayload;\n /** Epoch ms when the write resolved. */\n readonly at: number;\n}\nexport interface ErrorState {\n readonly status: 'error';\n /** `null` when the input itself could not be resolved. */\n readonly payload: CopyPayload | null;\n readonly error: CopyError;\n readonly retryCount: number;\n}\n\nexport type CopyState = IdleState | CopyingState | CopiedState | ErrorState;\nexport type CopyStatus = CopyState['status'];\n\n/**\n * `cancelled`: the copy was reset or its host unmounted before it finished,\n * so its work was aborted. Nothing to report to the user.\n */\nexport type CopyIgnoredReason = 'in-flight' | 'nothing-to-retry' | 'not-retryable' | 'cancelled';\n\n/**\n * Why an in-flight copy was cancelled: `reset` (`reset()` was called) or\n * `disconnect` (its host disconnected, e.g. the React component unmounted).\n */\nexport type CopyCancelReason = 'reset' | 'disconnect';\n\n/** What `copy()`/`retry()` resolve to. They never reject. */\nexport type CopyOutcome =\n | { readonly status: 'copied'; readonly payload: CopyPayload }\n | { readonly status: 'error'; readonly error: CopyError }\n | { readonly status: 'ignored'; readonly reason: CopyIgnoredReason };\n\nexport interface CopyMachineOptions {\n /** Defaults to the browser Clipboard API adapter. */\n readonly adapter?: ClipboardAdapter;\n /** Time in `copied` before returning to `idle`. `false`/`Infinity` disables. Default 2000. */\n readonly resetAfterMs?: number | false;\n /**\n * Max `retry()` calls after the first failure. Default 3. `0` disables\n * retry; `Infinity` allows unlimited retries.\n */\n readonly maxRetries?: number;\n /**\n * Share \"Copied\" with other machines: only one member of a coordinator\n * shows `copied` at a time. `null` explicitly opts out (e.g. of a React `<CopyGroup>`).\n */\n readonly coordinator?: CopyCoordinator | null;\n readonly onCopy?: (payload: CopyPayload) => void;\n readonly onError?: (error: CopyError, payload: CopyPayload | null) => void;\n /**\n * `reset()` moved the machine back to `idle` from any other state. Not\n * called for the automatic return after `resetAfterMs`, for a `<CopyGroup>`\n * handing \"Copied\" to another member, or when already `idle`.\n */\n readonly onReset?: () => void;\n /**\n * A copy in flight was cancelled before it settled: its `signal` aborted\n * and its result will not reach state or `onCopy` / `onError`. Fires\n * before `onReset` when `reset()` cancels a copy.\n */\n readonly onCancel?: (reason: CopyCancelReason) => void;\n /** Clock injection for tests and deterministic environments. */\n readonly now?: () => number;\n}\n\n/** Options object, or a getter so hosts (like React) can supply the latest options. */\nexport type CopyMachineOptionsSource = CopyMachineOptions | (() => CopyMachineOptions);\n\nexport interface CopyMachine {\n readonly getSnapshot: () => CopyState;\n readonly subscribe: (listener: () => void) => () => void;\n readonly copy: (source: CopySource) => Promise<CopyOutcome>;\n readonly retry: () => Promise<CopyOutcome>;\n /** Back to `idle`. Discards any in-flight result and aborts its `signal`. */\n readonly reset: () => void;\n /**\n * Lifecycle hook for hosts. Re-arms a pending auto-reset; the returned\n * cleanup clears timers, drops in-flight results, aborts in-flight work and\n * unsticks `copying`.\n * Safe to call repeatedly (React StrictMode).\n */\n readonly connect: () => () => void;\n}\n\nexport const IDLE_STATE: IdleState = /* @__PURE__ */ Object.freeze({ status: 'idle' });\n\nconst IGNORED_IN_FLIGHT: CopyOutcome = /* @__PURE__ */ Object.freeze({ status: 'ignored', reason: 'in-flight' });\nconst IGNORED_NOTHING: CopyOutcome = /* @__PURE__ */ Object.freeze({ status: 'ignored', reason: 'nothing-to-retry' });\nconst IGNORED_NOT_RETRYABLE: CopyOutcome = /* @__PURE__ */ Object.freeze({ status: 'ignored', reason: 'not-retryable' });\nconst IGNORED_CANCELLED: CopyOutcome = /* @__PURE__ */ Object.freeze({ status: 'ignored', reason: 'cancelled' });\n\nfunction resolveResetDelay(value: number | false | undefined): number | null {\n if (value === false || value === Infinity) return null;\n if (value === undefined || Number.isNaN(value)) return DEFAULT_RESET_AFTER_MS;\n return Math.max(0, value);\n}\n\n/** Pure helper: can `retry()` do anything from this state? */\nexport function canRetryState(state: CopyState, maxRetries?: number): boolean {\n return (\n state.status === 'error' &&\n state.payload !== null &&\n isRetryableError(state.error) &&\n state.retryCount < resolveMaxRetries(maxRetries)\n );\n}\n\nlet defaultAdapter: ClipboardAdapter | undefined;\nconst getDefaultAdapter = (): ClipboardAdapter => (defaultAdapter ??= createBrowserClipboardAdapter());\n\n/** Framework-agnostic copy state machine. */\nexport function createCopyMachine(options: CopyMachineOptionsSource = {}): CopyMachine {\n const read = typeof options === 'function' ? options : (): CopyMachineOptions => options;\n const listeners = new Set<() => void>();\n let state: CopyState = IDLE_STATE;\n let generation = 0;\n let resetTimer: ReturnType<typeof setTimeout> | undefined;\n const operations = createOperations();\n\n const now = (): number => (read().now ?? Date.now)();\n\n // The coordinator that saw this machine's last `copied`, so leaving it is reported to the same one.\n let joined: CopyCoordinator | null = null;\n\n const member: CopyCoordinatorMember = {\n release: () => {\n if (state.status === 'copied') {\n clearResetTimer();\n setState(IDLE_STATE);\n }\n },\n };\n\n const setState = (next: CopyState): void => {\n if (next === state) return;\n const previous = state;\n state = next;\n if (previous.status === 'copied' && next.status !== 'copied' && joined) {\n joined.deactivate(member);\n joined = null;\n }\n for (const listener of Array.from(listeners)) listener();\n };\n\n const joinCoordinator = (): void => {\n joined = read().coordinator ?? null;\n joined?.activate(member);\n };\n\n const clearResetTimer = (): void => {\n if (resetTimer !== undefined) {\n clearTimeout(resetTimer);\n resetTimer = undefined;\n }\n };\n\n const scheduleReset = (copied: CopiedState): void => {\n clearResetTimer();\n const delay = resolveResetDelay(read().resetAfterMs);\n if (delay === null) return;\n const remaining = Math.max(0, delay - (now() - copied.at));\n // Invariant: every transition out of `copied` clears this timer, so it only ever fires while still in `copied`.\n resetTimer = setTimeout(() => {\n resetTimer = undefined;\n setState(IDLE_STATE);\n }, remaining);\n };\n\n const settleError = (error: CopyError, payload: CopyPayload | null, retryCount: number): void => {\n setState({ status: 'error', payload, error, retryCount });\n invoke(read().onError, error, payload);\n };\n\n const run = (source: CopySource, retryCount: number): Promise<CopyOutcome> => {\n clearResetTimer();\n const current = ++generation;\n // Started before the source runs, so an async source gets the copy's abort signal.\n const context = operations.start();\n const fail = (error: CopyError, payload: CopyPayload | null): Promise<CopyOutcome> => {\n operations.end(context);\n settleError(error, payload, retryCount);\n return Promise.resolve({ status: 'error', error });\n };\n\n let resolved: CopyInput | PromiseLike<AsyncCopyInput>;\n try {\n resolved = typeof source === 'function' ? source(context) : source;\n } catch (cause) {\n return fail(sourceError(cause, 'The copy source function threw.'), null);\n }\n\n const adapter = read().adapter ?? getDefaultAdapter();\n // Known now for a value, once it arrives for an async source.\n let payload: CopyPayload | null = null;\n // The adapter is called synchronously: no await may precede it, or the\n // browser loses the transient user activation and rejects the write.\n let pending: Promise<void>;\n if (isThenable(resolved)) {\n // Text still being made (a share link from the server). The write starts now with a\n // promise of it, so the gesture is kept; the text is checked like any payload on arrival.\n const arrived = Promise.resolve(resolved).then(\n (input): string => {\n if (context.signal.aborted) throw copyFailure('aborted', 'Copying was cancelled.');\n const made = normalizePayload(input);\n if (made.kind !== 'text' && made.kind !== 'json') {\n throw copyFailure('invalid-payload', 'An async copy source must resolve to text or JSON.');\n }\n const invalid = validatePayload(made);\n if (invalid) throw new CopyFailure(invalid);\n payload = made;\n return made.kind === 'text' ? made.value : serializeJson(made);\n },\n (cause: unknown): never => {\n throw new CopyFailure(sourceError(cause, 'The copy source rejected.'));\n },\n );\n setState({ status: 'copying', payload: null, retryCount });\n try {\n const written = adapter.writeDeferred ? adapter.writeDeferred(arrived, context) : arrived.then(() => adapter.write(payload as CopyPayload, context));\n // Copied only once the text has arrived, whatever the adapter resolves first.\n pending = written.then(() => arrived).then(noop);\n } catch (cause) {\n arrived.catch(noop);\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors -- classified by toCopyError()\n pending = Promise.reject(cause);\n }\n } else {\n payload = normalizePayload(resolved);\n const invalid = validatePayload(payload);\n if (invalid) return fail(invalid, payload);\n setState({ status: 'copying', payload, retryCount });\n try {\n pending = adapter.write(payload, context);\n } catch (cause) {\n // Keep the raw reason: toCopyError() classifies it (DOMException names, CopyFailure brand).\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors -- classified by toCopyError()\n pending = Promise.reject(cause);\n }\n }\n\n return pending.then(\n (): CopyOutcome => {\n operations.end(context);\n const done = payload as CopyPayload; // Set by now: an async source's text has arrived.\n if (current === generation) {\n const copied: CopiedState = { status: 'copied', payload: done, at: now() };\n setState(copied);\n joinCoordinator();\n scheduleReset(copied);\n invoke(read().onCopy, done);\n }\n return { status: 'copied', payload: done };\n },\n (cause: unknown): CopyOutcome => {\n operations.end(context);\n // Work we aborted ourselves (reset, unmount) is not a failure to report.\n // Invariant: superseding an in-flight copy always aborts it, so past\n // this line the copy is still the current one.\n if (context.signal.aborted) return IGNORED_CANCELLED;\n const error = toCopyError(cause);\n settleError(error, payload, retryCount);\n return { status: 'error', error };\n },\n );\n };\n\n const copy = (source: CopySource): Promise<CopyOutcome> =>\n state.status === 'copying' ? Promise.resolve(IGNORED_IN_FLIGHT) : run(source, 0);\n\n const retry = (): Promise<CopyOutcome> => {\n if (state.status !== 'error') return Promise.resolve(IGNORED_NOTHING);\n if (state.payload === null || !isRetryableError(state.error)) return Promise.resolve(IGNORED_NOT_RETRYABLE);\n\n if (state.retryCount >= resolveMaxRetries(read().maxRetries)) {\n const error = createCopyError(\n 'max-retries-exceeded',\n `Copy failed after ${String(state.retryCount)} retries.`,\n state.error,\n );\n settleError(error, state.payload, state.retryCount);\n return Promise.resolve({ status: 'error', error });\n }\n return run(state.payload, state.retryCount + 1);\n };\n\n const reset = (): void => {\n ++generation;\n const cancelled = operations.abort();\n clearResetTimer();\n const wasIdle = state.status === 'idle';\n setState(IDLE_STATE);\n if (cancelled) invoke(read().onCancel, 'reset');\n if (!wasIdle) invoke(read().onReset);\n };\n\n const connect = (): (() => void) => {\n if (state.status === 'copied') scheduleReset(state);\n return () => {\n ++generation;\n const cancelled = operations.abort();\n clearResetTimer();\n if (state.status === 'copying') setState(IDLE_STATE);\n if (cancelled) invoke(read().onCancel, 'disconnect');\n };\n };\n\n return {\n getSnapshot: () => state,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n copy,\n retry,\n reset,\n connect,\n };\n}\n"],"mappings":";;;;;;;;;AAKA,MAAa,sBAAsB;AAWnC,SAAgB,kBAAkB,OAAmC;CACnE,IAAI,UAAU,UAAU,OAAO;CAC/B,IAAI,UAAU,KAAA,KAAa,CAAC,OAAO,SAAS,KAAK,GAAG,OAAA;CACpD,OAAO,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,CAAC;AACtC;AAEA,SAAS,oBAAoB,OAAsB;CACjD,MAAM,QAAQ;CACd,IAAI,OAAO,MAAM,gBAAgB,YAC/B,MAAM,YAAY,KAAK;MAEvB,iBAAiB;EACf,MAAM;CACR,GAAG,CAAC;AAER;;AAGA,SAAgB,OAA+B,IAA2C,GAAG,MAAkB;CAC7G,IAAI,CAAC,IAAI;CACT,IAAI;EACF,GAAG,GAAG,IAAI;CACZ,SAAS,OAAO;EACd,oBAAoB,KAAK;CAC3B;AACF;;AAYA,SAAgB,mBAA+B;CAC7C,IAAI;CACJ,MAAM,cAAuB;EAC3B,IAAI,CAAC,YAAY,OAAO;EACxB,WAAW,MAAM;EACjB,aAAa,KAAA;EACb,OAAO;CACT;CACA,OAAO;EACL,aAAa;GACX,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