Skip to content

files.js -- Update with code from Files Expanded #1833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

SharkPool-SP
Copy link
Collaborator

@SharkPool-SP SharkPool-SP commented Jan 2, 2025

Super Mega Update to the Files Extension to port over many new features from my expansion of the extension.
This includes:

  • getting file meta data
  • new encoding types
  • modal selector customization
  • basic usage of the File API (write to files, open folders, delete selected files, etc)

Closes:
#1603
#156
#837

Files Expanded:
https://github.com/SharkPool-SP/SharkPools-Extensions/blob/main/extension-code/Files-Expanded.js

@SharkPool-SP SharkPool-SP changed the title files -- Update with code from Files Expanded files.js -- Update with code from Files Expanded Jan 2, 2025
@CubesterYT
Copy link
Member

!format

@SharkPool-SP SharkPool-SP added the pr: new extension Pull requests that add a new extension label Jan 4, 2025
@yuri-kiss
Copy link
Member

Related PR: #1594
Related API suggestion: #1594 (comment) (on the PR comments)

@CubesterYT CubesterYT added pr: change existing extension Pull requests that change an existing extension and removed pr: new extension Pull requests that add a new extension labels Jan 4, 2025
@SharkPool-SP
Copy link
Collaborator Author

Related PR: #1594 Related API suggestion: #1594 (comment) (on the PR comments)

TurboWarp/scratch-gui#979

@RockyTheProtogen
Copy link

Ah, someone that actually knows what they are doing. I'm just going to close mine, since this does everything that mine would do (and better).
Plus, I've lost interest in developing mine so it is better off.

@yuri-kiss yuri-kiss closed this Feb 27, 2025
@yuri-kiss yuri-kiss deleted the SharkPool-SP-patch-1 branch February 27, 2025 13:56
@yuri-kiss
Copy link
Member

Renamed the branch, reopen the PR from sp-files-update

@GarboMuffin GarboMuffin restored the SharkPool-SP-patch-1 branch February 27, 2025 14:53
@GarboMuffin GarboMuffin reopened this Feb 27, 2025
@WAYLIVES
Copy link

WAYLIVES commented Mar 2, 2025

!format

@SharkPool-SP
Copy link
Collaborator Author

!format

Copy link
Member

@yuri-kiss yuri-kiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more indepth review is indeed required.

fileDate = "",
lastData = "";
let openModals = 0;
let selectorOptions = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason you cant just make this a constant

if (override === "folder") {
fileInfo = await window.showDirectoryPicker({
multiple: false,
types: [{ accept: { "*/*": [] } }],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason you cant accept other types

* @param {Uint8Array} buffer
* @returns {string} base64
*/
function bufferToBase64(buffer) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems wasteful and copied from stackoverflow, is there a reason you cant use the globally exposed Base64 module

const picker = await showFilePrompt("Folder", "", "folder");
if (!picker) return;

const createExtFile = async (folderN, data) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason these have to be inlined instead of just functions on the class itself

@@ -444,7 +1117,242 @@
console.warn(`unknown mode`, args.mode);
}
}

fileInfo(args) {
if (args.FORMAT === "size formatted") return FileSize;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking again you dont cast anything in your new changes, that should be fixed

selectorOptions.image = `url(${encodeURI(args.IMG)})`;
updateModalVisuals();
} else {
console.warn("Cannot fetch content from the URL.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no reason to console.warn but okay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: change existing extension Pull requests that change an existing extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants