diff --git a/cache/FilesExpanded-min.js b/cache/FilesExpanded-min.js index 129ab89..1b510c0 100644 --- a/cache/FilesExpanded-min.js +++ b/cache/FilesExpanded-min.js @@ -1 +1,5 @@ +// This extension by Sharkpool has been minified and modified by "Mistium" to remove code that goes unused within originOS +// DO NOT USE THIS +// Go here: https://sharkpool-sp.github.io/SharkPools-Extensions/ + !function(e){"use strict";if(!e.extensions.unsandboxed)throw new Error("Files Expanded must be run unsandboxed");let t={border:"#888",text:"#000000",outer:"#ffffff",sizeFont:1.5,borderRadius:16,borderType:"dashed",font:"inherit",shadow:.5,image:"",imageScale:100,textV:"Select or drop file",fontWeight:40,letterSpacing:"normal"};const o=["Scratch","Sans Serif","Serif","Handwriting","Marker","Curly","Pixel","inherit"],r="modal",n="selector",a="only-selector",l=[r,n,a];let s=r,c="",i="0kb",d="0",p="",u=!0;const m="text",y="hex",T="base64";const f=(o,r)=>new Promise((l=>{const u=t=>{l(t),e.vm.renderer.removeOverlay(R),e.vm.runtime.off("PROJECT_STOP_ALL",h),document.body.removeEventListener("keydown",b)};let f=!1;const g=e=>{if(f)return;f=!0;const t=new FileReader;switch(t.onload=()=>{c=e.name,i=x(e.size),d=e.size;const o=new Date(e.lastModified);let n;if(p=o.toLocaleString(),[y,T].includes(r)){let e=t.result.split(",");if(n=e.splice(1,e.length).join(","),r===y)n=function(e,t){const o=atob(e);let r="";for(let e=0;e{console.error("Failed to read file as text",t.error),u("")},r){case m:t.readAsText(e);case"url":t.readAsDataURL(e);default:t.readAsDataURL(e)}},x=e=>{const t=["B","KB","MB","GB","TB"];let o=0;for(;e>=1024&&o{"Escape"===e.key&&(e.stopPropagation(),e.preventDefault(),u(""))};document.body.addEventListener("keydown",b,{capture:!0});const h=()=>{u("")};e.vm.runtime.on("PROJECT_STOP_ALL",h);const k=t.border,R=document.createElement("div");R.style.pointerEvents="auto",R.style.width="100%",R.style.height="100%",R.style.display="flex",R.style.alignItems="center",R.style.justifyContent="center",R.style.background=`rgba(0, 0, 0, ${t.shadow})`,R.style.color=t.text,R.style.colorScheme="light",R.addEventListener("dragover",(e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",S.style.borderColor="#03a9fc")})),R.addEventListener("dragleave",(()=>{S.style.borderColor=k})),R.addEventListener("drop",(e=>{const t=e.dataTransfer.files[0];t&&(e.preventDefault(),g(t))})),R.addEventListener("click",(e=>{e.target===R&&u("")}));const S=document.createElement("button");S.style.boxShadow="0 0 10px -5px currentColor",S.style.cursor="pointer",S.style.font=t.font,S.style.fontFamily=t.font,S.style.background=t.image?t.image:t.outer,S.style.backgroundSize=t.imageScale+"%",S.style.padding="16px",S.style.borderRadius=`${t.borderRadius}px`,S.style.border=`8px ${t.borderType} ${k}`,S.style.position="relative",S.style.textAlign="center",S.addEventListener("click",(()=>{O.click()})),S.focus(),R.appendChild(S);const O=document.createElement("input");O.type="file",O.accept=o,O.addEventListener("change",(e=>{const t=e.target.files[0];t&&g(t)}));const v=document.createElement("div");v.textContent=t.textV,v.style.color=t.text,v.style.fontSize=`${t.sizeFont}em`,v.style.fontWeight=9*t.fontWeight,v.style.letterSpacing=`${t.letterSpacing}px`,v.style.marginBottom="8px",S.appendChild(v);const A=document.createElement("div"),E=o||"any";if(A.textContent=`Accepted Formats: ${E}`,A.style.fontSize=t.sizeFont-.5+"em",A.style.color=t.text,A.style.fontWeight=9*t.fontWeight,A.style.letterSpacing=`${t.letterSpacing}px`,S.appendChild(A),s!==a||(e=>"oncancel"in e||navigator.userAgent.includes("Firefox"))(O)||(s=n),s!==a){e.vm.renderer.addOverlay(R,"scale").container.style.zIndex="100"}s!==n&&s!==a||O.click(),s===a&&O.addEventListener("cancel",(()=>{u("")}))})),g=(e,t)=>{const o=document.createElement("a");o.href=e,o.download=t,document.body.appendChild(o),o.click(),o.remove()},x=(e,t)=>{const o=URL.createObjectURL(e);g(o,t),(requestIdleCallback??setTimeout)((()=>URL.revokeObjectURL(o)))},b=(t,o)=>{if(!(e=>{try{return"data:"===new URL(e).protocol}catch(e){return!1}})(t))return e.fetch(t).then((e=>e.blob())).then((e=>{x(e,o)}));g(t,o)};e.extensions.register(new class{getInfo(){return{id:"filesExpanded",name:"Files Expanded",color1:"#fcb103",color2:"#db9a37",color3:"#db8937",blocks:[{blockType:e.BlockType.LABEL,text:"Uploading"},{opcode:"showPicker",blockType:e.BlockType.REPORTER,text:"open a file",disableMonitor:!0,hideFromPalette:!0},{opcode:"showPickerExtensions",blockType:e.BlockType.REPORTER,text:"open a [extension] file",hideFromPalette:!0,arguments:{extension:{type:e.ArgumentType.STRING,defaultValue:".txt"}}},{opcode:"showPickerAs",blockType:e.BlockType.REPORTER,text:"open a file as [as]",arguments:{as:{type:e.ArgumentType.STRING,menu:"encoding"}}},{opcode:"showPickerExtensionsAs",blockType:e.BlockType.REPORTER,text:"open a [extension] file as [as]",arguments:{extension:{type:e.ArgumentType.STRING,defaultValue:".txt"},as:{type:e.ArgumentType.STRING,menu:"encoding"}}},{opcode:"fileInfo",blockType:e.BlockType.REPORTER,text:"file [FORMAT]",arguments:{FORMAT:{type:e.ArgumentType.STRING,menu:"formatted"}}},{blockType:e.BlockType.LABEL,text:"Downloading"},{opcode:"download",blockType:e.BlockType.COMMAND,text:"download [text] as [file]",arguments:{text:{type:e.ArgumentType.STRING,defaultValue:"Hello, world!"},file:{type:e.ArgumentType.STRING,defaultValue:"save.txt"}}},{opcode:"downloadURL",blockType:e.BlockType.COMMAND,text:"download URL [url] as [file]",arguments:{url:{type:e.ArgumentType.STRING,defaultValue:"data:text/plain;base64,SGVsbG8sIHdvcmxkIQ=="},file:{type:e.ArgumentType.STRING,defaultValue:"save.txt"}}},"---",{opcode:"setOpenMode",blockType:e.BlockType.COMMAND,text:"set open file selector mode to [mode]",arguments:{mode:{type:e.ArgumentType.STRING,defaultValue:r,menu:"automaticallyOpen"}}},{blockType:e.BlockType.LABEL,text:"Visuals"},{func:"toggleVis",blockType:e.BlockType.BUTTON,text:(u?"En":"Dis")+"able Customization"},{opcode:"resetStyle",blockType:e.BlockType.COMMAND,text:"reset selector style to default",hideFromPalette:u},"---",{opcode:"imageSet",blockType:e.BlockType.COMMAND,text:"set selector image to [IMG]",hideFromPalette:u,arguments:{IMG:{type:e.ArgumentType.STRING,defaultValue:"https://extensions.turbowarp.org/dango.png"}}},{opcode:"scaleImage",blockType:e.BlockType.COMMAND,text:"scale selector image to [SCALE]%",hideFromPalette:u,arguments:{SCALE:{type:e.ArgumentType.NUMBER,defaultValue:100}}},"---",{opcode:"borderColors",blockType:e.BlockType.COMMAND,text:"set selector [OPTION] color to [COLOR]",hideFromPalette:u,arguments:{OPTION:{type:e.ArgumentType.STRING,menu:"visualColors"},COLOR:{type:e.ArgumentType.COLOR,defaultValue:"#ff0000"}}},{opcode:"visualsSelect",blockType:e.BlockType.COMMAND,text:"set selector [OPTION] to [AMT]",hideFromPalette:u,arguments:{OPTION:{type:e.ArgumentType.STRING,menu:"visualOptions"},AMT:{type:e.ArgumentType.NUMBER,defaultValue:15}}},{opcode:"borderTypeSet",blockType:e.BlockType.COMMAND,text:"set selector border type to [TYPE]",hideFromPalette:u,arguments:{TYPE:{type:e.ArgumentType.STRING,menu:"borderTypes"}}},{opcode:"fontSet",blockType:e.BlockType.COMMAND,text:"set selector font to [FONT]",hideFromPalette:u,arguments:{FONT:{type:e.ArgumentType.STRING,menu:"font"}}},{opcode:"textSet",blockType:e.BlockType.COMMAND,text:"set file selector text to [TEXT]",hideFromPalette:u,arguments:{TEXT:{type:e.ArgumentType.STRING,defaultValue:"Insert File Here"}}},{opcode:"currentX",blockType:e.BlockType.REPORTER,text:"current selector [THING]",hideFromPalette:u,arguments:{THING:{type:e.ArgumentType.STRING,menu:"all"}}}],menus:{encoding:{acceptReporters:!0,items:[{text:"text",value:m},{text:"data: URL",value:"url"},{text:"base64",value:T},{text:"hex",value:y}]},automaticallyOpen:{acceptReporters:!0,items:[{text:"show modal",value:r},{text:"open selector immediately",value:n},{text:"only show selector (unreliable)",value:a}]},font:{acceptReporters:!0,items:"getFonts"},all:{acceptReporters:!0,items:[{text:"border color",value:"border"},{text:"text color",value:"text"},{text:"background color",value:"outer"},{text:"shadow intensity",value:"shadow"},{text:"font",value:"font"},{text:"font size",value:"sizeFont"},{text:"font thickness",value:"fontWeight"},{text:"letter spacing",value:"letterSpacing"},{text:"border radius",value:"borderRadius"},{text:"border type",value:"borderType"},{text:"background image",value:"image"},{text:"text",value:"textV"}]},formatted:{acceptReporters:!0,items:["name","modified date","size formatted","size unformatted"]},visualColors:{acceptReporters:!0,items:["border","text","background"]},visualOptions:{acceptReporters:!0,items:["font size","font thickness","letter spacing","border radius","shadow intensity"]},borderTypes:{acceptReporters:!0,items:["dotted","dashed","solid","double","groove","ridge","inset","outset","none"]}}}}getFonts(){const t=e.vm.runtime.fontManager?e.vm.runtime.fontManager.getFonts().map((e=>({text:e.name,value:e.family}))):[];return[...o,...t]}toggleVis(){u=!u,e.vm.extensionManager.refreshBlocks()}showPicker(){return f("",m)}showPickerExtensions(e){return f(e.extension,m)}showPickerAs(e){return f("",e.as)}showPickerExtensionsAs(e){return f(e.extension,e.as)}download(t){x(new Blob([e.Cast.toString(t.text)]),e.Cast.toString(t.file))}downloadURL(t){return b(e.Cast.toString(t.url),e.Cast.toString(t.file))}setOpenMode(e){l.includes(e.mode)?s=e.mode:console.warn("unknown mode",e.mode)}fileInfo(e){return"size formatted"===e.FORMAT?i:"size unformatted"===e.FORMAT?d:"modified date"===e.FORMAT?p:c}resetStyle(){t={border:"#888",text:"#000000",outer:"#ffffff",sizeFont:1.5,borderRadius:16,borderType:"dashed",font:"inherit",shadow:.5,image:"",imageScale:100,textV:"Select or drop file",fontWeight:40,letterSpacing:"normal"}}borderColors(e){switch(e.OPTION){case"text":t.text=e.COLOR;break;case"background":t.outer=e.COLOR,t.image="";break;default:t.border=e.COLOR}}visualsSelect(e){switch(e.OPTION){case"font size":t.sizeFont=e.AMT/10;break;case"font thickness":t.fontWeight=e.AMT;break;case"letter spacing":t.letterSpacing=e.AMT;break;case"border radius":t.borderRadius=e.AMT;break;case"shadow intensity":t.shadow=e.AMT/100;break;default:t.border=e.AMT}}borderTypeSet(e){t.borderType=e.TYPE}fontSet(e){t.font=e.FONT}currentX(e){if("shadow"===e.THING||"sizeFont"===e.THING){const o="shadow"===e.THING?100:10;return t[e.THING]*o}return t[e.THING]}imageSet(o){e.canFetch(encodeURI(o.IMG)).then((e=>{e?t.image=`url(${encodeURI(o.IMG)})`:console.log("Cannot fetch content from the URL.")}))}scaleImage(e){t.imageScale=e.SCALE}textSet(e){t.textV=e.TEXT}})}(Scratch);