diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..ea0aede --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,20 @@ +version: 2 +enable-beta-ecosystems: true + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "daily" + versioning-strategy: lockfile-only + + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "daily" + versioning-strategy: increase diff --git a/.github/workflows/Dependabot.yml b/.github/workflows/Dependabot.yml new file mode 100644 index 0000000..cfa5b96 --- /dev/null +++ b/.github/workflows/Dependabot.yml @@ -0,0 +1,45 @@ +name: Dependabot + +concurrency: + group: Dependabot-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + security-events: write + contents: write + pull-requests: write + +on: + workflow_dispatch: + pull_request: + +jobs: + Approve: + runs-on: ubuntu-latest + + if: ${{ github.actor == 'dependabot[bot]' }} + + steps: + - uses: dependabot/fetch-metadata@v2.0.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + Merge: + runs-on: ubuntu-latest + + if: ${{ github.actor == 'dependabot[bot]' }} + + steps: + - uses: dependabot/fetch-metadata@v2.0.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/GitHub.yml b/.github/workflows/GitHub.yml new file mode 100644 index 0000000..09e8b75 --- /dev/null +++ b/.github/workflows/GitHub.yml @@ -0,0 +1,57 @@ +name: GitHub + +concurrency: + group: GitHub-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + issues: write + pull-requests: write + +on: + issues: + types: [opened] + pull_request: + types: [opened] + +jobs: + Assign: + runs-on: ubuntu-latest + + env: + ADBLOCK: true + ASTRO_TELEMETRY_DISABLED: 1 + AUTOMATEDLAB_TELEMETRY_OPTOUT: 1 + AZURE_CORE_COLLECT_TELEMETRY: 0 + CHOOSENIM_NO_ANALYTICS: 1 + DIEZ_DO_NOT_TRACK: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT: 1 + DO_NOT_TRACK: 1 + ET_NO_TELEMETRY: 1 + GATSBY_TELEMETRY_DISABLED: 1 + GATSBY_TELEMETRY_OPTOUT: 1 + GATSBY_TELEMETRY_OPT_OUT: 1 + GRIT_TELEMETRY_DISABLED: 1 + HASURA_GRAPHQL_ENABLE_TELEMETRY: false + HINT_TELEMETRY: off + HOMEBREW_NO_ANALYTICS: 1 + INFLUXD_REPORTING_DISABLED: true + ITERATIVE_DO_NOT_TRACK: 1 + NEXT_TELEMETRY_DEBUG: 1 + NEXT_TELEMETRY_DISABLED: 1 + NG_CLI_ANALYTICS: false + NUXT_TELEMETRY_DISABLED: 1 + PIN_DO_NOT_TRACK: 1 + POWERSHELL_TELEMETRY_OPTOUT: 1 + SAM_CLI_TELEMETRY: 0 + STNOUPGRADE: 1 + STRIPE_CLI_TELEMETRY_OPTOUT: 1 + TELEMETRY_DISABLED: 1 + + steps: + - uses: pozil/auto-assign-issue@v1.13.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + assignees: NikolaRHristov + numOfAssignee: 1 diff --git a/.github/workflows/NPM.yml b/.github/workflows/NPM.yml new file mode 100644 index 0000000..b0332f1 --- /dev/null +++ b/.github/workflows/NPM.yml @@ -0,0 +1,43 @@ +name: NPM + +concurrency: + group: NPM-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + security-events: write + contents: write + pull-requests: write + +on: + workflow_dispatch: + release: + types: [created] + workflow_call: + +jobs: + Publish: + runs-on: ubuntu-latest + + permissions: + contents: read + id-token: write + + steps: + - uses: actions/checkout@v4.1.2 + + - uses: actions/setup-node@v4.0.2 + with: + node-version: "18" + registry-url: "https://registry.npmjs.org" + + - run: npm install -g npm + + - name: Publish . + continue-on-error: true + working-directory: . + run: | + npm install --legacy-peer-deps + npm publish --legacy-peer-deps --provenance + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/Node.yml b/.github/workflows/Node.yml new file mode 100644 index 0000000..cd8ec65 --- /dev/null +++ b/.github/workflows/Node.yml @@ -0,0 +1,100 @@ +name: Node + +concurrency: + group: Node-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + security-events: write + contents: write + pull-requests: write + +on: + workflow_dispatch: + push: + branches: [Current] + pull_request: + branches: [Current] + workflow_call: + +jobs: + Pre-Publish: + runs-on: ubuntu-latest + + env: + ADBLOCK: true + ASTRO_TELEMETRY_DISABLED: 1 + AUTOMATEDLAB_TELEMETRY_OPTOUT: 1 + AZURE_CORE_COLLECT_TELEMETRY: 0 + CHOOSENIM_NO_ANALYTICS: 1 + DIEZ_DO_NOT_TRACK: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT: 1 + DO_NOT_TRACK: 1 + ET_NO_TELEMETRY: 1 + GATSBY_TELEMETRY_DISABLED: 1 + GATSBY_TELEMETRY_OPTOUT: 1 + GATSBY_TELEMETRY_OPT_OUT: 1 + GRIT_TELEMETRY_DISABLED: 1 + HASURA_GRAPHQL_ENABLE_TELEMETRY: false + HINT_TELEMETRY: off + HOMEBREW_NO_ANALYTICS: 1 + INFLUXD_REPORTING_DISABLED: true + ITERATIVE_DO_NOT_TRACK: 1 + NEXT_TELEMETRY_DEBUG: 1 + NEXT_TELEMETRY_DISABLED: 1 + NG_CLI_ANALYTICS: false + NUXT_TELEMETRY_DISABLED: 1 + PIN_DO_NOT_TRACK: 1 + POWERSHELL_TELEMETRY_OPTOUT: 1 + SAM_CLI_TELEMETRY: 0 + STNOUPGRADE: 1 + STRIPE_CLI_TELEMETRY_OPTOUT: 1 + TELEMETRY_DISABLED: 1 + + strategy: + matrix: + node-version: [18, 19, 20] + + steps: + - uses: actions/checkout@v4.1.2 + + - uses: pnpm/action-setup@v3.0.0 + with: + version: 8.15.5 + run_install: | + - recursive: true + args: [ + --link-workspace-packages=true, + --lockfile-only, + --prefer-frozen-lockfile=false, + --shamefully-hoist=false, + --shared-workspace-lockfile=true, + --strict-peer-dependencies=false, + --unsafe-perm=true + ] + + - uses: actions/setup-node@v4.0.2 + with: + node-version: ${{ matrix.node-version }} + cache: "pnpm" + cache-dependency-path: ./pnpm-lock.yaml + + - run: pnpm install + working-directory: . + + - run: pnpm run build + working-directory: . + + - uses: actions/upload-artifact@v4.3.1 + with: + name: .-Node-${{ matrix.node-version }}-Target + path: ./Target + + - run: pnpm run prepublishOnly + working-directory: . + + - uses: actions/upload-artifact@v4.3.1 + with: + name: .-Node-${{ matrix.node-version }}-Target + path: ./Target diff --git a/.github/workflows/Rust.yml b/.github/workflows/Rust.yml new file mode 100644 index 0000000..8d5e11c --- /dev/null +++ b/.github/workflows/Rust.yml @@ -0,0 +1,78 @@ +name: Rust + +concurrency: + group: Rust-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + security-events: write + +on: + workflow_dispatch: + push: + branches: [Current] + pull_request: + branches: [Current] + workflow_call: + +jobs: + Build: + runs-on: ubuntu-latest + + env: + ADBLOCK: true + ASTRO_TELEMETRY_DISABLED: 1 + AUTOMATEDLAB_TELEMETRY_OPTOUT: 1 + AZURE_CORE_COLLECT_TELEMETRY: 0 + CHOOSENIM_NO_ANALYTICS: 1 + DIEZ_DO_NOT_TRACK: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT: 1 + DO_NOT_TRACK: 1 + ET_NO_TELEMETRY: 1 + GATSBY_TELEMETRY_DISABLED: 1 + GATSBY_TELEMETRY_OPTOUT: 1 + GATSBY_TELEMETRY_OPT_OUT: 1 + GRIT_TELEMETRY_DISABLED: 1 + HASURA_GRAPHQL_ENABLE_TELEMETRY: false + HINT_TELEMETRY: off + HOMEBREW_NO_ANALYTICS: 1 + INFLUXD_REPORTING_DISABLED: true + ITERATIVE_DO_NOT_TRACK: 1 + NEXT_TELEMETRY_DEBUG: 1 + NEXT_TELEMETRY_DISABLED: 1 + NG_CLI_ANALYTICS: false + NUXT_TELEMETRY_DISABLED: 1 + PIN_DO_NOT_TRACK: 1 + POWERSHELL_TELEMETRY_OPTOUT: 1 + SAM_CLI_TELEMETRY: 0 + STNOUPGRADE: 1 + STRIPE_CLI_TELEMETRY_OPTOUT: 1 + TELEMETRY_DISABLED: 1 + + strategy: + matrix: + toolchain: ["stable", "nightly"] + + steps: + - uses: actions/checkout@v4.1.2 + + - uses: actions-rs/toolchain@v1.0.7 + with: + profile: minimal + toolchain: ${{ matrix.toolchain }} + + - uses: actions/cache@v4.0.1 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + Target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.toml') }} + - uses: actions-rs/cargo@v1.0.3 + with: + command: build + args: --release --all-features --manifest-path ./Cargo.toml diff --git a/Source/api-iife.js b/Source/api-iife.js index 079ccde..e7ef9f3 100644 --- a/Source/api-iife.js +++ b/Source/api-iife.js @@ -1 +1,379 @@ -if("__TAURI__"in window){var __TAURI_PLUGIN_FS__=function(t){"use strict";function e(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function n(t,e,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(t,n):o?o.value=n:e.set(t,n),n}var i,o,r,s,a,c;"function"==typeof SuppressedError&&SuppressedError;class f{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,i.set(this,(()=>{})),o.set(this,0),r.set(this,{}),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((({message:t,id:s})=>{if(s===e(this,o,"f")){n(this,o,s+1,"f"),e(this,i,"f").call(this,t);const a=Object.keys(e(this,r,"f"));if(a.length>0){let t=s+1;for(const n of a.sort()){if(parseInt(n)!==t)break;{const o=e(this,r,"f")[n];delete e(this,r,"f")[n],e(this,i,"f").call(this,o),t+=1}}}}else e(this,r,"f")[s.toString()]=t}))}set onmessage(t){n(this,i,t,"f")}get onmessage(){return e(this,i,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function l(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}i=new WeakMap,o=new WeakMap,r=new WeakMap;class u{get rid(){return e(this,s,"f")}constructor(t){s.set(this,void 0),n(this,s,t,"f")}async close(){return l("plugin:resources|close",{rid:this.rid})}}function p(t){return{isFile:t.isFile,isDirectory:t.isDirectory,isSymlink:t.isSymlink,size:t.size,mtime:null!=t.mtime?new Date(t.mtime):null,atime:null!=t.atime?new Date(t.atime):null,birthtime:null!=t.birthtime?new Date(t.birthtime):null,readonly:t.readonly,fileAttributes:t.fileAttributes,dev:t.dev,ino:t.ino,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,blksize:t.blksize,blocks:t.blocks}}s=new WeakMap,t.BaseDirectory=void 0,(a=t.BaseDirectory||(t.BaseDirectory={}))[a.Audio=1]="Audio",a[a.Cache=2]="Cache",a[a.Config=3]="Config",a[a.Data=4]="Data",a[a.LocalData=5]="LocalData",a[a.Document=6]="Document",a[a.Download=7]="Download",a[a.Picture=8]="Picture",a[a.Public=9]="Public",a[a.Video=10]="Video",a[a.Resource=11]="Resource",a[a.Temp=12]="Temp",a[a.AppConfig=13]="AppConfig",a[a.AppData=14]="AppData",a[a.AppLocalData=15]="AppLocalData",a[a.AppCache=16]="AppCache",a[a.AppLog=17]="AppLog",a[a.Desktop=18]="Desktop",a[a.Executable=19]="Executable",a[a.Font=20]="Font",a[a.Home=21]="Home",a[a.Runtime=22]="Runtime",a[a.Template=23]="Template",t.SeekMode=void 0,(c=t.SeekMode||(t.SeekMode={}))[c.Start=0]="Start",c[c.Current=1]="Current",c[c.End=2]="End";class h extends u{constructor(t){super(t)}async read(t){if(0===t.byteLength)return 0;const[e,n]=await l("plugin:fs|read",{rid:this.rid,len:t.byteLength});return t.set(e),0===n?null:n}async seek(t,e){return l("plugin:fs|seek",{rid:this.rid,offset:t,whence:e})}async stat(){return p(await l("plugin:fs|fstat",{rid:this.rid}))}async truncate(t){return l("plugin:fs|ftruncate",{rid:this.rid,len:t})}async write(t){return l("plugin:fs|write",{rid:this.rid,data:Array.from(t)})}}async function w(t){await l("plugin:fs|unwatch",{rid:t})}return t.FileHandle=h,t.copyFile=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol||e instanceof URL&&"file:"!==e.protocol)throw new TypeError("Must be a file URL.");return l("plugin:fs|copy_file",{fromPath:t instanceof URL?t.toString():t,toPath:e instanceof URL?e.toString():e,options:n})},t.create=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const n=await l("plugin:fs|create",{path:t instanceof URL?t.toString():t,options:e});return new h(n)},t.exists=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");return l("plugin:fs|exists",{path:t instanceof URL?t.toString():t,options:e})},t.lstat=async function(t,e){return p(await l("plugin:fs|lstat",{path:t instanceof URL?t.toString():t,options:e}))},t.mkdir=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");return l("plugin:fs|mkdir",{path:t instanceof URL?t.toString():t,options:e})},t.open=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const n=await l("plugin:fs|open",{path:t instanceof URL?t.toString():t,options:e});return new h(n)},t.readDir=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");return l("plugin:fs|read_dir",{path:t instanceof URL?t.toString():t,options:e})},t.readFile=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const n=await l("plugin:fs|read_file",{path:t instanceof URL?t.toString():t,options:e});return Uint8Array.from(n)},t.readTextFile=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");return l("plugin:fs|read_text_file",{path:t instanceof URL?t.toString():t,options:e})},t.readTextFileLines=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const n=t instanceof URL?t.toString():t;return Promise.resolve({path:n,rid:null,async next(){this.rid||(this.rid=await l("plugin:fs|read_text_file_lines",{path:n,options:e}));const[t,i]=await l("plugin:fs|read_text_file_lines_next",{rid:this.rid});return i&&(this.rid=null),{value:i?"":t,done:i}},[Symbol.asyncIterator](){return this}})},t.remove=async function(t,e){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");return l("plugin:fs|remove",{path:t instanceof URL?t.toString():t,options:e})},t.rename=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol||e instanceof URL&&"file:"!==e.protocol)throw new TypeError("Must be a file URL.");return l("plugin:fs|rename",{oldPath:t instanceof URL?t.toString():t,newPath:e instanceof URL?e.toString():e,options:n})},t.stat=async function(t,e){return p(await l("plugin:fs|stat",{path:t instanceof URL?t.toString():t,options:e}))},t.truncate=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");return l("plugin:fs|truncate",{path:t instanceof URL?t.toString():t,len:e,options:n})},t.watch=async function(t,e,n){const i={recursive:!1,delayMs:2e3,...n},o=Array.isArray(t)?t:[t];for(const t of o)if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const r=new f;r.onmessage=e;const s=await l("plugin:fs|watch",{paths:o.map((t=>t instanceof URL?t.toString():t)),options:i,onEvent:r});return()=>{w(s)}},t.watchImmediate=async function(t,e,n){const i={recursive:!1,...n,delayMs:null},o=Array.isArray(t)?t:[t];for(const t of o)if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");const r=new f;r.onmessage=e;const s=await l("plugin:fs|watch",{paths:o.map((t=>t instanceof URL?t.toString():t)),options:i,onEvent:r});return()=>{w(s)}},t.writeFile=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");return l("plugin:fs|write_file",{path:t instanceof URL?t.toString():t,data:Array.from(e),options:n})},t.writeTextFile=async function(t,e,n){if(t instanceof URL&&"file:"!==t.protocol)throw new TypeError("Must be a file URL.");return l("plugin:fs|write_text_file",{path:t instanceof URL?t.toString():t,data:e,options:n})},t}({});Object.defineProperty(window.__TAURI__,"fs",{value:__TAURI_PLUGIN_FS__})} +if ("__TAURI__" in window) { + var __TAURI_PLUGIN_FS__ = ((t) => { + function e(t, e, n, i) { + if ("a" === n && !i) + throw new TypeError( + "Private accessor was defined without a getter", + ); + if ("function" == typeof e ? t !== e || !i : !e.has(t)) + throw new TypeError( + "Cannot read private member from an object whose class did not declare it", + ); + return "m" === n + ? i + : "a" === n + ? i.call(t) + : i + ? i.value + : e.get(t); + } + function n(t, e, n, i, o) { + if ("m" === i) + throw new TypeError("Private method is not writable"); + if ("a" === i && !o) + throw new TypeError( + "Private accessor was defined without a setter", + ); + if ("function" == typeof e ? t !== e || !o : !e.has(t)) + throw new TypeError( + "Cannot write private member to an object whose class did not declare it", + ); + return ( + "a" === i ? o.call(t, n) : o ? (o.value = n) : e.set(t, n), n + ); + } + var i, o, r, s, a, c; + "function" == typeof SuppressedError && SuppressedError; + class f { + constructor() { + (this.__TAURI_CHANNEL_MARKER__ = !0), + i.set(this, () => {}), + o.set(this, 0), + r.set(this, {}), + (this.id = ((t, e = !1) => + window.__TAURI_INTERNALS__.transformCallback(t, e))( + ({ message: t, id: s }) => { + if (s === e(this, o, "f")) { + n(this, o, s + 1, "f"), + e(this, i, "f").call(this, t); + const a = Object.keys(e(this, r, "f")); + if (a.length > 0) { + let t = s + 1; + for (const n of a.sort()) { + if (Number.parseInt(n) !== t) break; + { + const o = e(this, r, "f")[n]; + delete e(this, r, "f")[n], + e(this, i, "f").call(this, o), + (t += 1); + } + } + } + } else e(this, r, "f")[s.toString()] = t; + }, + )); + } + set onmessage(t) { + n(this, i, t, "f"); + } + get onmessage() { + return e(this, i, "f"); + } + toJSON() { + return `__CHANNEL__:${this.id}`; + } + } + async function l(t, e = {}, n) { + return window.__TAURI_INTERNALS__.invoke(t, e, n); + } + (i = new WeakMap()), (o = new WeakMap()), (r = new WeakMap()); + class u { + get rid() { + return e(this, s, "f"); + } + constructor(t) { + s.set(this, void 0), n(this, s, t, "f"); + } + async close() { + return l("plugin:resources|close", { rid: this.rid }); + } + } + function p(t) { + return { + isFile: t.isFile, + isDirectory: t.isDirectory, + isSymlink: t.isSymlink, + size: t.size, + mtime: null != t.mtime ? new Date(t.mtime) : null, + atime: null != t.atime ? new Date(t.atime) : null, + birthtime: null != t.birthtime ? new Date(t.birthtime) : null, + readonly: t.readonly, + fileAttributes: t.fileAttributes, + dev: t.dev, + ino: t.ino, + mode: t.mode, + nlink: t.nlink, + uid: t.uid, + gid: t.gid, + rdev: t.rdev, + blksize: t.blksize, + blocks: t.blocks, + }; + } + (s = new WeakMap()), + (t.BaseDirectory = void 0), + ((a = t.BaseDirectory || (t.BaseDirectory = {}))[(a.Audio = 1)] = + "Audio"), + (a[(a.Cache = 2)] = "Cache"), + (a[(a.Config = 3)] = "Config"), + (a[(a.Data = 4)] = "Data"), + (a[(a.LocalData = 5)] = "LocalData"), + (a[(a.Document = 6)] = "Document"), + (a[(a.Download = 7)] = "Download"), + (a[(a.Picture = 8)] = "Picture"), + (a[(a.Public = 9)] = "Public"), + (a[(a.Video = 10)] = "Video"), + (a[(a.Resource = 11)] = "Resource"), + (a[(a.Temp = 12)] = "Temp"), + (a[(a.AppConfig = 13)] = "AppConfig"), + (a[(a.AppData = 14)] = "AppData"), + (a[(a.AppLocalData = 15)] = "AppLocalData"), + (a[(a.AppCache = 16)] = "AppCache"), + (a[(a.AppLog = 17)] = "AppLog"), + (a[(a.Desktop = 18)] = "Desktop"), + (a[(a.Executable = 19)] = "Executable"), + (a[(a.Font = 20)] = "Font"), + (a[(a.Home = 21)] = "Home"), + (a[(a.Runtime = 22)] = "Runtime"), + (a[(a.Template = 23)] = "Template"), + (t.SeekMode = void 0), + ((c = t.SeekMode || (t.SeekMode = {}))[(c.Start = 0)] = "Start"), + (c[(c.Current = 1)] = "Current"), + (c[(c.End = 2)] = "End"); + class h extends u { + constructor(t) { + super(t); + } + async read(t) { + if (0 === t.byteLength) return 0; + const [e, n] = await l("plugin:fs|read", { + rid: this.rid, + len: t.byteLength, + }); + return t.set(e), 0 === n ? null : n; + } + async seek(t, e) { + return l("plugin:fs|seek", { + rid: this.rid, + offset: t, + whence: e, + }); + } + async stat() { + return p(await l("plugin:fs|fstat", { rid: this.rid })); + } + async truncate(t) { + return l("plugin:fs|ftruncate", { rid: this.rid, len: t }); + } + async write(t) { + return l("plugin:fs|write", { + rid: this.rid, + data: Array.from(t), + }); + } + } + async function w(t) { + await l("plugin:fs|unwatch", { rid: t }); + } + return ( + (t.FileHandle = h), + (t.copyFile = async (t, e, n) => { + if ( + (t instanceof URL && "file:" !== t.protocol) || + (e instanceof URL && "file:" !== e.protocol) + ) + throw new TypeError("Must be a file URL."); + return l("plugin:fs|copy_file", { + fromPath: t instanceof URL ? t.toString() : t, + toPath: e instanceof URL ? e.toString() : e, + options: n, + }); + }), + (t.create = async (t, e) => { + if (t instanceof URL && "file:" !== t.protocol) + throw new TypeError("Must be a file URL."); + const n = await l("plugin:fs|create", { + path: t instanceof URL ? t.toString() : t, + options: e, + }); + return new h(n); + }), + (t.exists = async (t, e) => { + if (t instanceof URL && "file:" !== t.protocol) + throw new TypeError("Must be a file URL."); + return l("plugin:fs|exists", { + path: t instanceof URL ? t.toString() : t, + options: e, + }); + }), + (t.lstat = async (t, e) => + p( + await l("plugin:fs|lstat", { + path: t instanceof URL ? t.toString() : t, + options: e, + }), + )), + (t.mkdir = async (t, e) => { + if (t instanceof URL && "file:" !== t.protocol) + throw new TypeError("Must be a file URL."); + return l("plugin:fs|mkdir", { + path: t instanceof URL ? t.toString() : t, + options: e, + }); + }), + (t.open = async (t, e) => { + if (t instanceof URL && "file:" !== t.protocol) + throw new TypeError("Must be a file URL."); + const n = await l("plugin:fs|open", { + path: t instanceof URL ? t.toString() : t, + options: e, + }); + return new h(n); + }), + (t.readDir = async (t, e) => { + if (t instanceof URL && "file:" !== t.protocol) + throw new TypeError("Must be a file URL."); + return l("plugin:fs|read_dir", { + path: t instanceof URL ? t.toString() : t, + options: e, + }); + }), + (t.readFile = async (t, e) => { + if (t instanceof URL && "file:" !== t.protocol) + throw new TypeError("Must be a file URL."); + const n = await l("plugin:fs|read_file", { + path: t instanceof URL ? t.toString() : t, + options: e, + }); + return Uint8Array.from(n); + }), + (t.readTextFile = async (t, e) => { + if (t instanceof URL && "file:" !== t.protocol) + throw new TypeError("Must be a file URL."); + return l("plugin:fs|read_text_file", { + path: t instanceof URL ? t.toString() : t, + options: e, + }); + }), + (t.readTextFileLines = async (t, e) => { + if (t instanceof URL && "file:" !== t.protocol) + throw new TypeError("Must be a file URL."); + const n = t instanceof URL ? t.toString() : t; + return Promise.resolve({ + path: n, + rid: null, + async next() { + this.rid || + (this.rid = await l( + "plugin:fs|read_text_file_lines", + { path: n, options: e }, + )); + const [t, i] = await l( + "plugin:fs|read_text_file_lines_next", + { rid: this.rid }, + ); + return ( + i && (this.rid = null), + { value: i ? "" : t, done: i } + ); + }, + [Symbol.asyncIterator]() { + return this; + }, + }); + }), + (t.remove = async (t, e) => { + if (t instanceof URL && "file:" !== t.protocol) + throw new TypeError("Must be a file URL."); + return l("plugin:fs|remove", { + path: t instanceof URL ? t.toString() : t, + options: e, + }); + }), + (t.rename = async (t, e, n) => { + if ( + (t instanceof URL && "file:" !== t.protocol) || + (e instanceof URL && "file:" !== e.protocol) + ) + throw new TypeError("Must be a file URL."); + return l("plugin:fs|rename", { + oldPath: t instanceof URL ? t.toString() : t, + newPath: e instanceof URL ? e.toString() : e, + options: n, + }); + }), + (t.stat = async (t, e) => + p( + await l("plugin:fs|stat", { + path: t instanceof URL ? t.toString() : t, + options: e, + }), + )), + (t.truncate = async (t, e, n) => { + if (t instanceof URL && "file:" !== t.protocol) + throw new TypeError("Must be a file URL."); + return l("plugin:fs|truncate", { + path: t instanceof URL ? t.toString() : t, + len: e, + options: n, + }); + }), + (t.watch = async (t, e, n) => { + const i = { recursive: !1, delayMs: 2e3, ...n }, + o = Array.isArray(t) ? t : [t]; + for (const t of o) + if (t instanceof URL && "file:" !== t.protocol) + throw new TypeError("Must be a file URL."); + const r = new f(); + r.onmessage = e; + const s = await l("plugin:fs|watch", { + paths: o.map((t) => (t instanceof URL ? t.toString() : t)), + options: i, + onEvent: r, + }); + return () => { + w(s); + }; + }), + (t.watchImmediate = async (t, e, n) => { + const i = { recursive: !1, ...n, delayMs: null }, + o = Array.isArray(t) ? t : [t]; + for (const t of o) + if (t instanceof URL && "file:" !== t.protocol) + throw new TypeError("Must be a file URL."); + const r = new f(); + r.onmessage = e; + const s = await l("plugin:fs|watch", { + paths: o.map((t) => (t instanceof URL ? t.toString() : t)), + options: i, + onEvent: r, + }); + return () => { + w(s); + }; + }), + (t.writeFile = async (t, e, n) => { + if (t instanceof URL && "file:" !== t.protocol) + throw new TypeError("Must be a file URL."); + return l("plugin:fs|write_file", { + path: t instanceof URL ? t.toString() : t, + data: Array.from(e), + options: n, + }); + }), + (t.writeTextFile = async (t, e, n) => { + if (t instanceof URL && "file:" !== t.protocol) + throw new TypeError("Must be a file URL."); + return l("plugin:fs|write_text_file", { + path: t instanceof URL ? t.toString() : t, + data: e, + options: n, + }); + }), + t + ); + })({}); + Object.defineProperty(window.__TAURI__, "fs", { + value: __TAURI_PLUGIN_FS__, + }); +} diff --git a/dist-js/index.cjs b/dist-js/index.cjs index 017e25d..b61bbdc 100644 --- a/dist-js/index.cjs +++ b/dist-js/index.cjs @@ -1,7 +1,7 @@ -'use strict'; +"use strict"; -var path = require('@tauri-apps/api/path'); -var core = require('@tauri-apps/api/core'); +var path = require("@tauri-apps/api/path"); +var core = require("@tauri-apps/api/core"); // Copyright 2019-2023 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 @@ -65,32 +65,32 @@ var core = require('@tauri-apps/api/core'); * @module */ exports.SeekMode = void 0; -(function (SeekMode) { - SeekMode[SeekMode["Start"] = 0] = "Start"; - SeekMode[SeekMode["Current"] = 1] = "Current"; - SeekMode[SeekMode["End"] = 2] = "End"; +((SeekMode) => { + SeekMode[(SeekMode["Start"] = 0)] = "Start"; + SeekMode[(SeekMode["Current"] = 1)] = "Current"; + SeekMode[(SeekMode["End"] = 2)] = "End"; })(exports.SeekMode || (exports.SeekMode = {})); function parseFileInfo(r) { - return { - isFile: r.isFile, - isDirectory: r.isDirectory, - isSymlink: r.isSymlink, - size: r.size, - mtime: r.mtime != null ? new Date(r.mtime) : null, - atime: r.atime != null ? new Date(r.atime) : null, - birthtime: r.birthtime != null ? new Date(r.birthtime) : null, - readonly: r.readonly, - fileAttributes: r.fileAttributes, - dev: r.dev, - ino: r.ino, - mode: r.mode, - nlink: r.nlink, - uid: r.uid, - gid: r.gid, - rdev: r.rdev, - blksize: r.blksize, - blocks: r.blocks, - }; + return { + isFile: r.isFile, + isDirectory: r.isDirectory, + isSymlink: r.isSymlink, + size: r.size, + mtime: r.mtime != null ? new Date(r.mtime) : null, + atime: r.atime != null ? new Date(r.atime) : null, + birthtime: r.birthtime != null ? new Date(r.birthtime) : null, + readonly: r.readonly, + fileAttributes: r.fileAttributes, + dev: r.dev, + ino: r.ino, + mode: r.mode, + nlink: r.nlink, + uid: r.uid, + gid: r.gid, + rdev: r.rdev, + blksize: r.blksize, + blocks: r.blocks, + }; } /** * The Tauri abstraction for reading and writing files. @@ -98,162 +98,162 @@ function parseFileInfo(r) { * @since 2.0.0 */ class FileHandle extends core.Resource { - constructor(rid) { - super(rid); - } - /** - * Reads up to `p.byteLength` bytes into `p`. It resolves to the number of - * bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error - * encountered. Even if `read()` resolves to `n` < `p.byteLength`, it may - * use all of `p` as scratch space during the call. If some data is - * available but not `p.byteLength` bytes, `read()` conventionally resolves - * to what is available instead of waiting for more. - * - * When `read()` encounters end-of-file condition, it resolves to EOF - * (`null`). - * - * When `read()` encounters an error, it rejects with an error. - * - * Callers should always process the `n` > `0` bytes returned before - * considering the EOF (`null`). Doing so correctly handles I/O errors that - * happen after reading some bytes and also both of the allowed EOF - * behaviors. - * - * @example - * ```typescript - * import { open, read, close, BaseDirectory } from "@tauri-apps/plugin-fs" - * // if "$APP/foo/bar.txt" contains the text "hello world": - * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.App }); - * const buf = new Uint8Array(100); - * const numberOfBytesRead = await file.read(buf); // 11 bytes - * const text = new TextDecoder().decode(buf); // "hello world" - * await close(file.rid); - * ``` - * - * @since 2.0.0 - */ - async read(buffer) { - if (buffer.byteLength === 0) { - return 0; - } - const [data, nread] = await core.invoke("plugin:fs|read", { - rid: this.rid, - len: buffer.byteLength, - }); - buffer.set(data); - return nread === 0 ? null : nread; - } - /** - * Seek sets the offset for the next `read()` or `write()` to offset, - * interpreted according to `whence`: `Start` means relative to the - * start of the file, `Current` means relative to the current offset, - * and `End` means relative to the end. Seek resolves to the new offset - * relative to the start of the file. - * - * Seeking to an offset before the start of the file is an error. Seeking to - * any positive offset is legal, but the behavior of subsequent I/O - * operations on the underlying object is implementation-dependent. - * It returns the number of cursor position. - * - * @example - * ```typescript - * import { open, seek, write, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs'; - * - * // Given hello.txt pointing to file with "Hello world", which is 11 bytes long: - * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.App }); - * await file.write(new TextEncoder().encode("Hello world"), { baseDir: BaseDirectory.App }); - * - * // Seek 6 bytes from the start of the file - * console.log(await file.seek(6, SeekMode.Start)); // "6" - * // Seek 2 more bytes from the current position - * console.log(await file.seek(2, SeekMode.Current)); // "8" - * // Seek backwards 2 bytes from the end of the file - * console.log(await file.seek(-2, SeekMode.End)); // "9" (e.g. 11-2) - * ``` - * - * @since 2.0.0 - */ - async seek(offset, whence) { - return core.invoke("plugin:fs|seek", { - rid: this.rid, - offset, - whence, - }); - } - /** - * Returns a {@linkcode FileInfo } for this file. - * - * @example - * ```typescript - * import { open, fstat, BaseDirectory } from '@tauri-apps/plugin-fs'; - * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.App }); - * const fileInfo = await fstat(file.rid); - * console.log(fileInfo.isFile); // true - * ``` - * - * @since 2.0.0 - */ - async stat() { - const res = await core.invoke("plugin:fs|fstat", { - rid: this.rid, - }); - return parseFileInfo(res); - } - /** - * Truncates or extends this file, to reach the specified `len`. - * If `len` is not specified then the entire file contents are truncated. - * - * @example - * ```typescript - * import { ftruncate, open, write, read, BaseDirectory } from '@tauri-apps/plugin-fs'; - * - * // truncate the entire file - * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); - * await ftruncate(file.rid); - * - * // truncate part of the file - * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); - * await write(file.rid, new TextEncoder().encode("Hello World")); - * await ftruncate(file.rid, 7); - * const data = new Uint8Array(32); - * await read(file.rid, data); - * console.log(new TextDecoder().decode(data)); // Hello W - * ``` - * - * @since 2.0.0 - */ - async truncate(len) { - return core.invoke("plugin:fs|ftruncate", { - rid: this.rid, - len, - }); - } - /** - * Writes `p.byteLength` bytes from `p` to the underlying data stream. It - * resolves to the number of bytes written from `p` (`0` <= `n` <= - * `p.byteLength`) or reject with the error encountered that caused the - * write to stop early. `write()` must reject with a non-null error if - * would resolve to `n` < `p.byteLength`. `write()` must not modify the - * slice data, even temporarily. - * - * @example - * ```typescript - * import { open, write, close, BaseDirectory } from '@tauri-apps/plugin-fs'; - * const encoder = new TextEncoder(); - * const data = encoder.encode("Hello world"); - * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.App }); - * const bytesWritten = await write(file.rid, data); // 11 - * await close(file.rid); - * ``` - * - * @since 2.0.0 - */ - async write(data) { - return core.invoke("plugin:fs|write", { - rid: this.rid, - data: Array.from(data), - }); - } + constructor(rid) { + super(rid); + } + /** + * Reads up to `p.byteLength` bytes into `p`. It resolves to the number of + * bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error + * encountered. Even if `read()` resolves to `n` < `p.byteLength`, it may + * use all of `p` as scratch space during the call. If some data is + * available but not `p.byteLength` bytes, `read()` conventionally resolves + * to what is available instead of waiting for more. + * + * When `read()` encounters end-of-file condition, it resolves to EOF + * (`null`). + * + * When `read()` encounters an error, it rejects with an error. + * + * Callers should always process the `n` > `0` bytes returned before + * considering the EOF (`null`). Doing so correctly handles I/O errors that + * happen after reading some bytes and also both of the allowed EOF + * behaviors. + * + * @example + * ```typescript + * import { open, read, close, BaseDirectory } from "@tauri-apps/plugin-fs" + * // if "$APP/foo/bar.txt" contains the text "hello world": + * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.App }); + * const buf = new Uint8Array(100); + * const numberOfBytesRead = await file.read(buf); // 11 bytes + * const text = new TextDecoder().decode(buf); // "hello world" + * await close(file.rid); + * ``` + * + * @since 2.0.0 + */ + async read(buffer) { + if (buffer.byteLength === 0) { + return 0; + } + const [data, nread] = await core.invoke("plugin:fs|read", { + rid: this.rid, + len: buffer.byteLength, + }); + buffer.set(data); + return nread === 0 ? null : nread; + } + /** + * Seek sets the offset for the next `read()` or `write()` to offset, + * interpreted according to `whence`: `Start` means relative to the + * start of the file, `Current` means relative to the current offset, + * and `End` means relative to the end. Seek resolves to the new offset + * relative to the start of the file. + * + * Seeking to an offset before the start of the file is an error. Seeking to + * any positive offset is legal, but the behavior of subsequent I/O + * operations on the underlying object is implementation-dependent. + * It returns the number of cursor position. + * + * @example + * ```typescript + * import { open, seek, write, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs'; + * + * // Given hello.txt pointing to file with "Hello world", which is 11 bytes long: + * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.App }); + * await file.write(new TextEncoder().encode("Hello world"), { baseDir: BaseDirectory.App }); + * + * // Seek 6 bytes from the start of the file + * console.log(await file.seek(6, SeekMode.Start)); // "6" + * // Seek 2 more bytes from the current position + * console.log(await file.seek(2, SeekMode.Current)); // "8" + * // Seek backwards 2 bytes from the end of the file + * console.log(await file.seek(-2, SeekMode.End)); // "9" (e.g. 11-2) + * ``` + * + * @since 2.0.0 + */ + async seek(offset, whence) { + return core.invoke("plugin:fs|seek", { + rid: this.rid, + offset, + whence, + }); + } + /** + * Returns a {@linkcode FileInfo } for this file. + * + * @example + * ```typescript + * import { open, fstat, BaseDirectory } from '@tauri-apps/plugin-fs'; + * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.App }); + * const fileInfo = await fstat(file.rid); + * console.log(fileInfo.isFile); // true + * ``` + * + * @since 2.0.0 + */ + async stat() { + const res = await core.invoke("plugin:fs|fstat", { + rid: this.rid, + }); + return parseFileInfo(res); + } + /** + * Truncates or extends this file, to reach the specified `len`. + * If `len` is not specified then the entire file contents are truncated. + * + * @example + * ```typescript + * import { ftruncate, open, write, read, BaseDirectory } from '@tauri-apps/plugin-fs'; + * + * // truncate the entire file + * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); + * await ftruncate(file.rid); + * + * // truncate part of the file + * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); + * await write(file.rid, new TextEncoder().encode("Hello World")); + * await ftruncate(file.rid, 7); + * const data = new Uint8Array(32); + * await read(file.rid, data); + * console.log(new TextDecoder().decode(data)); // Hello W + * ``` + * + * @since 2.0.0 + */ + async truncate(len) { + return core.invoke("plugin:fs|ftruncate", { + rid: this.rid, + len, + }); + } + /** + * Writes `p.byteLength` bytes from `p` to the underlying data stream. It + * resolves to the number of bytes written from `p` (`0` <= `n` <= + * `p.byteLength`) or reject with the error encountered that caused the + * write to stop early. `write()` must reject with a non-null error if + * would resolve to `n` < `p.byteLength`. `write()` must not modify the + * slice data, even temporarily. + * + * @example + * ```typescript + * import { open, write, close, BaseDirectory } from '@tauri-apps/plugin-fs'; + * const encoder = new TextEncoder(); + * const data = encoder.encode("Hello world"); + * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.App }); + * const bytesWritten = await write(file.rid, data); // 11 + * await close(file.rid); + * ``` + * + * @since 2.0.0 + */ + async write(data) { + return core.invoke("plugin:fs|write", { + rid: this.rid, + data: Array.from(data), + }); + } } /** * Creates a file if none exists or truncates an existing file and resolves to @@ -268,14 +268,14 @@ class FileHandle extends core.Resource { * @since 2.0.0 */ async function create(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - const rid = await core.invoke("plugin:fs|create", { - path: path instanceof URL ? path.toString() : path, - options, - }); - return new FileHandle(rid); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + const rid = await core.invoke("plugin:fs|create", { + path: path instanceof URL ? path.toString() : path, + options, + }); + return new FileHandle(rid); } /** * Open a file and resolve to an instance of {@linkcode FileHandle}. The @@ -294,14 +294,14 @@ async function create(path, options) { * @since 2.0.0 */ async function open(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - const rid = await core.invoke("plugin:fs|open", { - path: path instanceof URL ? path.toString() : path, - options, - }); - return new FileHandle(rid); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + const rid = await core.invoke("plugin:fs|open", { + path: path instanceof URL ? path.toString() : path, + options, + }); + return new FileHandle(rid); } /** * Copies the contents and permissions of one file to another specified path, by default creating a new file if needed, else overwriting. @@ -314,15 +314,17 @@ async function open(path, options) { * @since 2.0.0 */ async function copyFile(fromPath, toPath, options) { - if ((fromPath instanceof URL && fromPath.protocol !== "file:") || - (toPath instanceof URL && toPath.protocol !== "file:")) { - throw new TypeError("Must be a file URL."); - } - return core.invoke("plugin:fs|copy_file", { - fromPath: fromPath instanceof URL ? fromPath.toString() : fromPath, - toPath: toPath instanceof URL ? toPath.toString() : toPath, - options, - }); + if ( + (fromPath instanceof URL && fromPath.protocol !== "file:") || + (toPath instanceof URL && toPath.protocol !== "file:") + ) { + throw new TypeError("Must be a file URL."); + } + return core.invoke("plugin:fs|copy_file", { + fromPath: fromPath instanceof URL ? fromPath.toString() : fromPath, + toPath: toPath instanceof URL ? toPath.toString() : toPath, + options, + }); } /** * Creates a new directory with the specified path. @@ -335,13 +337,13 @@ async function copyFile(fromPath, toPath, options) { * @since 2.0.0 */ async function mkdir(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return core.invoke("plugin:fs|mkdir", { - path: path instanceof URL ? path.toString() : path, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return core.invoke("plugin:fs|mkdir", { + path: path instanceof URL ? path.toString() : path, + options, + }); } /** * Reads the directory given by path and returns an array of `DirEntry`. @@ -365,13 +367,13 @@ async function mkdir(path, options) { * @since 2.0.0 */ async function readDir(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return core.invoke("plugin:fs|read_dir", { - path: path instanceof URL ? path.toString() : path, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return core.invoke("plugin:fs|read_dir", { + path: path instanceof URL ? path.toString() : path, + options, + }); } /** * Reads and resolves to the entire contents of a file as an array of bytes. @@ -385,14 +387,14 @@ async function readDir(path, options) { * @since 2.0.0 */ async function readFile(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - const arr = await core.invoke("plugin:fs|read_file", { - path: path instanceof URL ? path.toString() : path, - options, - }); - return Uint8Array.from(arr); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + const arr = await core.invoke("plugin:fs|read_file", { + path: path instanceof URL ? path.toString() : path, + options, + }); + return Uint8Array.from(arr); } /** * Reads and returns the entire contents of a file as UTF-8 string. @@ -405,13 +407,13 @@ async function readFile(path, options) { * @since 2.0.0 */ async function readTextFile(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return core.invoke("plugin:fs|read_text_file", { - path: path instanceof URL ? path.toString() : path, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return core.invoke("plugin:fs|read_text_file", { + path: path instanceof URL ? path.toString() : path, + options, + }); } /** * Returns an async {@linkcode AsyncIterableIterator} over the lines of a file as UTF-8 string. @@ -429,33 +431,35 @@ async function readTextFile(path, options) { * @since 2.0.0 */ async function readTextFileLines(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - const pathStr = path instanceof URL ? path.toString() : path; - return Promise.resolve({ - path: pathStr, - rid: null, - async next() { - if (!this.rid) { - this.rid = await core.invoke("plugin:fs|read_text_file_lines", { - path: pathStr, - options, - }); - } - const [line, done] = await core.invoke("plugin:fs|read_text_file_lines_next", { rid: this.rid }); - // an iteration is over, reset rid for next iteration - if (done) - this.rid = null; - return { - value: done ? "" : line, - done, - }; - }, - [Symbol.asyncIterator]() { - return this; - }, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + const pathStr = path instanceof URL ? path.toString() : path; + return Promise.resolve({ + path: pathStr, + rid: null, + async next() { + if (!this.rid) { + this.rid = await core.invoke("plugin:fs|read_text_file_lines", { + path: pathStr, + options, + }); + } + const [line, done] = await core.invoke( + "plugin:fs|read_text_file_lines_next", + { rid: this.rid }, + ); + // an iteration is over, reset rid for next iteration + if (done) this.rid = null; + return { + value: done ? "" : line, + done, + }; + }, + [Symbol.asyncIterator]() { + return this; + }, + }); } /** * Removes the named file or directory. @@ -470,13 +474,13 @@ async function readTextFileLines(path, options) { * @since 2.0.0 */ async function remove(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return core.invoke("plugin:fs|remove", { - path: path instanceof URL ? path.toString() : path, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return core.invoke("plugin:fs|remove", { + path: path instanceof URL ? path.toString() : path, + options, + }); } /** * Renames (moves) oldpath to newpath. Paths may be files or directories. @@ -494,15 +498,17 @@ async function remove(path, options) { * @since 2.0.0 */ async function rename(oldPath, newPath, options) { - if ((oldPath instanceof URL && oldPath.protocol !== "file:") || - (newPath instanceof URL && newPath.protocol !== "file:")) { - throw new TypeError("Must be a file URL."); - } - return core.invoke("plugin:fs|rename", { - oldPath: oldPath instanceof URL ? oldPath.toString() : oldPath, - newPath: newPath instanceof URL ? newPath.toString() : newPath, - options, - }); + if ( + (oldPath instanceof URL && oldPath.protocol !== "file:") || + (newPath instanceof URL && newPath.protocol !== "file:") + ) { + throw new TypeError("Must be a file URL."); + } + return core.invoke("plugin:fs|rename", { + oldPath: oldPath instanceof URL ? oldPath.toString() : oldPath, + newPath: newPath instanceof URL ? newPath.toString() : newPath, + options, + }); } /** * Resolves to a {@linkcode FileInfo} for the specified `path`. Will always @@ -518,11 +524,11 @@ async function rename(oldPath, newPath, options) { * @since 2.0.0 */ async function stat(path, options) { - const res = await core.invoke("plugin:fs|stat", { - path: path instanceof URL ? path.toString() : path, - options, - }); - return parseFileInfo(res); + const res = await core.invoke("plugin:fs|stat", { + path: path instanceof URL ? path.toString() : path, + options, + }); + return parseFileInfo(res); } /** * Resolves to a {@linkcode FileInfo} for the specified `path`. If `path` is a @@ -539,11 +545,11 @@ async function stat(path, options) { * @since 2.0.0 */ async function lstat(path, options) { - const res = await core.invoke("plugin:fs|lstat", { - path: path instanceof URL ? path.toString() : path, - options, - }); - return parseFileInfo(res); + const res = await core.invoke("plugin:fs|lstat", { + path: path instanceof URL ? path.toString() : path, + options, + }); + return parseFileInfo(res); } /** * Truncates or extends the specified file, to reach the specified `len`. @@ -566,14 +572,14 @@ async function lstat(path, options) { * @since 2.0.0 */ async function truncate(path, len, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return core.invoke("plugin:fs|truncate", { - path: path instanceof URL ? path.toString() : path, - len, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return core.invoke("plugin:fs|truncate", { + path: path instanceof URL ? path.toString() : path, + len, + options, + }); } /** * Write `data` to the given `path`, by default creating a new file if needed, else overwriting. @@ -589,14 +595,14 @@ async function truncate(path, len, options) { * @since 2.0.0 */ async function writeFile(path, data, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return core.invoke("plugin:fs|write_file", { - path: path instanceof URL ? path.toString() : path, - data: Array.from(data), - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return core.invoke("plugin:fs|write_file", { + path: path instanceof URL ? path.toString() : path, + data: Array.from(data), + options, + }); } /** * Writes UTF-8 string `data` to the given `path`, by default creating a new file if needed, else overwriting. @@ -610,14 +616,14 @@ async function writeFile(path, data, options) { * @since 2.0.0 */ async function writeTextFile(path, data, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return core.invoke("plugin:fs|write_text_file", { - path: path instanceof URL ? path.toString() : path, - data, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return core.invoke("plugin:fs|write_text_file", { + path: path instanceof URL ? path.toString() : path, + data, + options, + }); } /** * Check if a path exists. @@ -631,16 +637,16 @@ async function writeTextFile(path, data, options) { * @since 2.0.0 */ async function exists(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return core.invoke("plugin:fs|exists", { - path: path instanceof URL ? path.toString() : path, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return core.invoke("plugin:fs|exists", { + path: path instanceof URL ? path.toString() : path, + options, + }); } async function unwatch(rid) { - await core.invoke("plugin:fs|unwatch", { rid }); + await core.invoke("plugin:fs|unwatch", { rid }); } /** * Watch changes (after a delay) on files or directories. @@ -648,27 +654,27 @@ async function unwatch(rid) { * @since 2.0.0 */ async function watch(paths, cb, options) { - const opts = { - recursive: false, - delayMs: 2000, - ...options, - }; - const watchPaths = Array.isArray(paths) ? paths : [paths]; - for (const path of watchPaths) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - } - const onEvent = new core.Channel(); - onEvent.onmessage = cb; - const rid = await core.invoke("plugin:fs|watch", { - paths: watchPaths.map((p) => (p instanceof URL ? p.toString() : p)), - options: opts, - onEvent, - }); - return () => { - void unwatch(rid); - }; + const opts = { + recursive: false, + delayMs: 2000, + ...options, + }; + const watchPaths = Array.isArray(paths) ? paths : [paths]; + for (const path of watchPaths) { + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + } + const onEvent = new core.Channel(); + onEvent.onmessage = cb; + const rid = await core.invoke("plugin:fs|watch", { + paths: watchPaths.map((p) => (p instanceof URL ? p.toString() : p)), + options: opts, + onEvent, + }); + return () => { + void unwatch(rid); + }; } /** * Watch changes on files or directories. @@ -676,32 +682,32 @@ async function watch(paths, cb, options) { * @since 2.0.0 */ async function watchImmediate(paths, cb, options) { - const opts = { - recursive: false, - ...options, - delayMs: null, - }; - const watchPaths = Array.isArray(paths) ? paths : [paths]; - for (const path of watchPaths) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - } - const onEvent = new core.Channel(); - onEvent.onmessage = cb; - const rid = await core.invoke("plugin:fs|watch", { - paths: watchPaths.map((p) => (p instanceof URL ? p.toString() : p)), - options: opts, - onEvent, - }); - return () => { - void unwatch(rid); - }; + const opts = { + recursive: false, + ...options, + delayMs: null, + }; + const watchPaths = Array.isArray(paths) ? paths : [paths]; + for (const path of watchPaths) { + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + } + const onEvent = new core.Channel(); + onEvent.onmessage = cb; + const rid = await core.invoke("plugin:fs|watch", { + paths: watchPaths.map((p) => (p instanceof URL ? p.toString() : p)), + options: opts, + onEvent, + }); + return () => { + void unwatch(rid); + }; } Object.defineProperty(exports, "BaseDirectory", { - enumerable: true, - get: function () { return path.BaseDirectory; } + enumerable: true, + get: () => path.BaseDirectory, }); exports.FileHandle = FileHandle; exports.copyFile = copyFile; diff --git a/dist-js/index.d.ts b/dist-js/index.d.ts index 2c4abe6..604d42b 100644 --- a/dist-js/index.d.ts +++ b/dist-js/index.d.ts @@ -1,3 +1,4 @@ +import { Resource } from "@tauri-apps/api/core"; /** * Access the file system. * @@ -57,11 +58,10 @@ * @module */ import { BaseDirectory } from "@tauri-apps/api/path"; -import { Resource } from "@tauri-apps/api/core"; declare enum SeekMode { - Start = 0, - Current = 1, - End = 2 + Start = 0, + Current = 1, + End = 2, } /** * A FileInfo describes a file and is returned by `stat`, `lstat` or `fstat`. @@ -69,128 +69,128 @@ declare enum SeekMode { * @since 2.0.0 */ interface FileInfo { - /** - * True if this is info for a regular file. Mutually exclusive to - * `FileInfo.isDirectory` and `FileInfo.isSymlink`. - */ - isFile: boolean; - /** - * True if this is info for a regular directory. Mutually exclusive to - * `FileInfo.isFile` and `FileInfo.isSymlink`. - */ - isDirectory: boolean; - /** - * True if this is info for a symlink. Mutually exclusive to - * `FileInfo.isFile` and `FileInfo.isDirectory`. - */ - isSymlink: boolean; - /** - * The size of the file, in bytes. - */ - size: number; - /** - * The last modification time of the file. This corresponds to the `mtime` - * field from `stat` on Linux/Mac OS and `ftLastWriteTime` on Windows. This - * may not be available on all platforms. - */ - mtime: Date | null; - /** - * The last access time of the file. This corresponds to the `atime` - * field from `stat` on Unix and `ftLastAccessTime` on Windows. This may not - * be available on all platforms. - */ - atime: Date | null; - /** - * The creation time of the file. This corresponds to the `birthtime` - * field from `stat` on Mac/BSD and `ftCreationTime` on Windows. This may - * not be available on all platforms. - */ - birthtime: Date | null; - /** Whether this is a readonly (unwritable) file. */ - readonly: boolean; - /** - * This field contains the file system attribute information for a file - * or directory. For possible values and their descriptions, see - * {@link https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants | File Attribute Constants} in the Windows Dev Center - * - * #### Platform-specific - * - * - **macOS / Linux / Android / iOS:** Unsupported. - */ - fileAttributes: number | null; - /** - * ID of the device containing the file. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - dev: number | null; - /** - * Inode number. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - ino: number | null; - /** - * The underlying raw `st_mode` bits that contain the standard Unix - * permissions for this file/directory. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - mode: number | null; - /** - * Number of hard links pointing to this file. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - nlink: number | null; - /** - * User ID of the owner of this file. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - uid: number | null; - /** - * Group ID of the owner of this file. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - gid: number | null; - /** - * Device ID of this file. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - rdev: number | null; - /** - * Blocksize for filesystem I/O. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - blksize: number | null; - /** - * Number of blocks allocated to the file, in 512-byte units. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - blocks: number | null; + /** + * True if this is info for a regular file. Mutually exclusive to + * `FileInfo.isDirectory` and `FileInfo.isSymlink`. + */ + isFile: boolean; + /** + * True if this is info for a regular directory. Mutually exclusive to + * `FileInfo.isFile` and `FileInfo.isSymlink`. + */ + isDirectory: boolean; + /** + * True if this is info for a symlink. Mutually exclusive to + * `FileInfo.isFile` and `FileInfo.isDirectory`. + */ + isSymlink: boolean; + /** + * The size of the file, in bytes. + */ + size: number; + /** + * The last modification time of the file. This corresponds to the `mtime` + * field from `stat` on Linux/Mac OS and `ftLastWriteTime` on Windows. This + * may not be available on all platforms. + */ + mtime: Date | null; + /** + * The last access time of the file. This corresponds to the `atime` + * field from `stat` on Unix and `ftLastAccessTime` on Windows. This may not + * be available on all platforms. + */ + atime: Date | null; + /** + * The creation time of the file. This corresponds to the `birthtime` + * field from `stat` on Mac/BSD and `ftCreationTime` on Windows. This may + * not be available on all platforms. + */ + birthtime: Date | null; + /** Whether this is a readonly (unwritable) file. */ + readonly: boolean; + /** + * This field contains the file system attribute information for a file + * or directory. For possible values and their descriptions, see + * {@link https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants | File Attribute Constants} in the Windows Dev Center + * + * #### Platform-specific + * + * - **macOS / Linux / Android / iOS:** Unsupported. + */ + fileAttributes: number | null; + /** + * ID of the device containing the file. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + dev: number | null; + /** + * Inode number. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + ino: number | null; + /** + * The underlying raw `st_mode` bits that contain the standard Unix + * permissions for this file/directory. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + mode: number | null; + /** + * Number of hard links pointing to this file. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + nlink: number | null; + /** + * User ID of the owner of this file. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + uid: number | null; + /** + * Group ID of the owner of this file. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + gid: number | null; + /** + * Device ID of this file. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + rdev: number | null; + /** + * Blocksize for filesystem I/O. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + blksize: number | null; + /** + * Number of blocks allocated to the file, in 512-byte units. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + blocks: number | null; } /** * The Tauri abstraction for reading and writing files. @@ -198,136 +198,136 @@ interface FileInfo { * @since 2.0.0 */ declare class FileHandle extends Resource { - constructor(rid: number); - /** - * Reads up to `p.byteLength` bytes into `p`. It resolves to the number of - * bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error - * encountered. Even if `read()` resolves to `n` < `p.byteLength`, it may - * use all of `p` as scratch space during the call. If some data is - * available but not `p.byteLength` bytes, `read()` conventionally resolves - * to what is available instead of waiting for more. - * - * When `read()` encounters end-of-file condition, it resolves to EOF - * (`null`). - * - * When `read()` encounters an error, it rejects with an error. - * - * Callers should always process the `n` > `0` bytes returned before - * considering the EOF (`null`). Doing so correctly handles I/O errors that - * happen after reading some bytes and also both of the allowed EOF - * behaviors. - * - * @example - * ```typescript - * import { open, read, close, BaseDirectory } from "@tauri-apps/plugin-fs" - * // if "$APP/foo/bar.txt" contains the text "hello world": - * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.App }); - * const buf = new Uint8Array(100); - * const numberOfBytesRead = await file.read(buf); // 11 bytes - * const text = new TextDecoder().decode(buf); // "hello world" - * await close(file.rid); - * ``` - * - * @since 2.0.0 - */ - read(buffer: Uint8Array): Promise; - /** - * Seek sets the offset for the next `read()` or `write()` to offset, - * interpreted according to `whence`: `Start` means relative to the - * start of the file, `Current` means relative to the current offset, - * and `End` means relative to the end. Seek resolves to the new offset - * relative to the start of the file. - * - * Seeking to an offset before the start of the file is an error. Seeking to - * any positive offset is legal, but the behavior of subsequent I/O - * operations on the underlying object is implementation-dependent. - * It returns the number of cursor position. - * - * @example - * ```typescript - * import { open, seek, write, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs'; - * - * // Given hello.txt pointing to file with "Hello world", which is 11 bytes long: - * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.App }); - * await file.write(new TextEncoder().encode("Hello world"), { baseDir: BaseDirectory.App }); - * - * // Seek 6 bytes from the start of the file - * console.log(await file.seek(6, SeekMode.Start)); // "6" - * // Seek 2 more bytes from the current position - * console.log(await file.seek(2, SeekMode.Current)); // "8" - * // Seek backwards 2 bytes from the end of the file - * console.log(await file.seek(-2, SeekMode.End)); // "9" (e.g. 11-2) - * ``` - * - * @since 2.0.0 - */ - seek(offset: number, whence: SeekMode): Promise; - /** - * Returns a {@linkcode FileInfo } for this file. - * - * @example - * ```typescript - * import { open, fstat, BaseDirectory } from '@tauri-apps/plugin-fs'; - * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.App }); - * const fileInfo = await fstat(file.rid); - * console.log(fileInfo.isFile); // true - * ``` - * - * @since 2.0.0 - */ - stat(): Promise; - /** - * Truncates or extends this file, to reach the specified `len`. - * If `len` is not specified then the entire file contents are truncated. - * - * @example - * ```typescript - * import { ftruncate, open, write, read, BaseDirectory } from '@tauri-apps/plugin-fs'; - * - * // truncate the entire file - * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); - * await ftruncate(file.rid); - * - * // truncate part of the file - * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); - * await write(file.rid, new TextEncoder().encode("Hello World")); - * await ftruncate(file.rid, 7); - * const data = new Uint8Array(32); - * await read(file.rid, data); - * console.log(new TextDecoder().decode(data)); // Hello W - * ``` - * - * @since 2.0.0 - */ - truncate(len?: number): Promise; - /** - * Writes `p.byteLength` bytes from `p` to the underlying data stream. It - * resolves to the number of bytes written from `p` (`0` <= `n` <= - * `p.byteLength`) or reject with the error encountered that caused the - * write to stop early. `write()` must reject with a non-null error if - * would resolve to `n` < `p.byteLength`. `write()` must not modify the - * slice data, even temporarily. - * - * @example - * ```typescript - * import { open, write, close, BaseDirectory } from '@tauri-apps/plugin-fs'; - * const encoder = new TextEncoder(); - * const data = encoder.encode("Hello world"); - * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.App }); - * const bytesWritten = await write(file.rid, data); // 11 - * await close(file.rid); - * ``` - * - * @since 2.0.0 - */ - write(data: Uint8Array): Promise; + constructor(rid: number); + /** + * Reads up to `p.byteLength` bytes into `p`. It resolves to the number of + * bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error + * encountered. Even if `read()` resolves to `n` < `p.byteLength`, it may + * use all of `p` as scratch space during the call. If some data is + * available but not `p.byteLength` bytes, `read()` conventionally resolves + * to what is available instead of waiting for more. + * + * When `read()` encounters end-of-file condition, it resolves to EOF + * (`null`). + * + * When `read()` encounters an error, it rejects with an error. + * + * Callers should always process the `n` > `0` bytes returned before + * considering the EOF (`null`). Doing so correctly handles I/O errors that + * happen after reading some bytes and also both of the allowed EOF + * behaviors. + * + * @example + * ```typescript + * import { open, read, close, BaseDirectory } from "@tauri-apps/plugin-fs" + * // if "$APP/foo/bar.txt" contains the text "hello world": + * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.App }); + * const buf = new Uint8Array(100); + * const numberOfBytesRead = await file.read(buf); // 11 bytes + * const text = new TextDecoder().decode(buf); // "hello world" + * await close(file.rid); + * ``` + * + * @since 2.0.0 + */ + read(buffer: Uint8Array): Promise; + /** + * Seek sets the offset for the next `read()` or `write()` to offset, + * interpreted according to `whence`: `Start` means relative to the + * start of the file, `Current` means relative to the current offset, + * and `End` means relative to the end. Seek resolves to the new offset + * relative to the start of the file. + * + * Seeking to an offset before the start of the file is an error. Seeking to + * any positive offset is legal, but the behavior of subsequent I/O + * operations on the underlying object is implementation-dependent. + * It returns the number of cursor position. + * + * @example + * ```typescript + * import { open, seek, write, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs'; + * + * // Given hello.txt pointing to file with "Hello world", which is 11 bytes long: + * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.App }); + * await file.write(new TextEncoder().encode("Hello world"), { baseDir: BaseDirectory.App }); + * + * // Seek 6 bytes from the start of the file + * console.log(await file.seek(6, SeekMode.Start)); // "6" + * // Seek 2 more bytes from the current position + * console.log(await file.seek(2, SeekMode.Current)); // "8" + * // Seek backwards 2 bytes from the end of the file + * console.log(await file.seek(-2, SeekMode.End)); // "9" (e.g. 11-2) + * ``` + * + * @since 2.0.0 + */ + seek(offset: number, whence: SeekMode): Promise; + /** + * Returns a {@linkcode FileInfo } for this file. + * + * @example + * ```typescript + * import { open, fstat, BaseDirectory } from '@tauri-apps/plugin-fs'; + * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.App }); + * const fileInfo = await fstat(file.rid); + * console.log(fileInfo.isFile); // true + * ``` + * + * @since 2.0.0 + */ + stat(): Promise; + /** + * Truncates or extends this file, to reach the specified `len`. + * If `len` is not specified then the entire file contents are truncated. + * + * @example + * ```typescript + * import { ftruncate, open, write, read, BaseDirectory } from '@tauri-apps/plugin-fs'; + * + * // truncate the entire file + * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); + * await ftruncate(file.rid); + * + * // truncate part of the file + * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); + * await write(file.rid, new TextEncoder().encode("Hello World")); + * await ftruncate(file.rid, 7); + * const data = new Uint8Array(32); + * await read(file.rid, data); + * console.log(new TextDecoder().decode(data)); // Hello W + * ``` + * + * @since 2.0.0 + */ + truncate(len?: number): Promise; + /** + * Writes `p.byteLength` bytes from `p` to the underlying data stream. It + * resolves to the number of bytes written from `p` (`0` <= `n` <= + * `p.byteLength`) or reject with the error encountered that caused the + * write to stop early. `write()` must reject with a non-null error if + * would resolve to `n` < `p.byteLength`. `write()` must not modify the + * slice data, even temporarily. + * + * @example + * ```typescript + * import { open, write, close, BaseDirectory } from '@tauri-apps/plugin-fs'; + * const encoder = new TextEncoder(); + * const data = encoder.encode("Hello world"); + * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.App }); + * const bytesWritten = await write(file.rid, data); // 11 + * await close(file.rid); + * ``` + * + * @since 2.0.0 + */ + write(data: Uint8Array): Promise; } /** * @since 2.0.0 */ interface CreateOptions { - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** * Creates a file if none exists or truncates an existing file and resolves to @@ -341,58 +341,61 @@ interface CreateOptions { * * @since 2.0.0 */ -declare function create(path: string | URL, options?: CreateOptions): Promise; +declare function create( + path: string | URL, + options?: CreateOptions, +): Promise; /** * @since 2.0.0 */ interface OpenOptions { - /** - * Sets the option for read access. This option, when `true`, means that the - * file should be read-able if opened. - */ - read?: boolean; - /** - * Sets the option for write access. This option, when `true`, means that - * the file should be write-able if opened. If the file already exists, - * any write calls on it will overwrite its contents, by default without - * truncating it. - */ - write?: boolean; - /** - * Sets the option for the append mode. This option, when `true`, means that - * writes will append to a file instead of overwriting previous contents. - * Note that setting `{ write: true, append: true }` has the same effect as - * setting only `{ append: true }`. - */ - append?: boolean; - /** - * Sets the option for truncating a previous file. If a file is - * successfully opened with this option set it will truncate the file to `0` - * size if it already exists. The file must be opened with write access - * for truncate to work. - */ - truncate?: boolean; - /** - * Sets the option to allow creating a new file, if one doesn't already - * exist at the specified path. Requires write or append access to be - * used. - */ - create?: boolean; - /** - * Defaults to `false`. If set to `true`, no file, directory, or symlink is - * allowed to exist at the target location. Requires write or append - * access to be used. When createNew is set to `true`, create and truncate - * are ignored. - */ - createNew?: boolean; - /** - * Permissions to use if creating the file (defaults to `0o666`, before - * the process's umask). - * Ignored on Windows. - */ - mode?: number; - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** + * Sets the option for read access. This option, when `true`, means that the + * file should be read-able if opened. + */ + read?: boolean; + /** + * Sets the option for write access. This option, when `true`, means that + * the file should be write-able if opened. If the file already exists, + * any write calls on it will overwrite its contents, by default without + * truncating it. + */ + write?: boolean; + /** + * Sets the option for the append mode. This option, when `true`, means that + * writes will append to a file instead of overwriting previous contents. + * Note that setting `{ write: true, append: true }` has the same effect as + * setting only `{ append: true }`. + */ + append?: boolean; + /** + * Sets the option for truncating a previous file. If a file is + * successfully opened with this option set it will truncate the file to `0` + * size if it already exists. The file must be opened with write access + * for truncate to work. + */ + truncate?: boolean; + /** + * Sets the option to allow creating a new file, if one doesn't already + * exist at the specified path. Requires write or append access to be + * used. + */ + create?: boolean; + /** + * Defaults to `false`. If set to `true`, no file, directory, or symlink is + * allowed to exist at the target location. Requires write or append + * access to be used. When createNew is set to `true`, create and truncate + * are ignored. + */ + createNew?: boolean; + /** + * Permissions to use if creating the file (defaults to `0o666`, before + * the process's umask). + * Ignored on Windows. + */ + mode?: number; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** * Open a file and resolve to an instance of {@linkcode FileHandle}. The @@ -410,15 +413,18 @@ interface OpenOptions { * * @since 2.0.0 */ -declare function open(path: string | URL, options?: OpenOptions): Promise; +declare function open( + path: string | URL, + options?: OpenOptions, +): Promise; /** * @since 2.0.0 */ interface CopyFileOptions { - /** Base directory for `fromPath`. */ - fromPathBaseDir?: BaseDirectory; - /** Base directory for `toPath`. */ - toPathBaseDir?: BaseDirectory; + /** Base directory for `fromPath`. */ + fromPathBaseDir?: BaseDirectory; + /** Base directory for `toPath`. */ + toPathBaseDir?: BaseDirectory; } /** * Copies the contents and permissions of one file to another specified path, by default creating a new file if needed, else overwriting. @@ -430,19 +436,23 @@ interface CopyFileOptions { * * @since 2.0.0 */ -declare function copyFile(fromPath: string | URL, toPath: string | URL, options?: CopyFileOptions): Promise; +declare function copyFile( + fromPath: string | URL, + toPath: string | URL, + options?: CopyFileOptions, +): Promise; /** * @since 2.0.0 */ interface MkdirOptions { - /** Permissions to use when creating the directory (defaults to `0o777`, before the process's umask). Ignored on Windows. */ - mode?: number; - /** - * Defaults to `false`. If set to `true`, means that any intermediate directories will also be created (as with the shell command `mkdir -p`). - * */ - recursive?: boolean; - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** Permissions to use when creating the directory (defaults to `0o777`, before the process's umask). Ignored on Windows. */ + mode?: number; + /** + * Defaults to `false`. If set to `true`, means that any intermediate directories will also be created (as with the shell command `mkdir -p`). + * */ + recursive?: boolean; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** * Creates a new directory with the specified path. @@ -454,13 +464,16 @@ interface MkdirOptions { * * @since 2.0.0 */ -declare function mkdir(path: string | URL, options?: MkdirOptions): Promise; +declare function mkdir( + path: string | URL, + options?: MkdirOptions, +): Promise; /** * @since 2.0.0 */ interface ReadDirOptions { - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** * A disk entry which is either a file, a directory or a symlink. @@ -470,14 +483,14 @@ interface ReadDirOptions { * @since 2.0.0 */ interface DirEntry { - /** The name of the entry (file name with extension or directory name). */ - name: string; - /** Specifies whether this entry is a directory or not. */ - isDirectory: boolean; - /** Specifies whether this entry is a file or not. */ - isFile: boolean; - /** Specifies whether this entry is a symlink or not. */ - isSymlink: boolean; + /** The name of the entry (file name with extension or directory name). */ + name: string; + /** Specifies whether this entry is a directory or not. */ + isDirectory: boolean; + /** Specifies whether this entry is a file or not. */ + isFile: boolean; + /** Specifies whether this entry is a symlink or not. */ + isSymlink: boolean; } /** * Reads the directory given by path and returns an array of `DirEntry`. @@ -500,13 +513,16 @@ interface DirEntry { * * @since 2.0.0 */ -declare function readDir(path: string | URL, options?: ReadDirOptions): Promise; +declare function readDir( + path: string | URL, + options?: ReadDirOptions, +): Promise; /** * @since 2.0.0 */ interface ReadFileOptions { - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** * Reads and resolves to the entire contents of a file as an array of bytes. @@ -519,7 +535,10 @@ interface ReadFileOptions { * * @since 2.0.0 */ -declare function readFile(path: string | URL, options?: ReadFileOptions): Promise; +declare function readFile( + path: string | URL, + options?: ReadFileOptions, +): Promise; /** * Reads and returns the entire contents of a file as UTF-8 string. * @example @@ -530,7 +549,10 @@ declare function readFile(path: string | URL, options?: ReadFileOptions): Promis * * @since 2.0.0 */ -declare function readTextFile(path: string | URL, options?: ReadFileOptions): Promise; +declare function readTextFile( + path: string | URL, + options?: ReadFileOptions, +): Promise; /** * Returns an async {@linkcode AsyncIterableIterator} over the lines of a file as UTF-8 string. * @example @@ -546,15 +568,18 @@ declare function readTextFile(path: string | URL, options?: ReadFileOptions): Pr * * @since 2.0.0 */ -declare function readTextFileLines(path: string | URL, options?: ReadFileOptions): Promise>; +declare function readTextFileLines( + path: string | URL, + options?: ReadFileOptions, +): Promise>; /** * @since 2.0.0 */ interface RemoveOptions { - /** Defaults to `false`. If set to `true`, path will be removed even if it's a non-empty directory. */ - recursive?: boolean; - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** Defaults to `false`. If set to `true`, path will be removed even if it's a non-empty directory. */ + recursive?: boolean; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** * Removes the named file or directory. @@ -568,15 +593,18 @@ interface RemoveOptions { * * @since 2.0.0 */ -declare function remove(path: string | URL, options?: RemoveOptions): Promise; +declare function remove( + path: string | URL, + options?: RemoveOptions, +): Promise; /** * @since 2.0.0 */ interface RenameOptions { - /** Base directory for `oldPath`. */ - oldPathBaseDir?: BaseDirectory; - /** Base directory for `newPath`. */ - newPathBaseDir?: BaseDirectory; + /** Base directory for `oldPath`. */ + oldPathBaseDir?: BaseDirectory; + /** Base directory for `newPath`. */ + newPathBaseDir?: BaseDirectory; } /** * Renames (moves) oldpath to newpath. Paths may be files or directories. @@ -593,13 +621,17 @@ interface RenameOptions { * * @since 2.0.0 */ -declare function rename(oldPath: string | URL, newPath: string | URL, options?: RenameOptions): Promise; +declare function rename( + oldPath: string | URL, + newPath: string | URL, + options?: RenameOptions, +): Promise; /** * @since 2.0.0 */ interface StatOptions { - /** Base directory for `path`. */ - baseDir?: BaseDirectory; + /** Base directory for `path`. */ + baseDir?: BaseDirectory; } /** * Resolves to a {@linkcode FileInfo} for the specified `path`. Will always @@ -614,7 +646,10 @@ interface StatOptions { * * @since 2.0.0 */ -declare function stat(path: string | URL, options?: StatOptions): Promise; +declare function stat( + path: string | URL, + options?: StatOptions, +): Promise; /** * Resolves to a {@linkcode FileInfo} for the specified `path`. If `path` is a * symlink, information for the symlink will be returned instead of what it @@ -629,13 +664,16 @@ declare function stat(path: string | URL, options?: StatOptions): Promise; +declare function lstat( + path: string | URL, + options?: StatOptions, +): Promise; /** * @since 2.0.0 */ interface TruncateOptions { - /** Base directory for `path`. */ - baseDir?: BaseDirectory; + /** Base directory for `path`. */ + baseDir?: BaseDirectory; } /** * Truncates or extends the specified file, to reach the specified `len`. @@ -657,21 +695,25 @@ interface TruncateOptions { * * @since 2.0.0 */ -declare function truncate(path: string | URL, len?: number, options?: TruncateOptions): Promise; +declare function truncate( + path: string | URL, + len?: number, + options?: TruncateOptions, +): Promise; /** * @since 2.0.0 */ interface WriteFileOptions { - /** Defaults to `false`. If set to `true`, will append to a file instead of overwriting previous contents. */ - append?: boolean; - /** Sets the option to allow creating a new file, if one doesn't already exist at the specified path (defaults to `true`). */ - create?: boolean; - /** Sets the option to create a new file, failing if it already exists. */ - createNew?: boolean; - /** File permissions. Ignored on Windows. */ - mode?: number; - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** Defaults to `false`. If set to `true`, will append to a file instead of overwriting previous contents. */ + append?: boolean; + /** Sets the option to allow creating a new file, if one doesn't already exist at the specified path (defaults to `true`). */ + create?: boolean; + /** Sets the option to create a new file, failing if it already exists. */ + createNew?: boolean; + /** File permissions. Ignored on Windows. */ + mode?: number; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** * Write `data` to the given `path`, by default creating a new file if needed, else overwriting. @@ -686,7 +728,11 @@ interface WriteFileOptions { * * @since 2.0.0 */ -declare function writeFile(path: string | URL, data: Uint8Array, options?: WriteFileOptions): Promise; +declare function writeFile( + path: string | URL, + data: Uint8Array, + options?: WriteFileOptions, +): Promise; /** * Writes UTF-8 string `data` to the given `path`, by default creating a new file if needed, else overwriting. @example @@ -698,13 +744,17 @@ declare function writeFile(path: string | URL, data: Uint8Array, options?: Write * * @since 2.0.0 */ -declare function writeTextFile(path: string | URL, data: string, options?: WriteFileOptions): Promise; +declare function writeTextFile( + path: string | URL, + data: string, + options?: WriteFileOptions, +): Promise; /** * @since 2.0.0 */ interface ExistsOptions { - /** Base directory for `path`. */ - baseDir?: BaseDirectory; + /** Base directory for `path`. */ + baseDir?: BaseDirectory; } /** * Check if a path exists. @@ -717,98 +767,131 @@ interface ExistsOptions { * * @since 2.0.0 */ -declare function exists(path: string | URL, options?: ExistsOptions): Promise; +declare function exists( + path: string | URL, + options?: ExistsOptions, +): Promise; /** * @since 2.0.0 */ interface WatchOptions { - /** Watch a directory recursively */ - recursive?: boolean; - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** Watch a directory recursively */ + recursive?: boolean; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** * @since 2.0.0 */ interface DebouncedWatchOptions extends WatchOptions { - /** Debounce delay */ - delayMs?: number; + /** Debounce delay */ + delayMs?: number; } /** * @since 2.0.0 */ type WatchEvent = { - type: WatchEventKind; - paths: string[]; - attrs: unknown; -}; -/** - * @since 2.0.0 - */ -type WatchEventKind = "any" | { - access: WatchEventKindAccess; -} | { - create: WatchEventKindCreate; -} | { - modify: WatchEventKindModify; -} | { - remove: WatchEventKindRemove; -} | "other"; -/** - * @since 2.0.0 - */ -type WatchEventKindAccess = { - kind: "any"; -} | { - kind: "close"; - mode: "any" | "execute" | "read" | "write" | "other"; -} | { - kind: "open"; - mode: "any" | "execute" | "read" | "write" | "other"; -} | { - kind: "other"; -}; -/** - * @since 2.0.0 - */ -type WatchEventKindCreate = { - kind: "any"; -} | { - kind: "file"; -} | { - kind: "folder"; -} | { - kind: "other"; -}; -/** - * @since 2.0.0 - */ -type WatchEventKindModify = { - kind: "any"; -} | { - kind: "data"; - mode: "any" | "size" | "content" | "other"; -} | { - kind: "metadata"; - mode: "any" | "access-time" | "write-time" | "permissions" | "ownership" | "extended" | "other"; -} | { - kind: "rename"; - mode: "any" | "to" | "from" | "both" | "other"; -} | { - kind: "other"; + type: WatchEventKind; + paths: string[]; + attrs: unknown; }; /** * @since 2.0.0 */ -type WatchEventKindRemove = { - kind: "any"; -} | { - kind: "file"; -} | { - kind: "folder"; -} | { - kind: "other"; -}; +type WatchEventKind = + | "any" + | { + access: WatchEventKindAccess; + } + | { + create: WatchEventKindCreate; + } + | { + modify: WatchEventKindModify; + } + | { + remove: WatchEventKindRemove; + } + | "other"; +/** + * @since 2.0.0 + */ +type WatchEventKindAccess = + | { + kind: "any"; + } + | { + kind: "close"; + mode: "any" | "execute" | "read" | "write" | "other"; + } + | { + kind: "open"; + mode: "any" | "execute" | "read" | "write" | "other"; + } + | { + kind: "other"; + }; +/** + * @since 2.0.0 + */ +type WatchEventKindCreate = + | { + kind: "any"; + } + | { + kind: "file"; + } + | { + kind: "folder"; + } + | { + kind: "other"; + }; +/** + * @since 2.0.0 + */ +type WatchEventKindModify = + | { + kind: "any"; + } + | { + kind: "data"; + mode: "any" | "size" | "content" | "other"; + } + | { + kind: "metadata"; + mode: + | "any" + | "access-time" + | "write-time" + | "permissions" + | "ownership" + | "extended" + | "other"; + } + | { + kind: "rename"; + mode: "any" | "to" | "from" | "both" | "other"; + } + | { + kind: "other"; + }; +/** + * @since 2.0.0 + */ +type WatchEventKindRemove = + | { + kind: "any"; + } + | { + kind: "file"; + } + | { + kind: "folder"; + } + | { + kind: "other"; + }; /** * @since 2.0.0 */ @@ -818,12 +901,66 @@ type UnwatchFn = () => void; * * @since 2.0.0 */ -declare function watch(paths: string | string[] | URL | URL[], cb: (event: WatchEvent) => void, options?: DebouncedWatchOptions): Promise; +declare function watch( + paths: string | string[] | URL | URL[], + cb: (event: WatchEvent) => void, + options?: DebouncedWatchOptions, +): Promise; /** * Watch changes on files or directories. * * @since 2.0.0 */ -declare function watchImmediate(paths: string | string[] | URL | URL[], cb: (event: WatchEvent) => void, options?: WatchOptions): Promise; -export type { CreateOptions, OpenOptions, CopyFileOptions, MkdirOptions, DirEntry, ReadDirOptions, ReadFileOptions, RemoveOptions, RenameOptions, StatOptions, TruncateOptions, WriteFileOptions, ExistsOptions, FileInfo, WatchOptions, DebouncedWatchOptions, WatchEvent, WatchEventKind, WatchEventKindAccess, WatchEventKindCreate, WatchEventKindModify, WatchEventKindRemove, UnwatchFn, }; -export { BaseDirectory, FileHandle, create, open, copyFile, mkdir, readDir, readFile, readTextFile, readTextFileLines, remove, rename, SeekMode, stat, lstat, truncate, writeFile, writeTextFile, exists, watch, watchImmediate, }; +declare function watchImmediate( + paths: string | string[] | URL | URL[], + cb: (event: WatchEvent) => void, + options?: WatchOptions, +): Promise; +export type { + CreateOptions, + OpenOptions, + CopyFileOptions, + MkdirOptions, + DirEntry, + ReadDirOptions, + ReadFileOptions, + RemoveOptions, + RenameOptions, + StatOptions, + TruncateOptions, + WriteFileOptions, + ExistsOptions, + FileInfo, + WatchOptions, + DebouncedWatchOptions, + WatchEvent, + WatchEventKind, + WatchEventKindAccess, + WatchEventKindCreate, + WatchEventKindModify, + WatchEventKindRemove, + UnwatchFn, +}; +export { + BaseDirectory, + FileHandle, + create, + open, + copyFile, + mkdir, + readDir, + readFile, + readTextFile, + readTextFileLines, + remove, + rename, + SeekMode, + stat, + lstat, + truncate, + writeFile, + writeTextFile, + exists, + watch, + watchImmediate, +}; diff --git a/dist-js/index.js b/dist-js/index.js index 7494686..7de8029 100644 --- a/dist-js/index.js +++ b/dist-js/index.js @@ -1,5 +1,5 @@ -export { BaseDirectory } from '@tauri-apps/api/path'; -import { Resource, invoke, Channel } from '@tauri-apps/api/core'; +export { BaseDirectory } from "@tauri-apps/api/path"; +import { Channel, Resource, invoke } from "@tauri-apps/api/core"; // Copyright 2019-2023 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 @@ -63,32 +63,32 @@ import { Resource, invoke, Channel } from '@tauri-apps/api/core'; * @module */ var SeekMode; -(function (SeekMode) { - SeekMode[SeekMode["Start"] = 0] = "Start"; - SeekMode[SeekMode["Current"] = 1] = "Current"; - SeekMode[SeekMode["End"] = 2] = "End"; +((SeekMode) => { + SeekMode[(SeekMode["Start"] = 0)] = "Start"; + SeekMode[(SeekMode["Current"] = 1)] = "Current"; + SeekMode[(SeekMode["End"] = 2)] = "End"; })(SeekMode || (SeekMode = {})); function parseFileInfo(r) { - return { - isFile: r.isFile, - isDirectory: r.isDirectory, - isSymlink: r.isSymlink, - size: r.size, - mtime: r.mtime != null ? new Date(r.mtime) : null, - atime: r.atime != null ? new Date(r.atime) : null, - birthtime: r.birthtime != null ? new Date(r.birthtime) : null, - readonly: r.readonly, - fileAttributes: r.fileAttributes, - dev: r.dev, - ino: r.ino, - mode: r.mode, - nlink: r.nlink, - uid: r.uid, - gid: r.gid, - rdev: r.rdev, - blksize: r.blksize, - blocks: r.blocks, - }; + return { + isFile: r.isFile, + isDirectory: r.isDirectory, + isSymlink: r.isSymlink, + size: r.size, + mtime: r.mtime != null ? new Date(r.mtime) : null, + atime: r.atime != null ? new Date(r.atime) : null, + birthtime: r.birthtime != null ? new Date(r.birthtime) : null, + readonly: r.readonly, + fileAttributes: r.fileAttributes, + dev: r.dev, + ino: r.ino, + mode: r.mode, + nlink: r.nlink, + uid: r.uid, + gid: r.gid, + rdev: r.rdev, + blksize: r.blksize, + blocks: r.blocks, + }; } /** * The Tauri abstraction for reading and writing files. @@ -96,162 +96,162 @@ function parseFileInfo(r) { * @since 2.0.0 */ class FileHandle extends Resource { - constructor(rid) { - super(rid); - } - /** - * Reads up to `p.byteLength` bytes into `p`. It resolves to the number of - * bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error - * encountered. Even if `read()` resolves to `n` < `p.byteLength`, it may - * use all of `p` as scratch space during the call. If some data is - * available but not `p.byteLength` bytes, `read()` conventionally resolves - * to what is available instead of waiting for more. - * - * When `read()` encounters end-of-file condition, it resolves to EOF - * (`null`). - * - * When `read()` encounters an error, it rejects with an error. - * - * Callers should always process the `n` > `0` bytes returned before - * considering the EOF (`null`). Doing so correctly handles I/O errors that - * happen after reading some bytes and also both of the allowed EOF - * behaviors. - * - * @example - * ```typescript - * import { open, read, close, BaseDirectory } from "@tauri-apps/plugin-fs" - * // if "$APP/foo/bar.txt" contains the text "hello world": - * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.App }); - * const buf = new Uint8Array(100); - * const numberOfBytesRead = await file.read(buf); // 11 bytes - * const text = new TextDecoder().decode(buf); // "hello world" - * await close(file.rid); - * ``` - * - * @since 2.0.0 - */ - async read(buffer) { - if (buffer.byteLength === 0) { - return 0; - } - const [data, nread] = await invoke("plugin:fs|read", { - rid: this.rid, - len: buffer.byteLength, - }); - buffer.set(data); - return nread === 0 ? null : nread; - } - /** - * Seek sets the offset for the next `read()` or `write()` to offset, - * interpreted according to `whence`: `Start` means relative to the - * start of the file, `Current` means relative to the current offset, - * and `End` means relative to the end. Seek resolves to the new offset - * relative to the start of the file. - * - * Seeking to an offset before the start of the file is an error. Seeking to - * any positive offset is legal, but the behavior of subsequent I/O - * operations on the underlying object is implementation-dependent. - * It returns the number of cursor position. - * - * @example - * ```typescript - * import { open, seek, write, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs'; - * - * // Given hello.txt pointing to file with "Hello world", which is 11 bytes long: - * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.App }); - * await file.write(new TextEncoder().encode("Hello world"), { baseDir: BaseDirectory.App }); - * - * // Seek 6 bytes from the start of the file - * console.log(await file.seek(6, SeekMode.Start)); // "6" - * // Seek 2 more bytes from the current position - * console.log(await file.seek(2, SeekMode.Current)); // "8" - * // Seek backwards 2 bytes from the end of the file - * console.log(await file.seek(-2, SeekMode.End)); // "9" (e.g. 11-2) - * ``` - * - * @since 2.0.0 - */ - async seek(offset, whence) { - return invoke("plugin:fs|seek", { - rid: this.rid, - offset, - whence, - }); - } - /** - * Returns a {@linkcode FileInfo } for this file. - * - * @example - * ```typescript - * import { open, fstat, BaseDirectory } from '@tauri-apps/plugin-fs'; - * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.App }); - * const fileInfo = await fstat(file.rid); - * console.log(fileInfo.isFile); // true - * ``` - * - * @since 2.0.0 - */ - async stat() { - const res = await invoke("plugin:fs|fstat", { - rid: this.rid, - }); - return parseFileInfo(res); - } - /** - * Truncates or extends this file, to reach the specified `len`. - * If `len` is not specified then the entire file contents are truncated. - * - * @example - * ```typescript - * import { ftruncate, open, write, read, BaseDirectory } from '@tauri-apps/plugin-fs'; - * - * // truncate the entire file - * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); - * await ftruncate(file.rid); - * - * // truncate part of the file - * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); - * await write(file.rid, new TextEncoder().encode("Hello World")); - * await ftruncate(file.rid, 7); - * const data = new Uint8Array(32); - * await read(file.rid, data); - * console.log(new TextDecoder().decode(data)); // Hello W - * ``` - * - * @since 2.0.0 - */ - async truncate(len) { - return invoke("plugin:fs|ftruncate", { - rid: this.rid, - len, - }); - } - /** - * Writes `p.byteLength` bytes from `p` to the underlying data stream. It - * resolves to the number of bytes written from `p` (`0` <= `n` <= - * `p.byteLength`) or reject with the error encountered that caused the - * write to stop early. `write()` must reject with a non-null error if - * would resolve to `n` < `p.byteLength`. `write()` must not modify the - * slice data, even temporarily. - * - * @example - * ```typescript - * import { open, write, close, BaseDirectory } from '@tauri-apps/plugin-fs'; - * const encoder = new TextEncoder(); - * const data = encoder.encode("Hello world"); - * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.App }); - * const bytesWritten = await write(file.rid, data); // 11 - * await close(file.rid); - * ``` - * - * @since 2.0.0 - */ - async write(data) { - return invoke("plugin:fs|write", { - rid: this.rid, - data: Array.from(data), - }); - } + constructor(rid) { + super(rid); + } + /** + * Reads up to `p.byteLength` bytes into `p`. It resolves to the number of + * bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error + * encountered. Even if `read()` resolves to `n` < `p.byteLength`, it may + * use all of `p` as scratch space during the call. If some data is + * available but not `p.byteLength` bytes, `read()` conventionally resolves + * to what is available instead of waiting for more. + * + * When `read()` encounters end-of-file condition, it resolves to EOF + * (`null`). + * + * When `read()` encounters an error, it rejects with an error. + * + * Callers should always process the `n` > `0` bytes returned before + * considering the EOF (`null`). Doing so correctly handles I/O errors that + * happen after reading some bytes and also both of the allowed EOF + * behaviors. + * + * @example + * ```typescript + * import { open, read, close, BaseDirectory } from "@tauri-apps/plugin-fs" + * // if "$APP/foo/bar.txt" contains the text "hello world": + * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.App }); + * const buf = new Uint8Array(100); + * const numberOfBytesRead = await file.read(buf); // 11 bytes + * const text = new TextDecoder().decode(buf); // "hello world" + * await close(file.rid); + * ``` + * + * @since 2.0.0 + */ + async read(buffer) { + if (buffer.byteLength === 0) { + return 0; + } + const [data, nread] = await invoke("plugin:fs|read", { + rid: this.rid, + len: buffer.byteLength, + }); + buffer.set(data); + return nread === 0 ? null : nread; + } + /** + * Seek sets the offset for the next `read()` or `write()` to offset, + * interpreted according to `whence`: `Start` means relative to the + * start of the file, `Current` means relative to the current offset, + * and `End` means relative to the end. Seek resolves to the new offset + * relative to the start of the file. + * + * Seeking to an offset before the start of the file is an error. Seeking to + * any positive offset is legal, but the behavior of subsequent I/O + * operations on the underlying object is implementation-dependent. + * It returns the number of cursor position. + * + * @example + * ```typescript + * import { open, seek, write, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs'; + * + * // Given hello.txt pointing to file with "Hello world", which is 11 bytes long: + * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.App }); + * await file.write(new TextEncoder().encode("Hello world"), { baseDir: BaseDirectory.App }); + * + * // Seek 6 bytes from the start of the file + * console.log(await file.seek(6, SeekMode.Start)); // "6" + * // Seek 2 more bytes from the current position + * console.log(await file.seek(2, SeekMode.Current)); // "8" + * // Seek backwards 2 bytes from the end of the file + * console.log(await file.seek(-2, SeekMode.End)); // "9" (e.g. 11-2) + * ``` + * + * @since 2.0.0 + */ + async seek(offset, whence) { + return invoke("plugin:fs|seek", { + rid: this.rid, + offset, + whence, + }); + } + /** + * Returns a {@linkcode FileInfo } for this file. + * + * @example + * ```typescript + * import { open, fstat, BaseDirectory } from '@tauri-apps/plugin-fs'; + * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.App }); + * const fileInfo = await fstat(file.rid); + * console.log(fileInfo.isFile); // true + * ``` + * + * @since 2.0.0 + */ + async stat() { + const res = await invoke("plugin:fs|fstat", { + rid: this.rid, + }); + return parseFileInfo(res); + } + /** + * Truncates or extends this file, to reach the specified `len`. + * If `len` is not specified then the entire file contents are truncated. + * + * @example + * ```typescript + * import { ftruncate, open, write, read, BaseDirectory } from '@tauri-apps/plugin-fs'; + * + * // truncate the entire file + * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); + * await ftruncate(file.rid); + * + * // truncate part of the file + * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); + * await write(file.rid, new TextEncoder().encode("Hello World")); + * await ftruncate(file.rid, 7); + * const data = new Uint8Array(32); + * await read(file.rid, data); + * console.log(new TextDecoder().decode(data)); // Hello W + * ``` + * + * @since 2.0.0 + */ + async truncate(len) { + return invoke("plugin:fs|ftruncate", { + rid: this.rid, + len, + }); + } + /** + * Writes `p.byteLength` bytes from `p` to the underlying data stream. It + * resolves to the number of bytes written from `p` (`0` <= `n` <= + * `p.byteLength`) or reject with the error encountered that caused the + * write to stop early. `write()` must reject with a non-null error if + * would resolve to `n` < `p.byteLength`. `write()` must not modify the + * slice data, even temporarily. + * + * @example + * ```typescript + * import { open, write, close, BaseDirectory } from '@tauri-apps/plugin-fs'; + * const encoder = new TextEncoder(); + * const data = encoder.encode("Hello world"); + * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.App }); + * const bytesWritten = await write(file.rid, data); // 11 + * await close(file.rid); + * ``` + * + * @since 2.0.0 + */ + async write(data) { + return invoke("plugin:fs|write", { + rid: this.rid, + data: Array.from(data), + }); + } } /** * Creates a file if none exists or truncates an existing file and resolves to @@ -266,14 +266,14 @@ class FileHandle extends Resource { * @since 2.0.0 */ async function create(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - const rid = await invoke("plugin:fs|create", { - path: path instanceof URL ? path.toString() : path, - options, - }); - return new FileHandle(rid); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + const rid = await invoke("plugin:fs|create", { + path: path instanceof URL ? path.toString() : path, + options, + }); + return new FileHandle(rid); } /** * Open a file and resolve to an instance of {@linkcode FileHandle}. The @@ -292,14 +292,14 @@ async function create(path, options) { * @since 2.0.0 */ async function open(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - const rid = await invoke("plugin:fs|open", { - path: path instanceof URL ? path.toString() : path, - options, - }); - return new FileHandle(rid); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + const rid = await invoke("plugin:fs|open", { + path: path instanceof URL ? path.toString() : path, + options, + }); + return new FileHandle(rid); } /** * Copies the contents and permissions of one file to another specified path, by default creating a new file if needed, else overwriting. @@ -312,15 +312,17 @@ async function open(path, options) { * @since 2.0.0 */ async function copyFile(fromPath, toPath, options) { - if ((fromPath instanceof URL && fromPath.protocol !== "file:") || - (toPath instanceof URL && toPath.protocol !== "file:")) { - throw new TypeError("Must be a file URL."); - } - return invoke("plugin:fs|copy_file", { - fromPath: fromPath instanceof URL ? fromPath.toString() : fromPath, - toPath: toPath instanceof URL ? toPath.toString() : toPath, - options, - }); + if ( + (fromPath instanceof URL && fromPath.protocol !== "file:") || + (toPath instanceof URL && toPath.protocol !== "file:") + ) { + throw new TypeError("Must be a file URL."); + } + return invoke("plugin:fs|copy_file", { + fromPath: fromPath instanceof URL ? fromPath.toString() : fromPath, + toPath: toPath instanceof URL ? toPath.toString() : toPath, + options, + }); } /** * Creates a new directory with the specified path. @@ -333,13 +335,13 @@ async function copyFile(fromPath, toPath, options) { * @since 2.0.0 */ async function mkdir(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return invoke("plugin:fs|mkdir", { - path: path instanceof URL ? path.toString() : path, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return invoke("plugin:fs|mkdir", { + path: path instanceof URL ? path.toString() : path, + options, + }); } /** * Reads the directory given by path and returns an array of `DirEntry`. @@ -363,13 +365,13 @@ async function mkdir(path, options) { * @since 2.0.0 */ async function readDir(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return invoke("plugin:fs|read_dir", { - path: path instanceof URL ? path.toString() : path, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return invoke("plugin:fs|read_dir", { + path: path instanceof URL ? path.toString() : path, + options, + }); } /** * Reads and resolves to the entire contents of a file as an array of bytes. @@ -383,14 +385,14 @@ async function readDir(path, options) { * @since 2.0.0 */ async function readFile(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - const arr = await invoke("plugin:fs|read_file", { - path: path instanceof URL ? path.toString() : path, - options, - }); - return Uint8Array.from(arr); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + const arr = await invoke("plugin:fs|read_file", { + path: path instanceof URL ? path.toString() : path, + options, + }); + return Uint8Array.from(arr); } /** * Reads and returns the entire contents of a file as UTF-8 string. @@ -403,13 +405,13 @@ async function readFile(path, options) { * @since 2.0.0 */ async function readTextFile(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return invoke("plugin:fs|read_text_file", { - path: path instanceof URL ? path.toString() : path, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return invoke("plugin:fs|read_text_file", { + path: path instanceof URL ? path.toString() : path, + options, + }); } /** * Returns an async {@linkcode AsyncIterableIterator} over the lines of a file as UTF-8 string. @@ -427,33 +429,35 @@ async function readTextFile(path, options) { * @since 2.0.0 */ async function readTextFileLines(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - const pathStr = path instanceof URL ? path.toString() : path; - return Promise.resolve({ - path: pathStr, - rid: null, - async next() { - if (!this.rid) { - this.rid = await invoke("plugin:fs|read_text_file_lines", { - path: pathStr, - options, - }); - } - const [line, done] = await invoke("plugin:fs|read_text_file_lines_next", { rid: this.rid }); - // an iteration is over, reset rid for next iteration - if (done) - this.rid = null; - return { - value: done ? "" : line, - done, - }; - }, - [Symbol.asyncIterator]() { - return this; - }, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + const pathStr = path instanceof URL ? path.toString() : path; + return Promise.resolve({ + path: pathStr, + rid: null, + async next() { + if (!this.rid) { + this.rid = await invoke("plugin:fs|read_text_file_lines", { + path: pathStr, + options, + }); + } + const [line, done] = await invoke( + "plugin:fs|read_text_file_lines_next", + { rid: this.rid }, + ); + // an iteration is over, reset rid for next iteration + if (done) this.rid = null; + return { + value: done ? "" : line, + done, + }; + }, + [Symbol.asyncIterator]() { + return this; + }, + }); } /** * Removes the named file or directory. @@ -468,13 +472,13 @@ async function readTextFileLines(path, options) { * @since 2.0.0 */ async function remove(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return invoke("plugin:fs|remove", { - path: path instanceof URL ? path.toString() : path, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return invoke("plugin:fs|remove", { + path: path instanceof URL ? path.toString() : path, + options, + }); } /** * Renames (moves) oldpath to newpath. Paths may be files or directories. @@ -492,15 +496,17 @@ async function remove(path, options) { * @since 2.0.0 */ async function rename(oldPath, newPath, options) { - if ((oldPath instanceof URL && oldPath.protocol !== "file:") || - (newPath instanceof URL && newPath.protocol !== "file:")) { - throw new TypeError("Must be a file URL."); - } - return invoke("plugin:fs|rename", { - oldPath: oldPath instanceof URL ? oldPath.toString() : oldPath, - newPath: newPath instanceof URL ? newPath.toString() : newPath, - options, - }); + if ( + (oldPath instanceof URL && oldPath.protocol !== "file:") || + (newPath instanceof URL && newPath.protocol !== "file:") + ) { + throw new TypeError("Must be a file URL."); + } + return invoke("plugin:fs|rename", { + oldPath: oldPath instanceof URL ? oldPath.toString() : oldPath, + newPath: newPath instanceof URL ? newPath.toString() : newPath, + options, + }); } /** * Resolves to a {@linkcode FileInfo} for the specified `path`. Will always @@ -516,11 +522,11 @@ async function rename(oldPath, newPath, options) { * @since 2.0.0 */ async function stat(path, options) { - const res = await invoke("plugin:fs|stat", { - path: path instanceof URL ? path.toString() : path, - options, - }); - return parseFileInfo(res); + const res = await invoke("plugin:fs|stat", { + path: path instanceof URL ? path.toString() : path, + options, + }); + return parseFileInfo(res); } /** * Resolves to a {@linkcode FileInfo} for the specified `path`. If `path` is a @@ -537,11 +543,11 @@ async function stat(path, options) { * @since 2.0.0 */ async function lstat(path, options) { - const res = await invoke("plugin:fs|lstat", { - path: path instanceof URL ? path.toString() : path, - options, - }); - return parseFileInfo(res); + const res = await invoke("plugin:fs|lstat", { + path: path instanceof URL ? path.toString() : path, + options, + }); + return parseFileInfo(res); } /** * Truncates or extends the specified file, to reach the specified `len`. @@ -564,14 +570,14 @@ async function lstat(path, options) { * @since 2.0.0 */ async function truncate(path, len, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return invoke("plugin:fs|truncate", { - path: path instanceof URL ? path.toString() : path, - len, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return invoke("plugin:fs|truncate", { + path: path instanceof URL ? path.toString() : path, + len, + options, + }); } /** * Write `data` to the given `path`, by default creating a new file if needed, else overwriting. @@ -587,14 +593,14 @@ async function truncate(path, len, options) { * @since 2.0.0 */ async function writeFile(path, data, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return invoke("plugin:fs|write_file", { - path: path instanceof URL ? path.toString() : path, - data: Array.from(data), - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return invoke("plugin:fs|write_file", { + path: path instanceof URL ? path.toString() : path, + data: Array.from(data), + options, + }); } /** * Writes UTF-8 string `data` to the given `path`, by default creating a new file if needed, else overwriting. @@ -608,14 +614,14 @@ async function writeFile(path, data, options) { * @since 2.0.0 */ async function writeTextFile(path, data, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return invoke("plugin:fs|write_text_file", { - path: path instanceof URL ? path.toString() : path, - data, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return invoke("plugin:fs|write_text_file", { + path: path instanceof URL ? path.toString() : path, + data, + options, + }); } /** * Check if a path exists. @@ -629,16 +635,16 @@ async function writeTextFile(path, data, options) { * @since 2.0.0 */ async function exists(path, options) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - return invoke("plugin:fs|exists", { - path: path instanceof URL ? path.toString() : path, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + return invoke("plugin:fs|exists", { + path: path instanceof URL ? path.toString() : path, + options, + }); } async function unwatch(rid) { - await invoke("plugin:fs|unwatch", { rid }); + await invoke("plugin:fs|unwatch", { rid }); } /** * Watch changes (after a delay) on files or directories. @@ -646,27 +652,27 @@ async function unwatch(rid) { * @since 2.0.0 */ async function watch(paths, cb, options) { - const opts = { - recursive: false, - delayMs: 2000, - ...options, - }; - const watchPaths = Array.isArray(paths) ? paths : [paths]; - for (const path of watchPaths) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - } - const onEvent = new Channel(); - onEvent.onmessage = cb; - const rid = await invoke("plugin:fs|watch", { - paths: watchPaths.map((p) => (p instanceof URL ? p.toString() : p)), - options: opts, - onEvent, - }); - return () => { - void unwatch(rid); - }; + const opts = { + recursive: false, + delayMs: 2000, + ...options, + }; + const watchPaths = Array.isArray(paths) ? paths : [paths]; + for (const path of watchPaths) { + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + } + const onEvent = new Channel(); + onEvent.onmessage = cb; + const rid = await invoke("plugin:fs|watch", { + paths: watchPaths.map((p) => (p instanceof URL ? p.toString() : p)), + options: opts, + onEvent, + }); + return () => { + void unwatch(rid); + }; } /** * Watch changes on files or directories. @@ -674,27 +680,48 @@ async function watch(paths, cb, options) { * @since 2.0.0 */ async function watchImmediate(paths, cb, options) { - const opts = { - recursive: false, - ...options, - delayMs: null, - }; - const watchPaths = Array.isArray(paths) ? paths : [paths]; - for (const path of watchPaths) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - } - const onEvent = new Channel(); - onEvent.onmessage = cb; - const rid = await invoke("plugin:fs|watch", { - paths: watchPaths.map((p) => (p instanceof URL ? p.toString() : p)), - options: opts, - onEvent, - }); - return () => { - void unwatch(rid); - }; + const opts = { + recursive: false, + ...options, + delayMs: null, + }; + const watchPaths = Array.isArray(paths) ? paths : [paths]; + for (const path of watchPaths) { + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + } + const onEvent = new Channel(); + onEvent.onmessage = cb; + const rid = await invoke("plugin:fs|watch", { + paths: watchPaths.map((p) => (p instanceof URL ? p.toString() : p)), + options: opts, + onEvent, + }); + return () => { + void unwatch(rid); + }; } -export { FileHandle, SeekMode, copyFile, create, exists, lstat, mkdir, open, readDir, readFile, readTextFile, readTextFileLines, remove, rename, stat, truncate, watch, watchImmediate, writeFile, writeTextFile }; +export { + FileHandle, + SeekMode, + copyFile, + create, + exists, + lstat, + mkdir, + open, + readDir, + readFile, + readTextFile, + readTextFileLines, + remove, + rename, + stat, + truncate, + watch, + watchImmediate, + writeFile, + writeTextFile, +}; diff --git a/guest-js/index.ts b/guest-js/index.ts index 3d9aca3..5c80d8f 100644 --- a/guest-js/index.ts +++ b/guest-js/index.ts @@ -61,13 +61,13 @@ * @module */ +import { Channel, Resource, invoke } from "@tauri-apps/api/core"; import { BaseDirectory } from "@tauri-apps/api/path"; -import { Channel, invoke, Resource } from "@tauri-apps/api/core"; enum SeekMode { - Start = 0, - Current = 1, - End = 2, + Start = 0, + Current = 1, + End = 2, } /** @@ -76,171 +76,171 @@ enum SeekMode { * @since 2.0.0 */ interface FileInfo { - /** - * True if this is info for a regular file. Mutually exclusive to - * `FileInfo.isDirectory` and `FileInfo.isSymlink`. - */ - isFile: boolean; - /** - * True if this is info for a regular directory. Mutually exclusive to - * `FileInfo.isFile` and `FileInfo.isSymlink`. - */ - isDirectory: boolean; - /** - * True if this is info for a symlink. Mutually exclusive to - * `FileInfo.isFile` and `FileInfo.isDirectory`. - */ - isSymlink: boolean; - /** - * The size of the file, in bytes. - */ - size: number; - /** - * The last modification time of the file. This corresponds to the `mtime` - * field from `stat` on Linux/Mac OS and `ftLastWriteTime` on Windows. This - * may not be available on all platforms. - */ - mtime: Date | null; - /** - * The last access time of the file. This corresponds to the `atime` - * field from `stat` on Unix and `ftLastAccessTime` on Windows. This may not - * be available on all platforms. - */ - atime: Date | null; - /** - * The creation time of the file. This corresponds to the `birthtime` - * field from `stat` on Mac/BSD and `ftCreationTime` on Windows. This may - * not be available on all platforms. - */ - birthtime: Date | null; - /** Whether this is a readonly (unwritable) file. */ - readonly: boolean; - /** - * This field contains the file system attribute information for a file - * or directory. For possible values and their descriptions, see - * {@link https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants | File Attribute Constants} in the Windows Dev Center - * - * #### Platform-specific - * - * - **macOS / Linux / Android / iOS:** Unsupported. - */ - fileAttributes: number | null; - /** - * ID of the device containing the file. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - dev: number | null; - /** - * Inode number. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - ino: number | null; - /** - * The underlying raw `st_mode` bits that contain the standard Unix - * permissions for this file/directory. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - mode: number | null; - /** - * Number of hard links pointing to this file. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - nlink: number | null; - /** - * User ID of the owner of this file. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - uid: number | null; - /** - * Group ID of the owner of this file. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - gid: number | null; - /** - * Device ID of this file. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - rdev: number | null; - /** - * Blocksize for filesystem I/O. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - blksize: number | null; - /** - * Number of blocks allocated to the file, in 512-byte units. - * - * #### Platform-specific - * - * - **Windows:** Unsupported. - */ - blocks: number | null; + /** + * True if this is info for a regular file. Mutually exclusive to + * `FileInfo.isDirectory` and `FileInfo.isSymlink`. + */ + isFile: boolean; + /** + * True if this is info for a regular directory. Mutually exclusive to + * `FileInfo.isFile` and `FileInfo.isSymlink`. + */ + isDirectory: boolean; + /** + * True if this is info for a symlink. Mutually exclusive to + * `FileInfo.isFile` and `FileInfo.isDirectory`. + */ + isSymlink: boolean; + /** + * The size of the file, in bytes. + */ + size: number; + /** + * The last modification time of the file. This corresponds to the `mtime` + * field from `stat` on Linux/Mac OS and `ftLastWriteTime` on Windows. This + * may not be available on all platforms. + */ + mtime: Date | null; + /** + * The last access time of the file. This corresponds to the `atime` + * field from `stat` on Unix and `ftLastAccessTime` on Windows. This may not + * be available on all platforms. + */ + atime: Date | null; + /** + * The creation time of the file. This corresponds to the `birthtime` + * field from `stat` on Mac/BSD and `ftCreationTime` on Windows. This may + * not be available on all platforms. + */ + birthtime: Date | null; + /** Whether this is a readonly (unwritable) file. */ + readonly: boolean; + /** + * This field contains the file system attribute information for a file + * or directory. For possible values and their descriptions, see + * {@link https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants | File Attribute Constants} in the Windows Dev Center + * + * #### Platform-specific + * + * - **macOS / Linux / Android / iOS:** Unsupported. + */ + fileAttributes: number | null; + /** + * ID of the device containing the file. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + dev: number | null; + /** + * Inode number. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + ino: number | null; + /** + * The underlying raw `st_mode` bits that contain the standard Unix + * permissions for this file/directory. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + mode: number | null; + /** + * Number of hard links pointing to this file. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + nlink: number | null; + /** + * User ID of the owner of this file. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + uid: number | null; + /** + * Group ID of the owner of this file. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + gid: number | null; + /** + * Device ID of this file. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + rdev: number | null; + /** + * Blocksize for filesystem I/O. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + blksize: number | null; + /** + * Number of blocks allocated to the file, in 512-byte units. + * + * #### Platform-specific + * + * - **Windows:** Unsupported. + */ + blocks: number | null; } interface UnparsedFileInfo { - isFile: boolean; - isDirectory: boolean; - isSymlink: boolean; - size: number; - mtime: number | null; - atime: number | null; - birthtime: number | null; - readonly: boolean; - fileAttributes: number; - dev: number | null; - ino: number | null; - mode: number | null; - nlink: number | null; - uid: number | null; - gid: number | null; - rdev: number | null; - blksize: number | null; - blocks: number | null; + isFile: boolean; + isDirectory: boolean; + isSymlink: boolean; + size: number; + mtime: number | null; + atime: number | null; + birthtime: number | null; + readonly: boolean; + fileAttributes: number; + dev: number | null; + ino: number | null; + mode: number | null; + nlink: number | null; + uid: number | null; + gid: number | null; + rdev: number | null; + blksize: number | null; + blocks: number | null; } function parseFileInfo(r: UnparsedFileInfo): FileInfo { - return { - isFile: r.isFile, - isDirectory: r.isDirectory, - isSymlink: r.isSymlink, - size: r.size, - mtime: r.mtime != null ? new Date(r.mtime) : null, - atime: r.atime != null ? new Date(r.atime) : null, - birthtime: r.birthtime != null ? new Date(r.birthtime) : null, - readonly: r.readonly, - fileAttributes: r.fileAttributes, - dev: r.dev, - ino: r.ino, - mode: r.mode, - nlink: r.nlink, - uid: r.uid, - gid: r.gid, - rdev: r.rdev, - blksize: r.blksize, - blocks: r.blocks, - }; + return { + isFile: r.isFile, + isDirectory: r.isDirectory, + isSymlink: r.isSymlink, + size: r.size, + mtime: r.mtime != null ? new Date(r.mtime) : null, + atime: r.atime != null ? new Date(r.atime) : null, + birthtime: r.birthtime != null ? new Date(r.birthtime) : null, + readonly: r.readonly, + fileAttributes: r.fileAttributes, + dev: r.dev, + ino: r.ino, + mode: r.mode, + nlink: r.nlink, + uid: r.uid, + gid: r.gid, + rdev: r.rdev, + blksize: r.blksize, + blocks: r.blocks, + }; } /** @@ -249,179 +249,182 @@ function parseFileInfo(r: UnparsedFileInfo): FileInfo { * @since 2.0.0 */ class FileHandle extends Resource { - constructor(rid: number) { - super(rid); - } - - /** - * Reads up to `p.byteLength` bytes into `p`. It resolves to the number of - * bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error - * encountered. Even if `read()` resolves to `n` < `p.byteLength`, it may - * use all of `p` as scratch space during the call. If some data is - * available but not `p.byteLength` bytes, `read()` conventionally resolves - * to what is available instead of waiting for more. - * - * When `read()` encounters end-of-file condition, it resolves to EOF - * (`null`). - * - * When `read()` encounters an error, it rejects with an error. - * - * Callers should always process the `n` > `0` bytes returned before - * considering the EOF (`null`). Doing so correctly handles I/O errors that - * happen after reading some bytes and also both of the allowed EOF - * behaviors. - * - * @example - * ```typescript - * import { open, read, close, BaseDirectory } from "@tauri-apps/plugin-fs" - * // if "$APP/foo/bar.txt" contains the text "hello world": - * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.App }); - * const buf = new Uint8Array(100); - * const numberOfBytesRead = await file.read(buf); // 11 bytes - * const text = new TextDecoder().decode(buf); // "hello world" - * await close(file.rid); - * ``` - * - * @since 2.0.0 - */ - async read(buffer: Uint8Array): Promise { - if (buffer.byteLength === 0) { - return 0; - } - - const [data, nread] = await invoke<[number[], number]>("plugin:fs|read", { - rid: this.rid, - len: buffer.byteLength, - }); - - buffer.set(data); - - return nread === 0 ? null : nread; - } - - /** - * Seek sets the offset for the next `read()` or `write()` to offset, - * interpreted according to `whence`: `Start` means relative to the - * start of the file, `Current` means relative to the current offset, - * and `End` means relative to the end. Seek resolves to the new offset - * relative to the start of the file. - * - * Seeking to an offset before the start of the file is an error. Seeking to - * any positive offset is legal, but the behavior of subsequent I/O - * operations on the underlying object is implementation-dependent. - * It returns the number of cursor position. - * - * @example - * ```typescript - * import { open, seek, write, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs'; - * - * // Given hello.txt pointing to file with "Hello world", which is 11 bytes long: - * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.App }); - * await file.write(new TextEncoder().encode("Hello world"), { baseDir: BaseDirectory.App }); - * - * // Seek 6 bytes from the start of the file - * console.log(await file.seek(6, SeekMode.Start)); // "6" - * // Seek 2 more bytes from the current position - * console.log(await file.seek(2, SeekMode.Current)); // "8" - * // Seek backwards 2 bytes from the end of the file - * console.log(await file.seek(-2, SeekMode.End)); // "9" (e.g. 11-2) - * ``` - * - * @since 2.0.0 - */ - async seek(offset: number, whence: SeekMode): Promise { - return invoke("plugin:fs|seek", { - rid: this.rid, - offset, - whence, - }); - } - - /** - * Returns a {@linkcode FileInfo } for this file. - * - * @example - * ```typescript - * import { open, fstat, BaseDirectory } from '@tauri-apps/plugin-fs'; - * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.App }); - * const fileInfo = await fstat(file.rid); - * console.log(fileInfo.isFile); // true - * ``` - * - * @since 2.0.0 - */ - async stat(): Promise { - const res = await invoke("plugin:fs|fstat", { - rid: this.rid, - }); - - return parseFileInfo(res); - } - - /** - * Truncates or extends this file, to reach the specified `len`. - * If `len` is not specified then the entire file contents are truncated. - * - * @example - * ```typescript - * import { ftruncate, open, write, read, BaseDirectory } from '@tauri-apps/plugin-fs'; - * - * // truncate the entire file - * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); - * await ftruncate(file.rid); - * - * // truncate part of the file - * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); - * await write(file.rid, new TextEncoder().encode("Hello World")); - * await ftruncate(file.rid, 7); - * const data = new Uint8Array(32); - * await read(file.rid, data); - * console.log(new TextDecoder().decode(data)); // Hello W - * ``` - * - * @since 2.0.0 - */ - async truncate(len?: number): Promise { - return invoke("plugin:fs|ftruncate", { - rid: this.rid, - len, - }); - } - - /** - * Writes `p.byteLength` bytes from `p` to the underlying data stream. It - * resolves to the number of bytes written from `p` (`0` <= `n` <= - * `p.byteLength`) or reject with the error encountered that caused the - * write to stop early. `write()` must reject with a non-null error if - * would resolve to `n` < `p.byteLength`. `write()` must not modify the - * slice data, even temporarily. - * - * @example - * ```typescript - * import { open, write, close, BaseDirectory } from '@tauri-apps/plugin-fs'; - * const encoder = new TextEncoder(); - * const data = encoder.encode("Hello world"); - * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.App }); - * const bytesWritten = await write(file.rid, data); // 11 - * await close(file.rid); - * ``` - * - * @since 2.0.0 - */ - async write(data: Uint8Array): Promise { - return invoke("plugin:fs|write", { - rid: this.rid, - data: Array.from(data), - }); - } + constructor(rid: number) { + super(rid); + } + + /** + * Reads up to `p.byteLength` bytes into `p`. It resolves to the number of + * bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error + * encountered. Even if `read()` resolves to `n` < `p.byteLength`, it may + * use all of `p` as scratch space during the call. If some data is + * available but not `p.byteLength` bytes, `read()` conventionally resolves + * to what is available instead of waiting for more. + * + * When `read()` encounters end-of-file condition, it resolves to EOF + * (`null`). + * + * When `read()` encounters an error, it rejects with an error. + * + * Callers should always process the `n` > `0` bytes returned before + * considering the EOF (`null`). Doing so correctly handles I/O errors that + * happen after reading some bytes and also both of the allowed EOF + * behaviors. + * + * @example + * ```typescript + * import { open, read, close, BaseDirectory } from "@tauri-apps/plugin-fs" + * // if "$APP/foo/bar.txt" contains the text "hello world": + * const file = await open("foo/bar.txt", { baseDir: BaseDirectory.App }); + * const buf = new Uint8Array(100); + * const numberOfBytesRead = await file.read(buf); // 11 bytes + * const text = new TextDecoder().decode(buf); // "hello world" + * await close(file.rid); + * ``` + * + * @since 2.0.0 + */ + async read(buffer: Uint8Array): Promise { + if (buffer.byteLength === 0) { + return 0; + } + + const [data, nread] = await invoke<[number[], number]>( + "plugin:fs|read", + { + rid: this.rid, + len: buffer.byteLength, + }, + ); + + buffer.set(data); + + return nread === 0 ? null : nread; + } + + /** + * Seek sets the offset for the next `read()` or `write()` to offset, + * interpreted according to `whence`: `Start` means relative to the + * start of the file, `Current` means relative to the current offset, + * and `End` means relative to the end. Seek resolves to the new offset + * relative to the start of the file. + * + * Seeking to an offset before the start of the file is an error. Seeking to + * any positive offset is legal, but the behavior of subsequent I/O + * operations on the underlying object is implementation-dependent. + * It returns the number of cursor position. + * + * @example + * ```typescript + * import { open, seek, write, SeekMode, BaseDirectory } from '@tauri-apps/plugin-fs'; + * + * // Given hello.txt pointing to file with "Hello world", which is 11 bytes long: + * const file = await open('hello.txt', { read: true, write: true, truncate: true, create: true, baseDir: BaseDirectory.App }); + * await file.write(new TextEncoder().encode("Hello world"), { baseDir: BaseDirectory.App }); + * + * // Seek 6 bytes from the start of the file + * console.log(await file.seek(6, SeekMode.Start)); // "6" + * // Seek 2 more bytes from the current position + * console.log(await file.seek(2, SeekMode.Current)); // "8" + * // Seek backwards 2 bytes from the end of the file + * console.log(await file.seek(-2, SeekMode.End)); // "9" (e.g. 11-2) + * ``` + * + * @since 2.0.0 + */ + async seek(offset: number, whence: SeekMode): Promise { + return invoke("plugin:fs|seek", { + rid: this.rid, + offset, + whence, + }); + } + + /** + * Returns a {@linkcode FileInfo } for this file. + * + * @example + * ```typescript + * import { open, fstat, BaseDirectory } from '@tauri-apps/plugin-fs'; + * const file = await open("file.txt", { read: true, baseDir: BaseDirectory.App }); + * const fileInfo = await fstat(file.rid); + * console.log(fileInfo.isFile); // true + * ``` + * + * @since 2.0.0 + */ + async stat(): Promise { + const res = await invoke("plugin:fs|fstat", { + rid: this.rid, + }); + + return parseFileInfo(res); + } + + /** + * Truncates or extends this file, to reach the specified `len`. + * If `len` is not specified then the entire file contents are truncated. + * + * @example + * ```typescript + * import { ftruncate, open, write, read, BaseDirectory } from '@tauri-apps/plugin-fs'; + * + * // truncate the entire file + * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); + * await ftruncate(file.rid); + * + * // truncate part of the file + * const file = await open("my_file.txt", { read: true, write: true, create: true, baseDir: BaseDirectory.App }); + * await write(file.rid, new TextEncoder().encode("Hello World")); + * await ftruncate(file.rid, 7); + * const data = new Uint8Array(32); + * await read(file.rid, data); + * console.log(new TextDecoder().decode(data)); // Hello W + * ``` + * + * @since 2.0.0 + */ + async truncate(len?: number): Promise { + return invoke("plugin:fs|ftruncate", { + rid: this.rid, + len, + }); + } + + /** + * Writes `p.byteLength` bytes from `p` to the underlying data stream. It + * resolves to the number of bytes written from `p` (`0` <= `n` <= + * `p.byteLength`) or reject with the error encountered that caused the + * write to stop early. `write()` must reject with a non-null error if + * would resolve to `n` < `p.byteLength`. `write()` must not modify the + * slice data, even temporarily. + * + * @example + * ```typescript + * import { open, write, close, BaseDirectory } from '@tauri-apps/plugin-fs'; + * const encoder = new TextEncoder(); + * const data = encoder.encode("Hello world"); + * const file = await open("bar.txt", { write: true, baseDir: BaseDirectory.App }); + * const bytesWritten = await write(file.rid, data); // 11 + * await close(file.rid); + * ``` + * + * @since 2.0.0 + */ + async write(data: Uint8Array): Promise { + return invoke("plugin:fs|write", { + rid: this.rid, + data: Array.from(data), + }); + } } /** * @since 2.0.0 */ interface CreateOptions { - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** @@ -437,72 +440,72 @@ interface CreateOptions { * @since 2.0.0 */ async function create( - path: string | URL, - options?: CreateOptions, + path: string | URL, + options?: CreateOptions, ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } - const rid = await invoke("plugin:fs|create", { - path: path instanceof URL ? path.toString() : path, - options, - }); + const rid = await invoke("plugin:fs|create", { + path: path instanceof URL ? path.toString() : path, + options, + }); - return new FileHandle(rid); + return new FileHandle(rid); } /** * @since 2.0.0 */ interface OpenOptions { - /** - * Sets the option for read access. This option, when `true`, means that the - * file should be read-able if opened. - */ - read?: boolean; - /** - * Sets the option for write access. This option, when `true`, means that - * the file should be write-able if opened. If the file already exists, - * any write calls on it will overwrite its contents, by default without - * truncating it. - */ - write?: boolean; - /** - * Sets the option for the append mode. This option, when `true`, means that - * writes will append to a file instead of overwriting previous contents. - * Note that setting `{ write: true, append: true }` has the same effect as - * setting only `{ append: true }`. - */ - append?: boolean; - /** - * Sets the option for truncating a previous file. If a file is - * successfully opened with this option set it will truncate the file to `0` - * size if it already exists. The file must be opened with write access - * for truncate to work. - */ - truncate?: boolean; - /** - * Sets the option to allow creating a new file, if one doesn't already - * exist at the specified path. Requires write or append access to be - * used. - */ - create?: boolean; - /** - * Defaults to `false`. If set to `true`, no file, directory, or symlink is - * allowed to exist at the target location. Requires write or append - * access to be used. When createNew is set to `true`, create and truncate - * are ignored. - */ - createNew?: boolean; - /** - * Permissions to use if creating the file (defaults to `0o666`, before - * the process's umask). - * Ignored on Windows. - */ - mode?: number; - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** + * Sets the option for read access. This option, when `true`, means that the + * file should be read-able if opened. + */ + read?: boolean; + /** + * Sets the option for write access. This option, when `true`, means that + * the file should be write-able if opened. If the file already exists, + * any write calls on it will overwrite its contents, by default without + * truncating it. + */ + write?: boolean; + /** + * Sets the option for the append mode. This option, when `true`, means that + * writes will append to a file instead of overwriting previous contents. + * Note that setting `{ write: true, append: true }` has the same effect as + * setting only `{ append: true }`. + */ + append?: boolean; + /** + * Sets the option for truncating a previous file. If a file is + * successfully opened with this option set it will truncate the file to `0` + * size if it already exists. The file must be opened with write access + * for truncate to work. + */ + truncate?: boolean; + /** + * Sets the option to allow creating a new file, if one doesn't already + * exist at the specified path. Requires write or append access to be + * used. + */ + create?: boolean; + /** + * Defaults to `false`. If set to `true`, no file, directory, or symlink is + * allowed to exist at the target location. Requires write or append + * access to be used. When createNew is set to `true`, create and truncate + * are ignored. + */ + createNew?: boolean; + /** + * Permissions to use if creating the file (defaults to `0o666`, before + * the process's umask). + * Ignored on Windows. + */ + mode?: number; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** @@ -522,29 +525,29 @@ interface OpenOptions { * @since 2.0.0 */ async function open( - path: string | URL, - options?: OpenOptions, + path: string | URL, + options?: OpenOptions, ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } - const rid = await invoke("plugin:fs|open", { - path: path instanceof URL ? path.toString() : path, - options, - }); + const rid = await invoke("plugin:fs|open", { + path: path instanceof URL ? path.toString() : path, + options, + }); - return new FileHandle(rid); + return new FileHandle(rid); } /** * @since 2.0.0 */ interface CopyFileOptions { - /** Base directory for `fromPath`. */ - fromPathBaseDir?: BaseDirectory; - /** Base directory for `toPath`. */ - toPathBaseDir?: BaseDirectory; + /** Base directory for `fromPath`. */ + fromPathBaseDir?: BaseDirectory; + /** Base directory for `toPath`. */ + toPathBaseDir?: BaseDirectory; } /** @@ -558,36 +561,36 @@ interface CopyFileOptions { * @since 2.0.0 */ async function copyFile( - fromPath: string | URL, - toPath: string | URL, - options?: CopyFileOptions, + fromPath: string | URL, + toPath: string | URL, + options?: CopyFileOptions, ): Promise { - if ( - (fromPath instanceof URL && fromPath.protocol !== "file:") || - (toPath instanceof URL && toPath.protocol !== "file:") - ) { - throw new TypeError("Must be a file URL."); - } - - return invoke("plugin:fs|copy_file", { - fromPath: fromPath instanceof URL ? fromPath.toString() : fromPath, - toPath: toPath instanceof URL ? toPath.toString() : toPath, - options, - }); + if ( + (fromPath instanceof URL && fromPath.protocol !== "file:") || + (toPath instanceof URL && toPath.protocol !== "file:") + ) { + throw new TypeError("Must be a file URL."); + } + + return invoke("plugin:fs|copy_file", { + fromPath: fromPath instanceof URL ? fromPath.toString() : fromPath, + toPath: toPath instanceof URL ? toPath.toString() : toPath, + options, + }); } /** * @since 2.0.0 */ interface MkdirOptions { - /** Permissions to use when creating the directory (defaults to `0o777`, before the process's umask). Ignored on Windows. */ - mode?: number; - /** - * Defaults to `false`. If set to `true`, means that any intermediate directories will also be created (as with the shell command `mkdir -p`). - * */ - recursive?: boolean; - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** Permissions to use when creating the directory (defaults to `0o777`, before the process's umask). Ignored on Windows. */ + mode?: number; + /** + * Defaults to `false`. If set to `true`, means that any intermediate directories will also be created (as with the shell command `mkdir -p`). + * */ + recursive?: boolean; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** @@ -601,25 +604,25 @@ interface MkdirOptions { * @since 2.0.0 */ async function mkdir( - path: string | URL, - options?: MkdirOptions, + path: string | URL, + options?: MkdirOptions, ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - - return invoke("plugin:fs|mkdir", { - path: path instanceof URL ? path.toString() : path, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + + return invoke("plugin:fs|mkdir", { + path: path instanceof URL ? path.toString() : path, + options, + }); } /** * @since 2.0.0 */ interface ReadDirOptions { - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** @@ -630,14 +633,14 @@ interface ReadDirOptions { * @since 2.0.0 */ interface DirEntry { - /** The name of the entry (file name with extension or directory name). */ - name: string; - /** Specifies whether this entry is a directory or not. */ - isDirectory: boolean; - /** Specifies whether this entry is a file or not. */ - isFile: boolean; - /** Specifies whether this entry is a symlink or not. */ - isSymlink: boolean; + /** The name of the entry (file name with extension or directory name). */ + name: string; + /** Specifies whether this entry is a directory or not. */ + isDirectory: boolean; + /** Specifies whether this entry is a file or not. */ + isFile: boolean; + /** Specifies whether this entry is a symlink or not. */ + isSymlink: boolean; } /** @@ -662,25 +665,25 @@ interface DirEntry { * @since 2.0.0 */ async function readDir( - path: string | URL, - options?: ReadDirOptions, + path: string | URL, + options?: ReadDirOptions, ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - - return invoke("plugin:fs|read_dir", { - path: path instanceof URL ? path.toString() : path, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + + return invoke("plugin:fs|read_dir", { + path: path instanceof URL ? path.toString() : path, + options, + }); } /** * @since 2.0.0 */ interface ReadFileOptions { - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** @@ -695,19 +698,19 @@ interface ReadFileOptions { * @since 2.0.0 */ async function readFile( - path: string | URL, - options?: ReadFileOptions, + path: string | URL, + options?: ReadFileOptions, ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } - const arr = await invoke("plugin:fs|read_file", { - path: path instanceof URL ? path.toString() : path, - options, - }); + const arr = await invoke("plugin:fs|read_file", { + path: path instanceof URL ? path.toString() : path, + options, + }); - return Uint8Array.from(arr); + return Uint8Array.from(arr); } /** @@ -721,17 +724,17 @@ async function readFile( * @since 2.0.0 */ async function readTextFile( - path: string | URL, - options?: ReadFileOptions, + path: string | URL, + options?: ReadFileOptions, ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - - return invoke("plugin:fs|read_text_file", { - path: path instanceof URL ? path.toString() : path, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + + return invoke("plugin:fs|read_text_file", { + path: path instanceof URL ? path.toString() : path, + options, + }); } /** @@ -750,53 +753,56 @@ async function readTextFile( * @since 2.0.0 */ async function readTextFileLines( - path: string | URL, - options?: ReadFileOptions, + path: string | URL, + options?: ReadFileOptions, ): Promise> { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - - const pathStr = path instanceof URL ? path.toString() : path; - - return Promise.resolve({ - path: pathStr, - rid: null as number | null, - async next(): Promise> { - if (!this.rid) { - this.rid = await invoke("plugin:fs|read_text_file_lines", { - path: pathStr, - options, - }); - } - - const [line, done] = await invoke<[string | null, boolean]>( - "plugin:fs|read_text_file_lines_next", - { rid: this.rid }, - ); - - // an iteration is over, reset rid for next iteration - if (done) this.rid = null; - - return { - value: done ? "" : (line as string), - done, - }; - }, - [Symbol.asyncIterator](): AsyncIterableIterator { - return this; - }, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + + const pathStr = path instanceof URL ? path.toString() : path; + + return Promise.resolve({ + path: pathStr, + rid: null as number | null, + async next(): Promise> { + if (!this.rid) { + this.rid = await invoke( + "plugin:fs|read_text_file_lines", + { + path: pathStr, + options, + }, + ); + } + + const [line, done] = await invoke<[string | null, boolean]>( + "plugin:fs|read_text_file_lines_next", + { rid: this.rid }, + ); + + // an iteration is over, reset rid for next iteration + if (done) this.rid = null; + + return { + value: done ? "" : (line as string), + done, + }; + }, + [Symbol.asyncIterator](): AsyncIterableIterator { + return this; + }, + }); } /** * @since 2.0.0 */ interface RemoveOptions { - /** Defaults to `false`. If set to `true`, path will be removed even if it's a non-empty directory. */ - recursive?: boolean; - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** Defaults to `false`. If set to `true`, path will be removed even if it's a non-empty directory. */ + recursive?: boolean; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** @@ -812,27 +818,27 @@ interface RemoveOptions { * @since 2.0.0 */ async function remove( - path: string | URL, - options?: RemoveOptions, + path: string | URL, + options?: RemoveOptions, ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - - return invoke("plugin:fs|remove", { - path: path instanceof URL ? path.toString() : path, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + + return invoke("plugin:fs|remove", { + path: path instanceof URL ? path.toString() : path, + options, + }); } /** * @since 2.0.0 */ interface RenameOptions { - /** Base directory for `oldPath`. */ - oldPathBaseDir?: BaseDirectory; - /** Base directory for `newPath`. */ - newPathBaseDir?: BaseDirectory; + /** Base directory for `oldPath`. */ + oldPathBaseDir?: BaseDirectory; + /** Base directory for `newPath`. */ + newPathBaseDir?: BaseDirectory; } /** @@ -851,30 +857,30 @@ interface RenameOptions { * @since 2.0.0 */ async function rename( - oldPath: string | URL, - newPath: string | URL, - options?: RenameOptions, + oldPath: string | URL, + newPath: string | URL, + options?: RenameOptions, ): Promise { - if ( - (oldPath instanceof URL && oldPath.protocol !== "file:") || - (newPath instanceof URL && newPath.protocol !== "file:") - ) { - throw new TypeError("Must be a file URL."); - } - - return invoke("plugin:fs|rename", { - oldPath: oldPath instanceof URL ? oldPath.toString() : oldPath, - newPath: newPath instanceof URL ? newPath.toString() : newPath, - options, - }); + if ( + (oldPath instanceof URL && oldPath.protocol !== "file:") || + (newPath instanceof URL && newPath.protocol !== "file:") + ) { + throw new TypeError("Must be a file URL."); + } + + return invoke("plugin:fs|rename", { + oldPath: oldPath instanceof URL ? oldPath.toString() : oldPath, + newPath: newPath instanceof URL ? newPath.toString() : newPath, + options, + }); } /** * @since 2.0.0 */ interface StatOptions { - /** Base directory for `path`. */ - baseDir?: BaseDirectory; + /** Base directory for `path`. */ + baseDir?: BaseDirectory; } /** @@ -891,15 +897,15 @@ interface StatOptions { * @since 2.0.0 */ async function stat( - path: string | URL, - options?: StatOptions, + path: string | URL, + options?: StatOptions, ): Promise { - const res = await invoke("plugin:fs|stat", { - path: path instanceof URL ? path.toString() : path, - options, - }); + const res = await invoke("plugin:fs|stat", { + path: path instanceof URL ? path.toString() : path, + options, + }); - return parseFileInfo(res); + return parseFileInfo(res); } /** @@ -917,23 +923,23 @@ async function stat( * @since 2.0.0 */ async function lstat( - path: string | URL, - options?: StatOptions, + path: string | URL, + options?: StatOptions, ): Promise { - const res = await invoke("plugin:fs|lstat", { - path: path instanceof URL ? path.toString() : path, - options, - }); + const res = await invoke("plugin:fs|lstat", { + path: path instanceof URL ? path.toString() : path, + options, + }); - return parseFileInfo(res); + return parseFileInfo(res); } /** * @since 2.0.0 */ interface TruncateOptions { - /** Base directory for `path`. */ - baseDir?: BaseDirectory; + /** Base directory for `path`. */ + baseDir?: BaseDirectory; } /** @@ -957,35 +963,35 @@ interface TruncateOptions { * @since 2.0.0 */ async function truncate( - path: string | URL, - len?: number, - options?: TruncateOptions, + path: string | URL, + len?: number, + options?: TruncateOptions, ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - - return invoke("plugin:fs|truncate", { - path: path instanceof URL ? path.toString() : path, - len, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + + return invoke("plugin:fs|truncate", { + path: path instanceof URL ? path.toString() : path, + len, + options, + }); } /** * @since 2.0.0 */ interface WriteFileOptions { - /** Defaults to `false`. If set to `true`, will append to a file instead of overwriting previous contents. */ - append?: boolean; - /** Sets the option to allow creating a new file, if one doesn't already exist at the specified path (defaults to `true`). */ - create?: boolean; - /** Sets the option to create a new file, failing if it already exists. */ - createNew?: boolean; - /** File permissions. Ignored on Windows. */ - mode?: number; - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** Defaults to `false`. If set to `true`, will append to a file instead of overwriting previous contents. */ + append?: boolean; + /** Sets the option to allow creating a new file, if one doesn't already exist at the specified path (defaults to `true`). */ + create?: boolean; + /** Sets the option to create a new file, failing if it already exists. */ + createNew?: boolean; + /** File permissions. Ignored on Windows. */ + mode?: number; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** @@ -1002,19 +1008,19 @@ interface WriteFileOptions { * @since 2.0.0 */ async function writeFile( - path: string | URL, - data: Uint8Array, - options?: WriteFileOptions, + path: string | URL, + data: Uint8Array, + options?: WriteFileOptions, ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - - return invoke("plugin:fs|write_file", { - path: path instanceof URL ? path.toString() : path, - data: Array.from(data), - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + + return invoke("plugin:fs|write_file", { + path: path instanceof URL ? path.toString() : path, + data: Array.from(data), + options, + }); } /** @@ -1029,27 +1035,27 @@ async function writeFile( * @since 2.0.0 */ async function writeTextFile( - path: string | URL, - data: string, - options?: WriteFileOptions, + path: string | URL, + data: string, + options?: WriteFileOptions, ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - - return invoke("plugin:fs|write_text_file", { - path: path instanceof URL ? path.toString() : path, - data, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + + return invoke("plugin:fs|write_text_file", { + path: path instanceof URL ? path.toString() : path, + data, + options, + }); } /** * @since 2.0.0 */ interface ExistsOptions { - /** Base directory for `path`. */ - baseDir?: BaseDirectory; + /** Base directory for `path`. */ + baseDir?: BaseDirectory; } /** @@ -1064,103 +1070,103 @@ interface ExistsOptions { * @since 2.0.0 */ async function exists( - path: string | URL, - options?: ExistsOptions, + path: string | URL, + options?: ExistsOptions, ): Promise { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - - return invoke("plugin:fs|exists", { - path: path instanceof URL ? path.toString() : path, - options, - }); + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + + return invoke("plugin:fs|exists", { + path: path instanceof URL ? path.toString() : path, + options, + }); } /** * @since 2.0.0 */ interface WatchOptions { - /** Watch a directory recursively */ - recursive?: boolean; - /** Base directory for `path` */ - baseDir?: BaseDirectory; + /** Watch a directory recursively */ + recursive?: boolean; + /** Base directory for `path` */ + baseDir?: BaseDirectory; } /** * @since 2.0.0 */ interface DebouncedWatchOptions extends WatchOptions { - /** Debounce delay */ - delayMs?: number; + /** Debounce delay */ + delayMs?: number; } /** * @since 2.0.0 */ type WatchEvent = { - type: WatchEventKind; - paths: string[]; - attrs: unknown; + type: WatchEventKind; + paths: string[]; + attrs: unknown; }; /** * @since 2.0.0 */ type WatchEventKind = - | "any" - | { access: WatchEventKindAccess } - | { create: WatchEventKindCreate } - | { modify: WatchEventKindModify } - | { remove: WatchEventKindRemove } - | "other"; + | "any" + | { access: WatchEventKindAccess } + | { create: WatchEventKindCreate } + | { modify: WatchEventKindModify } + | { remove: WatchEventKindRemove } + | "other"; /** * @since 2.0.0 */ type WatchEventKindAccess = - | { kind: "any" } - | { kind: "close"; mode: "any" | "execute" | "read" | "write" | "other" } - | { kind: "open"; mode: "any" | "execute" | "read" | "write" | "other" } - | { kind: "other" }; + | { kind: "any" } + | { kind: "close"; mode: "any" | "execute" | "read" | "write" | "other" } + | { kind: "open"; mode: "any" | "execute" | "read" | "write" | "other" } + | { kind: "other" }; /** * @since 2.0.0 */ type WatchEventKindCreate = - | { kind: "any" } - | { kind: "file" } - | { kind: "folder" } - | { kind: "other" }; + | { kind: "any" } + | { kind: "file" } + | { kind: "folder" } + | { kind: "other" }; /** * @since 2.0.0 */ type WatchEventKindModify = - | { kind: "any" } - | { kind: "data"; mode: "any" | "size" | "content" | "other" } - | { - kind: "metadata"; - mode: - | "any" - | "access-time" - | "write-time" - | "permissions" - | "ownership" - | "extended" - | "other"; - } - | { kind: "rename"; mode: "any" | "to" | "from" | "both" | "other" } - | { kind: "other" }; + | { kind: "any" } + | { kind: "data"; mode: "any" | "size" | "content" | "other" } + | { + kind: "metadata"; + mode: + | "any" + | "access-time" + | "write-time" + | "permissions" + | "ownership" + | "extended" + | "other"; + } + | { kind: "rename"; mode: "any" | "to" | "from" | "both" | "other" } + | { kind: "other" }; /** * @since 2.0.0 */ type WatchEventKindRemove = - | { kind: "any" } - | { kind: "file" } - | { kind: "folder" } - | { kind: "other" }; + | { kind: "any" } + | { kind: "file" } + | { kind: "folder" } + | { kind: "other" }; /** * @since 2.0.0 @@ -1168,7 +1174,7 @@ type WatchEventKindRemove = type UnwatchFn = () => void; async function unwatch(rid: number): Promise { - await invoke("plugin:fs|unwatch", { rid }); + await invoke("plugin:fs|unwatch", { rid }); } /** @@ -1177,36 +1183,36 @@ async function unwatch(rid: number): Promise { * @since 2.0.0 */ async function watch( - paths: string | string[] | URL | URL[], - cb: (event: WatchEvent) => void, - options?: DebouncedWatchOptions, + paths: string | string[] | URL | URL[], + cb: (event: WatchEvent) => void, + options?: DebouncedWatchOptions, ): Promise { - const opts = { - recursive: false, - delayMs: 2000, - ...options, - }; - - const watchPaths = Array.isArray(paths) ? paths : [paths]; - - for (const path of watchPaths) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - } - - const onEvent = new Channel(); - onEvent.onmessage = cb; - - const rid: number = await invoke("plugin:fs|watch", { - paths: watchPaths.map((p) => (p instanceof URL ? p.toString() : p)), - options: opts, - onEvent, - }); - - return () => { - void unwatch(rid); - }; + const opts = { + recursive: false, + delayMs: 2000, + ...options, + }; + + const watchPaths = Array.isArray(paths) ? paths : [paths]; + + for (const path of watchPaths) { + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + } + + const onEvent = new Channel(); + onEvent.onmessage = cb; + + const rid: number = await invoke("plugin:fs|watch", { + paths: watchPaths.map((p) => (p instanceof URL ? p.toString() : p)), + options: opts, + onEvent, + }); + + return () => { + void unwatch(rid); + }; } /** @@ -1215,84 +1221,84 @@ async function watch( * @since 2.0.0 */ async function watchImmediate( - paths: string | string[] | URL | URL[], - cb: (event: WatchEvent) => void, - options?: WatchOptions, + paths: string | string[] | URL | URL[], + cb: (event: WatchEvent) => void, + options?: WatchOptions, ): Promise { - const opts = { - recursive: false, - ...options, - delayMs: null, - }; - - const watchPaths = Array.isArray(paths) ? paths : [paths]; - - for (const path of watchPaths) { - if (path instanceof URL && path.protocol !== "file:") { - throw new TypeError("Must be a file URL."); - } - } - - const onEvent = new Channel(); - onEvent.onmessage = cb; - - const rid: number = await invoke("plugin:fs|watch", { - paths: watchPaths.map((p) => (p instanceof URL ? p.toString() : p)), - options: opts, - onEvent, - }); - - return () => { - void unwatch(rid); - }; + const opts = { + recursive: false, + ...options, + delayMs: null, + }; + + const watchPaths = Array.isArray(paths) ? paths : [paths]; + + for (const path of watchPaths) { + if (path instanceof URL && path.protocol !== "file:") { + throw new TypeError("Must be a file URL."); + } + } + + const onEvent = new Channel(); + onEvent.onmessage = cb; + + const rid: number = await invoke("plugin:fs|watch", { + paths: watchPaths.map((p) => (p instanceof URL ? p.toString() : p)), + options: opts, + onEvent, + }); + + return () => { + void unwatch(rid); + }; } export type { - CreateOptions, - OpenOptions, - CopyFileOptions, - MkdirOptions, - DirEntry, - ReadDirOptions, - ReadFileOptions, - RemoveOptions, - RenameOptions, - StatOptions, - TruncateOptions, - WriteFileOptions, - ExistsOptions, - FileInfo, - WatchOptions, - DebouncedWatchOptions, - WatchEvent, - WatchEventKind, - WatchEventKindAccess, - WatchEventKindCreate, - WatchEventKindModify, - WatchEventKindRemove, - UnwatchFn, + CreateOptions, + OpenOptions, + CopyFileOptions, + MkdirOptions, + DirEntry, + ReadDirOptions, + ReadFileOptions, + RemoveOptions, + RenameOptions, + StatOptions, + TruncateOptions, + WriteFileOptions, + ExistsOptions, + FileInfo, + WatchOptions, + DebouncedWatchOptions, + WatchEvent, + WatchEventKind, + WatchEventKindAccess, + WatchEventKindCreate, + WatchEventKindModify, + WatchEventKindRemove, + UnwatchFn, }; export { - BaseDirectory, - FileHandle, - create, - open, - copyFile, - mkdir, - readDir, - readFile, - readTextFile, - readTextFileLines, - remove, - rename, - SeekMode, - stat, - lstat, - truncate, - writeFile, - writeTextFile, - exists, - watch, - watchImmediate, + BaseDirectory, + FileHandle, + create, + open, + copyFile, + mkdir, + readDir, + readFile, + readTextFile, + readTextFileLines, + remove, + rename, + SeekMode, + stat, + lstat, + truncate, + writeFile, + writeTextFile, + exists, + watch, + watchImmediate, }; diff --git a/package.json b/package.json index 219464e..ec27e6a 100644 --- a/package.json +++ b/package.json @@ -26,11 +26,7 @@ "main": "./dist-js/index.cjs", "module": "./dist-js/index.js", "types": "./dist-js/index.d.ts", - "files": [ - "dist-js", - "README.md", - "LICENSE" - ], + "files": ["dist-js", "README.md", "LICENSE"], "scripts": { "build": "rollup -c", "prepublishOnly": "TypeScriptESBuild 'Source/**/*.ts'" @@ -44,7 +40,5 @@ "publishConfig": { "access": "public" }, - "authors": [ - "Tauri Programme within The Commons Conservancy" - ] + "authors": ["Tauri Programme within The Commons Conservancy"] } diff --git a/permissions/schemas/schema.json b/permissions/schemas/schema.json index fadb22a..15599f3 100644 --- a/permissions/schemas/schema.json +++ b/permissions/schemas/schema.json @@ -1,2292 +1,1682 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "PermissionFile", - "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", - "type": "object", - "properties": { - "default": { - "description": "The default permission set for the plugin", - "anyOf": [ - { - "$ref": "#/definitions/DefaultPermission" - }, - { - "type": "null" - } - ] - }, - "set": { - "description": "A list of permissions sets defined", - "type": "array", - "items": { - "$ref": "#/definitions/PermissionSet" - } - }, - "permission": { - "description": "A list of inlined permissions", - "default": [], - "type": "array", - "items": { - "$ref": "#/definitions/Permission" - } - } - }, - "definitions": { - "DefaultPermission": { - "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", - "type": "object", - "required": [ - "permissions" - ], - "properties": { - "version": { - "description": "The version of the permission.", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 1.0 - }, - "description": { - "description": "Human-readable description of what the permission does.", - "type": [ - "string", - "null" - ] - }, - "permissions": { - "description": "All permissions this set contains.", - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "PermissionSet": { - "description": "A set of direct permissions grouped together under a new name.", - "type": "object", - "required": [ - "description", - "identifier", - "permissions" - ], - "properties": { - "identifier": { - "description": "A unique identifier for the permission.", - "type": "string" - }, - "description": { - "description": "Human-readable description of what the permission does.", - "type": "string" - }, - "permissions": { - "description": "All permissions this set contains.", - "type": "array", - "items": { - "$ref": "#/definitions/PermissionKind" - } - } - } - }, - "Permission": { - "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", - "type": "object", - "required": [ - "identifier" - ], - "properties": { - "version": { - "description": "The version of the permission.", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 1.0 - }, - "identifier": { - "description": "A unique identifier for the permission.", - "type": "string" - }, - "description": { - "description": "Human-readable description of what the permission does.", - "type": [ - "string", - "null" - ] - }, - "commands": { - "description": "Allowed or denied commands when using this permission.", - "default": { - "allow": [], - "deny": [] - }, - "allOf": [ - { - "$ref": "#/definitions/Commands" - } - ] - }, - "scope": { - "description": "Allowed or denied scoped when using this permission.", - "allOf": [ - { - "$ref": "#/definitions/Scopes" - } - ] - }, - "platforms": { - "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", - "default": [ - "linux", - "macOS", - "windows", - "android", - "iOS" - ], - "type": "array", - "items": { - "$ref": "#/definitions/Target" - } - } - } - }, - "Commands": { - "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", - "type": "object", - "properties": { - "allow": { - "description": "Allowed command.", - "default": [], - "type": "array", - "items": { - "type": "string" - } - }, - "deny": { - "description": "Denied command, which takes priority.", - "default": [], - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "Scopes": { - "description": "A restriction of the command/endpoint functionality.\n\nIt can be of any serde serializable type and is used for allowing or preventing certain actions inside a Tauri command.\n\nThe scope is passed to the command and handled/enforced by the command itself.", - "type": "object", - "properties": { - "allow": { - "description": "Data that defines what is allowed by the scope.", - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/Value" - } - }, - "deny": { - "description": "Data that defines what is denied by the scope.", - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/Value" - } - } - } - }, - "Value": { - "description": "All supported ACL values.", - "anyOf": [ - { - "description": "Represents a null JSON value.", - "type": "null" - }, - { - "description": "Represents a [`bool`].", - "type": "boolean" - }, - { - "description": "Represents a valid ACL [`Number`].", - "allOf": [ - { - "$ref": "#/definitions/Number" - } - ] - }, - { - "description": "Represents a [`String`].", - "type": "string" - }, - { - "description": "Represents a list of other [`Value`]s.", - "type": "array", - "items": { - "$ref": "#/definitions/Value" - } - }, - { - "description": "Represents a map of [`String`] keys to [`Value`]s.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/Value" - } - } - ] - }, - "Number": { - "description": "A valid ACL number.", - "anyOf": [ - { - "description": "Represents an [`i64`].", - "type": "integer", - "format": "int64" - }, - { - "description": "Represents a [`f64`].", - "type": "number", - "format": "double" - } - ] - }, - "Target": { - "description": "Platform target.", - "oneOf": [ - { - "description": "MacOS.", - "type": "string", - "enum": [ - "macOS" - ] - }, - { - "description": "Windows.", - "type": "string", - "enum": [ - "windows" - ] - }, - { - "description": "Linux.", - "type": "string", - "enum": [ - "linux" - ] - }, - { - "description": "Android.", - "type": "string", - "enum": [ - "android" - ] - }, - { - "description": "iOS.", - "type": "string", - "enum": [ - "iOS" - ] - } - ] - }, - "PermissionKind": { - "type": "string", - "oneOf": [ - { - "description": "allow-app-read-recursive -> This allows full recursive read access to the complete `$APP` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-app-read-recursive" - ] - }, - { - "description": "allow-app-write-recursive -> This allows full recusrive write access to the complete `$APP` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-app-write-recursive" - ] - }, - { - "description": "allow-app-read -> This allows non-recursive read access to the `$APP` folder.", - "type": "string", - "enum": [ - "allow-app-read" - ] - }, - { - "description": "allow-app-write -> This allows non-recursive write access to the `$APP` folder.", - "type": "string", - "enum": [ - "allow-app-write" - ] - }, - { - "description": "allow-app-meta-recursive -> This allows read access to metadata of the `$APP` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-app-meta-recursive" - ] - }, - { - "description": "allow-app-meta -> This allows read access to metadata of the `$APP` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-app-meta" - ] - }, - { - "description": "scope-app-recursive -> This scope recursive access to the complete `$APP` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-app-recursive" - ] - }, - { - "description": "scope-app -> This scope permits access to all files and list content of top level directories in the `$APP`folder.", - "type": "string", - "enum": [ - "scope-app" - ] - }, - { - "description": "scope-app-index -> This scope permits to list all files and folders in the `$APP`folder.", - "type": "string", - "enum": [ - "scope-app-index" - ] - }, - { - "description": "allow-appcache-read-recursive -> This allows full recursive read access to the complete `$APPCACHE` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-appcache-read-recursive" - ] - }, - { - "description": "allow-appcache-write-recursive -> This allows full recusrive write access to the complete `$APPCACHE` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-appcache-write-recursive" - ] - }, - { - "description": "allow-appcache-read -> This allows non-recursive read access to the `$APPCACHE` folder.", - "type": "string", - "enum": [ - "allow-appcache-read" - ] - }, - { - "description": "allow-appcache-write -> This allows non-recursive write access to the `$APPCACHE` folder.", - "type": "string", - "enum": [ - "allow-appcache-write" - ] - }, - { - "description": "allow-appcache-meta-recursive -> This allows read access to metadata of the `$APPCACHE` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-appcache-meta-recursive" - ] - }, - { - "description": "allow-appcache-meta -> This allows read access to metadata of the `$APPCACHE` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-appcache-meta" - ] - }, - { - "description": "scope-appcache-recursive -> This scope recursive access to the complete `$APPCACHE` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-appcache-recursive" - ] - }, - { - "description": "scope-appcache -> This scope permits access to all files and list content of top level directories in the `$APPCACHE`folder.", - "type": "string", - "enum": [ - "scope-appcache" - ] - }, - { - "description": "scope-appcache-index -> This scope permits to list all files and folders in the `$APPCACHE`folder.", - "type": "string", - "enum": [ - "scope-appcache-index" - ] - }, - { - "description": "allow-appconfig-read-recursive -> This allows full recursive read access to the complete `$APPCONFIG` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-appconfig-read-recursive" - ] - }, - { - "description": "allow-appconfig-write-recursive -> This allows full recusrive write access to the complete `$APPCONFIG` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-appconfig-write-recursive" - ] - }, - { - "description": "allow-appconfig-read -> This allows non-recursive read access to the `$APPCONFIG` folder.", - "type": "string", - "enum": [ - "allow-appconfig-read" - ] - }, - { - "description": "allow-appconfig-write -> This allows non-recursive write access to the `$APPCONFIG` folder.", - "type": "string", - "enum": [ - "allow-appconfig-write" - ] - }, - { - "description": "allow-appconfig-meta-recursive -> This allows read access to metadata of the `$APPCONFIG` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-appconfig-meta-recursive" - ] - }, - { - "description": "allow-appconfig-meta -> This allows read access to metadata of the `$APPCONFIG` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-appconfig-meta" - ] - }, - { - "description": "scope-appconfig-recursive -> This scope recursive access to the complete `$APPCONFIG` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-appconfig-recursive" - ] - }, - { - "description": "scope-appconfig -> This scope permits access to all files and list content of top level directories in the `$APPCONFIG`folder.", - "type": "string", - "enum": [ - "scope-appconfig" - ] - }, - { - "description": "scope-appconfig-index -> This scope permits to list all files and folders in the `$APPCONFIG`folder.", - "type": "string", - "enum": [ - "scope-appconfig-index" - ] - }, - { - "description": "allow-appdata-read-recursive -> This allows full recursive read access to the complete `$APPDATA` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-appdata-read-recursive" - ] - }, - { - "description": "allow-appdata-write-recursive -> This allows full recusrive write access to the complete `$APPDATA` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-appdata-write-recursive" - ] - }, - { - "description": "allow-appdata-read -> This allows non-recursive read access to the `$APPDATA` folder.", - "type": "string", - "enum": [ - "allow-appdata-read" - ] - }, - { - "description": "allow-appdata-write -> This allows non-recursive write access to the `$APPDATA` folder.", - "type": "string", - "enum": [ - "allow-appdata-write" - ] - }, - { - "description": "allow-appdata-meta-recursive -> This allows read access to metadata of the `$APPDATA` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-appdata-meta-recursive" - ] - }, - { - "description": "allow-appdata-meta -> This allows read access to metadata of the `$APPDATA` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-appdata-meta" - ] - }, - { - "description": "scope-appdata-recursive -> This scope recursive access to the complete `$APPDATA` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-appdata-recursive" - ] - }, - { - "description": "scope-appdata -> This scope permits access to all files and list content of top level directories in the `$APPDATA`folder.", - "type": "string", - "enum": [ - "scope-appdata" - ] - }, - { - "description": "scope-appdata-index -> This scope permits to list all files and folders in the `$APPDATA`folder.", - "type": "string", - "enum": [ - "scope-appdata-index" - ] - }, - { - "description": "allow-applocaldata-read-recursive -> This allows full recursive read access to the complete `$APPLOCALDATA` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-applocaldata-read-recursive" - ] - }, - { - "description": "allow-applocaldata-write-recursive -> This allows full recusrive write access to the complete `$APPLOCALDATA` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-applocaldata-write-recursive" - ] - }, - { - "description": "allow-applocaldata-read -> This allows non-recursive read access to the `$APPLOCALDATA` folder.", - "type": "string", - "enum": [ - "allow-applocaldata-read" - ] - }, - { - "description": "allow-applocaldata-write -> This allows non-recursive write access to the `$APPLOCALDATA` folder.", - "type": "string", - "enum": [ - "allow-applocaldata-write" - ] - }, - { - "description": "allow-applocaldata-meta-recursive -> This allows read access to metadata of the `$APPLOCALDATA` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-applocaldata-meta-recursive" - ] - }, - { - "description": "allow-applocaldata-meta -> This allows read access to metadata of the `$APPLOCALDATA` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-applocaldata-meta" - ] - }, - { - "description": "scope-applocaldata-recursive -> This scope recursive access to the complete `$APPLOCALDATA` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-applocaldata-recursive" - ] - }, - { - "description": "scope-applocaldata -> This scope permits access to all files and list content of top level directories in the `$APPLOCALDATA`folder.", - "type": "string", - "enum": [ - "scope-applocaldata" - ] - }, - { - "description": "scope-applocaldata-index -> This scope permits to list all files and folders in the `$APPLOCALDATA`folder.", - "type": "string", - "enum": [ - "scope-applocaldata-index" - ] - }, - { - "description": "allow-applog-read-recursive -> This allows full recursive read access to the complete `$APPLOG` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-applog-read-recursive" - ] - }, - { - "description": "allow-applog-write-recursive -> This allows full recusrive write access to the complete `$APPLOG` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-applog-write-recursive" - ] - }, - { - "description": "allow-applog-read -> This allows non-recursive read access to the `$APPLOG` folder.", - "type": "string", - "enum": [ - "allow-applog-read" - ] - }, - { - "description": "allow-applog-write -> This allows non-recursive write access to the `$APPLOG` folder.", - "type": "string", - "enum": [ - "allow-applog-write" - ] - }, - { - "description": "allow-applog-meta-recursive -> This allows read access to metadata of the `$APPLOG` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-applog-meta-recursive" - ] - }, - { - "description": "allow-applog-meta -> This allows read access to metadata of the `$APPLOG` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-applog-meta" - ] - }, - { - "description": "scope-applog-recursive -> This scope recursive access to the complete `$APPLOG` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-applog-recursive" - ] - }, - { - "description": "scope-applog -> This scope permits access to all files and list content of top level directories in the `$APPLOG`folder.", - "type": "string", - "enum": [ - "scope-applog" - ] - }, - { - "description": "scope-applog-index -> This scope permits to list all files and folders in the `$APPLOG`folder.", - "type": "string", - "enum": [ - "scope-applog-index" - ] - }, - { - "description": "allow-audio-read-recursive -> This allows full recursive read access to the complete `$AUDIO` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-audio-read-recursive" - ] - }, - { - "description": "allow-audio-write-recursive -> This allows full recusrive write access to the complete `$AUDIO` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-audio-write-recursive" - ] - }, - { - "description": "allow-audio-read -> This allows non-recursive read access to the `$AUDIO` folder.", - "type": "string", - "enum": [ - "allow-audio-read" - ] - }, - { - "description": "allow-audio-write -> This allows non-recursive write access to the `$AUDIO` folder.", - "type": "string", - "enum": [ - "allow-audio-write" - ] - }, - { - "description": "allow-audio-meta-recursive -> This allows read access to metadata of the `$AUDIO` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-audio-meta-recursive" - ] - }, - { - "description": "allow-audio-meta -> This allows read access to metadata of the `$AUDIO` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-audio-meta" - ] - }, - { - "description": "scope-audio-recursive -> This scope recursive access to the complete `$AUDIO` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-audio-recursive" - ] - }, - { - "description": "scope-audio -> This scope permits access to all files and list content of top level directories in the `$AUDIO`folder.", - "type": "string", - "enum": [ - "scope-audio" - ] - }, - { - "description": "scope-audio-index -> This scope permits to list all files and folders in the `$AUDIO`folder.", - "type": "string", - "enum": [ - "scope-audio-index" - ] - }, - { - "description": "allow-cache-read-recursive -> This allows full recursive read access to the complete `$CACHE` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-cache-read-recursive" - ] - }, - { - "description": "allow-cache-write-recursive -> This allows full recusrive write access to the complete `$CACHE` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-cache-write-recursive" - ] - }, - { - "description": "allow-cache-read -> This allows non-recursive read access to the `$CACHE` folder.", - "type": "string", - "enum": [ - "allow-cache-read" - ] - }, - { - "description": "allow-cache-write -> This allows non-recursive write access to the `$CACHE` folder.", - "type": "string", - "enum": [ - "allow-cache-write" - ] - }, - { - "description": "allow-cache-meta-recursive -> This allows read access to metadata of the `$CACHE` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-cache-meta-recursive" - ] - }, - { - "description": "allow-cache-meta -> This allows read access to metadata of the `$CACHE` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-cache-meta" - ] - }, - { - "description": "scope-cache-recursive -> This scope recursive access to the complete `$CACHE` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-cache-recursive" - ] - }, - { - "description": "scope-cache -> This scope permits access to all files and list content of top level directories in the `$CACHE`folder.", - "type": "string", - "enum": [ - "scope-cache" - ] - }, - { - "description": "scope-cache-index -> This scope permits to list all files and folders in the `$CACHE`folder.", - "type": "string", - "enum": [ - "scope-cache-index" - ] - }, - { - "description": "allow-config-read-recursive -> This allows full recursive read access to the complete `$CONFIG` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-config-read-recursive" - ] - }, - { - "description": "allow-config-write-recursive -> This allows full recusrive write access to the complete `$CONFIG` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-config-write-recursive" - ] - }, - { - "description": "allow-config-read -> This allows non-recursive read access to the `$CONFIG` folder.", - "type": "string", - "enum": [ - "allow-config-read" - ] - }, - { - "description": "allow-config-write -> This allows non-recursive write access to the `$CONFIG` folder.", - "type": "string", - "enum": [ - "allow-config-write" - ] - }, - { - "description": "allow-config-meta-recursive -> This allows read access to metadata of the `$CONFIG` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-config-meta-recursive" - ] - }, - { - "description": "allow-config-meta -> This allows read access to metadata of the `$CONFIG` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-config-meta" - ] - }, - { - "description": "scope-config-recursive -> This scope recursive access to the complete `$CONFIG` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-config-recursive" - ] - }, - { - "description": "scope-config -> This scope permits access to all files and list content of top level directories in the `$CONFIG`folder.", - "type": "string", - "enum": [ - "scope-config" - ] - }, - { - "description": "scope-config-index -> This scope permits to list all files and folders in the `$CONFIG`folder.", - "type": "string", - "enum": [ - "scope-config-index" - ] - }, - { - "description": "allow-data-read-recursive -> This allows full recursive read access to the complete `$DATA` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-data-read-recursive" - ] - }, - { - "description": "allow-data-write-recursive -> This allows full recusrive write access to the complete `$DATA` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-data-write-recursive" - ] - }, - { - "description": "allow-data-read -> This allows non-recursive read access to the `$DATA` folder.", - "type": "string", - "enum": [ - "allow-data-read" - ] - }, - { - "description": "allow-data-write -> This allows non-recursive write access to the `$DATA` folder.", - "type": "string", - "enum": [ - "allow-data-write" - ] - }, - { - "description": "allow-data-meta-recursive -> This allows read access to metadata of the `$DATA` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-data-meta-recursive" - ] - }, - { - "description": "allow-data-meta -> This allows read access to metadata of the `$DATA` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-data-meta" - ] - }, - { - "description": "scope-data-recursive -> This scope recursive access to the complete `$DATA` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-data-recursive" - ] - }, - { - "description": "scope-data -> This scope permits access to all files and list content of top level directories in the `$DATA`folder.", - "type": "string", - "enum": [ - "scope-data" - ] - }, - { - "description": "scope-data-index -> This scope permits to list all files and folders in the `$DATA`folder.", - "type": "string", - "enum": [ - "scope-data-index" - ] - }, - { - "description": "allow-desktop-read-recursive -> This allows full recursive read access to the complete `$DESKTOP` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-desktop-read-recursive" - ] - }, - { - "description": "allow-desktop-write-recursive -> This allows full recusrive write access to the complete `$DESKTOP` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-desktop-write-recursive" - ] - }, - { - "description": "allow-desktop-read -> This allows non-recursive read access to the `$DESKTOP` folder.", - "type": "string", - "enum": [ - "allow-desktop-read" - ] - }, - { - "description": "allow-desktop-write -> This allows non-recursive write access to the `$DESKTOP` folder.", - "type": "string", - "enum": [ - "allow-desktop-write" - ] - }, - { - "description": "allow-desktop-meta-recursive -> This allows read access to metadata of the `$DESKTOP` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-desktop-meta-recursive" - ] - }, - { - "description": "allow-desktop-meta -> This allows read access to metadata of the `$DESKTOP` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-desktop-meta" - ] - }, - { - "description": "scope-desktop-recursive -> This scope recursive access to the complete `$DESKTOP` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-desktop-recursive" - ] - }, - { - "description": "scope-desktop -> This scope permits access to all files and list content of top level directories in the `$DESKTOP`folder.", - "type": "string", - "enum": [ - "scope-desktop" - ] - }, - { - "description": "scope-desktop-index -> This scope permits to list all files and folders in the `$DESKTOP`folder.", - "type": "string", - "enum": [ - "scope-desktop-index" - ] - }, - { - "description": "allow-document-read-recursive -> This allows full recursive read access to the complete `$DOCUMENT` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-document-read-recursive" - ] - }, - { - "description": "allow-document-write-recursive -> This allows full recusrive write access to the complete `$DOCUMENT` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-document-write-recursive" - ] - }, - { - "description": "allow-document-read -> This allows non-recursive read access to the `$DOCUMENT` folder.", - "type": "string", - "enum": [ - "allow-document-read" - ] - }, - { - "description": "allow-document-write -> This allows non-recursive write access to the `$DOCUMENT` folder.", - "type": "string", - "enum": [ - "allow-document-write" - ] - }, - { - "description": "allow-document-meta-recursive -> This allows read access to metadata of the `$DOCUMENT` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-document-meta-recursive" - ] - }, - { - "description": "allow-document-meta -> This allows read access to metadata of the `$DOCUMENT` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-document-meta" - ] - }, - { - "description": "scope-document-recursive -> This scope recursive access to the complete `$DOCUMENT` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-document-recursive" - ] - }, - { - "description": "scope-document -> This scope permits access to all files and list content of top level directories in the `$DOCUMENT`folder.", - "type": "string", - "enum": [ - "scope-document" - ] - }, - { - "description": "scope-document-index -> This scope permits to list all files and folders in the `$DOCUMENT`folder.", - "type": "string", - "enum": [ - "scope-document-index" - ] - }, - { - "description": "allow-download-read-recursive -> This allows full recursive read access to the complete `$DOWNLOAD` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-download-read-recursive" - ] - }, - { - "description": "allow-download-write-recursive -> This allows full recusrive write access to the complete `$DOWNLOAD` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-download-write-recursive" - ] - }, - { - "description": "allow-download-read -> This allows non-recursive read access to the `$DOWNLOAD` folder.", - "type": "string", - "enum": [ - "allow-download-read" - ] - }, - { - "description": "allow-download-write -> This allows non-recursive write access to the `$DOWNLOAD` folder.", - "type": "string", - "enum": [ - "allow-download-write" - ] - }, - { - "description": "allow-download-meta-recursive -> This allows read access to metadata of the `$DOWNLOAD` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-download-meta-recursive" - ] - }, - { - "description": "allow-download-meta -> This allows read access to metadata of the `$DOWNLOAD` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-download-meta" - ] - }, - { - "description": "scope-download-recursive -> This scope recursive access to the complete `$DOWNLOAD` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-download-recursive" - ] - }, - { - "description": "scope-download -> This scope permits access to all files and list content of top level directories in the `$DOWNLOAD`folder.", - "type": "string", - "enum": [ - "scope-download" - ] - }, - { - "description": "scope-download-index -> This scope permits to list all files and folders in the `$DOWNLOAD`folder.", - "type": "string", - "enum": [ - "scope-download-index" - ] - }, - { - "description": "allow-exe-read-recursive -> This allows full recursive read access to the complete `$EXE` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-exe-read-recursive" - ] - }, - { - "description": "allow-exe-write-recursive -> This allows full recusrive write access to the complete `$EXE` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-exe-write-recursive" - ] - }, - { - "description": "allow-exe-read -> This allows non-recursive read access to the `$EXE` folder.", - "type": "string", - "enum": [ - "allow-exe-read" - ] - }, - { - "description": "allow-exe-write -> This allows non-recursive write access to the `$EXE` folder.", - "type": "string", - "enum": [ - "allow-exe-write" - ] - }, - { - "description": "allow-exe-meta-recursive -> This allows read access to metadata of the `$EXE` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-exe-meta-recursive" - ] - }, - { - "description": "allow-exe-meta -> This allows read access to metadata of the `$EXE` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-exe-meta" - ] - }, - { - "description": "scope-exe-recursive -> This scope recursive access to the complete `$EXE` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-exe-recursive" - ] - }, - { - "description": "scope-exe -> This scope permits access to all files and list content of top level directories in the `$EXE`folder.", - "type": "string", - "enum": [ - "scope-exe" - ] - }, - { - "description": "scope-exe-index -> This scope permits to list all files and folders in the `$EXE`folder.", - "type": "string", - "enum": [ - "scope-exe-index" - ] - }, - { - "description": "allow-font-read-recursive -> This allows full recursive read access to the complete `$FONT` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-font-read-recursive" - ] - }, - { - "description": "allow-font-write-recursive -> This allows full recusrive write access to the complete `$FONT` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-font-write-recursive" - ] - }, - { - "description": "allow-font-read -> This allows non-recursive read access to the `$FONT` folder.", - "type": "string", - "enum": [ - "allow-font-read" - ] - }, - { - "description": "allow-font-write -> This allows non-recursive write access to the `$FONT` folder.", - "type": "string", - "enum": [ - "allow-font-write" - ] - }, - { - "description": "allow-font-meta-recursive -> This allows read access to metadata of the `$FONT` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-font-meta-recursive" - ] - }, - { - "description": "allow-font-meta -> This allows read access to metadata of the `$FONT` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-font-meta" - ] - }, - { - "description": "scope-font-recursive -> This scope recursive access to the complete `$FONT` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-font-recursive" - ] - }, - { - "description": "scope-font -> This scope permits access to all files and list content of top level directories in the `$FONT`folder.", - "type": "string", - "enum": [ - "scope-font" - ] - }, - { - "description": "scope-font-index -> This scope permits to list all files and folders in the `$FONT`folder.", - "type": "string", - "enum": [ - "scope-font-index" - ] - }, - { - "description": "allow-home-read-recursive -> This allows full recursive read access to the complete `$HOME` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-home-read-recursive" - ] - }, - { - "description": "allow-home-write-recursive -> This allows full recusrive write access to the complete `$HOME` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-home-write-recursive" - ] - }, - { - "description": "allow-home-read -> This allows non-recursive read access to the `$HOME` folder.", - "type": "string", - "enum": [ - "allow-home-read" - ] - }, - { - "description": "allow-home-write -> This allows non-recursive write access to the `$HOME` folder.", - "type": "string", - "enum": [ - "allow-home-write" - ] - }, - { - "description": "allow-home-meta-recursive -> This allows read access to metadata of the `$HOME` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-home-meta-recursive" - ] - }, - { - "description": "allow-home-meta -> This allows read access to metadata of the `$HOME` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-home-meta" - ] - }, - { - "description": "scope-home-recursive -> This scope recursive access to the complete `$HOME` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-home-recursive" - ] - }, - { - "description": "scope-home -> This scope permits access to all files and list content of top level directories in the `$HOME`folder.", - "type": "string", - "enum": [ - "scope-home" - ] - }, - { - "description": "scope-home-index -> This scope permits to list all files and folders in the `$HOME`folder.", - "type": "string", - "enum": [ - "scope-home-index" - ] - }, - { - "description": "allow-localdata-read-recursive -> This allows full recursive read access to the complete `$LOCALDATA` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-localdata-read-recursive" - ] - }, - { - "description": "allow-localdata-write-recursive -> This allows full recusrive write access to the complete `$LOCALDATA` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-localdata-write-recursive" - ] - }, - { - "description": "allow-localdata-read -> This allows non-recursive read access to the `$LOCALDATA` folder.", - "type": "string", - "enum": [ - "allow-localdata-read" - ] - }, - { - "description": "allow-localdata-write -> This allows non-recursive write access to the `$LOCALDATA` folder.", - "type": "string", - "enum": [ - "allow-localdata-write" - ] - }, - { - "description": "allow-localdata-meta-recursive -> This allows read access to metadata of the `$LOCALDATA` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-localdata-meta-recursive" - ] - }, - { - "description": "allow-localdata-meta -> This allows read access to metadata of the `$LOCALDATA` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-localdata-meta" - ] - }, - { - "description": "scope-localdata-recursive -> This scope recursive access to the complete `$LOCALDATA` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-localdata-recursive" - ] - }, - { - "description": "scope-localdata -> This scope permits access to all files and list content of top level directories in the `$LOCALDATA`folder.", - "type": "string", - "enum": [ - "scope-localdata" - ] - }, - { - "description": "scope-localdata-index -> This scope permits to list all files and folders in the `$LOCALDATA`folder.", - "type": "string", - "enum": [ - "scope-localdata-index" - ] - }, - { - "description": "allow-log-read-recursive -> This allows full recursive read access to the complete `$LOG` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-log-read-recursive" - ] - }, - { - "description": "allow-log-write-recursive -> This allows full recusrive write access to the complete `$LOG` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-log-write-recursive" - ] - }, - { - "description": "allow-log-read -> This allows non-recursive read access to the `$LOG` folder.", - "type": "string", - "enum": [ - "allow-log-read" - ] - }, - { - "description": "allow-log-write -> This allows non-recursive write access to the `$LOG` folder.", - "type": "string", - "enum": [ - "allow-log-write" - ] - }, - { - "description": "allow-log-meta-recursive -> This allows read access to metadata of the `$LOG` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-log-meta-recursive" - ] - }, - { - "description": "allow-log-meta -> This allows read access to metadata of the `$LOG` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-log-meta" - ] - }, - { - "description": "scope-log-recursive -> This scope recursive access to the complete `$LOG` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-log-recursive" - ] - }, - { - "description": "scope-log -> This scope permits access to all files and list content of top level directories in the `$LOG`folder.", - "type": "string", - "enum": [ - "scope-log" - ] - }, - { - "description": "scope-log-index -> This scope permits to list all files and folders in the `$LOG`folder.", - "type": "string", - "enum": [ - "scope-log-index" - ] - }, - { - "description": "allow-picture-read-recursive -> This allows full recursive read access to the complete `$PICTURE` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-picture-read-recursive" - ] - }, - { - "description": "allow-picture-write-recursive -> This allows full recusrive write access to the complete `$PICTURE` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-picture-write-recursive" - ] - }, - { - "description": "allow-picture-read -> This allows non-recursive read access to the `$PICTURE` folder.", - "type": "string", - "enum": [ - "allow-picture-read" - ] - }, - { - "description": "allow-picture-write -> This allows non-recursive write access to the `$PICTURE` folder.", - "type": "string", - "enum": [ - "allow-picture-write" - ] - }, - { - "description": "allow-picture-meta-recursive -> This allows read access to metadata of the `$PICTURE` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-picture-meta-recursive" - ] - }, - { - "description": "allow-picture-meta -> This allows read access to metadata of the `$PICTURE` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-picture-meta" - ] - }, - { - "description": "scope-picture-recursive -> This scope recursive access to the complete `$PICTURE` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-picture-recursive" - ] - }, - { - "description": "scope-picture -> This scope permits access to all files and list content of top level directories in the `$PICTURE`folder.", - "type": "string", - "enum": [ - "scope-picture" - ] - }, - { - "description": "scope-picture-index -> This scope permits to list all files and folders in the `$PICTURE`folder.", - "type": "string", - "enum": [ - "scope-picture-index" - ] - }, - { - "description": "allow-public-read-recursive -> This allows full recursive read access to the complete `$PUBLIC` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-public-read-recursive" - ] - }, - { - "description": "allow-public-write-recursive -> This allows full recusrive write access to the complete `$PUBLIC` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-public-write-recursive" - ] - }, - { - "description": "allow-public-read -> This allows non-recursive read access to the `$PUBLIC` folder.", - "type": "string", - "enum": [ - "allow-public-read" - ] - }, - { - "description": "allow-public-write -> This allows non-recursive write access to the `$PUBLIC` folder.", - "type": "string", - "enum": [ - "allow-public-write" - ] - }, - { - "description": "allow-public-meta-recursive -> This allows read access to metadata of the `$PUBLIC` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-public-meta-recursive" - ] - }, - { - "description": "allow-public-meta -> This allows read access to metadata of the `$PUBLIC` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-public-meta" - ] - }, - { - "description": "scope-public-recursive -> This scope recursive access to the complete `$PUBLIC` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-public-recursive" - ] - }, - { - "description": "scope-public -> This scope permits access to all files and list content of top level directories in the `$PUBLIC`folder.", - "type": "string", - "enum": [ - "scope-public" - ] - }, - { - "description": "scope-public-index -> This scope permits to list all files and folders in the `$PUBLIC`folder.", - "type": "string", - "enum": [ - "scope-public-index" - ] - }, - { - "description": "allow-resource-read-recursive -> This allows full recursive read access to the complete `$RESOURCE` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-resource-read-recursive" - ] - }, - { - "description": "allow-resource-write-recursive -> This allows full recusrive write access to the complete `$RESOURCE` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-resource-write-recursive" - ] - }, - { - "description": "allow-resource-read -> This allows non-recursive read access to the `$RESOURCE` folder.", - "type": "string", - "enum": [ - "allow-resource-read" - ] - }, - { - "description": "allow-resource-write -> This allows non-recursive write access to the `$RESOURCE` folder.", - "type": "string", - "enum": [ - "allow-resource-write" - ] - }, - { - "description": "allow-resource-meta-recursive -> This allows read access to metadata of the `$RESOURCE` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-resource-meta-recursive" - ] - }, - { - "description": "allow-resource-meta -> This allows read access to metadata of the `$RESOURCE` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-resource-meta" - ] - }, - { - "description": "scope-resource-recursive -> This scope recursive access to the complete `$RESOURCE` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-resource-recursive" - ] - }, - { - "description": "scope-resource -> This scope permits access to all files and list content of top level directories in the `$RESOURCE`folder.", - "type": "string", - "enum": [ - "scope-resource" - ] - }, - { - "description": "scope-resource-index -> This scope permits to list all files and folders in the `$RESOURCE`folder.", - "type": "string", - "enum": [ - "scope-resource-index" - ] - }, - { - "description": "allow-runtime-read-recursive -> This allows full recursive read access to the complete `$RUNTIME` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-runtime-read-recursive" - ] - }, - { - "description": "allow-runtime-write-recursive -> This allows full recusrive write access to the complete `$RUNTIME` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-runtime-write-recursive" - ] - }, - { - "description": "allow-runtime-read -> This allows non-recursive read access to the `$RUNTIME` folder.", - "type": "string", - "enum": [ - "allow-runtime-read" - ] - }, - { - "description": "allow-runtime-write -> This allows non-recursive write access to the `$RUNTIME` folder.", - "type": "string", - "enum": [ - "allow-runtime-write" - ] - }, - { - "description": "allow-runtime-meta-recursive -> This allows read access to metadata of the `$RUNTIME` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-runtime-meta-recursive" - ] - }, - { - "description": "allow-runtime-meta -> This allows read access to metadata of the `$RUNTIME` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-runtime-meta" - ] - }, - { - "description": "scope-runtime-recursive -> This scope recursive access to the complete `$RUNTIME` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-runtime-recursive" - ] - }, - { - "description": "scope-runtime -> This scope permits access to all files and list content of top level directories in the `$RUNTIME`folder.", - "type": "string", - "enum": [ - "scope-runtime" - ] - }, - { - "description": "scope-runtime-index -> This scope permits to list all files and folders in the `$RUNTIME`folder.", - "type": "string", - "enum": [ - "scope-runtime-index" - ] - }, - { - "description": "allow-temp-read-recursive -> This allows full recursive read access to the complete `$TEMP` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-temp-read-recursive" - ] - }, - { - "description": "allow-temp-write-recursive -> This allows full recusrive write access to the complete `$TEMP` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-temp-write-recursive" - ] - }, - { - "description": "allow-temp-read -> This allows non-recursive read access to the `$TEMP` folder.", - "type": "string", - "enum": [ - "allow-temp-read" - ] - }, - { - "description": "allow-temp-write -> This allows non-recursive write access to the `$TEMP` folder.", - "type": "string", - "enum": [ - "allow-temp-write" - ] - }, - { - "description": "allow-temp-meta-recursive -> This allows read access to metadata of the `$TEMP` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-temp-meta-recursive" - ] - }, - { - "description": "allow-temp-meta -> This allows read access to metadata of the `$TEMP` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-temp-meta" - ] - }, - { - "description": "scope-temp-recursive -> This scope recursive access to the complete `$TEMP` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-temp-recursive" - ] - }, - { - "description": "scope-temp -> This scope permits access to all files and list content of top level directories in the `$TEMP`folder.", - "type": "string", - "enum": [ - "scope-temp" - ] - }, - { - "description": "scope-temp-index -> This scope permits to list all files and folders in the `$TEMP`folder.", - "type": "string", - "enum": [ - "scope-temp-index" - ] - }, - { - "description": "allow-template-read-recursive -> This allows full recursive read access to the complete `$TEMPLATE` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-template-read-recursive" - ] - }, - { - "description": "allow-template-write-recursive -> This allows full recusrive write access to the complete `$TEMPLATE` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-template-write-recursive" - ] - }, - { - "description": "allow-template-read -> This allows non-recursive read access to the `$TEMPLATE` folder.", - "type": "string", - "enum": [ - "allow-template-read" - ] - }, - { - "description": "allow-template-write -> This allows non-recursive write access to the `$TEMPLATE` folder.", - "type": "string", - "enum": [ - "allow-template-write" - ] - }, - { - "description": "allow-template-meta-recursive -> This allows read access to metadata of the `$TEMPLATE` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-template-meta-recursive" - ] - }, - { - "description": "allow-template-meta -> This allows read access to metadata of the `$TEMPLATE` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-template-meta" - ] - }, - { - "description": "scope-template-recursive -> This scope recursive access to the complete `$TEMPLATE` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-template-recursive" - ] - }, - { - "description": "scope-template -> This scope permits access to all files and list content of top level directories in the `$TEMPLATE`folder.", - "type": "string", - "enum": [ - "scope-template" - ] - }, - { - "description": "scope-template-index -> This scope permits to list all files and folders in the `$TEMPLATE`folder.", - "type": "string", - "enum": [ - "scope-template-index" - ] - }, - { - "description": "allow-video-read-recursive -> This allows full recursive read access to the complete `$VIDEO` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-video-read-recursive" - ] - }, - { - "description": "allow-video-write-recursive -> This allows full recusrive write access to the complete `$VIDEO` folder, files and subdirectories.", - "type": "string", - "enum": [ - "allow-video-write-recursive" - ] - }, - { - "description": "allow-video-read -> This allows non-recursive read access to the `$VIDEO` folder.", - "type": "string", - "enum": [ - "allow-video-read" - ] - }, - { - "description": "allow-video-write -> This allows non-recursive write access to the `$VIDEO` folder.", - "type": "string", - "enum": [ - "allow-video-write" - ] - }, - { - "description": "allow-video-meta-recursive -> This allows read access to metadata of the `$VIDEO` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-video-meta-recursive" - ] - }, - { - "description": "allow-video-meta -> This allows read access to metadata of the `$VIDEO` folder, including file listing and statistics.", - "type": "string", - "enum": [ - "allow-video-meta" - ] - }, - { - "description": "scope-video-recursive -> This scope recursive access to the complete `$VIDEO` folder, including sub directories and files.", - "type": "string", - "enum": [ - "scope-video-recursive" - ] - }, - { - "description": "scope-video -> This scope permits access to all files and list content of top level directories in the `$VIDEO`folder.", - "type": "string", - "enum": [ - "scope-video" - ] - }, - { - "description": "scope-video-index -> This scope permits to list all files and folders in the `$VIDEO`folder.", - "type": "string", - "enum": [ - "scope-video-index" - ] - }, - { - "description": "allow-copy-file -> Enables the copy_file command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-copy-file" - ] - }, - { - "description": "deny-copy-file -> Denies the copy_file command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-copy-file" - ] - }, - { - "description": "allow-create -> Enables the create command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-create" - ] - }, - { - "description": "deny-create -> Denies the create command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-create" - ] - }, - { - "description": "allow-exists -> Enables the exists command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-exists" - ] - }, - { - "description": "deny-exists -> Denies the exists command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-exists" - ] - }, - { - "description": "allow-fstat -> Enables the fstat command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-fstat" - ] - }, - { - "description": "deny-fstat -> Denies the fstat command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-fstat" - ] - }, - { - "description": "allow-ftruncate -> Enables the ftruncate command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-ftruncate" - ] - }, - { - "description": "deny-ftruncate -> Denies the ftruncate command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-ftruncate" - ] - }, - { - "description": "allow-lstat -> Enables the lstat command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-lstat" - ] - }, - { - "description": "deny-lstat -> Denies the lstat command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-lstat" - ] - }, - { - "description": "allow-mkdir -> Enables the mkdir command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-mkdir" - ] - }, - { - "description": "deny-mkdir -> Denies the mkdir command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-mkdir" - ] - }, - { - "description": "allow-open -> Enables the open command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-open" - ] - }, - { - "description": "deny-open -> Denies the open command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-open" - ] - }, - { - "description": "allow-read -> Enables the read command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-read" - ] - }, - { - "description": "deny-read -> Denies the read command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-read" - ] - }, - { - "description": "allow-read-dir -> Enables the read_dir command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-read-dir" - ] - }, - { - "description": "deny-read-dir -> Denies the read_dir command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-read-dir" - ] - }, - { - "description": "allow-read-file -> Enables the read_file command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-read-file" - ] - }, - { - "description": "deny-read-file -> Denies the read_file command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-read-file" - ] - }, - { - "description": "allow-read-text-file -> Enables the read_text_file command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-read-text-file" - ] - }, - { - "description": "deny-read-text-file -> Denies the read_text_file command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-read-text-file" - ] - }, - { - "description": "allow-read-text-file-lines -> Enables the read_text_file_lines command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-read-text-file-lines" - ] - }, - { - "description": "deny-read-text-file-lines -> Denies the read_text_file_lines command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-read-text-file-lines" - ] - }, - { - "description": "allow-read-text-file-lines-next -> Enables the read_text_file_lines_next command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-read-text-file-lines-next" - ] - }, - { - "description": "deny-read-text-file-lines-next -> Denies the read_text_file_lines_next command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-read-text-file-lines-next" - ] - }, - { - "description": "allow-remove -> Enables the remove command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-remove" - ] - }, - { - "description": "deny-remove -> Denies the remove command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-remove" - ] - }, - { - "description": "allow-rename -> Enables the rename command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-rename" - ] - }, - { - "description": "deny-rename -> Denies the rename command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-rename" - ] - }, - { - "description": "allow-seek -> Enables the seek command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-seek" - ] - }, - { - "description": "deny-seek -> Denies the seek command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-seek" - ] - }, - { - "description": "allow-stat -> Enables the stat command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-stat" - ] - }, - { - "description": "deny-stat -> Denies the stat command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-stat" - ] - }, - { - "description": "allow-truncate -> Enables the truncate command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-truncate" - ] - }, - { - "description": "deny-truncate -> Denies the truncate command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-truncate" - ] - }, - { - "description": "allow-unwatch -> Enables the unwatch command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-unwatch" - ] - }, - { - "description": "deny-unwatch -> Denies the unwatch command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-unwatch" - ] - }, - { - "description": "allow-watch -> Enables the watch command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-watch" - ] - }, - { - "description": "deny-watch -> Denies the watch command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-watch" - ] - }, - { - "description": "allow-write -> Enables the write command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-write" - ] - }, - { - "description": "deny-write -> Denies the write command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-write" - ] - }, - { - "description": "allow-write-file -> Enables the write_file command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-write-file" - ] - }, - { - "description": "deny-write-file -> Denies the write_file command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-write-file" - ] - }, - { - "description": "allow-write-text-file -> Enables the write_text_file command without any pre-configured scope.", - "type": "string", - "enum": [ - "allow-write-text-file" - ] - }, - { - "description": "deny-write-text-file -> Denies the write_text_file command without any pre-configured scope.", - "type": "string", - "enum": [ - "deny-write-text-file" - ] - }, - { - "description": "default -> # Tauri `fs` default permissions\n\nThis configuration file defines the default permissions granted\nto the filesystem.\n\n### Granted Permissions\n\nThis default permission set enables all read-related commands and\nallows access to the `$APP` folder and sub directories created in it.\nThe location of the `$APP` folder depends on the operating system,\nwhere the application is run.\n\nIn general the `$APP` folder needs to be manually created\nby the application at runtime, before accessing files or folders\nin it is possible.\n\n### Denied Permissions\n\nThis default permission set prevents access to critical components\nof the Tauri application by default.\nOn Windows the webview data folder access is denied.\n\n", - "type": "string", - "enum": [ - "default" - ] - }, - { - "description": "deny-default -> This denies access to dangerous Tauri relevant files and folders by default.", - "type": "string", - "enum": [ - "deny-default" - ] - }, - { - "description": "deny-webview-data-linux -> This denies read access to the\n`$APPLOCALDATA` folder on linux as the webview data and configuration values are stored here.\nAllowing access can lead to sensitive information disclosure and should be well considered.", - "type": "string", - "enum": [ - "deny-webview-data-linux" - ] - }, - { - "description": "deny-webview-data-windows -> This denies read access to the\n`$APPLOCALDATA/EBWebView` folder on windows as the webview data and configuration values are stored here.\nAllowing access can lead to sensitive information disclosure and should be well considered.", - "type": "string", - "enum": [ - "deny-webview-data-windows" - ] - }, - { - "description": "read-all -> This enables all read related commands without any pre-configured accessible paths.", - "type": "string", - "enum": [ - "read-all" - ] - }, - { - "description": "read-dirs -> This enables directory read and file metadata related commands without any pre-configured accessible paths.", - "type": "string", - "enum": [ - "read-dirs" - ] - }, - { - "description": "read-files -> This enables file read related commands without any pre-configured accessible paths.", - "type": "string", - "enum": [ - "read-files" - ] - }, - { - "description": "read-meta -> This enables all index or metadata related commands without any pre-configured accessible paths.", - "type": "string", - "enum": [ - "read-meta" - ] - }, - { - "description": "scope -> An empty permission you can use to modify the global scope.", - "type": "string", - "enum": [ - "scope" - ] - }, - { - "description": "write-all -> This enables all write related commands without any pre-configured accessible paths.", - "type": "string", - "enum": [ - "write-all" - ] - }, - { - "description": "write-files -> This enables all file write related commands without any pre-configured accessible paths.", - "type": "string", - "enum": [ - "write-files" - ] - } - ] - } - } -} \ No newline at end of file + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": ["permissions"], + "properties": { + "version": { + "description": "The version of the permission.", + "type": ["integer", "null"], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": ["string", "null"] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": ["description", "identifier", "permissions"], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": ["identifier"], + "properties": { + "version": { + "description": "The version of the permission.", + "type": ["integer", "null"], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": ["string", "null"] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "default": ["linux", "macOS", "windows", "android", "iOS"], + "type": "array", + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "A restriction of the command/endpoint functionality.\n\nIt can be of any serde serializable type and is used for allowing or preventing certain actions inside a Tauri command.\n\nThe scope is passed to the command and handled/enforced by the command itself.", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": ["array", "null"], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope.", + "type": ["array", "null"], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": ["macOS"] + }, + { + "description": "Windows.", + "type": "string", + "enum": ["windows"] + }, + { + "description": "Linux.", + "type": "string", + "enum": ["linux"] + }, + { + "description": "Android.", + "type": "string", + "enum": ["android"] + }, + { + "description": "iOS.", + "type": "string", + "enum": ["iOS"] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "allow-app-read-recursive -> This allows full recursive read access to the complete `$APP` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-app-read-recursive"] + }, + { + "description": "allow-app-write-recursive -> This allows full recusrive write access to the complete `$APP` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-app-write-recursive"] + }, + { + "description": "allow-app-read -> This allows non-recursive read access to the `$APP` folder.", + "type": "string", + "enum": ["allow-app-read"] + }, + { + "description": "allow-app-write -> This allows non-recursive write access to the `$APP` folder.", + "type": "string", + "enum": ["allow-app-write"] + }, + { + "description": "allow-app-meta-recursive -> This allows read access to metadata of the `$APP` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-app-meta-recursive"] + }, + { + "description": "allow-app-meta -> This allows read access to metadata of the `$APP` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-app-meta"] + }, + { + "description": "scope-app-recursive -> This scope recursive access to the complete `$APP` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-app-recursive"] + }, + { + "description": "scope-app -> This scope permits access to all files and list content of top level directories in the `$APP`folder.", + "type": "string", + "enum": ["scope-app"] + }, + { + "description": "scope-app-index -> This scope permits to list all files and folders in the `$APP`folder.", + "type": "string", + "enum": ["scope-app-index"] + }, + { + "description": "allow-appcache-read-recursive -> This allows full recursive read access to the complete `$APPCACHE` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-appcache-read-recursive"] + }, + { + "description": "allow-appcache-write-recursive -> This allows full recusrive write access to the complete `$APPCACHE` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-appcache-write-recursive"] + }, + { + "description": "allow-appcache-read -> This allows non-recursive read access to the `$APPCACHE` folder.", + "type": "string", + "enum": ["allow-appcache-read"] + }, + { + "description": "allow-appcache-write -> This allows non-recursive write access to the `$APPCACHE` folder.", + "type": "string", + "enum": ["allow-appcache-write"] + }, + { + "description": "allow-appcache-meta-recursive -> This allows read access to metadata of the `$APPCACHE` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-appcache-meta-recursive"] + }, + { + "description": "allow-appcache-meta -> This allows read access to metadata of the `$APPCACHE` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-appcache-meta"] + }, + { + "description": "scope-appcache-recursive -> This scope recursive access to the complete `$APPCACHE` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-appcache-recursive"] + }, + { + "description": "scope-appcache -> This scope permits access to all files and list content of top level directories in the `$APPCACHE`folder.", + "type": "string", + "enum": ["scope-appcache"] + }, + { + "description": "scope-appcache-index -> This scope permits to list all files and folders in the `$APPCACHE`folder.", + "type": "string", + "enum": ["scope-appcache-index"] + }, + { + "description": "allow-appconfig-read-recursive -> This allows full recursive read access to the complete `$APPCONFIG` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-appconfig-read-recursive"] + }, + { + "description": "allow-appconfig-write-recursive -> This allows full recusrive write access to the complete `$APPCONFIG` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-appconfig-write-recursive"] + }, + { + "description": "allow-appconfig-read -> This allows non-recursive read access to the `$APPCONFIG` folder.", + "type": "string", + "enum": ["allow-appconfig-read"] + }, + { + "description": "allow-appconfig-write -> This allows non-recursive write access to the `$APPCONFIG` folder.", + "type": "string", + "enum": ["allow-appconfig-write"] + }, + { + "description": "allow-appconfig-meta-recursive -> This allows read access to metadata of the `$APPCONFIG` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-appconfig-meta-recursive"] + }, + { + "description": "allow-appconfig-meta -> This allows read access to metadata of the `$APPCONFIG` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-appconfig-meta"] + }, + { + "description": "scope-appconfig-recursive -> This scope recursive access to the complete `$APPCONFIG` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-appconfig-recursive"] + }, + { + "description": "scope-appconfig -> This scope permits access to all files and list content of top level directories in the `$APPCONFIG`folder.", + "type": "string", + "enum": ["scope-appconfig"] + }, + { + "description": "scope-appconfig-index -> This scope permits to list all files and folders in the `$APPCONFIG`folder.", + "type": "string", + "enum": ["scope-appconfig-index"] + }, + { + "description": "allow-appdata-read-recursive -> This allows full recursive read access to the complete `$APPDATA` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-appdata-read-recursive"] + }, + { + "description": "allow-appdata-write-recursive -> This allows full recusrive write access to the complete `$APPDATA` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-appdata-write-recursive"] + }, + { + "description": "allow-appdata-read -> This allows non-recursive read access to the `$APPDATA` folder.", + "type": "string", + "enum": ["allow-appdata-read"] + }, + { + "description": "allow-appdata-write -> This allows non-recursive write access to the `$APPDATA` folder.", + "type": "string", + "enum": ["allow-appdata-write"] + }, + { + "description": "allow-appdata-meta-recursive -> This allows read access to metadata of the `$APPDATA` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-appdata-meta-recursive"] + }, + { + "description": "allow-appdata-meta -> This allows read access to metadata of the `$APPDATA` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-appdata-meta"] + }, + { + "description": "scope-appdata-recursive -> This scope recursive access to the complete `$APPDATA` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-appdata-recursive"] + }, + { + "description": "scope-appdata -> This scope permits access to all files and list content of top level directories in the `$APPDATA`folder.", + "type": "string", + "enum": ["scope-appdata"] + }, + { + "description": "scope-appdata-index -> This scope permits to list all files and folders in the `$APPDATA`folder.", + "type": "string", + "enum": ["scope-appdata-index"] + }, + { + "description": "allow-applocaldata-read-recursive -> This allows full recursive read access to the complete `$APPLOCALDATA` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-applocaldata-read-recursive"] + }, + { + "description": "allow-applocaldata-write-recursive -> This allows full recusrive write access to the complete `$APPLOCALDATA` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-applocaldata-write-recursive"] + }, + { + "description": "allow-applocaldata-read -> This allows non-recursive read access to the `$APPLOCALDATA` folder.", + "type": "string", + "enum": ["allow-applocaldata-read"] + }, + { + "description": "allow-applocaldata-write -> This allows non-recursive write access to the `$APPLOCALDATA` folder.", + "type": "string", + "enum": ["allow-applocaldata-write"] + }, + { + "description": "allow-applocaldata-meta-recursive -> This allows read access to metadata of the `$APPLOCALDATA` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-applocaldata-meta-recursive"] + }, + { + "description": "allow-applocaldata-meta -> This allows read access to metadata of the `$APPLOCALDATA` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-applocaldata-meta"] + }, + { + "description": "scope-applocaldata-recursive -> This scope recursive access to the complete `$APPLOCALDATA` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-applocaldata-recursive"] + }, + { + "description": "scope-applocaldata -> This scope permits access to all files and list content of top level directories in the `$APPLOCALDATA`folder.", + "type": "string", + "enum": ["scope-applocaldata"] + }, + { + "description": "scope-applocaldata-index -> This scope permits to list all files and folders in the `$APPLOCALDATA`folder.", + "type": "string", + "enum": ["scope-applocaldata-index"] + }, + { + "description": "allow-applog-read-recursive -> This allows full recursive read access to the complete `$APPLOG` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-applog-read-recursive"] + }, + { + "description": "allow-applog-write-recursive -> This allows full recusrive write access to the complete `$APPLOG` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-applog-write-recursive"] + }, + { + "description": "allow-applog-read -> This allows non-recursive read access to the `$APPLOG` folder.", + "type": "string", + "enum": ["allow-applog-read"] + }, + { + "description": "allow-applog-write -> This allows non-recursive write access to the `$APPLOG` folder.", + "type": "string", + "enum": ["allow-applog-write"] + }, + { + "description": "allow-applog-meta-recursive -> This allows read access to metadata of the `$APPLOG` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-applog-meta-recursive"] + }, + { + "description": "allow-applog-meta -> This allows read access to metadata of the `$APPLOG` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-applog-meta"] + }, + { + "description": "scope-applog-recursive -> This scope recursive access to the complete `$APPLOG` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-applog-recursive"] + }, + { + "description": "scope-applog -> This scope permits access to all files and list content of top level directories in the `$APPLOG`folder.", + "type": "string", + "enum": ["scope-applog"] + }, + { + "description": "scope-applog-index -> This scope permits to list all files and folders in the `$APPLOG`folder.", + "type": "string", + "enum": ["scope-applog-index"] + }, + { + "description": "allow-audio-read-recursive -> This allows full recursive read access to the complete `$AUDIO` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-audio-read-recursive"] + }, + { + "description": "allow-audio-write-recursive -> This allows full recusrive write access to the complete `$AUDIO` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-audio-write-recursive"] + }, + { + "description": "allow-audio-read -> This allows non-recursive read access to the `$AUDIO` folder.", + "type": "string", + "enum": ["allow-audio-read"] + }, + { + "description": "allow-audio-write -> This allows non-recursive write access to the `$AUDIO` folder.", + "type": "string", + "enum": ["allow-audio-write"] + }, + { + "description": "allow-audio-meta-recursive -> This allows read access to metadata of the `$AUDIO` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-audio-meta-recursive"] + }, + { + "description": "allow-audio-meta -> This allows read access to metadata of the `$AUDIO` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-audio-meta"] + }, + { + "description": "scope-audio-recursive -> This scope recursive access to the complete `$AUDIO` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-audio-recursive"] + }, + { + "description": "scope-audio -> This scope permits access to all files and list content of top level directories in the `$AUDIO`folder.", + "type": "string", + "enum": ["scope-audio"] + }, + { + "description": "scope-audio-index -> This scope permits to list all files and folders in the `$AUDIO`folder.", + "type": "string", + "enum": ["scope-audio-index"] + }, + { + "description": "allow-cache-read-recursive -> This allows full recursive read access to the complete `$CACHE` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-cache-read-recursive"] + }, + { + "description": "allow-cache-write-recursive -> This allows full recusrive write access to the complete `$CACHE` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-cache-write-recursive"] + }, + { + "description": "allow-cache-read -> This allows non-recursive read access to the `$CACHE` folder.", + "type": "string", + "enum": ["allow-cache-read"] + }, + { + "description": "allow-cache-write -> This allows non-recursive write access to the `$CACHE` folder.", + "type": "string", + "enum": ["allow-cache-write"] + }, + { + "description": "allow-cache-meta-recursive -> This allows read access to metadata of the `$CACHE` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-cache-meta-recursive"] + }, + { + "description": "allow-cache-meta -> This allows read access to metadata of the `$CACHE` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-cache-meta"] + }, + { + "description": "scope-cache-recursive -> This scope recursive access to the complete `$CACHE` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-cache-recursive"] + }, + { + "description": "scope-cache -> This scope permits access to all files and list content of top level directories in the `$CACHE`folder.", + "type": "string", + "enum": ["scope-cache"] + }, + { + "description": "scope-cache-index -> This scope permits to list all files and folders in the `$CACHE`folder.", + "type": "string", + "enum": ["scope-cache-index"] + }, + { + "description": "allow-config-read-recursive -> This allows full recursive read access to the complete `$CONFIG` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-config-read-recursive"] + }, + { + "description": "allow-config-write-recursive -> This allows full recusrive write access to the complete `$CONFIG` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-config-write-recursive"] + }, + { + "description": "allow-config-read -> This allows non-recursive read access to the `$CONFIG` folder.", + "type": "string", + "enum": ["allow-config-read"] + }, + { + "description": "allow-config-write -> This allows non-recursive write access to the `$CONFIG` folder.", + "type": "string", + "enum": ["allow-config-write"] + }, + { + "description": "allow-config-meta-recursive -> This allows read access to metadata of the `$CONFIG` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-config-meta-recursive"] + }, + { + "description": "allow-config-meta -> This allows read access to metadata of the `$CONFIG` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-config-meta"] + }, + { + "description": "scope-config-recursive -> This scope recursive access to the complete `$CONFIG` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-config-recursive"] + }, + { + "description": "scope-config -> This scope permits access to all files and list content of top level directories in the `$CONFIG`folder.", + "type": "string", + "enum": ["scope-config"] + }, + { + "description": "scope-config-index -> This scope permits to list all files and folders in the `$CONFIG`folder.", + "type": "string", + "enum": ["scope-config-index"] + }, + { + "description": "allow-data-read-recursive -> This allows full recursive read access to the complete `$DATA` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-data-read-recursive"] + }, + { + "description": "allow-data-write-recursive -> This allows full recusrive write access to the complete `$DATA` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-data-write-recursive"] + }, + { + "description": "allow-data-read -> This allows non-recursive read access to the `$DATA` folder.", + "type": "string", + "enum": ["allow-data-read"] + }, + { + "description": "allow-data-write -> This allows non-recursive write access to the `$DATA` folder.", + "type": "string", + "enum": ["allow-data-write"] + }, + { + "description": "allow-data-meta-recursive -> This allows read access to metadata of the `$DATA` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-data-meta-recursive"] + }, + { + "description": "allow-data-meta -> This allows read access to metadata of the `$DATA` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-data-meta"] + }, + { + "description": "scope-data-recursive -> This scope recursive access to the complete `$DATA` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-data-recursive"] + }, + { + "description": "scope-data -> This scope permits access to all files and list content of top level directories in the `$DATA`folder.", + "type": "string", + "enum": ["scope-data"] + }, + { + "description": "scope-data-index -> This scope permits to list all files and folders in the `$DATA`folder.", + "type": "string", + "enum": ["scope-data-index"] + }, + { + "description": "allow-desktop-read-recursive -> This allows full recursive read access to the complete `$DESKTOP` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-desktop-read-recursive"] + }, + { + "description": "allow-desktop-write-recursive -> This allows full recusrive write access to the complete `$DESKTOP` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-desktop-write-recursive"] + }, + { + "description": "allow-desktop-read -> This allows non-recursive read access to the `$DESKTOP` folder.", + "type": "string", + "enum": ["allow-desktop-read"] + }, + { + "description": "allow-desktop-write -> This allows non-recursive write access to the `$DESKTOP` folder.", + "type": "string", + "enum": ["allow-desktop-write"] + }, + { + "description": "allow-desktop-meta-recursive -> This allows read access to metadata of the `$DESKTOP` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-desktop-meta-recursive"] + }, + { + "description": "allow-desktop-meta -> This allows read access to metadata of the `$DESKTOP` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-desktop-meta"] + }, + { + "description": "scope-desktop-recursive -> This scope recursive access to the complete `$DESKTOP` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-desktop-recursive"] + }, + { + "description": "scope-desktop -> This scope permits access to all files and list content of top level directories in the `$DESKTOP`folder.", + "type": "string", + "enum": ["scope-desktop"] + }, + { + "description": "scope-desktop-index -> This scope permits to list all files and folders in the `$DESKTOP`folder.", + "type": "string", + "enum": ["scope-desktop-index"] + }, + { + "description": "allow-document-read-recursive -> This allows full recursive read access to the complete `$DOCUMENT` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-document-read-recursive"] + }, + { + "description": "allow-document-write-recursive -> This allows full recusrive write access to the complete `$DOCUMENT` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-document-write-recursive"] + }, + { + "description": "allow-document-read -> This allows non-recursive read access to the `$DOCUMENT` folder.", + "type": "string", + "enum": ["allow-document-read"] + }, + { + "description": "allow-document-write -> This allows non-recursive write access to the `$DOCUMENT` folder.", + "type": "string", + "enum": ["allow-document-write"] + }, + { + "description": "allow-document-meta-recursive -> This allows read access to metadata of the `$DOCUMENT` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-document-meta-recursive"] + }, + { + "description": "allow-document-meta -> This allows read access to metadata of the `$DOCUMENT` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-document-meta"] + }, + { + "description": "scope-document-recursive -> This scope recursive access to the complete `$DOCUMENT` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-document-recursive"] + }, + { + "description": "scope-document -> This scope permits access to all files and list content of top level directories in the `$DOCUMENT`folder.", + "type": "string", + "enum": ["scope-document"] + }, + { + "description": "scope-document-index -> This scope permits to list all files and folders in the `$DOCUMENT`folder.", + "type": "string", + "enum": ["scope-document-index"] + }, + { + "description": "allow-download-read-recursive -> This allows full recursive read access to the complete `$DOWNLOAD` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-download-read-recursive"] + }, + { + "description": "allow-download-write-recursive -> This allows full recusrive write access to the complete `$DOWNLOAD` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-download-write-recursive"] + }, + { + "description": "allow-download-read -> This allows non-recursive read access to the `$DOWNLOAD` folder.", + "type": "string", + "enum": ["allow-download-read"] + }, + { + "description": "allow-download-write -> This allows non-recursive write access to the `$DOWNLOAD` folder.", + "type": "string", + "enum": ["allow-download-write"] + }, + { + "description": "allow-download-meta-recursive -> This allows read access to metadata of the `$DOWNLOAD` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-download-meta-recursive"] + }, + { + "description": "allow-download-meta -> This allows read access to metadata of the `$DOWNLOAD` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-download-meta"] + }, + { + "description": "scope-download-recursive -> This scope recursive access to the complete `$DOWNLOAD` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-download-recursive"] + }, + { + "description": "scope-download -> This scope permits access to all files and list content of top level directories in the `$DOWNLOAD`folder.", + "type": "string", + "enum": ["scope-download"] + }, + { + "description": "scope-download-index -> This scope permits to list all files and folders in the `$DOWNLOAD`folder.", + "type": "string", + "enum": ["scope-download-index"] + }, + { + "description": "allow-exe-read-recursive -> This allows full recursive read access to the complete `$EXE` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-exe-read-recursive"] + }, + { + "description": "allow-exe-write-recursive -> This allows full recusrive write access to the complete `$EXE` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-exe-write-recursive"] + }, + { + "description": "allow-exe-read -> This allows non-recursive read access to the `$EXE` folder.", + "type": "string", + "enum": ["allow-exe-read"] + }, + { + "description": "allow-exe-write -> This allows non-recursive write access to the `$EXE` folder.", + "type": "string", + "enum": ["allow-exe-write"] + }, + { + "description": "allow-exe-meta-recursive -> This allows read access to metadata of the `$EXE` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-exe-meta-recursive"] + }, + { + "description": "allow-exe-meta -> This allows read access to metadata of the `$EXE` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-exe-meta"] + }, + { + "description": "scope-exe-recursive -> This scope recursive access to the complete `$EXE` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-exe-recursive"] + }, + { + "description": "scope-exe -> This scope permits access to all files and list content of top level directories in the `$EXE`folder.", + "type": "string", + "enum": ["scope-exe"] + }, + { + "description": "scope-exe-index -> This scope permits to list all files and folders in the `$EXE`folder.", + "type": "string", + "enum": ["scope-exe-index"] + }, + { + "description": "allow-font-read-recursive -> This allows full recursive read access to the complete `$FONT` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-font-read-recursive"] + }, + { + "description": "allow-font-write-recursive -> This allows full recusrive write access to the complete `$FONT` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-font-write-recursive"] + }, + { + "description": "allow-font-read -> This allows non-recursive read access to the `$FONT` folder.", + "type": "string", + "enum": ["allow-font-read"] + }, + { + "description": "allow-font-write -> This allows non-recursive write access to the `$FONT` folder.", + "type": "string", + "enum": ["allow-font-write"] + }, + { + "description": "allow-font-meta-recursive -> This allows read access to metadata of the `$FONT` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-font-meta-recursive"] + }, + { + "description": "allow-font-meta -> This allows read access to metadata of the `$FONT` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-font-meta"] + }, + { + "description": "scope-font-recursive -> This scope recursive access to the complete `$FONT` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-font-recursive"] + }, + { + "description": "scope-font -> This scope permits access to all files and list content of top level directories in the `$FONT`folder.", + "type": "string", + "enum": ["scope-font"] + }, + { + "description": "scope-font-index -> This scope permits to list all files and folders in the `$FONT`folder.", + "type": "string", + "enum": ["scope-font-index"] + }, + { + "description": "allow-home-read-recursive -> This allows full recursive read access to the complete `$HOME` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-home-read-recursive"] + }, + { + "description": "allow-home-write-recursive -> This allows full recusrive write access to the complete `$HOME` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-home-write-recursive"] + }, + { + "description": "allow-home-read -> This allows non-recursive read access to the `$HOME` folder.", + "type": "string", + "enum": ["allow-home-read"] + }, + { + "description": "allow-home-write -> This allows non-recursive write access to the `$HOME` folder.", + "type": "string", + "enum": ["allow-home-write"] + }, + { + "description": "allow-home-meta-recursive -> This allows read access to metadata of the `$HOME` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-home-meta-recursive"] + }, + { + "description": "allow-home-meta -> This allows read access to metadata of the `$HOME` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-home-meta"] + }, + { + "description": "scope-home-recursive -> This scope recursive access to the complete `$HOME` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-home-recursive"] + }, + { + "description": "scope-home -> This scope permits access to all files and list content of top level directories in the `$HOME`folder.", + "type": "string", + "enum": ["scope-home"] + }, + { + "description": "scope-home-index -> This scope permits to list all files and folders in the `$HOME`folder.", + "type": "string", + "enum": ["scope-home-index"] + }, + { + "description": "allow-localdata-read-recursive -> This allows full recursive read access to the complete `$LOCALDATA` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-localdata-read-recursive"] + }, + { + "description": "allow-localdata-write-recursive -> This allows full recusrive write access to the complete `$LOCALDATA` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-localdata-write-recursive"] + }, + { + "description": "allow-localdata-read -> This allows non-recursive read access to the `$LOCALDATA` folder.", + "type": "string", + "enum": ["allow-localdata-read"] + }, + { + "description": "allow-localdata-write -> This allows non-recursive write access to the `$LOCALDATA` folder.", + "type": "string", + "enum": ["allow-localdata-write"] + }, + { + "description": "allow-localdata-meta-recursive -> This allows read access to metadata of the `$LOCALDATA` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-localdata-meta-recursive"] + }, + { + "description": "allow-localdata-meta -> This allows read access to metadata of the `$LOCALDATA` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-localdata-meta"] + }, + { + "description": "scope-localdata-recursive -> This scope recursive access to the complete `$LOCALDATA` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-localdata-recursive"] + }, + { + "description": "scope-localdata -> This scope permits access to all files and list content of top level directories in the `$LOCALDATA`folder.", + "type": "string", + "enum": ["scope-localdata"] + }, + { + "description": "scope-localdata-index -> This scope permits to list all files and folders in the `$LOCALDATA`folder.", + "type": "string", + "enum": ["scope-localdata-index"] + }, + { + "description": "allow-log-read-recursive -> This allows full recursive read access to the complete `$LOG` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-log-read-recursive"] + }, + { + "description": "allow-log-write-recursive -> This allows full recusrive write access to the complete `$LOG` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-log-write-recursive"] + }, + { + "description": "allow-log-read -> This allows non-recursive read access to the `$LOG` folder.", + "type": "string", + "enum": ["allow-log-read"] + }, + { + "description": "allow-log-write -> This allows non-recursive write access to the `$LOG` folder.", + "type": "string", + "enum": ["allow-log-write"] + }, + { + "description": "allow-log-meta-recursive -> This allows read access to metadata of the `$LOG` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-log-meta-recursive"] + }, + { + "description": "allow-log-meta -> This allows read access to metadata of the `$LOG` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-log-meta"] + }, + { + "description": "scope-log-recursive -> This scope recursive access to the complete `$LOG` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-log-recursive"] + }, + { + "description": "scope-log -> This scope permits access to all files and list content of top level directories in the `$LOG`folder.", + "type": "string", + "enum": ["scope-log"] + }, + { + "description": "scope-log-index -> This scope permits to list all files and folders in the `$LOG`folder.", + "type": "string", + "enum": ["scope-log-index"] + }, + { + "description": "allow-picture-read-recursive -> This allows full recursive read access to the complete `$PICTURE` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-picture-read-recursive"] + }, + { + "description": "allow-picture-write-recursive -> This allows full recusrive write access to the complete `$PICTURE` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-picture-write-recursive"] + }, + { + "description": "allow-picture-read -> This allows non-recursive read access to the `$PICTURE` folder.", + "type": "string", + "enum": ["allow-picture-read"] + }, + { + "description": "allow-picture-write -> This allows non-recursive write access to the `$PICTURE` folder.", + "type": "string", + "enum": ["allow-picture-write"] + }, + { + "description": "allow-picture-meta-recursive -> This allows read access to metadata of the `$PICTURE` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-picture-meta-recursive"] + }, + { + "description": "allow-picture-meta -> This allows read access to metadata of the `$PICTURE` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-picture-meta"] + }, + { + "description": "scope-picture-recursive -> This scope recursive access to the complete `$PICTURE` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-picture-recursive"] + }, + { + "description": "scope-picture -> This scope permits access to all files and list content of top level directories in the `$PICTURE`folder.", + "type": "string", + "enum": ["scope-picture"] + }, + { + "description": "scope-picture-index -> This scope permits to list all files and folders in the `$PICTURE`folder.", + "type": "string", + "enum": ["scope-picture-index"] + }, + { + "description": "allow-public-read-recursive -> This allows full recursive read access to the complete `$PUBLIC` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-public-read-recursive"] + }, + { + "description": "allow-public-write-recursive -> This allows full recusrive write access to the complete `$PUBLIC` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-public-write-recursive"] + }, + { + "description": "allow-public-read -> This allows non-recursive read access to the `$PUBLIC` folder.", + "type": "string", + "enum": ["allow-public-read"] + }, + { + "description": "allow-public-write -> This allows non-recursive write access to the `$PUBLIC` folder.", + "type": "string", + "enum": ["allow-public-write"] + }, + { + "description": "allow-public-meta-recursive -> This allows read access to metadata of the `$PUBLIC` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-public-meta-recursive"] + }, + { + "description": "allow-public-meta -> This allows read access to metadata of the `$PUBLIC` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-public-meta"] + }, + { + "description": "scope-public-recursive -> This scope recursive access to the complete `$PUBLIC` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-public-recursive"] + }, + { + "description": "scope-public -> This scope permits access to all files and list content of top level directories in the `$PUBLIC`folder.", + "type": "string", + "enum": ["scope-public"] + }, + { + "description": "scope-public-index -> This scope permits to list all files and folders in the `$PUBLIC`folder.", + "type": "string", + "enum": ["scope-public-index"] + }, + { + "description": "allow-resource-read-recursive -> This allows full recursive read access to the complete `$RESOURCE` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-resource-read-recursive"] + }, + { + "description": "allow-resource-write-recursive -> This allows full recusrive write access to the complete `$RESOURCE` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-resource-write-recursive"] + }, + { + "description": "allow-resource-read -> This allows non-recursive read access to the `$RESOURCE` folder.", + "type": "string", + "enum": ["allow-resource-read"] + }, + { + "description": "allow-resource-write -> This allows non-recursive write access to the `$RESOURCE` folder.", + "type": "string", + "enum": ["allow-resource-write"] + }, + { + "description": "allow-resource-meta-recursive -> This allows read access to metadata of the `$RESOURCE` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-resource-meta-recursive"] + }, + { + "description": "allow-resource-meta -> This allows read access to metadata of the `$RESOURCE` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-resource-meta"] + }, + { + "description": "scope-resource-recursive -> This scope recursive access to the complete `$RESOURCE` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-resource-recursive"] + }, + { + "description": "scope-resource -> This scope permits access to all files and list content of top level directories in the `$RESOURCE`folder.", + "type": "string", + "enum": ["scope-resource"] + }, + { + "description": "scope-resource-index -> This scope permits to list all files and folders in the `$RESOURCE`folder.", + "type": "string", + "enum": ["scope-resource-index"] + }, + { + "description": "allow-runtime-read-recursive -> This allows full recursive read access to the complete `$RUNTIME` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-runtime-read-recursive"] + }, + { + "description": "allow-runtime-write-recursive -> This allows full recusrive write access to the complete `$RUNTIME` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-runtime-write-recursive"] + }, + { + "description": "allow-runtime-read -> This allows non-recursive read access to the `$RUNTIME` folder.", + "type": "string", + "enum": ["allow-runtime-read"] + }, + { + "description": "allow-runtime-write -> This allows non-recursive write access to the `$RUNTIME` folder.", + "type": "string", + "enum": ["allow-runtime-write"] + }, + { + "description": "allow-runtime-meta-recursive -> This allows read access to metadata of the `$RUNTIME` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-runtime-meta-recursive"] + }, + { + "description": "allow-runtime-meta -> This allows read access to metadata of the `$RUNTIME` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-runtime-meta"] + }, + { + "description": "scope-runtime-recursive -> This scope recursive access to the complete `$RUNTIME` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-runtime-recursive"] + }, + { + "description": "scope-runtime -> This scope permits access to all files and list content of top level directories in the `$RUNTIME`folder.", + "type": "string", + "enum": ["scope-runtime"] + }, + { + "description": "scope-runtime-index -> This scope permits to list all files and folders in the `$RUNTIME`folder.", + "type": "string", + "enum": ["scope-runtime-index"] + }, + { + "description": "allow-temp-read-recursive -> This allows full recursive read access to the complete `$TEMP` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-temp-read-recursive"] + }, + { + "description": "allow-temp-write-recursive -> This allows full recusrive write access to the complete `$TEMP` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-temp-write-recursive"] + }, + { + "description": "allow-temp-read -> This allows non-recursive read access to the `$TEMP` folder.", + "type": "string", + "enum": ["allow-temp-read"] + }, + { + "description": "allow-temp-write -> This allows non-recursive write access to the `$TEMP` folder.", + "type": "string", + "enum": ["allow-temp-write"] + }, + { + "description": "allow-temp-meta-recursive -> This allows read access to metadata of the `$TEMP` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-temp-meta-recursive"] + }, + { + "description": "allow-temp-meta -> This allows read access to metadata of the `$TEMP` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-temp-meta"] + }, + { + "description": "scope-temp-recursive -> This scope recursive access to the complete `$TEMP` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-temp-recursive"] + }, + { + "description": "scope-temp -> This scope permits access to all files and list content of top level directories in the `$TEMP`folder.", + "type": "string", + "enum": ["scope-temp"] + }, + { + "description": "scope-temp-index -> This scope permits to list all files and folders in the `$TEMP`folder.", + "type": "string", + "enum": ["scope-temp-index"] + }, + { + "description": "allow-template-read-recursive -> This allows full recursive read access to the complete `$TEMPLATE` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-template-read-recursive"] + }, + { + "description": "allow-template-write-recursive -> This allows full recusrive write access to the complete `$TEMPLATE` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-template-write-recursive"] + }, + { + "description": "allow-template-read -> This allows non-recursive read access to the `$TEMPLATE` folder.", + "type": "string", + "enum": ["allow-template-read"] + }, + { + "description": "allow-template-write -> This allows non-recursive write access to the `$TEMPLATE` folder.", + "type": "string", + "enum": ["allow-template-write"] + }, + { + "description": "allow-template-meta-recursive -> This allows read access to metadata of the `$TEMPLATE` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-template-meta-recursive"] + }, + { + "description": "allow-template-meta -> This allows read access to metadata of the `$TEMPLATE` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-template-meta"] + }, + { + "description": "scope-template-recursive -> This scope recursive access to the complete `$TEMPLATE` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-template-recursive"] + }, + { + "description": "scope-template -> This scope permits access to all files and list content of top level directories in the `$TEMPLATE`folder.", + "type": "string", + "enum": ["scope-template"] + }, + { + "description": "scope-template-index -> This scope permits to list all files and folders in the `$TEMPLATE`folder.", + "type": "string", + "enum": ["scope-template-index"] + }, + { + "description": "allow-video-read-recursive -> This allows full recursive read access to the complete `$VIDEO` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-video-read-recursive"] + }, + { + "description": "allow-video-write-recursive -> This allows full recusrive write access to the complete `$VIDEO` folder, files and subdirectories.", + "type": "string", + "enum": ["allow-video-write-recursive"] + }, + { + "description": "allow-video-read -> This allows non-recursive read access to the `$VIDEO` folder.", + "type": "string", + "enum": ["allow-video-read"] + }, + { + "description": "allow-video-write -> This allows non-recursive write access to the `$VIDEO` folder.", + "type": "string", + "enum": ["allow-video-write"] + }, + { + "description": "allow-video-meta-recursive -> This allows read access to metadata of the `$VIDEO` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-video-meta-recursive"] + }, + { + "description": "allow-video-meta -> This allows read access to metadata of the `$VIDEO` folder, including file listing and statistics.", + "type": "string", + "enum": ["allow-video-meta"] + }, + { + "description": "scope-video-recursive -> This scope recursive access to the complete `$VIDEO` folder, including sub directories and files.", + "type": "string", + "enum": ["scope-video-recursive"] + }, + { + "description": "scope-video -> This scope permits access to all files and list content of top level directories in the `$VIDEO`folder.", + "type": "string", + "enum": ["scope-video"] + }, + { + "description": "scope-video-index -> This scope permits to list all files and folders in the `$VIDEO`folder.", + "type": "string", + "enum": ["scope-video-index"] + }, + { + "description": "allow-copy-file -> Enables the copy_file command without any pre-configured scope.", + "type": "string", + "enum": ["allow-copy-file"] + }, + { + "description": "deny-copy-file -> Denies the copy_file command without any pre-configured scope.", + "type": "string", + "enum": ["deny-copy-file"] + }, + { + "description": "allow-create -> Enables the create command without any pre-configured scope.", + "type": "string", + "enum": ["allow-create"] + }, + { + "description": "deny-create -> Denies the create command without any pre-configured scope.", + "type": "string", + "enum": ["deny-create"] + }, + { + "description": "allow-exists -> Enables the exists command without any pre-configured scope.", + "type": "string", + "enum": ["allow-exists"] + }, + { + "description": "deny-exists -> Denies the exists command without any pre-configured scope.", + "type": "string", + "enum": ["deny-exists"] + }, + { + "description": "allow-fstat -> Enables the fstat command without any pre-configured scope.", + "type": "string", + "enum": ["allow-fstat"] + }, + { + "description": "deny-fstat -> Denies the fstat command without any pre-configured scope.", + "type": "string", + "enum": ["deny-fstat"] + }, + { + "description": "allow-ftruncate -> Enables the ftruncate command without any pre-configured scope.", + "type": "string", + "enum": ["allow-ftruncate"] + }, + { + "description": "deny-ftruncate -> Denies the ftruncate command without any pre-configured scope.", + "type": "string", + "enum": ["deny-ftruncate"] + }, + { + "description": "allow-lstat -> Enables the lstat command without any pre-configured scope.", + "type": "string", + "enum": ["allow-lstat"] + }, + { + "description": "deny-lstat -> Denies the lstat command without any pre-configured scope.", + "type": "string", + "enum": ["deny-lstat"] + }, + { + "description": "allow-mkdir -> Enables the mkdir command without any pre-configured scope.", + "type": "string", + "enum": ["allow-mkdir"] + }, + { + "description": "deny-mkdir -> Denies the mkdir command without any pre-configured scope.", + "type": "string", + "enum": ["deny-mkdir"] + }, + { + "description": "allow-open -> Enables the open command without any pre-configured scope.", + "type": "string", + "enum": ["allow-open"] + }, + { + "description": "deny-open -> Denies the open command without any pre-configured scope.", + "type": "string", + "enum": ["deny-open"] + }, + { + "description": "allow-read -> Enables the read command without any pre-configured scope.", + "type": "string", + "enum": ["allow-read"] + }, + { + "description": "deny-read -> Denies the read command without any pre-configured scope.", + "type": "string", + "enum": ["deny-read"] + }, + { + "description": "allow-read-dir -> Enables the read_dir command without any pre-configured scope.", + "type": "string", + "enum": ["allow-read-dir"] + }, + { + "description": "deny-read-dir -> Denies the read_dir command without any pre-configured scope.", + "type": "string", + "enum": ["deny-read-dir"] + }, + { + "description": "allow-read-file -> Enables the read_file command without any pre-configured scope.", + "type": "string", + "enum": ["allow-read-file"] + }, + { + "description": "deny-read-file -> Denies the read_file command without any pre-configured scope.", + "type": "string", + "enum": ["deny-read-file"] + }, + { + "description": "allow-read-text-file -> Enables the read_text_file command without any pre-configured scope.", + "type": "string", + "enum": ["allow-read-text-file"] + }, + { + "description": "deny-read-text-file -> Denies the read_text_file command without any pre-configured scope.", + "type": "string", + "enum": ["deny-read-text-file"] + }, + { + "description": "allow-read-text-file-lines -> Enables the read_text_file_lines command without any pre-configured scope.", + "type": "string", + "enum": ["allow-read-text-file-lines"] + }, + { + "description": "deny-read-text-file-lines -> Denies the read_text_file_lines command without any pre-configured scope.", + "type": "string", + "enum": ["deny-read-text-file-lines"] + }, + { + "description": "allow-read-text-file-lines-next -> Enables the read_text_file_lines_next command without any pre-configured scope.", + "type": "string", + "enum": ["allow-read-text-file-lines-next"] + }, + { + "description": "deny-read-text-file-lines-next -> Denies the read_text_file_lines_next command without any pre-configured scope.", + "type": "string", + "enum": ["deny-read-text-file-lines-next"] + }, + { + "description": "allow-remove -> Enables the remove command without any pre-configured scope.", + "type": "string", + "enum": ["allow-remove"] + }, + { + "description": "deny-remove -> Denies the remove command without any pre-configured scope.", + "type": "string", + "enum": ["deny-remove"] + }, + { + "description": "allow-rename -> Enables the rename command without any pre-configured scope.", + "type": "string", + "enum": ["allow-rename"] + }, + { + "description": "deny-rename -> Denies the rename command without any pre-configured scope.", + "type": "string", + "enum": ["deny-rename"] + }, + { + "description": "allow-seek -> Enables the seek command without any pre-configured scope.", + "type": "string", + "enum": ["allow-seek"] + }, + { + "description": "deny-seek -> Denies the seek command without any pre-configured scope.", + "type": "string", + "enum": ["deny-seek"] + }, + { + "description": "allow-stat -> Enables the stat command without any pre-configured scope.", + "type": "string", + "enum": ["allow-stat"] + }, + { + "description": "deny-stat -> Denies the stat command without any pre-configured scope.", + "type": "string", + "enum": ["deny-stat"] + }, + { + "description": "allow-truncate -> Enables the truncate command without any pre-configured scope.", + "type": "string", + "enum": ["allow-truncate"] + }, + { + "description": "deny-truncate -> Denies the truncate command without any pre-configured scope.", + "type": "string", + "enum": ["deny-truncate"] + }, + { + "description": "allow-unwatch -> Enables the unwatch command without any pre-configured scope.", + "type": "string", + "enum": ["allow-unwatch"] + }, + { + "description": "deny-unwatch -> Denies the unwatch command without any pre-configured scope.", + "type": "string", + "enum": ["deny-unwatch"] + }, + { + "description": "allow-watch -> Enables the watch command without any pre-configured scope.", + "type": "string", + "enum": ["allow-watch"] + }, + { + "description": "deny-watch -> Denies the watch command without any pre-configured scope.", + "type": "string", + "enum": ["deny-watch"] + }, + { + "description": "allow-write -> Enables the write command without any pre-configured scope.", + "type": "string", + "enum": ["allow-write"] + }, + { + "description": "deny-write -> Denies the write command without any pre-configured scope.", + "type": "string", + "enum": ["deny-write"] + }, + { + "description": "allow-write-file -> Enables the write_file command without any pre-configured scope.", + "type": "string", + "enum": ["allow-write-file"] + }, + { + "description": "deny-write-file -> Denies the write_file command without any pre-configured scope.", + "type": "string", + "enum": ["deny-write-file"] + }, + { + "description": "allow-write-text-file -> Enables the write_text_file command without any pre-configured scope.", + "type": "string", + "enum": ["allow-write-text-file"] + }, + { + "description": "deny-write-text-file -> Denies the write_text_file command without any pre-configured scope.", + "type": "string", + "enum": ["deny-write-text-file"] + }, + { + "description": "default -> # Tauri `fs` default permissions\n\nThis configuration file defines the default permissions granted\nto the filesystem.\n\n### Granted Permissions\n\nThis default permission set enables all read-related commands and\nallows access to the `$APP` folder and sub directories created in it.\nThe location of the `$APP` folder depends on the operating system,\nwhere the application is run.\n\nIn general the `$APP` folder needs to be manually created\nby the application at runtime, before accessing files or folders\nin it is possible.\n\n### Denied Permissions\n\nThis default permission set prevents access to critical components\nof the Tauri application by default.\nOn Windows the webview data folder access is denied.\n\n", + "type": "string", + "enum": ["default"] + }, + { + "description": "deny-default -> This denies access to dangerous Tauri relevant files and folders by default.", + "type": "string", + "enum": ["deny-default"] + }, + { + "description": "deny-webview-data-linux -> This denies read access to the\n`$APPLOCALDATA` folder on linux as the webview data and configuration values are stored here.\nAllowing access can lead to sensitive information disclosure and should be well considered.", + "type": "string", + "enum": ["deny-webview-data-linux"] + }, + { + "description": "deny-webview-data-windows -> This denies read access to the\n`$APPLOCALDATA/EBWebView` folder on windows as the webview data and configuration values are stored here.\nAllowing access can lead to sensitive information disclosure and should be well considered.", + "type": "string", + "enum": ["deny-webview-data-windows"] + }, + { + "description": "read-all -> This enables all read related commands without any pre-configured accessible paths.", + "type": "string", + "enum": ["read-all"] + }, + { + "description": "read-dirs -> This enables directory read and file metadata related commands without any pre-configured accessible paths.", + "type": "string", + "enum": ["read-dirs"] + }, + { + "description": "read-files -> This enables file read related commands without any pre-configured accessible paths.", + "type": "string", + "enum": ["read-files"] + }, + { + "description": "read-meta -> This enables all index or metadata related commands without any pre-configured accessible paths.", + "type": "string", + "enum": ["read-meta"] + }, + { + "description": "scope -> An empty permission you can use to modify the global scope.", + "type": "string", + "enum": ["scope"] + }, + { + "description": "write-all -> This enables all write related commands without any pre-configured accessible paths.", + "type": "string", + "enum": ["write-all"] + }, + { + "description": "write-files -> This enables all file write related commands without any pre-configured accessible paths.", + "type": "string", + "enum": ["write-files"] + } + ] + } + } +} diff --git a/tsconfig.json b/tsconfig.json index 5098169..56b42b0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,4 +1,4 @@ { - "extends": "../../tsconfig.base.json", - "include": ["guest-js/*.ts"] + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] }