Add capacitorjs runtime
This commit is contained in:
parent
d0ece489ee
commit
f90c0e6c40
8362 changed files with 1502407 additions and 1 deletions
21
node_modules/@capacitor/core/LICENSE
generated
vendored
Normal file
21
node_modules/@capacitor/core/LICENSE
generated
vendored
Normal 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
node_modules/@capacitor/core/README.md
generated
vendored
Normal file
3
node_modules/@capacitor/core/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Capacitor Core JS
|
||||
|
||||
See the [Capacitor website](https://capacitorjs.com) for more information.
|
||||
250
node_modules/@capacitor/core/cookies.md
generated
vendored
Normal file
250
node_modules/@capacitor/core/cookies.md
generated
vendored
Normal 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<<a href="#httpcookiemap">HttpCookieMap</a>></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><<a href="#httpcookie">HttpCookie</a>, 'key' | 'value'></code>
|
||||
|
||||
|
||||
#### Omit
|
||||
|
||||
Construct a type with the properties of T except for those in type K.
|
||||
|
||||
<code><a href="#pick">Pick</a><T, <a href="#exclude">Exclude</a><keyof T, K>></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><<a href="#httpcookie">HttpCookie</a>, 'value'></code>
|
||||
|
||||
|
||||
#### ClearCookieOptions
|
||||
|
||||
<code><a href="#omit">Omit</a><<a href="#httpcookie">HttpCookie</a>, 'key' | 'value'></code>
|
||||
|
||||
</docgen-api>
|
||||
1559
node_modules/@capacitor/core/cordova.js
generated
vendored
Normal file
1559
node_modules/@capacitor/core/cordova.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
3
node_modules/@capacitor/core/dist/capacitor.js
generated
vendored
Normal file
3
node_modules/@capacitor/core/dist/capacitor.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@capacitor/core/dist/capacitor.js.map
generated
vendored
Normal file
1
node_modules/@capacitor/core/dist/capacitor.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
658
node_modules/@capacitor/core/dist/index.cjs.js
generated
vendored
Normal file
658
node_modules/@capacitor/core/dist/index.cjs.js
generated
vendored
Normal file
|
|
@ -0,0 +1,658 @@
|
|||
/*! Capacitor: https://capacitorjs.com/ - MIT License */
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
exports.ExceptionCode = void 0;
|
||||
(function (ExceptionCode) {
|
||||
/**
|
||||
* API is not implemented.
|
||||
*
|
||||
* This usually means the API can't be used because it is not implemented for
|
||||
* the current platform.
|
||||
*/
|
||||
ExceptionCode["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
|
||||
*/
|
||||
ExceptionCode["Unavailable"] = "UNAVAILABLE";
|
||||
})(exports.ExceptionCode || (exports.ExceptionCode = {}));
|
||||
class CapacitorException extends Error {
|
||||
constructor(message, code, data) {
|
||||
super(message);
|
||||
this.message = message;
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
const getPlatformId = (win) => {
|
||||
var _a, _b;
|
||||
if (win === null || win === void 0 ? void 0 : win.androidBridge) {
|
||||
return 'android';
|
||||
}
|
||||
else if ((_b = (_a = win === null || win === void 0 ? void 0 : win.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.bridge) {
|
||||
return 'ios';
|
||||
}
|
||||
else {
|
||||
return 'web';
|
||||
}
|
||||
};
|
||||
|
||||
const createCapacitor = (win) => {
|
||||
const capCustomPlatform = win.CapacitorCustomPlatform || null;
|
||||
const cap = win.Capacitor || {};
|
||||
const Plugins = (cap.Plugins = cap.Plugins || {});
|
||||
const getPlatform = () => {
|
||||
return capCustomPlatform !== null ? capCustomPlatform.name : getPlatformId(win);
|
||||
};
|
||||
const isNativePlatform = () => getPlatform() !== 'web';
|
||||
const isPluginAvailable = (pluginName) => {
|
||||
const plugin = registeredPlugins.get(pluginName);
|
||||
if (plugin === null || plugin === void 0 ? void 0 : plugin.platforms.has(getPlatform())) {
|
||||
// JS implementation available for the current platform.
|
||||
return true;
|
||||
}
|
||||
if (getPluginHeader(pluginName)) {
|
||||
// Native implementation available.
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const getPluginHeader = (pluginName) => { var _a; return (_a = cap.PluginHeaders) === null || _a === void 0 ? void 0 : _a.find((h) => h.name === pluginName); };
|
||||
const handleError = (err) => win.console.error(err);
|
||||
const registeredPlugins = new Map();
|
||||
const registerPlugin = (pluginName, jsImplementations = {}) => {
|
||||
const registeredPlugin = registeredPlugins.get(pluginName);
|
||||
if (registeredPlugin) {
|
||||
console.warn(`Capacitor plugin "${pluginName}" already registered. Cannot register plugins twice.`);
|
||||
return registeredPlugin.proxy;
|
||||
}
|
||||
const platform = getPlatform();
|
||||
const pluginHeader = getPluginHeader(pluginName);
|
||||
let jsImplementation;
|
||||
const loadPluginImplementation = async () => {
|
||||
if (!jsImplementation && platform in jsImplementations) {
|
||||
jsImplementation =
|
||||
typeof jsImplementations[platform] === 'function'
|
||||
? (jsImplementation = await jsImplementations[platform]())
|
||||
: (jsImplementation = jsImplementations[platform]);
|
||||
}
|
||||
else if (capCustomPlatform !== null && !jsImplementation && 'web' in jsImplementations) {
|
||||
jsImplementation =
|
||||
typeof jsImplementations['web'] === 'function'
|
||||
? (jsImplementation = await jsImplementations['web']())
|
||||
: (jsImplementation = jsImplementations['web']);
|
||||
}
|
||||
return jsImplementation;
|
||||
};
|
||||
const createPluginMethod = (impl, prop) => {
|
||||
var _a, _b;
|
||||
if (pluginHeader) {
|
||||
const methodHeader = pluginHeader === null || pluginHeader === void 0 ? void 0 : pluginHeader.methods.find((m) => prop === m.name);
|
||||
if (methodHeader) {
|
||||
if (methodHeader.rtype === 'promise') {
|
||||
return (options) => cap.nativePromise(pluginName, prop.toString(), options);
|
||||
}
|
||||
else {
|
||||
return (options, callback) => cap.nativeCallback(pluginName, prop.toString(), options, callback);
|
||||
}
|
||||
}
|
||||
else if (impl) {
|
||||
return (_a = impl[prop]) === null || _a === void 0 ? void 0 : _a.bind(impl);
|
||||
}
|
||||
}
|
||||
else if (impl) {
|
||||
return (_b = impl[prop]) === null || _b === void 0 ? void 0 : _b.bind(impl);
|
||||
}
|
||||
else {
|
||||
throw new CapacitorException(`"${pluginName}" plugin is not implemented on ${platform}`, exports.ExceptionCode.Unimplemented);
|
||||
}
|
||||
};
|
||||
const createPluginMethodWrapper = (prop) => {
|
||||
let remove;
|
||||
const wrapper = (...args) => {
|
||||
const p = loadPluginImplementation().then((impl) => {
|
||||
const fn = createPluginMethod(impl, prop);
|
||||
if (fn) {
|
||||
const p = fn(...args);
|
||||
remove = p === null || p === void 0 ? void 0 : p.remove;
|
||||
return p;
|
||||
}
|
||||
else {
|
||||
throw new CapacitorException(`"${pluginName}.${prop}()" is not implemented on ${platform}`, exports.ExceptionCode.Unimplemented);
|
||||
}
|
||||
});
|
||||
if (prop === 'addListener') {
|
||||
p.remove = async () => remove();
|
||||
}
|
||||
return p;
|
||||
};
|
||||
// Some flair ✨
|
||||
wrapper.toString = () => `${prop.toString()}() { [capacitor code] }`;
|
||||
Object.defineProperty(wrapper, 'name', {
|
||||
value: prop,
|
||||
writable: false,
|
||||
configurable: false,
|
||||
});
|
||||
return wrapper;
|
||||
};
|
||||
const addListener = createPluginMethodWrapper('addListener');
|
||||
const removeListener = createPluginMethodWrapper('removeListener');
|
||||
const addListenerNative = (eventName, callback) => {
|
||||
const call = addListener({ eventName }, callback);
|
||||
const remove = async () => {
|
||||
const callbackId = await call;
|
||||
removeListener({
|
||||
eventName,
|
||||
callbackId,
|
||||
}, callback);
|
||||
};
|
||||
const p = new Promise((resolve) => call.then(() => resolve({ remove })));
|
||||
p.remove = async () => {
|
||||
console.warn(`Using addListener() without 'await' is deprecated.`);
|
||||
await remove();
|
||||
};
|
||||
return p;
|
||||
};
|
||||
const proxy = new Proxy({}, {
|
||||
get(_, prop) {
|
||||
switch (prop) {
|
||||
// https://github.com/facebook/react/issues/20030
|
||||
case '$$typeof':
|
||||
return undefined;
|
||||
case 'toJSON':
|
||||
return () => ({});
|
||||
case 'addListener':
|
||||
return pluginHeader ? addListenerNative : addListener;
|
||||
case 'removeListener':
|
||||
return removeListener;
|
||||
default:
|
||||
return createPluginMethodWrapper(prop);
|
||||
}
|
||||
},
|
||||
});
|
||||
Plugins[pluginName] = proxy;
|
||||
registeredPlugins.set(pluginName, {
|
||||
name: pluginName,
|
||||
proxy,
|
||||
platforms: new Set([...Object.keys(jsImplementations), ...(pluginHeader ? [platform] : [])]),
|
||||
});
|
||||
return proxy;
|
||||
};
|
||||
// Add in convertFileSrc for web, it will already be available in native context
|
||||
if (!cap.convertFileSrc) {
|
||||
cap.convertFileSrc = (filePath) => filePath;
|
||||
}
|
||||
cap.getPlatform = getPlatform;
|
||||
cap.handleError = handleError;
|
||||
cap.isNativePlatform = isNativePlatform;
|
||||
cap.isPluginAvailable = isPluginAvailable;
|
||||
cap.registerPlugin = registerPlugin;
|
||||
cap.Exception = CapacitorException;
|
||||
cap.DEBUG = !!cap.DEBUG;
|
||||
cap.isLoggingEnabled = !!cap.isLoggingEnabled;
|
||||
return cap;
|
||||
};
|
||||
const initCapacitorGlobal = (win) => (win.Capacitor = createCapacitor(win));
|
||||
|
||||
const Capacitor = /*#__PURE__*/ initCapacitorGlobal(typeof globalThis !== 'undefined'
|
||||
? globalThis
|
||||
: typeof self !== 'undefined'
|
||||
? self
|
||||
: typeof window !== 'undefined'
|
||||
? window
|
||||
: typeof global !== 'undefined'
|
||||
? global
|
||||
: {});
|
||||
const registerPlugin = Capacitor.registerPlugin;
|
||||
|
||||
/**
|
||||
* Base class web plugins should extend.
|
||||
*/
|
||||
class WebPlugin {
|
||||
constructor() {
|
||||
this.listeners = {};
|
||||
this.retainedEventArguments = {};
|
||||
this.windowListeners = {};
|
||||
}
|
||||
addListener(eventName, listenerFunc) {
|
||||
let firstListener = false;
|
||||
const listeners = this.listeners[eventName];
|
||||
if (!listeners) {
|
||||
this.listeners[eventName] = [];
|
||||
firstListener = true;
|
||||
}
|
||||
this.listeners[eventName].push(listenerFunc);
|
||||
// If we haven't added a window listener for this event and it requires one,
|
||||
// go ahead and add it
|
||||
const windowListener = this.windowListeners[eventName];
|
||||
if (windowListener && !windowListener.registered) {
|
||||
this.addWindowListener(windowListener);
|
||||
}
|
||||
if (firstListener) {
|
||||
this.sendRetainedArgumentsForEvent(eventName);
|
||||
}
|
||||
const remove = async () => this.removeListener(eventName, listenerFunc);
|
||||
const p = Promise.resolve({ remove });
|
||||
return p;
|
||||
}
|
||||
async removeAllListeners() {
|
||||
this.listeners = {};
|
||||
for (const listener in this.windowListeners) {
|
||||
this.removeWindowListener(this.windowListeners[listener]);
|
||||
}
|
||||
this.windowListeners = {};
|
||||
}
|
||||
notifyListeners(eventName, data, retainUntilConsumed) {
|
||||
const listeners = this.listeners[eventName];
|
||||
if (!listeners) {
|
||||
if (retainUntilConsumed) {
|
||||
let args = this.retainedEventArguments[eventName];
|
||||
if (!args) {
|
||||
args = [];
|
||||
}
|
||||
args.push(data);
|
||||
this.retainedEventArguments[eventName] = args;
|
||||
}
|
||||
return;
|
||||
}
|
||||
listeners.forEach((listener) => listener(data));
|
||||
}
|
||||
hasListeners(eventName) {
|
||||
var _a;
|
||||
return !!((_a = this.listeners[eventName]) === null || _a === void 0 ? void 0 : _a.length);
|
||||
}
|
||||
registerWindowListener(windowEventName, pluginEventName) {
|
||||
this.windowListeners[pluginEventName] = {
|
||||
registered: false,
|
||||
windowEventName,
|
||||
pluginEventName,
|
||||
handler: (event) => {
|
||||
this.notifyListeners(pluginEventName, event);
|
||||
},
|
||||
};
|
||||
}
|
||||
unimplemented(msg = 'not implemented') {
|
||||
return new Capacitor.Exception(msg, exports.ExceptionCode.Unimplemented);
|
||||
}
|
||||
unavailable(msg = 'not available') {
|
||||
return new Capacitor.Exception(msg, exports.ExceptionCode.Unavailable);
|
||||
}
|
||||
async removeListener(eventName, listenerFunc) {
|
||||
const listeners = this.listeners[eventName];
|
||||
if (!listeners) {
|
||||
return;
|
||||
}
|
||||
const index = listeners.indexOf(listenerFunc);
|
||||
this.listeners[eventName].splice(index, 1);
|
||||
// If there are no more listeners for this type of event,
|
||||
// remove the window listener
|
||||
if (!this.listeners[eventName].length) {
|
||||
this.removeWindowListener(this.windowListeners[eventName]);
|
||||
}
|
||||
}
|
||||
addWindowListener(handle) {
|
||||
window.addEventListener(handle.windowEventName, handle.handler);
|
||||
handle.registered = true;
|
||||
}
|
||||
removeWindowListener(handle) {
|
||||
if (!handle) {
|
||||
return;
|
||||
}
|
||||
window.removeEventListener(handle.windowEventName, handle.handler);
|
||||
handle.registered = false;
|
||||
}
|
||||
sendRetainedArgumentsForEvent(eventName) {
|
||||
const args = this.retainedEventArguments[eventName];
|
||||
if (!args) {
|
||||
return;
|
||||
}
|
||||
delete this.retainedEventArguments[eventName];
|
||||
args.forEach((arg) => {
|
||||
this.notifyListeners(eventName, arg);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const WebView = /*#__PURE__*/ registerPlugin('WebView');
|
||||
/******** END WEB VIEW PLUGIN ********/
|
||||
/******** COOKIES PLUGIN ********/
|
||||
/**
|
||||
* Safely web encode a string value (inspired by js-cookie)
|
||||
* @param str The string value to encode
|
||||
*/
|
||||
const encode = (str) => encodeURIComponent(str)
|
||||
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
||||
.replace(/[()]/g, escape);
|
||||
/**
|
||||
* Safely web decode a string value (inspired by js-cookie)
|
||||
* @param str The string value to decode
|
||||
*/
|
||||
const decode = (str) => str.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
||||
class CapacitorCookiesPluginWeb extends WebPlugin {
|
||||
async getCookies() {
|
||||
const cookies = document.cookie;
|
||||
const cookieMap = {};
|
||||
cookies.split(';').forEach((cookie) => {
|
||||
if (cookie.length <= 0)
|
||||
return;
|
||||
// Replace first "=" with CAP_COOKIE to prevent splitting on additional "="
|
||||
let [key, value] = cookie.replace(/=/, 'CAP_COOKIE').split('CAP_COOKIE');
|
||||
key = decode(key).trim();
|
||||
value = decode(value).trim();
|
||||
cookieMap[key] = value;
|
||||
});
|
||||
return cookieMap;
|
||||
}
|
||||
async setCookie(options) {
|
||||
try {
|
||||
// Safely Encoded Key/Value
|
||||
const encodedKey = encode(options.key);
|
||||
const encodedValue = encode(options.value);
|
||||
// Clean & sanitize options
|
||||
const expires = options.expires ? `; expires=${options.expires.replace('expires=', '')}` : '';
|
||||
const path = (options.path || '/').replace('path=', ''); // Default is "path=/"
|
||||
const domain = options.url != null && options.url.length > 0 ? `domain=${options.url}` : '';
|
||||
document.cookie = `${encodedKey}=${encodedValue || ''}${expires}; path=${path}; ${domain};`;
|
||||
}
|
||||
catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
async deleteCookie(options) {
|
||||
try {
|
||||
document.cookie = `${options.key}=; Max-Age=0`;
|
||||
}
|
||||
catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
async clearCookies() {
|
||||
try {
|
||||
const cookies = document.cookie.split(';') || [];
|
||||
for (const cookie of cookies) {
|
||||
document.cookie = cookie.replace(/^ +/, '').replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
async clearAllCookies() {
|
||||
try {
|
||||
await this.clearCookies();
|
||||
}
|
||||
catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
const CapacitorCookies = registerPlugin('CapacitorCookies', {
|
||||
web: () => new CapacitorCookiesPluginWeb(),
|
||||
});
|
||||
// UTILITY FUNCTIONS
|
||||
/**
|
||||
* Read in a Blob value and return it as a base64 string
|
||||
* @param blob The blob value to convert to a base64 string
|
||||
*/
|
||||
const readBlobAsBase64 = async (blob) => new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
const base64String = reader.result;
|
||||
// remove prefix "data:application/pdf;base64,"
|
||||
resolve(base64String.indexOf(',') >= 0 ? base64String.split(',')[1] : base64String);
|
||||
};
|
||||
reader.onerror = (error) => reject(error);
|
||||
reader.readAsDataURL(blob);
|
||||
});
|
||||
/**
|
||||
* Normalize an HttpHeaders map by lowercasing all of the values
|
||||
* @param headers The HttpHeaders object to normalize
|
||||
*/
|
||||
const normalizeHttpHeaders = (headers = {}) => {
|
||||
const originalKeys = Object.keys(headers);
|
||||
const loweredKeys = Object.keys(headers).map((k) => k.toLocaleLowerCase());
|
||||
const normalized = loweredKeys.reduce((acc, key, index) => {
|
||||
acc[key] = headers[originalKeys[index]];
|
||||
return acc;
|
||||
}, {});
|
||||
return normalized;
|
||||
};
|
||||
/**
|
||||
* Builds a string of url parameters that
|
||||
* @param params A map of url parameters
|
||||
* @param shouldEncode true if you should encodeURIComponent() the values (true by default)
|
||||
*/
|
||||
const buildUrlParams = (params, shouldEncode = true) => {
|
||||
if (!params)
|
||||
return null;
|
||||
const output = Object.entries(params).reduce((accumulator, entry) => {
|
||||
const [key, value] = entry;
|
||||
let encodedValue;
|
||||
let item;
|
||||
if (Array.isArray(value)) {
|
||||
item = '';
|
||||
value.forEach((str) => {
|
||||
encodedValue = shouldEncode ? encodeURIComponent(str) : str;
|
||||
item += `${key}=${encodedValue}&`;
|
||||
});
|
||||
// last character will always be "&" so slice it off
|
||||
item.slice(0, -1);
|
||||
}
|
||||
else {
|
||||
encodedValue = shouldEncode ? encodeURIComponent(value) : value;
|
||||
item = `${key}=${encodedValue}`;
|
||||
}
|
||||
return `${accumulator}&${item}`;
|
||||
}, '');
|
||||
// Remove initial "&" from the reduce
|
||||
return output.substr(1);
|
||||
};
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
const buildRequestInit = (options, extra = {}) => {
|
||||
const output = Object.assign({ method: options.method || 'GET', headers: options.headers }, extra);
|
||||
// Get the content-type
|
||||
const headers = normalizeHttpHeaders(options.headers);
|
||||
const type = headers['content-type'] || '';
|
||||
// If body is already a string, then pass it through as-is.
|
||||
if (typeof options.data === 'string') {
|
||||
output.body = options.data;
|
||||
}
|
||||
// Build request initializers based off of content-type
|
||||
else if (type.includes('application/x-www-form-urlencoded')) {
|
||||
const params = new URLSearchParams();
|
||||
for (const [key, value] of Object.entries(options.data || {})) {
|
||||
params.set(key, value);
|
||||
}
|
||||
output.body = params.toString();
|
||||
}
|
||||
else if (type.includes('multipart/form-data') || options.data instanceof FormData) {
|
||||
const form = new FormData();
|
||||
if (options.data instanceof FormData) {
|
||||
options.data.forEach((value, key) => {
|
||||
form.append(key, value);
|
||||
});
|
||||
}
|
||||
else {
|
||||
for (const key of Object.keys(options.data)) {
|
||||
form.append(key, options.data[key]);
|
||||
}
|
||||
}
|
||||
output.body = form;
|
||||
const headers = new Headers(output.headers);
|
||||
headers.delete('content-type'); // content-type will be set by `window.fetch` to includy boundary
|
||||
output.headers = headers;
|
||||
}
|
||||
else if (type.includes('application/json') || typeof options.data === 'object') {
|
||||
output.body = JSON.stringify(options.data);
|
||||
}
|
||||
return output;
|
||||
};
|
||||
// WEB IMPLEMENTATION
|
||||
class CapacitorHttpPluginWeb extends WebPlugin {
|
||||
/**
|
||||
* Perform an Http request given a set of options
|
||||
* @param options Options to build the HTTP request
|
||||
*/
|
||||
async request(options) {
|
||||
const requestInit = buildRequestInit(options, options.webFetchExtra);
|
||||
const urlParams = buildUrlParams(options.params, options.shouldEncodeUrlParams);
|
||||
const url = urlParams ? `${options.url}?${urlParams}` : options.url;
|
||||
const response = await fetch(url, requestInit);
|
||||
const contentType = response.headers.get('content-type') || '';
|
||||
// Default to 'text' responseType so no parsing happens
|
||||
let { responseType = 'text' } = response.ok ? options : {};
|
||||
// If the response content-type is json, force the response to be json
|
||||
if (contentType.includes('application/json')) {
|
||||
responseType = 'json';
|
||||
}
|
||||
let data;
|
||||
let blob;
|
||||
switch (responseType) {
|
||||
case 'arraybuffer':
|
||||
case 'blob':
|
||||
blob = await response.blob();
|
||||
data = await readBlobAsBase64(blob);
|
||||
break;
|
||||
case 'json':
|
||||
data = await response.json();
|
||||
break;
|
||||
case 'document':
|
||||
case 'text':
|
||||
default:
|
||||
data = await response.text();
|
||||
}
|
||||
// Convert fetch headers to Capacitor HttpHeaders
|
||||
const headers = {};
|
||||
response.headers.forEach((value, key) => {
|
||||
headers[key] = value;
|
||||
});
|
||||
return {
|
||||
data,
|
||||
headers,
|
||||
status: response.status,
|
||||
url: response.url,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Perform an Http GET request given a set of options
|
||||
* @param options Options to build the HTTP request
|
||||
*/
|
||||
async get(options) {
|
||||
return this.request(Object.assign(Object.assign({}, options), { method: 'GET' }));
|
||||
}
|
||||
/**
|
||||
* Perform an Http POST request given a set of options
|
||||
* @param options Options to build the HTTP request
|
||||
*/
|
||||
async post(options) {
|
||||
return this.request(Object.assign(Object.assign({}, options), { method: 'POST' }));
|
||||
}
|
||||
/**
|
||||
* Perform an Http PUT request given a set of options
|
||||
* @param options Options to build the HTTP request
|
||||
*/
|
||||
async put(options) {
|
||||
return this.request(Object.assign(Object.assign({}, options), { method: 'PUT' }));
|
||||
}
|
||||
/**
|
||||
* Perform an Http PATCH request given a set of options
|
||||
* @param options Options to build the HTTP request
|
||||
*/
|
||||
async patch(options) {
|
||||
return this.request(Object.assign(Object.assign({}, options), { method: 'PATCH' }));
|
||||
}
|
||||
/**
|
||||
* Perform an Http DELETE request given a set of options
|
||||
* @param options Options to build the HTTP request
|
||||
*/
|
||||
async delete(options) {
|
||||
return this.request(Object.assign(Object.assign({}, options), { method: 'DELETE' }));
|
||||
}
|
||||
}
|
||||
const CapacitorHttp = registerPlugin('CapacitorHttp', {
|
||||
web: () => new CapacitorHttpPluginWeb(),
|
||||
});
|
||||
/******** END HTTP PLUGIN ********/
|
||||
/******** SYSTEM BARS PLUGIN ********/
|
||||
/**
|
||||
* Available status bar styles.
|
||||
*/
|
||||
exports.SystemBarsStyle = void 0;
|
||||
(function (SystemBarsStyle) {
|
||||
/**
|
||||
* Light system bar content on a dark background.
|
||||
*
|
||||
* @since 8.0.0
|
||||
*/
|
||||
SystemBarsStyle["Dark"] = "DARK";
|
||||
/**
|
||||
* For dark system bar content on a light background.
|
||||
*
|
||||
* @since 8.0.0
|
||||
*/
|
||||
SystemBarsStyle["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
|
||||
*/
|
||||
SystemBarsStyle["Default"] = "DEFAULT";
|
||||
})(exports.SystemBarsStyle || (exports.SystemBarsStyle = {}));
|
||||
/**
|
||||
* Available system bar types.
|
||||
*/
|
||||
exports.SystemBarType = void 0;
|
||||
(function (SystemBarType) {
|
||||
/**
|
||||
* The top status bar on both Android and iOS.
|
||||
*
|
||||
* @since 8.0.0
|
||||
*/
|
||||
SystemBarType["StatusBar"] = "StatusBar";
|
||||
/**
|
||||
* The navigation bar (or gesture bar on iOS) on both Android and iOS.
|
||||
*
|
||||
* @since 8.0.0
|
||||
*/
|
||||
SystemBarType["NavigationBar"] = "NavigationBar";
|
||||
})(exports.SystemBarType || (exports.SystemBarType = {}));
|
||||
class SystemBarsPluginWeb extends WebPlugin {
|
||||
async setStyle() {
|
||||
this.unavailable('not available for web');
|
||||
}
|
||||
async setAnimation() {
|
||||
this.unavailable('not available for web');
|
||||
}
|
||||
async show() {
|
||||
this.unavailable('not available for web');
|
||||
}
|
||||
async hide() {
|
||||
this.unavailable('not available for web');
|
||||
}
|
||||
}
|
||||
const SystemBars = registerPlugin('SystemBars', {
|
||||
web: () => new SystemBarsPluginWeb(),
|
||||
});
|
||||
/******** END SYSTEM BARS PLUGIN ********/
|
||||
|
||||
exports.Capacitor = Capacitor;
|
||||
exports.CapacitorCookies = CapacitorCookies;
|
||||
exports.CapacitorException = CapacitorException;
|
||||
exports.CapacitorHttp = CapacitorHttp;
|
||||
exports.SystemBars = SystemBars;
|
||||
exports.WebPlugin = WebPlugin;
|
||||
exports.WebView = WebView;
|
||||
exports.buildRequestInit = buildRequestInit;
|
||||
exports.registerPlugin = registerPlugin;
|
||||
//# sourceMappingURL=index.cjs.js.map
|
||||
1
node_modules/@capacitor/core/dist/index.cjs.js.map
generated
vendored
Normal file
1
node_modules/@capacitor/core/dist/index.cjs.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
646
node_modules/@capacitor/core/dist/index.js
generated
vendored
Normal file
646
node_modules/@capacitor/core/dist/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,646 @@
|
|||
/*! Capacitor: https://capacitorjs.com/ - MIT License */
|
||||
var ExceptionCode;
|
||||
(function (ExceptionCode) {
|
||||
/**
|
||||
* API is not implemented.
|
||||
*
|
||||
* This usually means the API can't be used because it is not implemented for
|
||||
* the current platform.
|
||||
*/
|
||||
ExceptionCode["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
|
||||
*/
|
||||
ExceptionCode["Unavailable"] = "UNAVAILABLE";
|
||||
})(ExceptionCode || (ExceptionCode = {}));
|
||||
class CapacitorException extends Error {
|
||||
constructor(message, code, data) {
|
||||
super(message);
|
||||
this.message = message;
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
const getPlatformId = (win) => {
|
||||
var _a, _b;
|
||||
if (win === null || win === void 0 ? void 0 : win.androidBridge) {
|
||||
return 'android';
|
||||
}
|
||||
else if ((_b = (_a = win === null || win === void 0 ? void 0 : win.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.bridge) {
|
||||
return 'ios';
|
||||
}
|
||||
else {
|
||||
return 'web';
|
||||
}
|
||||
};
|
||||
|
||||
const createCapacitor = (win) => {
|
||||
const capCustomPlatform = win.CapacitorCustomPlatform || null;
|
||||
const cap = win.Capacitor || {};
|
||||
const Plugins = (cap.Plugins = cap.Plugins || {});
|
||||
const getPlatform = () => {
|
||||
return capCustomPlatform !== null ? capCustomPlatform.name : getPlatformId(win);
|
||||
};
|
||||
const isNativePlatform = () => getPlatform() !== 'web';
|
||||
const isPluginAvailable = (pluginName) => {
|
||||
const plugin = registeredPlugins.get(pluginName);
|
||||
if (plugin === null || plugin === void 0 ? void 0 : plugin.platforms.has(getPlatform())) {
|
||||
// JS implementation available for the current platform.
|
||||
return true;
|
||||
}
|
||||
if (getPluginHeader(pluginName)) {
|
||||
// Native implementation available.
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const getPluginHeader = (pluginName) => { var _a; return (_a = cap.PluginHeaders) === null || _a === void 0 ? void 0 : _a.find((h) => h.name === pluginName); };
|
||||
const handleError = (err) => win.console.error(err);
|
||||
const registeredPlugins = new Map();
|
||||
const registerPlugin = (pluginName, jsImplementations = {}) => {
|
||||
const registeredPlugin = registeredPlugins.get(pluginName);
|
||||
if (registeredPlugin) {
|
||||
console.warn(`Capacitor plugin "${pluginName}" already registered. Cannot register plugins twice.`);
|
||||
return registeredPlugin.proxy;
|
||||
}
|
||||
const platform = getPlatform();
|
||||
const pluginHeader = getPluginHeader(pluginName);
|
||||
let jsImplementation;
|
||||
const loadPluginImplementation = async () => {
|
||||
if (!jsImplementation && platform in jsImplementations) {
|
||||
jsImplementation =
|
||||
typeof jsImplementations[platform] === 'function'
|
||||
? (jsImplementation = await jsImplementations[platform]())
|
||||
: (jsImplementation = jsImplementations[platform]);
|
||||
}
|
||||
else if (capCustomPlatform !== null && !jsImplementation && 'web' in jsImplementations) {
|
||||
jsImplementation =
|
||||
typeof jsImplementations['web'] === 'function'
|
||||
? (jsImplementation = await jsImplementations['web']())
|
||||
: (jsImplementation = jsImplementations['web']);
|
||||
}
|
||||
return jsImplementation;
|
||||
};
|
||||
const createPluginMethod = (impl, prop) => {
|
||||
var _a, _b;
|
||||
if (pluginHeader) {
|
||||
const methodHeader = pluginHeader === null || pluginHeader === void 0 ? void 0 : pluginHeader.methods.find((m) => prop === m.name);
|
||||
if (methodHeader) {
|
||||
if (methodHeader.rtype === 'promise') {
|
||||
return (options) => cap.nativePromise(pluginName, prop.toString(), options);
|
||||
}
|
||||
else {
|
||||
return (options, callback) => cap.nativeCallback(pluginName, prop.toString(), options, callback);
|
||||
}
|
||||
}
|
||||
else if (impl) {
|
||||
return (_a = impl[prop]) === null || _a === void 0 ? void 0 : _a.bind(impl);
|
||||
}
|
||||
}
|
||||
else if (impl) {
|
||||
return (_b = impl[prop]) === null || _b === void 0 ? void 0 : _b.bind(impl);
|
||||
}
|
||||
else {
|
||||
throw new CapacitorException(`"${pluginName}" plugin is not implemented on ${platform}`, ExceptionCode.Unimplemented);
|
||||
}
|
||||
};
|
||||
const createPluginMethodWrapper = (prop) => {
|
||||
let remove;
|
||||
const wrapper = (...args) => {
|
||||
const p = loadPluginImplementation().then((impl) => {
|
||||
const fn = createPluginMethod(impl, prop);
|
||||
if (fn) {
|
||||
const p = fn(...args);
|
||||
remove = p === null || p === void 0 ? void 0 : p.remove;
|
||||
return p;
|
||||
}
|
||||
else {
|
||||
throw new CapacitorException(`"${pluginName}.${prop}()" is not implemented on ${platform}`, ExceptionCode.Unimplemented);
|
||||
}
|
||||
});
|
||||
if (prop === 'addListener') {
|
||||
p.remove = async () => remove();
|
||||
}
|
||||
return p;
|
||||
};
|
||||
// Some flair ✨
|
||||
wrapper.toString = () => `${prop.toString()}() { [capacitor code] }`;
|
||||
Object.defineProperty(wrapper, 'name', {
|
||||
value: prop,
|
||||
writable: false,
|
||||
configurable: false,
|
||||
});
|
||||
return wrapper;
|
||||
};
|
||||
const addListener = createPluginMethodWrapper('addListener');
|
||||
const removeListener = createPluginMethodWrapper('removeListener');
|
||||
const addListenerNative = (eventName, callback) => {
|
||||
const call = addListener({ eventName }, callback);
|
||||
const remove = async () => {
|
||||
const callbackId = await call;
|
||||
removeListener({
|
||||
eventName,
|
||||
callbackId,
|
||||
}, callback);
|
||||
};
|
||||
const p = new Promise((resolve) => call.then(() => resolve({ remove })));
|
||||
p.remove = async () => {
|
||||
console.warn(`Using addListener() without 'await' is deprecated.`);
|
||||
await remove();
|
||||
};
|
||||
return p;
|
||||
};
|
||||
const proxy = new Proxy({}, {
|
||||
get(_, prop) {
|
||||
switch (prop) {
|
||||
// https://github.com/facebook/react/issues/20030
|
||||
case '$$typeof':
|
||||
return undefined;
|
||||
case 'toJSON':
|
||||
return () => ({});
|
||||
case 'addListener':
|
||||
return pluginHeader ? addListenerNative : addListener;
|
||||
case 'removeListener':
|
||||
return removeListener;
|
||||
default:
|
||||
return createPluginMethodWrapper(prop);
|
||||
}
|
||||
},
|
||||
});
|
||||
Plugins[pluginName] = proxy;
|
||||
registeredPlugins.set(pluginName, {
|
||||
name: pluginName,
|
||||
proxy,
|
||||
platforms: new Set([...Object.keys(jsImplementations), ...(pluginHeader ? [platform] : [])]),
|
||||
});
|
||||
return proxy;
|
||||
};
|
||||
// Add in convertFileSrc for web, it will already be available in native context
|
||||
if (!cap.convertFileSrc) {
|
||||
cap.convertFileSrc = (filePath) => filePath;
|
||||
}
|
||||
cap.getPlatform = getPlatform;
|
||||
cap.handleError = handleError;
|
||||
cap.isNativePlatform = isNativePlatform;
|
||||
cap.isPluginAvailable = isPluginAvailable;
|
||||
cap.registerPlugin = registerPlugin;
|
||||
cap.Exception = CapacitorException;
|
||||
cap.DEBUG = !!cap.DEBUG;
|
||||
cap.isLoggingEnabled = !!cap.isLoggingEnabled;
|
||||
return cap;
|
||||
};
|
||||
const initCapacitorGlobal = (win) => (win.Capacitor = createCapacitor(win));
|
||||
|
||||
const Capacitor = /*#__PURE__*/ initCapacitorGlobal(typeof globalThis !== 'undefined'
|
||||
? globalThis
|
||||
: typeof self !== 'undefined'
|
||||
? self
|
||||
: typeof window !== 'undefined'
|
||||
? window
|
||||
: typeof global !== 'undefined'
|
||||
? global
|
||||
: {});
|
||||
const registerPlugin = Capacitor.registerPlugin;
|
||||
|
||||
/**
|
||||
* Base class web plugins should extend.
|
||||
*/
|
||||
class WebPlugin {
|
||||
constructor() {
|
||||
this.listeners = {};
|
||||
this.retainedEventArguments = {};
|
||||
this.windowListeners = {};
|
||||
}
|
||||
addListener(eventName, listenerFunc) {
|
||||
let firstListener = false;
|
||||
const listeners = this.listeners[eventName];
|
||||
if (!listeners) {
|
||||
this.listeners[eventName] = [];
|
||||
firstListener = true;
|
||||
}
|
||||
this.listeners[eventName].push(listenerFunc);
|
||||
// If we haven't added a window listener for this event and it requires one,
|
||||
// go ahead and add it
|
||||
const windowListener = this.windowListeners[eventName];
|
||||
if (windowListener && !windowListener.registered) {
|
||||
this.addWindowListener(windowListener);
|
||||
}
|
||||
if (firstListener) {
|
||||
this.sendRetainedArgumentsForEvent(eventName);
|
||||
}
|
||||
const remove = async () => this.removeListener(eventName, listenerFunc);
|
||||
const p = Promise.resolve({ remove });
|
||||
return p;
|
||||
}
|
||||
async removeAllListeners() {
|
||||
this.listeners = {};
|
||||
for (const listener in this.windowListeners) {
|
||||
this.removeWindowListener(this.windowListeners[listener]);
|
||||
}
|
||||
this.windowListeners = {};
|
||||
}
|
||||
notifyListeners(eventName, data, retainUntilConsumed) {
|
||||
const listeners = this.listeners[eventName];
|
||||
if (!listeners) {
|
||||
if (retainUntilConsumed) {
|
||||
let args = this.retainedEventArguments[eventName];
|
||||
if (!args) {
|
||||
args = [];
|
||||
}
|
||||
args.push(data);
|
||||
this.retainedEventArguments[eventName] = args;
|
||||
}
|
||||
return;
|
||||
}
|
||||
listeners.forEach((listener) => listener(data));
|
||||
}
|
||||
hasListeners(eventName) {
|
||||
var _a;
|
||||
return !!((_a = this.listeners[eventName]) === null || _a === void 0 ? void 0 : _a.length);
|
||||
}
|
||||
registerWindowListener(windowEventName, pluginEventName) {
|
||||
this.windowListeners[pluginEventName] = {
|
||||
registered: false,
|
||||
windowEventName,
|
||||
pluginEventName,
|
||||
handler: (event) => {
|
||||
this.notifyListeners(pluginEventName, event);
|
||||
},
|
||||
};
|
||||
}
|
||||
unimplemented(msg = 'not implemented') {
|
||||
return new Capacitor.Exception(msg, ExceptionCode.Unimplemented);
|
||||
}
|
||||
unavailable(msg = 'not available') {
|
||||
return new Capacitor.Exception(msg, ExceptionCode.Unavailable);
|
||||
}
|
||||
async removeListener(eventName, listenerFunc) {
|
||||
const listeners = this.listeners[eventName];
|
||||
if (!listeners) {
|
||||
return;
|
||||
}
|
||||
const index = listeners.indexOf(listenerFunc);
|
||||
this.listeners[eventName].splice(index, 1);
|
||||
// If there are no more listeners for this type of event,
|
||||
// remove the window listener
|
||||
if (!this.listeners[eventName].length) {
|
||||
this.removeWindowListener(this.windowListeners[eventName]);
|
||||
}
|
||||
}
|
||||
addWindowListener(handle) {
|
||||
window.addEventListener(handle.windowEventName, handle.handler);
|
||||
handle.registered = true;
|
||||
}
|
||||
removeWindowListener(handle) {
|
||||
if (!handle) {
|
||||
return;
|
||||
}
|
||||
window.removeEventListener(handle.windowEventName, handle.handler);
|
||||
handle.registered = false;
|
||||
}
|
||||
sendRetainedArgumentsForEvent(eventName) {
|
||||
const args = this.retainedEventArguments[eventName];
|
||||
if (!args) {
|
||||
return;
|
||||
}
|
||||
delete this.retainedEventArguments[eventName];
|
||||
args.forEach((arg) => {
|
||||
this.notifyListeners(eventName, arg);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const WebView = /*#__PURE__*/ registerPlugin('WebView');
|
||||
/******** END WEB VIEW PLUGIN ********/
|
||||
/******** COOKIES PLUGIN ********/
|
||||
/**
|
||||
* Safely web encode a string value (inspired by js-cookie)
|
||||
* @param str The string value to encode
|
||||
*/
|
||||
const encode = (str) => encodeURIComponent(str)
|
||||
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
||||
.replace(/[()]/g, escape);
|
||||
/**
|
||||
* Safely web decode a string value (inspired by js-cookie)
|
||||
* @param str The string value to decode
|
||||
*/
|
||||
const decode = (str) => str.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
||||
class CapacitorCookiesPluginWeb extends WebPlugin {
|
||||
async getCookies() {
|
||||
const cookies = document.cookie;
|
||||
const cookieMap = {};
|
||||
cookies.split(';').forEach((cookie) => {
|
||||
if (cookie.length <= 0)
|
||||
return;
|
||||
// Replace first "=" with CAP_COOKIE to prevent splitting on additional "="
|
||||
let [key, value] = cookie.replace(/=/, 'CAP_COOKIE').split('CAP_COOKIE');
|
||||
key = decode(key).trim();
|
||||
value = decode(value).trim();
|
||||
cookieMap[key] = value;
|
||||
});
|
||||
return cookieMap;
|
||||
}
|
||||
async setCookie(options) {
|
||||
try {
|
||||
// Safely Encoded Key/Value
|
||||
const encodedKey = encode(options.key);
|
||||
const encodedValue = encode(options.value);
|
||||
// Clean & sanitize options
|
||||
const expires = options.expires ? `; expires=${options.expires.replace('expires=', '')}` : '';
|
||||
const path = (options.path || '/').replace('path=', ''); // Default is "path=/"
|
||||
const domain = options.url != null && options.url.length > 0 ? `domain=${options.url}` : '';
|
||||
document.cookie = `${encodedKey}=${encodedValue || ''}${expires}; path=${path}; ${domain};`;
|
||||
}
|
||||
catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
async deleteCookie(options) {
|
||||
try {
|
||||
document.cookie = `${options.key}=; Max-Age=0`;
|
||||
}
|
||||
catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
async clearCookies() {
|
||||
try {
|
||||
const cookies = document.cookie.split(';') || [];
|
||||
for (const cookie of cookies) {
|
||||
document.cookie = cookie.replace(/^ +/, '').replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
async clearAllCookies() {
|
||||
try {
|
||||
await this.clearCookies();
|
||||
}
|
||||
catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
const CapacitorCookies = registerPlugin('CapacitorCookies', {
|
||||
web: () => new CapacitorCookiesPluginWeb(),
|
||||
});
|
||||
// UTILITY FUNCTIONS
|
||||
/**
|
||||
* Read in a Blob value and return it as a base64 string
|
||||
* @param blob The blob value to convert to a base64 string
|
||||
*/
|
||||
const readBlobAsBase64 = async (blob) => new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
const base64String = reader.result;
|
||||
// remove prefix "data:application/pdf;base64,"
|
||||
resolve(base64String.indexOf(',') >= 0 ? base64String.split(',')[1] : base64String);
|
||||
};
|
||||
reader.onerror = (error) => reject(error);
|
||||
reader.readAsDataURL(blob);
|
||||
});
|
||||
/**
|
||||
* Normalize an HttpHeaders map by lowercasing all of the values
|
||||
* @param headers The HttpHeaders object to normalize
|
||||
*/
|
||||
const normalizeHttpHeaders = (headers = {}) => {
|
||||
const originalKeys = Object.keys(headers);
|
||||
const loweredKeys = Object.keys(headers).map((k) => k.toLocaleLowerCase());
|
||||
const normalized = loweredKeys.reduce((acc, key, index) => {
|
||||
acc[key] = headers[originalKeys[index]];
|
||||
return acc;
|
||||
}, {});
|
||||
return normalized;
|
||||
};
|
||||
/**
|
||||
* Builds a string of url parameters that
|
||||
* @param params A map of url parameters
|
||||
* @param shouldEncode true if you should encodeURIComponent() the values (true by default)
|
||||
*/
|
||||
const buildUrlParams = (params, shouldEncode = true) => {
|
||||
if (!params)
|
||||
return null;
|
||||
const output = Object.entries(params).reduce((accumulator, entry) => {
|
||||
const [key, value] = entry;
|
||||
let encodedValue;
|
||||
let item;
|
||||
if (Array.isArray(value)) {
|
||||
item = '';
|
||||
value.forEach((str) => {
|
||||
encodedValue = shouldEncode ? encodeURIComponent(str) : str;
|
||||
item += `${key}=${encodedValue}&`;
|
||||
});
|
||||
// last character will always be "&" so slice it off
|
||||
item.slice(0, -1);
|
||||
}
|
||||
else {
|
||||
encodedValue = shouldEncode ? encodeURIComponent(value) : value;
|
||||
item = `${key}=${encodedValue}`;
|
||||
}
|
||||
return `${accumulator}&${item}`;
|
||||
}, '');
|
||||
// Remove initial "&" from the reduce
|
||||
return output.substr(1);
|
||||
};
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
const buildRequestInit = (options, extra = {}) => {
|
||||
const output = Object.assign({ method: options.method || 'GET', headers: options.headers }, extra);
|
||||
// Get the content-type
|
||||
const headers = normalizeHttpHeaders(options.headers);
|
||||
const type = headers['content-type'] || '';
|
||||
// If body is already a string, then pass it through as-is.
|
||||
if (typeof options.data === 'string') {
|
||||
output.body = options.data;
|
||||
}
|
||||
// Build request initializers based off of content-type
|
||||
else if (type.includes('application/x-www-form-urlencoded')) {
|
||||
const params = new URLSearchParams();
|
||||
for (const [key, value] of Object.entries(options.data || {})) {
|
||||
params.set(key, value);
|
||||
}
|
||||
output.body = params.toString();
|
||||
}
|
||||
else if (type.includes('multipart/form-data') || options.data instanceof FormData) {
|
||||
const form = new FormData();
|
||||
if (options.data instanceof FormData) {
|
||||
options.data.forEach((value, key) => {
|
||||
form.append(key, value);
|
||||
});
|
||||
}
|
||||
else {
|
||||
for (const key of Object.keys(options.data)) {
|
||||
form.append(key, options.data[key]);
|
||||
}
|
||||
}
|
||||
output.body = form;
|
||||
const headers = new Headers(output.headers);
|
||||
headers.delete('content-type'); // content-type will be set by `window.fetch` to includy boundary
|
||||
output.headers = headers;
|
||||
}
|
||||
else if (type.includes('application/json') || typeof options.data === 'object') {
|
||||
output.body = JSON.stringify(options.data);
|
||||
}
|
||||
return output;
|
||||
};
|
||||
// WEB IMPLEMENTATION
|
||||
class CapacitorHttpPluginWeb extends WebPlugin {
|
||||
/**
|
||||
* Perform an Http request given a set of options
|
||||
* @param options Options to build the HTTP request
|
||||
*/
|
||||
async request(options) {
|
||||
const requestInit = buildRequestInit(options, options.webFetchExtra);
|
||||
const urlParams = buildUrlParams(options.params, options.shouldEncodeUrlParams);
|
||||
const url = urlParams ? `${options.url}?${urlParams}` : options.url;
|
||||
const response = await fetch(url, requestInit);
|
||||
const contentType = response.headers.get('content-type') || '';
|
||||
// Default to 'text' responseType so no parsing happens
|
||||
let { responseType = 'text' } = response.ok ? options : {};
|
||||
// If the response content-type is json, force the response to be json
|
||||
if (contentType.includes('application/json')) {
|
||||
responseType = 'json';
|
||||
}
|
||||
let data;
|
||||
let blob;
|
||||
switch (responseType) {
|
||||
case 'arraybuffer':
|
||||
case 'blob':
|
||||
blob = await response.blob();
|
||||
data = await readBlobAsBase64(blob);
|
||||
break;
|
||||
case 'json':
|
||||
data = await response.json();
|
||||
break;
|
||||
case 'document':
|
||||
case 'text':
|
||||
default:
|
||||
data = await response.text();
|
||||
}
|
||||
// Convert fetch headers to Capacitor HttpHeaders
|
||||
const headers = {};
|
||||
response.headers.forEach((value, key) => {
|
||||
headers[key] = value;
|
||||
});
|
||||
return {
|
||||
data,
|
||||
headers,
|
||||
status: response.status,
|
||||
url: response.url,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Perform an Http GET request given a set of options
|
||||
* @param options Options to build the HTTP request
|
||||
*/
|
||||
async get(options) {
|
||||
return this.request(Object.assign(Object.assign({}, options), { method: 'GET' }));
|
||||
}
|
||||
/**
|
||||
* Perform an Http POST request given a set of options
|
||||
* @param options Options to build the HTTP request
|
||||
*/
|
||||
async post(options) {
|
||||
return this.request(Object.assign(Object.assign({}, options), { method: 'POST' }));
|
||||
}
|
||||
/**
|
||||
* Perform an Http PUT request given a set of options
|
||||
* @param options Options to build the HTTP request
|
||||
*/
|
||||
async put(options) {
|
||||
return this.request(Object.assign(Object.assign({}, options), { method: 'PUT' }));
|
||||
}
|
||||
/**
|
||||
* Perform an Http PATCH request given a set of options
|
||||
* @param options Options to build the HTTP request
|
||||
*/
|
||||
async patch(options) {
|
||||
return this.request(Object.assign(Object.assign({}, options), { method: 'PATCH' }));
|
||||
}
|
||||
/**
|
||||
* Perform an Http DELETE request given a set of options
|
||||
* @param options Options to build the HTTP request
|
||||
*/
|
||||
async delete(options) {
|
||||
return this.request(Object.assign(Object.assign({}, options), { method: 'DELETE' }));
|
||||
}
|
||||
}
|
||||
const CapacitorHttp = registerPlugin('CapacitorHttp', {
|
||||
web: () => new CapacitorHttpPluginWeb(),
|
||||
});
|
||||
/******** END HTTP PLUGIN ********/
|
||||
/******** SYSTEM BARS PLUGIN ********/
|
||||
/**
|
||||
* Available status bar styles.
|
||||
*/
|
||||
var SystemBarsStyle;
|
||||
(function (SystemBarsStyle) {
|
||||
/**
|
||||
* Light system bar content on a dark background.
|
||||
*
|
||||
* @since 8.0.0
|
||||
*/
|
||||
SystemBarsStyle["Dark"] = "DARK";
|
||||
/**
|
||||
* For dark system bar content on a light background.
|
||||
*
|
||||
* @since 8.0.0
|
||||
*/
|
||||
SystemBarsStyle["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
|
||||
*/
|
||||
SystemBarsStyle["Default"] = "DEFAULT";
|
||||
})(SystemBarsStyle || (SystemBarsStyle = {}));
|
||||
/**
|
||||
* Available system bar types.
|
||||
*/
|
||||
var SystemBarType;
|
||||
(function (SystemBarType) {
|
||||
/**
|
||||
* The top status bar on both Android and iOS.
|
||||
*
|
||||
* @since 8.0.0
|
||||
*/
|
||||
SystemBarType["StatusBar"] = "StatusBar";
|
||||
/**
|
||||
* The navigation bar (or gesture bar on iOS) on both Android and iOS.
|
||||
*
|
||||
* @since 8.0.0
|
||||
*/
|
||||
SystemBarType["NavigationBar"] = "NavigationBar";
|
||||
})(SystemBarType || (SystemBarType = {}));
|
||||
class SystemBarsPluginWeb extends WebPlugin {
|
||||
async setStyle() {
|
||||
this.unavailable('not available for web');
|
||||
}
|
||||
async setAnimation() {
|
||||
this.unavailable('not available for web');
|
||||
}
|
||||
async show() {
|
||||
this.unavailable('not available for web');
|
||||
}
|
||||
async hide() {
|
||||
this.unavailable('not available for web');
|
||||
}
|
||||
}
|
||||
const SystemBars = registerPlugin('SystemBars', {
|
||||
web: () => new SystemBarsPluginWeb(),
|
||||
});
|
||||
/******** END SYSTEM BARS PLUGIN ********/
|
||||
|
||||
export { Capacitor, CapacitorCookies, CapacitorException, CapacitorHttp, ExceptionCode, SystemBarType, SystemBars, SystemBarsStyle, WebPlugin, WebView, buildRequestInit, registerPlugin };
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@capacitor/core/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@capacitor/core/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
683
node_modules/@capacitor/core/http.md
generated
vendored
Normal file
683
node_modules/@capacitor/core/http.md
generated
vendored
Normal 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<<a href="#httpresponse">HttpResponse</a>></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<<a href="#httpresponse">HttpResponse</a>></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<<a href="#httpresponse">HttpResponse</a>></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<<a href="#httpresponse">HttpResponse</a>></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<<a href="#httpresponse">HttpResponse</a>></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<<a href="#httpresponse">HttpResponse</a>></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** | () => Promise<<a href="#arraybuffer">ArrayBuffer</a>> |
|
||||
| **slice** | (start?: number, end?: number, contentType?: string) => <a href="#blob">Blob</a> |
|
||||
| **stream** | () => <a href="#readablestream">ReadableStream</a> |
|
||||
| **text** | () => Promise<string> |
|
||||
|
||||
|
||||
#### 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) => <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) => Promise<void> |
|
||||
| **getReader** | () => <a href="#readablestreamdefaultreader">ReadableStreamDefaultReader</a><R> |
|
||||
| **pipeThrough** | <T>(transform: <a href="#readablewritablepair">ReadableWritablePair</a><T, R>, options?: <a href="#streampipeoptions">StreamPipeOptions</a>) => <a href="#readablestream">ReadableStream</a><T> |
|
||||
| **pipeTo** | (dest: <a href="#writablestream">WritableStream</a><R>, options?: <a href="#streampipeoptions">StreamPipeOptions</a>) => Promise<void> |
|
||||
| **tee** | () => [ReadableStream<R>, <a href="#readablestream">ReadableStream</a><R>] |
|
||||
|
||||
|
||||
#### ReadableStreamDefaultReader
|
||||
|
||||
| Method | Signature |
|
||||
| --------------- | --------------------------------------------------------------------------------------------------------------- |
|
||||
| **read** | () => Promise<<a href="#readablestreamdefaultreadresult">ReadableStreamDefaultReadResult</a><R>> |
|
||||
| **releaseLock** | () => 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><R></code> | |
|
||||
| **`writable`** | <code><a href="#writablestream">WritableStream</a><W></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) => Promise<void> |
|
||||
| **getWriter** | () => <a href="#writablestreamdefaultwriter">WritableStreamDefaultWriter</a><W> |
|
||||
|
||||
|
||||
#### WritableStreamDefaultWriter
|
||||
|
||||
This Streams API interface is the object returned by <a href="#writablestream">WritableStream.getWriter</a>() and once created locks the < writer to the <a href="#writablestream">WritableStream</a> ensuring that no other streams can write to the underlying sink.
|
||||
|
||||
| Prop | Type |
|
||||
| ----------------- | ------------------------------------- |
|
||||
| **`closed`** | <code>Promise<undefined></code> |
|
||||
| **`desiredSize`** | <code>number</code> |
|
||||
| **`ready`** | <code>Promise<undefined></code> |
|
||||
|
||||
| Method | Signature |
|
||||
| --------------- | ---------------------------------------- |
|
||||
| **abort** | (reason?: any) => Promise<void> |
|
||||
| **close** | () => Promise<void> |
|
||||
| **releaseLock** | () => void |
|
||||
| **write** | (chunk: W) => Promise<void> |
|
||||
|
||||
|
||||
#### 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>) => any</code> | |
|
||||
|
||||
| Method | Signature | Description |
|
||||
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **addEventListener** | <K extends "abort">(type: K, listener: (this: <a href="#abortsignal">AbortSignal</a>, ev: AbortSignalEventMap[K]) => any, options?: boolean \| <a href="#addeventlisteneroptions">AddEventListenerOptions</a>) => 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>) => 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** | <K extends "abort">(type: K, listener: (this: <a href="#abortsignal">AbortSignal</a>, ev: AbortSignalEventMap[K]) => any, options?: boolean \| <a href="#eventlisteneroptions">EventListenerOptions</a>) => 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>) => 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** | () => 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) => void | |
|
||||
| **preventDefault** | () => 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** | () => 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** | () => 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>) => 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>) => 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) => 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>) => 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) => void |
|
||||
| **delete** | (name: string) => void |
|
||||
| **get** | (name: string) => <a href="#formdataentryvalue">FormDataEntryValue</a> \| null |
|
||||
| **getAll** | (name: string) => FormDataEntryValue[] |
|
||||
| **has** | (name: string) => boolean |
|
||||
| **set** | (name: string, value: string \| <a href="#blob">Blob</a>, fileName?: string) => void |
|
||||
| **forEach** | (callbackfn: (value: <a href="#formdataentryvalue">FormDataEntryValue</a>, key: string, parent: <a href="#formdata">FormData</a>) => void, thisArg?: any) => 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) => void | Appends a specified key/value pair as a new search parameter. |
|
||||
| **delete** | (name: string) => void | Deletes the given search parameter, and its associated value, from the list of all search parameters. |
|
||||
| **get** | (name: string) => string \| null | Returns the first value associated to the given search parameter. |
|
||||
| **getAll** | (name: string) => string[] | Returns all the values association with a given search parameter. |
|
||||
| **has** | (name: string) => boolean | Returns a Boolean indicating if such a search parameter exists. |
|
||||
| **set** | (name: string, value: string) => void | Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. |
|
||||
| **sort** | () => void | |
|
||||
| **toString** | () => 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>) => void, thisArg?: any) => 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) => 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>) => unknown, thisArg?: any) => boolean | Determines whether all the members of an array satisfy the specified test. |
|
||||
| **fill** | (value: number, start?: number, end?: number) => 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>) => any, thisArg?: any) => <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>) => boolean, thisArg?: any) => 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>) => boolean, thisArg?: any) => 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>) => void, thisArg?: any) => void | Performs the specified action for each element in an array. |
|
||||
| **indexOf** | (searchElement: number, fromIndex?: number) => number | Returns the index of the first occurrence of a value in an array. |
|
||||
| **join** | (separator?: string) => string | Adds all the elements of an array separated by the specified separator string. |
|
||||
| **lastIndexOf** | (searchElement: number, fromIndex?: number) => 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>) => number, thisArg?: any) => <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>) => number) => 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>) => number, initialValue: number) => number | |
|
||||
| **reduce** | <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: <a href="#uint8array">Uint8Array</a>) => U, initialValue: U) => 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>) => number) => 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>) => number, initialValue: number) => number | |
|
||||
| **reduceRight** | <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: <a href="#uint8array">Uint8Array</a>) => U, initialValue: U) => 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** | () => <a href="#uint8array">Uint8Array</a> | Reverses the elements in an Array. |
|
||||
| **set** | (array: <a href="#arraylike">ArrayLike</a><number>, offset?: number) => void | Sets a value or an array of values. |
|
||||
| **slice** | (start?: number, end?: number) => <a href="#uint8array">Uint8Array</a> | Returns a section of an array. |
|
||||
| **some** | (predicate: (value: number, index: number, array: <a href="#uint8array">Uint8Array</a>) => unknown, thisArg?: any) => boolean | Determines whether the specified callback function returns true for any element of an array. |
|
||||
| **sort** | (compareFn?: (a: number, b: number) => number) => this | Sorts an array. |
|
||||
| **subarray** | (begin?: number, end?: number) => <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** | () => string | Converts a number to a string by using the current locale. |
|
||||
| **toString** | () => string | Returns a string representation of an array. |
|
||||
| **valueOf** | () => <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) => void |
|
||||
| **delete** | (name: string) => void |
|
||||
| **get** | (name: string) => string \| null |
|
||||
| **has** | (name: string) => boolean |
|
||||
| **set** | (name: string, value: string) => void |
|
||||
| **forEach** | (callbackfn: (value: string, key: string, parent: <a href="#headers">Headers</a>) => void, thisArg?: any) => 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><<a href="#uint8array">Uint8Array</a>> | string</code>
|
||||
|
||||
|
||||
#### ReadableStreamDefaultReadResult
|
||||
|
||||
<code><a href="#readablestreamdefaultreadvalueresult">ReadableStreamDefaultReadValueResult</a><T> | <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><string, string></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
node_modules/@capacitor/core/package.json
generated
vendored
Normal file
62
node_modules/@capacitor/core/package.json
generated
vendored
Normal 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
node_modules/@capacitor/core/system-bars.md
generated
vendored
Normal file
260
node_modules/@capacitor/core/system-bars.md
generated
vendored
Normal 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>
|
||||
372
node_modules/@capacitor/core/types/core-plugins.d.ts
generated
vendored
Normal file
372
node_modules/@capacitor/core/types/core-plugins.d.ts
generated
vendored
Normal 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 ********/
|
||||
171
node_modules/@capacitor/core/types/definitions-internal.d.ts
generated
vendored
Normal file
171
node_modules/@capacitor/core/types/definitions-internal.d.ts
generated
vendored
Normal 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;
|
||||
}
|
||||
76
node_modules/@capacitor/core/types/definitions.d.ts
generated
vendored
Normal file
76
node_modules/@capacitor/core/types/definitions.d.ts
generated
vendored
Normal 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;
|
||||
2
node_modules/@capacitor/core/types/global.d.ts
generated
vendored
Normal file
2
node_modules/@capacitor/core/types/global.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export declare const Capacitor: import("./definitions").CapacitorGlobal;
|
||||
export declare const registerPlugin: import("./definitions").RegisterPlugin;
|
||||
6
node_modules/@capacitor/core/types/index.d.ts
generated
vendored
Normal file
6
node_modules/@capacitor/core/types/index.d.ts
generated
vendored
Normal 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';
|
||||
9
node_modules/@capacitor/core/types/runtime.d.ts
generated
vendored
Normal file
9
node_modules/@capacitor/core/types/runtime.d.ts
generated
vendored
Normal 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
node_modules/@capacitor/core/types/util.d.ts
generated
vendored
Normal file
28
node_modules/@capacitor/core/types/util.d.ts
generated
vendored
Normal 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';
|
||||
34
node_modules/@capacitor/core/types/web-plugin.d.ts
generated
vendored
Normal file
34
node_modules/@capacitor/core/types/web-plugin.d.ts
generated
vendored
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue