@ew-color-picker/eyedropper 2.0.4 → 2.0.6

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.
@@ -100,7 +100,7 @@ var ewColorPickerEyedropperPlugin = /** @class */ (function () {
100
100
  case 3:
101
101
  error_1 = _a.sent();
102
102
  // 用户按 Esc 取消取色时 EyeDropper 会抛出 AbortError,属于正常流程
103
- if (error_1 && error_1.name === "AbortError")
103
+ if (error_1 instanceof Error && error_1.name === "AbortError")
104
104
  return [2 /*return*/];
105
105
  warn("[ewColorPicker warning]: Failed to pick color with EyeDropper", error_1);
106
106
  return [3 /*break*/, 4];
@@ -1 +1 @@
1
- ((t,e)=>{"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@ew-color-picker/utils")):"function"==typeof define&&define.amd?define(["@ew-color-picker/utils"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).Eyedropper=e(t.Utils)})(this,function(n){function o(t,s,c,p){return new(c=c||Promise)(function(o,e){function n(t){try{i(p.next(t))}catch(t){e(t)}}function r(t){try{i(p.throw(t))}catch(t){e(t)}}function i(t){var e;t.done?o(t.value):((e=t.value)instanceof c?e:new c(function(t){t(e)})).then(n,r)}i((p=p.apply(t,s||[])).next())})}function r(n,r){var i,s,c,p={label:0,sent:function(){if(1&c[0])throw c[1];return c[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return l.next=t(0),l.throw=t(1),l.return=t(2),"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function t(o){return function(t){var e=[o,t];if(i)throw new TypeError("Generator is already executing.");for(;p=l&&e[l=0]?0:p;)try{if(i=1,s&&(c=2&e[0]?s.return:e[0]?s.throw||((c=s.return)&&c.call(s),0):s.next)&&!(c=c.call(s,e[1])).done)return c;switch(s=0,(e=c?[2&e[0],c.value]:e)[0]){case 0:case 1:c=e;break;case 4:return p.label++,{value:e[1],done:!1};case 5:p.label++,s=e[1],e=[0];continue;case 7:e=p.ops.pop(),p.trys.pop();continue;default:if(!(c=0<(c=p.trys).length&&c[c.length-1])&&(6===e[0]||2===e[0])){p=0;continue}if(3===e[0]&&(!c||e[1]>c[0]&&e[1]<c[3]))p.label=e[1];else if(6===e[0]&&p.label<c[1])p.label=c[1],c=e;else{if(!(c&&p.label<c[2])){c[2]&&p.ops.pop(),p.trys.pop();continue}p.label=c[2],p.ops.push(e)}}e=r.call(n,p)}catch(t){e=[6,t],s=0}finally{i=c=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}}function t(t){var e=this;this.ewColorPicker=t,this.options={},this.container=null,this.button=null,this.destroyed=!1,this.handleClick=function(){return o(e,void 0,void 0,function(){var e,o;return r(this,function(t){switch(t.label){case 0:if(this.destroyed)return[2];if(!(e=window.EyeDropper))return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,(new e).open()];case 2:return(o=t.sent(),!this.destroyed&&o&&o.sRGBHex)?(this.ewColorPicker.setColor(o.sRGBHex),n.isFunction(this.options.onEyedropperPick)&&this.options.onEyedropperPick(o.sRGBHex),[3,4]):[2];case 3:return(o=t.sent())&&"AbortError"===o.name?[2]:(n.warn("[ewColorPicker warning]: Failed to pick color with EyeDropper",o),[3,4]);case 4:return[2]}})})},this.ewColorPicker=t,this.handleOptions(),this.run()}return Object.defineProperty(t.prototype,"prefix",{get:function(){return n.getPrefix(this.ewColorPicker)},enumerable:!1,configurable:!0}),t.prototype.isSupported=function(){return"undefined"!=typeof window&&"EyeDropper"in window},t.prototype.handleOptions=function(){this.options=n.extend({},this.options,this.ewColorPicker.options)},t.prototype.updateOptions=function(){this.handleOptions(),this.run()},t.prototype.run=function(){!1!==this.options.showEyedropper&&this.isSupported()?(this.removeContainer(),this.render(),this.bindEvents()):this.removeContainer()},t.prototype.render=function(){var t,e=this.ewColorPicker.getMountPoint("panelContainer");e?(e=this.getExtraRow(e),this.container=n.create("div"),n.addClass(this.container,"".concat(this.prefix,"color-picker-eyedropper-group")),this.button=n.create("button"),n.addClass(this.button,"".concat(this.prefix,"color-picker-eyedropper-btn")),n.setAttr(this.button,{type:"button",title:this.options.eyedropperText||"取色","aria-label":this.options.eyedropperText||"取色"}),this.button.innerHTML=n.eyedropperIcon(void 0,16,this.prefix),this.options.eyedropperText&&(t=n.create("span"),n.addClass(t,"".concat(this.prefix,"color-picker-eyedropper-text")),t.textContent=this.options.eyedropperText,n.insertNode(this.button,t)),n.insertNode(this.container,this.button),n.insertNode(e,this.container)):n.warn("[ewColorPicker warning]: Panel container not found")},t.prototype.getExtraRow=function(t){var e,o=n.$(".".concat(this.prefix,"color-picker-extra-row"),t);return o||(o=n.create("div"),n.addClass(o,"".concat(this.prefix,"color-picker-extra-row")),(e=n.$(".".concat(this.prefix,"color-picker-bottom-row"),t))?n.insertNode(t,o,null,e):n.insertNode(t,o),o)},t.prototype.bindEvents=function(){this.button&&n.on(this.button,"click",this.handleClick)},t.prototype.removeContainer=function(){this.button&&n.off(this.button,"click",this.handleClick),this.container&&n.removeElement(this.container),this.button=null;var t,e=(this.container=null)==(e=null==(t=this.ewColorPicker)?void 0:t.getMountPoint)?void 0:e.call(t,"panelContainer");e&&(t=n.$(".".concat(this.prefix,"color-picker-extra-row"),e))&&0===t.children.length&&n.removeElement(t)},t.prototype.destroy=function(){this.destroyed=!0,this.removeContainer()},t.prototype.install=function(t){this.ewColorPicker=t,this.destroyed=!1,this.handleOptions(),null!=(t=this.run)&&t.call(this)},t.pluginName="ewColorPickerEyedropper",t.applyOrder=n.ApplyOrder.Post,t});
1
+ ((t,e)=>{"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@ew-color-picker/utils")):"function"==typeof define&&define.amd?define(["@ew-color-picker/utils"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).Eyedropper=e(t.Utils)})(this,function(n){function o(t,s,c,p){return new(c=c||Promise)(function(o,e){function n(t){try{i(p.next(t))}catch(t){e(t)}}function r(t){try{i(p.throw(t))}catch(t){e(t)}}function i(t){var e;t.done?o(t.value):((e=t.value)instanceof c?e:new c(function(t){t(e)})).then(n,r)}i((p=p.apply(t,s||[])).next())})}function r(n,r){var i,s,c,p={label:0,sent:function(){if(1&c[0])throw c[1];return c[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return l.next=t(0),l.throw=t(1),l.return=t(2),"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function t(o){return function(t){var e=[o,t];if(i)throw new TypeError("Generator is already executing.");for(;p=l&&e[l=0]?0:p;)try{if(i=1,s&&(c=2&e[0]?s.return:e[0]?s.throw||((c=s.return)&&c.call(s),0):s.next)&&!(c=c.call(s,e[1])).done)return c;switch(s=0,(e=c?[2&e[0],c.value]:e)[0]){case 0:case 1:c=e;break;case 4:return p.label++,{value:e[1],done:!1};case 5:p.label++,s=e[1],e=[0];continue;case 7:e=p.ops.pop(),p.trys.pop();continue;default:if(!(c=0<(c=p.trys).length&&c[c.length-1])&&(6===e[0]||2===e[0])){p=0;continue}if(3===e[0]&&(!c||e[1]>c[0]&&e[1]<c[3]))p.label=e[1];else if(6===e[0]&&p.label<c[1])p.label=c[1],c=e;else{if(!(c&&p.label<c[2])){c[2]&&p.ops.pop(),p.trys.pop();continue}p.label=c[2],p.ops.push(e)}}e=r.call(n,p)}catch(t){e=[6,t],s=0}finally{i=c=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}}function t(t){var e=this;this.ewColorPicker=t,this.options={},this.container=null,this.button=null,this.destroyed=!1,this.handleClick=function(){return o(e,void 0,void 0,function(){var e,o;return r(this,function(t){switch(t.label){case 0:if(this.destroyed)return[2];if(!(e=window.EyeDropper))return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,(new e).open()];case 2:return(o=t.sent(),!this.destroyed&&o&&o.sRGBHex)?(this.ewColorPicker.setColor(o.sRGBHex),n.isFunction(this.options.onEyedropperPick)&&this.options.onEyedropperPick(o.sRGBHex),[3,4]):[2];case 3:return(o=t.sent())instanceof Error&&"AbortError"===o.name?[2]:(n.warn("[ewColorPicker warning]: Failed to pick color with EyeDropper",o),[3,4]);case 4:return[2]}})})},this.ewColorPicker=t,this.handleOptions(),this.run()}return Object.defineProperty(t.prototype,"prefix",{get:function(){return n.getPrefix(this.ewColorPicker)},enumerable:!1,configurable:!0}),t.prototype.isSupported=function(){return"undefined"!=typeof window&&"EyeDropper"in window},t.prototype.handleOptions=function(){this.options=n.extend({},this.options,this.ewColorPicker.options)},t.prototype.updateOptions=function(){this.handleOptions(),this.run()},t.prototype.run=function(){!1!==this.options.showEyedropper&&this.isSupported()?(this.removeContainer(),this.render(),this.bindEvents()):this.removeContainer()},t.prototype.render=function(){var t,e=this.ewColorPicker.getMountPoint("panelContainer");e?(e=this.getExtraRow(e),this.container=n.create("div"),n.addClass(this.container,"".concat(this.prefix,"color-picker-eyedropper-group")),this.button=n.create("button"),n.addClass(this.button,"".concat(this.prefix,"color-picker-eyedropper-btn")),n.setAttr(this.button,{type:"button",title:this.options.eyedropperText||"取色","aria-label":this.options.eyedropperText||"取色"}),this.button.innerHTML=n.eyedropperIcon(void 0,16,this.prefix),this.options.eyedropperText&&(t=n.create("span"),n.addClass(t,"".concat(this.prefix,"color-picker-eyedropper-text")),t.textContent=this.options.eyedropperText,n.insertNode(this.button,t)),n.insertNode(this.container,this.button),n.insertNode(e,this.container)):n.warn("[ewColorPicker warning]: Panel container not found")},t.prototype.getExtraRow=function(t){var e,o=n.$(".".concat(this.prefix,"color-picker-extra-row"),t);return o||(o=n.create("div"),n.addClass(o,"".concat(this.prefix,"color-picker-extra-row")),(e=n.$(".".concat(this.prefix,"color-picker-bottom-row"),t))?n.insertNode(t,o,null,e):n.insertNode(t,o),o)},t.prototype.bindEvents=function(){this.button&&n.on(this.button,"click",this.handleClick)},t.prototype.removeContainer=function(){this.button&&n.off(this.button,"click",this.handleClick),this.container&&n.removeElement(this.container),this.button=null;var t,e=(this.container=null)==(e=null==(t=this.ewColorPicker)?void 0:t.getMountPoint)?void 0:e.call(t,"panelContainer");e&&(t=n.$(".".concat(this.prefix,"color-picker-extra-row"),e))&&0===t.children.length&&n.removeElement(t)},t.prototype.destroy=function(){this.destroyed=!0,this.removeContainer()},t.prototype.install=function(t){this.ewColorPicker=t,this.destroyed=!1,this.handleOptions(),null!=(t=this.run)&&t.call(this)},t.pluginName="ewColorPickerEyedropper",t.applyOrder=n.ApplyOrder.Post,t});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ew-color-picker/eyedropper",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "EW Color Picker Eyedropper Plugin",
5
5
  "main": "dist/eyedropper.min.js",
6
6
  "module": "dist/eyedropper.esm.js",
@@ -27,16 +27,16 @@
27
27
  "author": "eveningwater(854806732@qq.com)",
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
- "@ew-color-picker/core": "^2.0.4",
31
- "@ew-color-picker/utils": "^2.0.4"
30
+ "@ew-color-picker/core": "^2.0.6",
31
+ "@ew-color-picker/utils": "^2.0.6"
32
32
  },
33
33
  "devDependencies": {
34
34
  "rollup": "^3.0.0",
35
35
  "rollup-plugin-typescript2": "^0.34.0",
36
36
  "typescript": "^4.9.0",
37
37
  "rimraf": "^3.0.2",
38
- "@ew-color-picker/utils": "2.0.4",
39
- "@ew-color-picker/core": "2.0.4"
38
+ "@ew-color-picker/core": "2.0.6",
39
+ "@ew-color-picker/utils": "2.0.6"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public"