Update gitignore (sorry)

This commit is contained in:
olcxja 2026-05-10 14:02:17 +02:00
commit cca8b02fea
6604 changed files with 1219661 additions and 4 deletions

21
electron/node_modules/@capacitor/cli/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017-present Drifty Co.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

84
electron/node_modules/@capacitor/cli/README.md generated vendored Normal file
View file

@ -0,0 +1,84 @@
# Capacitor CLI
The Capacitor command-line interface (CLI) is a tool for creating and managing Capacitor applications. While it can be installed globally, it's recommended to install it locally in your project and execute through `npm` scripts.
## Installation
### Project Installation (Recommended)
Install the CLI locally in your project:
```bash
npm install @capacitor/cli --save-dev
```
### Global Installation
While not recommended for project use, you can install the CLI globally:
```bash
npm install -g @capacitor/cli
```
## Using Capacitor CLI
The CLI can be used through the `capacitor` or `cap` command. When installed locally, use it through your project's `npm` scripts or `npx`.
Common commands:
- `cap init`: Initialize a new Capacitor project
- `cap add`: Add a native platform (ios, android)
- `cap sync`: Sync your web code to your native projects
For detailed information, consult the [Getting Started guide](https://capacitorjs.com/docs/getting-started).
## Local Development
If you're contributing to the Capacitor CLI or testing local changes:
1. Clone and setup:
```bash
git clone https://github.com/ionic-team/capacitor.git
cd cli
npm install
```
2. Build the CLI:
```bash
npm run build
```
3. Create a local link:
```bash
npm link
```
4. Development workflow:
- Run `npm run watch` to automatically rebuild on changes
- Use `capacitor` or `cap` commands to test your changes
- Run `npm test` to execute the test suite
## Debugging
### Using VS Code Launch Configurations
The CLI includes VS Code launch configurations for debugging. To debug a CLI command:
1. Open the project in VS Code
2. Right now we don't have debugging working in the ts files, so select one of the .js files inside of /dist/\*\*.js
3. Place a breakpoint
4. Press F5 or go to Run > Start Debugging
5. Select a launch config and run filling out the path you want to run the cli in, and the command that you want run.
You can add more configurations by copying and modifying the existing ones in `.vscode/launch.json`.
## Contributing
Contributions are welcome! Please read our [Contributing Guide](https://github.com/ionic-team/capacitor/blob/main/CONTRIBUTING.md) for details.
### License
- [MIT](https://github.com/ionic-team/capacitor/blob/HEAD/LICENSE)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

18
electron/node_modules/@capacitor/cli/bin/capacitor generated vendored Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env node
'use strict';
var satisfies = require('semver/functions/satisfies');
var packageJson = require('../package.json');
var requiresNodeVersion = packageJson.engines.node;
if (!satisfies(process.version, requiresNodeVersion, { includePrerelease: true})) {
process.stdout.write(
'\x1b[31m[fatal]\x1b[39m The Capacitor CLI requires NodeJS ' + requiresNodeVersion + '\n' +
' Please install the latest LTS version.\n'
);
process.exit(1);
}
var cli = require('../dist/index');
cli.run();

View file

@ -0,0 +1,15 @@
(The MIT License)
Copyright (c) 2011-2024 JP Richardson
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,294 @@
Node.js: fs-extra
=================
`fs-extra` adds file system methods that aren't included in the native `fs` module and adds promise support to the `fs` methods. It also uses [`graceful-fs`](https://github.com/isaacs/node-graceful-fs) to prevent `EMFILE` errors. It should be a drop in replacement for `fs`.
[![npm Package](https://img.shields.io/npm/v/fs-extra.svg)](https://www.npmjs.org/package/fs-extra)
[![License](https://img.shields.io/npm/l/fs-extra.svg)](https://github.com/jprichardson/node-fs-extra/blob/master/LICENSE)
[![build status](https://img.shields.io/github/actions/workflow/status/jprichardson/node-fs-extra/ci.yml?branch=master)](https://github.com/jprichardson/node-fs-extra/actions/workflows/ci.yml?query=branch%3Amaster)
[![downloads per month](http://img.shields.io/npm/dm/fs-extra.svg)](https://www.npmjs.org/package/fs-extra)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
Why?
----
I got tired of including `mkdirp`, `rimraf`, and `ncp` in most of my projects.
Installation
------------
npm install fs-extra
Usage
-----
### CommonJS
`fs-extra` is a drop in replacement for native `fs`. All methods in `fs` are attached to `fs-extra`. All `fs` methods return promises if the callback isn't passed.
You don't ever need to include the original `fs` module again:
```js
const fs = require('fs') // this is no longer necessary
```
you can now do this:
```js
const fs = require('fs-extra')
```
or if you prefer to make it clear that you're using `fs-extra` and not `fs`, you may want
to name your `fs` variable `fse` like so:
```js
const fse = require('fs-extra')
```
you can also keep both, but it's redundant:
```js
const fs = require('fs')
const fse = require('fs-extra')
```
**NOTE:** The deprecated constants `fs.F_OK`, `fs.R_OK`, `fs.W_OK`, & `fs.X_OK` are not exported on Node.js v24.0.0+; please use their `fs.constants` equivalents.
### ESM
There is also an `fs-extra/esm` import, that supports both default and named exports. However, note that `fs` methods are not included in `fs-extra/esm`; you still need to import `fs` and/or `fs/promises` seperately:
```js
import { readFileSync } from 'fs'
import { readFile } from 'fs/promises'
import { outputFile, outputFileSync } from 'fs-extra/esm'
```
Default exports are supported:
```js
import fs from 'fs'
import fse from 'fs-extra/esm'
// fse.readFileSync is not a function; must use fs.readFileSync
```
but you probably want to just use regular `fs-extra` instead of `fs-extra/esm` for default exports:
```js
import fs from 'fs-extra'
// both fs and fs-extra methods are defined
```
Sync vs Async vs Async/Await
-------------
Most methods are async by default. All async methods will return a promise if the callback isn't passed.
Sync methods on the other hand will throw if an error occurs.
Also Async/Await will throw an error if one occurs.
Example:
```js
const fs = require('fs-extra')
// Async with promises:
fs.copy('/tmp/myfile', '/tmp/mynewfile')
.then(() => console.log('success!'))
.catch(err => console.error(err))
// Async with callbacks:
fs.copy('/tmp/myfile', '/tmp/mynewfile', err => {
if (err) return console.error(err)
console.log('success!')
})
// Sync:
try {
fs.copySync('/tmp/myfile', '/tmp/mynewfile')
console.log('success!')
} catch (err) {
console.error(err)
}
// Async/Await:
async function copyFiles () {
try {
await fs.copy('/tmp/myfile', '/tmp/mynewfile')
console.log('success!')
} catch (err) {
console.error(err)
}
}
copyFiles()
```
Methods
-------
### Async
- [copy](docs/copy.md)
- [emptyDir](docs/emptyDir.md)
- [ensureFile](docs/ensureFile.md)
- [ensureDir](docs/ensureDir.md)
- [ensureLink](docs/ensureLink.md)
- [ensureSymlink](docs/ensureSymlink.md)
- [mkdirp](docs/ensureDir.md)
- [mkdirs](docs/ensureDir.md)
- [move](docs/move.md)
- [outputFile](docs/outputFile.md)
- [outputJson](docs/outputJson.md)
- [pathExists](docs/pathExists.md)
- [readJson](docs/readJson.md)
- [remove](docs/remove.md)
- [writeJson](docs/writeJson.md)
### Sync
- [copySync](docs/copy-sync.md)
- [emptyDirSync](docs/emptyDir-sync.md)
- [ensureFileSync](docs/ensureFile-sync.md)
- [ensureDirSync](docs/ensureDir-sync.md)
- [ensureLinkSync](docs/ensureLink-sync.md)
- [ensureSymlinkSync](docs/ensureSymlink-sync.md)
- [mkdirpSync](docs/ensureDir-sync.md)
- [mkdirsSync](docs/ensureDir-sync.md)
- [moveSync](docs/move-sync.md)
- [outputFileSync](docs/outputFile-sync.md)
- [outputJsonSync](docs/outputJson-sync.md)
- [pathExistsSync](docs/pathExists-sync.md)
- [readJsonSync](docs/readJson-sync.md)
- [removeSync](docs/remove-sync.md)
- [writeJsonSync](docs/writeJson-sync.md)
**NOTE:** You can still use the native Node.js methods. They are promisified and copied over to `fs-extra`. See [notes on `fs.read()`, `fs.write()`, & `fs.writev()`](docs/fs-read-write-writev.md)
### What happened to `walk()` and `walkSync()`?
They were removed from `fs-extra` in v2.0.0. If you need the functionality, `walk` and `walkSync` are available as separate packages, [`klaw`](https://github.com/jprichardson/node-klaw) and [`klaw-sync`](https://github.com/manidlou/node-klaw-sync).
Third Party
-----------
### CLI
[fse-cli](https://www.npmjs.com/package/@atao60/fse-cli) allows you to run `fs-extra` from a console or from [npm](https://www.npmjs.com) scripts.
### TypeScript
If you like TypeScript, you can use `fs-extra` with it: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/fs-extra
### File / Directory Watching
If you want to watch for changes to files or directories, then you should use [chokidar](https://github.com/paulmillr/chokidar).
### Obtain Filesystem (Devices, Partitions) Information
[fs-filesystem](https://github.com/arthurintelligence/node-fs-filesystem) allows you to read the state of the filesystem of the host on which it is run. It returns information about both the devices and the partitions (volumes) of the system.
### Misc.
- [fs-extra-debug](https://github.com/jdxcode/fs-extra-debug) - Send your fs-extra calls to [debug](https://npmjs.org/package/debug).
- [mfs](https://github.com/cadorn/mfs) - Monitor your fs-extra calls.
Hacking on fs-extra
-------------------
Wanna hack on `fs-extra`? Great! Your help is needed! [fs-extra is one of the most depended upon Node.js packages](http://nodei.co/npm/fs-extra.png?downloads=true&downloadRank=true&stars=true). This project
uses [JavaScript Standard Style](https://github.com/feross/standard) - if the name or style choices bother you,
you're gonna have to get over it :) If `standard` is good enough for `npm`, it's good enough for `fs-extra`.
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
What's needed?
- First, take a look at existing issues. Those are probably going to be where the priority lies.
- More tests for edge cases. Specifically on different platforms. There can never be enough tests.
- Improve test coverage.
Note: If you make any big changes, **you should definitely file an issue for discussion first.**
### Running the Test Suite
fs-extra contains hundreds of tests.
- `npm run lint`: runs the linter ([standard](http://standardjs.com/))
- `npm run unit`: runs the unit tests
- `npm run unit-esm`: runs tests for `fs-extra/esm` exports
- `npm test`: runs the linter and all tests
When running unit tests, set the environment variable `CROSS_DEVICE_PATH` to the absolute path of an empty directory on another device (like a thumb drive) to enable cross-device move tests.
### Windows
If you run the tests on the Windows and receive a lot of symbolic link `EPERM` permission errors, it's
because on Windows you need elevated privilege to create symbolic links. You can add this to your Windows's
account by following the instructions here: http://superuser.com/questions/104845/permission-to-make-symbolic-links-in-windows-7
However, I didn't have much luck doing this.
Since I develop on Mac OS X, I use VMWare Fusion for Windows testing. I create a shared folder that I map to a drive on Windows.
I open the `Node.js command prompt` and run as `Administrator`. I then map the network drive running the following command:
net use z: "\\vmware-host\Shared Folders"
I can then navigate to my `fs-extra` directory and run the tests.
Naming
------
I put a lot of thought into the naming of these functions. Inspired by @coolaj86's request. So he deserves much of the credit for raising the issue. See discussion(s) here:
* https://github.com/jprichardson/node-fs-extra/issues/2
* https://github.com/flatiron/utile/issues/11
* https://github.com/ryanmcgrath/wrench-js/issues/29
* https://github.com/substack/node-mkdirp/issues/17
First, I believe that in as many cases as possible, the [Node.js naming schemes](http://nodejs.org/api/fs.html) should be chosen. However, there are problems with the Node.js own naming schemes.
For example, `fs.readFile()` and `fs.readdir()`: the **F** is capitalized in *File* and the **d** is not capitalized in *dir*. Perhaps a bit pedantic, but they should still be consistent. Also, Node.js has chosen a lot of POSIX naming schemes, which I believe is great. See: `fs.mkdir()`, `fs.rmdir()`, `fs.chown()`, etc.
We have a dilemma though. How do you consistently name methods that perform the following POSIX commands: `cp`, `cp -r`, `mkdir -p`, and `rm -rf`?
My perspective: when in doubt, err on the side of simplicity. A directory is just a hierarchical grouping of directories and files. Consider that for a moment. So when you want to copy it or remove it, in most cases you'll want to copy or remove all of its contents. When you want to create a directory, if the directory that it's suppose to be contained in does not exist, then in most cases you'll want to create that too.
So, if you want to remove a file or a directory regardless of whether it has contents, just call `fs.remove(path)`. If you want to copy a file or a directory whether it has contents, just call `fs.copy(source, destination)`. If you want to create a directory regardless of whether its parent directories exist, just call `fs.mkdirs(path)` or `fs.mkdirp(path)`.
Credit
------
`fs-extra` wouldn't be possible without using the modules from the following authors:
- [Isaac Shlueter](https://github.com/isaacs)
- [Charlie McConnel](https://github.com/avianflu)
- [James Halliday](https://github.com/substack)
- [Andrew Kelley](https://github.com/andrewrk)
License
-------
Licensed under MIT
Copyright (c) 2011-2024 [JP Richardson](https://github.com/jprichardson)
[1]: http://nodejs.org/docs/latest/api/fs.html
[jsonfile]: https://github.com/jprichardson/node-jsonfile

View file

@ -0,0 +1,176 @@
'use strict'
const fs = require('graceful-fs')
const path = require('path')
const mkdirsSync = require('../mkdirs').mkdirsSync
const utimesMillisSync = require('../util/utimes').utimesMillisSync
const stat = require('../util/stat')
function copySync (src, dest, opts) {
if (typeof opts === 'function') {
opts = { filter: opts }
}
opts = opts || {}
opts.clobber = 'clobber' in opts ? !!opts.clobber : true // default to true for now
opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber // overwrite falls back to clobber
// Warn about using preserveTimestamps on 32-bit node
if (opts.preserveTimestamps && process.arch === 'ia32') {
process.emitWarning(
'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
'\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
'Warning', 'fs-extra-WARN0002'
)
}
const { srcStat, destStat } = stat.checkPathsSync(src, dest, 'copy', opts)
stat.checkParentPathsSync(src, srcStat, dest, 'copy')
if (opts.filter && !opts.filter(src, dest)) return
const destParent = path.dirname(dest)
if (!fs.existsSync(destParent)) mkdirsSync(destParent)
return getStats(destStat, src, dest, opts)
}
function getStats (destStat, src, dest, opts) {
const statSync = opts.dereference ? fs.statSync : fs.lstatSync
const srcStat = statSync(src)
if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts)
else if (srcStat.isFile() ||
srcStat.isCharacterDevice() ||
srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts)
else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts)
else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
throw new Error(`Unknown file: ${src}`)
}
function onFile (srcStat, destStat, src, dest, opts) {
if (!destStat) return copyFile(srcStat, src, dest, opts)
return mayCopyFile(srcStat, src, dest, opts)
}
function mayCopyFile (srcStat, src, dest, opts) {
if (opts.overwrite) {
fs.unlinkSync(dest)
return copyFile(srcStat, src, dest, opts)
} else if (opts.errorOnExist) {
throw new Error(`'${dest}' already exists`)
}
}
function copyFile (srcStat, src, dest, opts) {
fs.copyFileSync(src, dest)
if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest)
return setDestMode(dest, srcStat.mode)
}
function handleTimestamps (srcMode, src, dest) {
// Make sure the file is writable before setting the timestamp
// otherwise open fails with EPERM when invoked with 'r+'
// (through utimes call)
if (fileIsNotWritable(srcMode)) makeFileWritable(dest, srcMode)
return setDestTimestamps(src, dest)
}
function fileIsNotWritable (srcMode) {
return (srcMode & 0o200) === 0
}
function makeFileWritable (dest, srcMode) {
return setDestMode(dest, srcMode | 0o200)
}
function setDestMode (dest, srcMode) {
return fs.chmodSync(dest, srcMode)
}
function setDestTimestamps (src, dest) {
// The initial srcStat.atime cannot be trusted
// because it is modified by the read(2) system call
// (See https://nodejs.org/api/fs.html#fs_stat_time_values)
const updatedSrcStat = fs.statSync(src)
return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime)
}
function onDir (srcStat, destStat, src, dest, opts) {
if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts)
return copyDir(src, dest, opts)
}
function mkDirAndCopy (srcMode, src, dest, opts) {
fs.mkdirSync(dest)
copyDir(src, dest, opts)
return setDestMode(dest, srcMode)
}
function copyDir (src, dest, opts) {
const dir = fs.opendirSync(src)
try {
let dirent
while ((dirent = dir.readSync()) !== null) {
copyDirItem(dirent.name, src, dest, opts)
}
} finally {
dir.closeSync()
}
}
function copyDirItem (item, src, dest, opts) {
const srcItem = path.join(src, item)
const destItem = path.join(dest, item)
if (opts.filter && !opts.filter(srcItem, destItem)) return
const { destStat } = stat.checkPathsSync(srcItem, destItem, 'copy', opts)
return getStats(destStat, srcItem, destItem, opts)
}
function onLink (destStat, src, dest, opts) {
let resolvedSrc = fs.readlinkSync(src)
if (opts.dereference) {
resolvedSrc = path.resolve(process.cwd(), resolvedSrc)
}
if (!destStat) {
return fs.symlinkSync(resolvedSrc, dest)
} else {
let resolvedDest
try {
resolvedDest = fs.readlinkSync(dest)
} catch (err) {
// dest exists and is a regular file or directory,
// Windows may throw UNKNOWN error. If dest already exists,
// fs throws error anyway, so no need to guard against it here.
if (err.code === 'EINVAL' || err.code === 'UNKNOWN') return fs.symlinkSync(resolvedSrc, dest)
throw err
}
if (opts.dereference) {
resolvedDest = path.resolve(process.cwd(), resolvedDest)
}
// If both symlinks resolve to the same target, they are still distinct symlinks
// that can be copied/overwritten. Only check subdirectory constraints when
// the resolved paths are different.
if (resolvedSrc !== resolvedDest) {
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
}
// prevent copy if src is a subdir of dest since unlinking
// dest in this case would result in removing src contents
// and therefore a broken symlink would be created.
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
}
}
return copyLink(resolvedSrc, dest)
}
}
function copyLink (resolvedSrc, dest) {
fs.unlinkSync(dest)
return fs.symlinkSync(resolvedSrc, dest)
}
module.exports = copySync

View file

@ -0,0 +1,180 @@
'use strict'
const fs = require('../fs')
const path = require('path')
const { mkdirs } = require('../mkdirs')
const { pathExists } = require('../path-exists')
const { utimesMillis } = require('../util/utimes')
const stat = require('../util/stat')
const { asyncIteratorConcurrentProcess } = require('../util/async')
async function copy (src, dest, opts = {}) {
if (typeof opts === 'function') {
opts = { filter: opts }
}
opts.clobber = 'clobber' in opts ? !!opts.clobber : true // default to true for now
opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber // overwrite falls back to clobber
// Warn about using preserveTimestamps on 32-bit node
if (opts.preserveTimestamps && process.arch === 'ia32') {
process.emitWarning(
'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
'\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
'Warning', 'fs-extra-WARN0001'
)
}
const { srcStat, destStat } = await stat.checkPaths(src, dest, 'copy', opts)
await stat.checkParentPaths(src, srcStat, dest, 'copy')
const include = await runFilter(src, dest, opts)
if (!include) return
// check if the parent of dest exists, and create it if it doesn't exist
const destParent = path.dirname(dest)
const dirExists = await pathExists(destParent)
if (!dirExists) {
await mkdirs(destParent)
}
await getStatsAndPerformCopy(destStat, src, dest, opts)
}
async function runFilter (src, dest, opts) {
if (!opts.filter) return true
return opts.filter(src, dest)
}
async function getStatsAndPerformCopy (destStat, src, dest, opts) {
const statFn = opts.dereference ? fs.stat : fs.lstat
const srcStat = await statFn(src)
if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts)
if (
srcStat.isFile() ||
srcStat.isCharacterDevice() ||
srcStat.isBlockDevice()
) return onFile(srcStat, destStat, src, dest, opts)
if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts)
if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
throw new Error(`Unknown file: ${src}`)
}
async function onFile (srcStat, destStat, src, dest, opts) {
if (!destStat) return copyFile(srcStat, src, dest, opts)
if (opts.overwrite) {
await fs.unlink(dest)
return copyFile(srcStat, src, dest, opts)
}
if (opts.errorOnExist) {
throw new Error(`'${dest}' already exists`)
}
}
async function copyFile (srcStat, src, dest, opts) {
await fs.copyFile(src, dest)
if (opts.preserveTimestamps) {
// Make sure the file is writable before setting the timestamp
// otherwise open fails with EPERM when invoked with 'r+'
// (through utimes call)
if (fileIsNotWritable(srcStat.mode)) {
await makeFileWritable(dest, srcStat.mode)
}
// Set timestamps and mode correspondingly
// Note that The initial srcStat.atime cannot be trusted
// because it is modified by the read(2) system call
// (See https://nodejs.org/api/fs.html#fs_stat_time_values)
const updatedSrcStat = await fs.stat(src)
await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime)
}
return fs.chmod(dest, srcStat.mode)
}
function fileIsNotWritable (srcMode) {
return (srcMode & 0o200) === 0
}
function makeFileWritable (dest, srcMode) {
return fs.chmod(dest, srcMode | 0o200)
}
async function onDir (srcStat, destStat, src, dest, opts) {
// the dest directory might not exist, create it
if (!destStat) {
await fs.mkdir(dest)
}
// iterate through the files in the current directory to copy everything
await asyncIteratorConcurrentProcess(await fs.opendir(src), async (item) => {
const srcItem = path.join(src, item.name)
const destItem = path.join(dest, item.name)
const include = await runFilter(srcItem, destItem, opts)
// only copy the item if it matches the filter function
if (include) {
const { destStat } = await stat.checkPaths(srcItem, destItem, 'copy', opts)
// If the item is a copyable file, `getStatsAndPerformCopy` will copy it
// If the item is a directory, `getStatsAndPerformCopy` will call `onDir` recursively
await getStatsAndPerformCopy(destStat, srcItem, destItem, opts)
}
})
if (!destStat) {
await fs.chmod(dest, srcStat.mode)
}
}
async function onLink (destStat, src, dest, opts) {
let resolvedSrc = await fs.readlink(src)
if (opts.dereference) {
resolvedSrc = path.resolve(process.cwd(), resolvedSrc)
}
if (!destStat) {
return fs.symlink(resolvedSrc, dest)
}
let resolvedDest = null
try {
resolvedDest = await fs.readlink(dest)
} catch (e) {
// dest exists and is a regular file or directory,
// Windows may throw UNKNOWN error. If dest already exists,
// fs throws error anyway, so no need to guard against it here.
if (e.code === 'EINVAL' || e.code === 'UNKNOWN') return fs.symlink(resolvedSrc, dest)
throw e
}
if (opts.dereference) {
resolvedDest = path.resolve(process.cwd(), resolvedDest)
}
// If both symlinks resolve to the same target, they are still distinct symlinks
// that can be copied/overwritten. Only check subdirectory constraints when
// the resolved paths are different.
if (resolvedSrc !== resolvedDest) {
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
}
// do not copy if src is a subdir of dest since unlinking
// dest in this case would result in removing src contents
// and therefore a broken symlink would be created.
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
}
}
// copy the link
await fs.unlink(dest)
return fs.symlink(resolvedSrc, dest)
}
module.exports = copy

View file

@ -0,0 +1,7 @@
'use strict'
const u = require('universalify').fromPromise
module.exports = {
copy: u(require('./copy')),
copySync: require('./copy-sync')
}

View file

@ -0,0 +1,39 @@
'use strict'
const u = require('universalify').fromPromise
const fs = require('../fs')
const path = require('path')
const mkdir = require('../mkdirs')
const remove = require('../remove')
const emptyDir = u(async function emptyDir (dir) {
let items
try {
items = await fs.readdir(dir)
} catch {
return mkdir.mkdirs(dir)
}
return Promise.all(items.map(item => remove.remove(path.join(dir, item))))
})
function emptyDirSync (dir) {
let items
try {
items = fs.readdirSync(dir)
} catch {
return mkdir.mkdirsSync(dir)
}
items.forEach(item => {
item = path.join(dir, item)
remove.removeSync(item)
})
}
module.exports = {
emptyDirSync,
emptydirSync: emptyDirSync,
emptyDir,
emptydir: emptyDir
}

View file

@ -0,0 +1,66 @@
'use strict'
const u = require('universalify').fromPromise
const path = require('path')
const fs = require('../fs')
const mkdir = require('../mkdirs')
async function createFile (file) {
let stats
try {
stats = await fs.stat(file)
} catch { }
if (stats && stats.isFile()) return
const dir = path.dirname(file)
let dirStats = null
try {
dirStats = await fs.stat(dir)
} catch (err) {
// if the directory doesn't exist, make it
if (err.code === 'ENOENT') {
await mkdir.mkdirs(dir)
await fs.writeFile(file, '')
return
} else {
throw err
}
}
if (dirStats.isDirectory()) {
await fs.writeFile(file, '')
} else {
// parent is not a directory
// This is just to cause an internal ENOTDIR error to be thrown
await fs.readdir(dir)
}
}
function createFileSync (file) {
let stats
try {
stats = fs.statSync(file)
} catch { }
if (stats && stats.isFile()) return
const dir = path.dirname(file)
try {
if (!fs.statSync(dir).isDirectory()) {
// parent is not a directory
// This is just to cause an internal ENOTDIR error to be thrown
fs.readdirSync(dir)
}
} catch (err) {
// If the stat call above failed because the directory doesn't exist, create it
if (err && err.code === 'ENOENT') mkdir.mkdirsSync(dir)
else throw err
}
fs.writeFileSync(file, '')
}
module.exports = {
createFile: u(createFile),
createFileSync
}

View file

@ -0,0 +1,23 @@
'use strict'
const { createFile, createFileSync } = require('./file')
const { createLink, createLinkSync } = require('./link')
const { createSymlink, createSymlinkSync } = require('./symlink')
module.exports = {
// file
createFile,
createFileSync,
ensureFile: createFile,
ensureFileSync: createFileSync,
// link
createLink,
createLinkSync,
ensureLink: createLink,
ensureLinkSync: createLinkSync,
// symlink
createSymlink,
createSymlinkSync,
ensureSymlink: createSymlink,
ensureSymlinkSync: createSymlinkSync
}

View file

@ -0,0 +1,64 @@
'use strict'
const u = require('universalify').fromPromise
const path = require('path')
const fs = require('../fs')
const mkdir = require('../mkdirs')
const { pathExists } = require('../path-exists')
const { areIdentical } = require('../util/stat')
async function createLink (srcpath, dstpath) {
let dstStat
try {
dstStat = await fs.lstat(dstpath)
} catch {
// ignore error
}
let srcStat
try {
srcStat = await fs.lstat(srcpath)
} catch (err) {
err.message = err.message.replace('lstat', 'ensureLink')
throw err
}
if (dstStat && areIdentical(srcStat, dstStat)) return
const dir = path.dirname(dstpath)
const dirExists = await pathExists(dir)
if (!dirExists) {
await mkdir.mkdirs(dir)
}
await fs.link(srcpath, dstpath)
}
function createLinkSync (srcpath, dstpath) {
let dstStat
try {
dstStat = fs.lstatSync(dstpath)
} catch {}
try {
const srcStat = fs.lstatSync(srcpath)
if (dstStat && areIdentical(srcStat, dstStat)) return
} catch (err) {
err.message = err.message.replace('lstat', 'ensureLink')
throw err
}
const dir = path.dirname(dstpath)
const dirExists = fs.existsSync(dir)
if (dirExists) return fs.linkSync(srcpath, dstpath)
mkdir.mkdirsSync(dir)
return fs.linkSync(srcpath, dstpath)
}
module.exports = {
createLink: u(createLink),
createLinkSync
}

View file

@ -0,0 +1,101 @@
'use strict'
const path = require('path')
const fs = require('../fs')
const { pathExists } = require('../path-exists')
const u = require('universalify').fromPromise
/**
* Function that returns two types of paths, one relative to symlink, and one
* relative to the current working directory. Checks if path is absolute or
* relative. If the path is relative, this function checks if the path is
* relative to symlink or relative to current working directory. This is an
* initiative to find a smarter `srcpath` to supply when building symlinks.
* This allows you to determine which path to use out of one of three possible
* types of source paths. The first is an absolute path. This is detected by
* `path.isAbsolute()`. When an absolute path is provided, it is checked to
* see if it exists. If it does it's used, if not an error is returned
* (callback)/ thrown (sync). The other two options for `srcpath` are a
* relative url. By default Node's `fs.symlink` works by creating a symlink
* using `dstpath` and expects the `srcpath` to be relative to the newly
* created symlink. If you provide a `srcpath` that does not exist on the file
* system it results in a broken symlink. To minimize this, the function
* checks to see if the 'relative to symlink' source file exists, and if it
* does it will use it. If it does not, it checks if there's a file that
* exists that is relative to the current working directory, if does its used.
* This preserves the expectations of the original fs.symlink spec and adds
* the ability to pass in `relative to current working direcotry` paths.
*/
async function symlinkPaths (srcpath, dstpath) {
if (path.isAbsolute(srcpath)) {
try {
await fs.lstat(srcpath)
} catch (err) {
err.message = err.message.replace('lstat', 'ensureSymlink')
throw err
}
return {
toCwd: srcpath,
toDst: srcpath
}
}
const dstdir = path.dirname(dstpath)
const relativeToDst = path.join(dstdir, srcpath)
const exists = await pathExists(relativeToDst)
if (exists) {
return {
toCwd: relativeToDst,
toDst: srcpath
}
}
try {
await fs.lstat(srcpath)
} catch (err) {
err.message = err.message.replace('lstat', 'ensureSymlink')
throw err
}
return {
toCwd: srcpath,
toDst: path.relative(dstdir, srcpath)
}
}
function symlinkPathsSync (srcpath, dstpath) {
if (path.isAbsolute(srcpath)) {
const exists = fs.existsSync(srcpath)
if (!exists) throw new Error('absolute srcpath does not exist')
return {
toCwd: srcpath,
toDst: srcpath
}
}
const dstdir = path.dirname(dstpath)
const relativeToDst = path.join(dstdir, srcpath)
const exists = fs.existsSync(relativeToDst)
if (exists) {
return {
toCwd: relativeToDst,
toDst: srcpath
}
}
const srcExists = fs.existsSync(srcpath)
if (!srcExists) throw new Error('relative srcpath does not exist')
return {
toCwd: srcpath,
toDst: path.relative(dstdir, srcpath)
}
}
module.exports = {
symlinkPaths: u(symlinkPaths),
symlinkPathsSync
}

View file

@ -0,0 +1,34 @@
'use strict'
const fs = require('../fs')
const u = require('universalify').fromPromise
async function symlinkType (srcpath, type) {
if (type) return type
let stats
try {
stats = await fs.lstat(srcpath)
} catch {
return 'file'
}
return (stats && stats.isDirectory()) ? 'dir' : 'file'
}
function symlinkTypeSync (srcpath, type) {
if (type) return type
let stats
try {
stats = fs.lstatSync(srcpath)
} catch {
return 'file'
}
return (stats && stats.isDirectory()) ? 'dir' : 'file'
}
module.exports = {
symlinkType: u(symlinkType),
symlinkTypeSync
}

View file

@ -0,0 +1,92 @@
'use strict'
const u = require('universalify').fromPromise
const path = require('path')
const fs = require('../fs')
const { mkdirs, mkdirsSync } = require('../mkdirs')
const { symlinkPaths, symlinkPathsSync } = require('./symlink-paths')
const { symlinkType, symlinkTypeSync } = require('./symlink-type')
const { pathExists } = require('../path-exists')
const { areIdentical } = require('../util/stat')
async function createSymlink (srcpath, dstpath, type) {
let stats
try {
stats = await fs.lstat(dstpath)
} catch { }
if (stats && stats.isSymbolicLink()) {
// When srcpath is relative, resolve it relative to dstpath's directory
// (standard symlink behavior) or fall back to cwd if that doesn't exist
let srcStat
if (path.isAbsolute(srcpath)) {
srcStat = await fs.stat(srcpath)
} else {
const dstdir = path.dirname(dstpath)
const relativeToDst = path.join(dstdir, srcpath)
try {
srcStat = await fs.stat(relativeToDst)
} catch {
srcStat = await fs.stat(srcpath)
}
}
const dstStat = await fs.stat(dstpath)
if (areIdentical(srcStat, dstStat)) return
}
const relative = await symlinkPaths(srcpath, dstpath)
srcpath = relative.toDst
const toType = await symlinkType(relative.toCwd, type)
const dir = path.dirname(dstpath)
if (!(await pathExists(dir))) {
await mkdirs(dir)
}
return fs.symlink(srcpath, dstpath, toType)
}
function createSymlinkSync (srcpath, dstpath, type) {
let stats
try {
stats = fs.lstatSync(dstpath)
} catch { }
if (stats && stats.isSymbolicLink()) {
// When srcpath is relative, resolve it relative to dstpath's directory
// (standard symlink behavior) or fall back to cwd if that doesn't exist
let srcStat
if (path.isAbsolute(srcpath)) {
srcStat = fs.statSync(srcpath)
} else {
const dstdir = path.dirname(dstpath)
const relativeToDst = path.join(dstdir, srcpath)
try {
srcStat = fs.statSync(relativeToDst)
} catch {
srcStat = fs.statSync(srcpath)
}
}
const dstStat = fs.statSync(dstpath)
if (areIdentical(srcStat, dstStat)) return
}
const relative = symlinkPathsSync(srcpath, dstpath)
srcpath = relative.toDst
type = symlinkTypeSync(relative.toCwd, type)
const dir = path.dirname(dstpath)
const exists = fs.existsSync(dir)
if (exists) return fs.symlinkSync(srcpath, dstpath, type)
mkdirsSync(dir)
return fs.symlinkSync(srcpath, dstpath, type)
}
module.exports = {
createSymlink: u(createSymlink),
createSymlinkSync
}

View file

@ -0,0 +1,68 @@
import _copy from './copy/index.js'
import _empty from './empty/index.js'
import _ensure from './ensure/index.js'
import _json from './json/index.js'
import _mkdirs from './mkdirs/index.js'
import _move from './move/index.js'
import _outputFile from './output-file/index.js'
import _pathExists from './path-exists/index.js'
import _remove from './remove/index.js'
// NOTE: Only exports fs-extra's functions; fs functions must be imported from "node:fs" or "node:fs/promises"
export const copy = _copy.copy
export const copySync = _copy.copySync
export const emptyDirSync = _empty.emptyDirSync
export const emptydirSync = _empty.emptydirSync
export const emptyDir = _empty.emptyDir
export const emptydir = _empty.emptydir
export const createFile = _ensure.createFile
export const createFileSync = _ensure.createFileSync
export const ensureFile = _ensure.ensureFile
export const ensureFileSync = _ensure.ensureFileSync
export const createLink = _ensure.createLink
export const createLinkSync = _ensure.createLinkSync
export const ensureLink = _ensure.ensureLink
export const ensureLinkSync = _ensure.ensureLinkSync
export const createSymlink = _ensure.createSymlink
export const createSymlinkSync = _ensure.createSymlinkSync
export const ensureSymlink = _ensure.ensureSymlink
export const ensureSymlinkSync = _ensure.ensureSymlinkSync
export const readJson = _json.readJson
export const readJSON = _json.readJSON
export const readJsonSync = _json.readJsonSync
export const readJSONSync = _json.readJSONSync
export const writeJson = _json.writeJson
export const writeJSON = _json.writeJSON
export const writeJsonSync = _json.writeJsonSync
export const writeJSONSync = _json.writeJSONSync
export const outputJson = _json.outputJson
export const outputJSON = _json.outputJSON
export const outputJsonSync = _json.outputJsonSync
export const outputJSONSync = _json.outputJSONSync
export const mkdirs = _mkdirs.mkdirs
export const mkdirsSync = _mkdirs.mkdirsSync
export const mkdirp = _mkdirs.mkdirp
export const mkdirpSync = _mkdirs.mkdirpSync
export const ensureDir = _mkdirs.ensureDir
export const ensureDirSync = _mkdirs.ensureDirSync
export const move = _move.move
export const moveSync = _move.moveSync
export const outputFile = _outputFile.outputFile
export const outputFileSync = _outputFile.outputFileSync
export const pathExists = _pathExists.pathExists
export const pathExistsSync = _pathExists.pathExistsSync
export const remove = _remove.remove
export const removeSync = _remove.removeSync
export default {
..._copy,
..._empty,
..._ensure,
..._json,
..._mkdirs,
..._move,
..._outputFile,
..._pathExists,
..._remove
}

View file

@ -0,0 +1,146 @@
'use strict'
// This is adapted from https://github.com/normalize/mz
// Copyright (c) 2014-2016 Jonathan Ong me@jongleberry.com and Contributors
const u = require('universalify').fromCallback
const fs = require('graceful-fs')
const api = [
'access',
'appendFile',
'chmod',
'chown',
'close',
'copyFile',
'cp',
'fchmod',
'fchown',
'fdatasync',
'fstat',
'fsync',
'ftruncate',
'futimes',
'glob',
'lchmod',
'lchown',
'lutimes',
'link',
'lstat',
'mkdir',
'mkdtemp',
'open',
'opendir',
'readdir',
'readFile',
'readlink',
'realpath',
'rename',
'rm',
'rmdir',
'stat',
'statfs',
'symlink',
'truncate',
'unlink',
'utimes',
'writeFile'
].filter(key => {
// Some commands are not available on some systems. Ex:
// fs.cp was added in Node.js v16.7.0
// fs.statfs was added in Node v19.6.0, v18.15.0
// fs.glob was added in Node.js v22.0.0
// fs.lchown is not available on at least some Linux
return typeof fs[key] === 'function'
})
// Export cloned fs:
Object.assign(exports, fs)
// Universalify async methods:
api.forEach(method => {
exports[method] = u(fs[method])
})
// We differ from mz/fs in that we still ship the old, broken, fs.exists()
// since we are a drop-in replacement for the native module
exports.exists = function (filename, callback) {
if (typeof callback === 'function') {
return fs.exists(filename, callback)
}
return new Promise(resolve => {
return fs.exists(filename, resolve)
})
}
// fs.read(), fs.write(), fs.readv(), & fs.writev() need special treatment due to multiple callback args
exports.read = function (fd, buffer, offset, length, position, callback) {
if (typeof callback === 'function') {
return fs.read(fd, buffer, offset, length, position, callback)
}
return new Promise((resolve, reject) => {
fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
if (err) return reject(err)
resolve({ bytesRead, buffer })
})
})
}
// Function signature can be
// fs.write(fd, buffer[, offset[, length[, position]]], callback)
// OR
// fs.write(fd, string[, position[, encoding]], callback)
// We need to handle both cases, so we use ...args
exports.write = function (fd, buffer, ...args) {
if (typeof args[args.length - 1] === 'function') {
return fs.write(fd, buffer, ...args)
}
return new Promise((resolve, reject) => {
fs.write(fd, buffer, ...args, (err, bytesWritten, buffer) => {
if (err) return reject(err)
resolve({ bytesWritten, buffer })
})
})
}
// Function signature is
// s.readv(fd, buffers[, position], callback)
// We need to handle the optional arg, so we use ...args
exports.readv = function (fd, buffers, ...args) {
if (typeof args[args.length - 1] === 'function') {
return fs.readv(fd, buffers, ...args)
}
return new Promise((resolve, reject) => {
fs.readv(fd, buffers, ...args, (err, bytesRead, buffers) => {
if (err) return reject(err)
resolve({ bytesRead, buffers })
})
})
}
// Function signature is
// s.writev(fd, buffers[, position], callback)
// We need to handle the optional arg, so we use ...args
exports.writev = function (fd, buffers, ...args) {
if (typeof args[args.length - 1] === 'function') {
return fs.writev(fd, buffers, ...args)
}
return new Promise((resolve, reject) => {
fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers) => {
if (err) return reject(err)
resolve({ bytesWritten, buffers })
})
})
}
// fs.realpath.native sometimes not available if fs is monkey-patched
if (typeof fs.realpath.native === 'function') {
exports.realpath.native = u(fs.realpath.native)
} else {
process.emitWarning(
'fs.realpath.native is not a function. Is fs being monkey-patched?',
'Warning', 'fs-extra-WARN0003'
)
}

View file

@ -0,0 +1,16 @@
'use strict'
module.exports = {
// Export promiseified graceful-fs:
...require('./fs'),
// Export extra methods:
...require('./copy'),
...require('./empty'),
...require('./ensure'),
...require('./json'),
...require('./mkdirs'),
...require('./move'),
...require('./output-file'),
...require('./path-exists'),
...require('./remove')
}

View file

@ -0,0 +1,16 @@
'use strict'
const u = require('universalify').fromPromise
const jsonFile = require('./jsonfile')
jsonFile.outputJson = u(require('./output-json'))
jsonFile.outputJsonSync = require('./output-json-sync')
// aliases
jsonFile.outputJSON = jsonFile.outputJson
jsonFile.outputJSONSync = jsonFile.outputJsonSync
jsonFile.writeJSON = jsonFile.writeJson
jsonFile.writeJSONSync = jsonFile.writeJsonSync
jsonFile.readJSON = jsonFile.readJson
jsonFile.readJSONSync = jsonFile.readJsonSync
module.exports = jsonFile

View file

@ -0,0 +1,11 @@
'use strict'
const jsonFile = require('jsonfile')
module.exports = {
// jsonfile exports
readJson: jsonFile.readFile,
readJsonSync: jsonFile.readFileSync,
writeJson: jsonFile.writeFile,
writeJsonSync: jsonFile.writeFileSync
}

View file

@ -0,0 +1,12 @@
'use strict'
const { stringify } = require('jsonfile/utils')
const { outputFileSync } = require('../output-file')
function outputJsonSync (file, data, options) {
const str = stringify(data, options)
outputFileSync(file, str, options)
}
module.exports = outputJsonSync

View file

@ -0,0 +1,12 @@
'use strict'
const { stringify } = require('jsonfile/utils')
const { outputFile } = require('../output-file')
async function outputJson (file, data, options = {}) {
const str = stringify(data, options)
await outputFile(file, str, options)
}
module.exports = outputJson

View file

@ -0,0 +1,14 @@
'use strict'
const u = require('universalify').fromPromise
const { makeDir: _makeDir, makeDirSync } = require('./make-dir')
const makeDir = u(_makeDir)
module.exports = {
mkdirs: makeDir,
mkdirsSync: makeDirSync,
// alias
mkdirp: makeDir,
mkdirpSync: makeDirSync,
ensureDir: makeDir,
ensureDirSync: makeDirSync
}

View file

@ -0,0 +1,27 @@
'use strict'
const fs = require('../fs')
const { checkPath } = require('./utils')
const getMode = options => {
const defaults = { mode: 0o777 }
if (typeof options === 'number') return options
return ({ ...defaults, ...options }).mode
}
module.exports.makeDir = async (dir, options) => {
checkPath(dir)
return fs.mkdir(dir, {
mode: getMode(options),
recursive: true
})
}
module.exports.makeDirSync = (dir, options) => {
checkPath(dir)
return fs.mkdirSync(dir, {
mode: getMode(options),
recursive: true
})
}

View file

@ -0,0 +1,21 @@
// Adapted from https://github.com/sindresorhus/make-dir
// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict'
const path = require('path')
// https://github.com/nodejs/node/issues/8987
// https://github.com/libuv/libuv/pull/1088
module.exports.checkPath = function checkPath (pth) {
if (process.platform === 'win32') {
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''))
if (pathHasInvalidWinCharacters) {
const error = new Error(`Path contains invalid characters: ${pth}`)
error.code = 'EINVAL'
throw error
}
}
}

View file

@ -0,0 +1,7 @@
'use strict'
const u = require('universalify').fromPromise
module.exports = {
move: u(require('./move')),
moveSync: require('./move-sync')
}

View file

@ -0,0 +1,55 @@
'use strict'
const fs = require('graceful-fs')
const path = require('path')
const copySync = require('../copy').copySync
const removeSync = require('../remove').removeSync
const mkdirpSync = require('../mkdirs').mkdirpSync
const stat = require('../util/stat')
function moveSync (src, dest, opts) {
opts = opts || {}
const overwrite = opts.overwrite || opts.clobber || false
const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, 'move', opts)
stat.checkParentPathsSync(src, srcStat, dest, 'move')
if (!isParentRoot(dest)) mkdirpSync(path.dirname(dest))
return doRename(src, dest, overwrite, isChangingCase)
}
function isParentRoot (dest) {
const parent = path.dirname(dest)
const parsedPath = path.parse(parent)
return parsedPath.root === parent
}
function doRename (src, dest, overwrite, isChangingCase) {
if (isChangingCase) return rename(src, dest, overwrite)
if (overwrite) {
removeSync(dest)
return rename(src, dest, overwrite)
}
if (fs.existsSync(dest)) throw new Error('dest already exists.')
return rename(src, dest, overwrite)
}
function rename (src, dest, overwrite) {
try {
fs.renameSync(src, dest)
} catch (err) {
if (err.code !== 'EXDEV') throw err
return moveAcrossDevice(src, dest, overwrite)
}
}
function moveAcrossDevice (src, dest, overwrite) {
const opts = {
overwrite,
errorOnExist: true,
preserveTimestamps: true
}
copySync(src, dest, opts)
return removeSync(src)
}
module.exports = moveSync

View file

@ -0,0 +1,59 @@
'use strict'
const fs = require('../fs')
const path = require('path')
const { copy } = require('../copy')
const { remove } = require('../remove')
const { mkdirp } = require('../mkdirs')
const { pathExists } = require('../path-exists')
const stat = require('../util/stat')
async function move (src, dest, opts = {}) {
const overwrite = opts.overwrite || opts.clobber || false
const { srcStat, isChangingCase = false } = await stat.checkPaths(src, dest, 'move', opts)
await stat.checkParentPaths(src, srcStat, dest, 'move')
// If the parent of dest is not root, make sure it exists before proceeding
const destParent = path.dirname(dest)
const parsedParentPath = path.parse(destParent)
if (parsedParentPath.root !== destParent) {
await mkdirp(destParent)
}
return doRename(src, dest, overwrite, isChangingCase)
}
async function doRename (src, dest, overwrite, isChangingCase) {
if (!isChangingCase) {
if (overwrite) {
await remove(dest)
} else if (await pathExists(dest)) {
throw new Error('dest already exists.')
}
}
try {
// Try w/ rename first, and try copy + remove if EXDEV
await fs.rename(src, dest)
} catch (err) {
if (err.code !== 'EXDEV') {
throw err
}
await moveAcrossDevice(src, dest, overwrite)
}
}
async function moveAcrossDevice (src, dest, overwrite) {
const opts = {
overwrite,
errorOnExist: true,
preserveTimestamps: true
}
await copy(src, dest, opts)
return remove(src)
}
module.exports = move

View file

@ -0,0 +1,31 @@
'use strict'
const u = require('universalify').fromPromise
const fs = require('../fs')
const path = require('path')
const mkdir = require('../mkdirs')
const pathExists = require('../path-exists').pathExists
async function outputFile (file, data, encoding = 'utf-8') {
const dir = path.dirname(file)
if (!(await pathExists(dir))) {
await mkdir.mkdirs(dir)
}
return fs.writeFile(file, data, encoding)
}
function outputFileSync (file, ...args) {
const dir = path.dirname(file)
if (!fs.existsSync(dir)) {
mkdir.mkdirsSync(dir)
}
fs.writeFileSync(file, ...args)
}
module.exports = {
outputFile: u(outputFile),
outputFileSync
}

View file

@ -0,0 +1,12 @@
'use strict'
const u = require('universalify').fromPromise
const fs = require('../fs')
function pathExists (path) {
return fs.access(path).then(() => true).catch(() => false)
}
module.exports = {
pathExists: u(pathExists),
pathExistsSync: fs.existsSync
}

View file

@ -0,0 +1,17 @@
'use strict'
const fs = require('graceful-fs')
const u = require('universalify').fromCallback
function remove (path, callback) {
fs.rm(path, { recursive: true, force: true }, callback)
}
function removeSync (path) {
fs.rmSync(path, { recursive: true, force: true })
}
module.exports = {
remove: u(remove),
removeSync
}

View file

@ -0,0 +1,29 @@
'use strict'
// https://github.com/jprichardson/node-fs-extra/issues/1056
// Performing parallel operations on each item of an async iterator is
// surprisingly hard; you need to have handlers in place to avoid getting an
// UnhandledPromiseRejectionWarning.
// NOTE: This function does not presently handle return values, only errors
async function asyncIteratorConcurrentProcess (iterator, fn) {
const promises = []
for await (const item of iterator) {
promises.push(
fn(item).then(
() => null,
(err) => err ?? new Error('unknown error')
)
)
}
await Promise.all(
promises.map((promise) =>
promise.then((possibleErr) => {
if (possibleErr !== null) throw possibleErr
})
)
)
}
module.exports = {
asyncIteratorConcurrentProcess
}

View file

@ -0,0 +1,159 @@
'use strict'
const fs = require('../fs')
const path = require('path')
const u = require('universalify').fromPromise
function getStats (src, dest, opts) {
const statFunc = opts.dereference
? (file) => fs.stat(file, { bigint: true })
: (file) => fs.lstat(file, { bigint: true })
return Promise.all([
statFunc(src),
statFunc(dest).catch(err => {
if (err.code === 'ENOENT') return null
throw err
})
]).then(([srcStat, destStat]) => ({ srcStat, destStat }))
}
function getStatsSync (src, dest, opts) {
let destStat
const statFunc = opts.dereference
? (file) => fs.statSync(file, { bigint: true })
: (file) => fs.lstatSync(file, { bigint: true })
const srcStat = statFunc(src)
try {
destStat = statFunc(dest)
} catch (err) {
if (err.code === 'ENOENT') return { srcStat, destStat: null }
throw err
}
return { srcStat, destStat }
}
async function checkPaths (src, dest, funcName, opts) {
const { srcStat, destStat } = await getStats(src, dest, opts)
if (destStat) {
if (areIdentical(srcStat, destStat)) {
const srcBaseName = path.basename(src)
const destBaseName = path.basename(dest)
if (funcName === 'move' &&
srcBaseName !== destBaseName &&
srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
return { srcStat, destStat, isChangingCase: true }
}
throw new Error('Source and destination must not be the same.')
}
if (srcStat.isDirectory() && !destStat.isDirectory()) {
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
}
if (!srcStat.isDirectory() && destStat.isDirectory()) {
throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
}
}
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
throw new Error(errMsg(src, dest, funcName))
}
return { srcStat, destStat }
}
function checkPathsSync (src, dest, funcName, opts) {
const { srcStat, destStat } = getStatsSync(src, dest, opts)
if (destStat) {
if (areIdentical(srcStat, destStat)) {
const srcBaseName = path.basename(src)
const destBaseName = path.basename(dest)
if (funcName === 'move' &&
srcBaseName !== destBaseName &&
srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
return { srcStat, destStat, isChangingCase: true }
}
throw new Error('Source and destination must not be the same.')
}
if (srcStat.isDirectory() && !destStat.isDirectory()) {
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
}
if (!srcStat.isDirectory() && destStat.isDirectory()) {
throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
}
}
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
throw new Error(errMsg(src, dest, funcName))
}
return { srcStat, destStat }
}
// recursively check if dest parent is a subdirectory of src.
// It works for all file types including symlinks since it
// checks the src and dest inodes. It starts from the deepest
// parent and stops once it reaches the src parent or the root path.
async function checkParentPaths (src, srcStat, dest, funcName) {
const srcParent = path.resolve(path.dirname(src))
const destParent = path.resolve(path.dirname(dest))
if (destParent === srcParent || destParent === path.parse(destParent).root) return
let destStat
try {
destStat = await fs.stat(destParent, { bigint: true })
} catch (err) {
if (err.code === 'ENOENT') return
throw err
}
if (areIdentical(srcStat, destStat)) {
throw new Error(errMsg(src, dest, funcName))
}
return checkParentPaths(src, srcStat, destParent, funcName)
}
function checkParentPathsSync (src, srcStat, dest, funcName) {
const srcParent = path.resolve(path.dirname(src))
const destParent = path.resolve(path.dirname(dest))
if (destParent === srcParent || destParent === path.parse(destParent).root) return
let destStat
try {
destStat = fs.statSync(destParent, { bigint: true })
} catch (err) {
if (err.code === 'ENOENT') return
throw err
}
if (areIdentical(srcStat, destStat)) {
throw new Error(errMsg(src, dest, funcName))
}
return checkParentPathsSync(src, srcStat, destParent, funcName)
}
function areIdentical (srcStat, destStat) {
// stat.dev can be 0n on windows when node version >= 22.x.x
return destStat.ino !== undefined && destStat.dev !== undefined && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev
}
// return true if dest is a subdir of src, otherwise false.
// It only checks the path strings.
function isSrcSubdir (src, dest) {
const srcArr = path.resolve(src).split(path.sep).filter(i => i)
const destArr = path.resolve(dest).split(path.sep).filter(i => i)
return srcArr.every((cur, i) => destArr[i] === cur)
}
function errMsg (src, dest, funcName) {
return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`
}
module.exports = {
// checkPaths
checkPaths: u(checkPaths),
checkPathsSync,
// checkParent
checkParentPaths: u(checkParentPaths),
checkParentPathsSync,
// Misc
isSrcSubdir,
areIdentical
}

View file

@ -0,0 +1,36 @@
'use strict'
const fs = require('../fs')
const u = require('universalify').fromPromise
async function utimesMillis (path, atime, mtime) {
// if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
const fd = await fs.open(path, 'r+')
let closeErr = null
try {
await fs.futimes(fd, atime, mtime)
} finally {
try {
await fs.close(fd)
} catch (e) {
closeErr = e
}
}
if (closeErr) {
throw closeErr
}
}
function utimesMillisSync (path, atime, mtime) {
const fd = fs.openSync(path, 'r+')
fs.futimesSync(fd, atime, mtime)
return fs.closeSync(fd)
}
module.exports = {
utimesMillis: u(utimesMillis),
utimesMillisSync
}

View file

@ -0,0 +1,71 @@
{
"name": "fs-extra",
"version": "11.3.4",
"description": "fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.",
"engines": {
"node": ">=14.14"
},
"homepage": "https://github.com/jprichardson/node-fs-extra",
"repository": {
"type": "git",
"url": "git+https://github.com/jprichardson/node-fs-extra.git"
},
"keywords": [
"fs",
"file",
"file system",
"copy",
"directory",
"extra",
"mkdirp",
"mkdir",
"mkdirs",
"recursive",
"json",
"read",
"write",
"extra",
"delete",
"remove",
"touch",
"create",
"text",
"output",
"move",
"promise"
],
"author": "JP Richardson <jprichardson@gmail.com>",
"license": "MIT",
"dependencies": {
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
"universalify": "^2.0.0"
},
"devDependencies": {
"klaw": "^2.1.1",
"klaw-sync": "^3.0.2",
"minimist": "^1.1.1",
"mocha": "^10.1.0",
"nyc": "^15.0.0",
"proxyquire": "^2.0.1",
"read-dir-files": "^0.1.1",
"standard": "^17.0.0"
},
"main": "./lib/index.js",
"exports": {
".": "./lib/index.js",
"./esm": "./lib/esm.mjs"
},
"files": [
"lib/",
"!lib/**/__tests__/"
],
"scripts": {
"lint": "standard",
"test-find": "find ./lib/**/__tests__ -name *.test.js | xargs mocha",
"test": "npm run lint && npm run unit && npm run unit-esm",
"unit": "nyc node test.js",
"unit-esm": "node test.mjs"
},
"sideEffects": false
}

View file

@ -0,0 +1,15 @@
(The MIT License)
Copyright (c) 2012-2015, JP Richardson <jprichardson@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,230 @@
Node.js - jsonfile
================
Easily read/write JSON files in Node.js. _Note: this module cannot be used in the browser._
[![npm Package](https://img.shields.io/npm/v/jsonfile.svg?style=flat-square)](https://www.npmjs.org/package/jsonfile)
[![linux build status](https://img.shields.io/github/actions/workflow/status/jprichardson/node-jsonfile/ci.yml?branch=master)](https://github.com/jprichardson/node-jsonfile/actions?query=branch%3Amaster)
[![windows Build status](https://img.shields.io/appveyor/ci/jprichardson/node-jsonfile/master.svg?label=windows%20build)](https://ci.appveyor.com/project/jprichardson/node-jsonfile/branch/master)
<a href="https://github.com/feross/standard"><img src="https://cdn.rawgit.com/feross/standard/master/sticker.svg" alt="Standard JavaScript" width="100"></a>
Why?
----
Writing `JSON.stringify()` and then `fs.writeFile()` and `JSON.parse()` with `fs.readFile()` enclosed in `try/catch` blocks became annoying.
Installation
------------
npm install --save jsonfile
API
---
* [`readFile(filename, [options], callback)`](#readfilefilename-options-callback)
* [`readFileSync(filename, [options])`](#readfilesyncfilename-options)
* [`writeFile(filename, obj, [options], callback)`](#writefilefilename-obj-options-callback)
* [`writeFileSync(filename, obj, [options])`](#writefilesyncfilename-obj-options)
----
### readFile(filename, [options], callback)
`options` (`object`, default `undefined`): Pass in any [`fs.readFile`](https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback) options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
- `throws` (`boolean`, default: `true`). If `JSON.parse` throws an error, pass this error to the callback.
If `false`, returns `null` for the object.
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
jsonfile.readFile(file, function (err, obj) {
if (err) console.error(err)
console.dir(obj)
})
```
You can also use this method with promises. The `readFile` method will return a promise if you do not pass a callback function.
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
jsonfile.readFile(file)
.then(obj => console.dir(obj))
.catch(error => console.error(error))
```
----
### readFileSync(filename, [options])
`options` (`object`, default `undefined`): Pass in any [`fs.readFileSync`](https://nodejs.org/api/fs.html#fs_fs_readfilesync_path_options) options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
- `throws` (`boolean`, default: `true`). If an error is encountered reading or parsing the file, throw the error. If `false`, returns `null` for the object.
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
console.dir(jsonfile.readFileSync(file))
```
----
### writeFile(filename, obj, [options], callback)
`options`: Pass in any [`fs.writeFile`](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback) options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). Can also pass in `spaces`, or override `EOL` string or set `finalEOL` flag as `false` to not save the file with `EOL` at the end.
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
jsonfile.writeFile(file, obj, function (err) {
if (err) console.error(err)
})
```
Or use with promises as follows:
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
jsonfile.writeFile(file, obj)
.then(res => {
console.log('Write complete')
})
.catch(error => console.error(error))
```
**formatting with spaces:**
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
jsonfile.writeFile(file, obj, { spaces: 2 }, function (err) {
if (err) console.error(err)
})
```
**overriding EOL:**
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
jsonfile.writeFile(file, obj, { spaces: 2, EOL: '\r\n' }, function (err) {
if (err) console.error(err)
})
```
**disabling the EOL at the end of file:**
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
jsonfile.writeFile(file, obj, { spaces: 2, finalEOL: false }, function (err) {
if (err) console.log(err)
})
```
**appending to an existing JSON file:**
You can use `fs.writeFile` option `{ flag: 'a' }` to achieve this.
```js
const jsonfile = require('jsonfile')
const file = '/tmp/mayAlreadyExistedData.json'
const obj = { name: 'JP' }
jsonfile.writeFile(file, obj, { flag: 'a' }, function (err) {
if (err) console.error(err)
})
```
----
### writeFileSync(filename, obj, [options])
`options`: Pass in any [`fs.writeFileSync`](https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options) options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). Can also pass in `spaces`, or override `EOL` string or set `finalEOL` flag as `false` to not save the file with `EOL` at the end.
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
jsonfile.writeFileSync(file, obj)
```
**formatting with spaces:**
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
jsonfile.writeFileSync(file, obj, { spaces: 2 })
```
**overriding EOL:**
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
jsonfile.writeFileSync(file, obj, { spaces: 2, EOL: '\r\n' })
```
**disabling the EOL at the end of file:**
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
jsonfile.writeFileSync(file, obj, { spaces: 2, finalEOL: false })
```
**appending to an existing JSON file:**
You can use `fs.writeFileSync` option `{ flag: 'a' }` to achieve this.
```js
const jsonfile = require('jsonfile')
const file = '/tmp/mayAlreadyExistedData.json'
const obj = { name: 'JP' }
jsonfile.writeFileSync(file, obj, { flag: 'a' })
```
License
-------
(MIT License)
Copyright 2012-2016, JP Richardson <jprichardson@gmail.com>

View file

@ -0,0 +1,88 @@
let _fs
try {
_fs = require('graceful-fs')
} catch (_) {
_fs = require('fs')
}
const universalify = require('universalify')
const { stringify, stripBom } = require('./utils')
async function _readFile (file, options = {}) {
if (typeof options === 'string') {
options = { encoding: options }
}
const fs = options.fs || _fs
const shouldThrow = 'throws' in options ? options.throws : true
let data = await universalify.fromCallback(fs.readFile)(file, options)
data = stripBom(data)
let obj
try {
obj = JSON.parse(data, options ? options.reviver : null)
} catch (err) {
if (shouldThrow) {
err.message = `${file}: ${err.message}`
throw err
} else {
return null
}
}
return obj
}
const readFile = universalify.fromPromise(_readFile)
function readFileSync (file, options = {}) {
if (typeof options === 'string') {
options = { encoding: options }
}
const fs = options.fs || _fs
const shouldThrow = 'throws' in options ? options.throws : true
try {
let content = fs.readFileSync(file, options)
content = stripBom(content)
return JSON.parse(content, options.reviver)
} catch (err) {
if (shouldThrow) {
err.message = `${file}: ${err.message}`
throw err
} else {
return null
}
}
}
async function _writeFile (file, obj, options = {}) {
const fs = options.fs || _fs
const str = stringify(obj, options)
await universalify.fromCallback(fs.writeFile)(file, str, options)
}
const writeFile = universalify.fromPromise(_writeFile)
function writeFileSync (file, obj, options = {}) {
const fs = options.fs || _fs
const str = stringify(obj, options)
// not sure if fs.writeFileSync returns anything, but just in case
return fs.writeFileSync(file, str, options)
}
// NOTE: do not change this export format; required for ESM compat
// see https://github.com/jprichardson/node-jsonfile/pull/162 for details
module.exports = {
readFile,
readFileSync,
writeFile,
writeFileSync
}

View file

@ -0,0 +1,40 @@
{
"name": "jsonfile",
"version": "6.2.1",
"description": "Easily read/write JSON files.",
"repository": {
"type": "git",
"url": "git@github.com:jprichardson/node-jsonfile.git"
},
"keywords": [
"read",
"write",
"file",
"json",
"fs",
"fs-extra"
],
"author": "JP Richardson <jprichardson@gmail.com>",
"license": "MIT",
"dependencies": {
"universalify": "^2.0.0"
},
"optionalDependencies": {
"graceful-fs": "^4.1.6"
},
"devDependencies": {
"mocha": "^8.2.0",
"rimraf": "^2.4.0",
"standard": "^16.0.1"
},
"main": "index.js",
"files": [
"index.js",
"utils.js"
],
"scripts": {
"lint": "standard",
"test": "npm run lint && npm run unit",
"unit": "mocha"
}
}

View file

@ -0,0 +1,18 @@
function stringify (obj, { EOL = '\n', finalEOL = true, replacer = null, spaces } = {}) {
const EOF = finalEOL ? EOL : ''
const str = JSON.stringify(obj, replacer, spaces)
if (str === undefined) {
throw new TypeError(`Converting ${typeof obj} value to JSON is not supported`)
}
return str.replace(/\n/g, EOL) + EOF
}
function stripBom (content) {
// we do this because JSON.parse would convert it to a utf8 string if encoding wasn't specified
if (Buffer.isBuffer(content)) content = content.toString('utf8')
return content.replace(/^\uFEFF/, '')
}
module.exports = { stringify, stripBom }

88
electron/node_modules/@capacitor/cli/package.json generated vendored Normal file
View file

@ -0,0 +1,88 @@
{
"name": "@capacitor/cli",
"version": "8.3.1",
"description": "Capacitor: Cross-platform apps with JavaScript and the web",
"homepage": "https://capacitorjs.com",
"author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ionic-team/capacitor.git"
},
"bugs": {
"url": "https://github.com/ionic-team/capacitor/issues"
},
"files": [
"assets/",
"bin/",
"dist/**/*.js",
"dist/declarations.d.ts"
],
"keywords": [
"ionic",
"ionic framework",
"capacitor",
"universal app",
"progressive web apps",
"cross platform"
],
"engines": {
"node": ">=22.0.0"
},
"main": "dist/index.js",
"types": "dist/declarations.d.ts",
"bin": {
"capacitor": "./bin/capacitor",
"cap": "./bin/capacitor"
},
"scripts": {
"build": "npm run clean && npm run assets && tsc",
"clean": "rimraf ./dist",
"assets": "node ../scripts/pack-cli-assets.mjs",
"prepublishOnly": "npm run build",
"test": "jest -i",
"watch": "npm run assets && tsc -w"
},
"dependencies": {
"@ionic/cli-framework-output": "^2.2.8",
"@ionic/utils-subprocess": "^3.0.1",
"@ionic/utils-terminal": "^2.3.5",
"commander": "^12.1.0",
"debug": "^4.4.0",
"env-paths": "^2.2.0",
"fs-extra": "^11.2.0",
"kleur": "^4.1.5",
"native-run": "^2.0.3",
"open": "^8.4.0",
"plist": "^3.1.0",
"prompts": "^2.4.2",
"rimraf": "^6.0.1",
"semver": "^7.6.3",
"tar": "^7.5.3",
"tslib": "^2.8.1",
"xml2js": "^0.6.2"
},
"devDependencies": {
"@types/debug": "^4.1.12",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.14",
"@types/plist": "^3.0.5",
"@types/prompts": "^2.4.9",
"@types/semver": "^7.5.8",
"@types/tmp": "^0.2.6",
"@types/xml2js": "0.4.5",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-jasmine2": "^29.7.0",
"tmp": "^0.2.3",
"ts-jest": "^29.0.5",
"typescript": "~5.0.2"
},
"jest": {
"preset": "ts-jest",
"testRunner": "jest-jasmine2"
},
"publishConfig": {
"access": "public"
}
}

21
electron/node_modules/@capacitor/core/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017-present Drifty Co.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

3
electron/node_modules/@capacitor/core/README.md generated vendored Normal file
View file

@ -0,0 +1,3 @@
# Capacitor Core JS
See the [Capacitor website](https://capacitorjs.com) for more information.

250
electron/node_modules/@capacitor/core/cookies.md generated vendored Normal file
View file

@ -0,0 +1,250 @@
# CapacitorCookies
The Capacitor Cookies API provides native cookie support via patching `document.cookie` to use native libraries. It also provides methods for modifying cookies at a specific url. This plugin is bundled with `@capacitor/core`.
## Configuration
By default, the patching of `document.cookie` to use native libraries is disabled.
If you would like to enable this feature, modify the configuration below in the `capacitor.config` file.
| Prop | Type | Description | Default |
| ------------- | -------------------- | ------------------------------------------------------------------------- | ------------------ |
| **`enabled`** | <code>boolean</code> | Enable the patching of `document.cookie` to use native libraries instead. | <code>false</code> |
### Example Configuration
In `capacitor.config.json`:
```json
{
"plugins": {
"CapacitorCookies": {
"enabled": true
}
}
}
```
In `capacitor.config.ts`:
```ts
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
plugins: {
CapacitorCookies: {
enabled: true,
},
},
};
export default config;
```
## Example
```typescript
import { CapacitorCookies } from '@capacitor/core';
const getCookies = () => {
return document.cookie;
};
const setCookie = () => {
document.cookie = key + '=' + value;
};
const setCapacitorCookie = async () => {
await CapacitorCookies.setCookie({
url: 'http://example.com',
key: 'language',
value: 'en',
});
};
const deleteCookie = async () => {
await CapacitorCookies.deleteCookie({
url: 'https://example.com',
key: 'language',
});
};
const clearCookiesOnUrl = async () => {
await CapacitorCookies.clearCookies({
url: 'https://example.com',
});
};
const clearAllCookies = async () => {
await CapacitorCookies.clearAllCookies();
};
```
## Third Party Cookies on iOS
As of iOS 14, you cannot use 3rd party cookies by default. Add the following lines to your Info.plist file to get better support for cookies on iOS. You can add up to 10 domains.
```xml
<key>WKAppBoundDomains</key>
<array>
<string>www.mydomain.com</string>
<string>api.mydomain.com</string>
<string>www.myothercooldomain.com</string>
</array>
```
## API
<docgen-index>
* [`getCookies(...)`](#getcookies)
* [`setCookie(...)`](#setcookie)
* [`deleteCookie(...)`](#deletecookie)
* [`clearCookies(...)`](#clearcookies)
* [`clearAllCookies()`](#clearallcookies)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
</docgen-index>
<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
### getCookies(...)
```typescript
getCookies(options?: GetCookieOptions) => Promise<HttpCookieMap>
```
| Param | Type |
| ------------- | ------------------------------------------------------------- |
| **`options`** | <code><a href="#getcookieoptions">GetCookieOptions</a></code> |
**Returns:** <code>Promise&lt;<a href="#httpcookiemap">HttpCookieMap</a>&gt;</code>
--------------------
### setCookie(...)
```typescript
setCookie(options: SetCookieOptions) => Promise<void>
```
Write a cookie to the device.
| Param | Type |
| ------------- | ------------------------------------------------------------- |
| **`options`** | <code><a href="#setcookieoptions">SetCookieOptions</a></code> |
--------------------
### deleteCookie(...)
```typescript
deleteCookie(options: DeleteCookieOptions) => Promise<void>
```
Delete a cookie from the device.
| Param | Type |
| ------------- | ------------------------------------------------------------------- |
| **`options`** | <code><a href="#deletecookieoptions">DeleteCookieOptions</a></code> |
--------------------
### clearCookies(...)
```typescript
clearCookies(options: ClearCookieOptions) => Promise<void>
```
Clear cookies from the device at a given URL.
| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| **`options`** | <code><a href="#clearcookieoptions">ClearCookieOptions</a></code> |
--------------------
### clearAllCookies()
```typescript
clearAllCookies() => Promise<void>
```
Clear all cookies on the device.
--------------------
### Interfaces
#### HttpCookieMap
#### HttpCookie
| Prop | Type | Description |
| ----------- | ------------------- | ------------------------ |
| **`url`** | <code>string</code> | The URL of the cookie. |
| **`key`** | <code>string</code> | The key of the cookie. |
| **`value`** | <code>string</code> | The value of the cookie. |
#### HttpCookieExtras
| Prop | Type | Description |
| ------------- | ------------------- | -------------------------------- |
| **`path`** | <code>string</code> | The path to write the cookie to. |
| **`expires`** | <code>string</code> | The date to expire the cookie. |
### Type Aliases
#### GetCookieOptions
<code><a href="#omit">Omit</a>&lt;<a href="#httpcookie">HttpCookie</a>, 'key' | 'value'&gt;</code>
#### Omit
Construct a type with the properties of T except for those in type K.
<code><a href="#pick">Pick</a>&lt;T, <a href="#exclude">Exclude</a>&lt;keyof T, K&gt;&gt;</code>
#### Pick
From T, pick a set of properties whose keys are in the union K
<code>{ [P in K]: T[P]; }</code>
#### Exclude
<a href="#exclude">Exclude</a> from T those types that are assignable to U
<code>T extends U ? never : T</code>
#### SetCookieOptions
<code><a href="#httpcookie">HttpCookie</a> & <a href="#httpcookieextras">HttpCookieExtras</a></code>
#### DeleteCookieOptions
<code><a href="#omit">Omit</a>&lt;<a href="#httpcookie">HttpCookie</a>, 'value'&gt;</code>
#### ClearCookieOptions
<code><a href="#omit">Omit</a>&lt;<a href="#httpcookie">HttpCookie</a>, 'key' | 'value'&gt;</code>
</docgen-api>

1559
electron/node_modules/@capacitor/core/cordova.js generated vendored Normal file

File diff suppressed because it is too large Load diff

683
electron/node_modules/@capacitor/core/http.md generated vendored Normal file
View file

@ -0,0 +1,683 @@
# CapacitorHttp
The Capacitor Http API provides native http support via patching `fetch` and `XMLHttpRequest` to use native libraries. It also provides helper methods for native http requests without the use of `fetch` and `XMLHttpRequest`. This plugin is bundled with `@capacitor/core`.
## Configuration
By default, the patching of `window.fetch` and `XMLHttpRequest` to use native libraries is disabled.
If you would like to enable this feature, modify the configuration below in the `capacitor.config` file.
| Prop | Type | Description | Default |
| ------------- | -------------------- | ------------------------------------------------------------------------------------ | ------------------ |
| **`enabled`** | <code>boolean</code> | Enable the patching of `fetch` and `XMLHttpRequest` to use native libraries instead. | <code>false</code> |
### Example Configuration
In `capacitor.config.json`:
```json
{
"plugins": {
"CapacitorHttp": {
"enabled": true
}
}
}
```
In `capacitor.config.ts`:
```ts
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
plugins: {
CapacitorHttp: {
enabled: true,
},
},
};
export default config;
```
## Example
```typescript
import { CapacitorHttp } from '@capacitor/core';
// Example of a GET request
const doGet = () => {
const options = {
url: 'https://example.com/my/api',
headers: { 'X-Fake-Header': 'Fake-Value' },
params: { size: 'XL' },
};
const response: HttpResponse = await CapacitorHttp.get(options);
// or...
// const response = await CapacitorHttp.request({ ...options, method: 'GET' })
};
// Example of a POST request. Note: data
// can be passed as a raw JS Object (must be JSON serializable)
const doPost = () => {
const options = {
url: 'https://example.com/my/api',
headers: { 'X-Fake-Header': 'Fake-Value' },
data: { foo: 'bar' },
};
const response: HttpResponse = await CapacitorHttp.post(options);
// or...
// const response = await CapacitorHttp.request({ ...options, method: 'POST' })
};
```
## Large File Support
Due to the nature of the bridge, parsing and transferring large amount of data from native to the web can cause issues. Support for downloading and uploading files has been added to the [`@capacitor/file-transfer`](https://capacitorjs.com/docs/apis/file-transfer) plugin. In many cases, you may also need [`@capacitor/filesystem`](https://capacitorjs.com/docs/apis/filesystem) to generate a valid [file URI](https://capacitorjs.com/docs/apis/filesystem#geturi).
## API
<docgen-index>
* [`request(...)`](#request)
* [`get(...)`](#get)
* [`post(...)`](#post)
* [`put(...)`](#put)
* [`patch(...)`](#patch)
* [`delete(...)`](#delete)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
</docgen-index>
<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
****** HTTP PLUGIN *******
### request(...)
```typescript
request(options: HttpOptions) => Promise<HttpResponse>
```
Make a Http Request to a server using native libraries.
| Param | Type |
| ------------- | --------------------------------------------------- |
| **`options`** | <code><a href="#httpoptions">HttpOptions</a></code> |
**Returns:** <code>Promise&lt;<a href="#httpresponse">HttpResponse</a>&gt;</code>
--------------------
### get(...)
```typescript
get(options: HttpOptions) => Promise<HttpResponse>
```
Make a Http GET Request to a server using native libraries.
| Param | Type |
| ------------- | --------------------------------------------------- |
| **`options`** | <code><a href="#httpoptions">HttpOptions</a></code> |
**Returns:** <code>Promise&lt;<a href="#httpresponse">HttpResponse</a>&gt;</code>
--------------------
### post(...)
```typescript
post(options: HttpOptions) => Promise<HttpResponse>
```
Make a Http POST Request to a server using native libraries.
| Param | Type |
| ------------- | --------------------------------------------------- |
| **`options`** | <code><a href="#httpoptions">HttpOptions</a></code> |
**Returns:** <code>Promise&lt;<a href="#httpresponse">HttpResponse</a>&gt;</code>
--------------------
### put(...)
```typescript
put(options: HttpOptions) => Promise<HttpResponse>
```
Make a Http PUT Request to a server using native libraries.
| Param | Type |
| ------------- | --------------------------------------------------- |
| **`options`** | <code><a href="#httpoptions">HttpOptions</a></code> |
**Returns:** <code>Promise&lt;<a href="#httpresponse">HttpResponse</a>&gt;</code>
--------------------
### patch(...)
```typescript
patch(options: HttpOptions) => Promise<HttpResponse>
```
Make a Http PATCH Request to a server using native libraries.
| Param | Type |
| ------------- | --------------------------------------------------- |
| **`options`** | <code><a href="#httpoptions">HttpOptions</a></code> |
**Returns:** <code>Promise&lt;<a href="#httpresponse">HttpResponse</a>&gt;</code>
--------------------
### delete(...)
```typescript
delete(options: HttpOptions) => Promise<HttpResponse>
```
Make a Http DELETE Request to a server using native libraries.
| Param | Type |
| ------------- | --------------------------------------------------- |
| **`options`** | <code><a href="#httpoptions">HttpOptions</a></code> |
**Returns:** <code>Promise&lt;<a href="#httpresponse">HttpResponse</a>&gt;</code>
--------------------
### Interfaces
#### HttpResponse
| Prop | Type | Description |
| ------------- | --------------------------------------------------- | ------------------------------------------------- |
| **`data`** | <code>any</code> | Additional data received with the Http response. |
| **`status`** | <code>number</code> | The status code received from the Http response. |
| **`headers`** | <code><a href="#httpheaders">HttpHeaders</a></code> | The headers received from the Http response. |
| **`url`** | <code>string</code> | The response URL received from the Http response. |
#### HttpHeaders
#### HttpOptions
| Prop | Type | Description |
| --------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`url`** | <code>string</code> | The URL to send the request to. |
| **`method`** | <code>string</code> | The Http Request method to run. (Default is GET) |
| **`params`** | <code><a href="#httpparams">HttpParams</a></code> | URL parameters to append to the request. |
| **`data`** | <code>any</code> | Note: On Android and iOS, data can only be a string or a JSON. FormData, <a href="#blob">Blob</a>, <a href="#arraybuffer">ArrayBuffer</a>, and other complex types are only directly supported on web or through enabling `CapacitorHttp` in the config and using the patched `window.fetch` or `XMLHttpRequest`. If you need to send a complex type, you should serialize the data to base64 and set the `headers["Content-Type"]` and `dataType` attributes accordingly. |
| **`headers`** | <code><a href="#httpheaders">HttpHeaders</a></code> | Http Request headers to send with the request. |
| **`readTimeout`** | <code>number</code> | How long to wait to read additional data in milliseconds. Resets each time new data is received. |
| **`connectTimeout`** | <code>number</code> | How long to wait for the initial connection in milliseconds. |
| **`disableRedirects`** | <code>boolean</code> | Sets whether automatic HTTP redirects should be disabled |
| **`webFetchExtra`** | <code><a href="#requestinit">RequestInit</a></code> | Extra arguments for fetch when running on the web |
| **`responseType`** | <code><a href="#httpresponsetype">HttpResponseType</a></code> | This is used to parse the response appropriately before returning it to the requestee. If the response content-type is "json", this value is ignored. |
| **`shouldEncodeUrlParams`** | <code>boolean</code> | Use this option if you need to keep the URL unencoded in certain cases (already encoded, azure/firebase testing, etc.). The default is _true_. |
| **`dataType`** | <code>'file' \| 'formData'</code> | This is used if we've had to convert the data from a JS type that needs special handling in the native layer |
#### HttpParams
#### RequestInit
| Prop | Type | Description |
| -------------------- | ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`body`** | <code><a href="#bodyinit">BodyInit</a></code> | A <a href="#bodyinit">BodyInit</a> object or null to set request's body. |
| **`cache`** | <code><a href="#requestcache">RequestCache</a></code> | A string indicating how the request will interact with the browser's cache to set request's cache. |
| **`credentials`** | <code><a href="#requestcredentials">RequestCredentials</a></code> | A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. |
| **`headers`** | <code><a href="#headersinit">HeadersInit</a></code> | A <a href="#headers">Headers</a> object, an object literal, or an array of two-item arrays to set request's headers. |
| **`integrity`** | <code>string</code> | A cryptographic hash of the resource to be fetched by request. Sets request's integrity. |
| **`keepalive`** | <code>boolean</code> | A boolean to set request's keepalive. |
| **`method`** | <code>string</code> | A string to set request's method. |
| **`mode`** | <code><a href="#requestmode">RequestMode</a></code> | A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. |
| **`redirect`** | <code><a href="#requestredirect">RequestRedirect</a></code> | A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. |
| **`referrer`** | <code>string</code> | A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer. |
| **`referrerPolicy`** | <code><a href="#referrerpolicy">ReferrerPolicy</a></code> | A referrer policy to set request's referrerPolicy. |
| **`signal`** | <code><a href="#abortsignal">AbortSignal</a></code> | An <a href="#abortsignal">AbortSignal</a> to set request's signal. |
| **`window`** | <code>any</code> | Can only be null. Used to disassociate request from any Window. |
#### Blob
A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The <a href="#file">File</a> interface is based on <a href="#blob">Blob</a>, inheriting blob functionality and expanding it to support files on the user's system.
`Blob` class is a global reference for `require('node:buffer').Blob`
https://nodejs.org/api/buffer.html#class-blob
| Prop | Type |
| ---------- | ------------------- |
| **`size`** | <code>number</code> |
| **`type`** | <code>string</code> |
| Method | Signature |
| --------------- | ----------------------------------------------------------------------------------- |
| **arrayBuffer** | () =&gt; Promise&lt;<a href="#arraybuffer">ArrayBuffer</a>&gt; |
| **slice** | (start?: number, end?: number, contentType?: string) =&gt; <a href="#blob">Blob</a> |
| **stream** | () =&gt; <a href="#readablestream">ReadableStream</a> |
| **text** | () =&gt; Promise&lt;string&gt; |
#### ArrayBuffer
Represents a raw buffer of binary data, which is used to store data for the
different typed arrays. ArrayBuffers cannot be read from or written to directly,
but can be passed to a typed array or DataView Object to interpret the raw
buffer as needed.
| Prop | Type | Description |
| ---------------- | ------------------- | ------------------------------------------------------------------------------- |
| **`byteLength`** | <code>number</code> | Read-only. The length of the <a href="#arraybuffer">ArrayBuffer</a> (in bytes). |
| Method | Signature | Description |
| --------- | -------------------------------------------------------------------------- | --------------------------------------------------------------- |
| **slice** | (begin: number, end?: number) =&gt; <a href="#arraybuffer">ArrayBuffer</a> | Returns a section of an <a href="#arraybuffer">ArrayBuffer</a>. |
#### ReadableStream
This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a <a href="#readablestream">ReadableStream</a> through the body property of a Response object.
| Prop | Type |
| ------------ | -------------------- |
| **`locked`** | <code>boolean</code> |
| Method | Signature |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **cancel** | (reason?: any) =&gt; Promise&lt;void&gt; |
| **getReader** | () =&gt; <a href="#readablestreamdefaultreader">ReadableStreamDefaultReader</a>&lt;R&gt; |
| **pipeThrough** | &lt;T&gt;(transform: <a href="#readablewritablepair">ReadableWritablePair</a>&lt;T, R&gt;, options?: <a href="#streampipeoptions">StreamPipeOptions</a>) =&gt; <a href="#readablestream">ReadableStream</a>&lt;T&gt; |
| **pipeTo** | (dest: <a href="#writablestream">WritableStream</a>&lt;R&gt;, options?: <a href="#streampipeoptions">StreamPipeOptions</a>) =&gt; Promise&lt;void&gt; |
| **tee** | () =&gt; [ReadableStream&lt;R&gt;, <a href="#readablestream">ReadableStream</a>&lt;R&gt;] |
#### ReadableStreamDefaultReader
| Method | Signature |
| --------------- | --------------------------------------------------------------------------------------------------------------- |
| **read** | () =&gt; Promise&lt;<a href="#readablestreamdefaultreadresult">ReadableStreamDefaultReadResult</a>&lt;R&gt;&gt; |
| **releaseLock** | () =&gt; void |
#### ReadableStreamDefaultReadValueResult
| Prop | Type |
| ----------- | ------------------ |
| **`done`** | <code>false</code> |
| **`value`** | <code>T</code> |
#### ReadableStreamDefaultReadDoneResult
| Prop | Type |
| ----------- | ----------------- |
| **`done`** | <code>true</code> |
| **`value`** | |
#### ReadableWritablePair
| Prop | Type | Description |
| -------------- | ------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`readable`** | <code><a href="#readablestream">ReadableStream</a>&lt;R&gt;</code> | |
| **`writable`** | <code><a href="#writablestream">WritableStream</a>&lt;W&gt;</code> | Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use. Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. |
#### WritableStream
This Streams API interface provides a standard abstraction for writing streaming data to a destination, known as a sink. This object comes with built-in backpressure and queuing.
| Prop | Type |
| ------------ | -------------------- |
| **`locked`** | <code>boolean</code> |
| Method | Signature |
| ------------- | ---------------------------------------------------------------------------------------- |
| **abort** | (reason?: any) =&gt; Promise&lt;void&gt; |
| **getWriter** | () =&gt; <a href="#writablestreamdefaultwriter">WritableStreamDefaultWriter</a>&lt;W&gt; |
#### WritableStreamDefaultWriter
This Streams API interface is the object returned by <a href="#writablestream">WritableStream.getWriter</a>() and once created locks the &lt; writer to the <a href="#writablestream">WritableStream</a> ensuring that no other streams can write to the underlying sink.
| Prop | Type |
| ----------------- | ------------------------------------- |
| **`closed`** | <code>Promise&lt;undefined&gt;</code> |
| **`desiredSize`** | <code>number</code> |
| **`ready`** | <code>Promise&lt;undefined&gt;</code> |
| Method | Signature |
| --------------- | ---------------------------------------- |
| **abort** | (reason?: any) =&gt; Promise&lt;void&gt; |
| **close** | () =&gt; Promise&lt;void&gt; |
| **releaseLock** | () =&gt; void |
| **write** | (chunk: W) =&gt; Promise&lt;void&gt; |
#### StreamPipeOptions
| Prop | Type | Description |
| ------------------- | --------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`preventAbort`** | <code>boolean</code> | |
| **`preventCancel`** | <code>boolean</code> | |
| **`preventClose`** | <code>boolean</code> | Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered. Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. Errors and closures of the source and destination streams propagate as follows: An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination. An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source. When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error. If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source. The signal option can be set to an <a href="#abortsignal">AbortSignal</a> to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set. |
| **`signal`** | <code><a href="#abortsignal">AbortSignal</a></code> | |
#### AbortSignal
A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object.
| Prop | Type | Description |
| ------------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| **`aborted`** | <code>boolean</code> | Returns true if this <a href="#abortsignal">AbortSignal</a>'s AbortController has signaled to abort, and false otherwise. |
| **`onabort`** | <code>(this: <a href="#abortsignal">AbortSignal</a>, ev: <a href="#event">Event</a>) =&gt; any</code> | |
| Method | Signature | Description |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **addEventListener** | &lt;K extends "abort"&gt;(type: K, listener: (this: <a href="#abortsignal">AbortSignal</a>, ev: AbortSignalEventMap[K]) =&gt; any, options?: boolean \| <a href="#addeventlisteneroptions">AddEventListenerOptions</a>) =&gt; void | Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched. The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture. When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET. When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners. When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed. The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. |
| **addEventListener** | (type: string, listener: <a href="#eventlisteneroreventlistenerobject">EventListenerOrEventListenerObject</a>, options?: boolean \| <a href="#addeventlisteneroptions">AddEventListenerOptions</a>) =&gt; void | Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched. The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture. When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET. When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners. When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed. The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. |
| **removeEventListener** | &lt;K extends "abort"&gt;(type: K, listener: (this: <a href="#abortsignal">AbortSignal</a>, ev: AbortSignalEventMap[K]) =&gt; any, options?: boolean \| <a href="#eventlisteneroptions">EventListenerOptions</a>) =&gt; void | Removes the event listener in target's event listener list with the same type, callback, and options. |
| **removeEventListener** | (type: string, listener: <a href="#eventlisteneroreventlistenerobject">EventListenerOrEventListenerObject</a>, options?: boolean \| <a href="#eventlisteneroptions">EventListenerOptions</a>) =&gt; void | Removes the event listener in target's event listener list with the same type, callback, and options. |
#### AbortSignalEventMap
| Prop | Type |
| ------------- | --------------------------------------- |
| **`"abort"`** | <code><a href="#event">Event</a></code> |
#### Event
An event which takes place in the DOM.
| Prop | Type | Description |
| ---------------------- | --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`bubbles`** | <code>boolean</code> | Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise. |
| **`cancelBubble`** | <code>boolean</code> | |
| **`cancelable`** | <code>boolean</code> | Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method. |
| **`composed`** | <code>boolean</code> | Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise. |
| **`currentTarget`** | <code><a href="#eventtarget">EventTarget</a></code> | Returns the object whose event listener's callback is currently being invoked. |
| **`defaultPrevented`** | <code>boolean</code> | Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise. |
| **`eventPhase`** | <code>number</code> | Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE. |
| **`isTrusted`** | <code>boolean</code> | Returns true if event was dispatched by the user agent, and false otherwise. |
| **`returnValue`** | <code>boolean</code> | |
| **`srcElement`** | <code><a href="#eventtarget">EventTarget</a></code> | |
| **`target`** | <code><a href="#eventtarget">EventTarget</a></code> | Returns the object to which event is dispatched (its target). |
| **`timeStamp`** | <code>number</code> | Returns the event's timestamp as the number of milliseconds measured relative to the time origin. |
| **`type`** | <code>string</code> | Returns the type of event, e.g. "click", "hashchange", or "submit". |
| **`AT_TARGET`** | <code>number</code> | |
| **`BUBBLING_PHASE`** | <code>number</code> | |
| **`CAPTURING_PHASE`** | <code>number</code> | |
| **`NONE`** | <code>number</code> | |
| Method | Signature | Description |
| ---------------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **composedPath** | () =&gt; EventTarget[] | Returns the invocation target objects of event's path (objects on which listeners will be invoked), except for any nodes in shadow trees of which the shadow root's mode is "closed" that are not reachable from event's currentTarget. |
| **initEvent** | (type: string, bubbles?: boolean, cancelable?: boolean) =&gt; void | |
| **preventDefault** | () =&gt; void | If invoked when the cancelable attribute value is true, and while executing a listener for the event with passive set to false, signals to the operation that caused event to be dispatched that it needs to be canceled. |
| **stopImmediatePropagation** | () =&gt; void | Invoking this method prevents event from reaching any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any other objects. |
| **stopPropagation** | () =&gt; void | When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object. |
#### EventTarget
<a href="#eventtarget">EventTarget</a> is a DOM interface implemented by objects that can receive events and may have listeners for them.
EventTarget is a DOM interface implemented by objects that can
receive events and may have listeners for them.
| Method | Signature | Description |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **addEventListener** | (type: string, listener: <a href="#eventlisteneroreventlistenerobject">EventListenerOrEventListenerObject</a> \| null, options?: boolean \| <a href="#addeventlisteneroptions">AddEventListenerOptions</a>) =&gt; void | Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched. The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture. When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET. When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners. When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed. The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. |
| **dispatchEvent** | (event: <a href="#event">Event</a>) =&gt; boolean | Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. |
| **removeEventListener** | (type: string, callback: <a href="#eventlisteneroreventlistenerobject">EventListenerOrEventListenerObject</a> \| null, options?: <a href="#eventlisteneroptions">EventListenerOptions</a> \| boolean) =&gt; void | Removes the event listener in target's event listener list with the same type, callback, and options. |
#### EventListener
#### EventListenerObject
| Method | Signature |
| --------------- | -------------------------------------------- |
| **handleEvent** | (evt: <a href="#event">Event</a>) =&gt; void |
#### AddEventListenerOptions
| Prop | Type |
| ------------- | -------------------- |
| **`once`** | <code>boolean</code> |
| **`passive`** | <code>boolean</code> |
#### EventListenerOptions
| Prop | Type |
| ------------- | -------------------- |
| **`capture`** | <code>boolean</code> |
#### ArrayBufferView
| Prop | Type | Description |
| ---------------- | ----------------------------------------------------------- | ---------------------------------------------------------------------------- |
| **`buffer`** | <code><a href="#arraybufferlike">ArrayBufferLike</a></code> | The <a href="#arraybuffer">ArrayBuffer</a> instance referenced by the array. |
| **`byteLength`** | <code>number</code> | The length in bytes of the array. |
| **`byteOffset`** | <code>number</code> | The offset in bytes of the array. |
#### ArrayBufferTypes
Allowed <a href="#arraybuffer">ArrayBuffer</a> types for the buffer of an <a href="#arraybufferview">ArrayBufferView</a> and related Typed Arrays.
| Prop | Type |
| ----------------- | --------------------------------------------------- |
| **`ArrayBuffer`** | <code><a href="#arraybuffer">ArrayBuffer</a></code> |
#### FormData
Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data".
| Method | Signature |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **append** | (name: string, value: string \| <a href="#blob">Blob</a>, fileName?: string) =&gt; void |
| **delete** | (name: string) =&gt; void |
| **get** | (name: string) =&gt; <a href="#formdataentryvalue">FormDataEntryValue</a> \| null |
| **getAll** | (name: string) =&gt; FormDataEntryValue[] |
| **has** | (name: string) =&gt; boolean |
| **set** | (name: string, value: string \| <a href="#blob">Blob</a>, fileName?: string) =&gt; void |
| **forEach** | (callbackfn: (value: <a href="#formdataentryvalue">FormDataEntryValue</a>, key: string, parent: <a href="#formdata">FormData</a>) =&gt; void, thisArg?: any) =&gt; void |
#### File
Provides information about files and allows JavaScript in a web page to access their content.
| Prop | Type |
| ------------------ | ------------------- |
| **`lastModified`** | <code>number</code> |
| **`name`** | <code>string</code> |
#### URLSearchParams
<a href="#urlsearchparams">`URLSearchParams`</a> class is a global reference for `require('url').URLSearchParams`
https://nodejs.org/api/url.html#class-urlsearchparams
| Method | Signature | Description |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| **append** | (name: string, value: string) =&gt; void | Appends a specified key/value pair as a new search parameter. |
| **delete** | (name: string) =&gt; void | Deletes the given search parameter, and its associated value, from the list of all search parameters. |
| **get** | (name: string) =&gt; string \| null | Returns the first value associated to the given search parameter. |
| **getAll** | (name: string) =&gt; string[] | Returns all the values association with a given search parameter. |
| **has** | (name: string) =&gt; boolean | Returns a Boolean indicating if such a search parameter exists. |
| **set** | (name: string, value: string) =&gt; void | Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. |
| **sort** | () =&gt; void | |
| **toString** | () =&gt; string | Returns a string containing a query string suitable for use in a URL. Does not include the question mark. |
| **forEach** | (callbackfn: (value: string, key: string, parent: <a href="#urlsearchparams">URLSearchParams</a>) =&gt; void, thisArg?: any) =&gt; void | |
#### Uint8Array
A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
requested number of bytes could not be allocated an exception is raised.
| Prop | Type | Description |
| ----------------------- | ----------------------------------------------------------- | ---------------------------------------------------------------------------- |
| **`BYTES_PER_ELEMENT`** | <code>number</code> | The size in bytes of each element in the array. |
| **`buffer`** | <code><a href="#arraybufferlike">ArrayBufferLike</a></code> | The <a href="#arraybuffer">ArrayBuffer</a> instance referenced by the array. |
| **`byteLength`** | <code>number</code> | The length in bytes of the array. |
| **`byteOffset`** | <code>number</code> | The offset in bytes of the array. |
| **`length`** | <code>number</code> | The length of the array. |
| Method | Signature | Description |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **copyWithin** | (target: number, start: number, end?: number) =&gt; this | Returns the this object after copying a section of the array identified by start and end to the same array starting at position target |
| **every** | (predicate: (value: number, index: number, array: <a href="#uint8array">Uint8Array</a>) =&gt; unknown, thisArg?: any) =&gt; boolean | Determines whether all the members of an array satisfy the specified test. |
| **fill** | (value: number, start?: number, end?: number) =&gt; this | Returns the this object after filling the section identified by start and end with value |
| **filter** | (predicate: (value: number, index: number, array: <a href="#uint8array">Uint8Array</a>) =&gt; any, thisArg?: any) =&gt; <a href="#uint8array">Uint8Array</a> | Returns the elements of an array that meet the condition specified in a callback function. |
| **find** | (predicate: (value: number, index: number, obj: <a href="#uint8array">Uint8Array</a>) =&gt; boolean, thisArg?: any) =&gt; number \| undefined | Returns the value of the first element in the array where predicate is true, and undefined otherwise. |
| **findIndex** | (predicate: (value: number, index: number, obj: <a href="#uint8array">Uint8Array</a>) =&gt; boolean, thisArg?: any) =&gt; number | Returns the index of the first element in the array where predicate is true, and -1 otherwise. |
| **forEach** | (callbackfn: (value: number, index: number, array: <a href="#uint8array">Uint8Array</a>) =&gt; void, thisArg?: any) =&gt; void | Performs the specified action for each element in an array. |
| **indexOf** | (searchElement: number, fromIndex?: number) =&gt; number | Returns the index of the first occurrence of a value in an array. |
| **join** | (separator?: string) =&gt; string | Adds all the elements of an array separated by the specified separator string. |
| **lastIndexOf** | (searchElement: number, fromIndex?: number) =&gt; number | Returns the index of the last occurrence of a value in an array. |
| **map** | (callbackfn: (value: number, index: number, array: <a href="#uint8array">Uint8Array</a>) =&gt; number, thisArg?: any) =&gt; <a href="#uint8array">Uint8Array</a> | Calls a defined callback function on each element of an array, and returns an array that contains the results. |
| **reduce** | (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: <a href="#uint8array">Uint8Array</a>) =&gt; number) =&gt; number | Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
| **reduce** | (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: <a href="#uint8array">Uint8Array</a>) =&gt; number, initialValue: number) =&gt; number | |
| **reduce** | &lt;U&gt;(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: <a href="#uint8array">Uint8Array</a>) =&gt; U, initialValue: U) =&gt; U | Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
| **reduceRight** | (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: <a href="#uint8array">Uint8Array</a>) =&gt; number) =&gt; number | Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
| **reduceRight** | (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: <a href="#uint8array">Uint8Array</a>) =&gt; number, initialValue: number) =&gt; number | |
| **reduceRight** | &lt;U&gt;(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: <a href="#uint8array">Uint8Array</a>) =&gt; U, initialValue: U) =&gt; U | Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
| **reverse** | () =&gt; <a href="#uint8array">Uint8Array</a> | Reverses the elements in an Array. |
| **set** | (array: <a href="#arraylike">ArrayLike</a>&lt;number&gt;, offset?: number) =&gt; void | Sets a value or an array of values. |
| **slice** | (start?: number, end?: number) =&gt; <a href="#uint8array">Uint8Array</a> | Returns a section of an array. |
| **some** | (predicate: (value: number, index: number, array: <a href="#uint8array">Uint8Array</a>) =&gt; unknown, thisArg?: any) =&gt; boolean | Determines whether the specified callback function returns true for any element of an array. |
| **sort** | (compareFn?: (a: number, b: number) =&gt; number) =&gt; this | Sorts an array. |
| **subarray** | (begin?: number, end?: number) =&gt; <a href="#uint8array">Uint8Array</a> | Gets a new <a href="#uint8array">Uint8Array</a> view of the <a href="#arraybuffer">ArrayBuffer</a> store for this array, referencing the elements at begin, inclusive, up to end, exclusive. |
| **toLocaleString** | () =&gt; string | Converts a number to a string by using the current locale. |
| **toString** | () =&gt; string | Returns a string representation of an array. |
| **valueOf** | () =&gt; <a href="#uint8array">Uint8Array</a> | Returns the primitive value of the specified object. |
#### ArrayLike
| Prop | Type |
| ------------ | ------------------- |
| **`length`** | <code>number</code> |
#### Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A <a href="#headers">Headers</a> object has an associated header list, which is initially empty and consists of zero or more name and value pairs.  You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.
| Method | Signature |
| ----------- | ----------------------------------------------------------------------------------------------------------------------- |
| **append** | (name: string, value: string) =&gt; void |
| **delete** | (name: string) =&gt; void |
| **get** | (name: string) =&gt; string \| null |
| **has** | (name: string) =&gt; boolean |
| **set** | (name: string, value: string) =&gt; void |
| **forEach** | (callbackfn: (value: string, key: string, parent: <a href="#headers">Headers</a>) =&gt; void, thisArg?: any) =&gt; void |
### Type Aliases
#### BodyInit
<code><a href="#blob">Blob</a> | <a href="#buffersource">BufferSource</a> | <a href="#formdata">FormData</a> | <a href="#urlsearchparams">URLSearchParams</a> | <a href="#readablestream">ReadableStream</a>&lt;<a href="#uint8array">Uint8Array</a>&gt; | string</code>
#### ReadableStreamDefaultReadResult
<code><a href="#readablestreamdefaultreadvalueresult">ReadableStreamDefaultReadValueResult</a>&lt;T&gt; | <a href="#readablestreamdefaultreaddoneresult">ReadableStreamDefaultReadDoneResult</a></code>
#### EventListenerOrEventListenerObject
<code><a href="#eventlistener">EventListener</a> | <a href="#eventlistenerobject">EventListenerObject</a></code>
#### BufferSource
<code><a href="#arraybufferview">ArrayBufferView</a> | <a href="#arraybuffer">ArrayBuffer</a></code>
#### ArrayBufferLike
<code>ArrayBufferTypes[keyof ArrayBufferTypes]</code>
#### FormDataEntryValue
<code><a href="#file">File</a> | string</code>
#### RequestCache
<code>"default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload"</code>
#### RequestCredentials
<code>"include" | "omit" | "same-origin"</code>
#### HeadersInit
<code><a href="#headers">Headers</a> | string[][] | <a href="#record">Record</a>&lt;string, string&gt;</code>
#### Record
Construct a type with a set of properties K of type T
<code>{ [P in K]: T; }</code>
#### RequestMode
<code>"cors" | "navigate" | "no-cors" | "same-origin"</code>
#### RequestRedirect
<code>"error" | "follow" | "manual"</code>
#### ReferrerPolicy
<code>"" | "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url"</code>
#### HttpResponseType
How to parse the Http response before returning it to the client.
<code>'arraybuffer' | 'blob' | 'json' | 'text' | 'document'</code>
</docgen-api>

62
electron/node_modules/@capacitor/core/package.json generated vendored Normal file
View file

@ -0,0 +1,62 @@
{
"name": "@capacitor/core",
"version": "8.3.1",
"description": "Capacitor: Cross-platform apps with JavaScript and the web",
"homepage": "https://capacitorjs.com",
"author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/ionic-team/capacitor.git"
},
"bugs": {
"url": "https://github.com/ionic-team/capacitor/issues"
},
"files": [
"dist/",
"types/",
"cookies.md",
"cordova.js",
"http.md",
"system-bars.md"
],
"main": "dist/index.cjs.js",
"module": "dist/index.js",
"types": "types/index.d.ts",
"unpkg": "dist/capacitor.js",
"scripts": {
"build": "npm run clean && npm run docgen && npm run transpile && npm run rollup",
"build:nativebridge": "tsc native-bridge.ts --target es2017 --moduleResolution node --outDir build && rollup --config rollup.bridge.config.js",
"clean": "rimraf dist",
"docgen": "docgen --api CapacitorCookiesPlugin --output-readme cookies.md && docgen --api CapacitorHttpPlugin --output-readme http.md && docgen --api SystemBarsPlugin --output-readme system-bars.md",
"prepublishOnly": "npm run build",
"rollup": "rollup --config rollup.config.js",
"transpile": "tsc",
"test": "jest",
"test.watch": "jest --watchAll",
"test.treeshaking": "node src/tests/build-treeshaking.js"
},
"dependencies": {
"tslib": "^2.1.0"
},
"devDependencies": {
"@capacitor/docgen": "^0.2.2",
"@rollup/plugin-node-resolve": "^10.0.0",
"@rollup/plugin-replace": "^2.4.2",
"@types/jest": "^29.5.0",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-jasmine2": "^29.5.0",
"rimraf": "^4.4.1",
"rollup": "^2.21.0",
"rollup-plugin-terser": "^7.0.2",
"typescript": "~5.0.2"
},
"jest": {
"preset": "ts-jest",
"testRunner": "jest-jasmine2"
},
"publishConfig": {
"access": "public"
}
}

260
electron/node_modules/@capacitor/core/system-bars.md generated vendored Normal file
View file

@ -0,0 +1,260 @@
# SystemBars
The SystemBars API provides methods for configuring the style and visibility of the device System Bars / Status Bar. This plugin is bundled with `@capacitor/core`.
This API differs from the [Status Bar](https://capacitorjs.com/docs/apis/status-bar) plugin in that it is only intended to support modern edge to edge use cases moving forward. For legacy functionality, use the [Status Bar](https://capacitorjs.com/docs/apis/status-bar) plugin.
| Feature | System Bars | Status Bar |
| ------- | ----------- | ---------- |
| `setOverlaysWebView()` | Unsupported | Supported on iOS and Android <= 14 (or 15 if edge to edge opt-out is enabled) |
| `setBackgroundColor()` | Unsupported | Supported |
| `setStyle()` | Supported | Supported - top Status Bar only |
| `hide()/show()` | Supported | Supported - top Status Bar only |
## iOS Note
This plugin requires "View controller-based status bar appearance"
(`UIViewControllerBasedStatusBarAppearance`) set to `YES` in `Info.plist`. Read
about [Configuring iOS](https://capacitorjs.com/docs/ios/configuration) for
help.
The status bar visibility defaults to visible and the style defaults to
`Style.Default`. You can change these defaults by adding
`UIStatusBarHidden` and/or `UIStatusBarStyle` in `Info.plist`.
## Android Note
Due to a [bug](https://issues.chromium.org/issues/40699457) in some older versions of Android WebView (< 140), correct safe area values are not available via the `safe-area-inset-x` CSS `env` variables. This plugin will inject the correct inset values into a new CSS variable(s) named `--safe-area-inset-x` that you can use as a fallback in your frontend styles:
```css
html {
padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
padding-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
padding-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
}
```
To control this behavior, use the `insetsHandling` configuration setting.
## Example
```typescript
import { SystemBars, SystemBarsStyle, SystemBarType } from '@capacitor/core';
const setSystemBarStyleDark = async () => {
await SystemBars.setStyle({ style: SystemBarsStyle.Dark });
};
const setSystemBarStyleLight = async () => {
await SystemBars.setStyle({ style: SystemBarsStyle.Light });
};
const hideSystemBars = async () => {
await SystemBars.hide();
};
const showSystemBars = async () => {
await SystemBars.show();
};
const hideNavigationBar = async () => {
await SystemBars.hide({
bar: SystemBarType.NavigationBar
})
}
// Set the Status Bar animation, only on iOS
const setStatusBarAnimation = async () => {
await SystemBars.setAnimation({ animation: "NONE" });
}
````
## Configuration
| Prop | Type | Description | Default |
| ------------- | -------------------- | ------------------------------------------------------------------------- | ------------------ |
| **`insetsHandling`** | <code>string</code> | Specifies how to handle problematic insets on Android. This option is only supported on Android.<br>`css` = Injects CSS variables (`--safe-area-inset-*`) containing correct safe area inset values into the webview.<br>`disable` = Disable CSS variables injection. | <code>css</code> |
| **`style`** | <code>string</code> | The style of the text and icons of the system bars. | <code>DEFAULT</code> |
| **`hidden`** | <code>boolean</code> | Hide the system bars on start. | <code>false</code> |
| **`animation`** | <code>string</code> | The type of status bar animation used when showing or hiding. This option is only supported on iOS. | <code>FADE</code> |
### Example Configuration
In `capacitor.config.json`:
```json
{
"plugins": {
"SystemBars": {
"insetsHandling": "css",
"style": "DARK",
"hidden": false,
"animation": "NONE"
}
}
}
```
In `capacitor.config.ts`:
```ts
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
plugins: {
SystemBars: {
insetsHandling: "css",
style: "DARK",
hidden: false,
animation: "NONE"
},
},
};
export default config;
```
## API
<docgen-index>
* [`setStyle(...)`](#setstyle)
* [`show(...)`](#show)
* [`hide(...)`](#hide)
* [`setAnimation(...)`](#setanimation)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
* [Enums](#enums)
</docgen-index>
<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
### setStyle(...)
```typescript
setStyle(options: SystemBarsStyleOptions) => Promise<void>
```
Set the current style of the system bars.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| **`options`** | <code><a href="#systembarsstyleoptions">SystemBarsStyleOptions</a></code> |
**Since:** 8.0.0
--------------------
### show(...)
```typescript
show(options?: SystemBarsVisibilityOptions) => Promise<void>
```
Show the system bars.
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------- |
| **`options`** | <code><a href="#systembarsvisibilityoptions">SystemBarsVisibilityOptions</a></code> |
**Since:** 8.0.0
--------------------
### hide(...)
```typescript
hide(options?: SystemBarsVisibilityOptions) => Promise<void>
```
Hide the system bars.
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------- |
| **`options`** | <code><a href="#systembarsvisibilityoptions">SystemBarsVisibilityOptions</a></code> |
**Since:** 8.0.0
--------------------
### setAnimation(...)
```typescript
setAnimation(options: SystemBarsAnimationOptions) => Promise<void>
```
Set the animation to use when showing / hiding the status bar.
Only available on iOS.
| Param | Type |
| ------------- | --------------------------------------------------------------------------------- |
| **`options`** | <code><a href="#systembarsanimationoptions">SystemBarsAnimationOptions</a></code> |
**Since:** 8.0.0
--------------------
### Interfaces
#### SystemBarsStyleOptions
| Prop | Type | Description | Default | Since |
| ----------- | ----------------------------------------------------------- | ----------------------------------------------- | ---------------------- | ----- |
| **`style`** | <code><a href="#systembarsstyle">SystemBarsStyle</a></code> | Style of the text and icons of the system bars. | <code>'DEFAULT'</code> | 8.0.0 |
| **`bar`** | <code><a href="#systembartype">SystemBarType</a></code> | The system bar to which to apply the style. | <code>null</code> | 8.0.0 |
#### SystemBarsVisibilityOptions
| Prop | Type | Description | Default | Since |
| --------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ------------------- | ----- |
| **`bar`** | <code><a href="#systembartype">SystemBarType</a></code> | The system bar to hide or show. | <code>null</code> | 8.0.0 |
| **`animation`** | <code><a href="#systembarsanimation">SystemBarsAnimation</a></code> | The type of status bar animation used when showing or hiding. This option is only supported on iOS. | <code>'FADE'</code> | 8.0.0 |
#### SystemBarsAnimationOptions
| Prop | Type | Description | Default | Since |
| --------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ------------------- | ----- |
| **`animation`** | <code><a href="#systembarsanimation">SystemBarsAnimation</a></code> | The type of status bar animation used when showing or hiding. This option is only supported on iOS. | <code>'FADE'</code> | 8.0.0 |
### Type Aliases
#### SystemBarsAnimation
Available status bar animations. iOS only.
<code>'FADE' | 'NONE'</code>
### Enums
#### SystemBarsStyle
| Members | Value | Description | Since |
| ------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----- |
| **`Dark`** | <code>'DARK'</code> | Light system bar content on a dark background. | 8.0.0 |
| **`Light`** | <code>'LIGHT'</code> | For dark system bar content on a light background. | 8.0.0 |
| **`Default`** | <code>'DEFAULT'</code> | The style is based on the device appearance or the underlying content. If the device is using Dark mode, the system bars content will be light. If the device is using Light mode, the system bars content will be dark. | 8.0.0 |
#### SystemBarType
| Members | Value | Description | Since |
| ------------------- | ---------------------------- | ------------------------------------------------------------------- | ----- |
| **`StatusBar`** | <code>'StatusBar'</code> | The top status bar on both Android and iOS. | 8.0.0 |
| **`NavigationBar`** | <code>'NavigationBar'</code> | The navigation bar (or gesture bar on iOS) on both Android and iOS. | 8.0.0 |
</docgen-api>

View file

@ -0,0 +1,372 @@
import type { Plugin } from './definitions';
import { WebPlugin } from './web-plugin';
/******** WEB VIEW PLUGIN ********/
export interface WebViewPlugin extends Plugin {
setServerAssetPath(options: WebViewPath): Promise<void>;
setServerBasePath(options: WebViewPath): Promise<void>;
getServerBasePath(): Promise<WebViewPath>;
persistServerBasePath(): Promise<void>;
}
export interface WebViewPath {
path: string;
}
export declare const WebView: WebViewPlugin;
export interface CapacitorCookiesPlugin {
getCookies(options?: GetCookieOptions): Promise<HttpCookieMap>;
/**
* Write a cookie to the device.
*/
setCookie(options: SetCookieOptions): Promise<void>;
/**
* Delete a cookie from the device.
*/
deleteCookie(options: DeleteCookieOptions): Promise<void>;
/**
* Clear cookies from the device at a given URL.
*/
clearCookies(options: ClearCookieOptions): Promise<void>;
/**
* Clear all cookies on the device.
*/
clearAllCookies(): Promise<void>;
}
interface HttpCookie {
/**
* The URL of the cookie.
*/
url?: string;
/**
* The key of the cookie.
*/
key: string;
/**
* The value of the cookie.
*/
value: string;
}
interface HttpCookieMap {
[key: string]: string;
}
interface HttpCookieExtras {
/**
* The path to write the cookie to.
*/
path?: string;
/**
* The date to expire the cookie.
*/
expires?: string;
}
export type GetCookieOptions = Omit<HttpCookie, 'key' | 'value'>;
export type SetCookieOptions = HttpCookie & HttpCookieExtras;
export type DeleteCookieOptions = Omit<HttpCookie, 'value'>;
export type ClearCookieOptions = Omit<HttpCookie, 'key' | 'value'>;
export declare class CapacitorCookiesPluginWeb extends WebPlugin implements CapacitorCookiesPlugin {
getCookies(): Promise<HttpCookieMap>;
setCookie(options: SetCookieOptions): Promise<void>;
deleteCookie(options: DeleteCookieOptions): Promise<void>;
clearCookies(): Promise<void>;
clearAllCookies(): Promise<void>;
}
export declare const CapacitorCookies: CapacitorCookiesPlugin;
/******** END COOKIES PLUGIN ********/
/******** HTTP PLUGIN ********/
export interface CapacitorHttpPlugin {
/**
* Make a Http Request to a server using native libraries.
*/
request(options: HttpOptions): Promise<HttpResponse>;
/**
* Make a Http GET Request to a server using native libraries.
*/
get(options: HttpOptions): Promise<HttpResponse>;
/**
* Make a Http POST Request to a server using native libraries.
*/
post(options: HttpOptions): Promise<HttpResponse>;
/**
* Make a Http PUT Request to a server using native libraries.
*/
put(options: HttpOptions): Promise<HttpResponse>;
/**
* Make a Http PATCH Request to a server using native libraries.
*/
patch(options: HttpOptions): Promise<HttpResponse>;
/**
* Make a Http DELETE Request to a server using native libraries.
*/
delete(options: HttpOptions): Promise<HttpResponse>;
}
/**
* How to parse the Http response before returning it to the client.
*/
export type HttpResponseType = 'arraybuffer' | 'blob' | 'json' | 'text' | 'document';
export interface HttpOptions {
/**
* The URL to send the request to.
*/
url: string;
/**
* The Http Request method to run. (Default is GET)
*/
method?: string;
/**
* URL parameters to append to the request.
*/
params?: HttpParams;
/**
* Note: On Android and iOS, data can only be a string or a JSON.
* FormData, Blob, ArrayBuffer, and other complex types are only directly supported on web
* or through enabling `CapacitorHttp` in the config and using the patched `window.fetch` or `XMLHttpRequest`.
*
* If you need to send a complex type, you should serialize the data to base64
* and set the `headers["Content-Type"]` and `dataType` attributes accordingly.
*/
data?: any;
/**
* Http Request headers to send with the request.
*/
headers?: HttpHeaders;
/**
* How long to wait to read additional data in milliseconds.
* Resets each time new data is received.
*/
readTimeout?: number;
/**
* How long to wait for the initial connection in milliseconds.
*/
connectTimeout?: number;
/**
* Sets whether automatic HTTP redirects should be disabled
*/
disableRedirects?: boolean;
/**
* Extra arguments for fetch when running on the web
*/
webFetchExtra?: RequestInit;
/**
* This is used to parse the response appropriately before returning it to
* the requestee. If the response content-type is "json", this value is ignored.
*/
responseType?: HttpResponseType;
/**
* Use this option if you need to keep the URL unencoded in certain cases
* (already encoded, azure/firebase testing, etc.). The default is _true_.
*/
shouldEncodeUrlParams?: boolean;
/**
* This is used if we've had to convert the data from a JS type that needs
* special handling in the native layer
*/
dataType?: 'file' | 'formData';
}
export interface HttpParams {
/**
* A key/value dictionary of URL parameters to set.
*/
[key: string]: string | string[];
}
export interface HttpHeaders {
/**
* A key/value dictionary of Http headers.
*/
[key: string]: string;
}
export interface HttpResponse {
/**
* Additional data received with the Http response.
*/
data: any;
/**
* The status code received from the Http response.
*/
status: number;
/**
* The headers received from the Http response.
*/
headers: HttpHeaders;
/**
* The response URL received from the Http response.
*/
url: string;
}
/**
* Read in a Blob value and return it as a base64 string
* @param blob The blob value to convert to a base64 string
*/
export declare const readBlobAsBase64: (blob: Blob) => Promise<string>;
/**
* Build the RequestInit object based on the options passed into the initial request
* @param options The Http plugin options
* @param extra Any extra RequestInit values
*/
export declare const buildRequestInit: (options: HttpOptions, extra?: RequestInit) => RequestInit;
export declare class CapacitorHttpPluginWeb extends WebPlugin implements CapacitorHttpPlugin {
/**
* Perform an Http request given a set of options
* @param options Options to build the HTTP request
*/
request(options: HttpOptions): Promise<HttpResponse>;
/**
* Perform an Http GET request given a set of options
* @param options Options to build the HTTP request
*/
get(options: HttpOptions): Promise<HttpResponse>;
/**
* Perform an Http POST request given a set of options
* @param options Options to build the HTTP request
*/
post(options: HttpOptions): Promise<HttpResponse>;
/**
* Perform an Http PUT request given a set of options
* @param options Options to build the HTTP request
*/
put(options: HttpOptions): Promise<HttpResponse>;
/**
* Perform an Http PATCH request given a set of options
* @param options Options to build the HTTP request
*/
patch(options: HttpOptions): Promise<HttpResponse>;
/**
* Perform an Http DELETE request given a set of options
* @param options Options to build the HTTP request
*/
delete(options: HttpOptions): Promise<HttpResponse>;
}
export declare const CapacitorHttp: CapacitorHttpPlugin;
/******** END HTTP PLUGIN ********/
/******** SYSTEM BARS PLUGIN ********/
/**
* Available status bar styles.
*/
export declare enum SystemBarsStyle {
/**
* Light system bar content on a dark background.
*
* @since 8.0.0
*/
Dark = "DARK",
/**
* For dark system bar content on a light background.
*
* @since 8.0.0
*/
Light = "LIGHT",
/**
* The style is based on the device appearance or the underlying content.
* If the device is using Dark mode, the system bars content will be light.
* If the device is using Light mode, the system bars content will be dark.
*
* @since 8.0.0
*/
Default = "DEFAULT"
}
/**
* Available status bar animations. iOS only.
*/
export type SystemBarsAnimation = 'FADE' | 'NONE';
/**
* Available system bar types.
*/
export declare enum SystemBarType {
/**
* The top status bar on both Android and iOS.
*
* @since 8.0.0
*/
StatusBar = "StatusBar",
/**
* The navigation bar (or gesture bar on iOS) on both Android and iOS.
*
* @since 8.0.0
*/
NavigationBar = "NavigationBar"
}
export interface SystemBarsStyleOptions {
/**
* Style of the text and icons of the system bars.
*
* @since 8.0.0
* @default 'DEFAULT'
* @example "DARK"
*/
style: SystemBarsStyle;
/**
* The system bar to which to apply the style.
*
*
* @since 8.0.0
* @default null
* @example SystemBarType.StatusBar
*/
bar?: SystemBarType;
}
export interface SystemBarsVisibilityOptions {
/**
* The system bar to hide or show.
*
* @since 8.0.0
* @default null
* @example SystemBarType.StatusBar
*/
bar?: SystemBarType;
/**
* The type of status bar animation used when showing or hiding.
*
* This option is only supported on iOS.
*
* @default 'FADE'
*
* @since 8.0.0
*/
animation?: SystemBarsAnimation;
}
export interface SystemBarsAnimationOptions {
/**
* The type of status bar animation used when showing or hiding.
*
* This option is only supported on iOS.
*
* @default 'FADE'
*
* @since 8.0.0
*/
animation: SystemBarsAnimation;
}
export interface SystemBarsPlugin {
/**
* Set the current style of the system bars.
*
* @since 8.0.0
*/
setStyle(options: SystemBarsStyleOptions): Promise<void>;
/**
* Show the system bars.
*
* @since 8.0.0
*/
show(options?: SystemBarsVisibilityOptions): Promise<void>;
/**
* Hide the system bars.
*
* @since 8.0.0
*/
hide(options?: SystemBarsVisibilityOptions): Promise<void>;
/**
* Set the animation to use when showing / hiding the status bar.
*
* Only available on iOS.
*
* @since 8.0.0
*/
setAnimation(options: SystemBarsAnimationOptions): Promise<void>;
}
export declare class SystemBarsPluginWeb extends WebPlugin implements SystemBarsPlugin {
setStyle(): Promise<void>;
setAnimation(): Promise<void>;
show(): Promise<void>;
hide(): Promise<void>;
}
export declare const SystemBars: SystemBarsPlugin;
export {};
/******** END SYSTEM BARS PLUGIN ********/

View file

@ -0,0 +1,171 @@
import type { CapacitorGlobal, PluginCallback, PluginResultData, PluginResultError } from './definitions';
export interface PluginHeaderMethod {
readonly name: string;
readonly rtype?: 'promise' | 'callback';
}
export interface PluginHeader {
readonly name: string;
readonly methods: readonly PluginHeaderMethod[];
}
/**
* Has all instance properties that are available and used
* by the native layer. The "Capacitor" interface it extends
* is the public one.
*/
export interface CapacitorInstance extends CapacitorGlobal {
/**
* Internal registry for all plugins assigned to the Capacitor global.
* Legacy Capacitor referenced this property directly, but as of v3
* it should be an internal API. Still exporting on the Capacitor
* type, but with the deprecated JSDoc tag.
*/
Plugins: {
[pluginName: string]: {
[prop: string]: any;
};
};
PluginHeaders?: readonly PluginHeader[];
/**
* Gets the WebView server urls set by the native web view. Defaults
* to "" if not running from a native platform.
*/
getServerUrl: () => string;
/**
* Low-level API to send data to the native layer.
* Prefer using `nativeCallback()` or `nativePromise()` instead.
* Returns the Callback Id.
*/
toNative?: (pluginName: string, methodName: string, options: any, storedCallback?: StoredCallback) => string;
/**
* Sends data over the bridge to the native layer.
* Returns the Callback Id.
*/
nativeCallback: <O>(pluginName: string, methodName: string, options?: O, callback?: PluginCallback) => string;
/**
* Sends data over the bridge to the native layer and
* resolves the promise when it receives the data from
* the native implementation.
*/
nativePromise: <O, R>(pluginName: string, methodName: string, options?: O) => Promise<R>;
/**
* Low-level API used by the native layers to send
* data back to the webview runtime.
*/
fromNative?: (result: PluginResult) => void;
/**
* Low-level API for backwards compatibility.
*/
createEvent?: (eventName: string, eventData?: any) => Event;
/**
* Low-level API triggered from native implementations.
*/
triggerEvent?: (eventName: string, target: string, eventData?: any) => boolean;
handleError: (err: Error) => void;
handleWindowError: (msg: string | Event, url: string, lineNo: number, columnNo: number, err: Error) => void;
/**
* Low-level API used by the native bridge to log messages.
*/
logJs: (message: string, level: 'error' | 'warn' | 'info' | 'log') => void;
logToNative: (data: MessageCallData) => void;
logFromNative: (results: PluginResult) => void;
/**
* Low-level API used by the native bridge.
*/
withPlugin?: (pluginName: string, fn: (...args: any[]) => any) => void;
}
export interface MessageCallData {
type?: 'message';
callbackId: string;
pluginId: string;
methodName: string;
options: any;
}
export interface ErrorCallData {
type: 'js.error';
error: {
message: string;
url: string;
line: number;
col: number;
errorObject: string;
};
}
export type CallData = MessageCallData | ErrorCallData;
/**
* A resulting call back from the native layer.
*/
export interface PluginResult {
callbackId?: string;
methodName?: string;
data: PluginResultData;
success: boolean;
error?: PluginResultError;
pluginId?: string;
save?: boolean;
}
/**
* Callback data kept on the client
* to be called after native response
*/
export interface StoredCallback {
callback?: PluginCallback;
resolve?: (...args: any[]) => any;
reject?: (...args: any[]) => any;
}
export interface CapacitorCustomPlatformInstance {
name: string;
plugins: {
[pluginName: string]: any;
};
}
export interface WindowCapacitor {
Capacitor?: CapacitorInstance;
CapacitorSystemBarsAndroidInterface?: any;
CapacitorCookiesAndroidInterface?: any;
CapacitorCookiesDescriptor?: PropertyDescriptor;
CapacitorHttpAndroidInterface?: any;
CapacitorWebFetch?: any;
CapacitorWebXMLHttpRequest?: any;
CapacitorCustomPlatform?: CapacitorCustomPlatformInstance;
Ionic?: {
WebView?: {
getServerBasePath?: any;
setServerBasePath?: any;
setServerAssetPath?: any;
persistServerBasePath?: any;
convertFileSrc?: any;
};
};
WEBVIEW_SERVER_URL?: string;
androidBridge?: {
postMessage(data: string): void;
onmessage?: (event: {
data: string;
}) => void;
};
webkit?: {
messageHandlers?: {
bridge: {
postMessage(data: any): void;
};
};
};
console?: Console;
cordova?: {
fireDocumentEvent?: (eventName: string, eventData: any) => void;
};
dispatchEvent?: any;
document?: any;
navigator?: {
app?: {
exitApp?: () => void;
};
};
}
export interface CapFormDataEntry {
key: string;
value: string;
type: 'base64File' | 'string';
contentType?: string;
fileName?: string;
}

View file

@ -0,0 +1,76 @@
import type { CapacitorException } from './util';
export interface CapacitorGlobal {
/**
* The Exception class used when generating plugin Exceptions
* from bridge calls.
*/
Exception: typeof CapacitorException;
/**
* Utility function to convert a file path into a usable src depending
* on the native WebView implementation value and environment.
*/
convertFileSrc: (filePath: string) => string;
/**
* Gets the name of the platform, such as `android`, `ios`, or `web`.
*/
getPlatform: () => string;
/**
* Boolean if the platform is native or not. `android` and `ios`
* would return `true`, otherwise `false`.
*/
isNativePlatform: () => boolean;
/**
* Used to check if a platform is registered and available.
*/
isPluginAvailable: (name: string) => boolean;
registerPlugin: RegisterPlugin;
/**
* Add a listener for a plugin event.
*/
addListener?: (pluginName: string, eventName: string, callback: PluginCallback) => PluginListenerHandle;
/**
* Remove a listener to a plugin event.
*/
removeListener?: (pluginName: string, callbackId: string, eventName: string, callback: PluginCallback) => void;
DEBUG?: boolean;
isLoggingEnabled?: boolean;
}
/**
* Register plugin implementations with Capacitor.
*
* This function will create and register an instance that contains the
* implementations of the plugin.
*
* Each plugin has multiple implementations, one per platform. Each
* implementation must adhere to a common interface to ensure client code
* behaves consistently across each platform.
*
* @param pluginName The unique CamelCase name of this plugin.
* @param implementations The map of plugin implementations.
*/
export type RegisterPlugin = <T>(pluginName: string, implementations?: Readonly<PluginImplementations>) => T;
/**
* A map of plugin implementations.
*
* Each key should be the lowercased platform name as recognized by Capacitor,
* e.g. 'android', 'ios', and 'web'. Each value must be an instance of a plugin
* implementation for the respective platform.
*/
export type PluginImplementations = {
[platform: string]: (() => Promise<any>) | any;
};
export interface Plugin {
addListener(eventName: string, listenerFunc: (...args: any[]) => any): Promise<PluginListenerHandle>;
removeAllListeners(): Promise<void>;
}
export type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';
export interface PluginListenerHandle {
remove: () => Promise<void>;
}
export interface PluginResultData {
[key: string]: any;
}
export interface PluginResultError {
message: string;
}
export type PluginCallback = (data: PluginResultData, error?: PluginResultError) => void;

View file

@ -0,0 +1,2 @@
export declare const Capacitor: import("./definitions").CapacitorGlobal;
export declare const registerPlugin: import("./definitions").RegisterPlugin;

View file

@ -0,0 +1,6 @@
export type { CapacitorGlobal, PermissionState, Plugin, PluginCallback, PluginImplementations, PluginListenerHandle, PluginResultData, PluginResultError, } from './definitions';
export { Capacitor, registerPlugin } from './global';
export { WebPlugin, ListenerCallback } from './web-plugin';
export { SystemBars, SystemBarType, SystemBarsStyle, SystemBarsAnimation, CapacitorCookies, CapacitorHttp, WebView, buildRequestInit, } from './core-plugins';
export type { ClearCookieOptions, DeleteCookieOptions, SetCookieOptions, HttpHeaders, HttpOptions, HttpParams, HttpResponse, HttpResponseType, WebViewPath, WebViewPlugin, SystemBarsVisibilityOptions, SystemBarsStyleOptions, } from './core-plugins';
export { CapacitorException, ExceptionCode } from './util';

View file

@ -0,0 +1,9 @@
import type { CapacitorGlobal } from './definitions';
import type { CapacitorInstance, WindowCapacitor } from './definitions-internal';
export interface RegisteredPlugin {
readonly name: string;
readonly proxy: any;
readonly platforms: ReadonlySet<string>;
}
export declare const createCapacitor: (win: WindowCapacitor) => CapacitorInstance;
export declare const initCapacitorGlobal: (win: any) => CapacitorGlobal;

28
electron/node_modules/@capacitor/core/types/util.d.ts generated vendored Normal file
View file

@ -0,0 +1,28 @@
import type { WindowCapacitor } from './definitions-internal';
export declare enum ExceptionCode {
/**
* API is not implemented.
*
* This usually means the API can't be used because it is not implemented for
* the current platform.
*/
Unimplemented = "UNIMPLEMENTED",
/**
* API is not available.
*
* This means the API can't be used right now because:
* - it is currently missing a prerequisite, such as network connectivity
* - it requires a particular platform or browser version
*/
Unavailable = "UNAVAILABLE"
}
export interface ExceptionData {
[key: string]: any;
}
export declare class CapacitorException extends Error {
readonly message: string;
readonly code?: ExceptionCode;
readonly data?: ExceptionData;
constructor(message: string, code?: ExceptionCode, data?: ExceptionData);
}
export declare const getPlatformId: (win: WindowCapacitor) => 'android' | 'ios' | 'web';

View file

@ -0,0 +1,34 @@
import type { PluginListenerHandle, Plugin } from './definitions';
import type { CapacitorException } from './util';
/**
* Base class web plugins should extend.
*/
export declare class WebPlugin implements Plugin {
protected listeners: {
[eventName: string]: ListenerCallback[];
};
protected retainedEventArguments: {
[eventName: string]: any[];
};
protected windowListeners: {
[eventName: string]: WindowListenerHandle;
};
addListener(eventName: string, listenerFunc: ListenerCallback): Promise<PluginListenerHandle>;
removeAllListeners(): Promise<void>;
protected notifyListeners(eventName: string, data: any, retainUntilConsumed?: boolean): void;
protected hasListeners(eventName: string): boolean;
protected registerWindowListener(windowEventName: string, pluginEventName: string): void;
protected unimplemented(msg?: string): CapacitorException;
protected unavailable(msg?: string): CapacitorException;
private removeListener;
private addWindowListener;
private removeWindowListener;
private sendRetainedArgumentsForEvent;
}
export type ListenerCallback = (err: any, ...args: any[]) => void;
export interface WindowListenerHandle {
registered: boolean;
windowEventName: string;
pluginEventName: string;
handler: (event: any) => void;
}