From 175534b7881492bcc014404b678ad9bdb1226a77 Mon Sep 17 00:00:00 2001 From: Brian Beck Date: Sun, 27 Oct 2024 13:56:21 -0700 Subject: [PATCH] Add action log viewer --- docs/404.html | 2 +- docs/404/index.html | 2 +- ...ad38414a89e.js => 215-9d340583554476dc.js} | 0 ...218056.js => 4bd1b696-5718bc182b91a6e9.js} | 0 ...8dc133b7a18.js => 515-a62e2db5bca20cf3.js} | 0 .../chunks/94730671-6ced0342e6a25b8f.js | 1 + ...d80c488476.js => page-b483a32cdf1d8e2c.js} | 0 .../chunks/app/page-198e743de2f7340f.js | 1 - .../chunks/app/page-2dac80ee609f3188.js | 1 + .../chunks/f8025e75-eec57ce6fbd95417.js | 1 + ...1720d26.js => webpack-6224deb4e766f25e.js} | 2 +- ...87fbacbbad8f6.css => 8f45e42583e71b0d.css} | 2 +- .../_buildManifest.js | 0 .../_ssgManifest.js | 0 docs/index.html | 2 +- docs/index.txt | 6 +- src/Forge.tsx | 79 ++++++++++++++----- src/Messages.module.css | 69 ++++++++++++++++ src/Messages.tsx | 72 +++++++++++++++++ src/utils.ts | 3 + 20 files changed, 215 insertions(+), 28 deletions(-) rename docs/_next/static/chunks/{215-40b82ad38414a89e.js => 215-9d340583554476dc.js} (100%) rename docs/_next/static/chunks/{4bd1b696-219110418d218056.js => 4bd1b696-5718bc182b91a6e9.js} (100%) rename docs/_next/static/chunks/{515-35a068dc133b7a18.js => 515-a62e2db5bca20cf3.js} (100%) create mode 100644 docs/_next/static/chunks/94730671-6ced0342e6a25b8f.js rename docs/_next/static/chunks/app/_not-found/{page-5f7d01d80c488476.js => page-b483a32cdf1d8e2c.js} (100%) delete mode 100644 docs/_next/static/chunks/app/page-198e743de2f7340f.js create mode 100644 docs/_next/static/chunks/app/page-2dac80ee609f3188.js create mode 100644 docs/_next/static/chunks/f8025e75-eec57ce6fbd95417.js rename docs/_next/static/chunks/{webpack-33dd47c841720d26.js => webpack-6224deb4e766f25e.js} (96%) rename docs/_next/static/css/{d8287fbacbbad8f6.css => 8f45e42583e71b0d.css} (85%) rename docs/_next/static/{9Pi0et4BW69YTW10MWfB6 => doB4mbbCjK_svkG4sfPx3}/_buildManifest.js (100%) rename docs/_next/static/{9Pi0et4BW69YTW10MWfB6 => doB4mbbCjK_svkG4sfPx3}/_ssgManifest.js (100%) create mode 100644 src/Messages.module.css create mode 100644 src/Messages.tsx diff --git a/docs/404.html b/docs/404.html index 41b3cbe..2eb8595 100644 --- a/docs/404.html +++ b/docs/404.html @@ -1 +1 @@ -404: This page could not be found.VL2 Forge

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.VL2 Forge

404

This page could not be found.

\ No newline at end of file diff --git a/docs/404/index.html b/docs/404/index.html index 41b3cbe..2eb8595 100644 --- a/docs/404/index.html +++ b/docs/404/index.html @@ -1 +1 @@ -404: This page could not be found.VL2 Forge

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.VL2 Forge

404

This page could not be found.

\ No newline at end of file diff --git a/docs/_next/static/chunks/215-40b82ad38414a89e.js b/docs/_next/static/chunks/215-9d340583554476dc.js similarity index 100% rename from docs/_next/static/chunks/215-40b82ad38414a89e.js rename to docs/_next/static/chunks/215-9d340583554476dc.js diff --git a/docs/_next/static/chunks/4bd1b696-219110418d218056.js b/docs/_next/static/chunks/4bd1b696-5718bc182b91a6e9.js similarity index 100% rename from docs/_next/static/chunks/4bd1b696-219110418d218056.js rename to docs/_next/static/chunks/4bd1b696-5718bc182b91a6e9.js diff --git a/docs/_next/static/chunks/515-35a068dc133b7a18.js b/docs/_next/static/chunks/515-a62e2db5bca20cf3.js similarity index 100% rename from docs/_next/static/chunks/515-35a068dc133b7a18.js rename to docs/_next/static/chunks/515-a62e2db5bca20cf3.js diff --git a/docs/_next/static/chunks/94730671-6ced0342e6a25b8f.js b/docs/_next/static/chunks/94730671-6ced0342e6a25b8f.js new file mode 100644 index 0000000..9c943d6 --- /dev/null +++ b/docs/_next/static/chunks/94730671-6ced0342e6a25b8f.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[522],{3051:(t,L,r)=>{r.d(L,{qGf:()=>e});var a=r(1810);function e(t){return(0,a.w_)({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 10.5858L9.17157 7.75736L7.75736 9.17157L10.5858 12L7.75736 14.8284L9.17157 16.2426L12 13.4142L14.8284 16.2426L16.2426 14.8284L13.4142 12L16.2426 9.17157L14.8284 7.75736L12 10.5858Z"},child:[]}]})(t)}}}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/app/_not-found/page-5f7d01d80c488476.js b/docs/_next/static/chunks/app/_not-found/page-b483a32cdf1d8e2c.js similarity index 100% rename from docs/_next/static/chunks/app/_not-found/page-5f7d01d80c488476.js rename to docs/_next/static/chunks/app/_not-found/page-b483a32cdf1d8e2c.js diff --git a/docs/_next/static/chunks/app/page-198e743de2f7340f.js b/docs/_next/static/chunks/app/page-198e743de2f7340f.js deleted file mode 100644 index d25c592..0000000 --- a/docs/_next/static/chunks/app/page-198e743de2f7340f.js +++ /dev/null @@ -1 +0,0 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{9343:(e,t,i)=>{Promise.resolve().then(i.bind(i,7341))},7341:(e,t,i)=>{"use strict";i.d(t,{Forge:()=>I});var a=i(7437),n=i(2265),r=i(2781),s=i(9943),l=i.n(s),o=i(1942),m=i(3500),p=i.n(m);function c(){return(0,a.jsx)("div",{className:p().LoadingBackdrop,children:(0,a.jsx)("div",{className:p().LoadingText,children:"Loading…"})})}var u=i(6356),d=i(7692),g=i(7261),f=i(3872),h=i(1109),y=i(9675),_=i(7135),x=i.n(_);function v(e){let{file:t,onDelete:i,onRename:r}=e,s=(0,n.useMemo)(()=>{var e,i;if(t.blobUri&&(null===(e=t.type)||void 0===e?void 0:e.genericType)==="image")return(0,a.jsx)("img",{className:x().PreviewIcon,src:t.blobUri,width:24,alt:""});if((null===(i=t.type)||void 0===i?void 0:i.genericType)==="audio")return(0,a.jsx)(h.Eow,{});if(/\.cs$/i.test(t.path))return(0,a.jsx)(g.HXH,{});if(/\.mis$/i.test(t.path))return(0,a.jsx)(y.Gw8,{});if(/\.dif$/i.test(t.path))return(0,a.jsx)(d.Mm0,{});if(/\.ter$/i.test(t.path))return(0,a.jsx)(u.seb,{});if(/\.spn$/i.test(t.path))return(0,a.jsx)(f.ekl,{});return null},[t]);return(0,a.jsxs)("div",{className:x().File,children:[(0,a.jsx)("span",{className:x().IconContainer,children:s})," ",(0,a.jsx)("span",{className:x().Path,onDoubleClick:()=>{let e=window.prompt("Rename file (".concat(t.path,"):"),t.path);e&&(e=e.trim().replace(/\/+/g,"/").replace(/^\//,"").replace(/\/$/,"").trim())&&e!==t.path&&r(t.path,e)},children:t.path}),(0,a.jsx)("button",{className:x().DeleteButton,type:"button","aria-label":"Delete",title:"Delete",onClick:e=>{i(t.path)},children:(0,a.jsx)(o.AMf,{})})]})}var b=i(9315),w=i.n(b),j=i(7170);function F(e){let t=e.split("/"),i="",a="";return(t.length>1?(i=t.slice(0,-1).join("/"),a=t[t.length-1]):(i="",a=t[0]),i)?"".concat(i,"/").concat(a):(/\.(l|m|h)(male|female|bioderm)\.png$/i.test(a)||/^(vehicle|weapon)_.+png$/i.test(a)||/^dcase\d\d\.png$/i.test(a)?i="textures/skins":/\.(ter|spn)$/i.test(a)?i="terrains":/\.mis$/i.test(a)?i="missions":/\.dif$/i.test(a)&&(i="interiors"),i)?"".concat(i,"/").concat(a):a}function T(e){if(e.type){if(/^image\//i.test(e.type))return{mimeType:e.type,genericType:"image"};if(/^audio\//i.test(e.type))return{mimeType:e.type,genericType:"audio"}}if(/\.png$/i.test(e.name))return{mimeType:"image/png",genericType:"image"};if(/\.jpg$/i.test(e.name))return{mimeType:"image/jpeg",genericType:"image"};if(/\.bmp$/i.test(e.name))return{mimeType:"image/bmp",genericType:"image"};if(/\.webp$/i.test(e.name))return{mimeType:"image/webp",genericType:"image"};if(/\.gif$/i.test(e.name))return{mimeType:"image/gif",genericType:"image"};if(/\.tiff$/i.test(e.name))return{mimeType:"image/tiff",genericType:"image"};if(/\.svg$/i.test(e.name))return{mimeType:"image/svg+xml",genericType:"image"};else if(/\.wav$/i.test(e.name))return{mimeType:"audio/wav",genericType:"audio"};else if(/\.mp3$/i.test(e.name))return{mimeType:"audio/mpeg",genericType:"audio"};return e.type?{mimeType:e.type,genericType:null}:null}async function L(e){let t=await w().loadAsync(e),i=new Map;for(let e in t.files){let l=t.files[e];if(!l.dir){var a,n,r,s;e=F(e);let t=await l.async("arraybuffer"),o={path:e,buffer:t,blobUri:null,date:l.date,unixPermissions:l.unixPermissions,dosPermissions:l.dosPermissions,type:T(l)};if((null===(a=o.type)||void 0===a?void 0:a.genericType)==="image"||(null===(n=o.type)||void 0===n?void 0:n.genericType)==="audio"){let e=new Blob([t],{type:null!==(s=null===(r=o.type)||void 0===r?void 0:r.mimeType)&&void 0!==s?s:""});o.blobUri=URL.createObjectURL(e)}i.set(e,o)}}return i}async function N(e){var t;let i;let a=new Map;if(e.path)(i=e.path).startsWith("/")&&(i=i.slice(1));else{if(!e.name)return a;i=e.name}let n={path:i=F(i),buffer:await new Promise((t,i)=>{let a=new FileReader;a.addEventListener("load",e=>{t(e.target.result)}),a.readAsArrayBuffer(e)}),blobUri:null,date:null,unixPermissions:null,dosPermissions:null,type:T(e)};return(null===(t=n.type)||void 0===t?void 0:t.genericType)==="image"&&(n.blobUri=URL.createObjectURL(e)),a.set(i,n),a}async function k(e){return/\.(zip|vl2)$/i.test(e.name)?L(e):N(e)}async function $(e,t){let i=await e.generateAsync({type:"blob",mimeType:"application/octet-stream"});(0,j.saveAs)(i,t)}var D=i(4658),A=i.n(D);function P(e){let{fileList:t}=e;return(0,a.jsxs)("form",{className:A().DownloadForm,onSubmit:async e=>{e.preventDefault();let i=e.target.elements.fileName,a=i.value.trim();if(a){if(t.length){let e=function(e){let t=new(w());for(let i of e)t.file(i.path,i.buffer,{date:i.date,dosPermissions:i.dosPermissions,unixPermissions:i.unixPermissions});return t}(t);await $(e,"".concat(a,".vl2"))}else window.alert("Add some files!")}else window.alert("Name thy file."),i.focus()},children:[(0,a.jsx)("div",{className:A().NameInput,children:(0,a.jsx)("input",{name:"fileName",type:"text",placeholder:"name thy file",onChange:e=>{/\.vl2$/i.test(e.target.value)&&(e.target.value=e.target.value.slice(0,-4))}})}),(0,a.jsx)("button",{type:"submit",className:A().DownloadButton,children:"Download"})]})}var C=i(7673),B=i.n(C);function I(){let[e,t]=(0,n.useTransition)(),[i,s]=(0,n.useState)(0),[m,p]=(0,n.useState)(()=>[]),[u,d]=(0,n.useState)(()=>new Map),g=(0,n.useCallback)(async e=>{s(e=>e+1);let i=[],a=new Map;(await Promise.all(e.map(e=>k(e)))).forEach(e=>{e.forEach((e,t)=>{a.has(t)&&i.push({type:"overwrite",path:t}),a.set(t,e)})}),t(()=>{d(e=>new Map([...Array.from(e.entries()),...Array.from(a.entries())])),p(e=>[...e,...i])}),s(e=>e-1)},[]),{getRootProps:f,getInputProps:h,open:y,isDragActive:_}=(0,r.uI)({noClick:!0,noKeyboard:!0,onDrop:g}),x=(0,n.useMemo)(()=>l()(Array.from(u.keys()),[e=>e.toLowerCase()],["asc"]).map(e=>u.get(e)),[u]),b=(0,a.jsx)("button",{type:"button",className:B().AddButton,"aria-label":"Add files",title:"Add files",onClick:y,children:"+"}),w=(0,n.useCallback)(e=>{d(t=>{let i=new Map(t);return i.delete(e),i})},[]),j=(0,n.useCallback)((e,t)=>{d(i=>{let a={...i.get(e),path:t},n=new Map(i);return n.delete(e),n.set(t,a),n})},[]),F=e||i>0;return(0,a.jsxs)("section",{className:B().Forge,...f(),children:[(0,a.jsxs)("header",{className:B().Header,children:[(0,a.jsx)("a",{className:B().HeaderLink,href:"https://github.com/exogen/vl2-forge",children:(0,a.jsx)(o.hJX,{"aria-label":"GitHub"})}),(0,a.jsx)("img",{className:B().Logo,width:210,height:188,src:"/vl2-forge/logo-md.png",alt:"VL2 Forge"}),b]}),(0,a.jsx)("input",{...h()}),(0,a.jsxs)("div",{className:B().ListArea,children:[F?(0,a.jsx)(c,{}):null,x.length?(0,a.jsx)("ul",{className:B().FileList,children:x.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)(v,{file:e,onDelete:w,onRename:j})},e.path))}):F?null:(0,a.jsx)("div",{className:B().EmptyMessage,children:"Drop files onto the page or press the add button. No need to extract existing .vl2 files first –\xa0just drop ‘em in and it’ll take care of that!"})]}),(0,a.jsxs)("footer",{className:B().Footer,children:[(0,a.jsx)("a",{className:B().FooterLink,href:"https://github.com/exogen/vl2-forge",children:(0,a.jsx)(o.hJX,{"aria-label":"GitHub"})}),(0,a.jsx)(P,{fileList:x})]})]})}},4658:e=>{e.exports={DownloadForm:"DownloadForm_DownloadForm__xJrhQ",NameInput:"DownloadForm_NameInput__rJoTF",DownloadButton:"DownloadForm_DownloadButton__THR8u"}},7135:e=>{e.exports={File:"FileItem_File__FC9Rk",IconContainer:"FileItem_IconContainer__B0pA0",PreviewIcon:"FileItem_PreviewIcon__CVUKY",Path:"FileItem_Path__6Y42m",DeleteButton:"FileItem_DeleteButton__qYt5o"}},7673:e=>{e.exports={Forge:"Forge_Forge__dDZFe",Footer:"Forge_Footer__ghw3O",ListArea:"Forge_ListArea__OpY_R",FileList:"Forge_FileList__9JOyh",EmptyMessage:"Forge_EmptyMessage__Lrlud",AddButton:"Forge_AddButton__09pXD",Header:"Forge_Header__7t3Qc",HeaderLink:"Forge_HeaderLink__fEDGG",FooterLink:"Forge_FooterLink__gznaM"}},3500:e=>{e.exports={LoadingBackdrop:"Loading_LoadingBackdrop__9nxZJ",LoadingText:"Loading_LoadingText__cJZao"}}},e=>{var t=t=>e(e.s=t);e.O(0,[113,665,51,212,516,675,240,699,515,130,215,744],()=>t(9343)),_N_E=e.O()}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/app/page-2dac80ee609f3188.js b/docs/_next/static/chunks/app/page-2dac80ee609f3188.js new file mode 100644 index 0000000..4887dbf --- /dev/null +++ b/docs/_next/static/chunks/app/page-2dac80ee609f3188.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{9343:(e,t,i)=>{Promise.resolve().then(i.bind(i,4538))},4538:(e,t,i)=>{"use strict";i.d(t,{Forge:()=>U});var s=i(7437),n=i(2265),a=i(2781),r=i(9943),o=i.n(r),l=i(1942),c=i(3500),u=i.n(c);function m(){return(0,s.jsx)("div",{className:u().LoadingBackdrop,children:(0,s.jsx)("div",{className:u().LoadingText,children:"Loading…"})})}var d=i(6356),p=i(7692),g=i(7261),f=i(3872),h=i(1109),_=i(9675),y=i(7135),x=i.n(y);function w(e){let{file:t,onDelete:i,onRename:a}=e,r=(0,n.useMemo)(()=>{var e,i;if(t.blobUri&&(null===(e=t.type)||void 0===e?void 0:e.genericType)==="image")return(0,s.jsx)("img",{className:x().PreviewIcon,src:t.blobUri,width:24,alt:""});if((null===(i=t.type)||void 0===i?void 0:i.genericType)==="audio")return(0,s.jsx)(h.Eow,{});if(/\.cs$/i.test(t.path))return(0,s.jsx)(g.HXH,{});if(/\.mis$/i.test(t.path))return(0,s.jsx)(_.Gw8,{});if(/\.dif$/i.test(t.path))return(0,s.jsx)(p.Mm0,{});if(/\.ter$/i.test(t.path))return(0,s.jsx)(d.seb,{});if(/\.spn$/i.test(t.path))return(0,s.jsx)(f.ekl,{});return null},[t]);return(0,s.jsxs)("div",{className:x().File,children:[(0,s.jsx)("span",{className:x().IconContainer,children:r})," ",(0,s.jsx)("span",{className:x().Path,onDoubleClick:()=>{let e=window.prompt("Rename file (".concat(t.path,"):"),t.path);e&&(e=e.trim().replace(/\/+/g,"/").replace(/^\//,"").replace(/\/$/,"").trim())&&e!==t.path&&a(t.path,e)},children:t.path}),(0,s.jsx)("button",{className:x().DeleteButton,type:"button","aria-label":"Delete",title:"Delete",onClick:e=>{i(t.path)},children:(0,s.jsx)(l.AMf,{})})]})}var b=i(9315),j=i.n(b),v=i(7170);function F(e){let t=e.split("/"),i="",s="";return(t.length>1?(i=t.slice(0,-1).join("/"),s=t[t.length-1]):(i="",s=t[0]),i)?"".concat(i,"/").concat(s):(/\.(l|m|h)(male|female|bioderm)\.png$/i.test(s)||/^(vehicle|weapon)_.+png$/i.test(s)||/^dcase\d\d\.png$/i.test(s)?i="textures/skins":/\.(ter|spn)$/i.test(s)?i="terrains":/\.mis$/i.test(s)?i="missions":/\.dif$/i.test(s)&&(i="interiors"),i)?"".concat(i,"/").concat(s):s}function L(e){if(e.type){if(/^image\//i.test(e.type))return{mimeType:e.type,genericType:"image"};if(/^audio\//i.test(e.type))return{mimeType:e.type,genericType:"audio"}}if(/\.png$/i.test(e.name))return{mimeType:"image/png",genericType:"image"};if(/\.jpg$/i.test(e.name))return{mimeType:"image/jpeg",genericType:"image"};if(/\.bmp$/i.test(e.name))return{mimeType:"image/bmp",genericType:"image"};if(/\.webp$/i.test(e.name))return{mimeType:"image/webp",genericType:"image"};if(/\.gif$/i.test(e.name))return{mimeType:"image/gif",genericType:"image"};if(/\.tiff$/i.test(e.name))return{mimeType:"image/tiff",genericType:"image"};if(/\.svg$/i.test(e.name))return{mimeType:"image/svg+xml",genericType:"image"};else if(/\.wav$/i.test(e.name))return{mimeType:"audio/wav",genericType:"audio"};else if(/\.mp3$/i.test(e.name))return{mimeType:"audio/mpeg",genericType:"audio"};return e.type?{mimeType:e.type,genericType:null}:null}async function T(e){let t=await j().loadAsync(e),i=new Map;for(let o in t.files){let l=t.files[o];if(!l.dir){var s,n,a,r;o=F(o);let t=await l.async("arraybuffer"),c={source:e.name||null,path:o,buffer:t,blobUri:null,date:l.date,unixPermissions:l.unixPermissions,dosPermissions:l.dosPermissions,type:L(l)};if((null===(s=c.type)||void 0===s?void 0:s.genericType)==="image"||(null===(n=c.type)||void 0===n?void 0:n.genericType)==="audio"){let e=new Blob([t],{type:null!==(r=null===(a=c.type)||void 0===a?void 0:a.mimeType)&&void 0!==r?r:""});c.blobUri=URL.createObjectURL(e)}i.set(o,c)}}return i}async function N(e){var t;let i;let s=new Map;if(e.path)(i=e.path).startsWith("/")&&(i=i.slice(1));else{if(!e.name)return s;i=e.name}let n={source:"direct upload",path:i=F(i),buffer:await new Promise((t,i)=>{let s=new FileReader;s.addEventListener("load",e=>{t(e.target.result)}),s.readAsArrayBuffer(e)}),blobUri:null,date:null,unixPermissions:null,dosPermissions:null,type:L(e)};return(null===(t=n.type)||void 0===t?void 0:t.genericType)==="image"&&(n.blobUri=URL.createObjectURL(e)),s.set(i,n),s}async function k(e){return/\.(zip|vl2)$/i.test(e.name)?T(e):N(e)}async function C(e,t){let i=await e.generateAsync({type:"blob",mimeType:"application/octet-stream"});(0,v.saveAs)(i,t)}var M=i(4658),B=i.n(M);function E(e){let{fileList:t}=e;return(0,s.jsxs)("form",{className:B().DownloadForm,onSubmit:async e=>{e.preventDefault();let i=e.target.elements.fileName,s=i.value.trim();if(s){if(t.length){let e=function(e){let t=new(j());for(let i of e)t.file(i.path,i.buffer,{date:i.date,dosPermissions:i.dosPermissions,unixPermissions:i.unixPermissions});return t}(t);await C(e,"".concat(s,".vl2"))}else window.alert("Add some files!")}else window.alert("Name thy file."),i.focus()},children:[(0,s.jsx)("div",{className:B().NameInput,children:(0,s.jsx)("input",{name:"fileName",type:"text",placeholder:"name thy file",onChange:e=>{/\.vl2$/i.test(e.target.value)&&(e.target.value=e.target.value.slice(0,-4))}})}),(0,s.jsx)("button",{type:"submit",className:B().DownloadButton,children:"Download"})]})}var A=i(7673),P=i.n(A),$=i(2655),D=i(3051),I=i(2238),R=i.n(I);function H(e){let{actionLog:t}=e,[i,a]=(0,n.useState)(!1),[r,o]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{i||o(!1)},[i]),(0,n.useEffect)(()=>{t.length>0&&o(!0)},[t]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"".concat(R().MessagesButton," ").concat(r?R().NewMessages:""),onClick:()=>{a(e=>!e)},children:(0,s.jsx)($.m2k,{})}),(0,s.jsxs)("div",{className:R().ActionLog,hidden:!i,children:[(0,s.jsx)("button",{className:R().CloseButton,type:"button",onClick:()=>{a(!1)},children:(0,s.jsx)(D.qGf,{})}),t.map((e,t)=>{switch(e.type){case"BATCH_OVERWRITE":return(0,s.jsxs)("p",{children:["File at ",(0,s.jsx)("span",{className:R().Path,children:e.path})," ","from ",(0,s.jsx)("del",{children:e.oldSource})," was replaced with the one from ",(0,s.jsx)("ins",{children:e.newSource})," because of the priority in which it was handled."]},t);case"NEW_OVERWRITE":return(0,s.jsxs)("p",{children:["File at ",(0,s.jsx)("span",{className:R().Path,children:e.path})," ","from ",(0,s.jsx)("del",{children:e.oldSource})," was replaced with the one from ",(0,s.jsx)("ins",{children:e.newSource})," because it is a newer upload."]},t);default:return null}})]})]})}let S={files:new Map,actionLog:[]};function U(){let[e,t]=(0,n.useTransition)(),[i,r]=(0,n.useState)(0),[c,u]=(0,n.useState)(S),{files:d,actionLog:p}=c,g=(0,n.useCallback)(async e=>{r(e=>e+1);let t=[],i=new Map,s=o()(Array.from(e),[e=>{var t;return(null!==(t=e.name)&&void 0!==t?t:"").toLowerCase()}],["asc"]);(await Promise.all(s.map(e=>k(e)))).forEach(e=>{e.forEach((e,s)=>{i.has(s)&&t.push({type:"BATCH_OVERWRITE",path:s,oldSource:i.get(s).source,newSource:e.source}),i.set(s,e)})}),u(e=>{let{files:s,actionLog:n}=e,a=[...n,...t],r=new Map(s);return i.forEach((e,t)=>{r.has(t)&&a.push({type:"NEW_OVERWRITE",path:t,oldSource:r.get(t).source,newSource:e.source}),r.set(t,e)}),{files:r,actionLog:a.length===n.length?n:a}}),r(e=>e-1)},[]),{getRootProps:f,getInputProps:h,open:_,isDragActive:y}=(0,a.uI)({noClick:!0,noKeyboard:!0,onDrop:g}),x=(0,n.useMemo)(()=>o()(Array.from(d.keys()),[e=>e.toLowerCase()],["asc"]).map(e=>d.get(e)),[d]),b=(0,s.jsx)("button",{type:"button",className:P().AddButton,"aria-label":"Add files",title:"Add files",onClick:_,children:"+"}),j=(0,n.useCallback)(e=>{u(t=>{let i=new Map(t.files);return i.delete(e),{files:i,actionLog:t.actionLog}})},[]),v=(0,n.useCallback)((e,t)=>{u(i=>{let s={...i.files.get(e),path:t},n=new Map(i.files);return n.delete(e),n.set(t,s),{files:n,actionLog:i.actionLog}})},[]),F=e||i>0;return(0,s.jsxs)("section",{className:P().Forge,...f(),children:[(0,s.jsxs)("header",{className:P().Header,children:[(0,s.jsx)("a",{className:P().HeaderLink,href:"https://github.com/exogen/vl2-forge",children:(0,s.jsx)(l.hJX,{"aria-label":"GitHub"})}),(0,s.jsx)("img",{className:P().Logo,width:210,height:188,src:"/vl2-forge/logo-md.png",alt:"VL2 Forge"}),b]}),(0,s.jsx)("input",{...h()}),(0,s.jsxs)("div",{className:P().ListArea,children:[F?(0,s.jsx)(m,{}):null,x.length?(0,s.jsx)("ul",{className:P().FileList,children:x.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(w,{file:e,onDelete:j,onRename:v})},e.path))}):F?null:(0,s.jsx)("div",{className:P().EmptyMessage,children:"Drop files onto the page or press the add button. No need to extract existing .vl2 files first –\xa0just drop ‘em in and it’ll take care of that!"})]}),(0,s.jsxs)("footer",{className:P().Footer,children:[(0,s.jsx)("a",{className:P().FooterLink,href:"https://github.com/exogen/vl2-forge",children:(0,s.jsx)(l.hJX,{"aria-label":"GitHub"})}),(0,s.jsx)(E,{fileList:x}),(0,s.jsx)(H,{actionLog:p})]})]})}},4658:e=>{e.exports={DownloadForm:"DownloadForm_DownloadForm__xJrhQ",NameInput:"DownloadForm_NameInput__rJoTF",DownloadButton:"DownloadForm_DownloadButton__THR8u"}},7135:e=>{e.exports={File:"FileItem_File__FC9Rk",IconContainer:"FileItem_IconContainer__B0pA0",PreviewIcon:"FileItem_PreviewIcon__CVUKY",Path:"FileItem_Path__6Y42m",DeleteButton:"FileItem_DeleteButton__qYt5o"}},7673:e=>{e.exports={Forge:"Forge_Forge__dDZFe",Footer:"Forge_Footer__ghw3O",ListArea:"Forge_ListArea__OpY_R",FileList:"Forge_FileList__9JOyh",EmptyMessage:"Forge_EmptyMessage__Lrlud",AddButton:"Forge_AddButton__09pXD",Header:"Forge_Header__7t3Qc",HeaderLink:"Forge_HeaderLink__fEDGG",FooterLink:"Forge_FooterLink__gznaM"}},3500:e=>{e.exports={LoadingBackdrop:"Loading_LoadingBackdrop__9nxZJ",LoadingText:"Loading_LoadingText__cJZao"}},2238:e=>{e.exports={MessagesButton:"Messages_MessagesButton__7CUm6",CloseButton:"Messages_CloseButton__66g2r",NewMessages:"Messages_NewMessages__r7_5G",ActionLog:"Messages_ActionLog__Bgwa6",Path:"Messages_Path__g_kWC"}}},e=>{var t=t=>e(e.s=t);e.O(0,[995,950,522,665,51,212,516,675,240,699,515,130,215,744],()=>t(9343)),_N_E=e.O()}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/f8025e75-eec57ce6fbd95417.js b/docs/_next/static/chunks/f8025e75-eec57ce6fbd95417.js new file mode 100644 index 0000000..fb17c93 --- /dev/null +++ b/docs/_next/static/chunks/f8025e75-eec57ce6fbd95417.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[950],{2655:(l,a,t)=>{t.d(a,{m2k:()=>c});var r=t(1810);function c(l){return(0,r.w_)({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M12 1.67c.955 0 1.845 .467 2.39 1.247l.105 .16l8.114 13.548a2.914 2.914 0 0 1 -2.307 4.363l-.195 .008h-16.225a2.914 2.914 0 0 1 -2.582 -4.2l.099 -.185l8.11 -13.538a2.914 2.914 0 0 1 2.491 -1.403zm.01 13.33l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007zm-.01 -7a1 1 0 0 0 -.993 .883l-.007 .117v4l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-4l-.007 -.117a1 1 0 0 0 -.993 -.883z"},child:[]}]})(l)}}}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/webpack-33dd47c841720d26.js b/docs/_next/static/chunks/webpack-6224deb4e766f25e.js similarity index 96% rename from docs/_next/static/chunks/webpack-33dd47c841720d26.js rename to docs/_next/static/chunks/webpack-6224deb4e766f25e.js index 55496da..41dae87 100644 --- a/docs/_next/static/chunks/webpack-33dd47c841720d26.js +++ b/docs/_next/static/chunks/webpack-6224deb4e766f25e.js @@ -1 +1 @@ -(()=>{"use strict";var e={},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var a=t[o]={id:o,loaded:!1,exports:{}},i=!0;try{e[o].call(a.exports,a,a.exports,r),i=!1}finally{i&&delete t[o]}return a.loaded=!0,a.exports}r.m=e,(()=>{var e=[];r.O=(t,o,n,a)=>{if(o){a=a||0;for(var i=e.length;i>0&&e[i-1][2]>a;i--)e[i]=e[i-1];e[i]=[o,n,a];return}for(var l=1/0,i=0;i=a)&&Object.keys(r.O).every(e=>r.O[e](o[d]))?o.splice(d--,1):(u=!1,a{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},(()=>{var e,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;r.t=function(o,n){if(1&n&&(o=this(o)),8&n||"object"==typeof o&&o&&(4&n&&o.__esModule||16&n&&"function"==typeof o.then))return o;var a=Object.create(null);r.r(a);var i={};e=e||[null,t({}),t([]),t(t)];for(var l=2&n&&o;"object"==typeof l&&!~e.indexOf(l);l=t(l))Object.getOwnPropertyNames(l).forEach(e=>i[e]=()=>o[e]);return i.default=()=>o,r.d(a,i),a}})(),r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce((t,o)=>(r.f[o](e,t),t),[])),r.u=e=>{},r.miniCssF=e=>{},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={},t="_N_E:";r.l=(o,n,a,i)=>{if(e[o]){e[o].push(n);return}if(void 0!==a)for(var l,u,d=document.getElementsByTagName("script"),c=0;c{l.onerror=l.onload=null,clearTimeout(p);var n=e[o];if(delete e[o],l.parentNode&&l.parentNode.removeChild(l),n&&n.forEach(e=>e(r)),t)return t(r)},p=setTimeout(f.bind(null,void 0,{type:"timeout",target:l}),12e4);l.onerror=f.bind(null,l.onerror),l.onload=f.bind(null,l.onload),u&&document.head.appendChild(l)}})(),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e;r.tt=()=>(void 0===e&&(e={createScriptURL:e=>e},"undefined"!=typeof trustedTypes&&trustedTypes.createPolicy&&(e=trustedTypes.createPolicy("nextjs#bundler",e))),e)})(),r.tu=e=>r.tt().createScriptURL(e),r.p="/vl2-forge/_next/",(()=>{var e={272:0,465:0,113:0};r.f.j=(t,o)=>{var n=r.o(e,t)?e[t]:void 0;if(0!==n){if(n)o.push(n[2]);else if(/^(113|272|465)$/.test(t))e[t]=0;else{var a=new Promise((r,o)=>n=e[t]=[r,o]);o.push(n[2]=a);var i=r.p+r.u(t),l=Error();r.l(i,o=>{if(r.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var a=o&&("load"===o.type?"missing":o.type),i=o&&o.target&&o.target.src;l.message="Loading chunk "+t+" failed.\n("+a+": "+i+")",l.name="ChunkLoadError",l.type=a,l.request=i,n[1](l)}},"chunk-"+t,t)}}},r.O.j=t=>0===e[t];var t=(t,o)=>{var n,a,[i,l,u]=o,d=0;if(i.some(t=>0!==e[t])){for(n in l)r.o(l,n)&&(r.m[n]=l[n]);if(u)var c=u(r)}for(t&&t(o);d{"use strict";var e={},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var a=t[o]={id:o,loaded:!1,exports:{}},i=!0;try{e[o].call(a.exports,a,a.exports,r),i=!1}finally{i&&delete t[o]}return a.loaded=!0,a.exports}r.m=e,(()=>{var e=[];r.O=(t,o,n,a)=>{if(o){a=a||0;for(var i=e.length;i>0&&e[i-1][2]>a;i--)e[i]=e[i-1];e[i]=[o,n,a];return}for(var l=1/0,i=0;i=a)&&Object.keys(r.O).every(e=>r.O[e](o[d]))?o.splice(d--,1):(u=!1,a{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},(()=>{var e,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;r.t=function(o,n){if(1&n&&(o=this(o)),8&n||"object"==typeof o&&o&&(4&n&&o.__esModule||16&n&&"function"==typeof o.then))return o;var a=Object.create(null);r.r(a);var i={};e=e||[null,t({}),t([]),t(t)];for(var l=2&n&&o;"object"==typeof l&&!~e.indexOf(l);l=t(l))Object.getOwnPropertyNames(l).forEach(e=>i[e]=()=>o[e]);return i.default=()=>o,r.d(a,i),a}})(),r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce((t,o)=>(r.f[o](e,t),t),[])),r.u=e=>{},r.miniCssF=e=>{},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={},t="_N_E:";r.l=(o,n,a,i)=>{if(e[o]){e[o].push(n);return}if(void 0!==a)for(var l,u,d=document.getElementsByTagName("script"),c=0;c{l.onerror=l.onload=null,clearTimeout(p);var n=e[o];if(delete e[o],l.parentNode&&l.parentNode.removeChild(l),n&&n.forEach(e=>e(r)),t)return t(r)},p=setTimeout(f.bind(null,void 0,{type:"timeout",target:l}),12e4);l.onerror=f.bind(null,l.onerror),l.onload=f.bind(null,l.onload),u&&document.head.appendChild(l)}})(),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e;r.tt=()=>(void 0===e&&(e={createScriptURL:e=>e},"undefined"!=typeof trustedTypes&&trustedTypes.createPolicy&&(e=trustedTypes.createPolicy("nextjs#bundler",e))),e)})(),r.tu=e=>r.tt().createScriptURL(e),r.p="/vl2-forge/_next/",(()=>{var e={272:0,465:0,995:0};r.f.j=(t,o)=>{var n=r.o(e,t)?e[t]:void 0;if(0!==n){if(n)o.push(n[2]);else if(/^(272|465|995)$/.test(t))e[t]=0;else{var a=new Promise((r,o)=>n=e[t]=[r,o]);o.push(n[2]=a);var i=r.p+r.u(t),l=Error();r.l(i,o=>{if(r.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var a=o&&("load"===o.type?"missing":o.type),i=o&&o.target&&o.target.src;l.message="Loading chunk "+t+" failed.\n("+a+": "+i+")",l.name="ChunkLoadError",l.type=a,l.request=i,n[1](l)}},"chunk-"+t,t)}}},r.O.j=t=>0===e[t];var t=(t,o)=>{var n,a,[i,l,u]=o,d=0;if(i.some(t=>0!==e[t])){for(n in l)r.o(l,n)&&(r.m[n]=l[n]);if(u)var c=u(r)}for(t&&t(o);dVL2 Forge \ No newline at end of file +VL2 Forge \ No newline at end of file diff --git a/docs/index.txt b/docs/index.txt index 5acf83e..0af65f2 100644 --- a/docs/index.txt +++ b/docs/index.txt @@ -1,7 +1,7 @@ 7:"$Sreact.fragment" 8:I[9275,[],""] 9:I[1343,[],""] -a:I[7341,["665","static/chunks/f97e080b-d92374f1605c166e.js","51","static/chunks/795d4814-df14aa386162ffad.js","212","static/chunks/59650de3-3851382c06f0a1a6.js","516","static/chunks/f7333993-0b21ce6d3b378608.js","675","static/chunks/b563f954-1a29a90b42165810.js","240","static/chunks/53c13509-7351503a4af8a85a.js","699","static/chunks/8e1d74a4-900578ac2c71efa7.js","515","static/chunks/515-35a068dc133b7a18.js","931","static/chunks/app/page-198e743de2f7340f.js"],"Forge",1] +a:I[4538,["950","static/chunks/f8025e75-eec57ce6fbd95417.js","522","static/chunks/94730671-6ced0342e6a25b8f.js","665","static/chunks/f97e080b-d92374f1605c166e.js","51","static/chunks/795d4814-df14aa386162ffad.js","212","static/chunks/59650de3-3851382c06f0a1a6.js","516","static/chunks/f7333993-0b21ce6d3b378608.js","675","static/chunks/b563f954-1a29a90b42165810.js","240","static/chunks/53c13509-7351503a4af8a85a.js","699","static/chunks/8e1d74a4-900578ac2c71efa7.js","515","static/chunks/515-a62e2db5bca20cf3.js","931","static/chunks/app/page-2dac80ee609f3188.js"],"Forge",1] b:I[3120,[],"OutletBoundary"] d:I[3120,[],"MetadataBoundary"] f:I[3120,[],"ViewportBoundary"] @@ -11,8 +11,8 @@ f:I[3120,[],"ViewportBoundary"] 3:HL["/vl2-forge/_next/static/media/a521fcc400cf9065-s.p.ttf","font",{"crossOrigin":"","type":"font/ttf"}] 4:HL["/vl2-forge/_next/static/media/e9ed9197b1d41e00-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}] 5:HL["/vl2-forge/_next/static/css/bdff6c7d2b4adc3b.css","style"] -6:HL["/vl2-forge/_next/static/css/d8287fbacbbad8f6.css","style"] -0:{"P":null,"b":"9Pi0et4BW69YTW10MWfB6","p":"/vl2-forge","c":["",""],"i":false,"f":[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",["$","$7","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/vl2-forge/_next/static/css/bdff6c7d2b4adc3b.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}]],["$","html",null,{"lang":"en","className":"__variable_6dd175 __variable_60c549 __variable_b97ccf","children":["$","body",null,{"children":["$","$L8",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L9",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]]}],{"children":["__PAGE__",["$","$7","c",{"children":[["$","$La",null,{}],[["$","link","0",{"rel":"stylesheet","href":"/vl2-forge/_next/static/css/d8287fbacbbad8f6.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}]],["$","$Lb",null,{"children":"$Lc"}]]}],{},null]},null],["$","$7","h",{"children":[null,["$","$7","Bbs2r012w6VYSLPXygGDr",{"children":[["$","$Ld",null,{"children":"$Le"}],["$","$Lf",null,{"children":"$L10"}],["$","meta",null,{"name":"next-size-adjust"}]]}]]}]]],"m":"$undefined","G":"$11","s":false,"S":true} +6:HL["/vl2-forge/_next/static/css/8f45e42583e71b0d.css","style"] +0:{"P":null,"b":"doB4mbbCjK_svkG4sfPx3","p":"/vl2-forge","c":["",""],"i":false,"f":[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",["$","$7","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/vl2-forge/_next/static/css/bdff6c7d2b4adc3b.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}]],["$","html",null,{"lang":"en","className":"__variable_6dd175 __variable_60c549 __variable_b97ccf","children":["$","body",null,{"children":["$","$L8",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L9",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]]}],{"children":["__PAGE__",["$","$7","c",{"children":[["$","$La",null,{}],[["$","link","0",{"rel":"stylesheet","href":"/vl2-forge/_next/static/css/8f45e42583e71b0d.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}]],["$","$Lb",null,{"children":"$Lc"}]]}],{},null]},null],["$","$7","h",{"children":[null,["$","$7","zy8WzxHRJrJcftPOY8oU_",{"children":[["$","$Ld",null,{"children":"$Le"}],["$","$Lf",null,{"children":"$L10"}],["$","meta",null,{"name":"next-size-adjust"}]]}]]}]]],"m":"$undefined","G":"$11","s":false,"S":true} 10:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}]] e:[["$","meta","0",{"charSet":"utf-8"}],["$","title","1",{"children":"VL2 Forge"}],["$","meta","2",{"name":"description","content":"Create .vl2 files for Tribes 2"}]] c:null diff --git a/src/Forge.tsx b/src/Forge.tsx index e24259b..eaa3145 100644 --- a/src/Forge.tsx +++ b/src/Forge.tsx @@ -1,5 +1,11 @@ "use client"; -import { useCallback, useMemo, useState, useTransition } from "react"; +import { + useCallback, + useEffect, + useMemo, + useState, + useTransition, +} from "react"; import { useDropzone } from "react-dropzone"; import orderBy from "lodash.orderby"; import { FaGithub } from "react-icons/fa"; @@ -8,39 +14,67 @@ import { FileItem } from "./FileItem"; import { DownloadForm } from "./DownloadForm"; import { handleInputFile } from "./utils"; import styles from "./Forge.module.css"; +import { Messages } from "./Messages"; + +const defaultFileData = { + files: new Map(), + actionLog: [], +}; export function Forge() { const [isPending, startTransition] = useTransition(); const [loadingCount, setLoadingCount] = useState(0); - const [actionLog, setActionLog] = useState(() => []); - const [files, setFiles] = useState(() => new Map()); + const [fileData, setFileData] = useState(defaultFileData); + + const { files, actionLog } = fileData; const onDrop = useCallback(async (acceptedFiles) => { setLoadingCount((count) => count + 1); const actionLog = []; const finalMap = new Map(); + const orderedAcceptedFiles = orderBy( + Array.from(acceptedFiles), + [(file) => (file.name ?? "").toLowerCase()], + ["asc"] + ); const allFiles: Array> = await Promise.all( - acceptedFiles.map((file) => handleInputFile(file)) + orderedAcceptedFiles.map((file) => handleInputFile(file)) ); allFiles.forEach((map) => { map.forEach((file, path) => { if (finalMap.has(path)) { actionLog.push({ - type: "overwrite", + type: "BATCH_OVERWRITE", path, + oldSource: finalMap.get(path).source, + newSource: file.source, }); } finalMap.set(path, file); }); }); - startTransition(() => { - setFiles((prevMap) => { - return new Map([ - ...Array.from(prevMap.entries()), - ...Array.from(finalMap.entries()), - ]); + setFileData((prevData) => { + const { files: prevFiles, actionLog: prevActionLog } = prevData; + const newActionLog = [...prevActionLog, ...actionLog]; + const newFiles = new Map(prevFiles); + finalMap.forEach((file, path) => { + if (newFiles.has(path)) { + newActionLog.push({ + type: "NEW_OVERWRITE", + path, + oldSource: newFiles.get(path).source, + newSource: file.source, + }); + } + newFiles.set(path, file); }); - setActionLog((prevLog) => [...prevLog, ...actionLog]); + return { + files: newFiles, + actionLog: + newActionLog.length === prevActionLog.length + ? prevActionLog + : newActionLog, + }; }); setLoadingCount((count) => count - 1); }, []); @@ -73,21 +107,27 @@ export function Forge() { ); const handleDelete = useCallback((path) => { - setFiles((files) => { - const newFiles = new Map(files); + setFileData((prevFileData) => { + const newFiles = new Map(prevFileData.files); newFiles.delete(path); - return newFiles; + return { + files: newFiles, + actionLog: prevFileData.actionLog, + }; }); }, []); const handleRename = useCallback((oldPath, newPath) => { - setFiles((files) => { - const file = files.get(oldPath); + setFileData((prevFileData) => { + const file = prevFileData.files.get(oldPath); const newFile = { ...file, path: newPath }; - const newFiles = new Map(files); + const newFiles = new Map(prevFileData.files); newFiles.delete(oldPath); newFiles.set(newPath, newFile); - return newFiles; + return { + files: newFiles, + actionLog: prevFileData.actionLog, + }; }); }, []); @@ -144,6 +184,7 @@ export function Forge() { + ); diff --git a/src/Messages.module.css b/src/Messages.module.css new file mode 100644 index 0000000..5d4843e --- /dev/null +++ b/src/Messages.module.css @@ -0,0 +1,69 @@ +.MessagesButton, +.CloseButton { + background: transparent; + border: 0; + margin: 0; + padding: 0; + display: grid; + place-content: center; + width: 40px; + height: 40px; + font-size: 32px; + color: rgba(255, 255, 255, 0.3); + transition: color 200ms; + cursor: pointer; +} + +.MessagesButton.NewMessages { + color: rgba(255, 162, 43, 1); +} + +.MessagesButton svg { + pointer-events: none; +} + +.CloseButton { + position: absolute; + top: 12px; + right: 12px; +} + +.CloseButton:hover { + color: rgba(255, 255, 255, 1); +} + +.ActionLog { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + font-size: 12px; + background: rgba(0, 0, 0, 0.9); + color: rgba(255, 162, 43, 1); + padding: 32px; + overflow: auto; + z-index: 2; +} + +.ActionLog del { + font-style: normal; + text-decoration: none; + border-bottom: 2px solid red; +} + +.ActionLog ins { + font-style: normal; + text-decoration: none; + border-bottom: 2px solid green; +} + +.Path { + color: rgb(255, 237, 212); +} + +@media (max-width: 767px) { + .MessagesButton { + display: none; + } +} diff --git a/src/Messages.tsx b/src/Messages.tsx new file mode 100644 index 0000000..36574f3 --- /dev/null +++ b/src/Messages.tsx @@ -0,0 +1,72 @@ +import { useEffect, useState } from "react"; +import { TbAlertTriangleFilled } from "react-icons/tb"; +import { RiCloseCircleFill } from "react-icons/ri"; +import styles from "./Messages.module.css"; + +export function Messages({ actionLog }) { + const [isOpen, setIsOpen] = useState(false); + const [hasNewMessages, setHasNewMessages] = useState(false); + + useEffect(() => { + if (!isOpen) { + setHasNewMessages(false); + } + }, [isOpen]); + + useEffect(() => { + if (actionLog.length > 0) { + setHasNewMessages(true); + } + }, [actionLog]); + + return ( + <> + + + + ); +} diff --git a/src/utils.ts b/src/utils.ts index cf3f7f9..f4de868 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -7,6 +7,7 @@ export type FileType = { }; export type FileEntry = { + source: string | null; path: string; buffer: ArrayBuffer; blobUri: string | null; @@ -145,6 +146,7 @@ export async function handleZipFile(file) { path = detectBestPath(path); const buffer = await fileObj.async("arraybuffer"); const fileEntry = { + source: file.name || null, path, buffer, blobUri: null, @@ -192,6 +194,7 @@ export async function handleOtherFile(file) { reader.readAsArrayBuffer(file); }); const fileEntry = { + source: "direct upload", path, buffer, blobUri: null,