soiz1 commited on
Commit
ed1b66f
·
verified ·
1 Parent(s): 255c6cc

Update src/lib/tw-filesystem-api.js

Browse files
Files changed (1) hide show
  1. 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
- types: [
6
- {
7
- description: 'Scratch for School Project',
8
- accept: {
9
- 'application/x.scratch.sb3': '.s4s.txt'
 
 
10
  }
11
- }
12
- ],
13
- excludeAcceptAllOption: true
14
  });
15
 
16
  const showOpenFilePicker = async () => {
17
  const [handle] = await window.showOpenFilePicker({
18
  multiple: false,
19
- types: [
20
- {
21
- description: 'PenguinMod Project',
22
- accept: {
23
- 'application/x.scratch.sb3': ['.pmp', '.pm', '.s4s.txt']
24
- }
25
- },
26
- {
27
- description: 'Scratch Project',
28
- accept: {
29
- 'application/x.scratch.sb3': ['.sb3', '.sb2', '.sb', '.s4s.txt']
 
 
 
 
 
 
 
 
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
+ };