@tachybase/module-backup 0.23.22 → 0.23.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (function(p,l){typeof exports=="object"&&typeof module!="undefined"?l(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("react"),require("@tachybase/components"),require("@ant-design/icons"),require("antd"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","react","@tachybase/components","@ant-design/icons","antd","react-i18next"],l):(p=typeof globalThis!="undefined"?globalThis:p||self,l(p["@tachybase/module-backup"]={},p["@tachybase/client"],p.jsxRuntime,p.react,p["@tachybase/components"],p["@ant-design/icons"],p.antd,p["react-i18next"]))})(this,function(p,l,e,y,L,T,u,P){"use strict";var Z=Object.defineProperty,R=Object.defineProperties;var ee=Object.getOwnPropertyDescriptors;var z=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var W=(p,l,e)=>l in p?Z(p,l,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[l]=e,q=(p,l)=>{for(var e in l||(l={}))te.call(l,e)&&W(p,e,l[e]);if(z)for(var e of z(l))oe.call(l,e)&&W(p,e,l[e]);return p},D=(p,l)=>R(p,ee(l));var B=(p,l,e)=>new Promise((y,L)=>{var T=C=>{try{P(e.next(C))}catch(M){L(M)}},u=C=>{try{P(e.throw(C))}catch(M){L(M)}},P=C=>C.done?y(C.value):Promise.resolve(C.value).then(T,u);P((e=e.apply(p,l)).next())});var C=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},M={exports:{}};(function(a,g){(function(i,r){r()})(C,function(){function i(t,n){return typeof n=="undefined"?n={autoBom:!1}:typeof n!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),n={autoBom:!n}),n.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type)?new Blob(["\uFEFF",t],{type:t.type}):t}function r(t,n,b){var s=new XMLHttpRequest;s.open("GET",t),s.responseType="blob",s.onload=function(){v(s.response,n,b)},s.onerror=function(){console.error("could not download file")},s.send()}function d(t){var n=new XMLHttpRequest;n.open("HEAD",t,!1);try{n.send()}catch(b){}return 200<=n.status&&299>=n.status}function h(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(b){var n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(n)}}var f=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof C=="object"&&C.global===C?C:void 0,w=f.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),v=f.saveAs||(typeof window!="object"||window!==f?function(){}:"download"in HTMLAnchorElement.prototype&&!w?function(t,n,b){var s=f.URL||f.webkitURL,c=document.createElement("a");n=n||t.name||"download",c.download=n,c.rel="noopener",typeof t=="string"?(c.href=t,c.origin===location.origin?h(c):d(c.href)?r(t,n,b):h(c,c.target="_blank")):(c.href=s.createObjectURL(t),setTimeout(function(){s.revokeObjectURL(c.href)},4e4),setTimeout(function(){h(c)},0))}:"msSaveOrOpenBlob"in navigator?function(t,n,b){if(n=n||t.name||"download",typeof t!="string")navigator.msSaveOrOpenBlob(i(t,b),n);else if(d(t))r(t,n,b);else{var s=document.createElement("a");s.href=t,s.target="_blank",setTimeout(function(){h(s)})}}:function(t,n,b,s){if(s=s||open("","_blank"),s&&(s.document.title=s.document.body.innerText="downloading..."),typeof t=="string")return r(t,n,b);var c=t.type==="application/octet-stream",m=/constructor/i.test(f.HTMLElement)||f.safari,o=/CriOS\/[\d]+/.test(navigator.userAgent);if((o||c&&m||w)&&typeof FileReader!="undefined"){var k=new FileReader;k.onloadend=function(){var x=k.result;x=o?x:x.replace(/^data:[^;]*;/,"data:attachment/file;"),s?s.location.href=x:location=x,s=null},k.readAsDataURL(t)}else{var S=f.URL||f.webkitURL,A=S.createObjectURL(t);s?s.location=A:location.href=A,s=null,setTimeout(function(){S.revokeObjectURL(A)},4e4)}});f.saveAs=v.saveAs=v,a.exports=v})})(M);var K=M.exports;const I="backup";function E(){return P.useTranslation(I,{nsMode:"fallback"})}const{Dragger:X}=u.Upload;function J(a){const g=r=>{var d;(d=a.onChange)==null||d.call(a,r)},i=l.useAPIClient();return D(q({},a),{customRequest({action:r,data:d,file:h,filename:f,headers:w,onError:v,onProgress:t,onSuccess:n,withCredentials:b}){const s=new FormData;return d&&Object.keys(d).forEach(c=>{s.append(c,d[c])}),s.append(f,h),i.axios.post(r,s,{withCredentials:b,headers:w,onUploadProgress:({total:c,loaded:m})=>{t({percent:Math.round(m/c*100).toFixed(2)},h)}}).then(({data:c})=>{n(c,h)}).catch(v).finally(()=>{}),{abort(){console.log("upload progress is aborted.")}}},onChange:g})}const U=a=>{const{collectionsData:g}=a,{t:i}=E(),[r,d]=y.useState(!1),[h,f]=y.useState(g);y.useEffect(()=>{f(g)},[g]);const w=l.useAPIClient(),v=l.useCompile(),t=y.useMemo(()=>w.resource("backupFiles"),[w]),n=()=>B(this,null,function*(){if(a.isBackup){const o=yield t.dumpableCollections();f(o==null?void 0:o.data),d(!0)}d(!0)}),b=()=>{d(!1)},s=()=>{d(!1)},c=[{title:i("Collection"),dataIndex:"collection",key:"collection",render:(o,k)=>{const S=v(k.title);return k.name===S?S:e.jsxs("div",{children:[k.name," ",e.jsxs("span",{style:{color:"rgba(0, 0, 0, 0.3)",fontSize:"0.9em"},children:["(",v(k.title),")"]})]})}},{title:i("Origin"),dataIndex:"origin",key:"origin",width:"50%"}],m=Object.keys(h||{}).map(o=>({key:o,label:i(`${o}.title`),children:e.jsxs(e.Fragment,{children:[e.jsx(u.Alert,{style:{marginBottom:16},message:i(`${o}.description`)}),e.jsx(u.Table,{pagination:{pageSize:100},bordered:!0,size:"small",dataSource:h[o],columns:c,scroll:{y:400}})]})}));return e.jsxs(e.Fragment,{children:[e.jsx("a",{onClick:n,children:i("Learn more")}),e.jsx(u.Modal,{title:i("Backup instructions"),width:"80vw",open:r,footer:null,onOk:b,onCancel:s,children:e.jsx(u.Tabs,{defaultActiveKey:"required",items:m})})]})},G=({ButtonComponent:a=u.Button,title:g,upload:i=!1,fileData:r})=>{const{t:d}=E(),[h,f]=y.useState(["required"]),[w,v]=y.useState(!1),[t,n]=y.useState(null),[b,s]=y.useState(!1),c=l.useAPIClient(),m=y.useMemo(()=>c.resource("backupFiles"),[c]),[o,k]=y.useState([]);y.useEffect(()=>{k(Object.keys((t==null?void 0:t.dumpableCollectionsGroupByGroup)||[]).map(O=>({value:O,label:d(`${O}.title`),disabled:["required","skipped"].includes(O)})))},[t]);const S=()=>B(this,null,function*(){var O,H,$;if(v(!0),!i){s(!0);const{data:F}=yield m.get({filterByTk:r.name});k(Object.keys(((H=(O=F==null?void 0:F.data)==null?void 0:O.meta)==null?void 0:H.dumpableCollectionsGroupByGroup)||[]).map(j=>({value:j,label:d(`${j}.title`),disabled:["required","skipped"].includes(j)}))),n(($=F==null?void 0:F.data)==null?void 0:$.meta),s(!1)}}),A=()=>{m.restore({values:{dataTypes:h,filterByTk:r==null?void 0:r.name,key:t==null?void 0:t.key}}),v(!1)},x=()=>{v(!1),n(null),f(["required"])};return e.jsxs(e.Fragment,{children:[e.jsx(a,{onClick:S,children:g}),e.jsx(u.Modal,{title:d("Restore"),width:800,footer:i&&!t?null:void 0,open:w,onOk:A,onCancel:x,children:e.jsxs(u.Spin,{spinning:b,children:[i&&!t&&e.jsx(V,{setRestoreData:n}),(!i||t)&&[e.jsxs("strong",{style:{fontWeight:600,display:"block",margin:"16px 0 8px"},children:[d("Select the data to be restored")," (",e.jsx(U,{collectionsData:t==null?void 0:t.dumpableCollectionsGroupByGroup}),"):"]},"info"),e.jsx("div",{style:{lineHeight:2,marginBottom:8},children:e.jsx(L.FormItem,{children:e.jsx(l.Checkbox.Group,{options:o,style:{flexDirection:"column"},value:h,onChange:O=>f(O)})})},"dataType")]]})})]})},Q=({ButtonComponent:a=u.Button,refresh:g})=>{const{t:i}=E(),[r,d]=y.useState(!1),[h,f]=y.useState(["required"]),w=l.useAPIClient(),{notification:v}=u.App.useApp(),[t,n]=y.useState([]),b=()=>B(this,null,function*(){const{data:m}=yield w.resource("backupFiles").dumpableCollections();n(Object.keys(m||[]).map(o=>({value:o,label:i(`${o}.title`),disabled:["required","skipped"].includes(o)}))),d(!0)}),s=m=>{w.request({url:"backupFiles:create",method:"post",data:{dataTypes:h,method:m}}).finally(()=>{v.destroy("backup")}),v.info({key:"backup",message:e.jsxs("span",{children:[i("Processing..."),"    ",e.jsx(u.Spin,{indicator:e.jsx(T.LoadingOutlined,{style:{fontSize:24},spin:!0})})]}),duration:0}),d(!1),f(["required"]),setTimeout(()=>{g()},500)},c=()=>{d(!1),f(["required"])};return e.jsxs(e.Fragment,{children:[e.jsx(a,{icon:e.jsx(T.PlusOutlined,{}),type:"primary",onClick:b,children:i("New backup")}),e.jsxs(u.Modal,{title:i("New backup"),width:800,open:r,onCancel:c,footer:[e.jsx(u.Button,{onClick:c,children:i("Cancel")},"cancel"),e.jsx(u.Button,{type:"primary",onClick:()=>s("worker"),children:i("Worker backup")},"custom"),e.jsx(u.Button,{onClick:()=>s("main"),children:i("Self backup")},"ok")],children:[e.jsxs("strong",{style:{fontWeight:600,display:"block",margin:"16px 0 8px"},children:[i("Select the data to be backed up")," (",e.jsx(U,{isBackup:!0}),"):"]}),e.jsx("div",{style:{lineHeight:2,marginBottom:8},children:e.jsx(l.Checkbox.Group,{options:t,style:{flexDirection:"column"},onChange:m=>f(m),value:h})})]})]})},V=a=>{const{t:g}=E(),i={multiple:!1,action:"/backupFiles:upload",onChange(r){var h,f,w;r.fileList.length>1&&r.fileList.splice(0,r.fileList.length-1);const{status:d}=r.file;d==="done"?(u.message.success(`${r.file.name} `+g("file uploaded successfully")),a.setRestoreData(D(q({},(f=(h=r.file.response)==null?void 0:h.data)==null?void 0:f.meta),{key:(w=r.file.response)==null?void 0:w.data.key}))):d==="error"&&u.message.error(`${r.file.name} `+g("file upload failed"))},onDrop(r){console.log("Dropped files",r.dataTransfer.files)}};return e.jsxs(X,D(q({},J(i)),{children:[e.jsx("p",{className:"ant-upload-drag-icon",children:e.jsx(T.InboxOutlined,{})}),e.jsxs("p",{className:"ant-upload-text",children:[" ",g("Click or drag file to this area to upload")]})]}))},Y=()=>{const{t:a}=E(),g=l.useAPIClient(),[i,r]=y.useState([]),[d,h]=y.useState(!1),[f,w]=y.useState(!1),{modal:v,notification:t}=u.App.useApp(),n=y.useMemo(()=>g.resource("backupFiles"),[g]),b=y.useCallback(()=>B(this,null,function*(){yield s()}),[]);l.useNoticeSub("backup",o=>{(t[o.level]||t.info)({key:"backup",message:o.msg}),b()}),y.useEffect(()=>{s()},[]);const s=()=>B(this,null,function*(){h(!0);const{data:o}=yield n.list();r(o.data),h(!1)}),c=o=>B(this,null,function*(){w(o.name);const k=yield g.request({url:"backupFiles:download",method:"get",params:{filterByTk:o.name},responseType:"blob"});w(!1);const S=new Blob([k.data]);K.saveAs(S,o.name)}),m=o=>{v.confirm({title:a("Delete record",{ns:"core"}),content:a("Are you sure you want to delete it?",{ns:"core"}),onOk:()=>B(this,null,function*(){yield n.destroy({filterByTk:o.name}),yield s(),u.message.success(a("Deleted successfully"))})})};return e.jsx("div",{children:e.jsxs(u.Card,{bordered:!1,children:[e.jsxs(u.Space,{style:{float:"right",marginBottom:16},children:[e.jsx(u.Button,{onClick:b,icon:e.jsx(T.ReloadOutlined,{}),children:a("Refresh")}),e.jsx(G,{upload:!0,title:e.jsxs(e.Fragment,{children:[e.jsx(T.UploadOutlined,{})," ",a("Restore backup from local")]})}),e.jsx(Q,{refresh:b})]}),e.jsx(u.Table,{dataSource:i,loading:d,columns:[{title:a("Backup file"),dataIndex:"name",width:400,onCell:o=>o.inProgress?{colSpan:4}:{},render:(o,k)=>k.inProgress?e.jsxs("div",{style:{color:"rgba(0, 0, 0, 0.88)"},children:[o,"(",a("Backing up"),"...)"]}):e.jsx("div",{children:o})},{title:a("File size"),dataIndex:"fileSize",onCell:o=>o.inProgress?{colSpan:0}:{}},{title:a("Created at",{ns:"core"}),dataIndex:"createdAt",onCell:o=>o.inProgress?{colSpan:0}:{},render:o=>e.jsx(l.DatePicker.ReadPretty,{value:o,showTime:!0})},{title:a("Actions",{ns:"core"}),dataIndex:"actions",onCell:o=>o.inProgress?{colSpan:0}:{},render:(o,k)=>e.jsxs(u.Space,{split:e.jsx(u.Divider,{type:"vertical"}),children:[e.jsx(G,{ButtonComponent:"a",title:a("Restore"),fileData:k}),e.jsx("a",{type:"link",onClick:()=>c(k),children:a("Download")}),e.jsx("a",{onClick:()=>m(k),children:a("Delete")})]})}]})]})})},_=function(a){return e.jsx(l.SchemaComponentOptions,{children:a.children})};_.displayName="DuplicatorProvider";class N extends l.Plugin{load(){return B(this,null,function*(){this.app.use(_),this.app.systemSettingsManager.add("system-services."+I,{title:this.t("Backup & Restore"),icon:"CloudServerOutlined",Component:Y,aclSnippet:"pm.backup.restore"})})}}p.PluginBackupRestoreClient=N,p.default=N,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(p,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("react"),require("@tachybase/components"),require("@ant-design/icons"),require("antd"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","react","@tachybase/components","@ant-design/icons","antd","react-i18next"],r):(p=typeof globalThis!="undefined"?globalThis:p||self,r(p["@tachybase/module-backup"]={},p["@tachybase/client"],p.jsxRuntime,p.react,p["@tachybase/components"],p["@ant-design/icons"],p.antd,p["react-i18next"]))})(this,function(p,r,e,y,L,M,a,P){"use strict";var Z=Object.defineProperty,R=Object.defineProperties;var ee=Object.getOwnPropertyDescriptors;var z=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var W=(p,r,e)=>r in p?Z(p,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[r]=e,q=(p,r)=>{for(var e in r||(r={}))te.call(r,e)&&W(p,e,r[e]);if(z)for(var e of z(r))oe.call(r,e)&&W(p,e,r[e]);return p},D=(p,r)=>R(p,ee(r));var B=(p,r,e)=>new Promise((y,L)=>{var M=C=>{try{P(e.next(C))}catch(x){L(x)}},a=C=>{try{P(e.throw(C))}catch(x){L(x)}},P=C=>C.done?y(C.value):Promise.resolve(C.value).then(M,a);P((e=e.apply(p,r)).next())});var C=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},x={exports:{}};(function(l,g){(function(c,i){i()})(C,function(){function c(t,s){return typeof s=="undefined"?s={autoBom:!1}:typeof s!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),s={autoBom:!s}),s.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type)?new Blob(["\uFEFF",t],{type:t.type}):t}function i(t,s,b){var n=new XMLHttpRequest;n.open("GET",t),n.responseType="blob",n.onload=function(){v(n.response,s,b)},n.onerror=function(){console.error("could not download file")},n.send()}function u(t){var s=new XMLHttpRequest;s.open("HEAD",t,!1);try{s.send()}catch(b){}return 200<=s.status&&299>=s.status}function h(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(b){var s=document.createEvent("MouseEvents");s.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(s)}}var f=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof C=="object"&&C.global===C?C:void 0,w=f.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),v=f.saveAs||(typeof window!="object"||window!==f?function(){}:"download"in HTMLAnchorElement.prototype&&!w?function(t,s,b){var n=f.URL||f.webkitURL,d=document.createElement("a");s=s||t.name||"download",d.download=s,d.rel="noopener",typeof t=="string"?(d.href=t,d.origin===location.origin?h(d):u(d.href)?i(t,s,b):h(d,d.target="_blank")):(d.href=n.createObjectURL(t),setTimeout(function(){n.revokeObjectURL(d.href)},4e4),setTimeout(function(){h(d)},0))}:"msSaveOrOpenBlob"in navigator?function(t,s,b){if(s=s||t.name||"download",typeof t!="string")navigator.msSaveOrOpenBlob(c(t,b),s);else if(u(t))i(t,s,b);else{var n=document.createElement("a");n.href=t,n.target="_blank",setTimeout(function(){h(n)})}}:function(t,s,b,n){if(n=n||open("","_blank"),n&&(n.document.title=n.document.body.innerText="downloading..."),typeof t=="string")return i(t,s,b);var d=t.type==="application/octet-stream",m=/constructor/i.test(f.HTMLElement)||f.safari,o=/CriOS\/[\d]+/.test(navigator.userAgent);if((o||d&&m||w)&&typeof FileReader!="undefined"){var k=new FileReader;k.onloadend=function(){var T=k.result;T=o?T:T.replace(/^data:[^;]*;/,"data:attachment/file;"),n?n.location.href=T:location=T,n=null},k.readAsDataURL(t)}else{var S=f.URL||f.webkitURL,A=S.createObjectURL(t);n?n.location=A:location.href=A,n=null,setTimeout(function(){S.revokeObjectURL(A)},4e4)}});f.saveAs=v.saveAs=v,l.exports=v})})(x);var K=x.exports;const I="backup";function E(){return P.useTranslation(I,{nsMode:"fallback"})}const{Dragger:X}=a.Upload;function J(l){const g=i=>{var u;(u=l.onChange)==null||u.call(l,i)},c=r.useAPIClient();return D(q({},l),{customRequest({action:i,data:u,file:h,filename:f,headers:w,onError:v,onProgress:t,onSuccess:s,withCredentials:b}){const n=new FormData;return u&&Object.keys(u).forEach(d=>{n.append(d,u[d])}),n.append(f,h),c.axios.post(i,n,{withCredentials:b,headers:w,onUploadProgress:({total:d,loaded:m})=>{t({percent:Math.round(m/d*100).toFixed(2)},h)}}).then(({data:d})=>{s(d,h)}).catch(v).finally(()=>{}),{abort(){console.log("upload progress is aborted.")}}},onChange:g})}const U=l=>{const{collectionsData:g}=l,{t:c}=E(),[i,u]=y.useState(!1),[h,f]=y.useState(g);y.useEffect(()=>{f(g)},[g]);const w=r.useAPIClient(),v=r.useCompile(),t=y.useMemo(()=>w.resource("backupFiles"),[w]),s=()=>B(this,null,function*(){if(l.isBackup){const o=yield t.dumpableCollections();f(o==null?void 0:o.data),u(!0)}u(!0)}),b=()=>{u(!1)},n=()=>{u(!1)},d=[{title:c("Collection"),dataIndex:"collection",key:"collection",render:(o,k)=>{const S=v(k.title);return k.name===S?S:e.jsxs("div",{children:[k.name," ",e.jsxs("span",{style:{color:"rgba(0, 0, 0, 0.3)",fontSize:"0.9em"},children:["(",v(k.title),")"]})]})}},{title:c("Origin"),dataIndex:"origin",key:"origin",width:"50%"}],m=Object.keys(h||{}).map(o=>({key:o,label:c(`${o}.title`),children:e.jsxs(e.Fragment,{children:[e.jsx(a.Alert,{style:{marginBottom:16},message:c(`${o}.description`)}),e.jsx(a.Table,{pagination:{pageSize:100},bordered:!0,size:"small",dataSource:h[o],columns:d,scroll:{y:400}})]})}));return e.jsxs(e.Fragment,{children:[e.jsx("a",{onClick:s,children:c("Learn more")}),e.jsx(a.Modal,{title:c("Backup instructions"),width:"80vw",open:i,footer:null,onOk:b,onCancel:n,children:e.jsx(a.Tabs,{defaultActiveKey:"required",items:m})})]})},G=({ButtonComponent:l=a.Button,title:g,upload:c=!1,fileData:i})=>{const{t:u}=E(),[h,f]=y.useState(["required"]),[w,v]=y.useState(!1),[t,s]=y.useState(null),[b,n]=y.useState(!1),d=r.useAPIClient(),m=y.useMemo(()=>d.resource("backupFiles"),[d]),[o,k]=y.useState([]);y.useEffect(()=>{k(Object.keys((t==null?void 0:t.dumpableCollectionsGroupByGroup)||[]).map(O=>({value:O,label:u(`${O}.title`),disabled:["required","skipped"].includes(O)})))},[t]);const S=()=>B(this,null,function*(){var O,H,$;if(v(!0),!c){n(!0);const{data:F}=yield m.get({filterByTk:i.name});k(Object.keys(((H=(O=F==null?void 0:F.data)==null?void 0:O.meta)==null?void 0:H.dumpableCollectionsGroupByGroup)||[]).map(j=>({value:j,label:u(`${j}.title`),disabled:["required","skipped"].includes(j)}))),s(($=F==null?void 0:F.data)==null?void 0:$.meta),n(!1)}}),A=()=>{m.restore({values:{dataTypes:h,filterByTk:i==null?void 0:i.name,key:t==null?void 0:t.key}}),v(!1)},T=()=>{v(!1),s(null),f(["required"])};return e.jsxs(e.Fragment,{children:[e.jsx(l,{onClick:S,children:g}),e.jsx(a.Modal,{title:u("Restore"),width:800,footer:c&&!t?null:void 0,open:w,onOk:A,onCancel:T,children:e.jsxs(a.Spin,{spinning:b,children:[c&&!t&&e.jsx(V,{setRestoreData:s}),(!c||t)&&[e.jsxs("strong",{style:{fontWeight:600,display:"block",margin:"16px 0 8px"},children:[u("Select the data to be restored")," (",e.jsx(U,{collectionsData:t==null?void 0:t.dumpableCollectionsGroupByGroup}),"):"]},"info"),e.jsx("div",{style:{lineHeight:2,marginBottom:8},children:e.jsx(L.FormItem,{children:e.jsx(r.Checkbox.Group,{options:o,style:{flexDirection:"column"},value:h,onChange:O=>f(O)})})},"dataType")]]})})]})},Q=({ButtonComponent:l=a.Button,refresh:g})=>{const{t:c}=E(),[i,u]=y.useState(!1),[h,f]=y.useState(["required"]),w=r.useAPIClient(),{notification:v}=a.App.useApp(),[t,s]=y.useState([]),b=()=>B(this,null,function*(){const{data:m}=yield w.resource("backupFiles").dumpableCollections();s(Object.keys(m||[]).map(o=>({value:o,label:c(`${o}.title`),disabled:["required","skipped"].includes(o)}))),u(!0)}),n=m=>{w.request({url:"backupFiles:create",method:"post",data:{dataTypes:h,method:m}}).finally(()=>{v.destroy("backup")}),v.info({key:"backup",message:e.jsxs("span",{children:[c("Processing..."),"    ",e.jsx(a.Spin,{indicator:e.jsx(M.LoadingOutlined,{style:{fontSize:24},spin:!0})})]}),duration:0}),u(!1),f(["required"]),setTimeout(()=>{g()},500)},d=()=>{u(!1),f(["required"])};return e.jsxs(e.Fragment,{children:[e.jsx(l,{icon:e.jsx(M.PlusOutlined,{}),type:"primary",onClick:b,children:c("New backup")}),e.jsxs(a.Modal,{title:c("New backup"),width:800,open:i,onCancel:d,footer:[e.jsxs(a.Row,{gutter:16,justify:"end",align:"middle",children:[e.jsx(a.Col,{children:e.jsx(a.Button,{onClick:d,children:c("Cancel")},"cancel")}),e.jsx(a.Col,{children:e.jsx(a.Dropdown.Button,{type:"primary",onClick:()=>n("priority"),overlay:e.jsxs(a.Menu,{children:[e.jsx(a.Menu.Item,{onClick:()=>n("main"),children:c("Self backup")},"main"),e.jsx(a.Menu.Item,{onClick:()=>n("worker"),children:c("Worker backup")},"worker")]}),children:c("Backup")},"submit")})]})],children:[e.jsxs("strong",{style:{fontWeight:600,display:"block",margin:"16px 0 8px"},children:[c("Select the data to be backed up")," (",e.jsx(U,{isBackup:!0}),"):"]}),e.jsx("div",{style:{lineHeight:2,marginBottom:8},children:e.jsx(r.Checkbox.Group,{options:t,style:{flexDirection:"column"},onChange:m=>f(m),value:h})})]})]})},V=l=>{const{t:g}=E(),c={multiple:!1,action:"/backupFiles:upload",onChange(i){var h,f,w;i.fileList.length>1&&i.fileList.splice(0,i.fileList.length-1);const{status:u}=i.file;u==="done"?(a.message.success(`${i.file.name} `+g("file uploaded successfully")),l.setRestoreData(D(q({},(f=(h=i.file.response)==null?void 0:h.data)==null?void 0:f.meta),{key:(w=i.file.response)==null?void 0:w.data.key}))):u==="error"&&a.message.error(`${i.file.name} `+g("file upload failed"))},onDrop(i){console.log("Dropped files",i.dataTransfer.files)}};return e.jsxs(X,D(q({},J(c)),{children:[e.jsx("p",{className:"ant-upload-drag-icon",children:e.jsx(M.InboxOutlined,{})}),e.jsxs("p",{className:"ant-upload-text",children:[" ",g("Click or drag file to this area to upload")]})]}))},Y=()=>{const{t:l}=E(),g=r.useAPIClient(),[c,i]=y.useState([]),[u,h]=y.useState(!1),[f,w]=y.useState(!1),{modal:v,notification:t}=a.App.useApp(),s=y.useMemo(()=>g.resource("backupFiles"),[g]),b=y.useCallback(()=>B(this,null,function*(){yield n()}),[]);r.useNoticeSub("backup",o=>{(t[o.level]||t.info)({key:"backup",message:o.msg}),b()}),y.useEffect(()=>{n()},[]);const n=()=>B(this,null,function*(){h(!0);const{data:o}=yield s.list();i(o.data),h(!1)}),d=o=>B(this,null,function*(){w(o.name);const k=yield g.request({url:"backupFiles:download",method:"get",params:{filterByTk:o.name},responseType:"blob"});w(!1);const S=new Blob([k.data]);K.saveAs(S,o.name)}),m=o=>{v.confirm({title:l("Delete record",{ns:"core"}),content:l("Are you sure you want to delete it?",{ns:"core"}),onOk:()=>B(this,null,function*(){yield s.destroy({filterByTk:o.name}),yield n(),a.message.success(l("Deleted successfully"))})})};return e.jsx("div",{children:e.jsxs(a.Card,{bordered:!1,children:[e.jsxs(a.Space,{style:{float:"right",marginBottom:16},children:[e.jsx(a.Button,{onClick:b,icon:e.jsx(M.ReloadOutlined,{}),children:l("Refresh")}),e.jsx(G,{upload:!0,title:e.jsxs(e.Fragment,{children:[e.jsx(M.UploadOutlined,{})," ",l("Restore backup from local")]})}),e.jsx(Q,{refresh:b})]}),e.jsx(a.Table,{dataSource:c,loading:u,columns:[{title:l("Backup file"),dataIndex:"name",width:400,onCell:o=>o.inProgress?{colSpan:4}:{},render:(o,k)=>k.inProgress?e.jsxs("div",{style:{color:"rgba(0, 0, 0, 0.88)"},children:[o,"(",l("Backing up"),"...)"]}):e.jsx("div",{children:o})},{title:l("File size"),dataIndex:"fileSize",onCell:o=>o.inProgress?{colSpan:0}:{}},{title:l("Created at",{ns:"core"}),dataIndex:"createdAt",onCell:o=>o.inProgress?{colSpan:0}:{},render:o=>e.jsx(r.DatePicker.ReadPretty,{value:o,showTime:!0})},{title:l("Actions",{ns:"core"}),dataIndex:"actions",onCell:o=>o.inProgress?{colSpan:0}:{},render:(o,k)=>e.jsxs(a.Space,{split:e.jsx(a.Divider,{type:"vertical"}),children:[e.jsx(G,{ButtonComponent:"a",title:l("Restore"),fileData:k}),e.jsx("a",{type:"link",onClick:()=>d(k),children:l("Download")}),e.jsx("a",{onClick:()=>m(k),children:l("Delete")})]})}]})]})})},_=function(l){return e.jsx(r.SchemaComponentOptions,{children:l.children})};_.displayName="DuplicatorProvider";class N extends r.Plugin{load(){return B(this,null,function*(){this.app.use(_),this.app.systemSettingsManager.add("system-services."+I,{title:this.t("Backup & Restore"),icon:"CloudServerOutlined",Component:Y,aclSnippet:"pm.backup.restore"})})}}p.PluginBackupRestoreClient=N,p.default=N,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,14 +1,14 @@
1
1
  module.exports = {
2
2
  "react": "18.3.1",
3
- "@tachybase/client": "0.23.22",
4
- "@tachybase/components": "0.23.22",
3
+ "@tachybase/client": "0.23.40",
4
+ "@tachybase/components": "0.23.40",
5
5
  "@ant-design/icons": "5.5.2",
6
6
  "antd": "5.22.5",
7
- "@tachybase/server": "0.23.22",
8
- "@tachybase/utils": "0.23.22",
9
- "@tachybase/database": "0.23.22",
7
+ "@tachybase/server": "0.23.40",
8
+ "@tachybase/utils": "0.23.40",
9
+ "@tachybase/database": "0.23.40",
10
10
  "dayjs": "1.11.13",
11
11
  "lodash": "4.17.21",
12
12
  "react-i18next": "15.2.0",
13
- "@tachybase/actions": "0.23.22"
13
+ "@tachybase/actions": "0.23.40"
14
14
  };
@@ -1 +1 @@
1
- {"name":"@hapi/topo","description":"Topological sorting with grouping support","version":"6.0.2","repository":"git://github.com/hapijs/topo","main":"lib/index.js","types":"lib/index.d.ts","files":["lib"],"keywords":["topological","sort","toposort","topsort"],"eslintConfig":{"extends":["plugin:@hapi/module"]},"dependencies":{"@hapi/hoek":"^11.0.2"},"devDependencies":{"@hapi/code":"^9.0.3","@hapi/eslint-plugin":"*","@hapi/lab":"^25.1.2","@types/node":"^17.0.31","typescript":"~4.6.4"},"scripts":{"test":"lab -a @hapi/code -t 100 -L -Y","test-cov-html":"lab -a @hapi/code -t 100 -L -r html -o coverage.html"},"license":"BSD-3-Clause","_lastModified":"2024-12-30T04:21:49.061Z"}
1
+ {"name":"@hapi/topo","description":"Topological sorting with grouping support","version":"6.0.2","repository":"git://github.com/hapijs/topo","main":"lib/index.js","types":"lib/index.d.ts","files":["lib"],"keywords":["topological","sort","toposort","topsort"],"eslintConfig":{"extends":["plugin:@hapi/module"]},"dependencies":{"@hapi/hoek":"^11.0.2"},"devDependencies":{"@hapi/code":"^9.0.3","@hapi/eslint-plugin":"*","@hapi/lab":"^25.1.2","@types/node":"^17.0.31","typescript":"~4.6.4"},"scripts":{"test":"lab -a @hapi/code -t 100 -L -Y","test-cov-html":"lab -a @hapi/code -t 100 -L -r html -o coverage.html"},"license":"BSD-3-Clause","_lastModified":"2025-01-18T18:48:35.618Z"}
@@ -1 +1 @@
1
- {"name":"archiver","version":"5.3.2","description":"a streaming interface for archive generation","homepage":"https://github.com/archiverjs/node-archiver","author":{"name":"Chris Talkington","url":"http://christalkington.com/"},"repository":{"type":"git","url":"https://github.com/archiverjs/node-archiver.git"},"bugs":{"url":"https://github.com/archiverjs/node-archiver/issues"},"license":"MIT","main":"index.js","files":["index.js","lib"],"engines":{"node":">= 10"},"scripts":{"test":"mocha --reporter dot","bench":"node benchmark/simple/pack-zip.js"},"dependencies":{"archiver-utils":"^2.1.0","async":"^3.2.4","buffer-crc32":"^0.2.1","readable-stream":"^3.6.0","readdir-glob":"^1.1.2","tar-stream":"^2.2.0","zip-stream":"^4.1.0"},"devDependencies":{"archiver-jsdoc-theme":"^1.1.3","chai":"^4.3.7","jsdoc":"^3.6.4","mkdirp":"^2.1.5","mocha":"^9.0.2","rimraf":"^4.3.1","stream-bench":"^0.1.2","tar":"^6.1.13","yauzl":"^2.9.0"},"keywords":["archive","archiver","stream","zip","tar"],"publishConfig":{"registry":"https://registry.npmjs.org/"},"_lastModified":"2024-12-30T04:21:48.776Z"}
1
+ {"name":"archiver","version":"5.3.2","description":"a streaming interface for archive generation","homepage":"https://github.com/archiverjs/node-archiver","author":{"name":"Chris Talkington","url":"http://christalkington.com/"},"repository":{"type":"git","url":"https://github.com/archiverjs/node-archiver.git"},"bugs":{"url":"https://github.com/archiverjs/node-archiver/issues"},"license":"MIT","main":"index.js","files":["index.js","lib"],"engines":{"node":">= 10"},"scripts":{"test":"mocha --reporter dot","bench":"node benchmark/simple/pack-zip.js"},"dependencies":{"archiver-utils":"^2.1.0","async":"^3.2.4","buffer-crc32":"^0.2.1","readable-stream":"^3.6.0","readdir-glob":"^1.1.2","tar-stream":"^2.2.0","zip-stream":"^4.1.0"},"devDependencies":{"archiver-jsdoc-theme":"^1.1.3","chai":"^4.3.7","jsdoc":"^3.6.4","mkdirp":"^2.1.5","mocha":"^9.0.2","rimraf":"^4.3.1","stream-bench":"^0.1.2","tar":"^6.1.13","yauzl":"^2.9.0"},"keywords":["archive","archiver","stream","zip","tar"],"publishConfig":{"registry":"https://registry.npmjs.org/"},"_lastModified":"2025-01-18T18:48:35.433Z"}
@@ -1 +1 @@
1
- {"name":"mkdirp","description":"Recursively mkdir, like `mkdir -p`","version":"1.0.4","main":"index.js","keywords":["mkdir","directory","make dir","make","dir","recursive","native"],"repository":{"type":"git","url":"https://github.com/isaacs/node-mkdirp.git"},"scripts":{"test":"tap","snap":"tap","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --follow-tags"},"tap":{"check-coverage":true,"coverage-map":"map.js"},"devDependencies":{"require-inject":"^1.4.4","tap":"^14.10.7"},"bin":"bin/cmd.js","license":"MIT","engines":{"node":">=10"},"files":["bin","lib","index.js"],"_lastModified":"2024-12-30T04:21:48.869Z"}
1
+ {"name":"mkdirp","description":"Recursively mkdir, like `mkdir -p`","version":"1.0.4","main":"index.js","keywords":["mkdir","directory","make dir","make","dir","recursive","native"],"repository":{"type":"git","url":"https://github.com/isaacs/node-mkdirp.git"},"scripts":{"test":"tap","snap":"tap","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --follow-tags"},"tap":{"check-coverage":true,"coverage-map":"map.js"},"devDependencies":{"require-inject":"^1.4.4","tap":"^14.10.7"},"bin":"bin/cmd.js","license":"MIT","engines":{"node":">=10"},"files":["bin","lib","index.js"],"_lastModified":"2025-01-18T18:48:35.521Z"}
@@ -1 +1 @@
1
- {"name":"semver","version":"7.6.3","description":"The semantic version parser used by npm.","main":"index.js","scripts":{"test":"tap","snap":"tap","lint":"eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"","postlint":"template-oss-check","lintfix":"npm run lint -- --fix","posttest":"npm run lint","template-oss-apply":"template-oss-apply --force"},"devDependencies":{"@npmcli/eslint-config":"^4.0.0","@npmcli/template-oss":"4.22.0","benchmark":"^2.1.4","tap":"^16.0.0"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/npm/node-semver.git"},"bin":{"semver":"bin/semver.js"},"files":["bin/","lib/","classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"tap":{"timeout":30,"coverage-map":"map.js","nyc-arg":["--exclude","tap-snapshots/**"]},"engines":{"node":">=10"},"author":"GitHub Inc.","templateOSS":{"//@npmcli/template-oss":"This file is partially managed by @npmcli/template-oss. Edits may be overwritten.","version":"4.22.0","engines":">=10","distPaths":["classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"allowPaths":["/classes/","/functions/","/internal/","/ranges/","/index.js","/preload.js","/range.bnf","/benchmarks"],"publish":"true"},"_lastModified":"2024-12-30T04:21:50.247Z"}
1
+ {"name":"semver","version":"7.6.3","description":"The semantic version parser used by npm.","main":"index.js","scripts":{"test":"tap","snap":"tap","lint":"eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"","postlint":"template-oss-check","lintfix":"npm run lint -- --fix","posttest":"npm run lint","template-oss-apply":"template-oss-apply --force"},"devDependencies":{"@npmcli/eslint-config":"^4.0.0","@npmcli/template-oss":"4.22.0","benchmark":"^2.1.4","tap":"^16.0.0"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/npm/node-semver.git"},"bin":{"semver":"bin/semver.js"},"files":["bin/","lib/","classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"tap":{"timeout":30,"coverage-map":"map.js","nyc-arg":["--exclude","tap-snapshots/**"]},"engines":{"node":">=10"},"author":"GitHub Inc.","templateOSS":{"//@npmcli/template-oss":"This file is partially managed by @npmcli/template-oss. Edits may be overwritten.","version":"4.22.0","engines":">=10","distPaths":["classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"allowPaths":["/classes/","/functions/","/internal/","/ranges/","/index.js","/preload.js","/range.bnf","/benchmarks"],"publish":"true"},"_lastModified":"2025-01-18T18:48:35.854Z"}
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Josh Wolfe
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.
@@ -0,0 +1,314 @@
1
+ // This was adapted from https://github.com/andrewrk/node-fd-slicer by Andrew Kelley under the MIT License.
2
+ var fs = require('fs');
3
+ var util = require('util');
4
+ var stream = require('stream');
5
+ var Readable = stream.Readable;
6
+ var Writable = stream.Writable;
7
+ var PassThrough = stream.PassThrough;
8
+ var Pend = require('pend');
9
+ var EventEmitter = require('events').EventEmitter;
10
+
11
+ exports.createFromBuffer = createFromBuffer;
12
+ exports.createFromFd = createFromFd;
13
+ exports.BufferSlicer = BufferSlicer;
14
+ exports.FdSlicer = FdSlicer;
15
+
16
+ util.inherits(FdSlicer, EventEmitter);
17
+ function FdSlicer(fd, options) {
18
+ options = options || {};
19
+ EventEmitter.call(this);
20
+
21
+ this.fd = fd;
22
+ this.pend = new Pend();
23
+ this.pend.max = 1;
24
+ this.refCount = 0;
25
+ this.autoClose = !!options.autoClose;
26
+ }
27
+
28
+ FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
29
+ var self = this;
30
+ self.pend.go(function(cb) {
31
+ fs.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer) {
32
+ cb();
33
+ callback(err, bytesRead, buffer);
34
+ });
35
+ });
36
+ };
37
+
38
+ FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
39
+ var self = this;
40
+ self.pend.go(function(cb) {
41
+ fs.write(self.fd, buffer, offset, length, position, function(err, written, buffer) {
42
+ cb();
43
+ callback(err, written, buffer);
44
+ });
45
+ });
46
+ };
47
+
48
+ FdSlicer.prototype.createReadStream = function(options) {
49
+ return new ReadStream(this, options);
50
+ };
51
+
52
+ FdSlicer.prototype.createWriteStream = function(options) {
53
+ return new WriteStream(this, options);
54
+ };
55
+
56
+ FdSlicer.prototype.ref = function() {
57
+ this.refCount += 1;
58
+ };
59
+
60
+ FdSlicer.prototype.unref = function() {
61
+ var self = this;
62
+ self.refCount -= 1;
63
+
64
+ if (self.refCount > 0) return;
65
+ if (self.refCount < 0) throw new Error("invalid unref");
66
+
67
+ if (self.autoClose) {
68
+ fs.close(self.fd, onCloseDone);
69
+ }
70
+
71
+ function onCloseDone(err) {
72
+ if (err) {
73
+ self.emit('error', err);
74
+ } else {
75
+ self.emit('close');
76
+ }
77
+ }
78
+ };
79
+
80
+ util.inherits(ReadStream, Readable);
81
+ function ReadStream(context, options) {
82
+ options = options || {};
83
+ Readable.call(this, options);
84
+
85
+ this.context = context;
86
+ this.context.ref();
87
+
88
+ this.start = options.start || 0;
89
+ this.endOffset = options.end;
90
+ this.pos = this.start;
91
+ this.destroyed = false;
92
+ }
93
+
94
+ ReadStream.prototype._read = function(n) {
95
+ var self = this;
96
+ if (self.destroyed) return;
97
+
98
+ var toRead = Math.min(self._readableState.highWaterMark, n);
99
+ if (self.endOffset != null) {
100
+ toRead = Math.min(toRead, self.endOffset - self.pos);
101
+ }
102
+ if (toRead <= 0) {
103
+ self.destroyed = true;
104
+ self.push(null);
105
+ self.context.unref();
106
+ return;
107
+ }
108
+ self.context.pend.go(function(cb) {
109
+ if (self.destroyed) return cb();
110
+ var buffer = Buffer.allocUnsafe(toRead);
111
+ fs.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
112
+ if (err) {
113
+ self.destroy(err);
114
+ } else if (bytesRead === 0) {
115
+ self.destroyed = true;
116
+ self.push(null);
117
+ self.context.unref();
118
+ } else {
119
+ self.pos += bytesRead;
120
+ self.push(buffer.slice(0, bytesRead));
121
+ }
122
+ cb();
123
+ });
124
+ });
125
+ };
126
+
127
+ ReadStream.prototype.destroy = function(err) {
128
+ if (this.destroyed) return;
129
+ err = err || new Error("stream destroyed");
130
+ this.destroyed = true;
131
+ this.emit('error', err);
132
+ this.context.unref();
133
+ };
134
+
135
+ util.inherits(WriteStream, Writable);
136
+ function WriteStream(context, options) {
137
+ options = options || {};
138
+ Writable.call(this, options);
139
+
140
+ this.context = context;
141
+ this.context.ref();
142
+
143
+ this.start = options.start || 0;
144
+ this.endOffset = (options.end == null) ? Infinity : +options.end;
145
+ this.bytesWritten = 0;
146
+ this.pos = this.start;
147
+ this.destroyed = false;
148
+
149
+ this.on('finish', this.destroy.bind(this));
150
+ }
151
+
152
+ WriteStream.prototype._write = function(buffer, encoding, callback) {
153
+ var self = this;
154
+ if (self.destroyed) return;
155
+
156
+ if (self.pos + buffer.length > self.endOffset) {
157
+ var err = new Error("maximum file length exceeded");
158
+ err.code = 'ETOOBIG';
159
+ self.destroy();
160
+ callback(err);
161
+ return;
162
+ }
163
+ self.context.pend.go(function(cb) {
164
+ if (self.destroyed) return cb();
165
+ fs.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err, bytes) {
166
+ if (err) {
167
+ self.destroy();
168
+ cb();
169
+ callback(err);
170
+ } else {
171
+ self.bytesWritten += bytes;
172
+ self.pos += bytes;
173
+ self.emit('progress');
174
+ cb();
175
+ callback();
176
+ }
177
+ });
178
+ });
179
+ };
180
+
181
+ WriteStream.prototype.destroy = function() {
182
+ if (this.destroyed) return;
183
+ this.destroyed = true;
184
+ this.context.unref();
185
+ };
186
+
187
+ util.inherits(BufferSlicer, EventEmitter);
188
+ function BufferSlicer(buffer, options) {
189
+ EventEmitter.call(this);
190
+
191
+ options = options || {};
192
+ this.refCount = 0;
193
+ this.buffer = buffer;
194
+ this.maxChunkSize = options.maxChunkSize || Number.MAX_SAFE_INTEGER;
195
+ }
196
+
197
+ BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
198
+ if (!(0 <= offset && offset <= buffer.length)) throw new RangeError("offset outside buffer: 0 <= " + offset + " <= " + buffer.length);
199
+ if (position < 0) throw new RangeError("position is negative: " + position);
200
+ if (offset + length > buffer.length) {
201
+ // The caller's buffer can't hold all the bytes they're trying to read.
202
+ // Clamp the length instead of giving an error.
203
+ // The callback will be informed of fewer than expected bytes written.
204
+ length = buffer.length - offset;
205
+ }
206
+ if (position + length > this.buffer.length) {
207
+ // Clamp any attempt to read past the end of the source buffer.
208
+ length = this.buffer.length - position;
209
+ }
210
+ if (length <= 0) {
211
+ // After any clamping, we're fully out of bounds or otherwise have nothing to do.
212
+ // This isn't an error; it's just zero bytes written.
213
+ setImmediate(function() {
214
+ callback(null, 0);
215
+ });
216
+ return;
217
+ }
218
+ this.buffer.copy(buffer, offset, position, position + length);
219
+ setImmediate(function() {
220
+ callback(null, length);
221
+ });
222
+ };
223
+
224
+ BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
225
+ buffer.copy(this.buffer, position, offset, offset + length);
226
+ setImmediate(function() {
227
+ callback(null, length, buffer);
228
+ });
229
+ };
230
+
231
+ BufferSlicer.prototype.createReadStream = function(options) {
232
+ options = options || {};
233
+ var readStream = new PassThrough(options);
234
+ readStream.destroyed = false;
235
+ readStream.start = options.start || 0;
236
+ readStream.endOffset = options.end;
237
+ // by the time this function returns, we'll be done.
238
+ readStream.pos = readStream.endOffset || this.buffer.length;
239
+
240
+ // respect the maxChunkSize option to slice up the chunk into smaller pieces.
241
+ var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
242
+ var offset = 0;
243
+ while (true) {
244
+ var nextOffset = offset + this.maxChunkSize;
245
+ if (nextOffset >= entireSlice.length) {
246
+ // last chunk
247
+ if (offset < entireSlice.length) {
248
+ readStream.write(entireSlice.slice(offset, entireSlice.length));
249
+ }
250
+ break;
251
+ }
252
+ readStream.write(entireSlice.slice(offset, nextOffset));
253
+ offset = nextOffset;
254
+ }
255
+
256
+ readStream.end();
257
+ readStream.destroy = function() {
258
+ readStream.destroyed = true;
259
+ };
260
+ return readStream;
261
+ };
262
+
263
+ BufferSlicer.prototype.createWriteStream = function(options) {
264
+ var bufferSlicer = this;
265
+ options = options || {};
266
+ var writeStream = new Writable(options);
267
+ writeStream.start = options.start || 0;
268
+ writeStream.endOffset = (options.end == null) ? this.buffer.length : +options.end;
269
+ writeStream.bytesWritten = 0;
270
+ writeStream.pos = writeStream.start;
271
+ writeStream.destroyed = false;
272
+ writeStream._write = function(buffer, encoding, callback) {
273
+ if (writeStream.destroyed) return;
274
+
275
+ var end = writeStream.pos + buffer.length;
276
+ if (end > writeStream.endOffset) {
277
+ var err = new Error("maximum file length exceeded");
278
+ err.code = 'ETOOBIG';
279
+ writeStream.destroyed = true;
280
+ callback(err);
281
+ return;
282
+ }
283
+ buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
284
+
285
+ writeStream.bytesWritten += buffer.length;
286
+ writeStream.pos = end;
287
+ writeStream.emit('progress');
288
+ callback();
289
+ };
290
+ writeStream.destroy = function() {
291
+ writeStream.destroyed = true;
292
+ };
293
+ return writeStream;
294
+ };
295
+
296
+ BufferSlicer.prototype.ref = function() {
297
+ this.refCount += 1;
298
+ };
299
+
300
+ BufferSlicer.prototype.unref = function() {
301
+ this.refCount -= 1;
302
+
303
+ if (this.refCount < 0) {
304
+ throw new Error("invalid unref");
305
+ }
306
+ };
307
+
308
+ function createFromBuffer(buffer, options) {
309
+ return new BufferSlicer(buffer, options);
310
+ }
311
+
312
+ function createFromFd(fd, options) {
313
+ return new FdSlicer(fd, options);
314
+ }
@@ -0,0 +1 @@
1
+ (function(){var e={64:function(e,r,t){var n=t(181).Buffer;var i=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];if(typeof Int32Array!=="undefined"){i=new Int32Array(i)}function ensureBuffer(e){if(n.isBuffer(e)){return e}var r=typeof n.alloc==="function"&&typeof n.from==="function";if(typeof e==="number"){return r?n.alloc(e):new n(e)}else if(typeof e==="string"){return r?n.from(e):new n(e)}else{throw new Error("input must be buffer, number, or string, received "+typeof e)}}function bufferizeInt(e){var r=ensureBuffer(4);r.writeInt32BE(e,0);return r}function _crc32(e,r){e=ensureBuffer(e);if(n.isBuffer(r)){r=r.readUInt32BE(0)}var t=~~r^-1;for(var o=0;o<e.length;o++){t=i[(t^e[o])&255]^t>>>8}return t^-1}function crc32(){return bufferizeInt(_crc32.apply(null,arguments))}crc32.signed=function(){return _crc32.apply(null,arguments)};crc32.unsigned=function(){return _crc32.apply(null,arguments)>>>0};e.exports=crc32},295:function(e){e.exports=Pend;function Pend(){this.pending=0;this.max=Infinity;this.listeners=[];this.waiting=[];this.error=null}Pend.prototype.go=function(e){if(this.pending<this.max){pendGo(this,e)}else{this.waiting.push(e)}};Pend.prototype.wait=function(e){if(this.pending===0){e(this.error)}else{this.listeners.push(e)}};Pend.prototype.hold=function(){return pendHold(this)};function pendHold(e){e.pending+=1;var r=false;return onCb;function onCb(t){if(r)throw new Error("callback called twice");r=true;e.error=e.error||t;e.pending-=1;if(e.waiting.length>0&&e.pending<e.max){pendGo(e,e.waiting.shift())}else if(e.pending===0){var n=e.listeners;e.listeners=[];n.forEach(cbListener)}}function cbListener(r){r(e.error)}}function pendGo(e,r){r(pendHold(e))}},116:function(e,r,t){var n=t(896);var i=t(23);var o=t(203);var a=o.Readable;var s=o.Writable;var f=o.PassThrough;var l=t(295);var u=t(434).EventEmitter;r.createFromBuffer=createFromBuffer;r.createFromFd=createFromFd;r.BufferSlicer=BufferSlicer;r.FdSlicer=FdSlicer;i.inherits(FdSlicer,u);function FdSlicer(e,r){r=r||{};u.call(this);this.fd=e;this.pend=new l;this.pend.max=1;this.refCount=0;this.autoClose=!!r.autoClose}FdSlicer.prototype.read=function(e,r,t,i,o){var a=this;a.pend.go((function(s){n.read(a.fd,e,r,t,i,(function(e,r,t){s();o(e,r,t)}))}))};FdSlicer.prototype.write=function(e,r,t,i,o){var a=this;a.pend.go((function(s){n.write(a.fd,e,r,t,i,(function(e,r,t){s();o(e,r,t)}))}))};FdSlicer.prototype.createReadStream=function(e){return new ReadStream(this,e)};FdSlicer.prototype.createWriteStream=function(e){return new WriteStream(this,e)};FdSlicer.prototype.ref=function(){this.refCount+=1};FdSlicer.prototype.unref=function(){var e=this;e.refCount-=1;if(e.refCount>0)return;if(e.refCount<0)throw new Error("invalid unref");if(e.autoClose){n.close(e.fd,onCloseDone)}function onCloseDone(r){if(r){e.emit("error",r)}else{e.emit("close")}}};i.inherits(ReadStream,a);function ReadStream(e,r){r=r||{};a.call(this,r);this.context=e;this.context.ref();this.start=r.start||0;this.endOffset=r.end;this.pos=this.start;this.destroyed=false}ReadStream.prototype._read=function(e){var r=this;if(r.destroyed)return;var t=Math.min(r._readableState.highWaterMark,e);if(r.endOffset!=null){t=Math.min(t,r.endOffset-r.pos)}if(t<=0){r.destroyed=true;r.push(null);r.context.unref();return}r.context.pend.go((function(e){if(r.destroyed)return e();var i=Buffer.allocUnsafe(t);n.read(r.context.fd,i,0,t,r.pos,(function(t,n){if(t){r.destroy(t)}else if(n===0){r.destroyed=true;r.push(null);r.context.unref()}else{r.pos+=n;r.push(i.slice(0,n))}e()}))}))};ReadStream.prototype.destroy=function(e){if(this.destroyed)return;e=e||new Error("stream destroyed");this.destroyed=true;this.emit("error",e);this.context.unref()};i.inherits(WriteStream,s);function WriteStream(e,r){r=r||{};s.call(this,r);this.context=e;this.context.ref();this.start=r.start||0;this.endOffset=r.end==null?Infinity:+r.end;this.bytesWritten=0;this.pos=this.start;this.destroyed=false;this.on("finish",this.destroy.bind(this))}WriteStream.prototype._write=function(e,r,t){var i=this;if(i.destroyed)return;if(i.pos+e.length>i.endOffset){var o=new Error("maximum file length exceeded");o.code="ETOOBIG";i.destroy();t(o);return}i.context.pend.go((function(r){if(i.destroyed)return r();n.write(i.context.fd,e,0,e.length,i.pos,(function(e,n){if(e){i.destroy();r();t(e)}else{i.bytesWritten+=n;i.pos+=n;i.emit("progress");r();t()}}))}))};WriteStream.prototype.destroy=function(){if(this.destroyed)return;this.destroyed=true;this.context.unref()};i.inherits(BufferSlicer,u);function BufferSlicer(e,r){u.call(this);r=r||{};this.refCount=0;this.buffer=e;this.maxChunkSize=r.maxChunkSize||Number.MAX_SAFE_INTEGER}BufferSlicer.prototype.read=function(e,r,t,n,i){if(!(0<=r&&r<=e.length))throw new RangeError("offset outside buffer: 0 <= "+r+" <= "+e.length);if(n<0)throw new RangeError("position is negative: "+n);if(r+t>e.length){t=e.length-r}if(n+t>this.buffer.length){t=this.buffer.length-n}if(t<=0){setImmediate((function(){i(null,0)}));return}this.buffer.copy(e,r,n,n+t);setImmediate((function(){i(null,t)}))};BufferSlicer.prototype.write=function(e,r,t,n,i){e.copy(this.buffer,n,r,r+t);setImmediate((function(){i(null,t,e)}))};BufferSlicer.prototype.createReadStream=function(e){e=e||{};var r=new f(e);r.destroyed=false;r.start=e.start||0;r.endOffset=e.end;r.pos=r.endOffset||this.buffer.length;var t=this.buffer.slice(r.start,r.pos);var n=0;while(true){var i=n+this.maxChunkSize;if(i>=t.length){if(n<t.length){r.write(t.slice(n,t.length))}break}r.write(t.slice(n,i));n=i}r.end();r.destroy=function(){r.destroyed=true};return r};BufferSlicer.prototype.createWriteStream=function(e){var r=this;e=e||{};var t=new s(e);t.start=e.start||0;t.endOffset=e.end==null?this.buffer.length:+e.end;t.bytesWritten=0;t.pos=t.start;t.destroyed=false;t._write=function(e,n,i){if(t.destroyed)return;var o=t.pos+e.length;if(o>t.endOffset){var a=new Error("maximum file length exceeded");a.code="ETOOBIG";t.destroyed=true;i(a);return}e.copy(r.buffer,t.pos,0,e.length);t.bytesWritten+=e.length;t.pos=o;t.emit("progress");i()};t.destroy=function(){t.destroyed=true};return t};BufferSlicer.prototype.ref=function(){this.refCount+=1};BufferSlicer.prototype.unref=function(){this.refCount-=1;if(this.refCount<0){throw new Error("invalid unref")}};function createFromBuffer(e,r){return new BufferSlicer(e,r)}function createFromFd(e,r){return new FdSlicer(e,r)}},181:function(e){"use strict";e.exports=require("buffer")},434:function(e){"use strict";e.exports=require("events")},896:function(e){"use strict";e.exports=require("fs")},203:function(e){"use strict";e.exports=require("stream")},23:function(e){"use strict";e.exports=require("util")},106:function(e){"use strict";e.exports=require("zlib")}};var r={};function __nccwpck_require__(t){var n=r[t];if(n!==undefined){return n.exports}var i=r[t]={exports:{}};var o=true;try{e[t](i,i.exports,__nccwpck_require__);o=false}finally{if(o)delete r[t]}return i.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t={};!function(){var e=t;var r=__nccwpck_require__(896);var n=__nccwpck_require__(106);var i=__nccwpck_require__(116);var o=__nccwpck_require__(64);var a=__nccwpck_require__(23);var s=__nccwpck_require__(434).EventEmitter;var f=__nccwpck_require__(203).Transform;var l=__nccwpck_require__(203).PassThrough;var u=__nccwpck_require__(203).Writable;e.open=open;e.fromFd=fromFd;e.fromBuffer=fromBuffer;e.fromRandomAccessReader=fromRandomAccessReader;e.dosDateTimeToDate=dosDateTimeToDate;e.getFileNameLowLevel=getFileNameLowLevel;e.validateFileName=validateFileName;e.parseExtraFields=parseExtraFields;e.ZipFile=ZipFile;e.Entry=Entry;e.LocalFileHeader=LocalFileHeader;e.RandomAccessReader=RandomAccessReader;function open(e,t,n){if(typeof t==="function"){n=t;t=null}if(t==null)t={};if(t.autoClose==null)t.autoClose=true;if(t.lazyEntries==null)t.lazyEntries=false;if(t.decodeStrings==null)t.decodeStrings=true;if(t.validateEntrySizes==null)t.validateEntrySizes=true;if(t.strictFileNames==null)t.strictFileNames=false;if(n==null)n=defaultCallback;r.open(e,"r",(function(e,i){if(e)return n(e);fromFd(i,t,(function(e,t){if(e)r.close(i,defaultCallback);n(e,t)}))}))}function fromFd(e,t,n){if(typeof t==="function"){n=t;t=null}if(t==null)t={};if(t.autoClose==null)t.autoClose=false;if(t.lazyEntries==null)t.lazyEntries=false;if(t.decodeStrings==null)t.decodeStrings=true;if(t.validateEntrySizes==null)t.validateEntrySizes=true;if(t.strictFileNames==null)t.strictFileNames=false;if(n==null)n=defaultCallback;r.fstat(e,(function(r,o){if(r)return n(r);var a=i.createFromFd(e,{autoClose:true});fromRandomAccessReader(a,o.size,t,n)}))}function fromBuffer(e,r,t){if(typeof r==="function"){t=r;r=null}if(r==null)r={};r.autoClose=false;if(r.lazyEntries==null)r.lazyEntries=false;if(r.decodeStrings==null)r.decodeStrings=true;if(r.validateEntrySizes==null)r.validateEntrySizes=true;if(r.strictFileNames==null)r.strictFileNames=false;var n=i.createFromBuffer(e,{maxChunkSize:65536});fromRandomAccessReader(n,e.length,r,t)}function fromRandomAccessReader(e,r,t,n){if(typeof t==="function"){n=t;t=null}if(t==null)t={};if(t.autoClose==null)t.autoClose=true;if(t.lazyEntries==null)t.lazyEntries=false;if(t.decodeStrings==null)t.decodeStrings=true;var i=!!t.decodeStrings;if(t.validateEntrySizes==null)t.validateEntrySizes=true;if(t.strictFileNames==null)t.strictFileNames=false;if(n==null)n=defaultCallback;if(typeof r!=="number")throw new Error("expected totalSize parameter to be a number");if(r>Number.MAX_SAFE_INTEGER){throw new Error("zip file too large. only file sizes up to 2^52 are supported due to JavaScript's Number type being an IEEE 754 double.")}e.ref();var o=22;var a=20;var s=65535;var f=Math.min(a+o+s,r);var l=c(f);var u=r-l.length;readAndAssertNoEof(e,l,0,f,u,(function(s){if(s)return n(s);for(var u=f-o;u>=0;u-=1){if(l.readUInt32LE(u)!==101010256)continue;var d=l.subarray(u);var p=d.readUInt16LE(4);var m=d.readUInt16LE(10);var h=d.readUInt32LE(16);var y=d.readUInt16LE(20);var E=d.length-o;if(y!==E){return n(new Error("Invalid comment length. Expected: "+E+". Found: "+y+". Are there extra bytes at the end of the file? Or is the end of central dir signature `PK☺☻` in the comment?"))}var v=i?decodeBuffer(d.subarray(22),false):d.subarray(22);if(u-a>=0&&l.readUInt32LE(u-a)===117853008){var w=l.subarray(u-a,u-a+a);var g=readUInt64LE(w,8);var S=c(56);return readAndAssertNoEof(e,S,0,S.length,g,(function(o){if(o)return n(o);if(S.readUInt32LE(0)!==101075792){return n(new Error("invalid zip64 end of central directory record signature"))}p=S.readUInt32LE(16);if(p!==0){return n(new Error("multi-disk zip files are not supported: found disk number: "+p))}m=readUInt64LE(S,32);h=readUInt64LE(S,48);return n(null,new ZipFile(e,h,r,m,v,t.autoClose,t.lazyEntries,i,t.validateEntrySizes,t.strictFileNames))}))}if(p!==0){return n(new Error("multi-disk zip files are not supported: found disk number: "+p))}return n(null,new ZipFile(e,h,r,m,v,t.autoClose,t.lazyEntries,i,t.validateEntrySizes,t.strictFileNames))}n(new Error("End of central directory record signature not found. Either not a zip file, or file is truncated."))}))}a.inherits(ZipFile,s);function ZipFile(e,r,t,n,i,o,a,f,l,u){var d=this;s.call(d);d.reader=e;d.reader.on("error",(function(e){emitError(d,e)}));d.reader.once("close",(function(){d.emit("close")}));d.readEntryCursor=r;d.fileSize=t;d.entryCount=n;d.comment=i;d.entriesRead=0;d.autoClose=!!o;d.lazyEntries=!!a;d.decodeStrings=!!f;d.validateEntrySizes=!!l;d.strictFileNames=!!u;d.isOpen=true;d.emittedError=false;if(!d.lazyEntries)d._readEntry()}ZipFile.prototype.close=function(){if(!this.isOpen)return;this.isOpen=false;this.reader.unref()};function emitErrorAndAutoClose(e,r){if(e.autoClose)e.close();emitError(e,r)}function emitError(e,r){if(e.emittedError)return;e.emittedError=true;e.emit("error",r)}ZipFile.prototype.readEntry=function(){if(!this.lazyEntries)throw new Error("readEntry() called without lazyEntries:true");this._readEntry()};ZipFile.prototype._readEntry=function(){var e=this;if(e.entryCount===e.entriesRead){setImmediate((function(){if(e.autoClose)e.close();if(e.emittedError)return;e.emit("end")}));return}if(e.emittedError)return;var r=c(46);readAndAssertNoEof(e.reader,r,0,r.length,e.readEntryCursor,(function(t){if(t)return emitErrorAndAutoClose(e,t);if(e.emittedError)return;var n=new Entry;var i=r.readUInt32LE(0);if(i!==33639248)return emitErrorAndAutoClose(e,new Error("invalid central directory file header signature: 0x"+i.toString(16)));n.versionMadeBy=r.readUInt16LE(4);n.versionNeededToExtract=r.readUInt16LE(6);n.generalPurposeBitFlag=r.readUInt16LE(8);n.compressionMethod=r.readUInt16LE(10);n.lastModFileTime=r.readUInt16LE(12);n.lastModFileDate=r.readUInt16LE(14);n.crc32=r.readUInt32LE(16);n.compressedSize=r.readUInt32LE(20);n.uncompressedSize=r.readUInt32LE(24);n.fileNameLength=r.readUInt16LE(28);n.extraFieldLength=r.readUInt16LE(30);n.fileCommentLength=r.readUInt16LE(32);n.internalFileAttributes=r.readUInt16LE(36);n.externalFileAttributes=r.readUInt32LE(38);n.relativeOffsetOfLocalHeader=r.readUInt32LE(42);if(n.generalPurposeBitFlag&64)return emitErrorAndAutoClose(e,new Error("strong encryption is not supported"));e.readEntryCursor+=46;r=c(n.fileNameLength+n.extraFieldLength+n.fileCommentLength);readAndAssertNoEof(e.reader,r,0,r.length,e.readEntryCursor,(function(t){if(t)return emitErrorAndAutoClose(e,t);if(e.emittedError)return;n.fileNameRaw=r.subarray(0,n.fileNameLength);var i=n.fileNameLength+n.extraFieldLength;n.extraFieldRaw=r.subarray(n.fileNameLength,i);n.fileCommentRaw=r.subarray(i,i+n.fileCommentLength);try{n.extraFields=parseExtraFields(n.extraFieldRaw)}catch(t){return emitErrorAndAutoClose(e,t)}if(e.decodeStrings){var o=(n.generalPurposeBitFlag&2048)!==0;n.fileComment=decodeBuffer(n.fileCommentRaw,o);n.fileName=getFileNameLowLevel(n.generalPurposeBitFlag,n.fileNameRaw,n.extraFields,e.strictFileNames);var a=validateFileName(n.fileName);if(a!=null)return emitErrorAndAutoClose(e,new Error(a))}else{n.fileComment=n.fileCommentRaw;n.fileName=n.fileNameRaw}n.comment=n.fileComment;e.readEntryCursor+=r.length;e.entriesRead+=1;for(var s=0;s<n.extraFields.length;s++){var f=n.extraFields[s];if(f.id!==1)continue;var l=f.data;var u=0;if(n.uncompressedSize===4294967295){if(u+8>l.length){return emitErrorAndAutoClose(e,new Error("zip64 extended information extra field does not include uncompressed size"))}n.uncompressedSize=readUInt64LE(l,u);u+=8}if(n.compressedSize===4294967295){if(u+8>l.length){return emitErrorAndAutoClose(e,new Error("zip64 extended information extra field does not include compressed size"))}n.compressedSize=readUInt64LE(l,u);u+=8}if(n.relativeOffsetOfLocalHeader===4294967295){if(u+8>l.length){return emitErrorAndAutoClose(e,new Error("zip64 extended information extra field does not include relative header offset"))}n.relativeOffsetOfLocalHeader=readUInt64LE(l,u);u+=8}break}if(e.validateEntrySizes&&n.compressionMethod===0){var d=n.uncompressedSize;if(n.isEncrypted()){d+=12}if(n.compressedSize!==d){var c="compressed/uncompressed size mismatch for stored file: "+n.compressedSize+" != "+n.uncompressedSize;return emitErrorAndAutoClose(e,new Error(c))}}e.emit("entry",n);if(!e.lazyEntries)e._readEntry()}))}))};ZipFile.prototype.openReadStream=function(e,r,t){var n=this;var i=0;var o=e.compressedSize;if(t==null){t=r;r=null}if(r==null){r={}}else{if(r.decrypt!=null){if(!e.isEncrypted()){throw new Error("options.decrypt can only be specified for encrypted entries")}if(r.decrypt!==false)throw new Error("invalid options.decrypt value: "+r.decrypt);if(e.isCompressed()){if(r.decompress!==false)throw new Error("entry is encrypted and compressed, and options.decompress !== false")}}if(r.decompress!=null){if(!e.isCompressed()){throw new Error("options.decompress can only be specified for compressed entries")}if(!(r.decompress===false||r.decompress===true)){throw new Error("invalid options.decompress value: "+r.decompress)}}if(r.start!=null||r.end!=null){if(e.isCompressed()&&r.decompress!==false){throw new Error("start/end range not allowed for compressed entry without options.decompress === false")}if(e.isEncrypted()&&r.decrypt!==false){throw new Error("start/end range not allowed for encrypted entry without options.decrypt === false")}}if(r.start!=null){i=r.start;if(i<0)throw new Error("options.start < 0");if(i>e.compressedSize)throw new Error("options.start > entry.compressedSize")}if(r.end!=null){o=r.end;if(o<0)throw new Error("options.end < 0");if(o>e.compressedSize)throw new Error("options.end > entry.compressedSize");if(o<i)throw new Error("options.end < options.start")}}if(!n.isOpen)return t(new Error("closed"));if(e.isEncrypted()){if(r.decrypt!==false)return t(new Error("entry is encrypted, and options.decrypt !== false"))}var a;if(e.compressionMethod===0){a=false}else if(e.compressionMethod===8){a=r.decompress!=null?r.decompress:true}else{return t(new Error("unsupported compression method: "+e.compressionMethod))}n.readLocalFileHeader(e,{minimal:true},(function(r,s){if(r)return t(r);n.openReadStreamLowLevel(s.fileDataStart,e.compressedSize,i,o,a,e.uncompressedSize,t)}))};ZipFile.prototype.openReadStreamLowLevel=function(e,r,t,i,o,a,s){var f=this;var l=e+r;var u=f.reader.createReadStream({start:e+t,end:e+i});var d=u;if(o){var c=false;var p=n.createInflateRaw();u.on("error",(function(e){setImmediate((function(){if(!c)p.emit("error",e)}))}));u.pipe(p);if(f.validateEntrySizes){d=new AssertByteCountStream(a);p.on("error",(function(e){setImmediate((function(){if(!c)d.emit("error",e)}))}));p.pipe(d)}else{d=p}installDestroyFn(d,(function(){c=true;if(p!==d)p.unpipe(d);u.unpipe(p);u.destroy()}))}s(null,d)};ZipFile.prototype.readLocalFileHeader=function(e,r,t){var n=this;if(t==null){t=r;r=null}if(r==null)r={};n.reader.ref();var i=c(30);readAndAssertNoEof(n.reader,i,0,i.length,e.relativeOffsetOfLocalHeader,(function(o){try{if(o)return t(o);var a=i.readUInt32LE(0);if(a!==67324752){return t(new Error("invalid local file header signature: 0x"+a.toString(16)))}var s=i.readUInt16LE(26);var f=i.readUInt16LE(28);var l=e.relativeOffsetOfLocalHeader+30+s+f;if(l+e.compressedSize>n.fileSize){return t(new Error("file data overflows file bounds: "+l+" + "+e.compressedSize+" > "+n.fileSize))}if(r.minimal){return t(null,{fileDataStart:l})}var u=new LocalFileHeader;u.fileDataStart=l;u.versionNeededToExtract=i.readUInt16LE(4);u.generalPurposeBitFlag=i.readUInt16LE(6);u.compressionMethod=i.readUInt16LE(8);u.lastModFileTime=i.readUInt16LE(10);u.lastModFileDate=i.readUInt16LE(12);u.crc32=i.readUInt32LE(14);u.compressedSize=i.readUInt32LE(18);u.uncompressedSize=i.readUInt32LE(22);u.fileNameLength=s;u.extraFieldLength=f;i=c(s+f);n.reader.ref();readAndAssertNoEof(n.reader,i,0,i.length,e.relativeOffsetOfLocalHeader+30,(function(e){try{if(e)return t(e);u.fileName=i.subarray(0,s);u.extraField=i.subarray(s);return t(null,u)}finally{n.reader.unref()}}))}finally{n.reader.unref()}}))};function Entry(){}Entry.prototype.getLastModDate=function(e){if(e==null)e={};if(!e.forceDosFormat){for(var r=0;r<this.extraFields.length;r++){var t=this.extraFields[r];if(t.id===21589){var n=t.data;if(n.length<5)continue;var i=n[0];var o=1;if(!(i&o))continue;var a=n.readInt32LE(1);return new Date(a*1e3)}else if(t.id===10){var n=t.data;var s=4;while(s<n.length+4){var f=n.readUInt16LE(s);s+=2;var l=n.readUInt16LE(s);s+=2;if(f!==1){s+=l;continue}if(l<8||s+l>n.length)break;var u=4294967296*n.readInt32LE(s+4)+n.readUInt32LE(s);var d=u/1e4-116444736e5;return new Date(d)}}}}return dosDateTimeToDate(this.lastModFileDate,this.lastModFileTime,e.timezone)};Entry.prototype.isEncrypted=function(){return(this.generalPurposeBitFlag&1)!==0};Entry.prototype.isCompressed=function(){return this.compressionMethod===8};function LocalFileHeader(){}function dosDateTimeToDate(e,r,t){var n=e&31;var i=(e>>5&15)-1;var o=(e>>9&127)+1980;var a=0;var s=(r&31)*2;var f=r>>5&63;var l=r>>11&31;if(t==null||t==="local"){return new Date(o,i,n,l,f,s,a)}else if(t==="UTC"){return new Date(Date.UTC(o,i,n,l,f,s,a))}else{throw new Error("unrecognized options.timezone: "+options.timezone)}}function getFileNameLowLevel(e,r,t,n){var i=null;for(var a=0;a<t.length;a++){var s=t[a];if(s.id===28789){if(s.data.length<6){continue}if(s.data.readUInt8(0)!==1){continue}var f=s.data.readUInt32LE(1);if(o.unsigned(r)!==f){continue}i=decodeBuffer(s.data.subarray(5),true);break}}if(i==null){var l=(e&2048)!==0;i=decodeBuffer(r,l)}if(!n){i=i.replace(/\\/g,"/")}return i}function validateFileName(e){if(e.indexOf("\\")!==-1){return"invalid characters in fileName: "+e}if(/^[a-zA-Z]:/.test(e)||/^\//.test(e)){return"absolute path: "+e}if(e.split("/").indexOf("..")!==-1){return"invalid relative path: "+e}return null}function parseExtraFields(e){var r=[];var t=0;while(t<e.length-3){var n=e.readUInt16LE(t+0);var i=e.readUInt16LE(t+2);var o=t+4;var a=o+i;if(a>e.length)throw new Error("extra field length exceeds extra field buffer size");var s=e.subarray(o,a);r.push({id:n,data:s});t=a}return r}function readAndAssertNoEof(e,r,t,n,i,o){if(n===0){return setImmediate((function(){o(null,c(0))}))}e.read(r,t,n,i,(function(e,r){if(e)return o(e);if(r<n){return o(new Error("unexpected EOF"))}o()}))}a.inherits(AssertByteCountStream,f);function AssertByteCountStream(e){f.call(this);this.actualByteCount=0;this.expectedByteCount=e}AssertByteCountStream.prototype._transform=function(e,r,t){this.actualByteCount+=e.length;if(this.actualByteCount>this.expectedByteCount){var n="too many bytes in the stream. expected "+this.expectedByteCount+". got at least "+this.actualByteCount;return t(new Error(n))}t(null,e)};AssertByteCountStream.prototype._flush=function(e){if(this.actualByteCount<this.expectedByteCount){var r="not enough bytes in the stream. expected "+this.expectedByteCount+". got only "+this.actualByteCount;return e(new Error(r))}e()};a.inherits(RandomAccessReader,s);function RandomAccessReader(){s.call(this);this.refCount=0}RandomAccessReader.prototype.ref=function(){this.refCount+=1};RandomAccessReader.prototype.unref=function(){var e=this;e.refCount-=1;if(e.refCount>0)return;if(e.refCount<0)throw new Error("invalid unref");e.close(onCloseDone);function onCloseDone(r){if(r)return e.emit("error",r);e.emit("close")}};RandomAccessReader.prototype.createReadStream=function(e){if(e==null)e={};var r=e.start;var t=e.end;if(r===t){var n=new l;setImmediate((function(){n.end()}));return n}var i=this._readStreamForRange(r,t);var o=false;var a=new RefUnrefFilter(this);i.on("error",(function(e){setImmediate((function(){if(!o)a.emit("error",e)}))}));installDestroyFn(a,(function(){i.unpipe(a);a.unref();i.destroy()}));var s=new AssertByteCountStream(t-r);a.on("error",(function(e){setImmediate((function(){if(!o)s.emit("error",e)}))}));installDestroyFn(s,(function(){o=true;a.unpipe(s);a.destroy()}));return i.pipe(a).pipe(s)};RandomAccessReader.prototype._readStreamForRange=function(e,r){throw new Error("not implemented")};RandomAccessReader.prototype.read=function(e,r,t,n,i){var o=this.createReadStream({start:n,end:n+t});var a=new u;var s=0;a._write=function(t,n,i){t.copy(e,r+s,0,t.length);s+=t.length;i()};a.on("finish",i);o.on("error",(function(e){i(e)}));o.pipe(a)};RandomAccessReader.prototype.close=function(e){setImmediate(e)};a.inherits(RefUnrefFilter,l);function RefUnrefFilter(e){l.call(this);this.context=e;this.context.ref();this.unreffedYet=false}RefUnrefFilter.prototype._flush=function(e){this.unref();e()};RefUnrefFilter.prototype.unref=function(e){if(this.unreffedYet)return;this.unreffedYet=true;this.context.unref()};var d="\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ";function decodeBuffer(e,r){if(r){return e.toString("utf8")}else{var t="";for(var n=0;n<e.length;n++){t+=d[e[n]]}return t}}function readUInt64LE(e,r){var t=e.readUInt32LE(r);var n=e.readUInt32LE(r+4);return n*4294967296+t}var c;if(typeof Buffer.allocUnsafe==="function"){c=function(e){return Buffer.allocUnsafe(e)}}else{c=function(e){return new Buffer(e)}}function installDestroyFn(e,r){if(typeof e.destroy==="function"){e._destroy=function(e,t){r();if(t!=null)t(e)}}else{e.destroy=r}}function defaultCallback(e){if(e)throw e}}();module.exports=t})();
@@ -0,0 +1 @@
1
+ {"name":"yauzl","version":"3.2.0","description":"yet another unzip library for node","engines":{"node":">=12"},"main":"index.js","scripts":{"test":"node test/test.js"},"repository":{"type":"git","url":"git+https://github.com/thejoshwolfe/yauzl.git"},"keywords":["unzip","zip","stream","archive","file"],"author":"Josh Wolfe <thejoshwolfe@gmail.com>","license":"MIT","bugs":{"url":"https://github.com/thejoshwolfe/yauzl/issues"},"homepage":"https://github.com/thejoshwolfe/yauzl","dependencies":{"buffer-crc32":"~0.2.3","pend":"~1.2.0"},"devDependencies":{"bl":"^6.0.11"},"files":["fd-slicer.js","index.js"],"_lastModified":"2025-01-18T18:48:36.008Z"}