From 83d8b7417332bd2677ae98396e769b89d9189288 Mon Sep 17 00:00:00 2001 From: Roberto Martinez Date: Thu, 5 Mar 2020 12:42:39 -0500 Subject: [PATCH 1/3] Adapt the plugin to the new export which is an object and not an array anymore --- bundle.js | 2 +- src/plugin.js | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/bundle.js b/bundle.js index f414103..0ebb5e2 100644 --- a/bundle.js +++ b/bundle.js @@ -1 +1 @@ -"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var path=_interopDefault(require("path")),fs=_interopDefault(require("fs")),util=_interopDefault(require("util")),events=_interopDefault(require("events")),assert=_interopDefault(require("assert")),child_process=_interopDefault(require("child_process")),os=_interopDefault(require("os")),crypto=_interopDefault(require("crypto")),isWindows="win32"===process.platform,DEBUG=process.env.NODE_DEBUG&&/fs/.test(process.env.NODE_DEBUG);function rethrow(){var t;if(DEBUG){var e=new Error;t=function(t){t&&(e.message=t.message,r(t=e))}}else t=r;return t;function r(t){if(t){if(process.throwDeprecation)throw t;if(!process.noDeprecation){var e="fs: missing callback "+(t.stack||t.message);process.traceDeprecation?console.trace(e):console.error(e)}}}}function maybeCallback(t){return"function"==typeof t?t:rethrow()}var normalize=path.normalize;if(isWindows)var nextPartRe=/(.*?)(?:[\/\\]+|$)/g;else nextPartRe=/(.*?)(?:[\/]+|$)/g;if(isWindows)var splitRootRe=/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;else splitRootRe=/^[\/]*/;var realpathSync=function(t,e){if(t=path.resolve(t),e&&Object.prototype.hasOwnProperty.call(e,t))return e[t];var r,n,i,o,s=t,a={},c={};function h(){var e=splitRootRe.exec(t);r=e[0].length,n=e[0],i=e[0],o="",isWindows&&!c[i]&&(fs.lstatSync(i),c[i]=!0)}for(h();r=t.length)return e&&(e[a]=t),r(null,t);nextPartRe.lastIndex=n;var c=nextPartRe.exec(t);return s=i,i+=c[0],o=s+c[1],n=nextPartRe.lastIndex,h[o]||e&&e[o]===o?process.nextTick(p):e&&Object.prototype.hasOwnProperty.call(e,o)?m(e[o]):fs.lstat(o,u)}function u(t,n){if(t)return r(t);if(!n.isSymbolicLink())return h[o]=!0,e&&(e[o]=o),process.nextTick(p);if(!isWindows){var i=n.dev.toString(32)+":"+n.ino.toString(32);if(c.hasOwnProperty(i))return f(null,c[i],o)}fs.stat(o,function(t){if(t)return r(t);fs.readlink(o,function(t,e){isWindows||(c[i]=e),f(t,e)})})}function f(t,n,i){if(t)return r(t);var o=path.resolve(s,n);e&&(e[i]=o),m(o)}function m(e){t=path.resolve(e,t.slice(n)),l()}l()},old={realpathSync:realpathSync,realpath:realpath},fs_realpath=realpath$1;realpath$1.realpath=realpath$1,realpath$1.sync=realpathSync$1,realpath$1.realpathSync=realpathSync$1,realpath$1.monkeypatch=monkeypatch,realpath$1.unmonkeypatch=unmonkeypatch;var origRealpath=fs.realpath,origRealpathSync=fs.realpathSync,version=process.version,ok=/^v[0-5]\./.test(version);function newError(t){return t&&"realpath"===t.syscall&&("ELOOP"===t.code||"ENOMEM"===t.code||"ENAMETOOLONG"===t.code)}function realpath$1(t,e,r){if(ok)return origRealpath(t,e,r);"function"==typeof e&&(r=e,e=null),origRealpath(t,e,function(n,i){newError(n)?old.realpath(t,e,r):r(n,i)})}function realpathSync$1(t,e){if(ok)return origRealpathSync(t,e);try{return origRealpathSync(t,e)}catch(r){if(newError(r))return old.realpathSync(t,e);throw r}}function monkeypatch(){fs.realpath=realpath$1,fs.realpathSync=realpathSync$1}function unmonkeypatch(){fs.realpath=origRealpath,fs.realpathSync=origRealpathSync}var concatMap=function(t,e){for(var r=[],n=0;n=0&&h>0){for(n=[],o=r.length;l>=0&&!a;)l==c?(n.push(l),c=r.indexOf(t,l+1)):1==n.length?a=[n.pop(),h]:((i=n.pop())=0?c:h;n.length&&(a=[o,s])}return a}balanced.range=range;var braceExpansion=expandTop,escSlash="\0SLASH"+Math.random()+"\0",escOpen="\0OPEN"+Math.random()+"\0",escClose="\0CLOSE"+Math.random()+"\0",escComma="\0COMMA"+Math.random()+"\0",escPeriod="\0PERIOD"+Math.random()+"\0";function numeric(t){return parseInt(t,10)==t?parseInt(t,10):t.charCodeAt(0)}function escapeBraces(t){return t.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod)}function unescapeBraces(t){return t.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".")}function parseCommaParts(t){if(!t)return[""];var e=[],r=balancedMatch("{","}",t);if(!r)return t.split(",");var n=r.pre,i=r.body,o=r.post,s=n.split(",");s[s.length-1]+="{"+i+"}";var a=parseCommaParts(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),e.push.apply(e,s),e}function expandTop(t){return t?("{}"===t.substr(0,2)&&(t="\\{\\}"+t.substr(2)),expand(escapeBraces(t),!0).map(unescapeBraces)):[]}function embrace(t){return"{"+t+"}"}function isPadded(t){return/^-?0\d/.test(t)}function lte(t,e){return t<=e}function gte(t,e){return t>=e}function expand(t,e){var r=[],n=balancedMatch("{","}",t);if(!n||/\$$/.test(n.pre))return[t];var i,o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),s=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),a=o||s,c=n.body.indexOf(",")>=0;if(!a&&!c)return n.post.match(/,.*\}/)?expand(t=n.pre+"{"+n.body+escClose+n.post):[t];if(a)i=n.body.split(/\.\./);else if(1===(i=parseCommaParts(n.body)).length&&1===(i=expand(i[0],!1).map(embrace)).length)return(p=n.post.length?expand(n.post,!1):[""]).map(function(t){return n.pre+i[0]+t});var h,l=n.pre,p=n.post.length?expand(n.post,!1):[""];if(a){var u=numeric(i[0]),f=numeric(i[1]),m=Math.max(i[0].length,i[1].length),d=3==i.length?Math.abs(numeric(i[2])):1,g=lte;f0){var w=new Array(E+1).join("0");v=b<0?"-"+w+v.slice(1):w+v}}h.push(v)}}else h=concatMap(i,function(t){return expand(t,!1)});for(var S=0;S65536)throw new TypeError("pattern is too long");var r=this.options;if(!r.noglobstar&&"**"===t)return GLOBSTAR;if(""===t)return"";var n,i="",o=!!r.nocase,s=!1,a=[],c=[],h=!1,l=-1,p=-1,u="."===t.charAt(0)?"":r.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",f=this;function m(){if(n){switch(n){case"*":i+=star,o=!0;break;case"?":i+=qmark,o=!0;break;default:i+="\\"+n}f.debug("clearStateChar %j %j",n,i),n=!1}}for(var d,g=0,y=t.length;g-1;O--){var x=c[O],k=i.slice(0,x.reStart),P=i.slice(x.reStart,x.reEnd-8),A=i.slice(x.reEnd-8,x.reEnd),I=i.slice(x.reEnd);A+=I;var R=k.split("(").length-1,$=I;for(g=0;g=0&&!(n=t[i]);i--);for(i=0;i>> no match, partial?",t,p,e,u),p!==s))}if("string"==typeof h?(c=n.nocase?l.toLowerCase()===h.toLowerCase():l===h,this.debug("string match",h,l,c)):(c=l.match(h),this.debug("pattern match",h,l,c)),!c)return!1}if(i===s&&o===a)return!0;if(i===s)return r;if(o===a)return i===s-1&&""===t[i];throw new Error("wtf?")};var inherits_browser=createCommonjsModule(function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}}),inherits=createCommonjsModule(function(t){try{var e=util;if("function"!=typeof e.inherits)throw"";t.exports=e.inherits}catch(e){t.exports=inherits_browser}});function posix(t){return"/"===t.charAt(0)}function win32(t){var e=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/.exec(t),r=e[1]||"",n=Boolean(r&&":"!==r.charAt(1));return Boolean(e[2]||n)}var pathIsAbsolute="win32"===process.platform?win32:posix,posix_1=posix,win32_1=win32;pathIsAbsolute.posix=posix_1,pathIsAbsolute.win32=win32_1;var alphasort_1=alphasort,alphasorti_1=alphasorti,setopts_1=setopts,ownProp_1=ownProp,makeAbs_1=makeAbs,finish_1=finish,mark_1=mark,isIgnored_1=isIgnored,childrenIgnored_1=childrenIgnored;function ownProp(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var Minimatch$1=minimatch_1.Minimatch;function alphasorti(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}function alphasort(t,e){return t.localeCompare(e)}function setupIgnores(t,e){t.ignore=e.ignore||[],Array.isArray(t.ignore)||(t.ignore=[t.ignore]),t.ignore.length&&(t.ignore=t.ignore.map(ignoreMap))}function ignoreMap(t){var e=null;if("/**"===t.slice(-3)){var r=t.replace(/(\/\*\*)+$/,"");e=new Minimatch$1(r,{dot:!0})}return{matcher:new Minimatch$1(t,{dot:!0}),gmatcher:e}}function setopts(t,e,r){if(r||(r={}),r.matchBase&&-1===e.indexOf("/")){if(r.noglobstar)throw new Error("base matching requires globstar");e="**/"+e}t.silent=!!r.silent,t.pattern=e,t.strict=!1!==r.strict,t.realpath=!!r.realpath,t.realpathCache=r.realpathCache||Object.create(null),t.follow=!!r.follow,t.dot=!!r.dot,t.mark=!!r.mark,t.nodir=!!r.nodir,t.nodir&&(t.mark=!0),t.sync=!!r.sync,t.nounique=!!r.nounique,t.nonull=!!r.nonull,t.nosort=!!r.nosort,t.nocase=!!r.nocase,t.stat=!!r.stat,t.noprocess=!!r.noprocess,t.absolute=!!r.absolute,t.maxLength=r.maxLength||1/0,t.cache=r.cache||Object.create(null),t.statCache=r.statCache||Object.create(null),t.symlinks=r.symlinks||Object.create(null),setupIgnores(t,r),t.changedCwd=!1;var n=process.cwd();ownProp(r,"cwd")?(t.cwd=path.resolve(r.cwd),t.changedCwd=t.cwd!==n):t.cwd=n,t.root=r.root||path.resolve(t.cwd,"/"),t.root=path.resolve(t.root),"win32"===process.platform&&(t.root=t.root.replace(/\\/g,"/")),t.cwdAbs=pathIsAbsolute(t.cwd)?t.cwd:makeAbs(t,t.cwd),"win32"===process.platform&&(t.cwdAbs=t.cwdAbs.replace(/\\/g,"/")),t.nomount=!!r.nomount,r.nonegate=!0,r.nocomment=!0,t.minimatch=new Minimatch$1(e,r),t.options=t.minimatch.options}function finish(t){for(var e=t.nounique,r=e?[]:Object.create(null),n=0,i=t.matches.length;nn?(r.splice(0,n),process.nextTick(function(){e.apply(null,i)})):delete reqs[t]}})}function slice(t){for(var e=t.length,r=[],n=0;n1)return!0;for(var i=0;ithis.maxLength)return e();if(!this.stat&&ownProp$1(this.cache,r)){var i=this.cache[r];if(Array.isArray(i)&&(i="DIR"),!n||"DIR"===i)return e(null,i);if(n&&"FILE"===i)return e()}var o=this.statCache[r];if(void 0!==o){if(!1===o)return e(null,o);var s=o.isDirectory()?"DIR":"FILE";return n&&"FILE"===s?e():e(null,s,o)}var a=this,c=inflight_1("stat\0"+r,function(n,i){if(i&&i.isSymbolicLink())return fs.stat(r,function(n,o){n?a._stat2(t,r,null,i,e):a._stat2(t,r,n,o,e)});a._stat2(t,r,n,i,e)});c&&fs.lstat(r,c)},Glob.prototype._stat2=function(t,e,r,n,i){if(r&&("ENOENT"===r.code||"ENOTDIR"===r.code))return this.statCache[e]=!1,i();var o="/"===t.slice(-1);if(this.statCache[e]=n,"/"===e.slice(-1)&&n&&!n.isDirectory())return i(null,!1,n);var s=!0;return n&&(s=n.isDirectory()?"DIR":"FILE"),this.cache[e]=this.cache[e]||s,o&&"FILE"===s?i():i(null,s,n)};let glob$1=void 0;try{glob$1=glob_1}catch(t){}const defaultGlobOpts={nosort:!0,silent:!0};let timeout=0;const isWindows$1="win32"===process.platform,defaults=t=>{if(["unlink","chmod","stat","lstat","rmdir","readdir"].forEach(e=>{t[e]=t[e]||fs[e],t[e+="Sync"]=t[e]||fs[e]}),t.maxBusyTries=t.maxBusyTries||3,t.emfileWait=t.emfileWait||1e3,!1===t.glob&&(t.disableGlob=!0),!0!==t.disableGlob&&void 0===glob$1)throw Error("glob dependency not found, set `options.disableGlob = true` if intentional");t.disableGlob=t.disableGlob||!1,t.glob=t.glob||defaultGlobOpts},rimraf=(t,e,r)=>{"function"==typeof e&&(r=e,e={}),assert(t,"rimraf: missing path"),assert.equal(typeof t,"string","rimraf: path should be a string"),assert.equal(typeof r,"function","rimraf: callback function required"),assert(e,"rimraf: invalid options argument provided"),assert.equal(typeof e,"object","rimraf: options should be object"),defaults(e);let n=0,i=null,o=0;const s=(t,s)=>t?r(t):0===(o=s.length)?r():void s.forEach(t=>{const s=a=>{if(a){if(("EBUSY"===a.code||"ENOTEMPTY"===a.code||"EPERM"===a.code)&&nrimraf_(t,e,s),100*n);if("EMFILE"===a.code&&timeoutrimraf_(t,e,s),timeout++);"ENOENT"===a.code&&(a=null)}timeout=0,(t=>{i=i||t,0==--o&&r(i)})(a)};rimraf_(t,e,s)});if(e.disableGlob||!glob$1.hasMagic(t))return s(null,[t]);e.lstat(t,(r,n)=>{if(!r)return s(null,[t]);glob$1(t,e.glob,s)})},rimraf_=(t,e,r)=>{assert(t),assert(e),assert("function"==typeof r),e.lstat(t,(n,i)=>n&&"ENOENT"===n.code?r(null):(n&&"EPERM"===n.code&&isWindows$1&&fixWinEPERM(t,e,n,r),i&&i.isDirectory()?rmdir(t,e,n,r):void e.unlink(t,n=>{if(n){if("ENOENT"===n.code)return r(null);if("EPERM"===n.code)return isWindows$1?fixWinEPERM(t,e,n,r):rmdir(t,e,n,r);if("EISDIR"===n.code)return rmdir(t,e,n,r)}return r(n)})))},fixWinEPERM=(t,e,r,n)=>{assert(t),assert(e),assert("function"==typeof n),r&&assert(r instanceof Error),e.chmod(t,438,i=>{i?n("ENOENT"===i.code?null:r):e.stat(t,(i,o)=>{i?n("ENOENT"===i.code?null:r):o.isDirectory()?rmdir(t,e,r,n):e.unlink(t,n)})})},fixWinEPERMSync=(t,e,r)=>{assert(t),assert(e),r&&assert(r instanceof Error);try{e.chmodSync(t,438)}catch(t){if("ENOENT"===t.code)return;throw r}let n;try{n=e.statSync(t)}catch(t){if("ENOENT"===t.code)return;throw r}n.isDirectory()?rmdirSync(t,e,r):e.unlinkSync(t)},rmdir=(t,e,r,n)=>{assert(t),assert(e),r&&assert(r instanceof Error),assert("function"==typeof n),e.rmdir(t,i=>{!i||"ENOTEMPTY"!==i.code&&"EEXIST"!==i.code&&"EPERM"!==i.code?i&&"ENOTDIR"===i.code?n(r):n(i):rmkids(t,e,n)})},rmkids=(t,e,r)=>{assert(t),assert(e),assert("function"==typeof r),e.readdir(t,(n,i)=>{if(n)return r(n);let o,s=i.length;if(0===s)return e.rmdir(t,r);i.forEach(n=>{rimraf(path.join(t,n),e,n=>{if(!o)return n?r(o=n):void(0==--s&&e.rmdir(t,r))})})})},rimrafSync=(t,e)=>{let r;if(defaults(e=e||{}),assert(t,"rimraf: missing path"),assert.equal(typeof t,"string","rimraf: path should be a string"),assert(e,"rimraf: missing options"),assert.equal(typeof e,"object","rimraf: options should be object"),e.disableGlob||!glob$1.hasMagic(t))r=[t];else try{e.lstatSync(t),r=[t]}catch(n){r=glob$1.sync(t,e.glob)}if(r.length)for(let t=0;t{assert(t),assert(e),r&&assert(r instanceof Error);try{e.rmdirSync(t)}catch(n){if("ENOENT"===n.code)return;if("ENOTDIR"===n.code)throw r;"ENOTEMPTY"!==n.code&&"EEXIST"!==n.code&&"EPERM"!==n.code||rmkidsSync(t,e)}},rmkidsSync=(t,e)=>{assert(t),assert(e),e.readdirSync(t).forEach(r=>rimrafSync(path.join(t,r),e));const r=isWindows$1?100:1;let n=0;for(;;){let i=!0;try{const o=e.rmdirSync(t,e);return i=!1,o}finally{if(++nr("../dialog").save({filters:[{name:PLUGIN$1.ARCHIVES,extensions:["zip"]}]}))}substitutePaths(t){t=t.slice();for(let e of t)for(let t of e["@graph"])if(t.photo)for(let e of t.photo)e.path=this.destination(e.path,".");return t}async writeJson(){const t=this.substitutePaths(this.data);return fsPromises.writeFile(join(this.dir,PLUGIN$1.ITEMS_FILE),JSON.stringify(t,null,2))}source(t){return t.path}destination(t,e=this.dir){return join(e,PLUGIN$1.IMAGES_DIR,hash$1(t))+extname(t)}*getPhotoPath(t){const e=t.photo||[];for(let t of e){const e=this.source(t);yield{src:e,dst:this.destination(e)}}}*getPhotoPaths(){for(let t of this.data[0]["@graph"])yield*this.getPhotoPath(t)}async export(t){const{logger:e}=this.context,r=this.config.output||await this.dialog();if(r)try{this.data=t,this.dir=await fsPromises.mkdtemp(join(tmpdir(),PLUGIN$1.NAME)),await fsPromises.mkdir(join(this.dir,PLUGIN$1.IMAGES_DIR)),await this.Promise.all([this.Promise.map(this.getPhotoPaths(),({src:t,dst:e})=>fsPromises.copyFile(t,e),{concurrency:this.config.concurrency||PLUGIN$1.COPY_PROCESSES})]),await this.writeJson(),await zip$1(this.dir,r),await fsPromises.rmdir(this.dir,{recursive:!0})}catch(t){e.error(t.message)}}}var plugin=Plugin;module.exports=plugin; +"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var path=_interopDefault(require("path")),fs=_interopDefault(require("fs")),util=_interopDefault(require("util")),events=_interopDefault(require("events")),assert=_interopDefault(require("assert")),child_process=_interopDefault(require("child_process")),os=_interopDefault(require("os")),crypto=_interopDefault(require("crypto")),isWindows="win32"===process.platform,DEBUG=process.env.NODE_DEBUG&&/fs/.test(process.env.NODE_DEBUG);function rethrow(){var t;if(DEBUG){var e=new Error;t=function(t){t&&(e.message=t.message,r(t=e))}}else t=r;return t;function r(t){if(t){if(process.throwDeprecation)throw t;if(!process.noDeprecation){var e="fs: missing callback "+(t.stack||t.message);process.traceDeprecation?console.trace(e):console.error(e)}}}}function maybeCallback(t){return"function"==typeof t?t:rethrow()}var normalize=path.normalize;if(isWindows)var nextPartRe=/(.*?)(?:[\/\\]+|$)/g;else nextPartRe=/(.*?)(?:[\/]+|$)/g;if(isWindows)var splitRootRe=/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;else splitRootRe=/^[\/]*/;var realpathSync=function(t,e){if(t=path.resolve(t),e&&Object.prototype.hasOwnProperty.call(e,t))return e[t];var r,n,i,o,s=t,a={},c={};function h(){var e=splitRootRe.exec(t);r=e[0].length,n=e[0],i=e[0],o="",isWindows&&!c[i]&&(fs.lstatSync(i),c[i]=!0)}for(h();r=t.length)return e&&(e[a]=t),r(null,t);nextPartRe.lastIndex=n;var c=nextPartRe.exec(t);return s=i,i+=c[0],o=s+c[1],n=nextPartRe.lastIndex,h[o]||e&&e[o]===o?process.nextTick(p):e&&Object.prototype.hasOwnProperty.call(e,o)?m(e[o]):fs.lstat(o,u)}function u(t,n){if(t)return r(t);if(!n.isSymbolicLink())return h[o]=!0,e&&(e[o]=o),process.nextTick(p);if(!isWindows){var i=n.dev.toString(32)+":"+n.ino.toString(32);if(c.hasOwnProperty(i))return f(null,c[i],o)}fs.stat(o,function(t){if(t)return r(t);fs.readlink(o,function(t,e){isWindows||(c[i]=e),f(t,e)})})}function f(t,n,i){if(t)return r(t);var o=path.resolve(s,n);e&&(e[i]=o),m(o)}function m(e){t=path.resolve(e,t.slice(n)),l()}l()},old={realpathSync:realpathSync,realpath:realpath},fs_realpath=realpath$1;realpath$1.realpath=realpath$1,realpath$1.sync=realpathSync$1,realpath$1.realpathSync=realpathSync$1,realpath$1.monkeypatch=monkeypatch,realpath$1.unmonkeypatch=unmonkeypatch;var origRealpath=fs.realpath,origRealpathSync=fs.realpathSync,version=process.version,ok=/^v[0-5]\./.test(version);function newError(t){return t&&"realpath"===t.syscall&&("ELOOP"===t.code||"ENOMEM"===t.code||"ENAMETOOLONG"===t.code)}function realpath$1(t,e,r){if(ok)return origRealpath(t,e,r);"function"==typeof e&&(r=e,e=null),origRealpath(t,e,function(n,i){newError(n)?old.realpath(t,e,r):r(n,i)})}function realpathSync$1(t,e){if(ok)return origRealpathSync(t,e);try{return origRealpathSync(t,e)}catch(r){if(newError(r))return old.realpathSync(t,e);throw r}}function monkeypatch(){fs.realpath=realpath$1,fs.realpathSync=realpathSync$1}function unmonkeypatch(){fs.realpath=origRealpath,fs.realpathSync=origRealpathSync}var concatMap=function(t,e){for(var r=[],n=0;n=0&&h>0){for(n=[],o=r.length;l>=0&&!a;)l==c?(n.push(l),c=r.indexOf(t,l+1)):1==n.length?a=[n.pop(),h]:((i=n.pop())=0?c:h;n.length&&(a=[o,s])}return a}balanced.range=range;var braceExpansion=expandTop,escSlash="\0SLASH"+Math.random()+"\0",escOpen="\0OPEN"+Math.random()+"\0",escClose="\0CLOSE"+Math.random()+"\0",escComma="\0COMMA"+Math.random()+"\0",escPeriod="\0PERIOD"+Math.random()+"\0";function numeric(t){return parseInt(t,10)==t?parseInt(t,10):t.charCodeAt(0)}function escapeBraces(t){return t.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod)}function unescapeBraces(t){return t.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".")}function parseCommaParts(t){if(!t)return[""];var e=[],r=balancedMatch("{","}",t);if(!r)return t.split(",");var n=r.pre,i=r.body,o=r.post,s=n.split(",");s[s.length-1]+="{"+i+"}";var a=parseCommaParts(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),e.push.apply(e,s),e}function expandTop(t){return t?("{}"===t.substr(0,2)&&(t="\\{\\}"+t.substr(2)),expand(escapeBraces(t),!0).map(unescapeBraces)):[]}function embrace(t){return"{"+t+"}"}function isPadded(t){return/^-?0\d/.test(t)}function lte(t,e){return t<=e}function gte(t,e){return t>=e}function expand(t,e){var r=[],n=balancedMatch("{","}",t);if(!n||/\$$/.test(n.pre))return[t];var i,o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),s=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),a=o||s,c=n.body.indexOf(",")>=0;if(!a&&!c)return n.post.match(/,.*\}/)?expand(t=n.pre+"{"+n.body+escClose+n.post):[t];if(a)i=n.body.split(/\.\./);else if(1===(i=parseCommaParts(n.body)).length&&1===(i=expand(i[0],!1).map(embrace)).length)return(p=n.post.length?expand(n.post,!1):[""]).map(function(t){return n.pre+i[0]+t});var h,l=n.pre,p=n.post.length?expand(n.post,!1):[""];if(a){var u=numeric(i[0]),f=numeric(i[1]),m=Math.max(i[0].length,i[1].length),d=3==i.length?Math.abs(numeric(i[2])):1,g=lte;f0){var w=new Array(E+1).join("0");v=b<0?"-"+w+v.slice(1):w+v}}h.push(v)}}else h=concatMap(i,function(t){return expand(t,!1)});for(var S=0;S65536)throw new TypeError("pattern is too long");var r=this.options;if(!r.noglobstar&&"**"===t)return GLOBSTAR;if(""===t)return"";var n,i="",o=!!r.nocase,s=!1,a=[],c=[],h=!1,l=-1,p=-1,u="."===t.charAt(0)?"":r.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",f=this;function m(){if(n){switch(n){case"*":i+=star,o=!0;break;case"?":i+=qmark,o=!0;break;default:i+="\\"+n}f.debug("clearStateChar %j %j",n,i),n=!1}}for(var d,g=0,y=t.length;g-1;O--){var x=c[O],k=i.slice(0,x.reStart),P=i.slice(x.reStart,x.reEnd-8),A=i.slice(x.reEnd-8,x.reEnd),I=i.slice(x.reEnd);A+=I;var R=k.split("(").length-1,$=I;for(g=0;g=0&&!(n=t[i]);i--);for(i=0;i>> no match, partial?",t,p,e,u),p!==s))}if("string"==typeof h?(c=n.nocase?l.toLowerCase()===h.toLowerCase():l===h,this.debug("string match",h,l,c)):(c=l.match(h),this.debug("pattern match",h,l,c)),!c)return!1}if(i===s&&o===a)return!0;if(i===s)return r;if(o===a)return i===s-1&&""===t[i];throw new Error("wtf?")};var inherits_browser=createCommonjsModule(function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}}),inherits=createCommonjsModule(function(t){try{var e=util;if("function"!=typeof e.inherits)throw"";t.exports=e.inherits}catch(e){t.exports=inherits_browser}});function posix(t){return"/"===t.charAt(0)}function win32(t){var e=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/.exec(t),r=e[1]||"",n=Boolean(r&&":"!==r.charAt(1));return Boolean(e[2]||n)}var pathIsAbsolute="win32"===process.platform?win32:posix,posix_1=posix,win32_1=win32;pathIsAbsolute.posix=posix_1,pathIsAbsolute.win32=win32_1;var alphasort_1=alphasort,alphasorti_1=alphasorti,setopts_1=setopts,ownProp_1=ownProp,makeAbs_1=makeAbs,finish_1=finish,mark_1=mark,isIgnored_1=isIgnored,childrenIgnored_1=childrenIgnored;function ownProp(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var Minimatch$1=minimatch_1.Minimatch;function alphasorti(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}function alphasort(t,e){return t.localeCompare(e)}function setupIgnores(t,e){t.ignore=e.ignore||[],Array.isArray(t.ignore)||(t.ignore=[t.ignore]),t.ignore.length&&(t.ignore=t.ignore.map(ignoreMap))}function ignoreMap(t){var e=null;if("/**"===t.slice(-3)){var r=t.replace(/(\/\*\*)+$/,"");e=new Minimatch$1(r,{dot:!0})}return{matcher:new Minimatch$1(t,{dot:!0}),gmatcher:e}}function setopts(t,e,r){if(r||(r={}),r.matchBase&&-1===e.indexOf("/")){if(r.noglobstar)throw new Error("base matching requires globstar");e="**/"+e}t.silent=!!r.silent,t.pattern=e,t.strict=!1!==r.strict,t.realpath=!!r.realpath,t.realpathCache=r.realpathCache||Object.create(null),t.follow=!!r.follow,t.dot=!!r.dot,t.mark=!!r.mark,t.nodir=!!r.nodir,t.nodir&&(t.mark=!0),t.sync=!!r.sync,t.nounique=!!r.nounique,t.nonull=!!r.nonull,t.nosort=!!r.nosort,t.nocase=!!r.nocase,t.stat=!!r.stat,t.noprocess=!!r.noprocess,t.absolute=!!r.absolute,t.maxLength=r.maxLength||1/0,t.cache=r.cache||Object.create(null),t.statCache=r.statCache||Object.create(null),t.symlinks=r.symlinks||Object.create(null),setupIgnores(t,r),t.changedCwd=!1;var n=process.cwd();ownProp(r,"cwd")?(t.cwd=path.resolve(r.cwd),t.changedCwd=t.cwd!==n):t.cwd=n,t.root=r.root||path.resolve(t.cwd,"/"),t.root=path.resolve(t.root),"win32"===process.platform&&(t.root=t.root.replace(/\\/g,"/")),t.cwdAbs=pathIsAbsolute(t.cwd)?t.cwd:makeAbs(t,t.cwd),"win32"===process.platform&&(t.cwdAbs=t.cwdAbs.replace(/\\/g,"/")),t.nomount=!!r.nomount,r.nonegate=!0,r.nocomment=!0,t.minimatch=new Minimatch$1(e,r),t.options=t.minimatch.options}function finish(t){for(var e=t.nounique,r=e?[]:Object.create(null),n=0,i=t.matches.length;nn?(r.splice(0,n),process.nextTick(function(){e.apply(null,i)})):delete reqs[t]}})}function slice(t){for(var e=t.length,r=[],n=0;n1)return!0;for(var i=0;ithis.maxLength)return e();if(!this.stat&&ownProp$1(this.cache,r)){var i=this.cache[r];if(Array.isArray(i)&&(i="DIR"),!n||"DIR"===i)return e(null,i);if(n&&"FILE"===i)return e()}var o=this.statCache[r];if(void 0!==o){if(!1===o)return e(null,o);var s=o.isDirectory()?"DIR":"FILE";return n&&"FILE"===s?e():e(null,s,o)}var a=this,c=inflight_1("stat\0"+r,function(n,i){if(i&&i.isSymbolicLink())return fs.stat(r,function(n,o){n?a._stat2(t,r,null,i,e):a._stat2(t,r,n,o,e)});a._stat2(t,r,n,i,e)});c&&fs.lstat(r,c)},Glob.prototype._stat2=function(t,e,r,n,i){if(r&&("ENOENT"===r.code||"ENOTDIR"===r.code))return this.statCache[e]=!1,i();var o="/"===t.slice(-1);if(this.statCache[e]=n,"/"===e.slice(-1)&&n&&!n.isDirectory())return i(null,!1,n);var s=!0;return n&&(s=n.isDirectory()?"DIR":"FILE"),this.cache[e]=this.cache[e]||s,o&&"FILE"===s?i():i(null,s,n)};let glob$1=void 0;try{glob$1=glob_1}catch(t){}const defaultGlobOpts={nosort:!0,silent:!0};let timeout=0;const isWindows$1="win32"===process.platform,defaults=t=>{if(["unlink","chmod","stat","lstat","rmdir","readdir"].forEach(e=>{t[e]=t[e]||fs[e],t[e+="Sync"]=t[e]||fs[e]}),t.maxBusyTries=t.maxBusyTries||3,t.emfileWait=t.emfileWait||1e3,!1===t.glob&&(t.disableGlob=!0),!0!==t.disableGlob&&void 0===glob$1)throw Error("glob dependency not found, set `options.disableGlob = true` if intentional");t.disableGlob=t.disableGlob||!1,t.glob=t.glob||defaultGlobOpts},rimraf=(t,e,r)=>{"function"==typeof e&&(r=e,e={}),assert(t,"rimraf: missing path"),assert.equal(typeof t,"string","rimraf: path should be a string"),assert.equal(typeof r,"function","rimraf: callback function required"),assert(e,"rimraf: invalid options argument provided"),assert.equal(typeof e,"object","rimraf: options should be object"),defaults(e);let n=0,i=null,o=0;const s=(t,s)=>t?r(t):0===(o=s.length)?r():void s.forEach(t=>{const s=a=>{if(a){if(("EBUSY"===a.code||"ENOTEMPTY"===a.code||"EPERM"===a.code)&&nrimraf_(t,e,s),100*n);if("EMFILE"===a.code&&timeoutrimraf_(t,e,s),timeout++);"ENOENT"===a.code&&(a=null)}timeout=0,(t=>{i=i||t,0==--o&&r(i)})(a)};rimraf_(t,e,s)});if(e.disableGlob||!glob$1.hasMagic(t))return s(null,[t]);e.lstat(t,(r,n)=>{if(!r)return s(null,[t]);glob$1(t,e.glob,s)})},rimraf_=(t,e,r)=>{assert(t),assert(e),assert("function"==typeof r),e.lstat(t,(n,i)=>n&&"ENOENT"===n.code?r(null):(n&&"EPERM"===n.code&&isWindows$1&&fixWinEPERM(t,e,n,r),i&&i.isDirectory()?rmdir(t,e,n,r):void e.unlink(t,n=>{if(n){if("ENOENT"===n.code)return r(null);if("EPERM"===n.code)return isWindows$1?fixWinEPERM(t,e,n,r):rmdir(t,e,n,r);if("EISDIR"===n.code)return rmdir(t,e,n,r)}return r(n)})))},fixWinEPERM=(t,e,r,n)=>{assert(t),assert(e),assert("function"==typeof n),r&&assert(r instanceof Error),e.chmod(t,438,i=>{i?n("ENOENT"===i.code?null:r):e.stat(t,(i,o)=>{i?n("ENOENT"===i.code?null:r):o.isDirectory()?rmdir(t,e,r,n):e.unlink(t,n)})})},fixWinEPERMSync=(t,e,r)=>{assert(t),assert(e),r&&assert(r instanceof Error);try{e.chmodSync(t,438)}catch(t){if("ENOENT"===t.code)return;throw r}let n;try{n=e.statSync(t)}catch(t){if("ENOENT"===t.code)return;throw r}n.isDirectory()?rmdirSync(t,e,r):e.unlinkSync(t)},rmdir=(t,e,r,n)=>{assert(t),assert(e),r&&assert(r instanceof Error),assert("function"==typeof n),e.rmdir(t,i=>{!i||"ENOTEMPTY"!==i.code&&"EEXIST"!==i.code&&"EPERM"!==i.code?i&&"ENOTDIR"===i.code?n(r):n(i):rmkids(t,e,n)})},rmkids=(t,e,r)=>{assert(t),assert(e),assert("function"==typeof r),e.readdir(t,(n,i)=>{if(n)return r(n);let o,s=i.length;if(0===s)return e.rmdir(t,r);i.forEach(n=>{rimraf(path.join(t,n),e,n=>{if(!o)return n?r(o=n):void(0==--s&&e.rmdir(t,r))})})})},rimrafSync=(t,e)=>{let r;if(defaults(e=e||{}),assert(t,"rimraf: missing path"),assert.equal(typeof t,"string","rimraf: path should be a string"),assert(e,"rimraf: missing options"),assert.equal(typeof e,"object","rimraf: options should be object"),e.disableGlob||!glob$1.hasMagic(t))r=[t];else try{e.lstatSync(t),r=[t]}catch(n){r=glob$1.sync(t,e.glob)}if(r.length)for(let t=0;t{assert(t),assert(e),r&&assert(r instanceof Error);try{e.rmdirSync(t)}catch(n){if("ENOENT"===n.code)return;if("ENOTDIR"===n.code)throw r;"ENOTEMPTY"!==n.code&&"EEXIST"!==n.code&&"EPERM"!==n.code||rmkidsSync(t,e)}},rmkidsSync=(t,e)=>{assert(t),assert(e),e.readdirSync(t).forEach(r=>rimrafSync(path.join(t,r),e));const r=isWindows$1?100:1;let n=0;for(;;){let i=!0;try{const o=e.rmdirSync(t,e);return i=!1,o}finally{if(++nr("../dialog").save({filters:[{name:PLUGIN$1.ARCHIVES,extensions:["zip"]}]}))}substitutePaths(t){t=Object.assign({},t);for(let e of t["@graph"])if(e.photo)for(let t of e.photo)t.path=this.destination(t.path,".");return t}async writeJson(){const t=this.substitutePaths(this.data);return fsPromises.writeFile(join(this.dir,PLUGIN$1.ITEMS_FILE),JSON.stringify(t,null,2))}source(t){return t.path}destination(t,e=this.dir){return join(e,PLUGIN$1.IMAGES_DIR,hash$1(t))+extname(t)}*getPhotoPath(t){const e=t.photo||[];for(let t of e){const e=this.source(t);yield{src:e,dst:this.destination(e)}}}*getPhotoPaths(){for(let t of this.data["@graph"])yield*this.getPhotoPath(t)}async export(t){const{logger:e}=this.context,r=this.config.output||await this.dialog();if(r)try{this.data=t,this.dir=await fsPromises.mkdtemp(join(tmpdir(),PLUGIN$1.NAME)),await fsPromises.mkdir(join(this.dir,PLUGIN$1.IMAGES_DIR)),await this.Promise.all([this.Promise.map(this.getPhotoPaths(),({src:t,dst:e})=>fsPromises.copyFile(t,e),{concurrency:this.config.concurrency||PLUGIN$1.COPY_PROCESSES})]),await this.writeJson(),await zip$1(this.dir,r),await fsPromises.rmdir(this.dir,{recursive:!0})}catch(t){e.error(t.message)}}}var plugin=Plugin;module.exports=plugin; diff --git a/src/plugin.js b/src/plugin.js index 10edd74..4515eed 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -29,13 +29,11 @@ class Plugin { } substitutePaths(jsonld) { - jsonld = jsonld.slice() - for (let items of jsonld) { - for (let item of items['@graph']) { - if (!item.photo) continue - for (let photo of item.photo) { - photo.path = this.destination(photo.path, '.') - } + jsonld = Object.assign({}, jsonld) + for (let item of jsonld['@graph']) { + if (!item.photo) continue + for (let photo of item.photo) { + photo.path = this.destination(photo.path, '.') } } return jsonld @@ -67,7 +65,7 @@ class Plugin { } *getPhotoPaths() { - for (let item of this.data[0]['@graph']) { + for (let item of this.data['@graph']) { yield* this.getPhotoPath(item) } } From ef1da1a903c7fcea1c9b7c3569b0602067908b48 Mon Sep 17 00:00:00 2001 From: Roberto Martinez Date: Thu, 5 Mar 2020 15:03:51 -0500 Subject: [PATCH 2/3] Refactoring --- bundle.js | 2 +- src/plugin.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/bundle.js b/bundle.js index 0ebb5e2..b210ce2 100644 --- a/bundle.js +++ b/bundle.js @@ -1 +1 @@ -"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var path=_interopDefault(require("path")),fs=_interopDefault(require("fs")),util=_interopDefault(require("util")),events=_interopDefault(require("events")),assert=_interopDefault(require("assert")),child_process=_interopDefault(require("child_process")),os=_interopDefault(require("os")),crypto=_interopDefault(require("crypto")),isWindows="win32"===process.platform,DEBUG=process.env.NODE_DEBUG&&/fs/.test(process.env.NODE_DEBUG);function rethrow(){var t;if(DEBUG){var e=new Error;t=function(t){t&&(e.message=t.message,r(t=e))}}else t=r;return t;function r(t){if(t){if(process.throwDeprecation)throw t;if(!process.noDeprecation){var e="fs: missing callback "+(t.stack||t.message);process.traceDeprecation?console.trace(e):console.error(e)}}}}function maybeCallback(t){return"function"==typeof t?t:rethrow()}var normalize=path.normalize;if(isWindows)var nextPartRe=/(.*?)(?:[\/\\]+|$)/g;else nextPartRe=/(.*?)(?:[\/]+|$)/g;if(isWindows)var splitRootRe=/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;else splitRootRe=/^[\/]*/;var realpathSync=function(t,e){if(t=path.resolve(t),e&&Object.prototype.hasOwnProperty.call(e,t))return e[t];var r,n,i,o,s=t,a={},c={};function h(){var e=splitRootRe.exec(t);r=e[0].length,n=e[0],i=e[0],o="",isWindows&&!c[i]&&(fs.lstatSync(i),c[i]=!0)}for(h();r=t.length)return e&&(e[a]=t),r(null,t);nextPartRe.lastIndex=n;var c=nextPartRe.exec(t);return s=i,i+=c[0],o=s+c[1],n=nextPartRe.lastIndex,h[o]||e&&e[o]===o?process.nextTick(p):e&&Object.prototype.hasOwnProperty.call(e,o)?m(e[o]):fs.lstat(o,u)}function u(t,n){if(t)return r(t);if(!n.isSymbolicLink())return h[o]=!0,e&&(e[o]=o),process.nextTick(p);if(!isWindows){var i=n.dev.toString(32)+":"+n.ino.toString(32);if(c.hasOwnProperty(i))return f(null,c[i],o)}fs.stat(o,function(t){if(t)return r(t);fs.readlink(o,function(t,e){isWindows||(c[i]=e),f(t,e)})})}function f(t,n,i){if(t)return r(t);var o=path.resolve(s,n);e&&(e[i]=o),m(o)}function m(e){t=path.resolve(e,t.slice(n)),l()}l()},old={realpathSync:realpathSync,realpath:realpath},fs_realpath=realpath$1;realpath$1.realpath=realpath$1,realpath$1.sync=realpathSync$1,realpath$1.realpathSync=realpathSync$1,realpath$1.monkeypatch=monkeypatch,realpath$1.unmonkeypatch=unmonkeypatch;var origRealpath=fs.realpath,origRealpathSync=fs.realpathSync,version=process.version,ok=/^v[0-5]\./.test(version);function newError(t){return t&&"realpath"===t.syscall&&("ELOOP"===t.code||"ENOMEM"===t.code||"ENAMETOOLONG"===t.code)}function realpath$1(t,e,r){if(ok)return origRealpath(t,e,r);"function"==typeof e&&(r=e,e=null),origRealpath(t,e,function(n,i){newError(n)?old.realpath(t,e,r):r(n,i)})}function realpathSync$1(t,e){if(ok)return origRealpathSync(t,e);try{return origRealpathSync(t,e)}catch(r){if(newError(r))return old.realpathSync(t,e);throw r}}function monkeypatch(){fs.realpath=realpath$1,fs.realpathSync=realpathSync$1}function unmonkeypatch(){fs.realpath=origRealpath,fs.realpathSync=origRealpathSync}var concatMap=function(t,e){for(var r=[],n=0;n=0&&h>0){for(n=[],o=r.length;l>=0&&!a;)l==c?(n.push(l),c=r.indexOf(t,l+1)):1==n.length?a=[n.pop(),h]:((i=n.pop())=0?c:h;n.length&&(a=[o,s])}return a}balanced.range=range;var braceExpansion=expandTop,escSlash="\0SLASH"+Math.random()+"\0",escOpen="\0OPEN"+Math.random()+"\0",escClose="\0CLOSE"+Math.random()+"\0",escComma="\0COMMA"+Math.random()+"\0",escPeriod="\0PERIOD"+Math.random()+"\0";function numeric(t){return parseInt(t,10)==t?parseInt(t,10):t.charCodeAt(0)}function escapeBraces(t){return t.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod)}function unescapeBraces(t){return t.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".")}function parseCommaParts(t){if(!t)return[""];var e=[],r=balancedMatch("{","}",t);if(!r)return t.split(",");var n=r.pre,i=r.body,o=r.post,s=n.split(",");s[s.length-1]+="{"+i+"}";var a=parseCommaParts(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),e.push.apply(e,s),e}function expandTop(t){return t?("{}"===t.substr(0,2)&&(t="\\{\\}"+t.substr(2)),expand(escapeBraces(t),!0).map(unescapeBraces)):[]}function embrace(t){return"{"+t+"}"}function isPadded(t){return/^-?0\d/.test(t)}function lte(t,e){return t<=e}function gte(t,e){return t>=e}function expand(t,e){var r=[],n=balancedMatch("{","}",t);if(!n||/\$$/.test(n.pre))return[t];var i,o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),s=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),a=o||s,c=n.body.indexOf(",")>=0;if(!a&&!c)return n.post.match(/,.*\}/)?expand(t=n.pre+"{"+n.body+escClose+n.post):[t];if(a)i=n.body.split(/\.\./);else if(1===(i=parseCommaParts(n.body)).length&&1===(i=expand(i[0],!1).map(embrace)).length)return(p=n.post.length?expand(n.post,!1):[""]).map(function(t){return n.pre+i[0]+t});var h,l=n.pre,p=n.post.length?expand(n.post,!1):[""];if(a){var u=numeric(i[0]),f=numeric(i[1]),m=Math.max(i[0].length,i[1].length),d=3==i.length?Math.abs(numeric(i[2])):1,g=lte;f0){var w=new Array(E+1).join("0");v=b<0?"-"+w+v.slice(1):w+v}}h.push(v)}}else h=concatMap(i,function(t){return expand(t,!1)});for(var S=0;S65536)throw new TypeError("pattern is too long");var r=this.options;if(!r.noglobstar&&"**"===t)return GLOBSTAR;if(""===t)return"";var n,i="",o=!!r.nocase,s=!1,a=[],c=[],h=!1,l=-1,p=-1,u="."===t.charAt(0)?"":r.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",f=this;function m(){if(n){switch(n){case"*":i+=star,o=!0;break;case"?":i+=qmark,o=!0;break;default:i+="\\"+n}f.debug("clearStateChar %j %j",n,i),n=!1}}for(var d,g=0,y=t.length;g-1;O--){var x=c[O],k=i.slice(0,x.reStart),P=i.slice(x.reStart,x.reEnd-8),A=i.slice(x.reEnd-8,x.reEnd),I=i.slice(x.reEnd);A+=I;var R=k.split("(").length-1,$=I;for(g=0;g=0&&!(n=t[i]);i--);for(i=0;i>> no match, partial?",t,p,e,u),p!==s))}if("string"==typeof h?(c=n.nocase?l.toLowerCase()===h.toLowerCase():l===h,this.debug("string match",h,l,c)):(c=l.match(h),this.debug("pattern match",h,l,c)),!c)return!1}if(i===s&&o===a)return!0;if(i===s)return r;if(o===a)return i===s-1&&""===t[i];throw new Error("wtf?")};var inherits_browser=createCommonjsModule(function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}}),inherits=createCommonjsModule(function(t){try{var e=util;if("function"!=typeof e.inherits)throw"";t.exports=e.inherits}catch(e){t.exports=inherits_browser}});function posix(t){return"/"===t.charAt(0)}function win32(t){var e=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/.exec(t),r=e[1]||"",n=Boolean(r&&":"!==r.charAt(1));return Boolean(e[2]||n)}var pathIsAbsolute="win32"===process.platform?win32:posix,posix_1=posix,win32_1=win32;pathIsAbsolute.posix=posix_1,pathIsAbsolute.win32=win32_1;var alphasort_1=alphasort,alphasorti_1=alphasorti,setopts_1=setopts,ownProp_1=ownProp,makeAbs_1=makeAbs,finish_1=finish,mark_1=mark,isIgnored_1=isIgnored,childrenIgnored_1=childrenIgnored;function ownProp(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var Minimatch$1=minimatch_1.Minimatch;function alphasorti(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}function alphasort(t,e){return t.localeCompare(e)}function setupIgnores(t,e){t.ignore=e.ignore||[],Array.isArray(t.ignore)||(t.ignore=[t.ignore]),t.ignore.length&&(t.ignore=t.ignore.map(ignoreMap))}function ignoreMap(t){var e=null;if("/**"===t.slice(-3)){var r=t.replace(/(\/\*\*)+$/,"");e=new Minimatch$1(r,{dot:!0})}return{matcher:new Minimatch$1(t,{dot:!0}),gmatcher:e}}function setopts(t,e,r){if(r||(r={}),r.matchBase&&-1===e.indexOf("/")){if(r.noglobstar)throw new Error("base matching requires globstar");e="**/"+e}t.silent=!!r.silent,t.pattern=e,t.strict=!1!==r.strict,t.realpath=!!r.realpath,t.realpathCache=r.realpathCache||Object.create(null),t.follow=!!r.follow,t.dot=!!r.dot,t.mark=!!r.mark,t.nodir=!!r.nodir,t.nodir&&(t.mark=!0),t.sync=!!r.sync,t.nounique=!!r.nounique,t.nonull=!!r.nonull,t.nosort=!!r.nosort,t.nocase=!!r.nocase,t.stat=!!r.stat,t.noprocess=!!r.noprocess,t.absolute=!!r.absolute,t.maxLength=r.maxLength||1/0,t.cache=r.cache||Object.create(null),t.statCache=r.statCache||Object.create(null),t.symlinks=r.symlinks||Object.create(null),setupIgnores(t,r),t.changedCwd=!1;var n=process.cwd();ownProp(r,"cwd")?(t.cwd=path.resolve(r.cwd),t.changedCwd=t.cwd!==n):t.cwd=n,t.root=r.root||path.resolve(t.cwd,"/"),t.root=path.resolve(t.root),"win32"===process.platform&&(t.root=t.root.replace(/\\/g,"/")),t.cwdAbs=pathIsAbsolute(t.cwd)?t.cwd:makeAbs(t,t.cwd),"win32"===process.platform&&(t.cwdAbs=t.cwdAbs.replace(/\\/g,"/")),t.nomount=!!r.nomount,r.nonegate=!0,r.nocomment=!0,t.minimatch=new Minimatch$1(e,r),t.options=t.minimatch.options}function finish(t){for(var e=t.nounique,r=e?[]:Object.create(null),n=0,i=t.matches.length;nn?(r.splice(0,n),process.nextTick(function(){e.apply(null,i)})):delete reqs[t]}})}function slice(t){for(var e=t.length,r=[],n=0;n1)return!0;for(var i=0;ithis.maxLength)return e();if(!this.stat&&ownProp$1(this.cache,r)){var i=this.cache[r];if(Array.isArray(i)&&(i="DIR"),!n||"DIR"===i)return e(null,i);if(n&&"FILE"===i)return e()}var o=this.statCache[r];if(void 0!==o){if(!1===o)return e(null,o);var s=o.isDirectory()?"DIR":"FILE";return n&&"FILE"===s?e():e(null,s,o)}var a=this,c=inflight_1("stat\0"+r,function(n,i){if(i&&i.isSymbolicLink())return fs.stat(r,function(n,o){n?a._stat2(t,r,null,i,e):a._stat2(t,r,n,o,e)});a._stat2(t,r,n,i,e)});c&&fs.lstat(r,c)},Glob.prototype._stat2=function(t,e,r,n,i){if(r&&("ENOENT"===r.code||"ENOTDIR"===r.code))return this.statCache[e]=!1,i();var o="/"===t.slice(-1);if(this.statCache[e]=n,"/"===e.slice(-1)&&n&&!n.isDirectory())return i(null,!1,n);var s=!0;return n&&(s=n.isDirectory()?"DIR":"FILE"),this.cache[e]=this.cache[e]||s,o&&"FILE"===s?i():i(null,s,n)};let glob$1=void 0;try{glob$1=glob_1}catch(t){}const defaultGlobOpts={nosort:!0,silent:!0};let timeout=0;const isWindows$1="win32"===process.platform,defaults=t=>{if(["unlink","chmod","stat","lstat","rmdir","readdir"].forEach(e=>{t[e]=t[e]||fs[e],t[e+="Sync"]=t[e]||fs[e]}),t.maxBusyTries=t.maxBusyTries||3,t.emfileWait=t.emfileWait||1e3,!1===t.glob&&(t.disableGlob=!0),!0!==t.disableGlob&&void 0===glob$1)throw Error("glob dependency not found, set `options.disableGlob = true` if intentional");t.disableGlob=t.disableGlob||!1,t.glob=t.glob||defaultGlobOpts},rimraf=(t,e,r)=>{"function"==typeof e&&(r=e,e={}),assert(t,"rimraf: missing path"),assert.equal(typeof t,"string","rimraf: path should be a string"),assert.equal(typeof r,"function","rimraf: callback function required"),assert(e,"rimraf: invalid options argument provided"),assert.equal(typeof e,"object","rimraf: options should be object"),defaults(e);let n=0,i=null,o=0;const s=(t,s)=>t?r(t):0===(o=s.length)?r():void s.forEach(t=>{const s=a=>{if(a){if(("EBUSY"===a.code||"ENOTEMPTY"===a.code||"EPERM"===a.code)&&nrimraf_(t,e,s),100*n);if("EMFILE"===a.code&&timeoutrimraf_(t,e,s),timeout++);"ENOENT"===a.code&&(a=null)}timeout=0,(t=>{i=i||t,0==--o&&r(i)})(a)};rimraf_(t,e,s)});if(e.disableGlob||!glob$1.hasMagic(t))return s(null,[t]);e.lstat(t,(r,n)=>{if(!r)return s(null,[t]);glob$1(t,e.glob,s)})},rimraf_=(t,e,r)=>{assert(t),assert(e),assert("function"==typeof r),e.lstat(t,(n,i)=>n&&"ENOENT"===n.code?r(null):(n&&"EPERM"===n.code&&isWindows$1&&fixWinEPERM(t,e,n,r),i&&i.isDirectory()?rmdir(t,e,n,r):void e.unlink(t,n=>{if(n){if("ENOENT"===n.code)return r(null);if("EPERM"===n.code)return isWindows$1?fixWinEPERM(t,e,n,r):rmdir(t,e,n,r);if("EISDIR"===n.code)return rmdir(t,e,n,r)}return r(n)})))},fixWinEPERM=(t,e,r,n)=>{assert(t),assert(e),assert("function"==typeof n),r&&assert(r instanceof Error),e.chmod(t,438,i=>{i?n("ENOENT"===i.code?null:r):e.stat(t,(i,o)=>{i?n("ENOENT"===i.code?null:r):o.isDirectory()?rmdir(t,e,r,n):e.unlink(t,n)})})},fixWinEPERMSync=(t,e,r)=>{assert(t),assert(e),r&&assert(r instanceof Error);try{e.chmodSync(t,438)}catch(t){if("ENOENT"===t.code)return;throw r}let n;try{n=e.statSync(t)}catch(t){if("ENOENT"===t.code)return;throw r}n.isDirectory()?rmdirSync(t,e,r):e.unlinkSync(t)},rmdir=(t,e,r,n)=>{assert(t),assert(e),r&&assert(r instanceof Error),assert("function"==typeof n),e.rmdir(t,i=>{!i||"ENOTEMPTY"!==i.code&&"EEXIST"!==i.code&&"EPERM"!==i.code?i&&"ENOTDIR"===i.code?n(r):n(i):rmkids(t,e,n)})},rmkids=(t,e,r)=>{assert(t),assert(e),assert("function"==typeof r),e.readdir(t,(n,i)=>{if(n)return r(n);let o,s=i.length;if(0===s)return e.rmdir(t,r);i.forEach(n=>{rimraf(path.join(t,n),e,n=>{if(!o)return n?r(o=n):void(0==--s&&e.rmdir(t,r))})})})},rimrafSync=(t,e)=>{let r;if(defaults(e=e||{}),assert(t,"rimraf: missing path"),assert.equal(typeof t,"string","rimraf: path should be a string"),assert(e,"rimraf: missing options"),assert.equal(typeof e,"object","rimraf: options should be object"),e.disableGlob||!glob$1.hasMagic(t))r=[t];else try{e.lstatSync(t),r=[t]}catch(n){r=glob$1.sync(t,e.glob)}if(r.length)for(let t=0;t{assert(t),assert(e),r&&assert(r instanceof Error);try{e.rmdirSync(t)}catch(n){if("ENOENT"===n.code)return;if("ENOTDIR"===n.code)throw r;"ENOTEMPTY"!==n.code&&"EEXIST"!==n.code&&"EPERM"!==n.code||rmkidsSync(t,e)}},rmkidsSync=(t,e)=>{assert(t),assert(e),e.readdirSync(t).forEach(r=>rimrafSync(path.join(t,r),e));const r=isWindows$1?100:1;let n=0;for(;;){let i=!0;try{const o=e.rmdirSync(t,e);return i=!1,o}finally{if(++nr("../dialog").save({filters:[{name:PLUGIN$1.ARCHIVES,extensions:["zip"]}]}))}substitutePaths(t){t=Object.assign({},t);for(let e of t["@graph"])if(e.photo)for(let t of e.photo)t.path=this.destination(t.path,".");return t}async writeJson(){const t=this.substitutePaths(this.data);return fsPromises.writeFile(join(this.dir,PLUGIN$1.ITEMS_FILE),JSON.stringify(t,null,2))}source(t){return t.path}destination(t,e=this.dir){return join(e,PLUGIN$1.IMAGES_DIR,hash$1(t))+extname(t)}*getPhotoPath(t){const e=t.photo||[];for(let t of e){const e=this.source(t);yield{src:e,dst:this.destination(e)}}}*getPhotoPaths(){for(let t of this.data["@graph"])yield*this.getPhotoPath(t)}async export(t){const{logger:e}=this.context,r=this.config.output||await this.dialog();if(r)try{this.data=t,this.dir=await fsPromises.mkdtemp(join(tmpdir(),PLUGIN$1.NAME)),await fsPromises.mkdir(join(this.dir,PLUGIN$1.IMAGES_DIR)),await this.Promise.all([this.Promise.map(this.getPhotoPaths(),({src:t,dst:e})=>fsPromises.copyFile(t,e),{concurrency:this.config.concurrency||PLUGIN$1.COPY_PROCESSES})]),await this.writeJson(),await zip$1(this.dir,r),await fsPromises.rmdir(this.dir,{recursive:!0})}catch(t){e.error(t.message)}}}var plugin=Plugin;module.exports=plugin; +"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var path=_interopDefault(require("path")),fs=_interopDefault(require("fs")),util=_interopDefault(require("util")),events=_interopDefault(require("events")),assert=_interopDefault(require("assert")),child_process=_interopDefault(require("child_process")),os=_interopDefault(require("os")),crypto=_interopDefault(require("crypto")),isWindows="win32"===process.platform,DEBUG=process.env.NODE_DEBUG&&/fs/.test(process.env.NODE_DEBUG);function rethrow(){var t;if(DEBUG){var e=new Error;t=function(t){t&&(e.message=t.message,r(t=e))}}else t=r;return t;function r(t){if(t){if(process.throwDeprecation)throw t;if(!process.noDeprecation){var e="fs: missing callback "+(t.stack||t.message);process.traceDeprecation?console.trace(e):console.error(e)}}}}function maybeCallback(t){return"function"==typeof t?t:rethrow()}var normalize=path.normalize;if(isWindows)var nextPartRe=/(.*?)(?:[\/\\]+|$)/g;else nextPartRe=/(.*?)(?:[\/]+|$)/g;if(isWindows)var splitRootRe=/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;else splitRootRe=/^[\/]*/;var realpathSync=function(t,e){if(t=path.resolve(t),e&&Object.prototype.hasOwnProperty.call(e,t))return e[t];var r,n,i,o,s=t,a={},c={};function h(){var e=splitRootRe.exec(t);r=e[0].length,n=e[0],i=e[0],o="",isWindows&&!c[i]&&(fs.lstatSync(i),c[i]=!0)}for(h();r=t.length)return e&&(e[a]=t),r(null,t);nextPartRe.lastIndex=n;var c=nextPartRe.exec(t);return s=i,i+=c[0],o=s+c[1],n=nextPartRe.lastIndex,h[o]||e&&e[o]===o?process.nextTick(p):e&&Object.prototype.hasOwnProperty.call(e,o)?m(e[o]):fs.lstat(o,u)}function u(t,n){if(t)return r(t);if(!n.isSymbolicLink())return h[o]=!0,e&&(e[o]=o),process.nextTick(p);if(!isWindows){var i=n.dev.toString(32)+":"+n.ino.toString(32);if(c.hasOwnProperty(i))return f(null,c[i],o)}fs.stat(o,function(t){if(t)return r(t);fs.readlink(o,function(t,e){isWindows||(c[i]=e),f(t,e)})})}function f(t,n,i){if(t)return r(t);var o=path.resolve(s,n);e&&(e[i]=o),m(o)}function m(e){t=path.resolve(e,t.slice(n)),l()}l()},old={realpathSync:realpathSync,realpath:realpath},fs_realpath=realpath$1;realpath$1.realpath=realpath$1,realpath$1.sync=realpathSync$1,realpath$1.realpathSync=realpathSync$1,realpath$1.monkeypatch=monkeypatch,realpath$1.unmonkeypatch=unmonkeypatch;var origRealpath=fs.realpath,origRealpathSync=fs.realpathSync,version=process.version,ok=/^v[0-5]\./.test(version);function newError(t){return t&&"realpath"===t.syscall&&("ELOOP"===t.code||"ENOMEM"===t.code||"ENAMETOOLONG"===t.code)}function realpath$1(t,e,r){if(ok)return origRealpath(t,e,r);"function"==typeof e&&(r=e,e=null),origRealpath(t,e,function(n,i){newError(n)?old.realpath(t,e,r):r(n,i)})}function realpathSync$1(t,e){if(ok)return origRealpathSync(t,e);try{return origRealpathSync(t,e)}catch(r){if(newError(r))return old.realpathSync(t,e);throw r}}function monkeypatch(){fs.realpath=realpath$1,fs.realpathSync=realpathSync$1}function unmonkeypatch(){fs.realpath=origRealpath,fs.realpathSync=origRealpathSync}var concatMap=function(t,e){for(var r=[],n=0;n=0&&h>0){for(n=[],o=r.length;l>=0&&!a;)l==c?(n.push(l),c=r.indexOf(t,l+1)):1==n.length?a=[n.pop(),h]:((i=n.pop())=0?c:h;n.length&&(a=[o,s])}return a}balanced.range=range;var braceExpansion=expandTop,escSlash="\0SLASH"+Math.random()+"\0",escOpen="\0OPEN"+Math.random()+"\0",escClose="\0CLOSE"+Math.random()+"\0",escComma="\0COMMA"+Math.random()+"\0",escPeriod="\0PERIOD"+Math.random()+"\0";function numeric(t){return parseInt(t,10)==t?parseInt(t,10):t.charCodeAt(0)}function escapeBraces(t){return t.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod)}function unescapeBraces(t){return t.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".")}function parseCommaParts(t){if(!t)return[""];var e=[],r=balancedMatch("{","}",t);if(!r)return t.split(",");var n=r.pre,i=r.body,o=r.post,s=n.split(",");s[s.length-1]+="{"+i+"}";var a=parseCommaParts(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),e.push.apply(e,s),e}function expandTop(t){return t?("{}"===t.substr(0,2)&&(t="\\{\\}"+t.substr(2)),expand(escapeBraces(t),!0).map(unescapeBraces)):[]}function embrace(t){return"{"+t+"}"}function isPadded(t){return/^-?0\d/.test(t)}function lte(t,e){return t<=e}function gte(t,e){return t>=e}function expand(t,e){var r=[],n=balancedMatch("{","}",t);if(!n||/\$$/.test(n.pre))return[t];var i,o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),s=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),a=o||s,c=n.body.indexOf(",")>=0;if(!a&&!c)return n.post.match(/,.*\}/)?expand(t=n.pre+"{"+n.body+escClose+n.post):[t];if(a)i=n.body.split(/\.\./);else if(1===(i=parseCommaParts(n.body)).length&&1===(i=expand(i[0],!1).map(embrace)).length)return(p=n.post.length?expand(n.post,!1):[""]).map(function(t){return n.pre+i[0]+t});var h,l=n.pre,p=n.post.length?expand(n.post,!1):[""];if(a){var u=numeric(i[0]),f=numeric(i[1]),m=Math.max(i[0].length,i[1].length),d=3==i.length?Math.abs(numeric(i[2])):1,g=lte;f0){var w=new Array(E+1).join("0");v=b<0?"-"+w+v.slice(1):w+v}}h.push(v)}}else h=concatMap(i,function(t){return expand(t,!1)});for(var S=0;S65536)throw new TypeError("pattern is too long");var r=this.options;if(!r.noglobstar&&"**"===t)return GLOBSTAR;if(""===t)return"";var n,i="",o=!!r.nocase,s=!1,a=[],c=[],h=!1,l=-1,p=-1,u="."===t.charAt(0)?"":r.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",f=this;function m(){if(n){switch(n){case"*":i+=star,o=!0;break;case"?":i+=qmark,o=!0;break;default:i+="\\"+n}f.debug("clearStateChar %j %j",n,i),n=!1}}for(var d,g=0,y=t.length;g-1;O--){var x=c[O],k=i.slice(0,x.reStart),P=i.slice(x.reStart,x.reEnd-8),A=i.slice(x.reEnd-8,x.reEnd),I=i.slice(x.reEnd);A+=I;var R=k.split("(").length-1,$=I;for(g=0;g=0&&!(n=t[i]);i--);for(i=0;i>> no match, partial?",t,p,e,u),p!==s))}if("string"==typeof h?(c=n.nocase?l.toLowerCase()===h.toLowerCase():l===h,this.debug("string match",h,l,c)):(c=l.match(h),this.debug("pattern match",h,l,c)),!c)return!1}if(i===s&&o===a)return!0;if(i===s)return r;if(o===a)return i===s-1&&""===t[i];throw new Error("wtf?")};var inherits_browser=createCommonjsModule(function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}}),inherits=createCommonjsModule(function(t){try{var e=util;if("function"!=typeof e.inherits)throw"";t.exports=e.inherits}catch(e){t.exports=inherits_browser}});function posix(t){return"/"===t.charAt(0)}function win32(t){var e=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/.exec(t),r=e[1]||"",n=Boolean(r&&":"!==r.charAt(1));return Boolean(e[2]||n)}var pathIsAbsolute="win32"===process.platform?win32:posix,posix_1=posix,win32_1=win32;pathIsAbsolute.posix=posix_1,pathIsAbsolute.win32=win32_1;var alphasort_1=alphasort,alphasorti_1=alphasorti,setopts_1=setopts,ownProp_1=ownProp,makeAbs_1=makeAbs,finish_1=finish,mark_1=mark,isIgnored_1=isIgnored,childrenIgnored_1=childrenIgnored;function ownProp(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var Minimatch$1=minimatch_1.Minimatch;function alphasorti(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}function alphasort(t,e){return t.localeCompare(e)}function setupIgnores(t,e){t.ignore=e.ignore||[],Array.isArray(t.ignore)||(t.ignore=[t.ignore]),t.ignore.length&&(t.ignore=t.ignore.map(ignoreMap))}function ignoreMap(t){var e=null;if("/**"===t.slice(-3)){var r=t.replace(/(\/\*\*)+$/,"");e=new Minimatch$1(r,{dot:!0})}return{matcher:new Minimatch$1(t,{dot:!0}),gmatcher:e}}function setopts(t,e,r){if(r||(r={}),r.matchBase&&-1===e.indexOf("/")){if(r.noglobstar)throw new Error("base matching requires globstar");e="**/"+e}t.silent=!!r.silent,t.pattern=e,t.strict=!1!==r.strict,t.realpath=!!r.realpath,t.realpathCache=r.realpathCache||Object.create(null),t.follow=!!r.follow,t.dot=!!r.dot,t.mark=!!r.mark,t.nodir=!!r.nodir,t.nodir&&(t.mark=!0),t.sync=!!r.sync,t.nounique=!!r.nounique,t.nonull=!!r.nonull,t.nosort=!!r.nosort,t.nocase=!!r.nocase,t.stat=!!r.stat,t.noprocess=!!r.noprocess,t.absolute=!!r.absolute,t.maxLength=r.maxLength||1/0,t.cache=r.cache||Object.create(null),t.statCache=r.statCache||Object.create(null),t.symlinks=r.symlinks||Object.create(null),setupIgnores(t,r),t.changedCwd=!1;var n=process.cwd();ownProp(r,"cwd")?(t.cwd=path.resolve(r.cwd),t.changedCwd=t.cwd!==n):t.cwd=n,t.root=r.root||path.resolve(t.cwd,"/"),t.root=path.resolve(t.root),"win32"===process.platform&&(t.root=t.root.replace(/\\/g,"/")),t.cwdAbs=pathIsAbsolute(t.cwd)?t.cwd:makeAbs(t,t.cwd),"win32"===process.platform&&(t.cwdAbs=t.cwdAbs.replace(/\\/g,"/")),t.nomount=!!r.nomount,r.nonegate=!0,r.nocomment=!0,t.minimatch=new Minimatch$1(e,r),t.options=t.minimatch.options}function finish(t){for(var e=t.nounique,r=e?[]:Object.create(null),n=0,i=t.matches.length;nn?(r.splice(0,n),process.nextTick(function(){e.apply(null,i)})):delete reqs[t]}})}function slice(t){for(var e=t.length,r=[],n=0;n1)return!0;for(var i=0;ithis.maxLength)return e();if(!this.stat&&ownProp$1(this.cache,r)){var i=this.cache[r];if(Array.isArray(i)&&(i="DIR"),!n||"DIR"===i)return e(null,i);if(n&&"FILE"===i)return e()}var o=this.statCache[r];if(void 0!==o){if(!1===o)return e(null,o);var s=o.isDirectory()?"DIR":"FILE";return n&&"FILE"===s?e():e(null,s,o)}var a=this,c=inflight_1("stat\0"+r,function(n,i){if(i&&i.isSymbolicLink())return fs.stat(r,function(n,o){n?a._stat2(t,r,null,i,e):a._stat2(t,r,n,o,e)});a._stat2(t,r,n,i,e)});c&&fs.lstat(r,c)},Glob.prototype._stat2=function(t,e,r,n,i){if(r&&("ENOENT"===r.code||"ENOTDIR"===r.code))return this.statCache[e]=!1,i();var o="/"===t.slice(-1);if(this.statCache[e]=n,"/"===e.slice(-1)&&n&&!n.isDirectory())return i(null,!1,n);var s=!0;return n&&(s=n.isDirectory()?"DIR":"FILE"),this.cache[e]=this.cache[e]||s,o&&"FILE"===s?i():i(null,s,n)};let glob$1=void 0;try{glob$1=glob_1}catch(t){}const defaultGlobOpts={nosort:!0,silent:!0};let timeout=0;const isWindows$1="win32"===process.platform,defaults=t=>{if(["unlink","chmod","stat","lstat","rmdir","readdir"].forEach(e=>{t[e]=t[e]||fs[e],t[e+="Sync"]=t[e]||fs[e]}),t.maxBusyTries=t.maxBusyTries||3,t.emfileWait=t.emfileWait||1e3,!1===t.glob&&(t.disableGlob=!0),!0!==t.disableGlob&&void 0===glob$1)throw Error("glob dependency not found, set `options.disableGlob = true` if intentional");t.disableGlob=t.disableGlob||!1,t.glob=t.glob||defaultGlobOpts},rimraf=(t,e,r)=>{"function"==typeof e&&(r=e,e={}),assert(t,"rimraf: missing path"),assert.equal(typeof t,"string","rimraf: path should be a string"),assert.equal(typeof r,"function","rimraf: callback function required"),assert(e,"rimraf: invalid options argument provided"),assert.equal(typeof e,"object","rimraf: options should be object"),defaults(e);let n=0,i=null,o=0;const s=(t,s)=>t?r(t):0===(o=s.length)?r():void s.forEach(t=>{const s=a=>{if(a){if(("EBUSY"===a.code||"ENOTEMPTY"===a.code||"EPERM"===a.code)&&nrimraf_(t,e,s),100*n);if("EMFILE"===a.code&&timeoutrimraf_(t,e,s),timeout++);"ENOENT"===a.code&&(a=null)}timeout=0,(t=>{i=i||t,0==--o&&r(i)})(a)};rimraf_(t,e,s)});if(e.disableGlob||!glob$1.hasMagic(t))return s(null,[t]);e.lstat(t,(r,n)=>{if(!r)return s(null,[t]);glob$1(t,e.glob,s)})},rimraf_=(t,e,r)=>{assert(t),assert(e),assert("function"==typeof r),e.lstat(t,(n,i)=>n&&"ENOENT"===n.code?r(null):(n&&"EPERM"===n.code&&isWindows$1&&fixWinEPERM(t,e,n,r),i&&i.isDirectory()?rmdir(t,e,n,r):void e.unlink(t,n=>{if(n){if("ENOENT"===n.code)return r(null);if("EPERM"===n.code)return isWindows$1?fixWinEPERM(t,e,n,r):rmdir(t,e,n,r);if("EISDIR"===n.code)return rmdir(t,e,n,r)}return r(n)})))},fixWinEPERM=(t,e,r,n)=>{assert(t),assert(e),assert("function"==typeof n),r&&assert(r instanceof Error),e.chmod(t,438,i=>{i?n("ENOENT"===i.code?null:r):e.stat(t,(i,o)=>{i?n("ENOENT"===i.code?null:r):o.isDirectory()?rmdir(t,e,r,n):e.unlink(t,n)})})},fixWinEPERMSync=(t,e,r)=>{assert(t),assert(e),r&&assert(r instanceof Error);try{e.chmodSync(t,438)}catch(t){if("ENOENT"===t.code)return;throw r}let n;try{n=e.statSync(t)}catch(t){if("ENOENT"===t.code)return;throw r}n.isDirectory()?rmdirSync(t,e,r):e.unlinkSync(t)},rmdir=(t,e,r,n)=>{assert(t),assert(e),r&&assert(r instanceof Error),assert("function"==typeof n),e.rmdir(t,i=>{!i||"ENOTEMPTY"!==i.code&&"EEXIST"!==i.code&&"EPERM"!==i.code?i&&"ENOTDIR"===i.code?n(r):n(i):rmkids(t,e,n)})},rmkids=(t,e,r)=>{assert(t),assert(e),assert("function"==typeof r),e.readdir(t,(n,i)=>{if(n)return r(n);let o,s=i.length;if(0===s)return e.rmdir(t,r);i.forEach(n=>{rimraf(path.join(t,n),e,n=>{if(!o)return n?r(o=n):void(0==--s&&e.rmdir(t,r))})})})},rimrafSync=(t,e)=>{let r;if(defaults(e=e||{}),assert(t,"rimraf: missing path"),assert.equal(typeof t,"string","rimraf: path should be a string"),assert(e,"rimraf: missing options"),assert.equal(typeof e,"object","rimraf: options should be object"),e.disableGlob||!glob$1.hasMagic(t))r=[t];else try{e.lstatSync(t),r=[t]}catch(n){r=glob$1.sync(t,e.glob)}if(r.length)for(let t=0;t{assert(t),assert(e),r&&assert(r instanceof Error);try{e.rmdirSync(t)}catch(n){if("ENOENT"===n.code)return;if("ENOTDIR"===n.code)throw r;"ENOTEMPTY"!==n.code&&"EEXIST"!==n.code&&"EPERM"!==n.code||rmkidsSync(t,e)}},rmkidsSync=(t,e)=>{assert(t),assert(e),e.readdirSync(t).forEach(r=>rimrafSync(path.join(t,r),e));const r=isWindows$1?100:1;let n=0;for(;;){let i=!0;try{const o=e.rmdirSync(t,e);return i=!1,o}finally{if(++nr("../dialog").save({filters:[{name:PLUGIN$1.ARCHIVES,extensions:["zip"]}]}))}substitutePaths(t){for(let e of t["@graph"])if(e.photo)for(let t of e.photo)t.path=this.destination(t.path,".");return t}async writeJson(){const t=this.substitutePaths(this.data);return fsPromises.writeFile(join(this.dir,PLUGIN$1.ITEMS_FILE),JSON.stringify(t,null,2))}source(t){return t.path}destination(t,e=this.dir){return join(e,PLUGIN$1.IMAGES_DIR,hash$1(t))+extname(t)}*getPhotoPath(t){const e=t.photo||[];for(let t of e){const e=this.source(t);yield{src:e,dst:this.destination(e)}}}*getPhotoPaths(){for(let t of this.data["@graph"])yield*this.getPhotoPath(t)}async export(t){const{logger:e}=this.context,r=this.config.output||await this.dialog();if(r)try{this.data=t,this.dir=await fsPromises.mkdtemp(join(tmpdir(),PLUGIN$1.NAME)),await fsPromises.mkdir(join(this.dir,PLUGIN$1.IMAGES_DIR)),await this.Promise.all([this.Promise.map(this.getPhotoPaths(),({src:t,dst:e})=>fsPromises.copyFile(t,e),{concurrency:this.config.concurrency||PLUGIN$1.COPY_PROCESSES})]),await this.writeJson(),await zip$1(this.dir,r),await fsPromises.rmdir(this.dir,{recursive:!0})}catch(t){e.error(t.message)}}}var plugin=Plugin;module.exports=plugin; diff --git a/src/plugin.js b/src/plugin.js index 4515eed..88b4c31 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -29,7 +29,6 @@ class Plugin { } substitutePaths(jsonld) { - jsonld = Object.assign({}, jsonld) for (let item of jsonld['@graph']) { if (!item.photo) continue for (let photo of item.photo) { From 57cec85e2e4dd1d8a2347b0a5b3f17ab6cdc9bdf Mon Sep 17 00:00:00 2001 From: Roberto Martinez Date: Mon, 9 Mar 2020 15:53:30 -0400 Subject: [PATCH 3/3] Update version, add file select --- bundle.js | 2 +- package.json | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bundle.js b/bundle.js index b210ce2..a4f88d8 100644 --- a/bundle.js +++ b/bundle.js @@ -1 +1 @@ -"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var path=_interopDefault(require("path")),fs=_interopDefault(require("fs")),util=_interopDefault(require("util")),events=_interopDefault(require("events")),assert=_interopDefault(require("assert")),child_process=_interopDefault(require("child_process")),os=_interopDefault(require("os")),crypto=_interopDefault(require("crypto")),isWindows="win32"===process.platform,DEBUG=process.env.NODE_DEBUG&&/fs/.test(process.env.NODE_DEBUG);function rethrow(){var t;if(DEBUG){var e=new Error;t=function(t){t&&(e.message=t.message,r(t=e))}}else t=r;return t;function r(t){if(t){if(process.throwDeprecation)throw t;if(!process.noDeprecation){var e="fs: missing callback "+(t.stack||t.message);process.traceDeprecation?console.trace(e):console.error(e)}}}}function maybeCallback(t){return"function"==typeof t?t:rethrow()}var normalize=path.normalize;if(isWindows)var nextPartRe=/(.*?)(?:[\/\\]+|$)/g;else nextPartRe=/(.*?)(?:[\/]+|$)/g;if(isWindows)var splitRootRe=/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;else splitRootRe=/^[\/]*/;var realpathSync=function(t,e){if(t=path.resolve(t),e&&Object.prototype.hasOwnProperty.call(e,t))return e[t];var r,n,i,o,s=t,a={},c={};function h(){var e=splitRootRe.exec(t);r=e[0].length,n=e[0],i=e[0],o="",isWindows&&!c[i]&&(fs.lstatSync(i),c[i]=!0)}for(h();r=t.length)return e&&(e[a]=t),r(null,t);nextPartRe.lastIndex=n;var c=nextPartRe.exec(t);return s=i,i+=c[0],o=s+c[1],n=nextPartRe.lastIndex,h[o]||e&&e[o]===o?process.nextTick(p):e&&Object.prototype.hasOwnProperty.call(e,o)?m(e[o]):fs.lstat(o,u)}function u(t,n){if(t)return r(t);if(!n.isSymbolicLink())return h[o]=!0,e&&(e[o]=o),process.nextTick(p);if(!isWindows){var i=n.dev.toString(32)+":"+n.ino.toString(32);if(c.hasOwnProperty(i))return f(null,c[i],o)}fs.stat(o,function(t){if(t)return r(t);fs.readlink(o,function(t,e){isWindows||(c[i]=e),f(t,e)})})}function f(t,n,i){if(t)return r(t);var o=path.resolve(s,n);e&&(e[i]=o),m(o)}function m(e){t=path.resolve(e,t.slice(n)),l()}l()},old={realpathSync:realpathSync,realpath:realpath},fs_realpath=realpath$1;realpath$1.realpath=realpath$1,realpath$1.sync=realpathSync$1,realpath$1.realpathSync=realpathSync$1,realpath$1.monkeypatch=monkeypatch,realpath$1.unmonkeypatch=unmonkeypatch;var origRealpath=fs.realpath,origRealpathSync=fs.realpathSync,version=process.version,ok=/^v[0-5]\./.test(version);function newError(t){return t&&"realpath"===t.syscall&&("ELOOP"===t.code||"ENOMEM"===t.code||"ENAMETOOLONG"===t.code)}function realpath$1(t,e,r){if(ok)return origRealpath(t,e,r);"function"==typeof e&&(r=e,e=null),origRealpath(t,e,function(n,i){newError(n)?old.realpath(t,e,r):r(n,i)})}function realpathSync$1(t,e){if(ok)return origRealpathSync(t,e);try{return origRealpathSync(t,e)}catch(r){if(newError(r))return old.realpathSync(t,e);throw r}}function monkeypatch(){fs.realpath=realpath$1,fs.realpathSync=realpathSync$1}function unmonkeypatch(){fs.realpath=origRealpath,fs.realpathSync=origRealpathSync}var concatMap=function(t,e){for(var r=[],n=0;n=0&&h>0){for(n=[],o=r.length;l>=0&&!a;)l==c?(n.push(l),c=r.indexOf(t,l+1)):1==n.length?a=[n.pop(),h]:((i=n.pop())=0?c:h;n.length&&(a=[o,s])}return a}balanced.range=range;var braceExpansion=expandTop,escSlash="\0SLASH"+Math.random()+"\0",escOpen="\0OPEN"+Math.random()+"\0",escClose="\0CLOSE"+Math.random()+"\0",escComma="\0COMMA"+Math.random()+"\0",escPeriod="\0PERIOD"+Math.random()+"\0";function numeric(t){return parseInt(t,10)==t?parseInt(t,10):t.charCodeAt(0)}function escapeBraces(t){return t.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod)}function unescapeBraces(t){return t.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".")}function parseCommaParts(t){if(!t)return[""];var e=[],r=balancedMatch("{","}",t);if(!r)return t.split(",");var n=r.pre,i=r.body,o=r.post,s=n.split(",");s[s.length-1]+="{"+i+"}";var a=parseCommaParts(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),e.push.apply(e,s),e}function expandTop(t){return t?("{}"===t.substr(0,2)&&(t="\\{\\}"+t.substr(2)),expand(escapeBraces(t),!0).map(unescapeBraces)):[]}function embrace(t){return"{"+t+"}"}function isPadded(t){return/^-?0\d/.test(t)}function lte(t,e){return t<=e}function gte(t,e){return t>=e}function expand(t,e){var r=[],n=balancedMatch("{","}",t);if(!n||/\$$/.test(n.pre))return[t];var i,o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),s=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),a=o||s,c=n.body.indexOf(",")>=0;if(!a&&!c)return n.post.match(/,.*\}/)?expand(t=n.pre+"{"+n.body+escClose+n.post):[t];if(a)i=n.body.split(/\.\./);else if(1===(i=parseCommaParts(n.body)).length&&1===(i=expand(i[0],!1).map(embrace)).length)return(p=n.post.length?expand(n.post,!1):[""]).map(function(t){return n.pre+i[0]+t});var h,l=n.pre,p=n.post.length?expand(n.post,!1):[""];if(a){var u=numeric(i[0]),f=numeric(i[1]),m=Math.max(i[0].length,i[1].length),d=3==i.length?Math.abs(numeric(i[2])):1,g=lte;f0){var w=new Array(E+1).join("0");v=b<0?"-"+w+v.slice(1):w+v}}h.push(v)}}else h=concatMap(i,function(t){return expand(t,!1)});for(var S=0;S65536)throw new TypeError("pattern is too long");var r=this.options;if(!r.noglobstar&&"**"===t)return GLOBSTAR;if(""===t)return"";var n,i="",o=!!r.nocase,s=!1,a=[],c=[],h=!1,l=-1,p=-1,u="."===t.charAt(0)?"":r.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",f=this;function m(){if(n){switch(n){case"*":i+=star,o=!0;break;case"?":i+=qmark,o=!0;break;default:i+="\\"+n}f.debug("clearStateChar %j %j",n,i),n=!1}}for(var d,g=0,y=t.length;g-1;O--){var x=c[O],k=i.slice(0,x.reStart),P=i.slice(x.reStart,x.reEnd-8),A=i.slice(x.reEnd-8,x.reEnd),I=i.slice(x.reEnd);A+=I;var R=k.split("(").length-1,$=I;for(g=0;g=0&&!(n=t[i]);i--);for(i=0;i>> no match, partial?",t,p,e,u),p!==s))}if("string"==typeof h?(c=n.nocase?l.toLowerCase()===h.toLowerCase():l===h,this.debug("string match",h,l,c)):(c=l.match(h),this.debug("pattern match",h,l,c)),!c)return!1}if(i===s&&o===a)return!0;if(i===s)return r;if(o===a)return i===s-1&&""===t[i];throw new Error("wtf?")};var inherits_browser=createCommonjsModule(function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}}),inherits=createCommonjsModule(function(t){try{var e=util;if("function"!=typeof e.inherits)throw"";t.exports=e.inherits}catch(e){t.exports=inherits_browser}});function posix(t){return"/"===t.charAt(0)}function win32(t){var e=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/.exec(t),r=e[1]||"",n=Boolean(r&&":"!==r.charAt(1));return Boolean(e[2]||n)}var pathIsAbsolute="win32"===process.platform?win32:posix,posix_1=posix,win32_1=win32;pathIsAbsolute.posix=posix_1,pathIsAbsolute.win32=win32_1;var alphasort_1=alphasort,alphasorti_1=alphasorti,setopts_1=setopts,ownProp_1=ownProp,makeAbs_1=makeAbs,finish_1=finish,mark_1=mark,isIgnored_1=isIgnored,childrenIgnored_1=childrenIgnored;function ownProp(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var Minimatch$1=minimatch_1.Minimatch;function alphasorti(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}function alphasort(t,e){return t.localeCompare(e)}function setupIgnores(t,e){t.ignore=e.ignore||[],Array.isArray(t.ignore)||(t.ignore=[t.ignore]),t.ignore.length&&(t.ignore=t.ignore.map(ignoreMap))}function ignoreMap(t){var e=null;if("/**"===t.slice(-3)){var r=t.replace(/(\/\*\*)+$/,"");e=new Minimatch$1(r,{dot:!0})}return{matcher:new Minimatch$1(t,{dot:!0}),gmatcher:e}}function setopts(t,e,r){if(r||(r={}),r.matchBase&&-1===e.indexOf("/")){if(r.noglobstar)throw new Error("base matching requires globstar");e="**/"+e}t.silent=!!r.silent,t.pattern=e,t.strict=!1!==r.strict,t.realpath=!!r.realpath,t.realpathCache=r.realpathCache||Object.create(null),t.follow=!!r.follow,t.dot=!!r.dot,t.mark=!!r.mark,t.nodir=!!r.nodir,t.nodir&&(t.mark=!0),t.sync=!!r.sync,t.nounique=!!r.nounique,t.nonull=!!r.nonull,t.nosort=!!r.nosort,t.nocase=!!r.nocase,t.stat=!!r.stat,t.noprocess=!!r.noprocess,t.absolute=!!r.absolute,t.maxLength=r.maxLength||1/0,t.cache=r.cache||Object.create(null),t.statCache=r.statCache||Object.create(null),t.symlinks=r.symlinks||Object.create(null),setupIgnores(t,r),t.changedCwd=!1;var n=process.cwd();ownProp(r,"cwd")?(t.cwd=path.resolve(r.cwd),t.changedCwd=t.cwd!==n):t.cwd=n,t.root=r.root||path.resolve(t.cwd,"/"),t.root=path.resolve(t.root),"win32"===process.platform&&(t.root=t.root.replace(/\\/g,"/")),t.cwdAbs=pathIsAbsolute(t.cwd)?t.cwd:makeAbs(t,t.cwd),"win32"===process.platform&&(t.cwdAbs=t.cwdAbs.replace(/\\/g,"/")),t.nomount=!!r.nomount,r.nonegate=!0,r.nocomment=!0,t.minimatch=new Minimatch$1(e,r),t.options=t.minimatch.options}function finish(t){for(var e=t.nounique,r=e?[]:Object.create(null),n=0,i=t.matches.length;nn?(r.splice(0,n),process.nextTick(function(){e.apply(null,i)})):delete reqs[t]}})}function slice(t){for(var e=t.length,r=[],n=0;n1)return!0;for(var i=0;ithis.maxLength)return e();if(!this.stat&&ownProp$1(this.cache,r)){var i=this.cache[r];if(Array.isArray(i)&&(i="DIR"),!n||"DIR"===i)return e(null,i);if(n&&"FILE"===i)return e()}var o=this.statCache[r];if(void 0!==o){if(!1===o)return e(null,o);var s=o.isDirectory()?"DIR":"FILE";return n&&"FILE"===s?e():e(null,s,o)}var a=this,c=inflight_1("stat\0"+r,function(n,i){if(i&&i.isSymbolicLink())return fs.stat(r,function(n,o){n?a._stat2(t,r,null,i,e):a._stat2(t,r,n,o,e)});a._stat2(t,r,n,i,e)});c&&fs.lstat(r,c)},Glob.prototype._stat2=function(t,e,r,n,i){if(r&&("ENOENT"===r.code||"ENOTDIR"===r.code))return this.statCache[e]=!1,i();var o="/"===t.slice(-1);if(this.statCache[e]=n,"/"===e.slice(-1)&&n&&!n.isDirectory())return i(null,!1,n);var s=!0;return n&&(s=n.isDirectory()?"DIR":"FILE"),this.cache[e]=this.cache[e]||s,o&&"FILE"===s?i():i(null,s,n)};let glob$1=void 0;try{glob$1=glob_1}catch(t){}const defaultGlobOpts={nosort:!0,silent:!0};let timeout=0;const isWindows$1="win32"===process.platform,defaults=t=>{if(["unlink","chmod","stat","lstat","rmdir","readdir"].forEach(e=>{t[e]=t[e]||fs[e],t[e+="Sync"]=t[e]||fs[e]}),t.maxBusyTries=t.maxBusyTries||3,t.emfileWait=t.emfileWait||1e3,!1===t.glob&&(t.disableGlob=!0),!0!==t.disableGlob&&void 0===glob$1)throw Error("glob dependency not found, set `options.disableGlob = true` if intentional");t.disableGlob=t.disableGlob||!1,t.glob=t.glob||defaultGlobOpts},rimraf=(t,e,r)=>{"function"==typeof e&&(r=e,e={}),assert(t,"rimraf: missing path"),assert.equal(typeof t,"string","rimraf: path should be a string"),assert.equal(typeof r,"function","rimraf: callback function required"),assert(e,"rimraf: invalid options argument provided"),assert.equal(typeof e,"object","rimraf: options should be object"),defaults(e);let n=0,i=null,o=0;const s=(t,s)=>t?r(t):0===(o=s.length)?r():void s.forEach(t=>{const s=a=>{if(a){if(("EBUSY"===a.code||"ENOTEMPTY"===a.code||"EPERM"===a.code)&&nrimraf_(t,e,s),100*n);if("EMFILE"===a.code&&timeoutrimraf_(t,e,s),timeout++);"ENOENT"===a.code&&(a=null)}timeout=0,(t=>{i=i||t,0==--o&&r(i)})(a)};rimraf_(t,e,s)});if(e.disableGlob||!glob$1.hasMagic(t))return s(null,[t]);e.lstat(t,(r,n)=>{if(!r)return s(null,[t]);glob$1(t,e.glob,s)})},rimraf_=(t,e,r)=>{assert(t),assert(e),assert("function"==typeof r),e.lstat(t,(n,i)=>n&&"ENOENT"===n.code?r(null):(n&&"EPERM"===n.code&&isWindows$1&&fixWinEPERM(t,e,n,r),i&&i.isDirectory()?rmdir(t,e,n,r):void e.unlink(t,n=>{if(n){if("ENOENT"===n.code)return r(null);if("EPERM"===n.code)return isWindows$1?fixWinEPERM(t,e,n,r):rmdir(t,e,n,r);if("EISDIR"===n.code)return rmdir(t,e,n,r)}return r(n)})))},fixWinEPERM=(t,e,r,n)=>{assert(t),assert(e),assert("function"==typeof n),r&&assert(r instanceof Error),e.chmod(t,438,i=>{i?n("ENOENT"===i.code?null:r):e.stat(t,(i,o)=>{i?n("ENOENT"===i.code?null:r):o.isDirectory()?rmdir(t,e,r,n):e.unlink(t,n)})})},fixWinEPERMSync=(t,e,r)=>{assert(t),assert(e),r&&assert(r instanceof Error);try{e.chmodSync(t,438)}catch(t){if("ENOENT"===t.code)return;throw r}let n;try{n=e.statSync(t)}catch(t){if("ENOENT"===t.code)return;throw r}n.isDirectory()?rmdirSync(t,e,r):e.unlinkSync(t)},rmdir=(t,e,r,n)=>{assert(t),assert(e),r&&assert(r instanceof Error),assert("function"==typeof n),e.rmdir(t,i=>{!i||"ENOTEMPTY"!==i.code&&"EEXIST"!==i.code&&"EPERM"!==i.code?i&&"ENOTDIR"===i.code?n(r):n(i):rmkids(t,e,n)})},rmkids=(t,e,r)=>{assert(t),assert(e),assert("function"==typeof r),e.readdir(t,(n,i)=>{if(n)return r(n);let o,s=i.length;if(0===s)return e.rmdir(t,r);i.forEach(n=>{rimraf(path.join(t,n),e,n=>{if(!o)return n?r(o=n):void(0==--s&&e.rmdir(t,r))})})})},rimrafSync=(t,e)=>{let r;if(defaults(e=e||{}),assert(t,"rimraf: missing path"),assert.equal(typeof t,"string","rimraf: path should be a string"),assert(e,"rimraf: missing options"),assert.equal(typeof e,"object","rimraf: options should be object"),e.disableGlob||!glob$1.hasMagic(t))r=[t];else try{e.lstatSync(t),r=[t]}catch(n){r=glob$1.sync(t,e.glob)}if(r.length)for(let t=0;t{assert(t),assert(e),r&&assert(r instanceof Error);try{e.rmdirSync(t)}catch(n){if("ENOENT"===n.code)return;if("ENOTDIR"===n.code)throw r;"ENOTEMPTY"!==n.code&&"EEXIST"!==n.code&&"EPERM"!==n.code||rmkidsSync(t,e)}},rmkidsSync=(t,e)=>{assert(t),assert(e),e.readdirSync(t).forEach(r=>rimrafSync(path.join(t,r),e));const r=isWindows$1?100:1;let n=0;for(;;){let i=!0;try{const o=e.rmdirSync(t,e);return i=!1,o}finally{if(++nr("../dialog").save({filters:[{name:PLUGIN$1.ARCHIVES,extensions:["zip"]}]}))}substitutePaths(t){for(let e of t["@graph"])if(e.photo)for(let t of e.photo)t.path=this.destination(t.path,".");return t}async writeJson(){const t=this.substitutePaths(this.data);return fsPromises.writeFile(join(this.dir,PLUGIN$1.ITEMS_FILE),JSON.stringify(t,null,2))}source(t){return t.path}destination(t,e=this.dir){return join(e,PLUGIN$1.IMAGES_DIR,hash$1(t))+extname(t)}*getPhotoPath(t){const e=t.photo||[];for(let t of e){const e=this.source(t);yield{src:e,dst:this.destination(e)}}}*getPhotoPaths(){for(let t of this.data["@graph"])yield*this.getPhotoPath(t)}async export(t){const{logger:e}=this.context,r=this.config.output||await this.dialog();if(r)try{this.data=t,this.dir=await fsPromises.mkdtemp(join(tmpdir(),PLUGIN$1.NAME)),await fsPromises.mkdir(join(this.dir,PLUGIN$1.IMAGES_DIR)),await this.Promise.all([this.Promise.map(this.getPhotoPaths(),({src:t,dst:e})=>fsPromises.copyFile(t,e),{concurrency:this.config.concurrency||PLUGIN$1.COPY_PROCESSES})]),await this.writeJson(),await zip$1(this.dir,r),await fsPromises.rmdir(this.dir,{recursive:!0})}catch(t){e.error(t.message)}}}var plugin=Plugin;module.exports=plugin; +"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var path=_interopDefault(require("path")),fs=_interopDefault(require("fs")),util=_interopDefault(require("util")),events=_interopDefault(require("events")),assert=_interopDefault(require("assert")),child_process=_interopDefault(require("child_process")),os=_interopDefault(require("os")),crypto=_interopDefault(require("crypto")),isWindows="win32"===process.platform,DEBUG=process.env.NODE_DEBUG&&/fs/.test(process.env.NODE_DEBUG);function rethrow(){var t;if(DEBUG){var e=new Error;t=function(t){t&&(e.message=t.message,r(t=e))}}else t=r;return t;function r(t){if(t){if(process.throwDeprecation)throw t;if(!process.noDeprecation){var e="fs: missing callback "+(t.stack||t.message);process.traceDeprecation?console.trace(e):console.error(e)}}}}function maybeCallback(t){return"function"==typeof t?t:rethrow()}var normalize=path.normalize;if(isWindows)var nextPartRe=/(.*?)(?:[\/\\]+|$)/g;else nextPartRe=/(.*?)(?:[\/]+|$)/g;if(isWindows)var splitRootRe=/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;else splitRootRe=/^[\/]*/;var realpathSync=function(t,e){if(t=path.resolve(t),e&&Object.prototype.hasOwnProperty.call(e,t))return e[t];var r,n,i,o,s=t,a={},c={};function h(){var e=splitRootRe.exec(t);r=e[0].length,n=e[0],i=e[0],o="",isWindows&&!c[i]&&(fs.lstatSync(i),c[i]=!0)}for(h();r=t.length)return e&&(e[a]=t),r(null,t);nextPartRe.lastIndex=n;var c=nextPartRe.exec(t);return s=i,i+=c[0],o=s+c[1],n=nextPartRe.lastIndex,h[o]||e&&e[o]===o?process.nextTick(p):e&&Object.prototype.hasOwnProperty.call(e,o)?m(e[o]):fs.lstat(o,u)}function u(t,n){if(t)return r(t);if(!n.isSymbolicLink())return h[o]=!0,e&&(e[o]=o),process.nextTick(p);if(!isWindows){var i=n.dev.toString(32)+":"+n.ino.toString(32);if(c.hasOwnProperty(i))return f(null,c[i],o)}fs.stat(o,function(t){if(t)return r(t);fs.readlink(o,function(t,e){isWindows||(c[i]=e),f(t,e)})})}function f(t,n,i){if(t)return r(t);var o=path.resolve(s,n);e&&(e[i]=o),m(o)}function m(e){t=path.resolve(e,t.slice(n)),l()}l()},old={realpathSync:realpathSync,realpath:realpath},fs_realpath=realpath$1;realpath$1.realpath=realpath$1,realpath$1.sync=realpathSync$1,realpath$1.realpathSync=realpathSync$1,realpath$1.monkeypatch=monkeypatch,realpath$1.unmonkeypatch=unmonkeypatch;var origRealpath=fs.realpath,origRealpathSync=fs.realpathSync,version=process.version,ok=/^v[0-5]\./.test(version);function newError(t){return t&&"realpath"===t.syscall&&("ELOOP"===t.code||"ENOMEM"===t.code||"ENAMETOOLONG"===t.code)}function realpath$1(t,e,r){if(ok)return origRealpath(t,e,r);"function"==typeof e&&(r=e,e=null),origRealpath(t,e,function(n,i){newError(n)?old.realpath(t,e,r):r(n,i)})}function realpathSync$1(t,e){if(ok)return origRealpathSync(t,e);try{return origRealpathSync(t,e)}catch(r){if(newError(r))return old.realpathSync(t,e);throw r}}function monkeypatch(){fs.realpath=realpath$1,fs.realpathSync=realpathSync$1}function unmonkeypatch(){fs.realpath=origRealpath,fs.realpathSync=origRealpathSync}var concatMap=function(t,e){for(var r=[],n=0;n=0&&h>0){for(n=[],o=r.length;l>=0&&!a;)l==c?(n.push(l),c=r.indexOf(t,l+1)):1==n.length?a=[n.pop(),h]:((i=n.pop())=0?c:h;n.length&&(a=[o,s])}return a}balanced.range=range;var braceExpansion=expandTop,escSlash="\0SLASH"+Math.random()+"\0",escOpen="\0OPEN"+Math.random()+"\0",escClose="\0CLOSE"+Math.random()+"\0",escComma="\0COMMA"+Math.random()+"\0",escPeriod="\0PERIOD"+Math.random()+"\0";function numeric(t){return parseInt(t,10)==t?parseInt(t,10):t.charCodeAt(0)}function escapeBraces(t){return t.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod)}function unescapeBraces(t){return t.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".")}function parseCommaParts(t){if(!t)return[""];var e=[],r=balancedMatch("{","}",t);if(!r)return t.split(",");var n=r.pre,i=r.body,o=r.post,s=n.split(",");s[s.length-1]+="{"+i+"}";var a=parseCommaParts(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),e.push.apply(e,s),e}function expandTop(t){return t?("{}"===t.substr(0,2)&&(t="\\{\\}"+t.substr(2)),expand(escapeBraces(t),!0).map(unescapeBraces)):[]}function embrace(t){return"{"+t+"}"}function isPadded(t){return/^-?0\d/.test(t)}function lte(t,e){return t<=e}function gte(t,e){return t>=e}function expand(t,e){var r=[],n=balancedMatch("{","}",t);if(!n||/\$$/.test(n.pre))return[t];var i,o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),s=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),a=o||s,c=n.body.indexOf(",")>=0;if(!a&&!c)return n.post.match(/,.*\}/)?expand(t=n.pre+"{"+n.body+escClose+n.post):[t];if(a)i=n.body.split(/\.\./);else if(1===(i=parseCommaParts(n.body)).length&&1===(i=expand(i[0],!1).map(embrace)).length)return(p=n.post.length?expand(n.post,!1):[""]).map(function(t){return n.pre+i[0]+t});var h,l=n.pre,p=n.post.length?expand(n.post,!1):[""];if(a){var u=numeric(i[0]),f=numeric(i[1]),m=Math.max(i[0].length,i[1].length),d=3==i.length?Math.abs(numeric(i[2])):1,g=lte;f0){var E=new Array(w+1).join("0");v=b<0?"-"+E+v.slice(1):E+v}}h.push(v)}}else h=concatMap(i,function(t){return expand(t,!1)});for(var S=0;S65536)throw new TypeError("pattern is too long");var r=this.options;if(!r.noglobstar&&"**"===t)return GLOBSTAR;if(""===t)return"";var n,i="",o=!!r.nocase,s=!1,a=[],c=[],h=!1,l=-1,p=-1,u="."===t.charAt(0)?"":r.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",f=this;function m(){if(n){switch(n){case"*":i+=star,o=!0;break;case"?":i+=qmark,o=!0;break;default:i+="\\"+n}f.debug("clearStateChar %j %j",n,i),n=!1}}for(var d,g=0,y=t.length;g-1;O--){var x=c[O],k=i.slice(0,x.reStart),P=i.slice(x.reStart,x.reEnd-8),A=i.slice(x.reEnd-8,x.reEnd),I=i.slice(x.reEnd);A+=I;var R=k.split("(").length-1,$=I;for(g=0;g=0&&!(n=t[i]);i--);for(i=0;i>> no match, partial?",t,p,e,u),p!==s))}if("string"==typeof h?(c=n.nocase?l.toLowerCase()===h.toLowerCase():l===h,this.debug("string match",h,l,c)):(c=l.match(h),this.debug("pattern match",h,l,c)),!c)return!1}if(i===s&&o===a)return!0;if(i===s)return r;if(o===a)return i===s-1&&""===t[i];throw new Error("wtf?")};var inherits_browser=createCommonjsModule(function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}}),inherits=createCommonjsModule(function(t){try{var e=util;if("function"!=typeof e.inherits)throw"";t.exports=e.inherits}catch(e){t.exports=inherits_browser}});function posix(t){return"/"===t.charAt(0)}function win32(t){var e=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/.exec(t),r=e[1]||"",n=Boolean(r&&":"!==r.charAt(1));return Boolean(e[2]||n)}var pathIsAbsolute="win32"===process.platform?win32:posix,posix_1=posix,win32_1=win32;pathIsAbsolute.posix=posix_1,pathIsAbsolute.win32=win32_1;var alphasort_1=alphasort,alphasorti_1=alphasorti,setopts_1=setopts,ownProp_1=ownProp,makeAbs_1=makeAbs,finish_1=finish,mark_1=mark,isIgnored_1=isIgnored,childrenIgnored_1=childrenIgnored;function ownProp(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var Minimatch$1=minimatch_1.Minimatch;function alphasorti(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}function alphasort(t,e){return t.localeCompare(e)}function setupIgnores(t,e){t.ignore=e.ignore||[],Array.isArray(t.ignore)||(t.ignore=[t.ignore]),t.ignore.length&&(t.ignore=t.ignore.map(ignoreMap))}function ignoreMap(t){var e=null;if("/**"===t.slice(-3)){var r=t.replace(/(\/\*\*)+$/,"");e=new Minimatch$1(r,{dot:!0})}return{matcher:new Minimatch$1(t,{dot:!0}),gmatcher:e}}function setopts(t,e,r){if(r||(r={}),r.matchBase&&-1===e.indexOf("/")){if(r.noglobstar)throw new Error("base matching requires globstar");e="**/"+e}t.silent=!!r.silent,t.pattern=e,t.strict=!1!==r.strict,t.realpath=!!r.realpath,t.realpathCache=r.realpathCache||Object.create(null),t.follow=!!r.follow,t.dot=!!r.dot,t.mark=!!r.mark,t.nodir=!!r.nodir,t.nodir&&(t.mark=!0),t.sync=!!r.sync,t.nounique=!!r.nounique,t.nonull=!!r.nonull,t.nosort=!!r.nosort,t.nocase=!!r.nocase,t.stat=!!r.stat,t.noprocess=!!r.noprocess,t.absolute=!!r.absolute,t.maxLength=r.maxLength||1/0,t.cache=r.cache||Object.create(null),t.statCache=r.statCache||Object.create(null),t.symlinks=r.symlinks||Object.create(null),setupIgnores(t,r),t.changedCwd=!1;var n=process.cwd();ownProp(r,"cwd")?(t.cwd=path.resolve(r.cwd),t.changedCwd=t.cwd!==n):t.cwd=n,t.root=r.root||path.resolve(t.cwd,"/"),t.root=path.resolve(t.root),"win32"===process.platform&&(t.root=t.root.replace(/\\/g,"/")),t.cwdAbs=pathIsAbsolute(t.cwd)?t.cwd:makeAbs(t,t.cwd),"win32"===process.platform&&(t.cwdAbs=t.cwdAbs.replace(/\\/g,"/")),t.nomount=!!r.nomount,r.nonegate=!0,r.nocomment=!0,t.minimatch=new Minimatch$1(e,r),t.options=t.minimatch.options}function finish(t){for(var e=t.nounique,r=e?[]:Object.create(null),n=0,i=t.matches.length;nn?(r.splice(0,n),process.nextTick(function(){e.apply(null,i)})):delete reqs[t]}})}function slice(t){for(var e=t.length,r=[],n=0;n1)return!0;for(var i=0;ithis.maxLength)return e();if(!this.stat&&ownProp$1(this.cache,r)){var i=this.cache[r];if(Array.isArray(i)&&(i="DIR"),!n||"DIR"===i)return e(null,i);if(n&&"FILE"===i)return e()}var o=this.statCache[r];if(void 0!==o){if(!1===o)return e(null,o);var s=o.isDirectory()?"DIR":"FILE";return n&&"FILE"===s?e():e(null,s,o)}var a=this,c=inflight_1("stat\0"+r,function(n,i){if(i&&i.isSymbolicLink())return fs.stat(r,function(n,o){n?a._stat2(t,r,null,i,e):a._stat2(t,r,n,o,e)});a._stat2(t,r,n,i,e)});c&&fs.lstat(r,c)},Glob.prototype._stat2=function(t,e,r,n,i){if(r&&("ENOENT"===r.code||"ENOTDIR"===r.code))return this.statCache[e]=!1,i();var o="/"===t.slice(-1);if(this.statCache[e]=n,"/"===e.slice(-1)&&n&&!n.isDirectory())return i(null,!1,n);var s=!0;return n&&(s=n.isDirectory()?"DIR":"FILE"),this.cache[e]=this.cache[e]||s,o&&"FILE"===s?i():i(null,s,n)};let glob$1=void 0;try{glob$1=glob_1}catch(t){}const defaultGlobOpts={nosort:!0,silent:!0};let timeout=0;const isWindows$1="win32"===process.platform,defaults=t=>{if(["unlink","chmod","stat","lstat","rmdir","readdir"].forEach(e=>{t[e]=t[e]||fs[e],t[e+="Sync"]=t[e]||fs[e]}),t.maxBusyTries=t.maxBusyTries||3,t.emfileWait=t.emfileWait||1e3,!1===t.glob&&(t.disableGlob=!0),!0!==t.disableGlob&&void 0===glob$1)throw Error("glob dependency not found, set `options.disableGlob = true` if intentional");t.disableGlob=t.disableGlob||!1,t.glob=t.glob||defaultGlobOpts},rimraf=(t,e,r)=>{"function"==typeof e&&(r=e,e={}),assert(t,"rimraf: missing path"),assert.equal(typeof t,"string","rimraf: path should be a string"),assert.equal(typeof r,"function","rimraf: callback function required"),assert(e,"rimraf: invalid options argument provided"),assert.equal(typeof e,"object","rimraf: options should be object"),defaults(e);let n=0,i=null,o=0;const s=(t,s)=>t?r(t):0===(o=s.length)?r():void s.forEach(t=>{const s=a=>{if(a){if(("EBUSY"===a.code||"ENOTEMPTY"===a.code||"EPERM"===a.code)&&nrimraf_(t,e,s),100*n);if("EMFILE"===a.code&&timeoutrimraf_(t,e,s),timeout++);"ENOENT"===a.code&&(a=null)}timeout=0,(t=>{i=i||t,0==--o&&r(i)})(a)};rimraf_(t,e,s)});if(e.disableGlob||!glob$1.hasMagic(t))return s(null,[t]);e.lstat(t,(r,n)=>{if(!r)return s(null,[t]);glob$1(t,e.glob,s)})},rimraf_=(t,e,r)=>{assert(t),assert(e),assert("function"==typeof r),e.lstat(t,(n,i)=>n&&"ENOENT"===n.code?r(null):(n&&"EPERM"===n.code&&isWindows$1&&fixWinEPERM(t,e,n,r),i&&i.isDirectory()?rmdir(t,e,n,r):void e.unlink(t,n=>{if(n){if("ENOENT"===n.code)return r(null);if("EPERM"===n.code)return isWindows$1?fixWinEPERM(t,e,n,r):rmdir(t,e,n,r);if("EISDIR"===n.code)return rmdir(t,e,n,r)}return r(n)})))},fixWinEPERM=(t,e,r,n)=>{assert(t),assert(e),assert("function"==typeof n),e.chmod(t,438,i=>{i?n("ENOENT"===i.code?null:r):e.stat(t,(i,o)=>{i?n("ENOENT"===i.code?null:r):o.isDirectory()?rmdir(t,e,r,n):e.unlink(t,n)})})},fixWinEPERMSync=(t,e,r)=>{assert(t),assert(e);try{e.chmodSync(t,438)}catch(t){if("ENOENT"===t.code)return;throw r}let n;try{n=e.statSync(t)}catch(t){if("ENOENT"===t.code)return;throw r}n.isDirectory()?rmdirSync(t,e,r):e.unlinkSync(t)},rmdir=(t,e,r,n)=>{assert(t),assert(e),assert("function"==typeof n),e.rmdir(t,i=>{!i||"ENOTEMPTY"!==i.code&&"EEXIST"!==i.code&&"EPERM"!==i.code?i&&"ENOTDIR"===i.code?n(r):n(i):rmkids(t,e,n)})},rmkids=(t,e,r)=>{assert(t),assert(e),assert("function"==typeof r),e.readdir(t,(n,i)=>{if(n)return r(n);let o,s=i.length;if(0===s)return e.rmdir(t,r);i.forEach(n=>{rimraf(path.join(t,n),e,n=>{if(!o)return n?r(o=n):void(0==--s&&e.rmdir(t,r))})})})},rimrafSync=(t,e)=>{let r;if(defaults(e=e||{}),assert(t,"rimraf: missing path"),assert.equal(typeof t,"string","rimraf: path should be a string"),assert(e,"rimraf: missing options"),assert.equal(typeof e,"object","rimraf: options should be object"),e.disableGlob||!glob$1.hasMagic(t))r=[t];else try{e.lstatSync(t),r=[t]}catch(n){r=glob$1.sync(t,e.glob)}if(r.length)for(let t=0;t{assert(t),assert(e);try{e.rmdirSync(t)}catch(n){if("ENOENT"===n.code)return;if("ENOTDIR"===n.code)throw r;"ENOTEMPTY"!==n.code&&"EEXIST"!==n.code&&"EPERM"!==n.code||rmkidsSync(t,e)}},rmkidsSync=(t,e)=>{assert(t),assert(e),e.readdirSync(t).forEach(r=>rimrafSync(path.join(t,r),e));const r=isWindows$1?100:1;let n=0;for(;;){let i=!0;try{const o=e.rmdirSync(t,e);return i=!1,o}finally{if(++nr("../dialog").save({filters:[{name:PLUGIN$1.ARCHIVES,extensions:["zip"]}]}))}substitutePaths(t){for(let e of t["@graph"])if(e.photo)for(let t of e.photo)t.path=this.destination(t.path,".");return t}async writeJson(){const t=this.substitutePaths(this.data);return fsPromises.writeFile(join(this.dir,PLUGIN$1.ITEMS_FILE),JSON.stringify(t,null,2))}source(t){return t.path}destination(t,e=this.dir){return join(e,PLUGIN$1.IMAGES_DIR,hash$1(t))+extname(t)}*getPhotoPath(t){const e=t.photo||[];for(let t of e){const e=this.source(t);yield{src:e,dst:this.destination(e)}}}*getPhotoPaths(){for(let t of this.data["@graph"])yield*this.getPhotoPath(t)}async export(t){const{logger:e}=this.context,r=this.config.output||await this.dialog();if(r)try{this.data=t,this.dir=await fsPromises.mkdtemp(join(tmpdir(),PLUGIN$1.NAME)),await fsPromises.mkdir(join(this.dir,PLUGIN$1.IMAGES_DIR)),await this.Promise.all([this.Promise.map(this.getPhotoPaths(),({src:t,dst:e})=>fsPromises.copyFile(t,e),{concurrency:this.config.concurrency||PLUGIN$1.COPY_PROCESSES})]),await this.writeJson(),await zip$1(this.dir,r),await fsPromises.rmdir(this.dir,{recursive:!0})}catch(t){e.error(t.message)}}}var plugin=Plugin;module.exports=plugin; diff --git a/package.json b/package.json index 914dc91..cfe9f6a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tropy-archive", - "version": "0.1.1", + "version": "1.0.0", "description": "Export metadata and photos into a zip archive.", "main": "bundle.js", "hooks": { @@ -20,7 +20,8 @@ "field": "output", "label": "Output", "hint": "Location of output archive zip file", - "default": "/path/to/archive.zip" + "default": "/path/to/archive.zip", + "type": "save-file" } ], "dependencies": {