From 16505edb5ead65d2329334b9bc4b0817ffefc538 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Sat, 15 Apr 2023 12:50:29 -0300 Subject: [PATCH] feat: commit dist --- .gitignore | 3 +- plugins/fs/dist-js/index.d.ts | 356 ++++++++++++++++++++++++++++ plugins/fs/dist-js/index.min.js | 304 ++++++++++++++++++++++++ plugins/fs/dist-js/index.min.js.map | 1 + plugins/fs/dist-js/index.mjs | 302 +++++++++++++++++++++++ plugins/fs/dist-js/index.mjs.map | 1 + 6 files changed, 966 insertions(+), 1 deletion(-) create mode 100644 plugins/fs/dist-js/index.d.ts create mode 100644 plugins/fs/dist-js/index.min.js create mode 100644 plugins/fs/dist-js/index.min.js.map create mode 100644 plugins/fs/dist-js/index.mjs create mode 100644 plugins/fs/dist-js/index.mjs.map diff --git a/.gitignore b/.gitignore index 9a05fc88..7d8aa54c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ target node_modules dist -dist-js \ No newline at end of file +dist-js +!plugins/fs/dist-js \ No newline at end of file diff --git a/plugins/fs/dist-js/index.d.ts b/plugins/fs/dist-js/index.d.ts new file mode 100644 index 00000000..1b961dc9 --- /dev/null +++ b/plugins/fs/dist-js/index.d.ts @@ -0,0 +1,356 @@ +interface Permissions { + /** + * `true` if these permissions describe a readonly (unwritable) file. + */ + readonly: boolean; + /** + * The underlying raw `st_mode` bits that contain the standard Unix permissions for this file. + */ + mode: number | undefined; +} +/** + * Metadata information about a file. + * This structure is returned from the `metadata` function or method + * and represents known metadata about a file such as its permissions, size, modification times, etc. + */ +interface Metadata { + /** + * The last access time of this metadata. + */ + accessedAt: Date; + /** + * The creation time listed in this metadata. + */ + createdAt: Date; + /** + * The last modification time listed in this metadata. + */ + modifiedAt: Date; + /** + * `true` if this metadata is for a directory. + */ + isDir: boolean; + /** + * `true` if this metadata is for a regular file. + */ + isFile: boolean; + /** + * `true` if this metadata is for a symbolic link. + */ + isSymlink: boolean; + /** + * The size of the file, in bytes, this metadata is for. + */ + size: number; + /** + * The permissions of the file this metadata is for. + */ + permissions: Permissions; + /** + * The ID of the device containing the file. Only available on Unix. + */ + dev: number | undefined; + /** + * The inode number. Only available on Unix. + */ + ino: number | undefined; + /** + * The rights applied to this file. Only available on Unix. + */ + mode: number | undefined; + /** + * The number of hard links pointing to this file. Only available on Unix. + */ + nlink: number | undefined; + /** + * The user ID of the owner of this file. Only available on Unix. + */ + uid: number | undefined; + /** + * The group ID of the owner of this file. Only available on Unix. + */ + gid: number | undefined; + /** + * The device ID of this file (if it is a special one). Only available on Unix. + */ + rdev: number | undefined; + /** + * The block size for filesystem I/O. Only available on Unix. + */ + blksize: number | undefined; + /** + * The number of blocks allocated to the file, in 512-byte units. Only available on Unix. + */ + blocks: number | undefined; +} +/** + * @since 1.0.0 + */ +declare enum BaseDirectory { + Audio = 1, + Cache = 2, + Config = 3, + Data = 4, + LocalData = 5, + Document = 6, + Download = 7, + Picture = 8, + Public = 9, + Video = 10, + Resource = 11, + Temp = 12, + AppConfig = 13, + AppData = 14, + AppLocalData = 15, + AppCache = 16, + AppLog = 17, + Desktop = 18, + Executable = 19, + Font = 20, + Home = 21, + Runtime = 22, + Template = 23 +} +/** + * @since 1.0.0 + */ +interface FsOptions { + dir?: BaseDirectory; +} +/** + * @since 1.0.0 + */ +interface FsDirOptions { + dir?: BaseDirectory; + recursive?: boolean; +} +/** + * Options object used to write a UTF-8 string to a file. + * + * @since 1.0.0 + */ +interface FsTextFileOption { + /** Path to the file to write. */ + path: string; + /** The UTF-8 string to write to the file. */ + contents: string; +} +type BinaryFileContents = Iterable | ArrayLike | ArrayBuffer; +/** + * Options object used to write a binary data to a file. + * + * @since 1.0.0 + */ +interface FsBinaryFileOption { + /** Path to the file to write. */ + path: string; + /** The byte array contents. */ + contents: BinaryFileContents; +} +/** + * @since 1.0.0 + */ +interface FileEntry { + path: string; + /** + * Name of the directory/file + * can be null if the path terminates with `..` + */ + name?: string; + /** Children of this entry if it's a directory; null otherwise */ + children?: FileEntry[]; +} +/** + * Reads a file as an UTF-8 encoded string. + * @example + * ```typescript + * import { readTextFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Read the text file in the `$APPCONFIG/app.conf` path + * const contents = await readTextFile('app.conf', { dir: BaseDirectory.AppConfig }); + * ``` + * + * @since 1.0.0 + */ +declare function readTextFile(filePath: string, options?: FsOptions): Promise; +/** + * Reads a file as byte array. + * @example + * ```typescript + * import { readBinaryFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Read the image file in the `$RESOURCEDIR/avatar.png` path + * const contents = await readBinaryFile('avatar.png', { dir: BaseDirectory.Resource }); + * ``` + * + * @since 1.0.0 + */ +declare function readBinaryFile(filePath: string, options?: FsOptions): Promise; +/** + * Writes a UTF-8 text file. + * @example + * ```typescript + * import { writeTextFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Write a text file to the `$APPCONFIG/app.conf` path + * await writeTextFile('app.conf', 'file contents', { dir: BaseDirectory.AppConfig }); + * ``` + * + * @since 1.0.0 + */ +declare function writeTextFile(path: string, contents: string, options?: FsOptions): Promise; +/** + * Writes a UTF-8 text file. + * @example + * ```typescript + * import { writeTextFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Write a text file to the `$APPCONFIG/app.conf` path + * await writeTextFile({ path: 'app.conf', contents: 'file contents' }, { dir: BaseDirectory.AppConfig }); + * ``` + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +declare function writeTextFile(file: FsTextFileOption, options?: FsOptions): Promise; +/** + * Writes a byte array content to a file. + * @example + * ```typescript + * import { writeBinaryFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Write a binary file to the `$APPDATA/avatar.png` path + * await writeBinaryFile('avatar.png', new Uint8Array([]), { dir: BaseDirectory.AppData }); + * ``` + * + * @param options Configuration object. + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +declare function writeBinaryFile(path: string, contents: BinaryFileContents, options?: FsOptions): Promise; +/** + * Writes a byte array content to a file. + * @example + * ```typescript + * import { writeBinaryFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Write a binary file to the `$APPDATA/avatar.png` path + * await writeBinaryFile({ path: 'avatar.png', contents: new Uint8Array([]) }, { dir: BaseDirectory.AppData }); + * ``` + * + * @param file The object containing the file path and contents. + * @param options Configuration object. + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +declare function writeBinaryFile(file: FsBinaryFileOption, options?: FsOptions): Promise; +/** + * List directory files. + * @example + * ```typescript + * import { readDir, BaseDirectory } from '@tauri-apps/api/fs'; + * // Reads the `$APPDATA/users` directory recursively + * const entries = await readDir('users', { dir: BaseDirectory.AppData, recursive: true }); + * + * function processEntries(entries) { + * for (const entry of entries) { + * console.log(`Entry: ${entry.path}`); + * if (entry.children) { + * processEntries(entry.children) + * } + * } + * } + * ``` + * + * @since 1.0.0 + */ +declare function readDir(dir: string, options?: FsDirOptions): Promise; +/** + * Creates a directory. + * If one of the path's parent components doesn't exist + * and the `recursive` option isn't set to true, the promise will be rejected. + * @example + * ```typescript + * import { createDir, BaseDirectory } from '@tauri-apps/api/fs'; + * // Create the `$APPDATA/users` directory + * await createDir('users', { dir: BaseDirectory.AppData, recursive: true }); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +declare function createDir(dir: string, options?: FsDirOptions): Promise; +/** + * Removes a directory. + * If the directory is not empty and the `recursive` option isn't set to true, the promise will be rejected. + * @example + * ```typescript + * import { removeDir, BaseDirectory } from '@tauri-apps/api/fs'; + * // Remove the directory `$APPDATA/users` + * await removeDir('users', { dir: BaseDirectory.AppData }); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +declare function removeDir(dir: string, options?: FsDirOptions): Promise; +/** + * Copies a file to a destination. + * @example + * ```typescript + * import { copyFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Copy the `$APPCONFIG/app.conf` file to `$APPCONFIG/app.conf.bk` + * await copyFile('app.conf', 'app.conf.bk', { dir: BaseDirectory.AppConfig }); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +declare function copyFile(source: string, destination: string, options?: FsOptions): Promise; +/** + * Removes a file. + * @example + * ```typescript + * import { removeFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Remove the `$APPConfig/app.conf` file + * await removeFile('app.conf', { dir: BaseDirectory.AppConfig }); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +declare function removeFile(file: string, options?: FsOptions): Promise; +/** + * Renames a file. + * @example + * ```typescript + * import { renameFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Rename the `$APPDATA/avatar.png` file + * await renameFile('avatar.png', 'deleted.png', { dir: BaseDirectory.AppData }); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +declare function renameFile(oldPath: string, newPath: string, options?: FsOptions): Promise; +/** + * Check if a path exists. + * @example + * ```typescript + * import { exists, BaseDirectory } from '@tauri-apps/api/fs'; + * // Check if the `$APPDATA/avatar.png` file exists + * await exists('avatar.png', { dir: BaseDirectory.AppData }); + * ``` + * + * @since 1.0.0 + */ +declare function exists(path: string): Promise; +/** + * Returns the metadata for the given path. + * + * @since 1.0.0 + */ +declare function metadata(path: string): Promise; +export type { FsOptions, FsDirOptions, FsTextFileOption, BinaryFileContents, FsBinaryFileOption, FileEntry, Permissions, Metadata, }; +export { BaseDirectory, BaseDirectory as Dir, readTextFile, readBinaryFile, writeTextFile, writeTextFile as writeFile, writeBinaryFile, readDir, createDir, removeDir, copyFile, removeFile, renameFile, exists, metadata }; diff --git a/plugins/fs/dist-js/index.min.js b/plugins/fs/dist-js/index.min.js new file mode 100644 index 00000000..7c89dec3 --- /dev/null +++ b/plugins/fs/dist-js/index.min.js @@ -0,0 +1,304 @@ +var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0});}; + +var f={};e(f,{convertFileSrc:()=>w,invoke:()=>c,transformCallback:()=>s});function u(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(e,r=!1){let n=u(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c(e,r={}){return new Promise((n,t)=>{let o=s(i=>{n(i),Reflect.deleteProperty(window,`_${a}`);},!0),a=s(i=>{t(i),Reflect.deleteProperty(window,`_${o}`);},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r});})}function w(e,r="asset"){let n=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${r}.localhost/${n}`:`${r}://localhost/${n}`} + +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// TODO: pull BaseDirectory from @tauri-apps/api/path +/** + * @since 1.0.0 + */ +var BaseDirectory; +(function (BaseDirectory) { + BaseDirectory[BaseDirectory["Audio"] = 1] = "Audio"; + BaseDirectory[BaseDirectory["Cache"] = 2] = "Cache"; + BaseDirectory[BaseDirectory["Config"] = 3] = "Config"; + BaseDirectory[BaseDirectory["Data"] = 4] = "Data"; + BaseDirectory[BaseDirectory["LocalData"] = 5] = "LocalData"; + BaseDirectory[BaseDirectory["Document"] = 6] = "Document"; + BaseDirectory[BaseDirectory["Download"] = 7] = "Download"; + BaseDirectory[BaseDirectory["Picture"] = 8] = "Picture"; + BaseDirectory[BaseDirectory["Public"] = 9] = "Public"; + BaseDirectory[BaseDirectory["Video"] = 10] = "Video"; + BaseDirectory[BaseDirectory["Resource"] = 11] = "Resource"; + BaseDirectory[BaseDirectory["Temp"] = 12] = "Temp"; + BaseDirectory[BaseDirectory["AppConfig"] = 13] = "AppConfig"; + BaseDirectory[BaseDirectory["AppData"] = 14] = "AppData"; + BaseDirectory[BaseDirectory["AppLocalData"] = 15] = "AppLocalData"; + BaseDirectory[BaseDirectory["AppCache"] = 16] = "AppCache"; + BaseDirectory[BaseDirectory["AppLog"] = 17] = "AppLog"; + BaseDirectory[BaseDirectory["Desktop"] = 18] = "Desktop"; + BaseDirectory[BaseDirectory["Executable"] = 19] = "Executable"; + BaseDirectory[BaseDirectory["Font"] = 20] = "Font"; + BaseDirectory[BaseDirectory["Home"] = 21] = "Home"; + BaseDirectory[BaseDirectory["Runtime"] = 22] = "Runtime"; + BaseDirectory[BaseDirectory["Template"] = 23] = "Template"; +})(BaseDirectory || (BaseDirectory = {})); +/** + * Reads a file as an UTF-8 encoded string. + * @example + * ```typescript + * import { readTextFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Read the text file in the `$APPCONFIG/app.conf` path + * const contents = await readTextFile('app.conf', { dir: BaseDirectory.AppConfig }); + * ``` + * + * @since 1.0.0 + */ +async function readTextFile(filePath, options = {}) { + return await c("plugin:fs|read_text_file", { + path: filePath, + options + }); +} +/** + * Reads a file as byte array. + * @example + * ```typescript + * import { readBinaryFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Read the image file in the `$RESOURCEDIR/avatar.png` path + * const contents = await readBinaryFile('avatar.png', { dir: BaseDirectory.Resource }); + * ``` + * + * @since 1.0.0 + */ +async function readBinaryFile(filePath, options = {}) { + const arr = await c("plugin:fs|read_file", { + path: filePath, + options + }); + return Uint8Array.from(arr); +} +/** + * Writes a UTF-8 text file. + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function writeTextFile(path, contents, options) { + if (typeof options === 'object') { + Object.freeze(options); + } + if (typeof path === 'object') { + Object.freeze(path); + } + const file = { path: '', contents: '' }; + let fileOptions = options; + if (typeof path === 'string') { + file.path = path; + } + else { + file.path = path.path; + file.contents = path.contents; + } + if (typeof contents === 'string') { + file.contents = contents !== null && contents !== void 0 ? contents : ''; + } + else { + fileOptions = contents; + } + return await c("plugin:fs|write_file", { + path: file.path, + contents: Array.from(new TextEncoder().encode(file.contents)), + options: fileOptions + }); +} +/** + * Writes a byte array content to a file. + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function writeBinaryFile(path, contents, options) { + if (typeof options === 'object') { + Object.freeze(options); + } + if (typeof path === 'object') { + Object.freeze(path); + } + const file = { path: '', contents: [] }; + let fileOptions = options; + if (typeof path === 'string') { + file.path = path; + } + else { + file.path = path.path; + file.contents = path.contents; + } + if (contents && 'dir' in contents) { + fileOptions = contents; + } + else if (typeof path === 'string') { + // @ts-expect-error in this case `contents` is always a BinaryFileContents + file.contents = contents !== null && contents !== void 0 ? contents : []; + } + return await c("plugin:fs|write_binary_file", { + path: file.path, + contents: Array.from(file.contents instanceof ArrayBuffer + ? new Uint8Array(file.contents) + : file.contents), + options: fileOptions + }); +} +/** + * List directory files. + * @example + * ```typescript + * import { readDir, BaseDirectory } from '@tauri-apps/api/fs'; + * // Reads the `$APPDATA/users` directory recursively + * const entries = await readDir('users', { dir: BaseDirectory.AppData, recursive: true }); + * + * function processEntries(entries) { + * for (const entry of entries) { + * console.log(`Entry: ${entry.path}`); + * if (entry.children) { + * processEntries(entry.children) + * } + * } + * } + * ``` + * + * @since 1.0.0 + */ +async function readDir(dir, options = {}) { + return await c("plugin:fs|read_dir", { + path: dir, + options + }); +} +/** + * Creates a directory. + * If one of the path's parent components doesn't exist + * and the `recursive` option isn't set to true, the promise will be rejected. + * @example + * ```typescript + * import { createDir, BaseDirectory } from '@tauri-apps/api/fs'; + * // Create the `$APPDATA/users` directory + * await createDir('users', { dir: BaseDirectory.AppData, recursive: true }); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function createDir(dir, options = {}) { + return await c("plugin:fs|create_dir", { + path: dir, + options + }); +} +/** + * Removes a directory. + * If the directory is not empty and the `recursive` option isn't set to true, the promise will be rejected. + * @example + * ```typescript + * import { removeDir, BaseDirectory } from '@tauri-apps/api/fs'; + * // Remove the directory `$APPDATA/users` + * await removeDir('users', { dir: BaseDirectory.AppData }); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function removeDir(dir, options = {}) { + return await c("plugin:fs|remove_dir", { + path: dir, + options + }); +} +/** + * Copies a file to a destination. + * @example + * ```typescript + * import { copyFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Copy the `$APPCONFIG/app.conf` file to `$APPCONFIG/app.conf.bk` + * await copyFile('app.conf', 'app.conf.bk', { dir: BaseDirectory.AppConfig }); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function copyFile(source, destination, options = {}) { + return await c("plugin:fs|copy_file", { + source, + destination, + options + }); +} +/** + * Removes a file. + * @example + * ```typescript + * import { removeFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Remove the `$APPConfig/app.conf` file + * await removeFile('app.conf', { dir: BaseDirectory.AppConfig }); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function removeFile(file, options = {}) { + return await c("plugin:fs|remove_file", { + path: file, + options + }); +} +/** + * Renames a file. + * @example + * ```typescript + * import { renameFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Rename the `$APPDATA/avatar.png` file + * await renameFile('avatar.png', 'deleted.png', { dir: BaseDirectory.AppData }); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function renameFile(oldPath, newPath, options = {}) { + return await c("plugin:fs|rename_file", { + oldPath, + newPath, + options + }); +} +/** + * Check if a path exists. + * @example + * ```typescript + * import { exists, BaseDirectory } from '@tauri-apps/api/fs'; + * // Check if the `$APPDATA/avatar.png` file exists + * await exists('avatar.png', { dir: BaseDirectory.AppData }); + * ``` + * + * @since 1.0.0 + */ +async function exists(path) { + return await c("plugin:fs|exists", { path }); +} +/** + * Returns the metadata for the given path. + * + * @since 1.0.0 + */ +async function metadata(path) { + return await c("plugin:fs|metadata", { + path, + }).then((metadata) => { + const { accessedAtMs, createdAtMs, modifiedAtMs, ...data } = metadata; + return { + accessedAt: new Date(accessedAtMs), + createdAt: new Date(createdAtMs), + modifiedAt: new Date(modifiedAtMs), + ...data, + }; + }); +} + +export { BaseDirectory, BaseDirectory as Dir, copyFile, createDir, exists, metadata, readBinaryFile, readDir, readTextFile, removeDir, removeFile, renameFile, writeBinaryFile, writeTextFile as writeFile, writeTextFile }; +//# sourceMappingURL=index.min.js.map diff --git a/plugins/fs/dist-js/index.min.js.map b/plugins/fs/dist-js/index.min.js.map new file mode 100644 index 00000000..7eb4ec48 --- /dev/null +++ b/plugins/fs/dist-js/index.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.min.js","sources":["../../../node_modules/.pnpm/@tauri-apps+api@1.2.0/node_modules/@tauri-apps/api/chunk-FEIY7W7S.js","../../../node_modules/.pnpm/@tauri-apps+api@1.2.0/node_modules/@tauri-apps/api/chunk-RCPA6UVN.js","../guest-js/index.ts"],"sourcesContent":["var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0})};export{e as a};\n","import{a as d}from\"./chunk-FEIY7W7S.js\";var f={};d(f,{convertFileSrc:()=>w,invoke:()=>c,transformCallback:()=>s});function u(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(e,r=!1){let n=u(),t=`_${n}`;return Object.defineProperty(window,t,{value:o=>(r&&Reflect.deleteProperty(window,t),e==null?void 0:e(o)),writable:!1,configurable:!0}),n}async function c(e,r={}){return new Promise((n,t)=>{let o=s(i=>{n(i),Reflect.deleteProperty(window,`_${a}`)},!0),a=s(i=>{t(i),Reflect.deleteProperty(window,`_${o}`)},!0);window.__TAURI_IPC__({cmd:e,callback:o,error:a,...r})})}function w(e,r=\"asset\"){let n=encodeURIComponent(e);return navigator.userAgent.includes(\"Windows\")?`https://${r}.localhost/${n}`:`${r}://localhost/${n}`}export{s as a,c as b,w as c,f as d};\n",null],"names":["d","invoke"],"mappings":"AAAA,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,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I,IAAI,CAAC,WAAW,CAAC;AAChC,YAAA,UAAU,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC;AAClC,YAAA,GAAG,IAAI;SACR,CAAC;AACJ,KAAC,CAAC,CAAC;AACL;;;;"} \ No newline at end of file diff --git a/plugins/fs/dist-js/index.mjs b/plugins/fs/dist-js/index.mjs new file mode 100644 index 00000000..077ae34d --- /dev/null +++ b/plugins/fs/dist-js/index.mjs @@ -0,0 +1,302 @@ +import { invoke } from '@tauri-apps/api/tauri'; + +// Copyright 2019-2023 Tauri Programme within The Commons Conservancy +// TODO: pull BaseDirectory from @tauri-apps/api/path +/** + * @since 1.0.0 + */ +var BaseDirectory; +(function (BaseDirectory) { + BaseDirectory[BaseDirectory["Audio"] = 1] = "Audio"; + BaseDirectory[BaseDirectory["Cache"] = 2] = "Cache"; + BaseDirectory[BaseDirectory["Config"] = 3] = "Config"; + BaseDirectory[BaseDirectory["Data"] = 4] = "Data"; + BaseDirectory[BaseDirectory["LocalData"] = 5] = "LocalData"; + BaseDirectory[BaseDirectory["Document"] = 6] = "Document"; + BaseDirectory[BaseDirectory["Download"] = 7] = "Download"; + BaseDirectory[BaseDirectory["Picture"] = 8] = "Picture"; + BaseDirectory[BaseDirectory["Public"] = 9] = "Public"; + BaseDirectory[BaseDirectory["Video"] = 10] = "Video"; + BaseDirectory[BaseDirectory["Resource"] = 11] = "Resource"; + BaseDirectory[BaseDirectory["Temp"] = 12] = "Temp"; + BaseDirectory[BaseDirectory["AppConfig"] = 13] = "AppConfig"; + BaseDirectory[BaseDirectory["AppData"] = 14] = "AppData"; + BaseDirectory[BaseDirectory["AppLocalData"] = 15] = "AppLocalData"; + BaseDirectory[BaseDirectory["AppCache"] = 16] = "AppCache"; + BaseDirectory[BaseDirectory["AppLog"] = 17] = "AppLog"; + BaseDirectory[BaseDirectory["Desktop"] = 18] = "Desktop"; + BaseDirectory[BaseDirectory["Executable"] = 19] = "Executable"; + BaseDirectory[BaseDirectory["Font"] = 20] = "Font"; + BaseDirectory[BaseDirectory["Home"] = 21] = "Home"; + BaseDirectory[BaseDirectory["Runtime"] = 22] = "Runtime"; + BaseDirectory[BaseDirectory["Template"] = 23] = "Template"; +})(BaseDirectory || (BaseDirectory = {})); +/** + * Reads a file as an UTF-8 encoded string. + * @example + * ```typescript + * import { readTextFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Read the text file in the `$APPCONFIG/app.conf` path + * const contents = await readTextFile('app.conf', { dir: BaseDirectory.AppConfig }); + * ``` + * + * @since 1.0.0 + */ +async function readTextFile(filePath, options = {}) { + return await invoke("plugin:fs|read_text_file", { + path: filePath, + options + }); +} +/** + * Reads a file as byte array. + * @example + * ```typescript + * import { readBinaryFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Read the image file in the `$RESOURCEDIR/avatar.png` path + * const contents = await readBinaryFile('avatar.png', { dir: BaseDirectory.Resource }); + * ``` + * + * @since 1.0.0 + */ +async function readBinaryFile(filePath, options = {}) { + const arr = await invoke("plugin:fs|read_file", { + path: filePath, + options + }); + return Uint8Array.from(arr); +} +/** + * Writes a UTF-8 text file. + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function writeTextFile(path, contents, options) { + if (typeof options === 'object') { + Object.freeze(options); + } + if (typeof path === 'object') { + Object.freeze(path); + } + const file = { path: '', contents: '' }; + let fileOptions = options; + if (typeof path === 'string') { + file.path = path; + } + else { + file.path = path.path; + file.contents = path.contents; + } + if (typeof contents === 'string') { + file.contents = contents !== null && contents !== void 0 ? contents : ''; + } + else { + fileOptions = contents; + } + return await invoke("plugin:fs|write_file", { + path: file.path, + contents: Array.from(new TextEncoder().encode(file.contents)), + options: fileOptions + }); +} +/** + * Writes a byte array content to a file. + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function writeBinaryFile(path, contents, options) { + if (typeof options === 'object') { + Object.freeze(options); + } + if (typeof path === 'object') { + Object.freeze(path); + } + const file = { path: '', contents: [] }; + let fileOptions = options; + if (typeof path === 'string') { + file.path = path; + } + else { + file.path = path.path; + file.contents = path.contents; + } + if (contents && 'dir' in contents) { + fileOptions = contents; + } + else if (typeof path === 'string') { + // @ts-expect-error in this case `contents` is always a BinaryFileContents + file.contents = contents !== null && contents !== void 0 ? contents : []; + } + return await invoke("plugin:fs|write_binary_file", { + path: file.path, + contents: Array.from(file.contents instanceof ArrayBuffer + ? new Uint8Array(file.contents) + : file.contents), + options: fileOptions + }); +} +/** + * List directory files. + * @example + * ```typescript + * import { readDir, BaseDirectory } from '@tauri-apps/api/fs'; + * // Reads the `$APPDATA/users` directory recursively + * const entries = await readDir('users', { dir: BaseDirectory.AppData, recursive: true }); + * + * function processEntries(entries) { + * for (const entry of entries) { + * console.log(`Entry: ${entry.path}`); + * if (entry.children) { + * processEntries(entry.children) + * } + * } + * } + * ``` + * + * @since 1.0.0 + */ +async function readDir(dir, options = {}) { + return await invoke("plugin:fs|read_dir", { + path: dir, + options + }); +} +/** + * Creates a directory. + * If one of the path's parent components doesn't exist + * and the `recursive` option isn't set to true, the promise will be rejected. + * @example + * ```typescript + * import { createDir, BaseDirectory } from '@tauri-apps/api/fs'; + * // Create the `$APPDATA/users` directory + * await createDir('users', { dir: BaseDirectory.AppData, recursive: true }); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function createDir(dir, options = {}) { + return await invoke("plugin:fs|create_dir", { + path: dir, + options + }); +} +/** + * Removes a directory. + * If the directory is not empty and the `recursive` option isn't set to true, the promise will be rejected. + * @example + * ```typescript + * import { removeDir, BaseDirectory } from '@tauri-apps/api/fs'; + * // Remove the directory `$APPDATA/users` + * await removeDir('users', { dir: BaseDirectory.AppData }); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function removeDir(dir, options = {}) { + return await invoke("plugin:fs|remove_dir", { + path: dir, + options + }); +} +/** + * Copies a file to a destination. + * @example + * ```typescript + * import { copyFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Copy the `$APPCONFIG/app.conf` file to `$APPCONFIG/app.conf.bk` + * await copyFile('app.conf', 'app.conf.bk', { dir: BaseDirectory.AppConfig }); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function copyFile(source, destination, options = {}) { + return await invoke("plugin:fs|copy_file", { + source, + destination, + options + }); +} +/** + * Removes a file. + * @example + * ```typescript + * import { removeFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Remove the `$APPConfig/app.conf` file + * await removeFile('app.conf', { dir: BaseDirectory.AppConfig }); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function removeFile(file, options = {}) { + return await invoke("plugin:fs|remove_file", { + path: file, + options + }); +} +/** + * Renames a file. + * @example + * ```typescript + * import { renameFile, BaseDirectory } from '@tauri-apps/api/fs'; + * // Rename the `$APPDATA/avatar.png` file + * await renameFile('avatar.png', 'deleted.png', { dir: BaseDirectory.AppData }); + * ``` + * + * @returns A promise indicating the success or failure of the operation. + * + * @since 1.0.0 + */ +async function renameFile(oldPath, newPath, options = {}) { + return await invoke("plugin:fs|rename_file", { + oldPath, + newPath, + options + }); +} +/** + * Check if a path exists. + * @example + * ```typescript + * import { exists, BaseDirectory } from '@tauri-apps/api/fs'; + * // Check if the `$APPDATA/avatar.png` file exists + * await exists('avatar.png', { dir: BaseDirectory.AppData }); + * ``` + * + * @since 1.0.0 + */ +async function exists(path) { + return await invoke("plugin:fs|exists", { path }); +} +/** + * Returns the metadata for the given path. + * + * @since 1.0.0 + */ +async function metadata(path) { + return await invoke("plugin:fs|metadata", { + path, + }).then((metadata) => { + const { accessedAtMs, createdAtMs, modifiedAtMs, ...data } = metadata; + return { + accessedAt: new Date(accessedAtMs), + createdAt: new Date(createdAtMs), + modifiedAt: new Date(modifiedAtMs), + ...data, + }; + }); +} + +export { BaseDirectory, BaseDirectory as Dir, copyFile, createDir, exists, metadata, readBinaryFile, readDir, readTextFile, removeDir, removeFile, renameFile, writeBinaryFile, writeTextFile as writeFile, writeTextFile }; +//# sourceMappingURL=index.mjs.map diff --git a/plugins/fs/dist-js/index.mjs.map b/plugins/fs/dist-js/index.mjs.map new file mode 100644 index 00000000..c5d92203 --- /dev/null +++ b/plugins/fs/dist-js/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../guest-js/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AAwLA;AACA;;AAEG;AACH,IAAK,cAyBJ;AAzBD,CAAA,UAAK,aAAa,EAAA;AAChB,IAAA,aAAA,CAAA,aAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS,CAAA;AACT,IAAA,aAAA,CAAA,aAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAK,CAAA;AACL,IAAA,aAAA,CAAA,aAAA,CAAA,QAAA,CAAA,GAAA,CAAA,CAAA,GAAA,QAAM,CAAA;AACN,IAAA,aAAA,CAAA,aAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAI,CAAA;AACJ,IAAA,aAAA,CAAA,aAAA,CAAA,WAAA,CAAA,GAAA,CAAA,CAAA,GAAA,WAAS,CAAA;AACT,IAAA,aAAA,CAAA,aAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAQ,CAAA;AACR,IAAA,aAAA,CAAA,aAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAQ,CAAA;AACR,IAAA,aAAA,CAAA,aAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAO,CAAA;AACP,IAAA,aAAA,CAAA,aAAA,CAAA,QAAA,CAAA,GAAA,CAAA,CAAA,GAAA,QAAM,CAAA;AACN,IAAA,aAAA,CAAA,aAAA,CAAA,OAAA,CAAA,GAAA,EAAA,CAAA,GAAA,OAAK,CAAA;AACL,IAAA,aAAA,CAAA,aAAA,CAAA,UAAA,CAAA,GAAA,EAAA,CAAA,G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