Spaces:
Runtime error
Runtime error
Update src/lib/tw-filesystem-api.js
Browse files- src/lib/tw-filesystem-api.js +36 -22
src/lib/tw-filesystem-api.js
CHANGED
@@ -1,35 +1,48 @@
|
|
|
|
|
|
1 |
const available = () => !!window.showSaveFilePicker;
|
2 |
|
|
|
3 |
const showSaveFilePicker = fileName => window.showSaveFilePicker({
|
4 |
suggestedName: fileName,
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
10 |
}
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
});
|
15 |
|
16 |
const showOpenFilePicker = async () => {
|
17 |
const [handle] = await window.showOpenFilePicker({
|
18 |
multiple: false,
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
-
|
32 |
-
|
33 |
});
|
34 |
return handle;
|
35 |
};
|
@@ -42,9 +55,10 @@ const showDirectoryPicker = async (optId, optStartIn) => {
|
|
42 |
});
|
43 |
return handle;
|
44 |
};
|
|
|
45 |
export default {
|
46 |
available,
|
47 |
showOpenFilePicker,
|
48 |
showSaveFilePicker,
|
49 |
showDirectoryPicker
|
50 |
-
};
|
|
|
1 |
+
import { isMobile } from './pm-mobile';
|
2 |
+
|
3 |
const available = () => !!window.showSaveFilePicker;
|
4 |
|
5 |
+
// pm: Some bad mobile devices block any file type (iOS), so these funcs should allow all files on mobile
|
6 |
const showSaveFilePicker = fileName => window.showSaveFilePicker({
|
7 |
suggestedName: fileName,
|
8 |
+
...(isMobile() ? {} : {
|
9 |
+
types: [
|
10 |
+
{
|
11 |
+
description: 'PenguinMod Project',
|
12 |
+
accept: {
|
13 |
+
'application/x.scratch.sb3': '.s4s.txt'
|
14 |
+
}
|
15 |
}
|
16 |
+
],
|
17 |
+
excludeAcceptAllOption: true
|
18 |
+
}),
|
19 |
});
|
20 |
|
21 |
const showOpenFilePicker = async () => {
|
22 |
const [handle] = await window.showOpenFilePicker({
|
23 |
multiple: false,
|
24 |
+
...(isMobile() ? {} : {
|
25 |
+
types: [
|
26 |
+
{
|
27 |
+
description: 'Supported Files',
|
28 |
+
accept: {
|
29 |
+
'application/x.scratch.sb3': ['.s4s.txt', '.pmp', '.pm', '.zip', '.tar.gz', '.sb3', '.sb2', '.sb']
|
30 |
+
}
|
31 |
+
},
|
32 |
+
{
|
33 |
+
description: 'PenguinMod Project',
|
34 |
+
accept: {
|
35 |
+
'application/x.scratch.sb3': ['.s4s.txt', '.pmp', '.pm']
|
36 |
+
}
|
37 |
+
},
|
38 |
+
{
|
39 |
+
description: 'Scratch Project',
|
40 |
+
accept: {
|
41 |
+
'application/x.scratch.sb3': ['.sb3', '.sb2', '.sb']
|
42 |
+
}
|
43 |
}
|
44 |
+
]
|
45 |
+
}),
|
46 |
});
|
47 |
return handle;
|
48 |
};
|
|
|
55 |
});
|
56 |
return handle;
|
57 |
};
|
58 |
+
|
59 |
export default {
|
60 |
available,
|
61 |
showOpenFilePicker,
|
62 |
showSaveFilePicker,
|
63 |
showDirectoryPicker
|
64 |
+
};
|