@nativescript-community/ui-document-picker 1.1.12 → 1.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -56
- package/README.md +72 -12
- package/index.android.d.ts +2 -1
- package/index.android.js +85 -12
- package/index.android.js.map +1 -1
- package/index.common.d.ts +7 -0
- package/index.d.ts +2 -1
- package/index.ios.d.ts +2 -1
- package/index.ios.js +60 -19
- package/index.ios.js.map +1 -1
- package/package.json +3 -3
- package/references.d.ts +2 -0
package/CHANGELOG.md
CHANGED
@@ -3,132 +3,81 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
-
## [1.1.
|
6
|
+
## [1.1.14](https://github.com/nativescript-community/ui-document-picker/compare/v1.1.13...v1.1.14) (2023-12-15)
|
7
7
|
|
8
8
|
**Note:** Version bump only for package @nativescript-community/ui-document-picker
|
9
9
|
|
10
|
+
## [1.1.13](https://github.com/nativescript-community/ui-document-picker/compare/v1.1.12...v1.1.13) (2023-10-24)
|
10
11
|
|
12
|
+
**Note:** Version bump only for package @nativescript-community/ui-document-picker
|
11
13
|
|
14
|
+
## [1.1.12](https://github.com/nativescript-community/ui-document-picker/compare/v1.1.11...v1.1.12) (2022-02-18)
|
12
15
|
|
16
|
+
**Note:** Version bump only for package @nativescript-community/ui-document-picker
|
13
17
|
|
14
18
|
## [1.1.11](https://github.com/nativescript-community/ui-document-picker/compare/v1.1.10...v1.1.11) (2022-02-16)
|
15
19
|
|
16
|
-
|
17
20
|
### Bug Fixes
|
18
21
|
|
19
22
|
* missing dependency ([203fb9e](https://github.com/nativescript-community/ui-document-picker/commit/203fb9e46c7f6c526ff67c50ff8f60d842bd097e))
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
24
|
## [1.1.10](https://github.com/nativescript-community/ui-document-picker/compare/v1.1.9...v1.1.10) (2022-02-16)
|
26
25
|
|
27
|
-
|
28
26
|
### Bug Fixes
|
29
27
|
|
30
28
|
* **android:** removed unused dependency ([448d753](https://github.com/nativescript-community/ui-document-picker/commit/448d75379ce7c25d6faba64b2a4a320b4f5e058c))
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
30
|
## [1.1.9](https://github.com/nativescript-community/ui-document-picker/compare/v1.1.8...v1.1.9) (2022-01-29)
|
37
31
|
|
38
|
-
|
39
32
|
### Bug Fixes
|
40
33
|
|
41
34
|
* **android:** fixed path on some devices ([97881c8](https://github.com/nativescript-community/ui-document-picker/commit/97881c808dee5fb4f78339e2562482554dbe3bc4))
|
42
35
|
* **android:** remove `MANAGE_EXTERNAL_STORAGE` as it prevents app release ([564a5b3](https://github.com/nativescript-community/ui-document-picker/commit/564a5b3706c9bdd2ba9be963e77b7f03bd5f6eb4))
|
43
36
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
37
|
## [1.1.8](https://github.com/nativescript-community/ui-document-picker/compare/v13.0.32...v1.1.8) (2021-12-03)
|
49
38
|
|
50
|
-
|
51
39
|
### Bug Fixes
|
52
40
|
|
53
41
|
* package version ([9e52a0d](https://github.com/nativescript-community/ui-document-picker/commit/9e52a0ddec67b47a369efbf422731388681e2965))
|
54
42
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
43
|
## [13.0.32](https://github.com/nativescript-community/ui-document-picker/compare/v1.1.7...v13.0.32) (2021-12-03)
|
60
44
|
|
61
45
|
**Note:** Version bump only for package @nativescript-community/ui-document-picker
|
62
46
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
47
|
## [1.1.7](https://github.com/nativescript-community/ui-document-picker/compare/v1.1.6...v1.1.7) (2021-08-25)
|
68
48
|
|
69
49
|
**Note:** Version bump only for package @nativescript-community/ui-document-picker
|
70
50
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
51
|
## [1.1.6](https://github.com/nativescript-community/ui-document-picker/compare/v1.1.5...v1.1.6) (2021-06-28)
|
76
52
|
|
77
|
-
|
78
53
|
### Reverts
|
79
54
|
|
80
55
|
* Revert "v1.1.6" ([ef0be58](https://github.com/nativescript-community/ui-document-picker/commit/ef0be58589aa75a6be4a85b2837b6f968c341b08))
|
81
56
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
57
|
## [1.1.5](https://github.com/nativescript-community/ui-document-picker/compare/v1.1.4...v1.1.5) (2021-05-19)
|
87
58
|
|
88
59
|
**Note:** Version bump only for package @nativescript-community/ui-document-picker
|
89
60
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
61
|
## [1.1.4](https://github.com/nativescript-community/ui-document-picker/compare/v1.1.3...v1.1.4) (2021-05-04)
|
95
62
|
|
96
63
|
**Note:** Version bump only for package @nativescript-community/ui-document-picker
|
97
64
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
65
|
## [1.1.3](https://github.com/nativescript-community/ui-document-picker/compare/v1.1.2...v1.1.3) (2020-11-02)
|
103
66
|
|
104
67
|
**Note:** Version bump only for package @nativescript-community/ui-document-picker
|
105
68
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
69
|
## [1.1.2](https://github.com/nativescript-community/ui-document-picker/compare/v1.1.1...v1.1.2) (2020-10-13)
|
111
70
|
|
112
71
|
**Note:** Version bump only for package @nativescript-community/ui-document-picker
|
113
72
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
73
|
## [1.1.1](https://github.com/nativescript-community/ui-document-picker/compare/v1.1.0...v1.1.1) (2020-09-17)
|
119
74
|
|
120
|
-
|
121
75
|
### Bug Fixes
|
122
76
|
|
123
77
|
* **android:** build fix ([6d6495f](https://github.com/nativescript-community/ui-document-picker/commit/6d6495f8cbbd81f55773d74aae0fa0da0480dc21))
|
124
78
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
79
|
# 1.1.0 (2020-09-06)
|
130
80
|
|
131
|
-
|
132
81
|
### Features
|
133
82
|
|
134
83
|
* N7 and new plugin name ([1b9c4ab](https://github.com/nativescript-community/ui-document-picker/commit/1b9c4abf4eb1c64c8cee565f7a4ae08319718e3a))
|
package/README.md
CHANGED
@@ -43,9 +43,15 @@
|
|
43
43
|
* [Vue](#vue)
|
44
44
|
* [Examples](#examples)
|
45
45
|
* [Demos and Development](#demos-and-development)
|
46
|
-
* [Setup](#setup)
|
46
|
+
* [Repo Setup](#repo-setup)
|
47
47
|
* [Build](#build)
|
48
48
|
* [Demos](#demos)
|
49
|
+
* [Contributing](#contributing)
|
50
|
+
* [Update repo ](#update-repo-)
|
51
|
+
* [Update readme ](#update-readme-)
|
52
|
+
* [Update doc ](#update-doc-)
|
53
|
+
* [Publish](#publish)
|
54
|
+
* [modifying submodules](#modifying-submodules)
|
49
55
|
* [Questions](#questions)
|
50
56
|
|
51
57
|
|
@@ -93,18 +99,18 @@ export function openFilePicker(params: FilePickerOptions): Promise<{ files: stri
|
|
93
99
|
## Demos and Development
|
94
100
|
|
95
101
|
|
96
|
-
### Setup
|
97
|
-
|
98
|
-
To run the demos, you must clone this repo **recursively**.
|
102
|
+
### Repo Setup
|
99
103
|
|
104
|
+
The repo uses submodules. If you did not clone with ` --recursive` then you need to call
|
100
105
|
```
|
101
|
-
git
|
106
|
+
git submodule update --init
|
102
107
|
```
|
103
108
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
109
|
+
The package manager used to install and link dependencies must be `pnpm` or `yarn`. `npm` wont work.
|
110
|
+
|
111
|
+
To develop and test:
|
112
|
+
if you use `yarn` then run `yarn`
|
113
|
+
if you use `pnpm` then run `pnpm i`
|
108
114
|
|
109
115
|
**Interactive Menu:**
|
110
116
|
|
@@ -113,10 +119,9 @@ To start the interactive menu, run `npm start` (or `yarn start` or `pnpm start`)
|
|
113
119
|
### Build
|
114
120
|
|
115
121
|
```bash
|
116
|
-
npm run build
|
117
|
-
|
118
|
-
npm run build.angular # or for Angular
|
122
|
+
npm run build.all
|
119
123
|
```
|
124
|
+
WARNING: it seems `yarn build.all` wont always work (not finding binaries in `node_modules/.bin`) which is why the doc explicitly uses `npm run`
|
120
125
|
|
121
126
|
### Demos
|
122
127
|
|
@@ -125,6 +130,61 @@ npm run demo.[ng|react|svelte|vue].[ios|android]
|
|
125
130
|
|
126
131
|
npm run demo.svelte.ios # Example
|
127
132
|
```
|
133
|
+
|
134
|
+
Demo setup is a bit special in the sense that if you want to modify/add demos you dont work directly in `demo-[ng|react|svelte|vue]`
|
135
|
+
Instead you work in `demo-snippets/[ng|react|svelte|vue]`
|
136
|
+
You can start from the `install.ts` of each flavor to see how to register new demos
|
137
|
+
|
138
|
+
|
139
|
+
[](#contributing)
|
140
|
+
|
141
|
+
## Contributing
|
142
|
+
|
143
|
+
### Update repo
|
144
|
+
|
145
|
+
You can update the repo files quite easily
|
146
|
+
|
147
|
+
First update the submodules
|
148
|
+
|
149
|
+
```bash
|
150
|
+
npm run update
|
151
|
+
```
|
152
|
+
|
153
|
+
Then commit the changes
|
154
|
+
Then update common files
|
155
|
+
|
156
|
+
```bash
|
157
|
+
npm run sync
|
158
|
+
```
|
159
|
+
Then you can run `yarn|pnpm`, commit changed files if any
|
160
|
+
|
161
|
+
### Update readme
|
162
|
+
```bash
|
163
|
+
npm run readme
|
164
|
+
```
|
165
|
+
|
166
|
+
### Update doc
|
167
|
+
```bash
|
168
|
+
npm run doc
|
169
|
+
```
|
170
|
+
|
171
|
+
### Publish
|
172
|
+
|
173
|
+
The publishing is completely handled by `lerna` (you can add `-- --bump major` to force a major release)
|
174
|
+
Simply run
|
175
|
+
```shell
|
176
|
+
npm run publish
|
177
|
+
```
|
178
|
+
|
179
|
+
### modifying submodules
|
180
|
+
|
181
|
+
The repo uses https:// for submodules which means you won't be able to push directly into the submodules.
|
182
|
+
One easy solution is t modify `~/.gitconfig` and add
|
183
|
+
```
|
184
|
+
[url "ssh://git@github.com/"]
|
185
|
+
pushInsteadOf = https://github.com/
|
186
|
+
```
|
187
|
+
|
128
188
|
|
129
189
|
[](#questions)
|
130
190
|
|
package/index.android.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { FilePickerOptions, FolderPickerOptions } from './index.common';
|
1
|
+
import { FilePickerOptions, FolderPickerOptions, SaveFileOptions } from './index.common';
|
2
2
|
export { FilePickerOptions };
|
3
3
|
export declare function openFilePicker(params?: FilePickerOptions): Promise<{
|
4
4
|
files: string[];
|
@@ -20,3 +20,4 @@ export declare function pickFolder(params?: FolderPickerOptions): Promise<{
|
|
20
20
|
folders: any[];
|
21
21
|
android?: undefined;
|
22
22
|
}>;
|
23
|
+
export declare function saveFile(params: SaveFileOptions): Promise<boolean>;
|
package/index.android.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { request } from '@nativescript-community/perms';
|
2
|
-
import {
|
3
|
-
import { AndroidApplication, Device } from '@nativescript/core';
|
2
|
+
import { AndroidApplication, Application, Device, File, Utils, knownFolders } from '@nativescript/core';
|
4
3
|
import lazy from '@nativescript/core/utils/lazy';
|
5
4
|
let Intent;
|
6
5
|
let FilePath;
|
@@ -11,13 +10,16 @@ async function callIntent(context, intent, pickerType) {
|
|
11
10
|
const onEvent = function (e) {
|
12
11
|
if (e.requestCode === pickerType) {
|
13
12
|
resolve(e);
|
14
|
-
|
13
|
+
Application.android.off(AndroidApplication.activityResultEvent, onEvent);
|
15
14
|
}
|
16
15
|
};
|
17
|
-
|
16
|
+
Application.android.once(AndroidApplication.activityResultEvent, onEvent);
|
18
17
|
context.startActivityForResult(intent, pickerType);
|
19
18
|
});
|
20
19
|
}
|
20
|
+
/**
|
21
|
+
* Convert to android Array
|
22
|
+
*/
|
21
23
|
function convertToArray(types) {
|
22
24
|
let mimeTypes;
|
23
25
|
if (types && types.length > 0) {
|
@@ -52,8 +54,7 @@ function prepareIntent(intent, options) {
|
|
52
54
|
}
|
53
55
|
}
|
54
56
|
export function openFilePicker(params = {}) {
|
55
|
-
|
56
|
-
const context = androidApp.foregroundActivity || androidApp.startActivity;
|
57
|
+
const context = Application.android.startActivity;
|
57
58
|
const FILE_CODE = 1231;
|
58
59
|
if (!Intent) {
|
59
60
|
Intent = android.content.Intent;
|
@@ -62,15 +63,20 @@ export function openFilePicker(params = {}) {
|
|
62
63
|
FilePath = com.nativescript.documentpicker.FilePath;
|
63
64
|
}
|
64
65
|
const intent = new Intent(Intent.ACTION_GET_CONTENT);
|
66
|
+
// Convert extensions to mime type
|
65
67
|
let mimeTypes;
|
66
68
|
if (params.extensions) {
|
67
69
|
const singleton = android.webkit.MimeTypeMap.getSingleton();
|
68
|
-
mimeTypes =
|
70
|
+
mimeTypes = params.extensions?.map((s) => singleton.getMimeTypeFromExtension(s.replace('.', ''))).filter((s) => !!s);
|
69
71
|
}
|
70
|
-
if (mimeTypes
|
72
|
+
if (params.mimeTypes) {
|
73
|
+
mimeTypes = mimeTypes || [];
|
74
|
+
mimeTypes.push(...params.mimeTypes);
|
75
|
+
}
|
76
|
+
if (mimeTypes?.length) {
|
71
77
|
intent.setType(mimeTypes[0]);
|
72
78
|
if (mimeTypes.length > 1) {
|
73
|
-
intent.putExtra(Intent.EXTRA_MIME_TYPES, convertToArray(mimeTypes
|
79
|
+
intent.putExtra(Intent.EXTRA_MIME_TYPES, convertToArray(mimeTypes));
|
74
80
|
}
|
75
81
|
}
|
76
82
|
else {
|
@@ -81,6 +87,10 @@ export function openFilePicker(params = {}) {
|
|
81
87
|
prepareIntent(intent, params);
|
82
88
|
return callIntent(context, intent, FILE_CODE).then((result) => {
|
83
89
|
if (result.resultCode === android.app.Activity.RESULT_OK) {
|
90
|
+
// The document selected by the user won't be returned in the intent.
|
91
|
+
// Instead, a URI to that document will be contained in the return intent
|
92
|
+
// provided to this method as a parameter.
|
93
|
+
// Pull that URI using resultData.getData().
|
84
94
|
if (result.intent != null) {
|
85
95
|
const uri = result.intent.getData();
|
86
96
|
if (uri) {
|
@@ -126,12 +136,21 @@ export function openFilePicker(params = {}) {
|
|
126
136
|
}
|
127
137
|
function updatePersistableUris(context, uri) {
|
128
138
|
const contentResolver = context.getContentResolver();
|
139
|
+
// contentResolver.getPersistedUriPermissions()
|
140
|
+
// .filter { it.isReadPermission }
|
141
|
+
// .filter { it.uri != uri }
|
142
|
+
// .forEach {
|
143
|
+
// contentResolver.releasePersistableUriPermission(
|
144
|
+
// it.uri,
|
145
|
+
// Intent.FLAG_GRANT_READ_URI_PERMISSION
|
146
|
+
// )
|
147
|
+
// }
|
129
148
|
if (contentResolver.takePersistableUriPermission) {
|
130
149
|
contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
131
150
|
}
|
132
151
|
}
|
133
152
|
export function pickFolder(params = {}) {
|
134
|
-
const context =
|
153
|
+
const context = Application.android.startActivity;
|
135
154
|
const FOLDER_CODE = 1232;
|
136
155
|
if (!Intent) {
|
137
156
|
Intent = android.content.Intent;
|
@@ -139,12 +158,15 @@ export function pickFolder(params = {}) {
|
|
139
158
|
const intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
140
159
|
prepareIntent(intent, params);
|
141
160
|
return callIntent(context, intent, FOLDER_CODE).then((result) => {
|
142
|
-
var _a;
|
143
161
|
if (result.resultCode === android.app.Activity.RESULT_OK) {
|
162
|
+
// The document selected by the user won't be returned in the intent.
|
163
|
+
// Instead, a URI to that document will be contained in the return intent
|
164
|
+
// provided to this method as a parameter.
|
165
|
+
// Pull that URI using resultData.getData().
|
144
166
|
if (result.intent != null) {
|
145
167
|
const uri = result.intent.getData();
|
146
168
|
if (uri) {
|
147
|
-
if (
|
169
|
+
if (params.permissions?.persistable) {
|
148
170
|
updatePersistableUris(context, uri);
|
149
171
|
}
|
150
172
|
return {
|
@@ -187,4 +209,55 @@ export function pickFolder(params = {}) {
|
|
187
209
|
}
|
188
210
|
});
|
189
211
|
}
|
212
|
+
export async function saveFile(params) {
|
213
|
+
// const tempFile = knownFolders.temp().getFile(params.name);
|
214
|
+
// if (typeof params.data === 'string') {
|
215
|
+
// await tempFile.writeText(params.data);
|
216
|
+
// } else {
|
217
|
+
// await tempFile.write(params.data);
|
218
|
+
// }
|
219
|
+
const context = Application.android.startActivity;
|
220
|
+
const FILE_CODE = 1233;
|
221
|
+
if (!Intent) {
|
222
|
+
Intent = android.content.Intent;
|
223
|
+
}
|
224
|
+
if (!FilePath) {
|
225
|
+
FilePath = com.nativescript.documentpicker.FilePath;
|
226
|
+
}
|
227
|
+
const intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
228
|
+
intent.putExtra(Intent.EXTRA_TITLE, params.name);
|
229
|
+
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
230
|
+
if (params.mimeType) {
|
231
|
+
intent.setType(params.mimeType);
|
232
|
+
}
|
233
|
+
else {
|
234
|
+
intent.setType('*/*');
|
235
|
+
}
|
236
|
+
prepareIntent(intent, params);
|
237
|
+
return callIntent(context, intent, FILE_CODE).then((result) => {
|
238
|
+
if (result.resultCode === android.app.Activity.RESULT_OK) {
|
239
|
+
if (result.intent != null) {
|
240
|
+
const uri = result.intent.getData();
|
241
|
+
const filePath = sdkVersion() >= 30 ? uri.toString() : FilePath.getPath(context, uri);
|
242
|
+
console.log('uri', filePath, params.data);
|
243
|
+
if (typeof params.data === 'string') {
|
244
|
+
return File.fromPath(filePath)
|
245
|
+
.writeText(params.data)
|
246
|
+
.then(() => true);
|
247
|
+
// await tempFile.writeText(params.data);
|
248
|
+
}
|
249
|
+
else {
|
250
|
+
return File.fromPath(filePath)
|
251
|
+
.write(params.data)
|
252
|
+
.then(() => true);
|
253
|
+
// await tempFile.write(params.data);
|
254
|
+
}
|
255
|
+
}
|
256
|
+
return false;
|
257
|
+
}
|
258
|
+
else {
|
259
|
+
return false;
|
260
|
+
}
|
261
|
+
});
|
262
|
+
}
|
190
263
|
//# sourceMappingURL=index.android.js.map
|
package/index.android.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.android.js","sourceRoot":"../src/","sources":["index.android.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,
|
1
|
+
{"version":3,"file":"index.android.js","sourceRoot":"../src/","sources":["index.android.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAEH,kBAAkB,EAClB,WAAW,EACX,MAAM,EACN,IAAI,EACJ,KAAK,EACL,YAAY,EACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,IAAI,MAAM,+BAA+B,CAAC;AAIjD,IAAI,MAAqC,CAAC;AAC1C,IAAI,QAAyD,CAAC;AAE9D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;AAE/D,KAAK,UAAU,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU;IACjD,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;IACzB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAoD,EAAE,MAAM,EAAE,EAAE;QAChF,MAAM,OAAO,GAAG,UAAU,CAAiC;YACvD,IAAI,CAAC,CAAC,WAAW,KAAK,UAAU,EAAE;gBAC9B,OAAO,CAAC,CAAC,CAAC,CAAC;gBACX,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;aAC5E;QACL,CAAC,CAAC;QACF,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;QAC1E,OAAO,CAAC,sBAAsB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CAAC,KAAK;IACzB,IAAI,SAAmB,CAAC;IACxB,IAAI,KAA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,CAAC,UAAU,KAAK,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE;YACtD,IAAI,MAAM,CAAC,MAAM,IAAI,IAAI,EAAE;gBACvB,MAAM,GAAG,GAAqB,MAAM,CAAC,MAAiC,CAAC,OAAO,EAAE,CAAC;gBACjF,MAAM,QAAQ,GAAG,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;gBACtF,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;gBAC1C,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE;oBACjC,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;yBACzB,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;yBACtB,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;oBACtB,yCAAyC;iBAC5C;qBAAM;oBACH,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;yBACzB,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;yBAClB,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;oBACtB,qCAAqC;iBACxC;aACJ;YACD,OAAO,KAAK,CAAC;SAChB;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/index.common.d.ts
CHANGED
@@ -10,7 +10,14 @@ export interface CommonPickerOptions {
|
|
10
10
|
}
|
11
11
|
export interface FilePickerOptions extends CommonPickerOptions {
|
12
12
|
extensions?: string[];
|
13
|
+
mimeTypes?: string[];
|
14
|
+
documentTypes?: string[];
|
13
15
|
pickerMode?: number;
|
14
16
|
}
|
15
17
|
export interface FolderPickerOptions extends CommonPickerOptions {
|
16
18
|
}
|
19
|
+
export interface SaveFileOptions extends Pick<CommonPickerOptions, 'permissions'> {
|
20
|
+
name: string;
|
21
|
+
data: any;
|
22
|
+
mimeType?: string;
|
23
|
+
}
|
package/index.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
import { FilePickerOptions, FolderPickerOptions } from './index.common';
|
1
|
+
import { FilePickerOptions, FolderPickerOptions, SaveFileOptions } from './index.common';
|
2
2
|
|
3
3
|
export { FilePickerOptions, FolderPickerOptions };
|
4
4
|
export function openFilePicker(params?: FilePickerOptions): Promise<{ files: string[]; ios?; android? }>;
|
5
5
|
export function pickFolder(params?: FolderPickerOptions): Promise<{ folders: string[]; ios?; android? }>;
|
6
|
+
export function saveFile(params: SaveFileOptions): Promise<boolean>;
|
package/index.ios.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
import { FolderPickerOptions } from '.';
|
2
|
-
import { FilePickerOptions } from './index.common';
|
2
|
+
import { FilePickerOptions, SaveFileOptions } from './index.common';
|
3
3
|
export { FilePickerOptions };
|
4
4
|
export declare function openFilePicker(params?: FilePickerOptions): Promise<unknown>;
|
5
5
|
export declare function pickFolder(params?: FolderPickerOptions): Promise<{
|
6
6
|
folders: any[];
|
7
7
|
}>;
|
8
|
+
export declare function saveFile(params: SaveFileOptions): Promise<unknown>;
|
package/index.ios.js
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
import { Utils } from '@nativescript/core';
|
1
|
+
import { Utils, knownFolders } from '@nativescript/core';
|
2
2
|
var DocumentPickerDelegate = /** @class */ (function (_super) {
|
3
3
|
__extends(DocumentPickerDelegate, _super);
|
4
4
|
function DocumentPickerDelegate() {
|
5
5
|
return _super !== null && _super.apply(this, arguments) || this;
|
6
6
|
}
|
7
|
-
DocumentPickerDelegate.initWithResolveReject = function (resolve, reject) {
|
7
|
+
DocumentPickerDelegate.initWithResolveReject = function (resolve, reject, booleanResult) {
|
8
|
+
if (booleanResult === void 0) { booleanResult = false; }
|
8
9
|
var delegate = DocumentPickerDelegate.new();
|
9
10
|
delegate._resolve = resolve;
|
10
11
|
delegate._reject = reject;
|
12
|
+
delegate._booleanResult = booleanResult;
|
11
13
|
return delegate;
|
12
14
|
};
|
13
15
|
DocumentPickerDelegate.prototype.cleanup = function (controller) {
|
@@ -17,46 +19,65 @@ var DocumentPickerDelegate = /** @class */ (function (_super) {
|
|
17
19
|
delegate = null;
|
18
20
|
};
|
19
21
|
DocumentPickerDelegate.prototype.documentPickerDidPickDocumentAtURL = function (controller, url) {
|
20
|
-
this._resolve(
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
this._resolve(this._booleanResult
|
23
|
+
? true
|
24
|
+
: {
|
25
|
+
files: [url.absoluteString],
|
26
|
+
ios: url
|
27
|
+
});
|
24
28
|
this.cleanup(controller);
|
25
29
|
};
|
26
30
|
DocumentPickerDelegate.prototype.documentPickerDidPickDocumentsAtURLs = function (controller, urls) {
|
27
|
-
|
28
|
-
|
29
|
-
|
31
|
+
if (this._booleanResult) {
|
32
|
+
this._resolve(true);
|
33
|
+
}
|
34
|
+
else {
|
35
|
+
var output = [];
|
36
|
+
for (var i = 0; i < urls.count; i++) {
|
37
|
+
output.push(urls[i].absoluteString);
|
38
|
+
}
|
39
|
+
this._resolve({
|
40
|
+
files: output,
|
41
|
+
ios: urls
|
42
|
+
});
|
30
43
|
}
|
31
|
-
this._resolve({
|
32
|
-
files: output,
|
33
|
-
ios: urls
|
34
|
-
});
|
35
44
|
this.cleanup(controller);
|
36
45
|
};
|
37
46
|
DocumentPickerDelegate.prototype.documentPickerWasCancelled = function (controller) {
|
38
|
-
this._resolve(
|
39
|
-
|
40
|
-
|
47
|
+
this._resolve(this._booleanResult
|
48
|
+
? false
|
49
|
+
: {
|
50
|
+
files: []
|
51
|
+
});
|
41
52
|
this.cleanup(controller);
|
42
53
|
};
|
43
54
|
DocumentPickerDelegate.ObjCProtocols = [UIDocumentPickerDelegate];
|
44
55
|
return DocumentPickerDelegate;
|
45
56
|
}(NSObject));
|
57
|
+
// Reference to delegate instance to avoid delegate issue
|
58
|
+
// https://github.com/nativescript-community/ui-document-picker/issues/10
|
46
59
|
let delegate;
|
47
60
|
export function openFilePicker(params = {}) {
|
61
|
+
// const options = params;
|
48
62
|
let documentTypes;
|
49
63
|
if (params.extensions && params.extensions.length > 0) {
|
50
|
-
documentTypes =
|
64
|
+
documentTypes = params.extensions;
|
51
65
|
}
|
52
66
|
else {
|
53
|
-
documentTypes =
|
67
|
+
documentTypes = [UTTypeContent.identifier];
|
68
|
+
}
|
69
|
+
if (params.documentTypes) {
|
70
|
+
documentTypes = documentTypes || [];
|
71
|
+
documentTypes.push(...params.documentTypes);
|
54
72
|
}
|
55
73
|
return new Promise((resolve, reject) => {
|
56
|
-
const controller = UIDocumentPickerViewController.alloc().initWithDocumentTypesInMode(documentTypes, params.pickerMode !== undefined ? params.pickerMode : 0);
|
74
|
+
const controller = UIDocumentPickerViewController.alloc().initWithDocumentTypesInMode(Utils.ios.collections.jsArrayToNSArray(documentTypes), params.pickerMode !== undefined ? params.pickerMode : 0 /* UIDocumentPickerMode.Import */);
|
57
75
|
delegate = DocumentPickerDelegate.initWithResolveReject(resolve, reject);
|
58
76
|
controller.delegate = delegate;
|
77
|
+
// if (options.multipleSelection) {
|
59
78
|
controller.allowsMultipleSelection = !!params.multipleSelection;
|
79
|
+
// }
|
80
|
+
// this.presentViewController(controller);
|
60
81
|
const app = UIApplication.sharedApplication;
|
61
82
|
const window = app.keyWindow || (app.windows.count > 0 && app.windows[0]);
|
62
83
|
const visibleVC = Utils.ios.getVisibleViewController(window.rootViewController);
|
@@ -68,4 +89,24 @@ export async function pickFolder(params = {}) {
|
|
68
89
|
folders: []
|
69
90
|
};
|
70
91
|
}
|
92
|
+
export async function saveFile(params) {
|
93
|
+
return new Promise(async (resolve, reject) => {
|
94
|
+
const tempFile = knownFolders.temp().getFile(params.name);
|
95
|
+
if (typeof params.data === 'string') {
|
96
|
+
await tempFile.writeText(params.data);
|
97
|
+
}
|
98
|
+
else {
|
99
|
+
await tempFile.write(params.data);
|
100
|
+
}
|
101
|
+
const controller = UIDocumentPickerViewController.alloc().initForExportingURLsAsCopy([NSURL.URLWithString(tempFile.path)], true);
|
102
|
+
delegate = DocumentPickerDelegate.initWithResolveReject(resolve, reject, true);
|
103
|
+
controller.delegate = delegate;
|
104
|
+
controller.shouldShowFileExtensions = true;
|
105
|
+
// this.presentViewController(controller);
|
106
|
+
const app = UIApplication.sharedApplication;
|
107
|
+
const window = app.keyWindow || (app.windows.count > 0 && app.windows[0]);
|
108
|
+
const visibleVC = Utils.ios.getVisibleViewController(window.rootViewController);
|
109
|
+
visibleVC.presentViewControllerAnimatedCompletion(controller, true, null);
|
110
|
+
});
|
111
|
+
}
|
71
112
|
//# sourceMappingURL=index.ios.js.map
|
package/index.ios.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.ios.js","sourceRoot":"../src/","sources":["index.ios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC
|
1
|
+
{"version":3,"file":"index.ios.js","sourceRoot":"../src/","sources":["index.ios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEzD,yDAAyD;AACzD,yEAAyE;AACzE,IAAI,QAAQ,CAAC;AACb,MAAM,UAAU,cAAc,CAAC,SAA4B,EAAE;IACzD,0BAA0B;IAC1B,IAAI,aAAa,CAAC;IAElB,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;QACnD,aAAa,GAAG,MAAM,CAAC,UAAU,CAAC;KACrC;SAAM;QACH,aAAa,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;KAC9C;IACD,IAAI,MAAM,CAAC,aAAa,EAAE;QACtB,aAAa,GA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|
+
"version": "1.1.14",
|
4
4
|
"description": "A NativeScript plugin that allows you to select files from the device.",
|
5
5
|
"main": "index",
|
6
6
|
"typings": "index.d.ts",
|
@@ -39,7 +39,7 @@
|
|
39
39
|
"license": "Apache-2.0",
|
40
40
|
"readmeFilename": "README.md",
|
41
41
|
"dependencies": {
|
42
|
-
"@nativescript-community/perms": "2.
|
42
|
+
"@nativescript-community/perms": "^2.3.0"
|
43
43
|
},
|
44
|
-
"gitHead": "
|
44
|
+
"gitHead": "73768ea5a17b4a62dd783a1e12d472e6afe696e4"
|
45
45
|
}
|
package/references.d.ts
CHANGED