react-smart-copy 1.30.0 → 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 +4 -1
- 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/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 +20 -1
- package/dist/chunks/core-B8_wVOSU.js.map +0 -1
- package/dist/chunks/core-BR8Jgea1.cjs.map +0 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
const require_errors = require("./errors-CF2EQNbc.cjs");
|
|
3
|
-
const require_payload = require("./payload-DjSSLonm.cjs");
|
|
4
3
|
const require_mime = require("./mime--LB7kdqG.cjs");
|
|
5
|
-
const
|
|
4
|
+
const require_copy_machine = require("./copy-machine-oNmnrjMc.cjs");
|
|
6
5
|
const require_paste_reader = require("./paste-reader-BL51Jt1y.cjs");
|
|
7
6
|
//#region src/core/copy-coordinator.ts
|
|
8
7
|
function createCopyCoordinator() {
|
|
@@ -20,291 +19,6 @@ function createCopyCoordinator() {
|
|
|
20
19
|
};
|
|
21
20
|
}
|
|
22
21
|
//#endregion
|
|
23
|
-
//#region src/core/machine-shared.ts
|
|
24
|
-
/**
|
|
25
|
-
* Internals shared by the copy and paste state machines. Kept in one module so
|
|
26
|
-
* apps that use both don't ship two copies.
|
|
27
|
-
*/
|
|
28
|
-
const DEFAULT_MAX_RETRIES = 3;
|
|
29
|
-
function resolveMaxRetries(value) {
|
|
30
|
-
if (value === Infinity) return Infinity;
|
|
31
|
-
if (value === void 0 || !Number.isFinite(value)) return 3;
|
|
32
|
-
return Math.max(0, Math.floor(value));
|
|
33
|
-
}
|
|
34
|
-
function reportCallbackError(error) {
|
|
35
|
-
const scope = globalThis;
|
|
36
|
-
if (typeof scope.reportError === "function") scope.reportError(error);
|
|
37
|
-
else setTimeout(() => {
|
|
38
|
-
throw error;
|
|
39
|
-
}, 0);
|
|
40
|
-
}
|
|
41
|
-
/** User callbacks must never corrupt machine state; their errors are reported, not swallowed. */
|
|
42
|
-
function invoke(fn, ...args) {
|
|
43
|
-
if (!fn) return;
|
|
44
|
-
try {
|
|
45
|
-
fn(...args);
|
|
46
|
-
} catch (error) {
|
|
47
|
-
reportCallbackError(error);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/** One cancellable operation at a time. Signals only fire while their operation is unfinished. */
|
|
51
|
-
function createOperations() {
|
|
52
|
-
let controller;
|
|
53
|
-
const abort = () => {
|
|
54
|
-
if (!controller) return false;
|
|
55
|
-
controller.abort();
|
|
56
|
-
controller = void 0;
|
|
57
|
-
return true;
|
|
58
|
-
};
|
|
59
|
-
return {
|
|
60
|
-
start: () => {
|
|
61
|
-
abort();
|
|
62
|
-
controller = new AbortController();
|
|
63
|
-
return { signal: controller.signal };
|
|
64
|
-
},
|
|
65
|
-
end: (context) => {
|
|
66
|
-
if (controller?.signal === context.signal) controller = void 0;
|
|
67
|
-
},
|
|
68
|
-
abort
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/core/source-error.ts
|
|
73
|
-
/**
|
|
74
|
-
* The error for a user-supplied source (copy source, drag source, copy transform)
|
|
75
|
-
* that threw. A thrown `CopyFailure` keeps its classification, so a helper such as
|
|
76
|
-
* `tablePayload()` can report `too-large` instead of a generic `invalid-payload`.
|
|
77
|
-
* Internal: not part of the public API.
|
|
78
|
-
*/
|
|
79
|
-
function sourceError(cause, message) {
|
|
80
|
-
return require_errors.isCopyFailure(cause) ? cause.copyError : require_errors.createCopyError("invalid-payload", message, cause);
|
|
81
|
-
}
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/core/copy-machine.ts
|
|
84
|
-
const DEFAULT_RESET_AFTER_MS = 2e3;
|
|
85
|
-
const noop = () => void 0;
|
|
86
|
-
function isThenable(value) {
|
|
87
|
-
return typeof value === "object" && value !== null && typeof value.then === "function";
|
|
88
|
-
}
|
|
89
|
-
const IDLE_STATE = /* @__PURE__ */ Object.freeze({ status: "idle" });
|
|
90
|
-
const IGNORED_IN_FLIGHT$1 = /* @__PURE__ */ Object.freeze({
|
|
91
|
-
status: "ignored",
|
|
92
|
-
reason: "in-flight"
|
|
93
|
-
});
|
|
94
|
-
const IGNORED_NOTHING$1 = /* @__PURE__ */ Object.freeze({
|
|
95
|
-
status: "ignored",
|
|
96
|
-
reason: "nothing-to-retry"
|
|
97
|
-
});
|
|
98
|
-
const IGNORED_NOT_RETRYABLE$1 = /* @__PURE__ */ Object.freeze({
|
|
99
|
-
status: "ignored",
|
|
100
|
-
reason: "not-retryable"
|
|
101
|
-
});
|
|
102
|
-
const IGNORED_CANCELLED$1 = /* @__PURE__ */ Object.freeze({
|
|
103
|
-
status: "ignored",
|
|
104
|
-
reason: "cancelled"
|
|
105
|
-
});
|
|
106
|
-
function resolveResetDelay$1(value) {
|
|
107
|
-
if (value === false || value === Infinity) return null;
|
|
108
|
-
if (value === void 0 || Number.isNaN(value)) return DEFAULT_RESET_AFTER_MS;
|
|
109
|
-
return Math.max(0, value);
|
|
110
|
-
}
|
|
111
|
-
/** Pure helper: can `retry()` do anything from this state? */
|
|
112
|
-
function canRetryState(state, maxRetries) {
|
|
113
|
-
return state.status === "error" && state.payload !== null && require_errors.isRetryableError(state.error) && state.retryCount < resolveMaxRetries(maxRetries);
|
|
114
|
-
}
|
|
115
|
-
let defaultAdapter$1;
|
|
116
|
-
const getDefaultAdapter$1 = () => defaultAdapter$1 ?? (defaultAdapter$1 = require_clipboard_adapter.createBrowserClipboardAdapter());
|
|
117
|
-
/** Framework-agnostic copy state machine. */
|
|
118
|
-
function createCopyMachine(options = {}) {
|
|
119
|
-
const read = typeof options === "function" ? options : () => options;
|
|
120
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
121
|
-
let state = IDLE_STATE;
|
|
122
|
-
let generation = 0;
|
|
123
|
-
let resetTimer;
|
|
124
|
-
const operations = createOperations();
|
|
125
|
-
const now = () => (read().now ?? Date.now)();
|
|
126
|
-
let joined = null;
|
|
127
|
-
const member = { release: () => {
|
|
128
|
-
if (state.status === "copied") {
|
|
129
|
-
clearResetTimer();
|
|
130
|
-
setState(IDLE_STATE);
|
|
131
|
-
}
|
|
132
|
-
} };
|
|
133
|
-
const setState = (next) => {
|
|
134
|
-
if (next === state) return;
|
|
135
|
-
const previous = state;
|
|
136
|
-
state = next;
|
|
137
|
-
if (previous.status === "copied" && next.status !== "copied" && joined) {
|
|
138
|
-
joined.deactivate(member);
|
|
139
|
-
joined = null;
|
|
140
|
-
}
|
|
141
|
-
for (const listener of Array.from(listeners)) listener();
|
|
142
|
-
};
|
|
143
|
-
const joinCoordinator = () => {
|
|
144
|
-
joined = read().coordinator ?? null;
|
|
145
|
-
joined?.activate(member);
|
|
146
|
-
};
|
|
147
|
-
const clearResetTimer = () => {
|
|
148
|
-
if (resetTimer !== void 0) {
|
|
149
|
-
clearTimeout(resetTimer);
|
|
150
|
-
resetTimer = void 0;
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
const scheduleReset = (copied) => {
|
|
154
|
-
clearResetTimer();
|
|
155
|
-
const delay = resolveResetDelay$1(read().resetAfterMs);
|
|
156
|
-
if (delay === null) return;
|
|
157
|
-
const remaining = Math.max(0, delay - (now() - copied.at));
|
|
158
|
-
resetTimer = setTimeout(() => {
|
|
159
|
-
resetTimer = void 0;
|
|
160
|
-
setState(IDLE_STATE);
|
|
161
|
-
}, remaining);
|
|
162
|
-
};
|
|
163
|
-
const settleError = (error, payload, retryCount) => {
|
|
164
|
-
setState({
|
|
165
|
-
status: "error",
|
|
166
|
-
payload,
|
|
167
|
-
error,
|
|
168
|
-
retryCount
|
|
169
|
-
});
|
|
170
|
-
invoke(read().onError, error, payload);
|
|
171
|
-
};
|
|
172
|
-
const run = (source, retryCount) => {
|
|
173
|
-
clearResetTimer();
|
|
174
|
-
const current = ++generation;
|
|
175
|
-
const context = operations.start();
|
|
176
|
-
const fail = (error, payload) => {
|
|
177
|
-
operations.end(context);
|
|
178
|
-
settleError(error, payload, retryCount);
|
|
179
|
-
return Promise.resolve({
|
|
180
|
-
status: "error",
|
|
181
|
-
error
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
|
-
let resolved;
|
|
185
|
-
try {
|
|
186
|
-
resolved = typeof source === "function" ? source(context) : source;
|
|
187
|
-
} catch (cause) {
|
|
188
|
-
return fail(sourceError(cause, "The copy source function threw."), null);
|
|
189
|
-
}
|
|
190
|
-
const adapter = read().adapter ?? getDefaultAdapter$1();
|
|
191
|
-
let payload = null;
|
|
192
|
-
let pending;
|
|
193
|
-
if (isThenable(resolved)) {
|
|
194
|
-
const arrived = Promise.resolve(resolved).then((input) => {
|
|
195
|
-
if (context.signal.aborted) throw require_errors.copyFailure("aborted", "Copying was cancelled.");
|
|
196
|
-
const made = require_payload.normalizePayload(input);
|
|
197
|
-
if (made.kind !== "text" && made.kind !== "json") throw require_errors.copyFailure("invalid-payload", "An async copy source must resolve to text or JSON.");
|
|
198
|
-
const invalid = require_payload.validatePayload(made);
|
|
199
|
-
if (invalid) throw new require_errors.CopyFailure(invalid);
|
|
200
|
-
payload = made;
|
|
201
|
-
return made.kind === "text" ? made.value : require_payload.serializeJson(made);
|
|
202
|
-
}, (cause) => {
|
|
203
|
-
throw new require_errors.CopyFailure(sourceError(cause, "The copy source rejected."));
|
|
204
|
-
});
|
|
205
|
-
setState({
|
|
206
|
-
status: "copying",
|
|
207
|
-
payload: null,
|
|
208
|
-
retryCount
|
|
209
|
-
});
|
|
210
|
-
try {
|
|
211
|
-
pending = (adapter.writeDeferred ? adapter.writeDeferred(arrived, context) : arrived.then(() => adapter.write(payload, context))).then(() => arrived).then(noop);
|
|
212
|
-
} catch (cause) {
|
|
213
|
-
arrived.catch(noop);
|
|
214
|
-
pending = Promise.reject(cause);
|
|
215
|
-
}
|
|
216
|
-
} else {
|
|
217
|
-
payload = require_payload.normalizePayload(resolved);
|
|
218
|
-
const invalid = require_payload.validatePayload(payload);
|
|
219
|
-
if (invalid) return fail(invalid, payload);
|
|
220
|
-
setState({
|
|
221
|
-
status: "copying",
|
|
222
|
-
payload,
|
|
223
|
-
retryCount
|
|
224
|
-
});
|
|
225
|
-
try {
|
|
226
|
-
pending = adapter.write(payload, context);
|
|
227
|
-
} catch (cause) {
|
|
228
|
-
pending = Promise.reject(cause);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return pending.then(() => {
|
|
232
|
-
operations.end(context);
|
|
233
|
-
const done = payload;
|
|
234
|
-
if (current === generation) {
|
|
235
|
-
const copied = {
|
|
236
|
-
status: "copied",
|
|
237
|
-
payload: done,
|
|
238
|
-
at: now()
|
|
239
|
-
};
|
|
240
|
-
setState(copied);
|
|
241
|
-
joinCoordinator();
|
|
242
|
-
scheduleReset(copied);
|
|
243
|
-
invoke(read().onCopy, done);
|
|
244
|
-
}
|
|
245
|
-
return {
|
|
246
|
-
status: "copied",
|
|
247
|
-
payload: done
|
|
248
|
-
};
|
|
249
|
-
}, (cause) => {
|
|
250
|
-
operations.end(context);
|
|
251
|
-
if (context.signal.aborted) return IGNORED_CANCELLED$1;
|
|
252
|
-
const error = require_errors.toCopyError(cause);
|
|
253
|
-
settleError(error, payload, retryCount);
|
|
254
|
-
return {
|
|
255
|
-
status: "error",
|
|
256
|
-
error
|
|
257
|
-
};
|
|
258
|
-
});
|
|
259
|
-
};
|
|
260
|
-
const copy = (source) => state.status === "copying" ? Promise.resolve(IGNORED_IN_FLIGHT$1) : run(source, 0);
|
|
261
|
-
const retry = () => {
|
|
262
|
-
if (state.status !== "error") return Promise.resolve(IGNORED_NOTHING$1);
|
|
263
|
-
if (state.payload === null || !require_errors.isRetryableError(state.error)) return Promise.resolve(IGNORED_NOT_RETRYABLE$1);
|
|
264
|
-
if (state.retryCount >= resolveMaxRetries(read().maxRetries)) {
|
|
265
|
-
const error = require_errors.createCopyError("max-retries-exceeded", `Copy failed after ${String(state.retryCount)} retries.`, state.error);
|
|
266
|
-
settleError(error, state.payload, state.retryCount);
|
|
267
|
-
return Promise.resolve({
|
|
268
|
-
status: "error",
|
|
269
|
-
error
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
return run(state.payload, state.retryCount + 1);
|
|
273
|
-
};
|
|
274
|
-
const reset = () => {
|
|
275
|
-
++generation;
|
|
276
|
-
const cancelled = operations.abort();
|
|
277
|
-
clearResetTimer();
|
|
278
|
-
const wasIdle = state.status === "idle";
|
|
279
|
-
setState(IDLE_STATE);
|
|
280
|
-
if (cancelled) invoke(read().onCancel, "reset");
|
|
281
|
-
if (!wasIdle) invoke(read().onReset);
|
|
282
|
-
};
|
|
283
|
-
const connect = () => {
|
|
284
|
-
if (state.status === "copied") scheduleReset(state);
|
|
285
|
-
return () => {
|
|
286
|
-
++generation;
|
|
287
|
-
const cancelled = operations.abort();
|
|
288
|
-
clearResetTimer();
|
|
289
|
-
if (state.status === "copying") setState(IDLE_STATE);
|
|
290
|
-
if (cancelled) invoke(read().onCancel, "disconnect");
|
|
291
|
-
};
|
|
292
|
-
};
|
|
293
|
-
return {
|
|
294
|
-
getSnapshot: () => state,
|
|
295
|
-
subscribe: (listener) => {
|
|
296
|
-
listeners.add(listener);
|
|
297
|
-
return () => {
|
|
298
|
-
listeners.delete(listener);
|
|
299
|
-
};
|
|
300
|
-
},
|
|
301
|
-
copy,
|
|
302
|
-
retry,
|
|
303
|
-
reset,
|
|
304
|
-
connect
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
//#endregion
|
|
308
22
|
//#region src/core/copy-interceptor.ts
|
|
309
23
|
const DEFAULT_INTERCEPTED_EVENTS = ["copy", "cut"];
|
|
310
24
|
function isNode(value) {
|
|
@@ -535,7 +249,7 @@ function interceptCopyEvent(event, options) {
|
|
|
535
249
|
try {
|
|
536
250
|
decision = options.transform(selection);
|
|
537
251
|
} catch (cause) {
|
|
538
|
-
return fail(sourceError(cause, "The copy transform threw."));
|
|
252
|
+
return fail(require_copy_machine.sourceError(cause, "The copy transform threw."));
|
|
539
253
|
}
|
|
540
254
|
if (decision === null || decision === void 0) return {
|
|
541
255
|
status: "passed",
|
|
@@ -626,8 +340,8 @@ function dispatch(registry, event) {
|
|
|
626
340
|
if (!scope) return;
|
|
627
341
|
const options = scope.read();
|
|
628
342
|
const outcome = interceptCopyEvent(event, options);
|
|
629
|
-
invoke(options.onIntercept, outcome);
|
|
630
|
-
if (outcome.status === "failed") invoke(options.onError, outcome.error);
|
|
343
|
+
require_copy_machine.invoke(options.onIntercept, outcome);
|
|
344
|
+
if (outcome.status === "failed") require_copy_machine.invoke(options.onError, outcome.error);
|
|
631
345
|
}
|
|
632
346
|
/**
|
|
633
347
|
* Intercepts native copies and cuts whose selection touches `root`. Returns
|
|
@@ -765,7 +479,7 @@ function applyDragCopy(event, options) {
|
|
|
765
479
|
} catch (cause) {
|
|
766
480
|
return {
|
|
767
481
|
status: "failed",
|
|
768
|
-
error: sourceError(cause, "The drag source threw.")
|
|
482
|
+
error: require_copy_machine.sourceError(cause, "The drag source threw.")
|
|
769
483
|
};
|
|
770
484
|
}
|
|
771
485
|
if (decision === null || decision === void 0) return {
|
|
@@ -842,8 +556,8 @@ function registerDragCopy(element, options) {
|
|
|
842
556
|
status: "dragging",
|
|
843
557
|
outcome
|
|
844
558
|
};
|
|
845
|
-
if (outcome.status === "failed") invoke(opts.onError, outcome.error);
|
|
846
|
-
invoke(opts.onDrag, state);
|
|
559
|
+
if (outcome.status === "failed") require_copy_machine.invoke(opts.onError, outcome.error);
|
|
560
|
+
require_copy_machine.invoke(opts.onDrag, state);
|
|
847
561
|
}
|
|
848
562
|
function onDragEnd() {
|
|
849
563
|
const opts = read();
|
|
@@ -851,7 +565,7 @@ function registerDragCopy(element, options) {
|
|
|
851
565
|
status: "done",
|
|
852
566
|
outcome: currentOutcome
|
|
853
567
|
};
|
|
854
|
-
invoke(opts.onDrag, state);
|
|
568
|
+
require_copy_machine.invoke(opts.onDrag, state);
|
|
855
569
|
currentOutcome = null;
|
|
856
570
|
}
|
|
857
571
|
element.setAttribute("draggable", "true");
|
|
@@ -916,7 +630,7 @@ function watchClipboardPermission(name, onChange) {
|
|
|
916
630
|
const state = toState(status?.state);
|
|
917
631
|
if (!active || state === last) return;
|
|
918
632
|
last = state;
|
|
919
|
-
invoke(onChange, state);
|
|
633
|
+
require_copy_machine.invoke(onChange, state);
|
|
920
634
|
};
|
|
921
635
|
queryStatus(name).then((found) => {
|
|
922
636
|
if (!active) return;
|
|
@@ -1013,7 +727,7 @@ function resolveResetDelay(value) {
|
|
|
1013
727
|
}
|
|
1014
728
|
/** Pure helper: can `retry()` do anything from this state? */
|
|
1015
729
|
function canRetryPasteState(state, maxRetries) {
|
|
1016
|
-
return state.status === "error" && state.source === "clipboard" && require_errors.isRetryableError(state.error) && state.retryCount < resolveMaxRetries(maxRetries);
|
|
730
|
+
return state.status === "error" && state.source === "clipboard" && require_errors.isRetryableError(state.error) && state.retryCount < require_copy_machine.resolveMaxRetries(maxRetries);
|
|
1017
731
|
}
|
|
1018
732
|
let defaultAdapter;
|
|
1019
733
|
const getDefaultAdapter = () => defaultAdapter ?? (defaultAdapter = createBrowserPasteAdapter());
|
|
@@ -1024,7 +738,7 @@ function createPasteMachine(options = {}) {
|
|
|
1024
738
|
let state = PASTE_IDLE_STATE;
|
|
1025
739
|
let generation = 0;
|
|
1026
740
|
let resetTimer;
|
|
1027
|
-
const operations = createOperations();
|
|
741
|
+
const operations = require_copy_machine.createOperations();
|
|
1028
742
|
const now = () => (read().now ?? Date.now)();
|
|
1029
743
|
const setState = (next) => {
|
|
1030
744
|
if (next === state) return;
|
|
@@ -1054,7 +768,7 @@ function createPasteMachine(options = {}) {
|
|
|
1054
768
|
source,
|
|
1055
769
|
retryCount
|
|
1056
770
|
});
|
|
1057
|
-
invoke(read().onError, error);
|
|
771
|
+
require_copy_machine.invoke(read().onError, error);
|
|
1058
772
|
};
|
|
1059
773
|
/** Runs one read. `produce` is invoked synchronously so the user gesture is preserved. */
|
|
1060
774
|
const run = (produce, source, retryCount) => {
|
|
@@ -1063,7 +777,7 @@ function createPasteMachine(options = {}) {
|
|
|
1063
777
|
const superseded = operations.abort();
|
|
1064
778
|
const context = operations.start();
|
|
1065
779
|
setState(PASTE_READING_STATE);
|
|
1066
|
-
if (superseded) invoke(read().onCancel, "superseded");
|
|
780
|
+
if (superseded) require_copy_machine.invoke(read().onCancel, "superseded");
|
|
1067
781
|
let pending;
|
|
1068
782
|
try {
|
|
1069
783
|
pending = produce(context);
|
|
@@ -1080,7 +794,7 @@ function createPasteMachine(options = {}) {
|
|
|
1080
794
|
};
|
|
1081
795
|
setState(readState);
|
|
1082
796
|
scheduleReset(readState);
|
|
1083
|
-
invoke(read().onPaste, result);
|
|
797
|
+
require_copy_machine.invoke(read().onPaste, result);
|
|
1084
798
|
}
|
|
1085
799
|
return {
|
|
1086
800
|
status: "read",
|
|
@@ -1102,7 +816,7 @@ function createPasteMachine(options = {}) {
|
|
|
1102
816
|
const retry = () => {
|
|
1103
817
|
if (state.status !== "error") return Promise.resolve(IGNORED_NOTHING);
|
|
1104
818
|
if (state.source !== "clipboard" || !require_errors.isRetryableError(state.error)) return Promise.resolve(IGNORED_NOT_RETRYABLE);
|
|
1105
|
-
if (state.retryCount >= resolveMaxRetries(read().maxRetries)) {
|
|
819
|
+
if (state.retryCount >= require_copy_machine.resolveMaxRetries(read().maxRetries)) {
|
|
1106
820
|
const error = require_errors.createCopyError("max-retries-exceeded", `Paste failed after ${String(state.retryCount)} retries.`, state.error);
|
|
1107
821
|
settleError(error, "clipboard", state.retryCount);
|
|
1108
822
|
return Promise.resolve({
|
|
@@ -1126,7 +840,7 @@ function createPasteMachine(options = {}) {
|
|
|
1126
840
|
const superseded = operations.abort();
|
|
1127
841
|
clearResetTimer();
|
|
1128
842
|
settleError(error, source, 0);
|
|
1129
|
-
if (superseded) invoke(current.onCancel, "superseded");
|
|
843
|
+
if (superseded) require_copy_machine.invoke(current.onCancel, "superseded");
|
|
1130
844
|
return Promise.resolve({
|
|
1131
845
|
status: "error",
|
|
1132
846
|
error
|
|
@@ -1148,8 +862,8 @@ function createPasteMachine(options = {}) {
|
|
|
1148
862
|
clearResetTimer();
|
|
1149
863
|
const wasIdle = state.status === "idle";
|
|
1150
864
|
setState(PASTE_IDLE_STATE);
|
|
1151
|
-
if (cancelled) invoke(read().onCancel, "reset");
|
|
1152
|
-
if (!wasIdle) invoke(read().onReset);
|
|
865
|
+
if (cancelled) require_copy_machine.invoke(read().onCancel, "reset");
|
|
866
|
+
if (!wasIdle) require_copy_machine.invoke(read().onReset);
|
|
1153
867
|
};
|
|
1154
868
|
const connect = () => {
|
|
1155
869
|
if (state.status === "read") scheduleReset(state);
|
|
@@ -1158,7 +872,7 @@ function createPasteMachine(options = {}) {
|
|
|
1158
872
|
const cancelled = operations.abort();
|
|
1159
873
|
clearResetTimer();
|
|
1160
874
|
if (state.status === "reading") setState(PASTE_IDLE_STATE);
|
|
1161
|
-
if (cancelled) invoke(read().onCancel, "disconnect");
|
|
875
|
+
if (cancelled) require_copy_machine.invoke(read().onCancel, "disconnect");
|
|
1162
876
|
};
|
|
1163
877
|
};
|
|
1164
878
|
return {
|
|
@@ -1184,24 +898,6 @@ Object.defineProperty(exports, "DEFAULT_INTERCEPTED_EVENTS", {
|
|
|
1184
898
|
return DEFAULT_INTERCEPTED_EVENTS;
|
|
1185
899
|
}
|
|
1186
900
|
});
|
|
1187
|
-
Object.defineProperty(exports, "DEFAULT_MAX_RETRIES", {
|
|
1188
|
-
enumerable: true,
|
|
1189
|
-
get: function() {
|
|
1190
|
-
return DEFAULT_MAX_RETRIES;
|
|
1191
|
-
}
|
|
1192
|
-
});
|
|
1193
|
-
Object.defineProperty(exports, "DEFAULT_RESET_AFTER_MS", {
|
|
1194
|
-
enumerable: true,
|
|
1195
|
-
get: function() {
|
|
1196
|
-
return DEFAULT_RESET_AFTER_MS;
|
|
1197
|
-
}
|
|
1198
|
-
});
|
|
1199
|
-
Object.defineProperty(exports, "IDLE_STATE", {
|
|
1200
|
-
enumerable: true,
|
|
1201
|
-
get: function() {
|
|
1202
|
-
return IDLE_STATE;
|
|
1203
|
-
}
|
|
1204
|
-
});
|
|
1205
901
|
Object.defineProperty(exports, "PASTE_IDLE_STATE", {
|
|
1206
902
|
enumerable: true,
|
|
1207
903
|
get: function() {
|
|
@@ -1220,12 +916,6 @@ Object.defineProperty(exports, "canRetryPasteState", {
|
|
|
1220
916
|
return canRetryPasteState;
|
|
1221
917
|
}
|
|
1222
918
|
});
|
|
1223
|
-
Object.defineProperty(exports, "canRetryState", {
|
|
1224
|
-
enumerable: true,
|
|
1225
|
-
get: function() {
|
|
1226
|
-
return canRetryState;
|
|
1227
|
-
}
|
|
1228
|
-
});
|
|
1229
919
|
Object.defineProperty(exports, "createBrowserPasteAdapter", {
|
|
1230
920
|
enumerable: true,
|
|
1231
921
|
get: function() {
|
|
@@ -1238,12 +928,6 @@ Object.defineProperty(exports, "createCopyCoordinator", {
|
|
|
1238
928
|
return createCopyCoordinator;
|
|
1239
929
|
}
|
|
1240
930
|
});
|
|
1241
|
-
Object.defineProperty(exports, "createCopyMachine", {
|
|
1242
|
-
enumerable: true,
|
|
1243
|
-
get: function() {
|
|
1244
|
-
return createCopyMachine;
|
|
1245
|
-
}
|
|
1246
|
-
});
|
|
1247
931
|
Object.defineProperty(exports, "createPasteMachine", {
|
|
1248
932
|
enumerable: true,
|
|
1249
933
|
get: function() {
|
|
@@ -1256,12 +940,6 @@ Object.defineProperty(exports, "interceptCopyEvent", {
|
|
|
1256
940
|
return interceptCopyEvent;
|
|
1257
941
|
}
|
|
1258
942
|
});
|
|
1259
|
-
Object.defineProperty(exports, "invoke", {
|
|
1260
|
-
enumerable: true,
|
|
1261
|
-
get: function() {
|
|
1262
|
-
return invoke;
|
|
1263
|
-
}
|
|
1264
|
-
});
|
|
1265
943
|
Object.defineProperty(exports, "readClipboardPermission", {
|
|
1266
944
|
enumerable: true,
|
|
1267
945
|
get: function() {
|
|
@@ -1286,12 +964,6 @@ Object.defineProperty(exports, "registerDragCopy", {
|
|
|
1286
964
|
return registerDragCopy;
|
|
1287
965
|
}
|
|
1288
966
|
});
|
|
1289
|
-
Object.defineProperty(exports, "resolveMaxRetries", {
|
|
1290
|
-
enumerable: true,
|
|
1291
|
-
get: function() {
|
|
1292
|
-
return resolveMaxRetries;
|
|
1293
|
-
}
|
|
1294
|
-
});
|
|
1295
967
|
Object.defineProperty(exports, "watchClipboardPermission", {
|
|
1296
968
|
enumerable: true,
|
|
1297
969
|
get: function() {
|
|
@@ -1299,4 +971,4 @@ Object.defineProperty(exports, "watchClipboardPermission", {
|
|
|
1299
971
|
}
|
|
1300
972
|
});
|
|
1301
973
|
|
|
1302
|
-
//# sourceMappingURL=core-
|
|
974
|
+
//# sourceMappingURL=core-DsMKPNx_.cjs.map
|