├── .gitignore ├── LICENSE ├── README.md ├── Reselect.sketchplugin └── Contents │ ├── Resources │ ├── _webpack_resources │ │ └── 121b71ba0ff9335035decac87f069831.html │ ├── images │ │ ├── bg.png │ │ ├── delete.png │ │ ├── header.png │ │ ├── load.png │ │ ├── reselect.png │ │ ├── save.png │ │ └── settings.png │ └── ui.js │ └── Sketch │ ├── deleteSelection.js │ ├── loadSelection.js │ ├── manifest.json │ ├── restorePreviousSelection.js │ ├── saveCurrentSelection.js │ ├── selectionChanged.js │ └── showSettings.js ├── appcast.xml ├── banner.png ├── package-lock.json ├── package.json ├── src ├── images │ ├── bg.png │ ├── delete.png │ ├── header.png │ ├── load.png │ ├── reselect.png │ ├── save.png │ └── settings.png ├── sketch │ ├── deleteSelection.js │ ├── loadSelection.js │ ├── manifest.json │ ├── restorePreviousSelection.js │ ├── saveCurrentSelection.js │ ├── selectionChanged.js │ ├── showSettings.js │ └── utilities │ │ ├── constants.js │ │ └── utilities.js └── web │ ├── ui.css │ ├── ui.html │ ├── ui.js │ └── ui.tsx ├── tsconfig.json └── webpack.skpm.config.js /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2020 Michael Fouquet 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Reselect 4 | 5 | **Rather than go through this readme, check out the [website](http://www.reselect.co/). It's way better.** 6 | 7 | Ever deselect when you didn't mean to? Wish you could save a tricky selection that you're doing over and over? 8 | 9 | Reselect allows you to restore a previous selection or save selections for later use (even after you close the document!). 10 | 11 | If you want to read more about it, check out this [Medium post](https://medium.com/@_fookay/reselect-sketch-plugin-d6ede304883d). 12 | 13 | ## Installation 14 | 15 | #### Recommended 16 | 17 | - Install via [Sketch Runner](http://sketchrunner.com/) or [Sketchpacks](https://sketchpacks.com/) by searching for Reselect. 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | #### Old-Fashioned 28 | 29 | - Download [this file](https://github.com/mfouquet/reselect/archive/main.zip) and double click to install. 30 | 31 | ## Usage 32 | 33 | #### Restore a Selection 34 | 35 | - Navigate to `Plugins` > `Reselect` > `Restore Previous Selection`. 36 | - Hit ctrl + alt + \\ on your keyboard. 37 | 38 | ### Save a Selection 39 | 40 | - Navigate to `Plugins` > `Reselect` > `Save Current Selection`. 41 | - Provide a name for the selection and hit `Save`. 42 | 43 | ### Load a Selection 44 | 45 | - Navigate to `Plugins` > `Reselect` > `Load Selection`. 46 | - Hit ctrl + alt + ] on your keyboard. 47 | - Select a selection from the dropdown and hit `Ok`. 48 | 49 | ### Settings 50 | 51 | - Navigate to `Plugins` > `Reselect` > `Settings`. 52 | - Change the maximum number of selection restores allow - best to keep this < 20. 53 | 54 | # Problems? 55 | 56 | [File an issue](https://github.com/mfouquet/Reselect/issues) or send me a note on [Twitter](https://twitter.com/_fookay). Any and all feedback is welcome! 57 | -------------------------------------------------------------------------------- /Reselect.sketchplugin/Contents/Resources/_webpack_resources/121b71ba0ff9335035decac87f069831.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Reselect 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Reselect.sketchplugin/Contents/Resources/images/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfouquet/Reselect/47126d1044dafd06f7a5a8a1d782ddc3ef03d808/Reselect.sketchplugin/Contents/Resources/images/bg.png -------------------------------------------------------------------------------- /Reselect.sketchplugin/Contents/Resources/images/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfouquet/Reselect/47126d1044dafd06f7a5a8a1d782ddc3ef03d808/Reselect.sketchplugin/Contents/Resources/images/delete.png -------------------------------------------------------------------------------- /Reselect.sketchplugin/Contents/Resources/images/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfouquet/Reselect/47126d1044dafd06f7a5a8a1d782ddc3ef03d808/Reselect.sketchplugin/Contents/Resources/images/header.png -------------------------------------------------------------------------------- /Reselect.sketchplugin/Contents/Resources/images/load.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfouquet/Reselect/47126d1044dafd06f7a5a8a1d782ddc3ef03d808/Reselect.sketchplugin/Contents/Resources/images/load.png -------------------------------------------------------------------------------- /Reselect.sketchplugin/Contents/Resources/images/reselect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfouquet/Reselect/47126d1044dafd06f7a5a8a1d782ddc3ef03d808/Reselect.sketchplugin/Contents/Resources/images/reselect.png -------------------------------------------------------------------------------- /Reselect.sketchplugin/Contents/Resources/images/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfouquet/Reselect/47126d1044dafd06f7a5a8a1d782ddc3ef03d808/Reselect.sketchplugin/Contents/Resources/images/save.png -------------------------------------------------------------------------------- /Reselect.sketchplugin/Contents/Resources/images/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfouquet/Reselect/47126d1044dafd06f7a5a8a1d782ddc3ef03d808/Reselect.sketchplugin/Contents/Resources/images/settings.png -------------------------------------------------------------------------------- /Reselect.sketchplugin/Contents/Sketch/deleteSelection.js: -------------------------------------------------------------------------------- 1 | var that=this;function __skpm_run(e,t){that.context=t;var r=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s="./src/sketch/deleteSelection.js")}({"./node_modules/@skpm/fs/index.js": 2 | /*!****************************************!*\ 3 | !*** ./node_modules/@skpm/fs/index.js ***! 4 | \****************************************/ 5 | /*! no static exports found */function(e,t,r){var n=r(/*! buffer */"buffer").Buffer,i=r(/*! ./utils */"./node_modules/@skpm/fs/utils.js"),a=i.parseStat,o=i.fsError,s=i.fsErrorForPath,l=i.encodingFromOptions,c=i.NOT_IMPLEMENTED;e.exports.constants={F_OK:0,R_OK:4,W_OK:2,X_OK:1},e.exports.access=c("access"),e.exports.accessSync=function(t,r){r|=0;var n=NSFileManager.defaultManager();switch(r){case 0:canAccess=e.exports.existsSync(t);break;case 1:canAccess=Boolean(Number(n.isExecutableFileAtPath(t)));break;case 2:canAccess=Boolean(Number(n.isWritableFileAtPath(t)));break;case 3:canAccess=Boolean(Number(n.isExecutableFileAtPath(t)))&&Boolean(Number(n.isWritableFileAtPath(t)));break;case 4:canAccess=Boolean(Number(n.isReadableFileAtPath(t)));break;case 5:canAccess=Boolean(Number(n.isReadableFileAtPath(t)))&&Boolean(Number(n.isExecutableFileAtPath(t)));break;case 6:canAccess=Boolean(Number(n.isReadableFileAtPath(t)))&&Boolean(Number(n.isWritableFileAtPath(t)));break;case 7:canAccess=Boolean(Number(n.isReadableFileAtPath(t)))&&Boolean(Number(n.isWritableFileAtPath(t)))&&Boolean(Number(n.isExecutableFileAtPath(t)))}if(!canAccess)throw new Error("Can't access "+String(t))},e.exports.appendFile=c("appendFile"),e.exports.appendFileSync=function(t,r,i){if(!e.exports.existsSync(t))return e.exports.writeFileSync(t,r,i);var a=NSFileHandle.fileHandleForWritingAtPath(t);a.seekToEndOfFile();var o=l(i,"utf8"),s=n.from(r,"NSData"===o||"buffer"===o?void 0:o).toNSData();a.writeData(s)},e.exports.chmod=c("chmod"),e.exports.chmodSync=function(e,t){var r=MOPointer.alloc().init();if(NSFileManager.defaultManager().setAttributes_ofItemAtPath_error({NSFilePosixPermissions:t},e,r),null!==r.value())throw s(e,void 0,r.value())},e.exports.chown=c("chown"),e.exports.chownSync=c("chownSync"),e.exports.close=c("close"),e.exports.closeSync=c("closeSync"),e.exports.copyFile=c("copyFile"),e.exports.copyFileSync=function(e,t,r){var n=MOPointer.alloc().init();if(NSFileManager.defaultManager().copyItemAtPath_toPath_error(e,t,n),null!==n.value())throw s(e,!1,n.value())},e.exports.createReadStream=c("createReadStream"),e.exports.createWriteStream=c("createWriteStream"),e.exports.exists=c("exists"),e.exports.existsSync=function(e){var t=NSFileManager.defaultManager();return Boolean(Number(t.fileExistsAtPath(e)))},e.exports.fchmod=c("fchmod"),e.exports.fchmodSync=c("fchmodSync"),e.exports.fchown=c("fchown"),e.exports.fchownSync=c("fchownSync"),e.exports.fdatasync=c("fdatasync"),e.exports.fdatasyncSync=c("fdatasyncSync"),e.exports.fstat=c("fstat"),e.exports.fstatSync=c("fstatSync"),e.exports.fsync=c("fsync"),e.exports.fsyncSync=c("fsyncSync"),e.exports.ftruncate=c("ftruncate"),e.exports.ftruncateSync=c("ftruncateSync"),e.exports.futimes=c("futimes"),e.exports.futimesSync=c("futimesSync"),e.exports.lchmod=c("lchmod"),e.exports.lchmodSync=c("lchmodSync"),e.exports.lchown=c("lchown"),e.exports.lchownSync=c("lchownSync"),e.exports.link=c("link"),e.exports.linkSync=function(e,t){var r=MOPointer.alloc().init();if(NSFileManager.defaultManager().linkItemAtPath_toPath_error(e,t,r),null!==r.value())throw s(e,void 0,r.value())},e.exports.lstat=c("lstat"),e.exports.lstatSync=function(e){var t=MOPointer.alloc().init(),r=NSFileManager.defaultManager().attributesOfItemAtPath_error(e,t);if(null!==t.value())throw s(e,void 0,t.value());return a(r)},e.exports.mkdir=c("mkdir"),e.exports.mkdirSync=function(e,t){var r=511,n=!1;t&&t.mode&&(r=t.mode),t&&t.recursive&&(n=t.recursive),"number"==typeof t&&(r=t);var i=MOPointer.alloc().init();if(NSFileManager.defaultManager().createDirectoryAtPath_withIntermediateDirectories_attributes_error(e,n,{NSFilePosixPermissions:r},i),null!==i.value())throw new Error(i.value())},e.exports.mkdtemp=c("mkdtemp"),e.exports.mkdtempSync=function(t){var r=t+function(){for(var e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=0;r<6;r++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}();return e.exports.mkdirSync(r),r},e.exports.open=c("open"),e.exports.openSync=c("openSync"),e.exports.read=c("read"),e.exports.readdir=c("readdir"),e.exports.readdirSync=function(e,t){for(var r=l(t,"utf8"),i=NSFileManager.defaultManager().subpathsAtPath(e),a=[],o=0;o2){var u=n.lastIndexOf("/");if(u!==n.length-1){-1===u?(n="",o=0):o=(n=n.slice(0,u)).length-1-n.lastIndexOf("/"),s=c,l=0;continue}}else if(2===n.length||1===n.length){n="",o=0,s=c,l=0;continue}t&&(n.length>0?n+="/..":n="..",o=2)}else n.length>0?n+="/"+e.slice(s+1,c):n=e.slice(s+1,c),o=c-s-1;s=c,l=0}else r===a&&-1!==l?++l:l=-1}return n}var s={resolve:function(){for(var e,t="",r=!1,a=arguments.length-1;a>=-1&&!r;a-=1){var l;a>=0?l=arguments[a]:(void 0===e&&(e=s.dirname(n.cwd())),l=e),0!==(l=n.getString(l,"path")).length&&(t=l+"/"+t,r=l.charCodeAt(0)===i)}return t=o(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(0===(e=n.getString(e,"path")).length)return".";var t=e.charCodeAt(0)===i,r=e.charCodeAt(e.length-1)===i;return 0!==(e=o(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return(e=n.getString(e,"path")).length>0&&e.charCodeAt(0)===i},join:function(){if(0===arguments.length)return".";for(var e,t=0;t0&&(void 0===e?e=r:e+="/"+r)}return void 0===e?".":s.normalize(e)},relative:function(e,t){if((e=n.getString(e,"from path"))===(t=n.getString(t,"to path")))return"";if((e=s.resolve(e))===(t=s.resolve(t)))return"";for(var r=1;ru){if(t.charCodeAt(l+h)===i)return t.slice(l+h+1);if(0===h)return t.slice(l+h)}else o>u&&(e.charCodeAt(r+h)===i?f=h:0===h&&(f=0));break}var p=e.charCodeAt(r+h);if(p!==t.charCodeAt(l+h))break;p===i&&(f=h)}var d="";for(h=r+f+1;h<=a;h+=1)h!==a&&e.charCodeAt(h)!==i||(0===d.length?d+="..":d+="/..");return d.length>0?d+t.slice(l+f):(l+=f,t.charCodeAt(l)===i&&(l+=1),t.slice(l))},toNamespacedPath:function(e){return e},dirname:function(e){if(0===(e=n.getString(e,"path")).length)return".";for(var t=e.charCodeAt(0),r=t===i,a=-1,o=!0,s=e.length-1;s>=1;s-=1)if((t=e.charCodeAt(s))===i){if(!o){a=s;break}}else o=!1;return-1===a?r?"/":".":r&&1===a?"//":e.slice(0,a)},basename:function(e,t){void 0!==t&&(t=n.getString(t,"ext")),e=n.getString(e,"path");var r,a=0,o=-1,s=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var l=t.length-1,c=-1;for(r=e.length-1;r>=0;r-=1){var u=e.charCodeAt(r);if(u===i){if(!s){a=r+1;break}}else-1===c&&(s=!1,c=r+1),l>=0&&(u===t.charCodeAt(l)?-1==--l&&(o=r):(l=-1,o=c))}return a===o?o=c:-1===o&&(o=e.length),e.slice(a,o)}for(r=e.length-1;r>=0;--r)if(e.charCodeAt(r)===i){if(!s){a=r+1;break}}else-1===o&&(s=!1,o=r+1);return-1===o?"":e.slice(a,o)},extname:function(e){for(var t=-1,r=0,o=-1,s=!0,l=0,c=(e=n.getString(e,"path")).length-1;c>=0;--c){var u=e.charCodeAt(c);if(u!==i)-1===o&&(s=!1,o=c+1),u===a?-1===t?t=c:1!==l&&(l=1):-1!==t&&(l=-1);else if(!s){r=c+1;break}}return-1===t||-1===o||0===l||1===l&&t===o-1&&t===r+1?"":e.slice(t,o)},format:function(e){if(null===e||"object"!=typeof e)throw new Error("pathObject should be an Object");return function(e,t){var r=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+n:r+e+n:n}("/",e)},parse:function(e){var t={root:"",dir:"",base:"",ext:"",name:""};if(0===(e=n.getString(e,"path")).length)return t;var r,o=e.charCodeAt(0),s=o===i;s?(t.root="/",r=1):r=0;for(var l=-1,c=0,u=-1,f=!0,h=e.length-1,p=0;h>=r;--h)if((o=e.charCodeAt(h))!==i)-1===u&&(f=!1,u=h+1),o===a?-1===l?l=h:1!==p&&(p=1):-1!==l&&(p=-1);else if(!f){c=h+1;break}return-1===l||-1===u||0===p||1===p&&l===u-1&&l===c+1?-1!==u&&(t.base=t.name=0===c&&s?e.slice(1,u):e.slice(c,u)):(0===c&&s?(t.name=e.slice(1,l),t.base=e.slice(1,u)):(t.name=e.slice(c,l),t.base=e.slice(c,u)),t.ext=e.slice(l,u)),c>0?t.dir=e.slice(0,c-1):s&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null,resourcePath:n.resourcePath};e.exports=s,e.exports.posix=s},"./node_modules/@skpm/path/sketch-specifics.js": 14 | /*!*****************************************************!*\ 15 | !*** ./node_modules/@skpm/path/sketch-specifics.js ***! 16 | \*****************************************************/ 17 | /*! no static exports found */function(e,t,r){var n=r(/*! util */"util");e.exports.getString=function(e,t){if(!n.isString(e)){if("NSURL"===n.getNativeClass(e))return String(e.path().copy());throw new Error(t+" should be a string. Got "+typeof e+" instead.")}return String(e)},e.exports.cwd=function(){return"undefined"!=typeof __command&&__command.script()&&__command.script().URL()?String(__command.script().URL().path().copy()):String(MSPluginManager.defaultPluginURL().path().copy())},e.exports.resourcePath=function(e){if("undefined"!=typeof __command&&__command.pluginBundle()){var t=__command.pluginBundle().urlForResourceNamed(e);if(t)return String(t.path())}}},"./src/sketch/deleteSelection.js": 18 | /*!***************************************!*\ 19 | !*** ./src/sketch/deleteSelection.js ***! 20 | \***************************************/ 21 | /*! exports provided: deleteSelection */function(e,t,r){"use strict";r.r(t),r.d(t,"deleteSelection",function(){return h});var n=r(/*! sketch/dom */"sketch/dom"),i=r.n(n),a=r(/*! sketch/ui */"sketch/ui"),o=r.n(a),s=r(/*! @skpm/fs */"./node_modules/@skpm/fs/index.js"),l=r.n(s),c=r(/*! @skpm/path */"./node_modules/@skpm/path/index.js"),u=r.n(c),f=r(/*! ./utilities/utilities */"./src/sketch/utilities/utilities.js"),h=function(){var e=i.a.getSelectedDocument().id,t=u.a.resolve(".."),r="".concat(t,"/selections/").concat(e,".txt");if(l.a.existsSync(r)){for(var n=l.a.readFileSync(r),a=JSON.parse(n),s=[],c=0;c2){var u=n.lastIndexOf("/");if(u!==n.length-1){-1===u?(n="",o=0):o=(n=n.slice(0,u)).length-1-n.lastIndexOf("/"),s=c,l=0;continue}}else if(2===n.length||1===n.length){n="",o=0,s=c,l=0;continue}t&&(n.length>0?n+="/..":n="..",o=2)}else n.length>0?n+="/"+e.slice(s+1,c):n=e.slice(s+1,c),o=c-s-1;s=c,l=0}else r===a&&-1!==l?++l:l=-1}return n}var s={resolve:function(){for(var e,t="",r=!1,a=arguments.length-1;a>=-1&&!r;a-=1){var l;a>=0?l=arguments[a]:(void 0===e&&(e=s.dirname(n.cwd())),l=e),0!==(l=n.getString(l,"path")).length&&(t=l+"/"+t,r=l.charCodeAt(0)===i)}return t=o(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(0===(e=n.getString(e,"path")).length)return".";var t=e.charCodeAt(0)===i,r=e.charCodeAt(e.length-1)===i;return 0!==(e=o(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return(e=n.getString(e,"path")).length>0&&e.charCodeAt(0)===i},join:function(){if(0===arguments.length)return".";for(var e,t=0;t0&&(void 0===e?e=r:e+="/"+r)}return void 0===e?".":s.normalize(e)},relative:function(e,t){if((e=n.getString(e,"from path"))===(t=n.getString(t,"to path")))return"";if((e=s.resolve(e))===(t=s.resolve(t)))return"";for(var r=1;ru){if(t.charCodeAt(l+h)===i)return t.slice(l+h+1);if(0===h)return t.slice(l+h)}else o>u&&(e.charCodeAt(r+h)===i?f=h:0===h&&(f=0));break}var d=e.charCodeAt(r+h);if(d!==t.charCodeAt(l+h))break;d===i&&(f=h)}var p="";for(h=r+f+1;h<=a;h+=1)h!==a&&e.charCodeAt(h)!==i||(0===p.length?p+="..":p+="/..");return p.length>0?p+t.slice(l+f):(l+=f,t.charCodeAt(l)===i&&(l+=1),t.slice(l))},toNamespacedPath:function(e){return e},dirname:function(e){if(0===(e=n.getString(e,"path")).length)return".";for(var t=e.charCodeAt(0),r=t===i,a=-1,o=!0,s=e.length-1;s>=1;s-=1)if((t=e.charCodeAt(s))===i){if(!o){a=s;break}}else o=!1;return-1===a?r?"/":".":r&&1===a?"//":e.slice(0,a)},basename:function(e,t){void 0!==t&&(t=n.getString(t,"ext")),e=n.getString(e,"path");var r,a=0,o=-1,s=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var l=t.length-1,c=-1;for(r=e.length-1;r>=0;r-=1){var u=e.charCodeAt(r);if(u===i){if(!s){a=r+1;break}}else-1===c&&(s=!1,c=r+1),l>=0&&(u===t.charCodeAt(l)?-1==--l&&(o=r):(l=-1,o=c))}return a===o?o=c:-1===o&&(o=e.length),e.slice(a,o)}for(r=e.length-1;r>=0;--r)if(e.charCodeAt(r)===i){if(!s){a=r+1;break}}else-1===o&&(s=!1,o=r+1);return-1===o?"":e.slice(a,o)},extname:function(e){for(var t=-1,r=0,o=-1,s=!0,l=0,c=(e=n.getString(e,"path")).length-1;c>=0;--c){var u=e.charCodeAt(c);if(u!==i)-1===o&&(s=!1,o=c+1),u===a?-1===t?t=c:1!==l&&(l=1):-1!==t&&(l=-1);else if(!s){r=c+1;break}}return-1===t||-1===o||0===l||1===l&&t===o-1&&t===r+1?"":e.slice(t,o)},format:function(e){if(null===e||"object"!=typeof e)throw new Error("pathObject should be an Object");return function(e,t){var r=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+n:r+e+n:n}("/",e)},parse:function(e){var t={root:"",dir:"",base:"",ext:"",name:""};if(0===(e=n.getString(e,"path")).length)return t;var r,o=e.charCodeAt(0),s=o===i;s?(t.root="/",r=1):r=0;for(var l=-1,c=0,u=-1,f=!0,h=e.length-1,d=0;h>=r;--h)if((o=e.charCodeAt(h))!==i)-1===u&&(f=!1,u=h+1),o===a?-1===l?l=h:1!==d&&(d=1):-1!==l&&(d=-1);else if(!f){c=h+1;break}return-1===l||-1===u||0===d||1===d&&l===u-1&&l===c+1?-1!==u&&(t.base=t.name=0===c&&s?e.slice(1,u):e.slice(c,u)):(0===c&&s?(t.name=e.slice(1,l),t.base=e.slice(1,u)):(t.name=e.slice(c,l),t.base=e.slice(c,u)),t.ext=e.slice(l,u)),c>0?t.dir=e.slice(0,c-1):s&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null,resourcePath:n.resourcePath};e.exports=s,e.exports.posix=s},"./node_modules/@skpm/path/sketch-specifics.js": 14 | /*!*****************************************************!*\ 15 | !*** ./node_modules/@skpm/path/sketch-specifics.js ***! 16 | \*****************************************************/ 17 | /*! no static exports found */function(e,t,r){var n=r(/*! util */"util");e.exports.getString=function(e,t){if(!n.isString(e)){if("NSURL"===n.getNativeClass(e))return String(e.path().copy());throw new Error(t+" should be a string. Got "+typeof e+" instead.")}return String(e)},e.exports.cwd=function(){return"undefined"!=typeof __command&&__command.script()&&__command.script().URL()?String(__command.script().URL().path().copy()):String(MSPluginManager.defaultPluginURL().path().copy())},e.exports.resourcePath=function(e){if("undefined"!=typeof __command&&__command.pluginBundle()){var t=__command.pluginBundle().urlForResourceNamed(e);if(t)return String(t.path())}}},"./src/sketch/loadSelection.js": 18 | /*!*************************************!*\ 19 | !*** ./src/sketch/loadSelection.js ***! 20 | \*************************************/ 21 | /*! exports provided: loadSelection */function(e,t,r){"use strict";r.r(t),r.d(t,"loadSelection",function(){return h});var n=r(/*! sketch/dom */"sketch/dom"),i=r.n(n),a=r(/*! sketch/ui */"sketch/ui"),o=r.n(a),s=r(/*! @skpm/fs */"./node_modules/@skpm/fs/index.js"),l=r.n(s),c=r(/*! @skpm/path */"./node_modules/@skpm/path/index.js"),u=r.n(c),f=r(/*! ./utilities/utilities */"./src/sketch/utilities/utilities.js"),h=function(){var e=i.a.getSelectedDocument(),t=e.id,r=u.a.resolve(".."),n="".concat(r,"/selections/").concat(t,".txt");if(l.a.existsSync(n)){for(var a=l.a.readFileSync(n),s=JSON.parse(a),c=[],h=0;h2){var u=n.lastIndexOf("/");if(u!==n.length-1){-1===u?(n="",o=0):o=(n=n.slice(0,u)).length-1-n.lastIndexOf("/"),l=c,s=0;continue}}else if(2===n.length||1===n.length){n="",o=0,l=c,s=0;continue}t&&(n.length>0?n+="/..":n="..",o=2)}else n.length>0?n+="/"+e.slice(l+1,c):n=e.slice(l+1,c),o=c-l-1;l=c,s=0}else r===a&&-1!==s?++s:s=-1}return n}var l={resolve:function(){for(var e,t="",r=!1,a=arguments.length-1;a>=-1&&!r;a-=1){var s;a>=0?s=arguments[a]:(void 0===e&&(e=l.dirname(n.cwd())),s=e),0!==(s=n.getString(s,"path")).length&&(t=s+"/"+t,r=s.charCodeAt(0)===i)}return t=o(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(0===(e=n.getString(e,"path")).length)return".";var t=e.charCodeAt(0)===i,r=e.charCodeAt(e.length-1)===i;return 0!==(e=o(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return(e=n.getString(e,"path")).length>0&&e.charCodeAt(0)===i},join:function(){if(0===arguments.length)return".";for(var e,t=0;t0&&(void 0===e?e=r:e+="/"+r)}return void 0===e?".":l.normalize(e)},relative:function(e,t){if((e=n.getString(e,"from path"))===(t=n.getString(t,"to path")))return"";if((e=l.resolve(e))===(t=l.resolve(t)))return"";for(var r=1;ru){if(t.charCodeAt(s+h)===i)return t.slice(s+h+1);if(0===h)return t.slice(s+h)}else o>u&&(e.charCodeAt(r+h)===i?f=h:0===h&&(f=0));break}var p=e.charCodeAt(r+h);if(p!==t.charCodeAt(s+h))break;p===i&&(f=h)}var d="";for(h=r+f+1;h<=a;h+=1)h!==a&&e.charCodeAt(h)!==i||(0===d.length?d+="..":d+="/..");return d.length>0?d+t.slice(s+f):(s+=f,t.charCodeAt(s)===i&&(s+=1),t.slice(s))},toNamespacedPath:function(e){return e},dirname:function(e){if(0===(e=n.getString(e,"path")).length)return".";for(var t=e.charCodeAt(0),r=t===i,a=-1,o=!0,l=e.length-1;l>=1;l-=1)if((t=e.charCodeAt(l))===i){if(!o){a=l;break}}else o=!1;return-1===a?r?"/":".":r&&1===a?"//":e.slice(0,a)},basename:function(e,t){void 0!==t&&(t=n.getString(t,"ext")),e=n.getString(e,"path");var r,a=0,o=-1,l=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var s=t.length-1,c=-1;for(r=e.length-1;r>=0;r-=1){var u=e.charCodeAt(r);if(u===i){if(!l){a=r+1;break}}else-1===c&&(l=!1,c=r+1),s>=0&&(u===t.charCodeAt(s)?-1==--s&&(o=r):(s=-1,o=c))}return a===o?o=c:-1===o&&(o=e.length),e.slice(a,o)}for(r=e.length-1;r>=0;--r)if(e.charCodeAt(r)===i){if(!l){a=r+1;break}}else-1===o&&(l=!1,o=r+1);return-1===o?"":e.slice(a,o)},extname:function(e){for(var t=-1,r=0,o=-1,l=!0,s=0,c=(e=n.getString(e,"path")).length-1;c>=0;--c){var u=e.charCodeAt(c);if(u!==i)-1===o&&(l=!1,o=c+1),u===a?-1===t?t=c:1!==s&&(s=1):-1!==t&&(s=-1);else if(!l){r=c+1;break}}return-1===t||-1===o||0===s||1===s&&t===o-1&&t===r+1?"":e.slice(t,o)},format:function(e){if(null===e||"object"!=typeof e)throw new Error("pathObject should be an Object");return function(e,t){var r=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+n:r+e+n:n}("/",e)},parse:function(e){var t={root:"",dir:"",base:"",ext:"",name:""};if(0===(e=n.getString(e,"path")).length)return t;var r,o=e.charCodeAt(0),l=o===i;l?(t.root="/",r=1):r=0;for(var s=-1,c=0,u=-1,f=!0,h=e.length-1,p=0;h>=r;--h)if((o=e.charCodeAt(h))!==i)-1===u&&(f=!1,u=h+1),o===a?-1===s?s=h:1!==p&&(p=1):-1!==s&&(p=-1);else if(!f){c=h+1;break}return-1===s||-1===u||0===p||1===p&&s===u-1&&s===c+1?-1!==u&&(t.base=t.name=0===c&&l?e.slice(1,u):e.slice(c,u)):(0===c&&l?(t.name=e.slice(1,s),t.base=e.slice(1,u)):(t.name=e.slice(c,s),t.base=e.slice(c,u)),t.ext=e.slice(s,u)),c>0?t.dir=e.slice(0,c-1):l&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null,resourcePath:n.resourcePath};e.exports=l,e.exports.posix=l},"./node_modules/@skpm/path/sketch-specifics.js": 14 | /*!*****************************************************!*\ 15 | !*** ./node_modules/@skpm/path/sketch-specifics.js ***! 16 | \*****************************************************/ 17 | /*! no static exports found */function(e,t,r){var n=r(/*! util */"util");e.exports.getString=function(e,t){if(!n.isString(e)){if("NSURL"===n.getNativeClass(e))return String(e.path().copy());throw new Error(t+" should be a string. Got "+typeof e+" instead.")}return String(e)},e.exports.cwd=function(){return"undefined"!=typeof __command&&__command.script()&&__command.script().URL()?String(__command.script().URL().path().copy()):String(MSPluginManager.defaultPluginURL().path().copy())},e.exports.resourcePath=function(e){if("undefined"!=typeof __command&&__command.pluginBundle()){var t=__command.pluginBundle().urlForResourceNamed(e);if(t)return String(t.path())}}},"./src/sketch/saveCurrentSelection.js": 18 | /*!********************************************!*\ 19 | !*** ./src/sketch/saveCurrentSelection.js ***! 20 | \********************************************/ 21 | /*! exports provided: saveCurrentSelection */function(e,t,r){"use strict";r.r(t),r.d(t,"saveCurrentSelection",function(){return f});var n=r(/*! sketch/dom */"sketch/dom"),i=r.n(n),a=r(/*! sketch/ui */"sketch/ui"),o=r.n(a),l=r(/*! @skpm/fs */"./node_modules/@skpm/fs/index.js"),s=r.n(l),c=r(/*! @skpm/path */"./node_modules/@skpm/path/index.js"),u=r.n(c),f=function(){var e=i.a.getSelectedDocument(),t=e.id,r=e.selectedLayers,n="".concat(r.layers.length," ").concat(1===r.layers.length?"layer":"layers");o.a.getInputFromUser("Enter a name for this selection",{initialValue:n},function(e,n){if(!e){for(var i=[],a=0;a0){for(var s=[],u=0;un&&t.shift(),r.saveSessionVariable("selections",t)}}}},"./src/sketch/utilities/constants.js": 6 | /*!*******************************************!*\ 7 | !*** ./src/sketch/utilities/constants.js ***! 8 | \*******************************************/ 9 | /*! exports provided: SETTINGS_PLUGIN_RESELECTAMOUNT, URL_WEBSITE, URL_HELP, URL_CHANGELOG */function(e,t,n){"use strict";n.r(t),n.d(t,"SETTINGS_PLUGIN_RESELECTAMOUNT",function(){return r}),n.d(t,"URL_WEBSITE",function(){return o}),n.d(t,"URL_HELP",function(){return i}),n.d(t,"URL_CHANGELOG",function(){return s});var r="amount",o="http://www.reselect.co/",i="http://www.reselect.co/",s="https://github.com/mfouquet/Reselect/releases"},"./src/sketch/utilities/utilities.js": 10 | /*!*******************************************!*\ 11 | !*** ./src/sketch/utilities/utilities.js ***! 12 | \*******************************************/ 13 | /*! exports provided: saveGlobalSetting, loadGlobalSetting, savePluginSetting, loadPluginSetting, saveSessionVariable, loadSessionVariable, openURL, showToast */function(e,t,n){"use strict";n.r(t),n.d(t,"saveGlobalSetting",function(){return u}),n.d(t,"loadGlobalSetting",function(){return c}),n.d(t,"savePluginSetting",function(){return a}),n.d(t,"loadPluginSetting",function(){return l}),n.d(t,"saveSessionVariable",function(){return f}),n.d(t,"loadSessionVariable",function(){return d}),n.d(t,"openURL",function(){return h}),n.d(t,"showToast",function(){return g});var r=n(/*! sketch/settings */"sketch/settings"),o=n.n(r),i=n(/*! sketch/ui */"sketch/ui"),s=n.n(i),u=function(e,t){o.a.setGlobalSettingForKey(e,t)},c=function(e){return o.a.globalSettingForKey(e)},a=function(e,t){o.a.setSettingForKey("com.mfouquet.sketch.reselect.".concat(e),t)},l=function(e){return o.a.settingForKey("com.mfouquet.sketch.reselect.".concat(e))},f=function(e,t){o.a.setSessionVariable("com.mfouquet.sketch.reselect.".concat(e),t)},d=function(e){return o.a.sessionVariable("com.mfouquet.sketch.reselect.".concat(e))},h=function(e){var t=NSURL.URLWithString(e);NSWorkspace.sharedWorkspace().openURL(t)},g=function(e){s.a.message(e)}},"sketch/settings": 14 | /*!**********************************!*\ 15 | !*** external "sketch/settings" ***! 16 | \**********************************/ 17 | /*! no static exports found */function(e,t){e.exports=require("sketch/settings")},"sketch/ui": 18 | /*!****************************!*\ 19 | !*** external "sketch/ui" ***! 20 | \****************************/ 21 | /*! no static exports found */function(e,t){e.exports=require("sketch/ui")}});"default"===e&&"function"==typeof n?n(t):n[e](t)}that.selectionChanged=__skpm_run.bind(this,"selectionChanged"),that.onRun=__skpm_run.bind(this,"default"); -------------------------------------------------------------------------------- /Reselect.sketchplugin/Contents/Sketch/showSettings.js: -------------------------------------------------------------------------------- 1 | var that=this;function __skpm_run(key,context){that.context=context;var exports=function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="./src/sketch/showSettings.js")}({"./node_modules/@skpm/timers/immediate.js": 2 | /*!************************************************!*\ 3 | !*** ./node_modules/@skpm/timers/immediate.js ***! 4 | \************************************************/ 5 | /*! no static exports found */function(e,t,n){var i=n(/*! ./timeout */"./node_modules/@skpm/timers/timeout.js");e.exports={setImmediate:function(e,t,n,o,r,s,a,u,l,c,d){return i.setTimeout(e,0,t,n,o,r,s,a,u,l,c,d)},clearImmediate:function(e){return i.clearTimeout(e)}}},"./node_modules/@skpm/timers/interval.js": 6 | /*!***********************************************!*\ 7 | !*** ./node_modules/@skpm/timers/interval.js ***! 8 | \***********************************************/ 9 | /*! no static exports found */function(e,t,n){var i,o,r=[];n(/*! ./test-if-fiber */"./node_modules/@skpm/timers/test-if-fiber.js")()?(i=function(e,t,n,i,o,s,a,u,l,c,d,f){var m=r.length;return r.push(coscript.scheduleWithRepeatingInterval_jsFunction((t||0)/1e3,function(){e(n,i,o,s,a,u,l,c,d,f)})),m},o=function(e){var t=r[e];t&&(t.cancel(),r[e]=void 0)}):(i=function(e,t,n,i,o,s,a,u,l,c,d,f){coscript.shouldKeepAround=!0;var m=r.length;return r.push(!0),function h(){coscript.scheduleWithInterval_jsFunction((t||0)/1e3,function(){r[m]&&(e(n,i,o,s,a,u,l,c,d,f),h())})}(),m},o=function(e){r[e]=!1,r.every(function(e){return!e})&&(coscript.shouldKeepAround=!1)}),e.exports={setInterval:i,clearInterval:o}},"./node_modules/@skpm/timers/test-if-fiber.js": 10 | /*!****************************************************!*\ 11 | !*** ./node_modules/@skpm/timers/test-if-fiber.js ***! 12 | \****************************************************/ 13 | /*! no static exports found */function(e,t){e.exports=function(){return"undefined"!=typeof coscript&&coscript.createFiber}},"./node_modules/@skpm/timers/timeout.js": 14 | /*!**********************************************!*\ 15 | !*** ./node_modules/@skpm/timers/timeout.js ***! 16 | \**********************************************/ 17 | /*! no static exports found */function(e,t,n){var i,o,r=[];if(n(/*! ./test-if-fiber */"./node_modules/@skpm/timers/test-if-fiber.js")()){r=[];i=function(e,t,n,i,o,s,a,u,l,c,d,f){var m=r.length;return r.push(coscript.scheduleWithInterval_jsFunction((t||0)/1e3,function(){e(n,i,o,s,a,u,l,c,d,f)})),m},o=function(e){var t=r[e];t&&(t.cancel(),r[e]=void 0)}}else i=function(e,t,n,i,s,a,u,l,c,d,f,m){coscript.shouldKeepAround=!0;var h=r.length;return r.push(!0),coscript.scheduleWithInterval_jsFunction((t||0)/1e3,function(){r[h]&&e(n,i,s,a,u,l,c,d,f,m),o(h),r.every(function(e){return!e})&&(coscript.shouldKeepAround=!1)}),h},o=function(e){r[e]=!1};e.exports={setTimeout:i,clearTimeout:o}},"./node_modules/mocha-js-delegate/index.js": 18 | /*!*************************************************!*\ 19 | !*** ./node_modules/mocha-js-delegate/index.js ***! 20 | \*************************************************/ 21 | /*! no static exports found */function(module,exports){module.exports=function MochaDelegate(definition,superclass){var uniqueClassName="MochaJSDelegate_DynamicClass_"+NSUUID.UUID().UUIDString(),delegateClassDesc=MOClassDescription.allocateDescriptionForClassWithName_superclass_(uniqueClassName,superclass||NSObject),handlers={},ivars={};function setHandlerForSelector(selectorString,func){var handlerHasBeenSet=selectorString in handlers,selector=NSSelectorFromString(selectorString);if(handlers[selectorString]=func,!handlerHasBeenSet){for(var args=[],regex=/:/g;regex.exec(selectorString);)args.push("arg"+args.length);var dynamicFunction=eval("(function ("+args.join(", ")+") { return handlers[selectorString].apply(this, arguments); })");delegateClassDesc.addInstanceMethodWithSelector_function(selector,dynamicFunction)}}function setIvar(e,t){var n=e in handlers;if(ivars[e]=t,!n){delegateClassDesc.addInstanceVariableWithName_typeEncoding(e,"@");var i=MOPropertyDescription.new();i.name=e,i.typeEncoding="@",i.weak=!0,i.ivarName=e,delegateClassDesc.addProperty(i)}}this.getClass=function(){return NSClassFromString(uniqueClassName)},this.getClassInstance=function(e){var t=NSClassFromString(uniqueClassName).new();return Object.keys(ivars).forEach(function(e){t[e]=ivars[e]}),Object.keys(e||{}).forEach(function(n){t[n]=e[n]}),t},this.new=this.getClassInstance,"object"==typeof definition&&Object.keys(definition).forEach(function(e){"function"==typeof definition[e]?setHandlerForSelector(e,definition[e]):setIvar(e,definition[e])}),delegateClassDesc.registerClass()}},"./node_modules/process/browser.js": 22 | /*!*****************************************!*\ 23 | !*** ./node_modules/process/browser.js ***! 24 | \*****************************************/ 25 | /*! no static exports found */function(e,t,n){(function(t,n){var i,o,r=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(e){if(i===t)return t(e,0);if((i===s||!i)&&t)return i=t,t(e,0);try{return i(e,0)}catch(t){try{return i.call(null,e,0)}catch(t){return i.call(this,e,0)}}}!function(){try{i="function"==typeof t?t:s}catch(e){i=s}try{o="function"==typeof n?n:a}catch(e){o=a}}();var l,c=[],d=!1,f=-1;function m(){d&&l&&(d=!1,l.length?c=l.concat(c):f=-1,c.length&&h())}function h(){if(!d){var e=u(m);d=!0;for(var t=c.length;t;){for(l=c,c=[];++f1)for(var n=1;n0?t.setAspectRatio(NSMakeSize(e,1)):t.setResizeIncrements(NSMakeSize(1,1))},e.setBounds=function(n,i){if(!n)return;if(e.isFullscreen())return;const o=Object.assign(e.getBounds(),n);var r=NSMakeRect(o.x,0,o.width,o.height),s=NSScreen.screens().firstObject();r.origin.y=NSHeight(s.frame())-o.y,t.setFrame_display_animate(r,!0,i)},e.getBounds=function(){const e=t.frame();var n=NSScreen.screens().firstObject().frame();return{x:e.origin.x,y:Math.round(NSHeight(n)-e.origin.y),width:e.size.width,height:e.size.height}},e.setContentBounds=function(t,n){e.setBounds(t,n)},e.getContentBounds=function(){return e.getBounds()},e.setSize=function(t,n,i){return e.setBounds({width:t,height:n},i)},e.getSize=function(){var t=e.getBounds();return[t.width,t.height]},e.setContentSize=function(t,n,i){return e.setContentBounds({width:t,height:n},i)},e.getContentSize=function(){var t=e.getContentBounds();return[t.width,t.height]},e.setMinimumSize=function(e,n){const i=CGSizeMake(e,n);t.setContentMinSize(i)},e.getMinimumSize=function(){const e=t.contentMinSize();return[e.width,e.height]},e.setMaximumSize=function(e,n){const i=CGSizeMake(e,n);t.setContentMaxSize(i)},e.getMaximumSize=function(){const e=t.contentMaxSize();return[e.width,e.height]},e.setResizable=function(t){return e._setStyleMask(t,NSResizableWindowMask)},e.isResizable=function(){return t.styleMask()&NSResizableWindowMask},e.setMovable=function(e){return t.setMovable(e)},e.isMovable=function(){return t.isMovable()},e.setMinimizable=function(t){return e._setStyleMask(t,NSMiniaturizableWindowMask)},e.isMinimizable=function(){return t.styleMask()&NSMiniaturizableWindowMask},e.setMaximizable=function(e){t.standardWindowButton(NSWindowZoomButton)&&t.standardWindowButton(NSWindowZoomButton).setEnabled(e)},e.isMaximizable=function(){return t.standardWindowButton(NSWindowZoomButton)&&t.standardWindowButton(NSWindowZoomButton).isEnabled()},e.setFullScreenable=function(t){e._setCollectionBehavior(t,NSWindowCollectionBehaviorFullScreenPrimary),e._setCollectionBehavior(!t,NSWindowCollectionBehaviorFullScreenAuxiliary)},e.isFullScreenable=function(){return t.collectionBehavior()&NSWindowCollectionBehaviorFullScreenPrimary},e.setClosable=function(t){e._setStyleMask(t,NSClosableWindowMask)},e.isClosable=function(){return t.styleMask()&NSClosableWindowMask},e.setAlwaysOnTop=function(e,n,i){var o=NSNormalWindowLevel,r=CGWindowLevelForKey(kCGMaximumWindowLevelKey),s=CGWindowLevelForKey(kCGMinimumWindowLevelKey);e&&(o="normal"===n?NSNormalWindowLevel:"torn-off-menu"===n?NSTornOffMenuWindowLevel:"modal-panel"===n?NSModalPanelWindowLevel:"main-menu"===n?NSMainMenuWindowLevel:"status"===n?NSStatusWindowLevel:"pop-up-menu"===n?NSPopUpMenuWindowLevel:"screen-saver"===n?NSScreenSaverWindowLevel:"dock"===n?NSDockWindowLevel:NSFloatingWindowLevel);var a=o+(i||0);if(!(a>=s&&a<=r))throw new Error("relativeLevel must be between "+s+" and "+r);t.setLevel(a)},e.isAlwaysOnTop=function(){return t.level()!==NSNormalWindowLevel},e.moveTop=function(){return t.orderFrontRegardless()},e.center=function(){t.center()},e.setPosition=function(t,n,i){return e.setBounds({x:t,y:n},i)},e.getPosition=function(){var t=e.getBounds();return[t.x,t.y]},e.setTitle=function(e){t.setTitle(e)},e.getTitle=function(){return String(t.title())};var o=0;e.flashFrame=function(e){e?o=NSApp.requestUserAttention(NSInformationalRequest):(NSApp.cancelUserAttentionRequest(o),o=0)},e.getNativeWindowHandle=function(){return t},e.getNativeWebViewHandle=function(){return n},e.loadURL=function(e){if(/^(?!https?|file).*\.html?$/.test(e)&&"undefined"!=typeof __command&&__command.pluginBundle()&&(e="file://"+__command.pluginBundle().urlForResourceNamed(e).path()),/^file:\/\/.*\.html?$/.test(e))return e=(e=NSString.alloc().initWithString(e)).stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet()),void n.loadFileURL_allowingReadAccessToURL(NSURL.URLWithString(e),NSURL.URLWithString("file:///"));const t=NSURL.URLWithString(e),i=NSURLRequest.requestWithURL(t);n.loadRequest(i)},e.reload=function(){n.reload()},e.setHasShadow=function(e){return t.setHasShadow(e)},e.hasShadow=function(){return t.hasShadow()},e.setOpacity=function(e){return t.setAlphaValue(e)},e.getOpacity=function(){return t.alphaValue()},e.setVisibleOnAllWorkspaces=function(t){return e._setCollectionBehavior(t,NSWindowCollectionBehaviorCanJoinAllSpaces)},e.isVisibleOnAllWorkspaces=function(){return t.collectionBehavior()&NSWindowCollectionBehaviorCanJoinAllSpaces},e.setIgnoreMouseEvents=function(e){return t.setIgnoresMouseEvents(e)},e.setContentProtection=function(e){t.setSharingType(e?NSWindowSharingNone:NSWindowSharingReadOnly)},e.setAutoHideCursor=function(e){t.setDisableAutoHideCursor(e)},e.setVibrancy=function(n){var i=e._vibrantView;if(!n){if(null==i)return;return i.removeFromSuperview(),void t.setVibrantView(null)}if(null==i){var o=t.contentView();i=NSVisualEffectView.alloc().initWithFrame(o.bounds()),e._vibrantView=i,i.setAutoresizingMask(NSViewWidthSizable|NSViewHeightSizable),i.setBlendingMode(NSVisualEffectBlendingModeBehindWindow),i.setState(NSVisualEffectStateActive),i.setFrame(o.bounds()),o.addSubview_positioned_relativeTo(i,NSWindowBelow,null)}var r=NSVisualEffectMaterialLight;"appearance-based"===n?r=NSVisualEffectMaterialAppearanceBased:"light"===n?r=NSVisualEffectMaterialLight:"dark"===n?r=NSVisualEffectMaterialDark:"titlebar"===n?r=NSVisualEffectMaterialTitlebar:"selection"===n?r=NSVisualEffectMaterialSelection:"menu"===n?r=NSVisualEffectMaterialMenu:"popover"===n?r=NSVisualEffectMaterialPopover:"sidebar"===n?r=NSVisualEffectMaterialSidebar:"medium-light"===n?r=NSVisualEffectMaterialMediumLight:"ultra-dark"===n&&(r=NSVisualEffectMaterialUltraDark),i.setMaterial(r)},e._setBackgroundColor=function(e){var i=function(e){if(!e||"#"!==e[0]){if(e&&"function"==typeof e.isKindOfClass&&e.isKindOfClass(NSColor))return e;throw new Error("Incorrect color formating. It should be an hex color: #RRGGBBAA")}var t,n=e.substr(1);if(3===n.length?n+="F":6===n.length&&(n+="FF"),4===n.length)for(var i=0;i<4;i+=1)t+=n[i],t+=n[i];else{if(8!==n.length)return NSColor.whiteColor();t=n}var o=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),s=parseInt(t.slice(4,6),16),a=parseInt(t.slice(6,8),16);return NSColor.colorWithSRGBRed_green_blue_alpha(o,r,s,a)}(e);n.setValue_forKey(!1,"drawsBackground"),t.backgroundColor=i},e._invalidate=function(){t.flushWindow(),t.contentView().setNeedsDisplay(!0)},e._setStyleMask=function(n,i){var o=e.isMaximizable();n?t.setStyleMask(t.styleMask()|i):t.setStyleMask(t.styleMask()&~i),e.setMaximizable(o)},e._setCollectionBehavior=function(n,i){var o=e.isMaximizable();n?t.setCollectionBehavior(t.collectionBehavior()|i):t.setCollectionBehavior(t.collectionBehavior()&~i),e.setMaximizable(o)},e._showWindowButton=function(e){var n=t.standardWindowButton(e);n.superview().addSubview_positioned_relative(n,NSWindowAbove,null)}}},"./node_modules/sketch-module-web-view/lib/constants.js": 34 | /*!**************************************************************!*\ 35 | !*** ./node_modules/sketch-module-web-view/lib/constants.js ***! 36 | \**************************************************************/ 37 | /*! no static exports found */function(e,t){e.exports={JS_BRIDGE:"__skpm_sketchBridge",JS_BRIDGE_RESULT_SUCCESS:"__skpm_sketchBridge_success",JS_BRIDGE_RESULT_ERROR:"__skpm_sketchBridge_error",START_MOVING_WINDOW:"__skpm_startMovingWindow",EXECUTE_JAVASCRIPT:"__skpm_executeJS",EXECUTE_JAVASCRIPT_SUCCESS:"__skpm_executeJS_success_",EXECUTE_JAVASCRIPT_ERROR:"__skpm_executeJS_error_"}},"./node_modules/sketch-module-web-view/lib/dispatch-first-click.js": 38 | /*!*************************************************************************!*\ 39 | !*** ./node_modules/sketch-module-web-view/lib/dispatch-first-click.js ***! 40 | \*************************************************************************/ 41 | /*! no static exports found */function(e,t){e.exports=function(e,t){var n=e.convertPoint_fromView(t.locationInWindow(),null);return"var el = document.elementFromPoint("+n.x+", "+n.y+'); if (el && el.tagName === "SELECT") { var event = document.createEvent("MouseEvents"); event.initMouseEvent("mousedown", true, true, window); el.dispatchEvent(event);} else if (el && ["text", "textarea", "date", "datetime-local", "email", "number", "month", "password", "search", "tel", "time", "url", "week" ].indexOf(el.type) >= 0 && el.focus) {el.focus();} else if (el) {el.dispatchEvent(new Event("click", {bubbles: true}))}'}},"./node_modules/sketch-module-web-view/lib/execute-javascript.js": 42 | /*!***********************************************************************!*\ 43 | !*** ./node_modules/sketch-module-web-view/lib/execute-javascript.js ***! 44 | \***********************************************************************/ 45 | /*! no static exports found */function(e,t,n){(function(t){var i=n(/*! ./constants */"./node_modules/sketch-module-web-view/lib/constants.js");e.exports=function(n,o){return function r(s,a,u){"function"==typeof a&&(u=a,a=!1);var l=coscript.createFiber();return n.navigationDelegate().state&&0==n.navigationDelegate().state.wasReady?new t(function(e,t){o.once("ready-to-show",function(){r(s,a,u).then(e).catch(t),l.cleanup()})}):new t(function(t,r){var a=Math.random();o.webContents.on(i.EXECUTE_JAVASCRIPT_SUCCESS+a,function(e){try{u&&u(null,e),t(e)}catch(e){r(e)}l.cleanup()}),o.webContents.on(i.EXECUTE_JAVASCRIPT_ERROR+a,function(e){try{u?(u(e),t()):r(e)}catch(e){r(e)}l.cleanup()}),n.evaluateJavaScript_completionHandler(e.exports.wrapScript(s,a),null)})}},e.exports.wrapScript=function(e,t){return"window."+i.EXECUTE_JAVASCRIPT+"("+t+", "+JSON.stringify(e)+")"},e.exports.injectScript=function(e){var t="window."+i.EXECUTE_JAVASCRIPT+' = function(id, script) { try { var res = eval(script); if (res && typeof res.then === "function" && typeof res.catch === "function") { res.then(function (res2) { window.postMessage("'+i.EXECUTE_JAVASCRIPT_SUCCESS+'" + id, res2); }) .catch(function (err) { window.postMessage("'+i.EXECUTE_JAVASCRIPT_ERROR+'" + id, err); }) } else { window.postMessage("'+i.EXECUTE_JAVASCRIPT_SUCCESS+'" + id, res); } } catch (err) { window.postMessage("'+i.EXECUTE_JAVASCRIPT_ERROR+'" + id, err); }}',n=WKUserScript.alloc().initWithSource_injectionTime_forMainFrameOnly(t,0,!0);e.configuration().userContentController().addUserScript(n)}}).call(this,n(/*! ./node_modules/promise-polyfill/lib/index.js */"./node_modules/promise-polyfill/lib/index.js"))},"./node_modules/sketch-module-web-view/lib/fitSubview.js": 46 | /*!***************************************************************!*\ 47 | !*** ./node_modules/sketch-module-web-view/lib/fitSubview.js ***! 48 | \***************************************************************/ 49 | /*! no static exports found */function(e,t){function n(e,t,n,i){n.addConstraint(NSLayoutConstraint.constraintWithItem_attribute_relatedBy_toItem_attribute_multiplier_constant(t,e,NSLayoutRelationEqual,n,e,1,i))}e.exports=function(e,t,i){i=i||[],e.setTranslatesAutoresizingMaskIntoConstraints(!1),n(NSLayoutAttributeLeft,e,t,i[0]||0),n(NSLayoutAttributeTop,e,t,i[1]||0),n(NSLayoutAttributeRight,e,t,i[2]||0),n(NSLayoutAttributeBottom,e,t,i[3]||0)}},"./node_modules/sketch-module-web-view/lib/index.js": 50 | /*!**********************************************************!*\ 51 | !*** ./node_modules/sketch-module-web-view/lib/index.js ***! 52 | \**********************************************************/ 53 | /*! no static exports found */function(e,t,n){var i=n(/*! events */"events"),o=n(/*! ./browser-api */"./node_modules/sketch-module-web-view/lib/browser-api.js"),r=n(/*! ./webview-api */"./node_modules/sketch-module-web-view/lib/webview-api.js"),s=n(/*! ./fitSubview */"./node_modules/sketch-module-web-view/lib/fitSubview.js"),a=n(/*! ./dispatch-first-click */"./node_modules/sketch-module-web-view/lib/dispatch-first-click.js"),u=n(/*! ./inject-client-messaging */"./node_modules/sketch-module-web-view/lib/inject-client-messaging.js"),l=n(/*! ./movable-area */"./node_modules/sketch-module-web-view/lib/movable-area.js"),c=n(/*! ./execute-javascript */"./node_modules/sketch-module-web-view/lib/execute-javascript.js"),d=n(/*! ./set-delegates */"./node_modules/sketch-module-web-view/lib/set-delegates.js");function f(e){var t=(e=e||{}).identifier||NSUUID.UUID().UUIDString(),n=NSThread.mainThread().threadDictionary(),m=f.fromId(t);if(m)return m;var h=new i;if(h.id=t,e.modal&&!e.parent)throw new Error("A modal needs to have a parent.");var p=coscript.createFiber(),w=e.width||800,v=e.height||600,S=NSScreen.screens().firstObject().frame(),g=NSMakeRect(void 0!==e.x?e.x:Math.round((NSWidth(S)-w)/2),void 0!==e.y?NSHeight(S)-e.y:Math.round((NSHeight(S)-v)/2),w,v);e.titleBarStyle&&"default"!==e.titleBarStyle&&(e.frame=!1);var b="textured"!==e.windowType,_=NSTitledWindowMask;!1!==e.minimizable&&(_|=NSMiniaturizableWindowMask),!1!==e.closable&&(_|=NSClosableWindowMask),!1!==e.resizable&&(_|=NSResizableWindowMask),b&&!e.transparent&&!1!==e.frame||(_|=NSTexturedBackgroundWindowMask);var y=NSPanel.alloc().initWithContentRect_styleMask_backing_defer(g,_,NSBackingStoreBuffered,!0),k=WKWebViewConfiguration.alloc().init(),N=WKWebView.alloc().initWithFrame_configuration(CGRectMake(0,0,e.width||800,e.height||600),k);if(u(N),N.setAutoresizingMask(NSViewWidthSizable|NSViewHeightSizable),o(h,y,N),r(h,y,N),d(h,y,N,e),"desktop"===e.windowType&&(y.setLevel(kCGDesktopWindowLevel-1),y.setCollectionBehavior(NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorStationary|NSWindowCollectionBehaviorIgnoresCycle)),void 0===e.minWidth&&void 0===e.minHeight||h.setMinimumSize(e.minWidth||0,e.minHeight||0),void 0===e.maxWidth&&void 0===e.maxHeight||h.setMaximumSize(e.maxWidth||1e4,e.maxHeight||1e4),e.transparent||!1===e.frame){y.titlebarAppearsTransparent=!0,y.titleVisibility=NSWindowTitleHidden,y.setOpaque(0),y.isMovableByWindowBackground=!0;var C=NSToolbar.alloc().initWithIdentifier("titlebarStylingToolbar");C.setShowsBaselineSeparator(!1),y.setToolbar(C)}if("hiddenInset"===e.titleBarStyle){var M=NSToolbar.alloc().initWithIdentifier("titlebarStylingToolbar");M.setShowsBaselineSeparator(!1),y.setToolbar(M)}!1!==e.frame&&e.useContentSize||h.setSize(w,v),e.center&&h.center(),e.alwaysOnTop&&h.setAlwaysOnTop(!0),e.fullscreen&&h.setFullScreen(!0),h.setFullScreenable(!!e.fullscreenable);let E=e.title;!1===e.frame?E=void 0:void 0===E&&"undefined"!=typeof __command&&__command.pluginBundle()&&(E=__command.pluginBundle().name()),E&&h.setTitle(E);var R=e.backgroundColor;e.transparent&&(R=NSColor.clearColor()),!R&&!1===e.frame&&e.vibrancy&&(R=NSColor.clearColor()),h._setBackgroundColor(R||NSColor.windowBackgroundColor()),!1===e.hasShadow&&h.setHasShadow(!1),void 0!==e.opacity&&h.setOpacity(e.opacity),e.webPreferences=e.webPreferences||{},N.configuration().preferences().setValue_forKey(!1!==e.webPreferences.devTools,"developerExtrasEnabled"),N.configuration().preferences().setValue_forKey(!1!==e.webPreferences.javascript,"javaScriptEnabled"),N.configuration().preferences().setValue_forKey(!!e.webPreferences.plugins,"plugInsEnabled"),N.configuration().preferences().setValue_forKey(e.webPreferences.minimumFontSize||0,"minimumFontSize"),e.webPreferences.zoomFactor&&N.setMagnification(e.webPreferences.zoomFactor);var W=y.contentView();return!1!==e.frame?(N.setFrame(W.bounds()),W.addSubview(N)):(W.setAutoresizingMask(NSViewWidthSizable|NSViewHeightSizable),s(W,W.superview()),N.setFrame(W.bounds()),W.addSubview(N),y.standardWindowButton(NSWindowFullScreenButton)&&y.standardWindowButton(NSWindowFullScreenButton).setHidden(!0),e.titleBarStyle&&"default"!==e.titleBarStyle||(y.standardWindowButton(NSWindowZoomButton).setHidden(!0),y.standardWindowButton(NSWindowMiniaturizeButton).setHidden(!0),y.standardWindowButton(NSWindowCloseButton).setHidden(!0),y.standardWindowButton(NSWindowZoomButton).setEnabled(!1))),e.vibrancy&&h.setVibrancy(e.vibrancy),h.setMaximizable(!1!==e.maximizable),y.setHidesOnDeactivate(!1!==e.hidesOnDeactivate),e.remembersWindowFrame&&(y.setFrameAutosaveName(t),y.setFrameUsingName_force(y.frameAutosaveName(),!1)),e.acceptsFirstMouse&&h.on("focus",function(e){e.type()===NSEventTypeLeftMouseDown&&h.webContents.executeJavaScript(a(N,e)).catch(()=>{})}),c.injectScript(N),l.injectScript(N),l.setupHandler(h),!1!==e.show&&h.show(),h.on("closed",function(){h._destroyed=!0,n.removeObjectForKey(t);var e=n[t+".themeObserver"];e&&(NSApplication.sharedApplication().removeObserver_forKeyPath(e,"effectiveAppearance"),n.removeObjectForKey(t+".themeObserver")),p.cleanup()}),n[t]=y,p.onCleanup(function(){h._destroyed||h.destroy()}),h}f.fromId=function(e){var t=NSThread.mainThread().threadDictionary();if(t[e])return f.fromPanel(t[e],e)},f.fromPanel=function(e,t){var n=new i;if(n.id=t,!e||!e.contentView)throw new Error("needs to pass an NSPanel");for(var s=null,a=e.contentView().subviews(),u=0;ue)n.loadRequest(NSURLRequest.requestWithURL(i[e]));else{var r=t.forwardList();if(!(r.count()>e-o))throw new Error("Cannot go to index "+e);n.loadRequest(NSURLRequest.requestWithURL(r[e-o]))}},r.goToOffset=function(e){if(!r.canGoToOffset(e))throw new Error("Cannot go to offset "+e);n.loadRequest(NSURLRequest.requestWithURL(n.backForwardList().itemAtIndex(e)))},r.isCrashed=function(){console.warn("Not implemented yet, please open a PR on https://github.com/skpm/sketch-module-web-view :)")},r.setUserAgent=function(){console.warn("Not implemented yet, please open a PR on https://github.com/skpm/sketch-module-web-view :)")},r.getUserAgent=function(){const e=n.customUserAgent();return e?String(e):void 0},r.insertCSS=function(e){var t="var style = document.createElement('style'); style.innerHTML = "+e.replace(/"/,'\\"')+"; document.head.appendChild(style);",i=WKUserScript.alloc().initWithSource_injectionTime_forMainFrameOnly(t,0,!0);n.configuration().userContentController().addUserScript(i)},r.insertJS=function(e){var t=WKUserScript.alloc().initWithSource_injectionTime_forMainFrameOnly(e,0,!0);n.configuration().userContentController().addUserScript(t)},r.executeJavaScript=o(n,e),r.setIgnoreMenuShortcuts=function(){console.warn("Not implemented yet, please open a PR on https://github.com/skpm/sketch-module-web-view :)")},r.setAudioMuted=function(){console.warn("Not implemented yet, please open a PR on https://github.com/skpm/sketch-module-web-view :)")},r.isAudioMuted=function(){console.warn("Not implemented yet, please open a PR on https://github.com/skpm/sketch-module-web-view :)")},r.setZoomFactor=function(e){n.setMagnification_centeredAtPoint(e,CGPointMake(0,0))},r.getZoomFactor=function(e){e(Number(n.magnification()))},r.setZoomLevel=function(e){r.setZoomFactor(Math.pow(1.2,e))},r.getZoomLevel=function(e){e(Math.log(Number(n.magnification()))/Math.log(1.2))},r.setVisualZoomLevelLimits=function(){console.warn("Not implemented yet, please open a PR on https://github.com/skpm/sketch-module-web-view :)")},r.setLayoutZoomLevelLimits=function(){console.warn("Not implemented yet, please open a PR on https://github.com/skpm/sketch-module-web-view :)")},r.send=function(){const e="window.postMessage({isSketchMessage: true,origin: '"+String(__command.identifier())+"',args: "+JSON.stringify([].slice.call(arguments))+'}, "*")';n.evaluateJavaScript_completionHandler(e,null)},r.getNativeWebview=function(){return n},e.webContents=r}},"./src/sketch/showSettings.js": 74 | /*!************************************!*\ 75 | !*** ./src/sketch/showSettings.js ***! 76 | \************************************/ 77 | /*! exports provided: showSettings */function(e,t,n){"use strict";n.r(t),n.d(t,"showSettings",function(){return a});var i=n(/*! sketch-module-web-view */"./node_modules/sketch-module-web-view/lib/index.js"),o=n.n(i),r=n(/*! ./utilities/utilities */"./src/sketch/utilities/utilities.js"),s=n(/*! ./utilities/constants */"./src/sketch/utilities/constants.js"),a=function(){var e=new o.a({identifier:"reselect",frame:!1,height:464,width:332,resizable:!1,alwaysOnTop:!0,title:"reselect",backgroundColor:"#000000",show:!1}),t=e.webContents;e.once("ready-to-show",function(){e.show()}),t.on("did-finish-load",function(){var e={reselectAmount:r.loadPluginSetting(s.SETTINGS_PLUGIN_RESELECTAMOUNT)||10};t.executeJavaScript("prepareFirstLoad('".concat(JSON.stringify(e),"')")).catch(console.error)}),t.on("dismissClicked",function(){e.close()}),t.on("websiteButtonClicked",function(){r.openURL(s.URL_WEBSITE)}),t.on("helpButtonClicked",function(){r.openURL(s.URL_HELP)}),t.on("versionButtonClicked",function(){r.openURL(s.URL_CHANGELOG)}),t.on("saveButtonClicked",function(e){var t=JSON.parse(e);r.savePluginSetting(s.SETTINGS_PLUGIN_RESELECTAMOUNT,+t.reselectAmount),r.showToast("Reselect settings saved successfully!")}),e.loadURL(n(/*! ../web/ui.html */"./src/web/ui.html"))}},"./src/sketch/utilities/constants.js": 78 | /*!*******************************************!*\ 79 | !*** ./src/sketch/utilities/constants.js ***! 80 | \*******************************************/ 81 | /*! exports provided: SETTINGS_PLUGIN_RESELECTAMOUNT, URL_WEBSITE, URL_HELP, URL_CHANGELOG */function(e,t,n){"use strict";n.r(t),n.d(t,"SETTINGS_PLUGIN_RESELECTAMOUNT",function(){return i}),n.d(t,"URL_WEBSITE",function(){return o}),n.d(t,"URL_HELP",function(){return r}),n.d(t,"URL_CHANGELOG",function(){return s});var i="amount",o="http://www.reselect.co/",r="http://www.reselect.co/",s="https://github.com/mfouquet/Reselect/releases"},"./src/sketch/utilities/utilities.js": 82 | /*!*******************************************!*\ 83 | !*** ./src/sketch/utilities/utilities.js ***! 84 | \*******************************************/ 85 | /*! exports provided: saveGlobalSetting, loadGlobalSetting, savePluginSetting, loadPluginSetting, saveSessionVariable, loadSessionVariable, openURL, showToast */function(e,t,n){"use strict";n.r(t),n.d(t,"saveGlobalSetting",function(){return a}),n.d(t,"loadGlobalSetting",function(){return u}),n.d(t,"savePluginSetting",function(){return l}),n.d(t,"loadPluginSetting",function(){return c}),n.d(t,"saveSessionVariable",function(){return d}),n.d(t,"loadSessionVariable",function(){return f}),n.d(t,"openURL",function(){return m}),n.d(t,"showToast",function(){return h});var i=n(/*! sketch/settings */"sketch/settings"),o=n.n(i),r=n(/*! sketch/ui */"sketch/ui"),s=n.n(r),a=function(e,t){o.a.setGlobalSettingForKey(e,t)},u=function(e){return o.a.globalSettingForKey(e)},l=function(e,t){o.a.setSettingForKey("com.mfouquet.sketch.reselect.".concat(e),t)},c=function(e){return o.a.settingForKey("com.mfouquet.sketch.reselect.".concat(e))},d=function(e,t){o.a.setSessionVariable("com.mfouquet.sketch.reselect.".concat(e),t)},f=function(e){return o.a.sessionVariable("com.mfouquet.sketch.reselect.".concat(e))},m=function(e){var t=NSURL.URLWithString(e);NSWorkspace.sharedWorkspace().openURL(t)},h=function(e){s.a.message(e)}},"./src/web/ui.html": 86 | /*!*************************!*\ 87 | !*** ./src/web/ui.html ***! 88 | \*************************/ 89 | /*! no static exports found */function(e,t){e.exports="file://"+context.plugin.urlForResourceNamed("_webpack_resources/121b71ba0ff9335035decac87f069831.html").path()},events: 90 | /*!*************************!*\ 91 | !*** external "events" ***! 92 | \*************************/ 93 | /*! no static exports found */function(e,t){e.exports=require("events")},"sketch/settings": 94 | /*!**********************************!*\ 95 | !*** external "sketch/settings" ***! 96 | \**********************************/ 97 | /*! no static exports found */function(e,t){e.exports=require("sketch/settings")},"sketch/ui": 98 | /*!****************************!*\ 99 | !*** external "sketch/ui" ***! 100 | \****************************/ 101 | /*! no static exports found */function(e,t){e.exports=require("sketch/ui")}});"default"===key&&"function"==typeof exports?exports(context):exports[key](context)}that.showSettings=__skpm_run.bind(this,"showSettings"),that.onRun=__skpm_run.bind(this,"default"); -------------------------------------------------------------------------------- /appcast.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Reselect 5 | https://raw.githubusercontent.com/mfouquet/Reselect/main/appcast.xml 6 | Quickly reselect a previous selection and save selections for later use. 7 | en 8 | 9 | Version 2.1.0 10 | 11 | 13 |
  • Complete rewrite of plugin to get it working with latest versions of Sketch.
  • 14 | 15 | ]]> 16 |
    17 | Sat, 11 Jul 2020 08:00:00 +0000 18 | 19 |
    20 | 21 | Version 2.0 22 | 23 | 25 |
  • New UI.
  • 26 |
  • Add ability to delete selections.
  • 27 |
  • Bug fixes and performance improvements.
  • 28 | 29 | ]]> 30 |
    31 | Sun, 04 Mar 2017 11:49:11 +0000 32 | 33 |
    34 | 35 | Version 1.0 36 | 37 | 39 |
  • First release.
  • 40 | 41 | ]]> 42 |
    43 | Sun, 04 Mar 2017 11:58:00 +0000 44 | 45 |
    46 |
    47 |
    48 | -------------------------------------------------------------------------------- /banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfouquet/Reselect/47126d1044dafd06f7a5a8a1d782ddc3ef03d808/banner.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "reselect", 3 | "version": "1.0.0", 4 | "description": "Restore a previous selection.", 5 | "main": "index.js", 6 | "engines": { 7 | "sketch": ">=3.0" 8 | }, 9 | "skpm": { 10 | "name": "Reselect", 11 | "manifest": "src/sketch/manifest.json", 12 | "main": "Reselect.sketchplugin", 13 | "assets": [ 14 | "src/images/**/*" 15 | ] 16 | }, 17 | "scripts": { 18 | "build": "rimraf Reselect.sketchplugin && skpm-build", 19 | "watch": "skpm-build --watch", 20 | "start": "skpm-build --watch --run", 21 | "postinstall": "npm run build && skpm-link" 22 | }, 23 | "resources": [ 24 | "src/web/ui.js" 25 | ], 26 | "devDependencies": { 27 | "@skpm/builder": "^0.5.11", 28 | "@skpm/extract-loader": "^2.0.2", 29 | "@skpm/fs": "^0.2.2", 30 | "@skpm/path": "^0.1.4", 31 | "@skpm/process": "^0.1.4", 32 | "@types/node": "^12.7.1", 33 | "@types/react": "^16.9.1", 34 | "@types/react-dom": "^16.8.5", 35 | "babel-core": "^6.26.3", 36 | "babel-loader": "^8.0.5", 37 | "babel-plugin-transform-react-jsx": "^6.24.1", 38 | "css-loader": "^2.1.0", 39 | "html-loader": "^0.5.5", 40 | "html-webpack-inline-source-plugin": "0.0.10", 41 | "html-webpack-plugin": "^3.2.0", 42 | "prettier": "^1.15.3", 43 | "react": "16.9.0", 44 | "react-dom": "16.9.0", 45 | "style-loader": "^0.23.1", 46 | "ts-loader": "^6.0.4", 47 | "typescript": "^3.5.3", 48 | "url-loader": "^2.1.0", 49 | "webpack": "^4.28.4", 50 | "webpack-cli": "^3.2.1" 51 | }, 52 | "dependencies": { 53 | "sketch-module-web-view": "^3.2.1" 54 | }, 55 | "repository": { 56 | "type": "git", 57 | "url": "git+https://github.com/mfouquet/Reselect.git" 58 | }, 59 | "author": "Michael Fouquet", 60 | "license": "ISC", 61 | "bugs": { 62 | "url": "https://github.com/mfouquet/Reselect/issues" 63 | }, 64 | "homepage": "http://www.reselect.co" 65 | } 66 | -------------------------------------------------------------------------------- /src/images/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfouquet/Reselect/47126d1044dafd06f7a5a8a1d782ddc3ef03d808/src/images/bg.png -------------------------------------------------------------------------------- /src/images/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfouquet/Reselect/47126d1044dafd06f7a5a8a1d782ddc3ef03d808/src/images/delete.png -------------------------------------------------------------------------------- /src/images/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfouquet/Reselect/47126d1044dafd06f7a5a8a1d782ddc3ef03d808/src/images/header.png -------------------------------------------------------------------------------- /src/images/load.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfouquet/Reselect/47126d1044dafd06f7a5a8a1d782ddc3ef03d808/src/images/load.png -------------------------------------------------------------------------------- /src/images/reselect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfouquet/Reselect/47126d1044dafd06f7a5a8a1d782ddc3ef03d808/src/images/reselect.png -------------------------------------------------------------------------------- /src/images/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfouquet/Reselect/47126d1044dafd06f7a5a8a1d782ddc3ef03d808/src/images/save.png -------------------------------------------------------------------------------- /src/images/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfouquet/Reselect/47126d1044dafd06f7a5a8a1d782ddc3ef03d808/src/images/settings.png -------------------------------------------------------------------------------- /src/sketch/deleteSelection.js: -------------------------------------------------------------------------------- 1 | import DOM from "sketch/dom"; 2 | import UI from "sketch/ui"; 3 | import fs from "@skpm/fs"; 4 | import path from "@skpm/path"; 5 | import * as utils from "./utilities/utilities"; 6 | 7 | const deleteSelection = () => { 8 | const document = DOM.getSelectedDocument(); 9 | const documentId = document.id; 10 | 11 | const scriptPath = path.resolve(".."); 12 | const documentFilePath = `${scriptPath}/selections/${documentId}.txt`; 13 | 14 | if (fs.existsSync(documentFilePath)) { 15 | const data = fs.readFileSync(documentFilePath); 16 | const documentFile = JSON.parse(data); 17 | 18 | let options = []; 19 | for (let i = 0; i < documentFile.selectionsArray.length; i++) { 20 | options.push(documentFile.selectionsArray[i].selectionName); 21 | } 22 | 23 | UI.getInputFromUser( 24 | "Choose a selection to delete", 25 | { 26 | type: UI.INPUT_TYPE.selection, 27 | possibleValues: options, 28 | }, 29 | (err, value) => { 30 | if (err) return; 31 | 32 | for (let i = 0; i < documentFile.selectionsArray.length; i++) { 33 | if (value === documentFile.selectionsArray[i].selectionName) { 34 | documentFile.selectionsArray.splice(i, 1); 35 | } 36 | } 37 | 38 | if (documentFile.selectionsArray.length === 0) { 39 | fs.unlinkSync(documentFilePath); 40 | } else { 41 | fs.writeFileSync(documentFilePath, JSON.stringify(documentFile)); 42 | } 43 | } 44 | ); 45 | } else { 46 | utils.showToast("There are no selections saved for this document."); 47 | } 48 | }; 49 | 50 | export { deleteSelection }; 51 | -------------------------------------------------------------------------------- /src/sketch/loadSelection.js: -------------------------------------------------------------------------------- 1 | import DOM from "sketch/dom"; 2 | import UI from "sketch/ui"; 3 | import fs from "@skpm/fs"; 4 | import path from "@skpm/path"; 5 | import * as utils from "./utilities/utilities"; 6 | 7 | const loadSelection = () => { 8 | const document = DOM.getSelectedDocument(); 9 | const documentId = document.id; 10 | 11 | const scriptPath = path.resolve(".."); 12 | const documentFilePath = `${scriptPath}/selections/${documentId}.txt`; 13 | 14 | if (fs.existsSync(documentFilePath)) { 15 | const data = fs.readFileSync(documentFilePath); 16 | const documentFile = JSON.parse(data); 17 | 18 | let options = []; 19 | for (let i = 0; i < documentFile.selectionsArray.length; i++) { 20 | options.push(documentFile.selectionsArray[i].selectionName); 21 | } 22 | 23 | UI.getInputFromUser( 24 | "Choose a selection to load", 25 | { 26 | type: UI.INPUT_TYPE.selection, 27 | possibleValues: options, 28 | }, 29 | (err, value) => { 30 | if (err) return; 31 | 32 | let selectedSelection; 33 | for (let i = 0; i < documentFile.selectionsArray.length; i++) { 34 | if (value === documentFile.selectionsArray[i].selectionName) { 35 | selectedSelection = documentFile.selectionsArray[i].selection; 36 | } 37 | } 38 | 39 | const selectedLayers = document.selectedLayers; 40 | selectedLayers.clear(); 41 | 42 | for (let i = 0; i < selectedSelection.length; i++) { 43 | const layer = document.getLayerWithID(selectedSelection[i]); 44 | layer.selected = true; 45 | } 46 | } 47 | ); 48 | } else { 49 | utils.showToast("There are no selections saved for this document."); 50 | } 51 | }; 52 | 53 | export { loadSelection }; 54 | -------------------------------------------------------------------------------- /src/sketch/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Reselect", 3 | "description": "Restore a previous selection or save selections for later use.", 4 | "version": "2.1.0", 5 | "identifier": "com.mfouquet.sketch.reselect", 6 | "author ": "Michael Fouquet", 7 | "authorEmail": "michael.fouquet@me.com", 8 | "appcast": "https://raw.githubusercontent.com/mfouquet/Reselect/main/appcast.xml", 9 | "compatibleVersion": 4.1, 10 | "bundleVersion": 1, 11 | "disableCocoaScriptPreprocessor": true, 12 | "commands": [ 13 | { 14 | "script": "selectionChanged.js", 15 | "handlers": { 16 | "actions": { 17 | "SelectionChanged.finish": "selectionChanged" 18 | } 19 | } 20 | }, 21 | { 22 | "identifier": "restorePreviousSelection", 23 | "script": "restorePreviousSelection.js", 24 | "handler": "restorePreviousSelection", 25 | "shortcut": "ctrl alt \\", 26 | "description": "Reselects your previous selection.", 27 | "icon": "images/reselect.png", 28 | "name": "Reselect Previous" 29 | }, 30 | { 31 | "identifier": "saveCurrentSelection", 32 | "script": "saveCurrentSelection.js", 33 | "handler": "saveCurrentSelection", 34 | "description": "Save your current selection for access later.", 35 | "icon": "images/save.png", 36 | "name": "Save Current Selection" 37 | }, 38 | { 39 | "identifier": "loadSelection", 40 | "script": "loadSelection.js", 41 | "handler": "loadSelection", 42 | "shortcut": "ctrl alt ]", 43 | "description": "Load a selection for the current document.", 44 | "icon": "images/load.png", 45 | "name": "Load Selection" 46 | }, 47 | { 48 | "identifier": "deleteSelection", 49 | "script": "deleteSelection.js", 50 | "handler": "deleteSelection", 51 | "description": "Delete a saved selection from the current document.", 52 | "icon": "images/delete.png", 53 | "name": "Delete Selection" 54 | }, 55 | { 56 | "identifier": "showSettings", 57 | "script": "showSettings.js", 58 | "handler": "showSettings", 59 | "description": "Change your max selections stored and learn more about Reselect.", 60 | "icon": "images/settings.png", 61 | "name": "Settings" 62 | } 63 | ], 64 | "menu": { 65 | "title": "Reselect", 66 | "items": [ 67 | "restorePreviousSelection", 68 | "-", 69 | "saveCurrentSelection", 70 | "loadSelection", 71 | "-", 72 | "deleteSelection", 73 | "showSettings" 74 | ] 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/sketch/restorePreviousSelection.js: -------------------------------------------------------------------------------- 1 | import DOM from "sketch/dom"; 2 | import * as utils from "./utilities/utilities"; 3 | 4 | const restorePreviousSelection = () => { 5 | const document = DOM.getSelectedDocument(); 6 | const selectedLayers = document.selectedLayers; 7 | let selections = utils.loadSessionVariable("selections") || []; 8 | 9 | const lastSelection = selections.pop(); 10 | 11 | if (lastSelection) { 12 | selectedLayers.clear(); 13 | 14 | for (let i = 0; i < lastSelection.length; i++) { 15 | const layer = document.getLayerWithID(lastSelection[i]); 16 | layer.selected = true; 17 | } 18 | } 19 | 20 | utils.saveSessionVariable("selections", selections); 21 | utils.saveSessionVariable("hasReselected", true); 22 | }; 23 | 24 | export { restorePreviousSelection }; 25 | -------------------------------------------------------------------------------- /src/sketch/saveCurrentSelection.js: -------------------------------------------------------------------------------- 1 | import DOM from "sketch/dom"; 2 | import UI from "sketch/ui"; 3 | import fs from "@skpm/fs"; 4 | import path from "@skpm/path"; 5 | 6 | const saveCurrentSelection = () => { 7 | const document = DOM.getSelectedDocument(); 8 | const documentId = document.id; 9 | const selectedLayers = document.selectedLayers; 10 | 11 | const dialogInitialValue = `${selectedLayers.layers.length} ${ 12 | selectedLayers.layers.length === 1 ? "layer" : "layers" 13 | }`; 14 | 15 | UI.getInputFromUser( 16 | "Enter a name for this selection", 17 | { initialValue: dialogInitialValue }, 18 | (err, selectionName) => { 19 | if (err) return; 20 | 21 | let selectionIds = []; 22 | for (let i = 0; i < selectedLayers.layers.length; i++) { 23 | selectionIds.push(selectedLayers.layers[i].id); 24 | } 25 | 26 | const scriptPath = path.resolve(".."); 27 | const selectionsPath = `${scriptPath}/selections`; 28 | const documentFilePath = `${scriptPath}/selections/${documentId}.txt`; 29 | 30 | if (!fs.existsSync(selectionsPath)) { 31 | fs.mkdirSync(selectionsPath); 32 | } 33 | 34 | let documentFile; 35 | if (fs.existsSync(documentFilePath)) { 36 | const data = fs.readFileSync(documentFilePath); 37 | documentFile = JSON.parse(data); 38 | 39 | let fileToOverwriteIndex = -1; 40 | for (let i = 0; i < documentFile.selectionsArray.length; i++) { 41 | if (documentFile.selectionsArray[i].selectionName === selectionName) { 42 | fileToOverwriteIndex = i; 43 | } 44 | } 45 | 46 | if (fileToOverwriteIndex !== -1) { 47 | const alert = NSAlert.alloc().init(); 48 | alert.setMessageText("Warning"); 49 | alert.setInformativeText( 50 | "A selection with that name already exists for this document. Would you like to overwrite?" 51 | ); 52 | alert.addButtonWithTitle("Yes"); 53 | alert.addButtonWithTitle("No"); 54 | const responseCode = alert.runModal(); 55 | 56 | // If the user selects Yes (code 1000), pop it off the array. If the user selects 57 | // No, exit out - (they'll have to go back and resave with a new name) 58 | if (responseCode != "1000") { 59 | return; 60 | } else { 61 | documentFile.selectionsArray.splice(fileToOverwriteIndex, 1); 62 | } 63 | } 64 | } else { 65 | documentFile = { 66 | selectionsArray: [], 67 | }; 68 | } 69 | 70 | documentFile.selectionsArray.push({ 71 | selectionName: selectionName, 72 | selection: selectionIds, 73 | }); 74 | 75 | fs.writeFileSync(documentFilePath, JSON.stringify(documentFile)); 76 | } 77 | ); 78 | }; 79 | 80 | export { saveCurrentSelection }; 81 | -------------------------------------------------------------------------------- /src/sketch/selectionChanged.js: -------------------------------------------------------------------------------- 1 | import * as utils from "./utilities/utilities"; 2 | import { SETTINGS_PLUGIN_RESELECTAMOUNT } from "./utilities/constants"; 3 | 4 | const selectionChanged = (context) => { 5 | const hasReselected = utils.loadSessionVariable("hasReselected"); 6 | 7 | if (!hasReselected) { 8 | let selections = utils.loadSessionVariable("selections") || []; 9 | const reselectAmount = 10 | utils.loadPluginSetting(SETTINGS_PLUGIN_RESELECTAMOUNT) || 10; 11 | const previousSelection = context.actionContext.oldSelection; 12 | 13 | if (previousSelection.length > 0) { 14 | let previousSelectionIds = []; 15 | for (let i = 0; i < previousSelection.length; i++) { 16 | previousSelectionIds.push(previousSelection[i].objectID()); 17 | } 18 | 19 | selections.push(previousSelectionIds); 20 | 21 | if (selections.length > reselectAmount) { 22 | selections.shift(); 23 | } 24 | 25 | utils.saveSessionVariable("selections", selections); 26 | } 27 | } else { 28 | utils.saveSessionVariable("hasReselected", false); 29 | } 30 | }; 31 | 32 | export { selectionChanged }; 33 | -------------------------------------------------------------------------------- /src/sketch/showSettings.js: -------------------------------------------------------------------------------- 1 | import BrowserWindow from "sketch-module-web-view"; 2 | import * as utils from "./utilities/utilities"; 3 | import { 4 | SETTINGS_PLUGIN_RESELECTAMOUNT, 5 | URL_WEBSITE, 6 | URL_HELP, 7 | URL_CHANGELOG, 8 | } from "./utilities/constants"; 9 | 10 | const showSettings = () => { 11 | const options = { 12 | identifier: "reselect", 13 | frame: false, 14 | height: 464, 15 | width: 332, 16 | resizable: false, 17 | alwaysOnTop: true, 18 | title: "reselect", 19 | backgroundColor: "#000000", 20 | show: false, 21 | }; 22 | 23 | const browserWindow = new BrowserWindow(options); 24 | const webContents = browserWindow.webContents; 25 | 26 | browserWindow.once("ready-to-show", () => { 27 | browserWindow.show(); 28 | }); 29 | 30 | webContents.on("did-finish-load", () => { 31 | const resObject = { 32 | reselectAmount: 33 | utils.loadPluginSetting(SETTINGS_PLUGIN_RESELECTAMOUNT) || 10, 34 | }; 35 | webContents 36 | .executeJavaScript(`prepareFirstLoad('${JSON.stringify(resObject)}')`) 37 | .catch(console.error); 38 | }); 39 | 40 | webContents.on("dismissClicked", () => { 41 | browserWindow.close(); 42 | }); 43 | 44 | webContents.on("websiteButtonClicked", () => { 45 | utils.openURL(URL_WEBSITE); 46 | }); 47 | 48 | webContents.on("helpButtonClicked", () => { 49 | utils.openURL(URL_HELP); 50 | }); 51 | 52 | webContents.on("versionButtonClicked", () => { 53 | utils.openURL(URL_CHANGELOG); 54 | }); 55 | 56 | webContents.on("saveButtonClicked", (saveButtonClickedObject) => { 57 | const resObject = JSON.parse(saveButtonClickedObject); 58 | utils.savePluginSetting( 59 | SETTINGS_PLUGIN_RESELECTAMOUNT, 60 | +resObject.reselectAmount 61 | ); 62 | utils.showToast("Reselect settings saved successfully!"); 63 | }); 64 | 65 | browserWindow.loadURL(require("../web/ui.html")); 66 | }; 67 | 68 | export { showSettings }; 69 | -------------------------------------------------------------------------------- /src/sketch/utilities/constants.js: -------------------------------------------------------------------------------- 1 | const SETTINGS_PLUGIN_RESELECTAMOUNT = "amount"; 2 | 3 | const URL_WEBSITE = "http://www.reselect.co/"; 4 | const URL_HELP = "http://www.reselect.co/"; 5 | const URL_CHANGELOG = "https://github.com/mfouquet/Reselect/releases"; 6 | 7 | export { SETTINGS_PLUGIN_RESELECTAMOUNT, URL_WEBSITE, URL_HELP, URL_CHANGELOG }; 8 | -------------------------------------------------------------------------------- /src/sketch/utilities/utilities.js: -------------------------------------------------------------------------------- 1 | import Settings from "sketch/settings"; 2 | import UI from "sketch/ui"; 3 | 4 | /* 5 | Saves a global setting in Sketch to the provided key 6 | */ 7 | const saveGlobalSetting = (key, value) => { 8 | Settings.setGlobalSettingForKey(key, value); 9 | }; 10 | 11 | /* 12 | Loads a global setting in Sketch to the provided key 13 | */ 14 | const loadGlobalSetting = (key) => { 15 | return Settings.globalSettingForKey(key); 16 | }; 17 | 18 | /* 19 | Saves a plugin setting in Sketch to the provided key 20 | */ 21 | const savePluginSetting = (key, value) => { 22 | Settings.setSettingForKey(`com.mfouquet.sketch.reselect.${key}`, value); 23 | }; 24 | 25 | /* 26 | Loads a plugin setting in Sketch with the provided key 27 | */ 28 | const loadPluginSetting = (key) => { 29 | return Settings.settingForKey(`com.mfouquet.sketch.reselect.${key}`); 30 | }; 31 | 32 | /* 33 | Saves a session variable in Sketch to the provided key 34 | */ 35 | const saveSessionVariable = (key, value) => { 36 | Settings.setSessionVariable(`com.mfouquet.sketch.reselect.${key}`, value); 37 | }; 38 | 39 | /* 40 | Loads a session variable in Sketch with the provided key 41 | */ 42 | const loadSessionVariable = (key) => { 43 | return Settings.sessionVariable(`com.mfouquet.sketch.reselect.${key}`); 44 | }; 45 | 46 | /* 47 | Opens a URL from Sketch 48 | */ 49 | const openURL = (url) => { 50 | const nsurl = NSURL.URLWithString(url); 51 | NSWorkspace.sharedWorkspace().openURL(nsurl); 52 | }; 53 | 54 | /* 55 | Shows a message at the bottom of the Sketch window 56 | */ 57 | const showToast = (message) => { 58 | UI.message(message); 59 | }; 60 | 61 | export { 62 | saveGlobalSetting, 63 | loadGlobalSetting, 64 | savePluginSetting, 65 | loadPluginSetting, 66 | saveSessionVariable, 67 | loadSessionVariable, 68 | openURL, 69 | showToast, 70 | }; 71 | -------------------------------------------------------------------------------- /src/web/ui.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | background: url(../images/bg.png); 4 | background-size: contain; 5 | font-family: system-ui; 6 | height: 100vh; 7 | margin: 0; 8 | overflow: hidden; 9 | padding: 0; 10 | width: 100vw; 11 | } 12 | 13 | .dialog { 14 | align-items: center; 15 | display: flex; 16 | flex-direction: column; 17 | height: 100vh; 18 | justify-content: space-between; 19 | } 20 | 21 | .dismiss { 22 | color: rgba(237, 242, 244, 0.75); 23 | position: absolute; 24 | top: 4px; 25 | transition: color 0.15s ease-in-out; 26 | right: 8px; 27 | } 28 | 29 | .dismiss:focus, 30 | .dismiss:hover { 31 | color: rgba(237, 242, 244, 1); 32 | cursor: pointer; 33 | } 34 | 35 | header { 36 | background: url(../images/header.png); 37 | background-size: contain; 38 | height: 81px; 39 | margin-left: -16px; 40 | margin-top: 48px; 41 | width: 96px; 42 | } 43 | 44 | main { 45 | align-items: center; 46 | display: flex; 47 | flex-direction: column; 48 | margin-top: 32px; 49 | } 50 | 51 | h3 { 52 | color: rgba(255, 255, 255, 1); 53 | font-size: 16px; 54 | font-weight: 600; 55 | margin-bottom: 16px; 56 | margin-top: 0; 57 | } 58 | 59 | input { 60 | background-color: transparent; 61 | border: 1px solid rgba(255, 255, 255, 0.5); 62 | border-radius: 2px; 63 | color: rgba(255, 255, 255, 1); 64 | font-size: 24px; 65 | font-weight: 700; 66 | height: 30px; 67 | margin: 0; 68 | padding: 4px 8px; 69 | text-align: center; 70 | width: 28px; 71 | } 72 | 73 | input::-webkit-outer-spin-button, 74 | input::-webkit-inner-spin-button { 75 | -webkit-appearance: none; 76 | margin: 0; 77 | } 78 | 79 | p { 80 | color: rgba(255, 255, 255, 1); 81 | font-size: 10px; 82 | line-height: 14px; 83 | margin-top: 8px; 84 | text-align: center; 85 | } 86 | 87 | footer { 88 | margin-bottom: 24px; 89 | } 90 | 91 | button { 92 | background-color: transparent; 93 | border: 0; 94 | border-radius: 4px; 95 | box-shadow: none; 96 | color: rgba(237, 242, 244, 0.75); 97 | cursor: pointer; 98 | font-size: 14px; 99 | font-weight: 300; 100 | line-height: 1; 101 | margin: 0; 102 | padding: 8px; 103 | text-align: center; 104 | text-decoration: none; 105 | transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out; 106 | vertical-align: middle; 107 | -webkit-appearance: none; 108 | } 109 | 110 | button:not(.button--save):focus, 111 | button:not(.button--save):hover { 112 | background-color: rgba(255, 255, 255, 0.05); 113 | color: rgba(237, 242, 244, 1); 114 | } 115 | 116 | .button--save { 117 | background-color: #fbff12; 118 | color: #0c0f0a; 119 | font-size: 20px; 120 | font-weight: 900; 121 | height: 44px; 122 | margin-top: 24px; 123 | transition: transform 0.15s ease-in-out; 124 | width: 176px; 125 | } 126 | 127 | .button--save:focus, 128 | .button--save:hover { 129 | transform: scale(1.05); 130 | } 131 | 132 | .button--save:active { 133 | transform: scale(0.99); 134 | } 135 | 136 | .separator { 137 | color: rgba(237, 242, 244, 0.75); 138 | margin-top: -4px; 139 | padding: 0 8px; 140 | } 141 | -------------------------------------------------------------------------------- /src/web/ui.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Reselect 6 | 7 | 8 | 9 |
    10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/web/ui.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import { Plugin } from "./ui.tsx"; 4 | 5 | // Disable the context menu to have a more native feel 6 | if (process.env.NODE_ENV === "production") { 7 | document.addEventListener("contextmenu", (e) => e.preventDefault()); 8 | } 9 | 10 | window.prepareFirstLoad = (resObject) => { 11 | const jsonUiObject = JSON.parse(resObject); 12 | 13 | ReactDOM.render( 14 | , 15 | document.getElementById("react-page") 16 | ); 17 | }; 18 | -------------------------------------------------------------------------------- /src/web/ui.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import "./ui.css"; 3 | 4 | interface IProps { 5 | pluginMessage: { 6 | reselectAmount: string | number; 7 | }; 8 | } 9 | 10 | interface IState { 11 | reselectAmount: string | number; 12 | } 13 | 14 | export class Plugin extends React.Component { 15 | constructor(props) { 16 | super(props); 17 | this.state = { 18 | reselectAmount: this.props.pluginMessage.reselectAmount, 19 | }; 20 | 21 | this.handleDismissClick = this.handleDismissClick.bind(this); 22 | this.handleWebsiteClick = this.handleWebsiteClick.bind(this); 23 | this.handleHelpClick = this.handleHelpClick.bind(this); 24 | this.handleVersionClick = this.handleVersionClick.bind(this); 25 | this.handleAmountChange = this.handleAmountChange.bind(this); 26 | this.handleSaveClick = this.handleSaveClick.bind(this); 27 | } 28 | 29 | handleDismissClick = () => { 30 | window.postMessage("dismissClicked", ""); 31 | }; 32 | 33 | handleWebsiteClick = () => { 34 | window.postMessage("websiteButtonClicked", ""); 35 | }; 36 | 37 | handleHelpClick = () => { 38 | window.postMessage("helpButtonClicked", ""); 39 | }; 40 | 41 | handleVersionClick = () => { 42 | window.postMessage("versionButtonClicked", ""); 43 | }; 44 | 45 | handleAmountChange(e) { 46 | this.setState({ reselectAmount: e.target.value }); 47 | } 48 | 49 | handleSaveClick = () => { 50 | window.postMessage( 51 | "saveButtonClicked", 52 | JSON.stringify({ 53 | reselectAmount: this.state.reselectAmount, 54 | }) 55 | ); 56 | }; 57 | 58 | render() { 59 | const { reselectAmount } = this.state; 60 | return ( 61 |
    62 |
    63 | 70 | 77 | 84 | 85 |
    86 |
    87 |
    88 |

    Max Recent Selections Restored

    89 |
    90 | 96 |
    97 |

    Setting this too high can adversely affect performance

    98 | 101 |
    102 | 109 |
    110 | ); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "jsx": "react" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /webpack.skpm.config.js: -------------------------------------------------------------------------------- 1 | const webpack = require("webpack"); 2 | 3 | module.exports = (config) => { 4 | config.resolve.extensions = [".sketch.js", ".ts", ".tsx", ".js", ".jsx"]; 5 | config.module.rules.push({ 6 | test: /\.(html)$/, 7 | use: [ 8 | { 9 | loader: "@skpm/extract-loader", 10 | }, 11 | { 12 | loader: "html-loader", 13 | options: { 14 | attrs: ["img:src", "link:href"], 15 | interpolate: true, 16 | }, 17 | }, 18 | ], 19 | }); 20 | config.module.rules.push({ 21 | test: /\.jsx?$/, 22 | exclude: /node_modules/, 23 | loader: "babel-loader", 24 | options: { 25 | plugins: ["transform-react-jsx"], 26 | }, 27 | }); 28 | config.module.rules.push({ 29 | test: /\.tsx?$/, 30 | use: "ts-loader", 31 | exclude: /node_modules/, 32 | }); 33 | config.module.rules.push({ 34 | test: /\.(png|jpg)$/, 35 | use: "url-loader", 36 | exclude: /node_modules/, 37 | }); 38 | config.module.rules.push({ 39 | test: /\.(css)$/, 40 | use: [ 41 | { 42 | loader: "style-loader", 43 | }, 44 | { 45 | loader: "css-loader", 46 | }, 47 | ], 48 | }); 49 | 50 | config.plugins.push( 51 | new webpack.DefinePlugin({ 52 | "process.env": { 53 | NODE_ENV: JSON.stringify(process.env.NODE_ENV), 54 | }, 55 | }) 56 | ); 57 | }; 58 | --------------------------------------------------------------------------------