Skip to content

Commit

Permalink
Yippee
Browse files Browse the repository at this point in the history
  • Loading branch information
acemmerson committed Sep 15, 2024
1 parent b70b723 commit aaf3b78
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
(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]\)',

Check failure on line 15 in extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js

View workflow job for this annotation

GitHub Actions / lint

Unnecessary escape character: \(

Check failure on line 15 in extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js

View workflow job for this annotation

GitHub Actions / lint

Unnecessary escape character: \)
arguments: {
json: {
type: 'string'
}
}
},
{
opcode: 'filesavepicker',
blockType: 'reporter',
text: 'window.showSaveFilePicker\([json]\)',

Check failure on line 25 in extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js

View workflow job for this annotation

GitHub Actions / lint

Unnecessary escape character: \(

Check failure on line 25 in extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js

View workflow job for this annotation

GitHub Actions / lint

Unnecessary escape character: \)
arguments: {
json: {
type: 'string'
}
}
},
{
opcode: 'folderpicker',
blockType: 'reporter',
text: 'window.showDirectoryPicker\([json]\)',

Check failure on line 35 in extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js

View workflow job for this annotation

GitHub Actions / lint

Unnecessary escape character: \(

Check failure on line 35 in extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js

View workflow job for this annotation

GitHub Actions / lint

Unnecessary escape character: \)
arguments: {
json: {
type: 'string'
}
}
},
{
opcode: 'getFile',
blockType: 'reporter',
text: '[handle]\.getFile\(\)',

Check failure on line 45 in extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js

View workflow job for this annotation

GitHub Actions / lint

Unnecessary escape character: \.

Check failure on line 45 in extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js

View workflow job for this annotation

GitHub Actions / lint

Unnecessary escape character: \(

Check failure on line 45 in extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js

View workflow job for this annotation

GitHub Actions / lint

Unnecessary escape character: \)
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;
}
}
}
Scratch.extensions.register(new rtpfsaapi());
})(Scratch);

0 comments on commit aaf3b78

Please sign in to comment.