@tauri-apps/plugin-fs
Advanced tools
Comparing version 2.0.0-alpha.0 to 2.0.0-alpha.1
@@ -1,9 +0,53 @@ | ||
var f$2=Object.defineProperty;var g$1=(a,b)=>{for(var c in b)f$2(a,c,{get:b[c],enumerable:!0});};var e$1=(a,b,c)=>{if(!b.has(a))throw TypeError("Cannot "+c)};var h$2=(a,b,c)=>(e$1(a,b,"read from private field"),c?c.call(a):b.get(a)),i=(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$1(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c); | ||
var f$2=Object.defineProperty;var g$1=(a,b)=>{for(var c in b)f$2(a,c,{get:b[c],enumerable:!0});};var e=(a,b,c)=>{if(!b.has(a))throw TypeError("Cannot "+c)};var h$2=(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); | ||
var f$1={};g$1(f$1,{Channel:()=>a$1,PluginListener:()=>c$1,addPluginListener:()=>v$1,convertFileSrc:()=>m$1,invoke:()=>u$1,transformCallback:()=>o});function h$1(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function o(t,e=!1){let n=h$1(),r=`_${n}`;return Object.defineProperty(window,r,{value:i=>(e&&Reflect.deleteProperty(window,r),t?.(i)),writable:!1,configurable:!0}),n}var s,a$1=class a{constructor(){this.__TAURI_CHANNEL_MARKER__=!0;i(this,s,()=>{});this.id=o(e=>{h$2(this,s).call(this,e);});}set onmessage(e){j$1(this,s,e);}get onmessage(){return h$2(this,s)}toJSON(){return `__CHANNEL__:${this.id}`}};s=new WeakMap;var c$1=class c{constructor(e,n,r){this.plugin=e,this.event=n,this.channelId=r;}async unregister(){return u$1(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function v$1(t,e,n){let r=new a$1;return r.onmessage=n,u$1(`plugin:${t}|register_listener`,{event:e,handler:r}).then(()=>new c$1(t,e,r.id))}async function u$1(t,e={}){return new Promise((n,r)=>{let i=o(d=>{n(d),Reflect.deleteProperty(window,`_${g}`);},!0),g=o(d=>{r(d),Reflect.deleteProperty(window,`_${i}`);},!0);window.__TAURI_IPC__({cmd:t,callback:i,error:g,...e});})}function m$1(t,e="asset"){let n=encodeURIComponent(t);return navigator.userAgent.includes("Windows")?`https://${e}.localhost/${n}`:`${e}://localhost/${n}`} | ||
var h$1={};g$1(h$1,{Channel:()=>o,PluginListener:()=>a$1,addPluginListener:()=>m$1,convertFileSrc:()=>y$1,invoke:()=>u$1,transformCallback:()=>s$1});function f$1(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s$1(n,e=!1){let t=f$1(),r=`_${t}`;return Object.defineProperty(window,r,{value:c=>(e&&Reflect.deleteProperty(window,r),n?.(c)),writable:!1,configurable:!0}),t}var i,o=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0;i$1(this,i,()=>{});this.id=s$1(e=>{h$2(this,i).call(this,e);});}set onmessage(e){j$1(this,i,e);}get onmessage(){return h$2(this,i)}toJSON(){return `__CHANNEL__:${this.id}`}};i=new WeakMap;var a$1=class a{constructor(e,t,r){this.plugin=e,this.event=t,this.channelId=r;}async unregister(){return u$1(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function m$1(n,e,t){let r=new o;return r.onmessage=t,u$1(`plugin:${n}|register_listener`,{event:e,handler:r}).then(()=>new a$1(n,e,r.id))}async function u$1(n,e={},t){return new Promise((r,c)=>{let g=s$1(d=>{r(d),Reflect.deleteProperty(window,`_${_}`);},!0),_=s$1(d=>{c(d),Reflect.deleteProperty(window,`_${g}`);},!0);window.__TAURI_IPC__({cmd:n,callback:g,error:_,payload:e,options:t});})}function y$1(n,e="asset"){return window.__TAURI__.convertFileSrc(n,e)} | ||
var O={};g$1(O,{BaseDirectory:()=>e,appCacheDir:()=>p,appConfigDir:()=>u,appDataDir:()=>c,appLocalDataDir:()=>a,appLogDir:()=>V,audioDir:()=>l,basename:()=>H,cacheDir:()=>g,configDir:()=>d,dataDir:()=>m,delimiter:()=>T,desktopDir:()=>y,dirname:()=>E,documentDir:()=>f,downloadDir:()=>h,executableDir:()=>P,extname:()=>F,fontDir:()=>v,homeDir:()=>_,isAbsolute:()=>M,join:()=>z,localDataDir:()=>D,normalize:()=>j,pictureDir:()=>b,publicDir:()=>A,resolve:()=>W,resolveResource:()=>L,resourceDir:()=>C,runtimeDir:()=>x,sep:()=>k,templateDir:()=>R,videoDir:()=>w});function t(){return navigator.appVersion.includes("Win")}var e=(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))(e||{});async function u(){return u$1("plugin:path|resolve_directory",{directory:13})}async function c(){return u$1("plugin:path|resolve_directory",{directory:14})}async function a(){return u$1("plugin:path|resolve_directory",{directory:15})}async function p(){return u$1("plugin:path|resolve_directory",{directory:16})}async function l(){return u$1("plugin:path|resolve_directory",{directory:1})}async function g(){return u$1("plugin:path|resolve_directory",{directory:2})}async function d(){return u$1("plugin:path|resolve_directory",{directory:3})}async function m(){return u$1("plugin:path|resolve_directory",{directory:4})}async function y(){return u$1("plugin:path|resolve_directory",{directory:18})}async function f(){return u$1("plugin:path|resolve_directory",{directory:6})}async function h(){return u$1("plugin:path|resolve_directory",{directory:7})}async function P(){return u$1("plugin:path|resolve_directory",{directory:19})}async function v(){return u$1("plugin:path|resolve_directory",{directory:20})}async function _(){return u$1("plugin:path|resolve_directory",{directory:21})}async function D(){return u$1("plugin:path|resolve_directory",{directory:5})}async function b(){return u$1("plugin:path|resolve_directory",{directory:8})}async function A(){return u$1("plugin:path|resolve_directory",{directory:9})}async function C(){return u$1("plugin:path|resolve_directory",{directory:11})}async function L(i){return u$1("plugin:path|resolve_directory",{directory:11,path:i})}async function x(){return u$1("plugin:path|resolve_directory",{directory:22})}async function R(){return u$1("plugin:path|resolve_directory",{directory:23})}async function w(){return u$1("plugin:path|resolve_directory",{directory:10})}async function V(){return u$1("plugin:path|resolve_directory",{directory:17})}var k=t()?"\\":"/",T=t()?";":":";async function W(...i){return u$1("plugin:path|resolve",{paths:i})}async function j(i){return u$1("plugin:path|normalize",{path:i})}async function z(...i){return u$1("plugin:path|join",{paths:i})}async function E(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,o){return u$1("plugin:path|basename",{path:i,ext:o})}async function M(i){return u$1("plugin:path|isAbsolute",{path:i})} | ||
var q={};g$1(q,{BaseDirectory:()=>t,appCacheDir:()=>p,appConfigDir:()=>s,appDataDir:()=>u,appLocalDataDir:()=>c,appLogDir:()=>x,audioDir:()=>a,basename:()=>U,cacheDir:()=>l,configDir:()=>g,dataDir:()=>d,delimiter:()=>j,desktopDir:()=>m,dirname:()=>H,documentDir:()=>y,downloadDir:()=>h,executableDir:()=>f,extname:()=>I,fontDir:()=>_,homeDir:()=>P,isAbsolute:()=>V,join:()=>F,localDataDir:()=>v,normalize:()=>E,pictureDir:()=>D,publicDir:()=>A,resolve:()=>z,resolveResource:()=>C,resourceDir:()=>b,runtimeDir:()=>L,sep:()=>k,tempDir:()=>T,templateDir:()=>R,videoDir:()=>w});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 _(){return u$1("plugin:path|resolve_directory",{directory:20})}async function P(){return u$1("plugin:path|resolve_directory",{directory:21})}async function v(){return u$1("plugin:path|resolve_directory",{directory:5})}async function D(){return u$1("plugin:path|resolve_directory",{directory:8})}async function A(){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 w(){return u$1("plugin:path|resolve_directory",{directory:10})}async function x(){return u$1("plugin:path|resolve_directory",{directory:17})}async function T(i){return u$1("plugin:path|resolve_directory",{directory:12})}function k(){return window.__TAURI__.path.__sep}function j(){return window.__TAURI__.path.__delimiter}async function z(...i){return u$1("plugin:path|resolve",{paths:i})}async function E(i){return u$1("plugin:path|normalize",{path:i})}async function F(...i){return u$1("plugin:path|join",{paths:i})}async function H(i){return u$1("plugin:path|dirname",{path:i})}async function I(i){return u$1("plugin:path|extname",{path:i})}async function U(i,e){return u$1("plugin:path|basename",{path:i,ext:e})}async function V(i){return u$1("plugin:path|isAbsolute",{path:i})} | ||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
/** | ||
* Access the file system. | ||
* | ||
* ## Security | ||
* | ||
* This module prevents path traversal, not allowing absolute paths or parent dir components | ||
* (i.e. "/usr/path/to/file" or "../path/to/file" paths are not allowed). | ||
* Paths accessed with this API must be relative to one of the {@link BaseDirectory | base directories} | ||
* so if you need access to arbitrary filesystem paths, you must write such logic on the core layer instead. | ||
* | ||
* The API has a scope configuration that forces you to restrict the paths that can be accessed using glob patterns. | ||
* | ||
* The scope configuration is an array of glob patterns describing folder paths that are allowed. | ||
* For instance, this scope configuration only allows accessing files on the | ||
* *databases* folder of the {@link path.appDataDir | $APPDATA directory}: | ||
* ```json | ||
* { | ||
* "plugins": { | ||
* "fs": { | ||
* "scope": ["$APPDATA/databases/*"] | ||
* } | ||
* } | ||
* } | ||
* ``` | ||
* | ||
* Notice the use of the `$APPDATA` variable. The value is injected at runtime, resolving to the {@link path.appDataDir | app data directory}. | ||
* The available variables are: | ||
* {@link path.appConfigDir | `$APPCONFIG`}, {@link path.appDataDir | `$APPDATA`}, {@link path.appLocalDataDir | `$APPLOCALDATA`}, | ||
* {@link path.appCacheDir | `$APPCACHE`}, {@link path.appLogDir | `$APPLOG`}, | ||
* {@link path.audioDir | `$AUDIO`}, {@link path.cacheDir | `$CACHE`}, {@link path.configDir | `$CONFIG`}, {@link path.dataDir | `$DATA`}, | ||
* {@link path.localDataDir | `$LOCALDATA`}, {@link path.desktopDir | `$DESKTOP`}, {@link path.documentDir | `$DOCUMENT`}, | ||
* {@link path.downloadDir | `$DOWNLOAD`}, {@link path.executableDir | `$EXE`}, {@link path.fontDir | `$FONT`}, {@link path.homeDir | `$HOME`}, | ||
* {@link path.pictureDir | `$PICTURE`}, {@link path.publicDir | `$PUBLIC`}, {@link path.runtimeDir | `$RUNTIME`}, | ||
* {@link path.templateDir | `$TEMPLATE`}, {@link path.videoDir | `$VIDEO`}, {@link path.resourceDir | `$RESOURCE`}, | ||
* {@link os.tempdir | `$TEMP`}. | ||
* | ||
* Trying to execute any API with a URL not configured on the scope results in a promise rejection due to denied access. | ||
* | ||
* Note that this scope applies to **all** APIs on this module. | ||
* | ||
* @module | ||
*/ | ||
/** | ||
* Reads a file as an UTF-8 encoded string. | ||
@@ -108,3 +152,3 @@ * @example | ||
} | ||
return await window.__TAURI_INVOKE__("plugin:fs|write_binary_file", { | ||
return await window.__TAURI_INVOKE__("plugin:fs|write_file", { | ||
path: file.path, | ||
@@ -278,3 +322,3 @@ contents: Array.from(file.contents instanceof ArrayBuffer | ||
export { e as BaseDirectory, e as Dir, copyFile, createDir, exists, metadata, readBinaryFile, readDir, readTextFile, removeDir, removeFile, renameFile, writeBinaryFile, writeTextFile as writeFile, writeTextFile }; | ||
export { t as BaseDirectory, t as Dir, copyFile, createDir, exists, metadata, readBinaryFile, readDir, readTextFile, removeDir, removeFile, renameFile, writeBinaryFile, writeTextFile as writeFile, writeTextFile }; | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "@tauri-apps/plugin-fs", | ||
"version": "2.0.0-alpha.0", | ||
"version": "2.0.0-alpha.1", | ||
"description": "Access the file system.", | ||
@@ -28,3 +28,3 @@ "license": "MIT or APACHE-2.0", | ||
"dependencies": { | ||
"@tauri-apps/api": "2.0.0-alpha.4" | ||
"@tauri-apps/api": "2.0.0-alpha.6" | ||
}, | ||
@@ -31,0 +31,0 @@ "scripts": { |
@@ -1,2 +0,2 @@ | ||
# File System | ||
![plugin-fs](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/fs/banner.png) | ||
@@ -3,0 +3,0 @@ Access the file system. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42049
1028
+ Added@tauri-apps/api@2.0.0-alpha.6(transitive)
- Removed@tauri-apps/api@2.0.0-alpha.4(transitive)