-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b70b723
commit aaf3b78
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / lint
|
||
arguments: { | ||
json: { | ||
type: 'string' | ||
} | ||
} | ||
}, | ||
{ | ||
opcode: 'filesavepicker', | ||
blockType: 'reporter', | ||
text: 'window.showSaveFilePicker\([json]\)', | ||
Check failure on line 25 in extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js GitHub Actions / lint
|
||
arguments: { | ||
json: { | ||
type: 'string' | ||
} | ||
} | ||
}, | ||
{ | ||
opcode: 'folderpicker', | ||
blockType: 'reporter', | ||
text: 'window.showDirectoryPicker\([json]\)', | ||
Check failure on line 35 in extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js GitHub Actions / lint
|
||
arguments: { | ||
json: { | ||
type: 'string' | ||
} | ||
} | ||
}, | ||
{ | ||
opcode: 'getFile', | ||
blockType: 'reporter', | ||
text: '[handle]\.getFile\(\)', | ||
Check failure on line 45 in extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js GitHub Actions / lint
Check failure on line 45 in extensions/RockytheProtogen/FileSystemAccessAPI/fsa-api.js GitHub Actions / lint
|
||
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); |