@pisell/utils 1.0.36 → 1.0.37

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/es/document.js CHANGED
@@ -41,17 +41,29 @@ export var copyToClipboard = /*#__PURE__*/function () {
41
41
  while (1) switch (_context.prev = _context.next) {
42
42
  case 0:
43
43
  if (!navigator.clipboard) {
44
- _context.next = 4;
44
+ _context.next = 13;
45
45
  break;
46
46
  }
47
- return _context.abrupt("return", navigator.clipboard.writeText(text));
47
+ _context.prev = 1;
48
+ _context.next = 4;
49
+ return navigator.clipboard.writeText(text);
48
50
  case 4:
51
+ return _context.abrupt("return", _context.sent);
52
+ case 7:
53
+ _context.prev = 7;
54
+ _context.t0 = _context["catch"](1);
55
+ console.error(_context.t0);
49
56
  return _context.abrupt("return", httpCopyToClipboard(text));
50
- case 5:
57
+ case 11:
58
+ _context.next = 14;
59
+ break;
60
+ case 13:
61
+ return _context.abrupt("return", httpCopyToClipboard(text));
62
+ case 14:
51
63
  case "end":
52
64
  return _context.stop();
53
65
  }
54
- }, _callee);
66
+ }, _callee, null, [[1, 7]]);
55
67
  }));
56
68
  return function copyToClipboard(_x) {
57
69
  return _ref.apply(this, arguments);
package/lib/document.js CHANGED
@@ -47,7 +47,12 @@ var httpCopyToClipboard = (text) => {
47
47
  };
48
48
  var copyToClipboard = async (text) => {
49
49
  if (navigator.clipboard) {
50
- return navigator.clipboard.writeText(text);
50
+ try {
51
+ return await navigator.clipboard.writeText(text);
52
+ } catch (error) {
53
+ console.error(error);
54
+ return httpCopyToClipboard(text);
55
+ }
51
56
  } else {
52
57
  return httpCopyToClipboard(text);
53
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/utils",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "sideEffects": false,
5
5
  "main": "./lib/index.js",
6
6
  "module": "./es/index.js",