Skip to content
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

File System Access API #1594

Draft
wants to merge 68 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
6b8cbf6
Create RockytheProtogen/FSApi.js
RockyTheProtogen Jul 7, 2024
a510e03
Made permission prompt to open file. Added close.
RockyTheProtogen Jul 8, 2024
2731111
I put the permission prompt in the wrong function, so I made a new one.
RockyTheProtogen Jul 8, 2024
9261736
Changed stuff for the last time today
RockyTheProtogen Jul 8, 2024
c545108
Code cleanup, just to keep it a little neater.
RockyTheProtogen Jul 8, 2024
dc9cacd
Revamped Stream read to implement delay and chunks
RockyTheProtogen Jul 8, 2024
4874840
Images, and fix FSApi breaking on write.
RockyTheProtogen Jul 8, 2024
2b09a46
Additional parameters for file open and labelling.
RockyTheProtogen Jul 8, 2024
1e7778f
Rename file to be more precise.
RockyTheProtogen Jul 8, 2024
541e129
Better contributions
RockyTheProtogen Jul 8, 2024
a5f946d
You can now open directories and view their contents.
RockyTheProtogen Jul 8, 2024
1952a47
Additional Changes
RockyTheProtogen Jul 9, 2024
b812909
Blank file.type is now checked and replaced with "unknown"
RockyTheProtogen Jul 9, 2024
b66ecc5
Local Validate, Lint, and Format
RockyTheProtogen Jul 9, 2024
fc53fb1
Added file slots
RockyTheProtogen Jul 9, 2024
0a54b08
Minimize null, and format
RockyTheProtogen Jul 9, 2024
1452616
Added /Folder/file.ext read
RockyTheProtogen Jul 9, 2024
035b648
Added Create/Delete File/Folder with reindexing option
RockyTheProtogen Jul 9, 2024
b717e3b
Fixed new block
RockyTheProtogen Jul 9, 2024
eb9f6a3
Note to self: Replace all breaks things
RockyTheProtogen Jul 9, 2024
f4c6b9f
Finishing up. Should be ready!
RockyTheProtogen Jul 10, 2024
cf54c4f
Remove Dev branch warning
RockyTheProtogen Jul 10, 2024
9e1069d
Code Cleanup 1
RockyTheProtogen Jul 10, 2024
2a0b019
Removed back to back if statements in place of mappings
RockyTheProtogen Jul 10, 2024
5a88e17
Validate, Lint, Format
RockyTheProtogen Jul 10, 2024
173a081
Removed lines
RockyTheProtogen Jul 10, 2024
d963309
Create NEW FSAAPI extension.
RockyTheProtogen Jul 10, 2024
61d6619
Added some quick CONST stuff
RockyTheProtogen Jul 10, 2024
bd41744
Preparing File/Folder data variables for later use
RockyTheProtogen Jul 10, 2024
8c0dbe3
Additional changes
RockyTheProtogen Jul 10, 2024
0d4c11c
Figuring out how to add Toaster-UI
RockyTheProtogen Jul 11, 2024
7becb32
Toaster spotted!?!?!
RockyTheProtogen Jul 11, 2024
0a5f1d2
Could not implement Toaster-UI.
RockyTheProtogen Jul 11, 2024
4714ad4
Note: Being tired does not help at all.
RockyTheProtogen Jul 11, 2024
72737ef
Local Format
RockyTheProtogen Jul 11, 2024
b0d3908
Push minor changes
RockyTheProtogen Jul 11, 2024
0503a20
"Good one-liners that will get you dismissed on the spot!"
RockyTheProtogen Jul 11, 2024
446bcfe
Stream read code dragged over.
RockyTheProtogen Jul 11, 2024
491a498
added 750 MB file hard limit
RockyTheProtogen Jul 11, 2024
0f20afe
I watched someone google "google", oh the pain.
RockyTheProtogen Jul 11, 2024
720bd01
"You'll live forever tonight" - ミラクルミュージカル
RockyTheProtogen Jul 11, 2024
abbafaa
Begin implementation of writing system
RockyTheProtogen Jul 11, 2024
c65eced
Added memory WRITE and PUSH
RockyTheProtogen Jul 11, 2024
bd36ff6
I configured stuff in vscode. Mostly ESLint and Prettier.
RockyTheProtogen Jul 12, 2024
f6f0fb8
added ::-da\\clear for clearing file
RockyTheProtogen Jul 12, 2024
5cf6340
Sneaky gitwatch trying to get through. Not on my watch.
RockyTheProtogen Jul 12, 2024
662dc79
Ah yes, an accidental nap
RockyTheProtogen Jul 12, 2024
b159c76
Read and write works as intended. (I think)
RockyTheProtogen Jul 12, 2024
ee3b5ca
Merge branch 'TurboWarp:master' into master
RockyTheProtogen Jul 13, 2024
2bc0413
Update for possible compliance in recent comments.
RockyTheProtogen Jul 13, 2024
ad73384
Prettier+ just made this thing slightly less readable to me
RockyTheProtogen Jul 13, 2024
4940289
Finish FILES
RockyTheProtogen Jul 13, 2024
f7b4b45
Begin work on folders
RockyTheProtogen Jul 13, 2024
cb51123
Idk
RockyTheProtogen Jul 13, 2024
ba53c79
Hmmm... yes... a commit
RockyTheProtogen Jul 14, 2024
908ec69
Run format and catch error in iGFC(iDH)
RockyTheProtogen Jul 15, 2024
1dac235
Read file stuff
RockyTheProtogen Jul 15, 2024
00f6261
Attempt 1 at squashing dumb bug
RockyTheProtogen Jul 15, 2024
5a3fef2
Fixed the bug
RockyTheProtogen Jul 15, 2024
51f1d92
Yippee
RockyTheProtogen Jul 16, 2024
8b968d6
Reuse existing code to create and delete files in folders
RockyTheProtogen Jul 18, 2024
9a8d6ce
more stuff, idk
RockyTheProtogen Jul 18, 2024
c558160
Whats grass?
RockyTheProtogen Jul 21, 2024
0355b0d
Merge branch 'TurboWarp:master' into master
RockyTheProtogen Aug 29, 2024
e3681de
Merge branch 'TurboWarp:master' into master
RockyTheProtogen Sep 15, 2024
b70b723
Start rewrite 3! Can't wait for 4 (jk last rewrite)
acemmerson Sep 15, 2024
aaf3b78
Yippee
acemmerson Sep 15, 2024
b61bd4a
Rewrite 3 Update 1
acemmerson Sep 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
(function (Scratch) {
"use strict";

if (!Scratch.extensions.unsandboxed) {
throw new Error("File System Access API must run unsandboxed");
}

class rtpfsaapi {
getInfo() {
return {
id: "rtpfsaapi",
name: "File System Access API",
blocks: [
{
opcode: "filepicker",
blockType: "reporter",
text: "window.showOpenFilePicker([json])",
arguments: {
json: {
type: "string",
},
},
},
{
opcode: "filesavepicker",
blockType: "reporter",
text: "window.showSaveFilePicker([json])",
arguments: {
json: {
type: "string",
},
},
},
{
opcode: "folderpicker",
blockType: "reporter",
text: "window.showDirectoryPicker([json])",
arguments: {
json: {
type: "string",
},
},
},
{
opcode: "getFile",
blockType: "reporter",
text: "[handle].getFile()",
arguments: {
handle: {
acceptReporters: true,
},
},
},
{
opcode: "text",
blockType: "reporter",
text: "[handle].text()",
arguments: {
handle: {
acceptReporters: true,
},
},
},
{
opcode: "arrayBuffer",
blockType: "reporter",
text: "[handle].arrayBuffer()",
arguments: {
handle: {
acceptReporters: true,
},
},
},
{
opcode: "arrayFromArrayBuffer",
blockType: "reporter",
text: "new Uint8Array([arrayBuffer])",
arguments: {
handle: {
acceptReporters: true,
},
},
},
],
};
}
filepicker(args) {
try {
return window.showOpenFilePicker(JSON.parse(args.json));
} catch (err) {
return err;
}
}
filesavepicker(args) {
try {
return window.showSaveFilePicker(JSON.parse(args.json));
} catch (err) {
return err;
}
}
folderpicker(args) {
try {
return window.showDirectoryPicker(JSON.parse(args.json));
} catch (err) {
return err;
}
}
getFile(args) {
try {
let handle;
[handle] = args.handle;
return handle.getFile();
} catch (err) {
return err;
}
}
slice(args) {
try {
let handle;
const parameters = args.start.split(",");
console.log(parameters);
handle = args.handle;
return handle.slice(parameters[0], parameters[1]);
} catch (err) {
return err;
}
}
text(args) {
try {
let handle;
handle = args.handle;
return handle.text();
} catch (err) {
return err;
}
}
arrayBuffer(args) {
try {
let handle;
handle = args.handle;
return handle.arrayBuffer();
} catch (err) {
return err;
}
}
arrayFromArrayBuffer(args) {
return new Uint8Array(args.arrayBuffer);
}
async arrayFromBlob(args) {
return await new Response(args.blob).arrayBuffer();
}
}
Scratch.extensions.register(new rtpfsaapi());
})(Scratch);
Binary file added images/RockytheProtogen/FSA-API-TW-V2B.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.