@tauri-apps/plugin-fs 2.0.0-alpha.1 → 2.0.0-alpha.2
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/README.md +1 -1
- package/dist-js/index.d.ts +0 -5
- package/dist-js/index.min.js +16 -18
- package/dist-js/index.mjs +14 -15
- package/package.json +2 -2
package/README.md
CHANGED
package/dist-js/index.d.ts
CHANGED
|
@@ -41,11 +41,6 @@
|
|
|
41
41
|
* @module
|
|
42
42
|
*/
|
|
43
43
|
import { BaseDirectory } from "@tauri-apps/api/path";
|
|
44
|
-
declare global {
|
|
45
|
-
interface Window {
|
|
46
|
-
__TAURI_INVOKE__: <T>(cmd: string, args?: unknown) => Promise<T>;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
44
|
interface Permissions {
|
|
50
45
|
/**
|
|
51
46
|
* `true` if these permissions describe a readonly (unwritable) file.
|
package/dist-js/index.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var f$
|
|
1
|
+
var f$1=Object.defineProperty;var g$1=(a,b)=>{for(var c in b)f$1(a,c,{get:b[c],enumerable:!0});};var e=(a,b,c)=>{if(!b.has(a))throw TypeError("Cannot "+c)};var h$1=(a,b,c)=>(e(a,b,"read from private field"),c?c.call(a):b.get(a)),i$1=(a,b,c)=>{if(b.has(a))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(a):b.set(a,c);},j$1=(a,b,c,d)=>(e(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c);
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var T$1={};g$1(T$1,{Channel:()=>i,PluginListener:()=>o,addPluginListener:()=>l$1,convertFileSrc:()=>v$1,invoke:()=>u$1,transformCallback:()=>_$1});function _$1(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}var r,i=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0;i$1(this,r,()=>{});this.id=_$1(n=>{h$1(this,r).call(this,n);});}set onmessage(n){j$1(this,r,n);}get onmessage(){return h$1(this,r)}toJSON(){return `__CHANNEL__:${this.id}`}};r=new WeakMap;var o=class{constructor(n,s,t){this.plugin=n,this.event=s,this.channelId=t;}async unregister(){return u$1(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function l$1(e,n,s){let t=new i;return t.onmessage=s,u$1(`plugin:${e}|register_listener`,{event:n,handler:t}).then(()=>new o(e,n,t.id))}async function u$1(e,n={},s){return window.__TAURI_INTERNALS__.invoke(e,n,s)}function v$1(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)}
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var U={};g$1(U,{BaseDirectory:()=>t,appCacheDir:()=>p,appConfigDir:()=>s,appDataDir:()=>u,appLocalDataDir:()=>c,appLogDir:()=>w,audioDir:()=>a,basename:()=>H,cacheDir:()=>l,configDir:()=>g,dataDir:()=>d,delimiter:()=>E,desktopDir:()=>m,dirname:()=>z,documentDir:()=>y,downloadDir:()=>h,executableDir:()=>f,extname:()=>F,fontDir:()=>P,homeDir:()=>_,isAbsolute:()=>S,join:()=>j,localDataDir:()=>v,normalize:()=>N,pictureDir:()=>A,publicDir:()=>D,resolve:()=>I,resolveResource:()=>C,resourceDir:()=>b,runtimeDir:()=>L,sep:()=>k,tempDir:()=>x,templateDir:()=>R,videoDir:()=>T});var t=(r=>(r[r.Audio=1]="Audio",r[r.Cache=2]="Cache",r[r.Config=3]="Config",r[r.Data=4]="Data",r[r.LocalData=5]="LocalData",r[r.Document=6]="Document",r[r.Download=7]="Download",r[r.Picture=8]="Picture",r[r.Public=9]="Public",r[r.Video=10]="Video",r[r.Resource=11]="Resource",r[r.Temp=12]="Temp",r[r.AppConfig=13]="AppConfig",r[r.AppData=14]="AppData",r[r.AppLocalData=15]="AppLocalData",r[r.AppCache=16]="AppCache",r[r.AppLog=17]="AppLog",r[r.Desktop=18]="Desktop",r[r.Executable=19]="Executable",r[r.Font=20]="Font",r[r.Home=21]="Home",r[r.Runtime=22]="Runtime",r[r.Template=23]="Template",r))(t||{});async function s(){return u$1("plugin:path|resolve_directory",{directory:13})}async function u(){return u$1("plugin:path|resolve_directory",{directory:14})}async function c(){return u$1("plugin:path|resolve_directory",{directory:15})}async function p(){return u$1("plugin:path|resolve_directory",{directory:16})}async function a(){return u$1("plugin:path|resolve_directory",{directory:1})}async function l(){return u$1("plugin:path|resolve_directory",{directory:2})}async function g(){return u$1("plugin:path|resolve_directory",{directory:3})}async function d(){return u$1("plugin:path|resolve_directory",{directory:4})}async function m(){return u$1("plugin:path|resolve_directory",{directory:18})}async function y(){return u$1("plugin:path|resolve_directory",{directory:6})}async function h(){return u$1("plugin:path|resolve_directory",{directory:7})}async function f(){return u$1("plugin:path|resolve_directory",{directory:19})}async function P(){return u$1("plugin:path|resolve_directory",{directory:20})}async function _(){return u$1("plugin:path|resolve_directory",{directory:21})}async function v(){return u$1("plugin:path|resolve_directory",{directory:5})}async function A(){return u$1("plugin:path|resolve_directory",{directory:8})}async function D(){return u$1("plugin:path|resolve_directory",{directory:9})}async function b(){return u$1("plugin:path|resolve_directory",{directory:11})}async function C(i){return u$1("plugin:path|resolve_directory",{directory:11,path:i})}async function L(){return u$1("plugin:path|resolve_directory",{directory:22})}async function R(){return u$1("plugin:path|resolve_directory",{directory:23})}async function T(){return u$1("plugin:path|resolve_directory",{directory:10})}async function w(){return u$1("plugin:path|resolve_directory",{directory:17})}async function x(i){return u$1("plugin:path|resolve_directory",{directory:12})}function k(){return window.__TAURI_INTERNALS__.plugins.path.sep}function E(){return window.__TAURI_INTERNALS__.plugins.path.delimiter}async function I(...i){return u$1("plugin:path|resolve",{paths:i})}async function N(i){return u$1("plugin:path|normalize",{path:i})}async function j(...i){return u$1("plugin:path|join",{paths:i})}async function z(i){return u$1("plugin:path|dirname",{path:i})}async function F(i){return u$1("plugin:path|extname",{path:i})}async function H(i,e){return u$1("plugin:path|basename",{path:i,ext:e})}async function S(i){return u$1("plugin:path|isAbsolute",{path:i})}
|
|
6
6
|
|
|
7
7
|
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -61,7 +61,7 @@ var q={};g$1(q,{BaseDirectory:()=>t,appCacheDir:()=>p,appConfigDir:()=>s,appData
|
|
|
61
61
|
* @since 2.0.0
|
|
62
62
|
*/
|
|
63
63
|
async function readTextFile(filePath, options = {}) {
|
|
64
|
-
return await
|
|
64
|
+
return await u$1("plugin:fs|read_text_file", {
|
|
65
65
|
path: filePath,
|
|
66
66
|
options,
|
|
67
67
|
});
|
|
@@ -78,7 +78,7 @@ async function readTextFile(filePath, options = {}) {
|
|
|
78
78
|
* @since 2.0.0
|
|
79
79
|
*/
|
|
80
80
|
async function readBinaryFile(filePath, options = {}) {
|
|
81
|
-
const arr = await
|
|
81
|
+
const arr = await u$1("plugin:fs|read_file", {
|
|
82
82
|
path: filePath,
|
|
83
83
|
options,
|
|
84
84
|
});
|
|
@@ -113,7 +113,7 @@ async function writeTextFile(path, contents, options) {
|
|
|
113
113
|
else {
|
|
114
114
|
fileOptions = contents;
|
|
115
115
|
}
|
|
116
|
-
return await
|
|
116
|
+
return await u$1("plugin:fs|write_file", {
|
|
117
117
|
path: file.path,
|
|
118
118
|
contents: Array.from(new TextEncoder().encode(file.contents)),
|
|
119
119
|
options: fileOptions,
|
|
@@ -149,7 +149,7 @@ async function writeBinaryFile(path, contents, options) {
|
|
|
149
149
|
// @ts-expect-error in this case `contents` is always a BinaryFileContents
|
|
150
150
|
file.contents = contents !== null && contents !== void 0 ? contents : [];
|
|
151
151
|
}
|
|
152
|
-
return await
|
|
152
|
+
return await u$1("plugin:fs|write_file", {
|
|
153
153
|
path: file.path,
|
|
154
154
|
contents: Array.from(file.contents instanceof ArrayBuffer
|
|
155
155
|
? new Uint8Array(file.contents)
|
|
@@ -178,7 +178,7 @@ async function writeBinaryFile(path, contents, options) {
|
|
|
178
178
|
* @since 2.0.0
|
|
179
179
|
*/
|
|
180
180
|
async function readDir(dir, options = {}) {
|
|
181
|
-
return await
|
|
181
|
+
return await u$1("plugin:fs|read_dir", {
|
|
182
182
|
path: dir,
|
|
183
183
|
options,
|
|
184
184
|
});
|
|
@@ -199,7 +199,7 @@ async function readDir(dir, options = {}) {
|
|
|
199
199
|
* @since 2.0.0
|
|
200
200
|
*/
|
|
201
201
|
async function createDir(dir, options = {}) {
|
|
202
|
-
return await
|
|
202
|
+
return await u$1("plugin:fs|create_dir", {
|
|
203
203
|
path: dir,
|
|
204
204
|
options,
|
|
205
205
|
});
|
|
@@ -219,7 +219,7 @@ async function createDir(dir, options = {}) {
|
|
|
219
219
|
* @since 2.0.0
|
|
220
220
|
*/
|
|
221
221
|
async function removeDir(dir, options = {}) {
|
|
222
|
-
return await
|
|
222
|
+
return await u$1("plugin:fs|remove_dir", {
|
|
223
223
|
path: dir,
|
|
224
224
|
options,
|
|
225
225
|
});
|
|
@@ -238,7 +238,7 @@ async function removeDir(dir, options = {}) {
|
|
|
238
238
|
* @since 2.0.0
|
|
239
239
|
*/
|
|
240
240
|
async function copyFile(source, destination, options = {}) {
|
|
241
|
-
return await
|
|
241
|
+
return await u$1("plugin:fs|copy_file", {
|
|
242
242
|
source,
|
|
243
243
|
destination,
|
|
244
244
|
options,
|
|
@@ -258,7 +258,7 @@ async function copyFile(source, destination, options = {}) {
|
|
|
258
258
|
* @since 2.0.0
|
|
259
259
|
*/
|
|
260
260
|
async function removeFile(file, options = {}) {
|
|
261
|
-
return await
|
|
261
|
+
return await u$1("plugin:fs|remove_file", {
|
|
262
262
|
path: file,
|
|
263
263
|
options,
|
|
264
264
|
});
|
|
@@ -277,7 +277,7 @@ async function removeFile(file, options = {}) {
|
|
|
277
277
|
* @since 2.0.0
|
|
278
278
|
*/
|
|
279
279
|
async function renameFile(oldPath, newPath, options = {}) {
|
|
280
|
-
return await
|
|
280
|
+
return await u$1("plugin:fs|rename_file", {
|
|
281
281
|
oldPath,
|
|
282
282
|
newPath,
|
|
283
283
|
options,
|
|
@@ -295,7 +295,7 @@ async function renameFile(oldPath, newPath, options = {}) {
|
|
|
295
295
|
* @since 2.0.0
|
|
296
296
|
*/
|
|
297
297
|
async function exists(path) {
|
|
298
|
-
return await
|
|
298
|
+
return await u$1("plugin:fs|exists", { path });
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
301
301
|
* Returns the metadata for the given path.
|
|
@@ -303,11 +303,9 @@ async function exists(path) {
|
|
|
303
303
|
* @since 2.0.0
|
|
304
304
|
*/
|
|
305
305
|
async function metadata(path) {
|
|
306
|
-
return await
|
|
307
|
-
.__TAURI_INVOKE__("plugin:fs|metadata", {
|
|
306
|
+
return await u$1("plugin:fs|metadata", {
|
|
308
307
|
path,
|
|
309
|
-
})
|
|
310
|
-
.then((metadata) => {
|
|
308
|
+
}).then((metadata) => {
|
|
311
309
|
const { accessedAtMs, createdAtMs, modifiedAtMs, ...data } = metadata;
|
|
312
310
|
return {
|
|
313
311
|
accessedAt: new Date(accessedAtMs),
|
package/dist-js/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { BaseDirectory, BaseDirectory as Dir } from '@tauri-apps/api/path';
|
|
2
|
+
import { invoke } from '@tauri-apps/api/primitives';
|
|
2
3
|
|
|
3
4
|
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
4
5
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -57,7 +58,7 @@ export { BaseDirectory, BaseDirectory as Dir } from '@tauri-apps/api/path';
|
|
|
57
58
|
* @since 2.0.0
|
|
58
59
|
*/
|
|
59
60
|
async function readTextFile(filePath, options = {}) {
|
|
60
|
-
return await
|
|
61
|
+
return await invoke("plugin:fs|read_text_file", {
|
|
61
62
|
path: filePath,
|
|
62
63
|
options,
|
|
63
64
|
});
|
|
@@ -74,7 +75,7 @@ async function readTextFile(filePath, options = {}) {
|
|
|
74
75
|
* @since 2.0.0
|
|
75
76
|
*/
|
|
76
77
|
async function readBinaryFile(filePath, options = {}) {
|
|
77
|
-
const arr = await
|
|
78
|
+
const arr = await invoke("plugin:fs|read_file", {
|
|
78
79
|
path: filePath,
|
|
79
80
|
options,
|
|
80
81
|
});
|
|
@@ -109,7 +110,7 @@ async function writeTextFile(path, contents, options) {
|
|
|
109
110
|
else {
|
|
110
111
|
fileOptions = contents;
|
|
111
112
|
}
|
|
112
|
-
return await
|
|
113
|
+
return await invoke("plugin:fs|write_file", {
|
|
113
114
|
path: file.path,
|
|
114
115
|
contents: Array.from(new TextEncoder().encode(file.contents)),
|
|
115
116
|
options: fileOptions,
|
|
@@ -145,7 +146,7 @@ async function writeBinaryFile(path, contents, options) {
|
|
|
145
146
|
// @ts-expect-error in this case `contents` is always a BinaryFileContents
|
|
146
147
|
file.contents = contents !== null && contents !== void 0 ? contents : [];
|
|
147
148
|
}
|
|
148
|
-
return await
|
|
149
|
+
return await invoke("plugin:fs|write_file", {
|
|
149
150
|
path: file.path,
|
|
150
151
|
contents: Array.from(file.contents instanceof ArrayBuffer
|
|
151
152
|
? new Uint8Array(file.contents)
|
|
@@ -174,7 +175,7 @@ async function writeBinaryFile(path, contents, options) {
|
|
|
174
175
|
* @since 2.0.0
|
|
175
176
|
*/
|
|
176
177
|
async function readDir(dir, options = {}) {
|
|
177
|
-
return await
|
|
178
|
+
return await invoke("plugin:fs|read_dir", {
|
|
178
179
|
path: dir,
|
|
179
180
|
options,
|
|
180
181
|
});
|
|
@@ -195,7 +196,7 @@ async function readDir(dir, options = {}) {
|
|
|
195
196
|
* @since 2.0.0
|
|
196
197
|
*/
|
|
197
198
|
async function createDir(dir, options = {}) {
|
|
198
|
-
return await
|
|
199
|
+
return await invoke("plugin:fs|create_dir", {
|
|
199
200
|
path: dir,
|
|
200
201
|
options,
|
|
201
202
|
});
|
|
@@ -215,7 +216,7 @@ async function createDir(dir, options = {}) {
|
|
|
215
216
|
* @since 2.0.0
|
|
216
217
|
*/
|
|
217
218
|
async function removeDir(dir, options = {}) {
|
|
218
|
-
return await
|
|
219
|
+
return await invoke("plugin:fs|remove_dir", {
|
|
219
220
|
path: dir,
|
|
220
221
|
options,
|
|
221
222
|
});
|
|
@@ -234,7 +235,7 @@ async function removeDir(dir, options = {}) {
|
|
|
234
235
|
* @since 2.0.0
|
|
235
236
|
*/
|
|
236
237
|
async function copyFile(source, destination, options = {}) {
|
|
237
|
-
return await
|
|
238
|
+
return await invoke("plugin:fs|copy_file", {
|
|
238
239
|
source,
|
|
239
240
|
destination,
|
|
240
241
|
options,
|
|
@@ -254,7 +255,7 @@ async function copyFile(source, destination, options = {}) {
|
|
|
254
255
|
* @since 2.0.0
|
|
255
256
|
*/
|
|
256
257
|
async function removeFile(file, options = {}) {
|
|
257
|
-
return await
|
|
258
|
+
return await invoke("plugin:fs|remove_file", {
|
|
258
259
|
path: file,
|
|
259
260
|
options,
|
|
260
261
|
});
|
|
@@ -273,7 +274,7 @@ async function removeFile(file, options = {}) {
|
|
|
273
274
|
* @since 2.0.0
|
|
274
275
|
*/
|
|
275
276
|
async function renameFile(oldPath, newPath, options = {}) {
|
|
276
|
-
return await
|
|
277
|
+
return await invoke("plugin:fs|rename_file", {
|
|
277
278
|
oldPath,
|
|
278
279
|
newPath,
|
|
279
280
|
options,
|
|
@@ -291,7 +292,7 @@ async function renameFile(oldPath, newPath, options = {}) {
|
|
|
291
292
|
* @since 2.0.0
|
|
292
293
|
*/
|
|
293
294
|
async function exists(path) {
|
|
294
|
-
return await
|
|
295
|
+
return await invoke("plugin:fs|exists", { path });
|
|
295
296
|
}
|
|
296
297
|
/**
|
|
297
298
|
* Returns the metadata for the given path.
|
|
@@ -299,11 +300,9 @@ async function exists(path) {
|
|
|
299
300
|
* @since 2.0.0
|
|
300
301
|
*/
|
|
301
302
|
async function metadata(path) {
|
|
302
|
-
return await
|
|
303
|
-
.__TAURI_INVOKE__("plugin:fs|metadata", {
|
|
303
|
+
return await invoke("plugin:fs|metadata", {
|
|
304
304
|
path,
|
|
305
|
-
})
|
|
306
|
-
.then((metadata) => {
|
|
305
|
+
}).then((metadata) => {
|
|
307
306
|
const { accessedAtMs, createdAtMs, modifiedAtMs, ...data } = metadata;
|
|
308
307
|
return {
|
|
309
308
|
accessedAt: new Date(accessedAtMs),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tauri-apps/plugin-fs",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.2",
|
|
4
4
|
"description": "Access the file system.",
|
|
5
5
|
"license": "MIT or APACHE-2.0",
|
|
6
6
|
"authors": [
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"tslib": "^2.4.1"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tauri-apps/api": "2.0.0-alpha.
|
|
28
|
+
"@tauri-apps/api": "2.0.0-alpha.9"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "rollup -c"
|