Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cordova-plugin-ionic

Package Overview
Dependencies
Maintainers
5
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-ionic - npm Package Compare versions

Comparing version 5.4.0-0 to 5.4.0-1

dist/IonicCordova.d.ts

182

CHANGELOG.md

@@ -1,22 +0,22 @@

## Change Log
Changelog
======
## 5.3.1
* Add cordova-plugin-whitelist dependency ([#215] (https://github.com/ionic-team/cordova-plugin-ionic/pull/215))
### 5.4.0
* Added Deploy API Imports
### 5.3.0
## 5.3.0
* Added an 'incompatibleUpdateAvailable' property to the 'CheckForUpdateResponse' ([#204] (https://github.com/ionic-team/cordova-plugin-ionic/pull/204))
* 'ConfigurationInfo' now contains the 'BuildId' in addition to the 'SnapshotId' ([#204] (https://github.com/ionic-team/cordova-plugin-ionic/pull/204))
### 5.2.9
## 5.2.9
* Get dataDirectory from getAppInfo function ([#197](https://github.com/ionic-team/cordova-plugin-ionic/pull/197))
* Add proxy for browser platform to support it ([#199](https://github.com/ionic-team/cordova-plugin-ionic/pull/199))
### 5.2.8
## 5.2.8
* Fix Type Error in IDeployConfig ([#196](https://github.com/ionic-team/cordova-plugin-ionic/pull/196))
### 5.2.7
## 5.2.7
* Change hook to run before_prepare and make it async ([#178](https://github.com/ionic-team/cordova-plugin-ionic/pull/178))
* Fixed bug where the a new binary update would load an older cached version of the app ([#179)](https://github.com/ionic-team/cordova-plugin-ionic/issues/179))
### 5.2.6
## 5.2.6
* Check for Capacitor and switch folder ([#164](https://github.com/ionic-team/cordova-plugin-ionic/pull/164))

@@ -26,3 +26,3 @@ * Remove unused import ([#163](https://github.com/ionic-team/cordova-plugin-ionic/pull/163))

### 5.2.5
## 5.2.5
* Fix bug where binaryVersionName and binaryVersionCode are not returned from getConfiguation call

@@ -32,18 +32,18 @@ * Fix bug where downloadUpdate progress call back would go from 0 to 50 rather than 100 ([#156](https://github.com/ionic-team/cordova-plugin-ionic/pull/156]))

### 5.2.4
## 5.2.4
* update check device resp to be accurate ([#148](https://github.com/ionic-team/cordova-plugin-ionic/pull/148))
### 5.2.3
## 5.2.3
* Fixed bug with AndroidManifest.xml syntax for real since our release script kept breaking it
### 5.2.2
## 5.2.2
* Fixed bug with AndroidManifest.xml syntax
### 5.2.1
## 5.2.1
* Add ACCESS_NETWORK_STATE permission to make navigator.onLine work on android
### 5.2.0
## 5.2.0

@@ -53,16 +53,160 @@ * Added `DisableDeploy` Cordova preference allowing disabling of the plugin

### 5.1.6
## 5.1.6
* Fixed a bug with none update method strategy that could cause background updates upon resume of the app from background
### 5.0.6
## 5.0.6
* Fixed a bug with version rebulds that could make some initial redirects take up to 15 seconds.
### 5.0.5
## 5.0.5
* Rebuild a deploy directory in the case where the binary version has changed since the update was downloaded.
### 5.0.0
# 5.0.0
* Release!
* Misc. bugfixes from rc3
## 5.0.0-rc.3
* Improved dev tools
## 5.0.0-rc.2
* Disable certain features if browser `fetch` is unavailable
* Update some API methods for coherent returns
## 5.0.0-rc.1
* Removed the switch statement in Android Native code to support older Java platforms
## 5.0.0-rc.0
* Removed the deprecated API, to be added to version 4.2.0
## 5.0.0-alpha.0
* Rewrote the plugin in Typescript.
* Added support for application file manifests.
* Added full support for partial update downloads, greatly decreasing network bandwidth.
* **Deprecated old plugin API** in favor of modern promise-based API using async/await. Existing methods are still available, but may be removed in the future.
## 4.1.7
* Fix a redirect bug in iOS that would give the `background` update method inconsistent behavior
## 4.1.6
* Fix redirect bug in extract when version already exists (PR #82)
## 4.1.5
* Fix UUID storage bug on iOS (PR #79)
## 4.1.4
* Fix `checkAndApply` bug on Android (PR #77)
## 4.1.3
* Fix broken release (4.1.2)
## 4.1.2
* Handle `partial` flag from Pro API in `check-device` endpoint.
## 4.1.1
* Send plugin version to Ionic Pro when checking for updates.
## 4.1.0
* Added support for partial downloads.
## 4.0.1
* Fixed a bug where `deleteVersion` would errorwhen called. (PR #63)
# 4.0.0
* Removed some extraneous plugin result calls.
* **BREAKING** Unified all API functions to return `true` on success.
## 3.1.3
* Fixed a bug where `ng-cordova` could potentially be overwritten when a deploy is applied.
* Update no-zip branch
## 3.1.2
* Fixed the extract callback value
* Fixed a bug where the splashscreen would show for long periods while using the `background` update method on Android
## 3.1.1
* Fixed another issue with the cordova.js regex.
## 3.1.0
* Added a `WARN_DEBUG` flag to allow bypass of the debug dialog. (PR $49)
* Fixed a bug where minified script tags could be overwritten.
* Fixed a bug where redirect could error incorrectly on Android.
# 3.0.0
* Updated Cordova Splashscreen dependency (PR #41)
* Fixed the callback responses from the `download` and `extract` functions to reflect the docs.
* Store updates to plugin config make via the `init` methods in preferences.
## 2.0.4
* Added a supported platforms note (PR #33)
* Added correct callback calld for initialize and redirect methods (PR #20)
## 2.0.3
* Fixed a bug where the splashscreen could hang in some cases when dismissing the debug dialog within the automatic update methods on Android.
## 2.0.2
* Fixed a bug where the splashscreen could hang in some cases when using the `background` update method on Android.
## 2.0.1
* Fixed a bug with the splashscreen dependency definition
# 2.0.0
* **BREAKING** Refactored the deploy plugin API to take a config object at `init`, but no longer needs app ID's/channels in individual calls.
* Fixed a bug where the splashscreen was hiding before the deploy had finished on iOS.
* Fixed an iOS bug where redirects were failing as a result of a regex comparison.
* Fixed `auto` update method in Android to properly show the splash screen.
* Streamlined the way debug builds are handled. The plugin will now ask before each redirect away from the bundled version, allowing easier local development.
## 1.1.9
* Track channel.
* Add ability to clear debug dialog.
## 1.1.8
* Hooked up the `MAX_STORE` variable.
## 1.1.7
* When the app is a `DEBUG` build, the deploy feature will show a prompt and ask whether to apply updates
## 1.1.6
* Fixed a bug with `auto` mode when versions were already present.
* Added `MAX_STORE` flag for future use.
* Changed default behavior to `background` downloads.
## 1.1.5
* Added this changelog and updated the README
## 1.1.4
* Added background download flags and changed `AUTO_UPDATE` config to `UPDATE_METHOD`

317

dist/common.d.ts

@@ -1,304 +0,10 @@

import { CallbackFunction, CheckForUpdateResponse, IAppInfo, ICurrentConfig, IDeployConfig, ISnapshotInfo, ISyncOptions } from './definitions';
import { CallbackFunction, IAppInfo, IPluginBaseAPI } from './IonicCordova';
/**
* @hidden
*/
declare global {
interface Window {
IonicCordova: IonicCordovaPlugin;
}
}
/**
* The Ionic Deploy Plugin API
* @usage
* ```typescript
* async performManualUpdate() {
* const update = await Deploy.checkForUpdate()
* if (update.available){
* // We have an update!
* }
* }
* ```
* BASE API
*
* ## Methods
*
* The plugin contains many functions that can help you utilize Deploy inside of your app.
* * {@link checkForUpdate}
* * {@link configure}
* * {@link deleteVersionById}
* * {@link downloadUpdate}
* * {@link extractUpdate}
* * {@link getAvailableVersions}
* * {@link getConfiguration}
* * {@link getCurrentVersion}
* * {@link getVersionById}
* * {@link reloadApp}
* * {@link sync}
* All features of the Ionic Cordova plugin are registered here, along with some low level error tracking features used
* by the monitoring service.
*/
declare class IonicDeploy {
private parent;
private delegate;
private fetchIsAvailable;
private lastPause;
private minBackgroundDuration;
private disabled;
/**
* @hidden
*/
constructor(parent: IonicCordovaPlugin);
private initialize;
private onLoad;
private onPause;
private onResume;
private _initPreferences;
/**
* @description Check for available updates for the currently configured app id and channel.
*
* @since v5.0.0
*
* @returns A response describing an update if one is available.
*
* @usage
* ```typescript
* async performManualUpdate() {
* const update = await Deploy.checkForUpdate()
* if (update.available){
* // We have an update!
* }
* }
* ```
*/
checkForUpdate(): Promise<CheckForUpdateResponse>;
/**
* @description Update the default configuration for the plugin on the current device. The new configuration will be persisted across app close and binary updates.
*
* @since v5.0.0
*
* @param config The new configuration for the plugin on this device.
*
* @usage
* ```typescript
* async configureDeploy() {
* const config = {
* 'appId': 'YOUR_APP_ID',
* 'channel': 'CHANNEL_NAME'
* }
* await Deploy.configure(config);
* }
* ```
*/
configure(config: IDeployConfig): Promise<void>;
/**
* @description Get the current configuration for the plugin on the current device.
*
* @since v5.0.0
*
* @return The current configuration of the plugin.
*
* @usage
* ```typescript
* const info = Deploy.getConfiguration()
* console.log(info)
* // {
* // 'appId': 'abcd1234',
* // 'channel': 'MY_CHANNEL_NAME',
* // 'binaryVersionName': 'X.X.X',
* // 'binaryVersionCode': 'X.X.X', (string on iOS number on Android)
* // 'disabled': false,
* // 'updateMethod': 'auto',
* // 'maxVersions': 3,
* // 'minBackgroundDuration': 30,
* // 'currentVersionId': 'xxxx-xxxx-xxxx-xxxx'
* // 'currentBuildId' : 'xxxxxxx'
* // }
* ```
*/
getConfiguration(): Promise<ICurrentConfig>;
/**
* @description Remove the files specific to a snapshot from the device.
*
* @param version The versionId
*
* @return true if the update was deleted.
*
* @usage
* ```typescript
* async deleteVersion() {
* const versions = await Deploy.getAvailableVersions();
* Deploy.deleteVersionById(versions[0].versionId);
* }
* ```
*/
deleteVersionById(version: string): Promise<boolean>;
/**
* @description Download the new files from an available update found by the checkForUpdate method and prepare the update.
*
* @since v5.0.0
*
* @param progress A progress callback function which will be called with a number representing the percent of completion of the download and prepare.
*
* @return true if the download succeeded
*
* @usage
* ```typescript
* async performManualUpdate() {
* const update = await Deploy.checkForUpdate()
* if (update.available){
* await Deploy.downloadUpdate((progress) => {
* console.log(progress);
* })
* }
* }
* ```
*/
downloadUpdate(progress?: CallbackFunction<number>): Promise<boolean>;
/**
* @description Extract a downloaded bundle of updated files.
*
* @since v5.0.0
*
* @param progress A progress callback function which will be called with a number representing the percent of completion of the extract.
*
* @return true if the extract succeeded
*
* @usage
* ```typescript
* async performManualUpdate() {
* const update = await Deploy.checkForUpdate()
* if (update.available){
* await Deploy.downloadUpdate((progress) => {
* console.log(progress);
* })
* await Deploy.extractUpdate((progress) => {
* console.log(progress);
* })
* }
* }
* ```
*/
extractUpdate(progress?: CallbackFunction<number>): Promise<boolean>;
/**
* @description Get a list of the snapshots available on the device.
*
* @since v5.0.0
*
* @return a list of available updates.
*
* @usage
* ```typescript
* async checkVersions() {
* const versions = await Deploy.getAvailableVersions();
* console.log(versions);
* // [
* // {
* // 'versionId': 'versionId1',
* // 'channel': 'CHANNEL_NAME',
* // 'binaryVersion': '1.0.1'
* // },
* // {
* // 'versionId': 'versionId2',
* // 'channel': 'CHANNEL_NAME',
* // 'binaryVersion': '1.0.1'
* // },
* // ]
*
* ```
*/
getAvailableVersions(): Promise<ISnapshotInfo[]>;
/**
*
* @description Get info about the currently deployed update or undefined if none are applied.
*
* @since v5.0.0
*
* @return The info about the currently applied update or undefined if none is applied.
*
* @usage
* ```typescript
* const info = await Deploy.getCurrentVersion()
* console.log(info)
* // {
* // 'versionId': 'UUID_OF_ACTIVE_CODE',
* // 'channel': 'CHANNEL_NAME',
* // 'binaryVersion': 'X.X.X'
* // }
* ```
*/
getCurrentVersion(): Promise<ISnapshotInfo | undefined>;
/**
*
* @description Get info about the update by its versionId
*
* @since v5.0.0
*
* @return The info about the currently applied update or undefined if none is applied.
*
* @usage
* ```typescript
* const info = await Deploy.getVersionById(versionId)
* console.log(info)
* // {
* // 'versionId': 'UUID_OF_VERSION',
* // 'channel': 'CHANNEL_NAME',
* // 'binaryVersion': 'X.X.X'
* // }
* ```
*/
getVersionById(versionId: string): Promise<ISnapshotInfo>;
/**
* @description Reload the app if a more recent version of the app is available.
*
* @since v5.0.0
*
* @return true if the reload succeeded
*
* @usage
* ```typescript
* async performManualUpdate() {
* const update = await Deploy.checkForUpdate()
* if (update.available){
* await Deploy.downloadUpdate((progress) => {
* console.log(progress);
* })
* await Deploy.extractUpdate((progress) => {
* console.log(progress);
* })
* await Deploy.reloadApp();
* }
* }
* ```
*/
reloadApp(): Promise<boolean>;
/**
* @description Check for an update, download it, and apply it in one step.
*
* @since v5.0.0
*
* @param syncOptions (Optional) Application update overrides.
*
* @return The info about the currently applied update or undefined if none is applied.
*
* @usage
* ```typescript
* async performAutomaticUpdate() {
* try {
* const currentVersion = Deploy.getCurrentVersion();
* const resp = await Deploy.sync({updateMethod: 'auto'});
* if (currentVersion.versionId !== resp.versionId){
* // We found an update, and are in process of redirecting you since you put auto!
* }else{
* // No update available
* }
* } catch (err) {
* // We encountered an error.
* }
* }
* ```
*/
sync(syncOptions?: ISyncOptions): Promise<ISnapshotInfo | undefined>;
}
/**
* @hidden
*/
declare class IonicCordovaPlugin {
deploy: IonicDeploy;
declare class IonicCordova implements IPluginBaseAPI {
deploy: IDeployPluginAPI;
constructor();

@@ -308,10 +14,3 @@ getAppInfo(success: CallbackFunction<IAppInfo>, failure: CallbackFunction<string>): void;

}
/**
* @hidden
*/
export declare const IonicCordova: IonicCordovaPlugin;
/**
* @hidden
*/
export declare const Deploy: IonicDeploy;
export {};
declare const instance: IonicCordova;
export = instance;

@@ -1,232 +0,2 @@

/**
* The configuration for the deploy plugin on the device.
*/
export interface IDeployConfig {
/**
* The [Ionic](https://ionicframework.com/docs/appflow/) app id.
*/
appId?: string;
/**
* whether or not the app should in debug mode
*/
debug?: boolean;
/**
* @ignore
*/
host?: string;
/**
* The [channel](https://ionicframework.com/docs/pro/deploy/channels) that the plugin should listen for updates on.
*/
channel?: string;
/**
* The number of previous updates to be cached on the device
*/
maxVersions?: number;
/**
* The number of seconds the app should be in the background for before the plugin considers it closed
* and checks for an updated on resume of the app.
*/
minBackgroundDuration?: number;
/**
* The update method the app should use when checking for available updates
*/
updateMethod?: 'none' | 'auto' | 'background';
}
/**
* The current configuration for the deploy plugin on the device.
*/
export interface ICurrentConfig {
/**
* The [Ionic Pro](https://ionicframework.com/docs/pro/) app id.
*/
appId: string;
/**
* The [channel](https://ionicframework.com/docs/pro/deploy/channels) that the plugin should listen for updates on.
*/
channel: string;
/**
* @deprecated
* The binary version of the native bundle versionName on Android or CFBundleShortVersionString on iOS
* deprecated in favor of versionName
*/
binaryVersion: string;
/**
* The binary version of the native bundle versionName on Android or CFBundleShortVersionString on iOS
*/
binaryVersionName: string;
/**
* The build version code of the native bundle versionCode on Android or CFBundleVersion on iOS
*/
binaryVersionCode: string;
/**
* Whether the user disabled deploy updates or not.
*/
disabled: boolean;
/**
* The host API the plugin is configured to check for updates from.
*/
host: string;
/**
* The currently configured updateMethod for the plugin.
*/
updateMethod: 'none' | 'auto' | 'background';
/**
* The maximum number of updates to be stored locally on the device.
*/
maxVersions: number;
/**
* The number of seconds the app needs to be in the background before the plugin considers it
* closed for the purposes of fetching and applying a new update.
*/
minBackgroundDuration: number;
/**
* The id of the currently applied updated or undefined if none is applied.
*/
currentVersionId?: string;
/**
* The id of the currently applied build or undefined if none is applied.
*/
currentBuildId?: string;
}
/**
* Information about a snapshot
*/
export interface ISnapshotInfo {
/**
* @deprecated in favor of [versionId](#versionid)
*
* The id for the snapshot.
*/
deploy_uuid: string;
/**
* The id for the snapshot.
*/
versionId: string;
/**
* The id for the snapshot.
*/
buildId: string;
/**
* The channel that the snapshot was downloaded for..
*/
channel: string;
/**
* @deprecated in favor of [binaryVersion](#binaryversion)
*
* The binary version the snapshot was downloaded for.
*/
binary_version: string;
/**
* @deprecated
* The binary version the snapshot was downloaded for.
* The versionName on Android or CFBundleShortVersionString on iOS this is the end user readable version listed on the stores.
*/
binaryVersion: string;
/**
* The binary version name the snapshot was downloaded for.
* The versionName on Android or CFBundleShortVersionString on iOS this is the end user readable version listed on the stores.
*/
binaryVersionName: string;
/**
* The binary version build code the snapshot was downloaded for.
* The versionCode on Android or CFBundleVersion on iOS this should be changed every time you do a new build debug or otherwise.
*/
binaryVersionCode: string;
}
/**
* Configuration options for the call to `sync`
*/
export interface ISyncOptions {
/**
* Whether the update should be applied immediately or on the next app start.
*/
updateMethod?: 'background' | 'auto';
}
/**
* The response object describing if an update is available.
*/
export interface CheckForUpdateResponse {
/**
* Whether or not an update is available.
*/
available: boolean;
/**
* Equivalent to available since v5 this can be ignored in favor of available
* @deprecated
*/
compatible: boolean;
/**
* Legacy indicator of whether the update is a partial one. This will always be false and can be ignored
* @deprecated
*/
partial: false;
/**
* The id of the snapshot if available.
*/
snapshot?: string;
/**
* The id of the build if available.
*/
build?: string;
/**
* The url to fetch the manifest of files in the update.
*/
url?: string;
/**
* Whether or not there is an update available that is not compatible with this device.
*/
incompatibleUpdateAvailable?: boolean;
}
/**
* Information about the application.
*/
export interface IAppInfo {
/**
* The platform that the app is currently installed on.
*/
platform: 'ios' | 'android';
/**
* The version of the native platform.
*/
platformVersion: string;
/**
* @deprecated
* The versionCode on Android or CFBundleVersion on iOS this should be changed every time you do a new build debug or otherwise.
*/
version: string;
/**
* The versionCode on Android or CFBundleVersion on iOS this should be changed every time you do a new build debug or otherwise.
*/
binaryVersionCode: string | number;
/**
* The bundle name.
*/
bundleName: string;
/**
* @deprecated
* The versionName on Android or CFBundleShortVersionString on iOS this is the end user readable version listed on the stores.
*/
bundleVersion: string;
/**
* The versionName on Android or CFBundleShortVersionString on iOS this is the end user readable version listed on the stores.
*/
binaryVersionName: string;
/**
* A generated device ID (NOT a native device ID)
*/
device: string;
/**
* Directory where the snapshots are stored
*/
dataDirectory: string;
}
/**
* A callback function to handle the result.
*/
export interface CallbackFunction<T> {
(result?: T): void;
}
/**
* @hidden
*/
import { ICurrentConfig } from './IonicCordova';
export interface IAvailableUpdate {

@@ -242,5 +12,2 @@ binaryVersionName: string;

}
/**
* @hidden
*/
export interface ISavedPreferences extends ICurrentConfig {

@@ -252,5 +19,2 @@ availableUpdate?: IAvailableUpdate;

}
/**
* @hidden
*/
export interface UpdateInfo {

@@ -260,5 +24,2 @@ versionId: string;

}
/**
* @hidden
*/
export interface ManifestFileEntry {

@@ -269,5 +30,2 @@ integrity: string;

}
/**
* @hidden
*/
export interface FetchManifestResp {

@@ -274,0 +32,0 @@ manifestJson: ManifestFileEntry[];

@@ -1,2 +0,2 @@

import { IDeployConfig } from './definitions';
import { IDeployConfig } from './IonicCordova';
export declare function isPluginConfig(o: object): o is IDeployConfig;

@@ -1,2 +0,15 @@

export { Deploy, IonicCordova } from './common';
export * from './definitions';
import { CallbackFunction, IDeployConfig, ISyncOptions } from './IonicCordova';
export declare class DeployClass implements IDeployPluginAPI {
configure(config: IDeployConfig): Promise<void>;
getConfiguration(): Promise<import("./IonicCordova").ICurrentConfig>;
checkForUpdate(): Promise<import("./IonicCordova").CheckForUpdateResponse>;
downloadUpdate(progress?: CallbackFunction<number>): Promise<boolean>;
extractUpdate(progress?: CallbackFunction<number>): Promise<boolean>;
reloadApp(): Promise<boolean>;
sync(options: ISyncOptions, progress?: CallbackFunction<number>): Promise<import("./IonicCordova").ISnapshotInfo | undefined>;
getCurrentVersion(): Promise<import("./IonicCordova").ISnapshotInfo | undefined>;
getAvailableVersions(): Promise<import("./IonicCordova").ISnapshotInfo[]>;
deleteVersionById(versionId: string): Promise<boolean>;
getVersionById(versionId: string): Promise<import("./IonicCordova").ISnapshotInfo | undefined>;
}
export declare const Deploy: DeployClass;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var common_1 = require("./common");
exports.Deploy = common_1.Deploy;
exports.IonicCordova = common_1.IonicCordova;
/**
* @hidden
*/
var deviceready = new Promise(function (resolve, rejects) {
document.addEventListener('deviceready', function () {
if (window.IonicCordova) {
return resolve(window.IonicCordova.deploy);
}
return rejects('cordova-plugin-ionic not found. Are you sure you installed it?');
});
});
var DeployClass = /** @class */ (function () {
function DeployClass() {
}
DeployClass.prototype.configure = function (config) {
return __awaiter(this, void 0, void 0, function () {
var deploy;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, deviceready];
case 1:
deploy = _a.sent();
return [2 /*return*/, deploy.configure(config)];
}
});
});
};
DeployClass.prototype.getConfiguration = function () {
return __awaiter(this, void 0, void 0, function () {
var deploy;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, deviceready];
case 1:
deploy = _a.sent();
return [2 /*return*/, deploy.getConfiguration()];
}
});
});
};
DeployClass.prototype.checkForUpdate = function () {
return __awaiter(this, void 0, void 0, function () {
var deploy;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, deviceready];
case 1:
deploy = _a.sent();
return [2 /*return*/, deploy.checkForUpdate()];
}
});
});
};
DeployClass.prototype.downloadUpdate = function (progress) {
return __awaiter(this, void 0, void 0, function () {
var deploy;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, deviceready];
case 1:
deploy = _a.sent();
return [2 /*return*/, deploy.downloadUpdate(progress)];
}
});
});
};
DeployClass.prototype.extractUpdate = function (progress) {
return __awaiter(this, void 0, void 0, function () {
var deploy;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, deviceready];
case 1:
deploy = _a.sent();
return [2 /*return*/, deploy.extractUpdate(progress)];
}
});
});
};
DeployClass.prototype.reloadApp = function () {
return __awaiter(this, void 0, void 0, function () {
var deploy;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, deviceready];
case 1:
deploy = _a.sent();
return [2 /*return*/, deploy.reloadApp()];
}
});
});
};
DeployClass.prototype.sync = function (options, progress) {
return __awaiter(this, void 0, void 0, function () {
var deploy;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, deviceready];
case 1:
deploy = _a.sent();
return [2 /*return*/, deploy.sync(options, progress)];
}
});
});
};
DeployClass.prototype.getCurrentVersion = function () {
return __awaiter(this, void 0, void 0, function () {
var deploy;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, deviceready];
case 1:
deploy = _a.sent();
return [2 /*return*/, deploy.getCurrentVersion()];
}
});
});
};
DeployClass.prototype.getAvailableVersions = function () {
return __awaiter(this, void 0, void 0, function () {
var deploy;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, deviceready];
case 1:
deploy = _a.sent();
return [2 /*return*/, deploy.getAvailableVersions()];
}
});
});
};
DeployClass.prototype.deleteVersionById = function (versionId) {
return __awaiter(this, void 0, void 0, function () {
var deploy;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, deviceready];
case 1:
deploy = _a.sent();
return [2 /*return*/, deploy.deleteVersionById(versionId)];
}
});
});
};
DeployClass.prototype.getVersionById = function (versionId) {
return __awaiter(this, void 0, void 0, function () {
var deploy;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, deviceready];
case 1:
deploy = _a.sent();
return [2 /*return*/, deploy.getVersionById(versionId)];
}
});
});
};
return DeployClass;
}());
exports.DeployClass = DeployClass;
exports.Deploy = new DeployClass();
{
"name": "cordova-plugin-ionic",
"version": "5.4.0-0",
"version": "5.4.0-1",
"cordova": {

@@ -12,21 +12,4 @@ "id": "cordova-plugin-ionic",

"main": "dist/index.js",
"types": "dist/IonicCordova.d.ts",
"description": "Ionic Cordova SDK",
"engines": {
"cordovaDependencies": {
">5.0.0": {
"cordova-plugin-splashscreen": ">=5.0.1",
"cordova-plugin-file": ">=6.0.1",
"cordova-plugin-webview": ">=2.1.0"
},
"4.1.7": {
"cordova-plugin-splashscreen": ">=5.0.1"
},
"3.1.3": {
"cordova-plugin-splashscreen": ">=5.0.1"
},
"2.0.4": {
"cordova-plugin-splashscreen": ">=4.0.0"
}
}
},
"scripts": {

@@ -64,10 +47,2 @@ "apply-dev": "npm run build && ./apply-changes.sh",

],
"dependencies": {
"@ionic/typedoc-plugin-markdown": "^1.0.5",
"@types/cordova-plugin-file-transfer": "^1.6.2",
"mkpath": ">=1.0.0",
"node-version-compare": ">=1.0.1",
"plist": ">=1.2.0",
"xml2js": ">=0.4"
},
"author": "Ionic",

@@ -87,3 +62,2 @@ "contributors": [

"@types/cordova": "0.0.34",
"cordova-plugin-file": "^6.0.1",
"jest": "^22.4.3",

@@ -96,5 +70,6 @@ "np": "^3.0.4",

"tslint-ionic-rules": "0.0.14",
"typedoc": "^0.14.2",
"typescript": "^2.6.2",
"watch": "^1.0.2"
"typedoc": "^0.11.1",
"typedoc-plugin-markdown": "^1.1.6",
"watch": "^1.0.2",
"@angular/core": "^7.2.15"
},

@@ -115,3 +90,6 @@ "jest": {

"testRegex": "tests/.*\\.(ts|js)$"
},
"dependencies": {
"typescript": "^3.5.3"
}
}

@@ -0,32 +1,75 @@

Ionic Cordova SDK
======
Supported platforms: iOS, Android
## Setup
```bash
cordova plugin add cordova-plugin-ionic --save --variable APP_ID="abcd1234" --variable CHANNEL_NAME="Master" --variable UPDATE_METHOD="background"
```
The plugin will be available on `window` as `IonicCordova`
**NOTE**: The plugin delays the cordova ready event until it finish checking for updates and add this preference to the app `<preference name="AutoHideSplashScreen" value="false"/>`, which makes the Splash Screen to not go away automatically. All Ionic templates run `this.splashScreen.hide();` on cordova ready event, but if it was removed it should be added back. Alternatively the app can add `<preference name="AutoHideSplashScreen" value="true"/>` to override the value added by the plugin, but that can lead to the Splash Screen going away before the download is complete.
## Live Updates
### Cordova Install Variables
* `APP_ID` **Required** - Your Ionic Pro app ID
* `CHANNEL_NAME` **Required** - The channel to check for updates from
* `UPDATE_API` - The location of the Ionic Pro API (only change this for development)
* `UPDATE_METHOD` - `auto`, `background`, or `none`. Dictates the behavior of the plugin. `auto` will download and apply the latest update on app start, potentially leading to long splash screen loads if the connection is slow. `background` will only download the update in the background on app start, but will allow full functionality while doing so, only redirecting users the _next_ time the app is loaded. `none` will do nothing, leaving full plugin functionality in the hands of the developer. **Default is `background`**
* `MAX_STORE` - The maximum number of downloaded versions to store on the device for quick loading. More versions means less downloading, but can increase the app size greatly. **Default is 3 (Defaults is 2 in V5)**
* `MIN_BACKGROUND_DURATION` - The minimum duration in seconds after which the app in background checks for an update. **Default is 30 (New in V5)**
### Preferences
* `DisableDeploy` - Default value is `false`.
Allows to disable deploy updates by adding this preference in the config.xml
```
<preference name="DisableDeploy" value="true" />
```
## API Docs
* [IonicCordova](docs/interfaces/ipluginbaseapi.md)
* [IonicCordova.deploy](docs/interfaces/ideploypluginapi.md)
### External modules
---
previousText: 'Channels'
previousUrl: '/docs/appflow/deploy/channels'
nextText: 'Tutorials and Videos'
nextUrl: '/docs/appflow/deploy/tutorials'
---
## Installation and Usage
In order to use the Deploy API inside of your app. You simply need to install the latest version of the Appflow
SDK and set the `UPDATE_METHOD` to `none`:
## Contributing to this plugin
<command-line>
<command-prompt>
ionic cordova plugin add cordova-plugin-ionic --variable UPDATE_METHOD="none" --variable APP_ID="YOUR_APP_ID" --variable CHANNEL_NAME="YOUR_CHANNEL_NAME"
</command-prompt>
</command-line>
```bash
npm install
npm run create-dev
```
Then you can import the Deploy API in order to it in your code:
```typescript
import { Deploy } from 'cordova-plugin-ionic';
This will create a blank Ionic app in a local `tmp` directory with the plugin and dependencies installed, and the iOS platform added. Native plugin code is installed with `--link` and any changes to the typescript in `www` will be copied over into the app's `platforms/ios` and `platforms/android` directories.
...
### Some other helpful dev commands
```bash
npm run apply-dev
```
async changeToBetaChannel() {
await Deploy.configure({channel: 'BETA'});
}
Updates the linked plugin in the `tmp` test app with your JavaScript changes
...
```bash
npm run watch
```
Watches for Typescript changes
```bash
npm run watch-dev
```
Watches for Typescript changes, then runs the `apply-dev` script to propogate them to the testing app.

@@ -6,2 +6,3 @@ {

"declaration": true,
"experimentalDecorators": true,
"importHelpers": false,

@@ -16,7 +17,2 @@ "module": "commonjs",

"target": "es5",
"types": [
"cordova",
"cordova-plugin-file",
"cordova-plugin-file-transfer"
],
"lib": [

@@ -23,0 +19,0 @@ "es2015",

{
"extends": "tslint-ionic-rules"
"extends": "tslint-ionic-rules",
"rules": {
"eofline": false
}
}

@@ -0,37 +1,16 @@

/// <reference types="cordova" />
import {
CallbackFunction,
CheckForUpdateResponse,
FetchManifestResp,
IAppInfo,
IAvailableUpdate,
ICurrentConfig,
IDeployConfig,
ISavedPreferences,
IPluginBaseAPI,
ISnapshotInfo,
ISyncOptions,
ManifestFileEntry,
} from './definitions';
} from './IonicCordova';
import {
isPluginConfig
} from './guards';
/**
* @hidden
*/
declare global {
interface Window {
IonicCordova: IonicCordovaPlugin;
}
}
/**
* @hidden
*/
declare const cordova: Cordova;
/**
* @hidden
*/
const channel = cordova.require('cordova/channel');

@@ -41,22 +20,6 @@ channel.createSticky('onIonicProReady');

/**
* @hidden
*/
declare const resolveLocalFileSystemURL: Window['resolveLocalFileSystemURL'] ;
/**
* @hidden
*/
declare const Ionic: any;
/**
* @hidden
*/
declare const WEBVIEW_SERVER_URL: string;
/**
* @hidden
*/
declare const Capacitor: any;
/**
* @hidden
*/
enum UpdateMethod {

@@ -68,5 +31,2 @@ BACKGROUND = 'background',

/**
* @hidden
*/
enum UpdateState {

@@ -78,6 +38,13 @@ Available = 'available',

import {
FetchManifestResp, IAvailableUpdate,
ISavedPreferences,
ManifestFileEntry,
} from './definitions';
/**
* @hidden
*/
import {
isPluginConfig
} from './guards';
class Path {

@@ -100,4 +67,4 @@ static join(...paths: string[]): string {

* The plugin API for the live updates feature.
* @hidden
*/
class IonicDeployImpl {

@@ -110,3 +77,3 @@

private MANIFEST_FILE = 'pro-manifest.json';
public PLUGIN_VERSION = '5.4.0-0';
public PLUGIN_VERSION = '5.4.0-1';

@@ -162,3 +129,3 @@ constructor(appInfo: IAppInfo, preferences: ISavedPreferences) {

getSnapshotCacheDir(versionId: string): string {
return Path.join(this.appInfo.dataDirectory, this.SNAPSHOT_CACHE, versionId);
return new URL(Path.join(this.appInfo.dataDirectory, this.SNAPSHOT_CACHE, versionId)).pathname;
}

@@ -171,3 +138,3 @@

}
return Path.join(cordova.file.applicationDirectory, folder);
return folder;
}

@@ -300,3 +267,3 @@

console.log(`About to download ${manifest.length} new files for update.`);
const maxBatch = 20;
const maxBatch = 2000;
let numberBatches = Math.round(manifest.length / maxBatch);

@@ -400,4 +367,4 @@ if (manifest.length % maxBatch !== 0) {

// Reload the webview
const newLocation = new URL(this.getSnapshotCacheDir(prefs.currentVersionId));
Ionic.WebView.setServerBasePath(newLocation.pathname);
const newLocation = this.getSnapshotCacheDir(prefs.currentVersionId);
Ionic.WebView.setServerBasePath(newLocation);
return true;

@@ -456,4 +423,3 @@ }

try {
const dirEntry = await this._fileManager.getDirectory(snapshotDir, false);
await (new Promise( (resolve, reject) => dirEntry.removeRecursively(resolve, reject)));
await this._fileManager.remove(snapshotDir);
timer.end();

@@ -468,11 +434,10 @@ } catch (e) {

const timer = new Timer('CopyBaseApp');
return new Promise( async (resolve, reject) => {
try {
const rootAppDirEntry = await this._fileManager.getDirectory(this.getBundledAppDir(), false);
const snapshotCacheDirEntry = await this._fileManager.getDirectory(this.getSnapshotCacheDir(''), true);
rootAppDirEntry.copyTo(snapshotCacheDirEntry, versionId, () => { timer.end(); resolve(); }, reject);
} catch (e) {
reject(e);
}
await this._fileManager.copyTo({
source: {
path: this.getBundledAppDir(),
directory: 'APPLICATION',
},
target: this.getSnapshotCacheDir(versionId),
});
timer.end();
}

@@ -488,6 +453,6 @@

async getVersionById(versionId: string): Promise<ISnapshotInfo> {
async getVersionById(versionId: string): Promise<ISnapshotInfo | undefined> {
const update = this._savedPreferences.updates[versionId];
if (!update) {
throw Error(`No update available with versionId ${versionId}`);
return;
}

@@ -570,3 +535,3 @@ return this._convertToSnapshotInfo(update);

async sync(syncOptions: ISyncOptions = {}): Promise<ISnapshotInfo | undefined> {
async sync(syncOptions: ISyncOptions = {}, progress?: CallbackFunction<number>): Promise<ISnapshotInfo | undefined> {
const prefs = this._savedPreferences;

@@ -577,2 +542,6 @@

const wrappedProgress = progress ? (complete?: number) => {
progress(complete);
} : undefined;
await this.checkForUpdate();

@@ -582,5 +551,6 @@

if (prefs.availableUpdate.state === UpdateState.Available) {
await this.downloadUpdate();
await this.downloadUpdate(wrappedProgress);
}
if (prefs.availableUpdate.state === UpdateState.Pending) {
// ignore progress from this since it's trivial
await this.extractUpdate();

@@ -609,81 +579,20 @@ }

/**
* @hidden
*/
class FileManager {
async getDirectory(path: string, createDirectory = true): Promise<DirectoryEntry> {
return new Promise<DirectoryEntry>((resolve, reject) => {
resolveLocalFileSystemURL(
path,
entry => entry.isDirectory ? resolve(entry as DirectoryEntry) : reject(),
async () => {
const components = path.split('/');
const child = components.pop() as string;
try {
const parent = (await this.getDirectory(components.join('/'), createDirectory)) as DirectoryEntry;
parent.getDirectory(child, {create: createDirectory}, async entry => {
if (entry.fullPath === path) {
resolve(entry);
} else {
resolve(await this.getDirectory(path, createDirectory));
}
}, reject);
} catch (e) {
reject(e);
}
}
);
async copyTo(options: { source: { directory: string; path: string; } , target: string}) {
return new Promise<void>( (resolve, reject) => {
cordova.exec(resolve, reject, 'IonicCordovaCommon', 'copyTo', [options]);
});
}
async resolvePath(): Promise<DirectoryEntry> {
return new Promise<DirectoryEntry>((resolve, reject) => {
resolveLocalFileSystemURL(cordova.file.dataDirectory, (rootDirEntry: Entry) => {
resolve(rootDirEntry as DirectoryEntry);
}, reject);
async remove(path: string) {
return new Promise<void>( (resolve, reject) => {
cordova.exec(resolve, reject, 'IonicCordovaCommon', 'remove', [{target: path}]);
});
}
async getFile(fullPath: string): Promise<string> {
const normalizedURL = Ionic.WebView.convertFileSrc(fullPath);
const req = await fetch(normalizedURL);
return req.text();
}
async getFileEntry(path: string, fileName: string) {
const dirEntry = await this.getDirectory(path, false);
return new Promise<FileEntry>((resolve, reject) => {
dirEntry.getFile(fileName, {create: false, exclusive: false}, resolve, reject);
async downloadAndWriteFile(url: string, path: string) {
return new Promise<void>( (resolve, reject) => {
cordova.exec(resolve, reject, 'IonicCordovaCommon', 'downloadFile', [{url, target: path}]);
});
}
async fileExists(path: string, fileName: string) {
try {
await this.getFileEntry(path, fileName);
return true;
} catch (e) {
return false;
}
}
async copyTo(oldPath: string, oldFileName: string, newPath: string, newFileName: string) {
const fileEntry = await this.getFileEntry(oldPath, oldFileName);
const newDirEntry = await this.getDirectory(newPath);
return new Promise((resolve, reject) => {
fileEntry.copyTo(newDirEntry, newFileName, resolve, reject);
});
}
async removeFile(path: string, filename: string) {
const fileEntry = await this.getFileEntry(path, filename);
return new Promise((resolve, reject) => {
fileEntry.remove(resolve, reject);
});
}
async downloadAndWriteFile(url: string, path: string) {
const fileT = new FileTransfer();
return new Promise<FileEntry>((resolve, reject) => fileT.download(url, path, resolve, reject));
}
}

@@ -693,31 +602,4 @@

/**
* The Ionic Deploy Plugin API
* @usage
* ```typescript
* async performManualUpdate() {
* const update = await Deploy.checkForUpdate()
* if (update.available){
* // We have an update!
* }
* }
* ```
*
* ## Methods
*
* The plugin contains many functions that can help you utilize Deploy inside of your app.
* * {@link checkForUpdate}
* * {@link configure}
* * {@link deleteVersionById}
* * {@link downloadUpdate}
* * {@link extractUpdate}
* * {@link getAvailableVersions}
* * {@link getConfiguration}
* * {@link getCurrentVersion}
* * {@link getVersionById}
* * {@link reloadApp}
* * {@link sync}
*/
class IonicDeploy {
private parent: IonicCordovaPlugin;
class IonicDeploy implements IDeployPluginAPI {
private parent: IPluginBaseAPI;
private delegate: Promise<IonicDeployImpl>;

@@ -729,6 +611,3 @@ private fetchIsAvailable: boolean;

/**
* @hidden
*/
constructor(parent: IonicCordovaPlugin) {
constructor(parent: IPluginBaseAPI) {
this.parent = parent;

@@ -740,3 +619,3 @@ this.delegate = this.initialize();

private async initialize() {
async initialize() {
const preferences = await this._initPreferences();

@@ -762,3 +641,3 @@ this.minBackgroundDuration = preferences.minBackgroundDuration;

private async onLoad() {
async onLoad() {
document.addEventListener('pause', this.onPause.bind(this));

@@ -769,7 +648,7 @@ document.addEventListener('resume', this.onResume.bind(this));

private async onPause() {
async onPause() {
this.lastPause = Date.now();
}
private async onResume() {
async onResume() {
if (!this.disabled && this.lastPause && this.minBackgroundDuration && Date.now() - this.lastPause > this.minBackgroundDuration * 1000) {

@@ -780,3 +659,3 @@ await (await this.delegate)._handleInitialPreferenceState();

private async _initPreferences(): Promise<ISavedPreferences> {
async _initPreferences(): Promise<ISavedPreferences> {
return new Promise<ISavedPreferences>(async (resolve, reject) => {

@@ -799,19 +678,2 @@ try {

/**
* @description Check for available updates for the currently configured app id and channel.
*
* @since v5.0.0
*
* @returns A response describing an update if one is available.
*
* @usage
* ```typescript
* async performManualUpdate() {
* const update = await Deploy.checkForUpdate()
* if (update.available){
* // We have an update!
* }
* }
* ```
*/
async checkForUpdate(): Promise<CheckForUpdateResponse> {

@@ -824,20 +686,2 @@ if (!this.disabled) {

/**
* @description Update the default configuration for the plugin on the current device. The new configuration will be persisted across app close and binary updates.
*
* @since v5.0.0
*
* @param config The new configuration for the plugin on this device.
*
* @usage
* ```typescript
* async configureDeploy() {
* const config = {
* 'appId': 'YOUR_APP_ID',
* 'channel': 'CHANNEL_NAME'
* }
* await Deploy.configure(config);
* }
* ```
*/
async configure(config: IDeployConfig): Promise<void> {

@@ -847,27 +691,2 @@ if (!this.disabled) return (await this.delegate).configure(config);

/**
* @description Get the current configuration for the plugin on the current device.
*
* @since v5.0.0
*
* @return The current configuration of the plugin.
*
* @usage
* ```typescript
* const info = Deploy.getConfiguration()
* console.log(info)
* // {
* // 'appId': 'abcd1234',
* // 'channel': 'MY_CHANNEL_NAME',
* // 'binaryVersionName': 'X.X.X',
* // 'binaryVersionCode': 'X.X.X', (string on iOS number on Android)
* // 'disabled': false,
* // 'updateMethod': 'auto',
* // 'maxVersions': 3,
* // 'minBackgroundDuration': 30,
* // 'currentVersionId': 'xxxx-xxxx-xxxx-xxxx'
* // 'currentBuildId' : 'xxxxxxx'
* // }
* ```
*/
async getConfiguration(): Promise<ICurrentConfig> {

@@ -891,17 +710,2 @@ return new Promise<ICurrentConfig>(async (resolve, reject) => {

/**
* @description Remove the files specific to a snapshot from the device.
*
* @param version The versionId
*
* @return true if the update was deleted.
*
* @usage
* ```typescript
* async deleteVersion() {
* const versions = await Deploy.getAvailableVersions();
* Deploy.deleteVersionById(versions[0].versionId);
* }
* ```
*/
async deleteVersionById(version: string): Promise<boolean> {

@@ -912,23 +716,2 @@ if (!this.disabled) return (await this.delegate).deleteVersionById(version);

/**
* @description Download the new files from an available update found by the checkForUpdate method and prepare the update.
*
* @since v5.0.0
*
* @param progress A progress callback function which will be called with a number representing the percent of completion of the download and prepare.
*
* @return true if the download succeeded
*
* @usage
* ```typescript
* async performManualUpdate() {
* const update = await Deploy.checkForUpdate()
* if (update.available){
* await Deploy.downloadUpdate((progress) => {
* console.log(progress);
* })
* }
* }
* ```
*/
async downloadUpdate(progress?: CallbackFunction<number>): Promise<boolean> {

@@ -939,26 +722,2 @@ if (!this.disabled) return (await this.delegate).downloadUpdate(progress);

/**
* @description Extract a downloaded bundle of updated files.
*
* @since v5.0.0
*
* @param progress A progress callback function which will be called with a number representing the percent of completion of the extract.
*
* @return true if the extract succeeded
*
* @usage
* ```typescript
* async performManualUpdate() {
* const update = await Deploy.checkForUpdate()
* if (update.available){
* await Deploy.downloadUpdate((progress) => {
* console.log(progress);
* })
* await Deploy.extractUpdate((progress) => {
* console.log(progress);
* })
* }
* }
* ```
*/
async extractUpdate(progress?: CallbackFunction<number>): Promise<boolean> {

@@ -969,29 +728,2 @@ if (!this.disabled) return (await this.delegate).extractUpdate(progress);

/**
* @description Get a list of the snapshots available on the device.
*
* @since v5.0.0
*
* @return a list of available updates.
*
* @usage
* ```typescript
* async checkVersions() {
* const versions = await Deploy.getAvailableVersions();
* console.log(versions);
* // [
* // {
* // 'versionId': 'versionId1',
* // 'channel': 'CHANNEL_NAME',
* // 'binaryVersion': '1.0.1'
* // },
* // {
* // 'versionId': 'versionId2',
* // 'channel': 'CHANNEL_NAME',
* // 'binaryVersion': '1.0.1'
* // },
* // ]
*
* ```
*/
async getAvailableVersions(): Promise<ISnapshotInfo[]> {

@@ -1002,21 +734,2 @@ if (!this.disabled) return (await this.delegate).getAvailableVersions();

/**
*
* @description Get info about the currently deployed update or undefined if none are applied.
*
* @since v5.0.0
*
* @return The info about the currently applied update or undefined if none is applied.
*
* @usage
* ```typescript
* const info = await Deploy.getCurrentVersion()
* console.log(info)
* // {
* // 'versionId': 'UUID_OF_ACTIVE_CODE',
* // 'channel': 'CHANNEL_NAME',
* // 'binaryVersion': 'X.X.X'
* // }
* ```
*/
async getCurrentVersion(): Promise<ISnapshotInfo | undefined> {

@@ -1027,49 +740,7 @@ if (!this.disabled) return (await this.delegate).getCurrentVersion();

/**
*
* @description Get info about the update by its versionId
*
* @since v5.0.0
*
* @return The info about the currently applied update or undefined if none is applied.
*
* @usage
* ```typescript
* const info = await Deploy.getVersionById(versionId)
* console.log(info)
* // {
* // 'versionId': 'UUID_OF_VERSION',
* // 'channel': 'CHANNEL_NAME',
* // 'binaryVersion': 'X.X.X'
* // }
* ```
*/
async getVersionById(versionId: string): Promise<ISnapshotInfo> {
async getVersionById(versionId: string): Promise<ISnapshotInfo | undefined> {
if (!this.disabled) return (await this.delegate).getVersionById(versionId);
throw Error(`No update available with versionId ${versionId}`);
return;
}
/**
* @description Reload the app if a more recent version of the app is available.
*
* @since v5.0.0
*
* @return true if the reload succeeded
*
* @usage
* ```typescript
* async performManualUpdate() {
* const update = await Deploy.checkForUpdate()
* if (update.available){
* await Deploy.downloadUpdate((progress) => {
* console.log(progress);
* })
* await Deploy.extractUpdate((progress) => {
* console.log(progress);
* })
* await Deploy.reloadApp();
* }
* }
* ```
*/
async reloadApp(): Promise<boolean> {

@@ -1080,30 +751,4 @@ if (!this.disabled) return (await this.delegate).reloadApp();

/**
* @description Check for an update, download it, and apply it in one step.
*
* @since v5.0.0
*
* @param syncOptions (Optional) Application update overrides.
*
* @return The info about the currently applied update or undefined if none is applied.
*
* @usage
* ```typescript
* async performAutomaticUpdate() {
* try {
* const currentVersion = Deploy.getCurrentVersion();
* const resp = await Deploy.sync({updateMethod: 'auto'});
* if (currentVersion.versionId !== resp.versionId){
* // We found an update, and are in process of redirecting you since you put auto!
* }else{
* // No update available
* }
* } catch (err) {
* // We encountered an error.
* }
* }
* ```
*/
async sync(syncOptions: ISyncOptions = {}): Promise<ISnapshotInfo | undefined> {
if (!this.disabled) return (await this.delegate).sync(syncOptions);
async sync(syncOptions: ISyncOptions = {}, progress?: CallbackFunction<number>): Promise<ISnapshotInfo | undefined> {
if (!this.disabled) return (await this.delegate).sync(syncOptions, progress);
return;

@@ -1115,7 +760,10 @@ }

/**
* @hidden
* BASE API
*
* All features of the Ionic Cordova plugin are registered here, along with some low level error tracking features used
* by the monitoring service.
*/
class IonicCordovaPlugin {
class IonicCordova implements IPluginBaseAPI {
public deploy: IonicDeploy;
public deploy: IDeployPluginAPI;

@@ -1144,14 +792,2 @@ constructor() {

/**
* @hidden
*/
export const IonicCordova = new IonicCordovaPlugin();
/**
* @hidden
*/
export const Deploy = IonicCordova.deploy;
/**
* @hidden
*/
class Timer {

@@ -1180,1 +816,4 @@ name: string;

}
const instance = new IonicCordova();
export = instance;

@@ -1,278 +0,3 @@

/**
* The configuration for the deploy plugin on the device.
*/
export interface IDeployConfig {
import { ICurrentConfig } from './IonicCordova';
/**
* The [Ionic](https://ionicframework.com/docs/appflow/) app id.
*/
appId?: string;
/**
* whether or not the app should in debug mode
*/
debug?: boolean;
/**
* @ignore
*/
host?: string;
/**
* The [channel](https://ionicframework.com/docs/pro/deploy/channels) that the plugin should listen for updates on.
*/
channel?: string;
/**
* The number of previous updates to be cached on the device
*/
maxVersions?: number;
/**
* The number of seconds the app should be in the background for before the plugin considers it closed
* and checks for an updated on resume of the app.
*/
minBackgroundDuration?: number;
/**
* The update method the app should use when checking for available updates
*/
updateMethod?: 'none' | 'auto' | 'background';
}
/**
* The current configuration for the deploy plugin on the device.
*/
export interface ICurrentConfig {
/**
* The [Ionic Pro](https://ionicframework.com/docs/pro/) app id.
*/
appId: string;
/**
* The [channel](https://ionicframework.com/docs/pro/deploy/channels) that the plugin should listen for updates on.
*/
channel: string;
/**
* @deprecated
* The binary version of the native bundle versionName on Android or CFBundleShortVersionString on iOS
* deprecated in favor of versionName
*/
binaryVersion: string;
/**
* The binary version of the native bundle versionName on Android or CFBundleShortVersionString on iOS
*/
binaryVersionName: string;
/**
* The build version code of the native bundle versionCode on Android or CFBundleVersion on iOS
*/
binaryVersionCode: string;
/**
* Whether the user disabled deploy updates or not.
*/
disabled: boolean;
/**
* The host API the plugin is configured to check for updates from.
*/
host: string;
/**
* The currently configured updateMethod for the plugin.
*/
updateMethod: 'none' | 'auto' | 'background';
/**
* The maximum number of updates to be stored locally on the device.
*/
maxVersions: number;
/**
* The number of seconds the app needs to be in the background before the plugin considers it
* closed for the purposes of fetching and applying a new update.
*/
minBackgroundDuration: number;
/**
* The id of the currently applied updated or undefined if none is applied.
*/
currentVersionId?: string;
/**
* The id of the currently applied build or undefined if none is applied.
*/
currentBuildId?: string;
}
/**
* Information about a snapshot
*/
export interface ISnapshotInfo {
/**
* @deprecated in favor of [versionId](#versionid)
*
* The id for the snapshot.
*/
deploy_uuid: string;
/**
* The id for the snapshot.
*/
versionId: string;
/**
* The id for the snapshot.
*/
buildId: string;
/**
* The channel that the snapshot was downloaded for..
*/
channel: string;
/**
* @deprecated in favor of [binaryVersion](#binaryversion)
*
* The binary version the snapshot was downloaded for.
*/
binary_version: string;
/**
* @deprecated
* The binary version the snapshot was downloaded for.
* The versionName on Android or CFBundleShortVersionString on iOS this is the end user readable version listed on the stores.
*/
binaryVersion: string;
/**
* The binary version name the snapshot was downloaded for.
* The versionName on Android or CFBundleShortVersionString on iOS this is the end user readable version listed on the stores.
*/
binaryVersionName: string;
/**
* The binary version build code the snapshot was downloaded for.
* The versionCode on Android or CFBundleVersion on iOS this should be changed every time you do a new build debug or otherwise.
*/
binaryVersionCode: string;
}
/**
* Configuration options for the call to `sync`
*/
export interface ISyncOptions {
/**
* Whether the update should be applied immediately or on the next app start.
*/
updateMethod?: 'background' | 'auto';
}
/**
* The response object describing if an update is available.
*/
export interface CheckForUpdateResponse {
/**
* Whether or not an update is available.
*/
available: boolean;
/**
* Equivalent to available since v5 this can be ignored in favor of available
* @deprecated
*/
compatible: boolean;
/**
* Legacy indicator of whether the update is a partial one. This will always be false and can be ignored
* @deprecated
*/
partial: false;
/**
* The id of the snapshot if available.
*/
snapshot?: string;
/**
* The id of the build if available.
*/
build?: string;
/**
* The url to fetch the manifest of files in the update.
*/
url?: string;
/**
* Whether or not there is an update available that is not compatible with this device.
*/
incompatibleUpdateAvailable?: boolean;
}
/**
* Information about the application.
*/
export interface IAppInfo {
/**
* The platform that the app is currently installed on.
*/
platform: 'ios' | 'android';
/**
* The version of the native platform.
*/
platformVersion: string;
/**
* @deprecated
* The versionCode on Android or CFBundleVersion on iOS this should be changed every time you do a new build debug or otherwise.
*/
version: string;
/**
* The versionCode on Android or CFBundleVersion on iOS this should be changed every time you do a new build debug or otherwise.
*/
binaryVersionCode: string | number;
/**
* The bundle name.
*/
bundleName: string;
/**
* @deprecated
* The versionName on Android or CFBundleShortVersionString on iOS this is the end user readable version listed on the stores.
*/
bundleVersion: string;
/**
* The versionName on Android or CFBundleShortVersionString on iOS this is the end user readable version listed on the stores.
*/
binaryVersionName: string;
/**
* A generated device ID (NOT a native device ID)
*/
device: string;
/**
* Directory where the snapshots are stored
*/
dataDirectory: string;
}
/**
* A callback function to handle the result.
*/
export interface CallbackFunction<T> { (result?: T): void; }
/**
* @hidden
*/
export interface IAvailableUpdate {

@@ -289,5 +14,2 @@ binaryVersionName: string;

/**
* @hidden
*/
export interface ISavedPreferences extends ICurrentConfig {

@@ -298,5 +20,2 @@ availableUpdate?: IAvailableUpdate;

/**
* @hidden
*/
export interface UpdateInfo {

@@ -307,5 +26,2 @@ versionId: string;

/**
* @hidden
*/
export interface ManifestFileEntry {

@@ -317,5 +33,2 @@ integrity: string;

/**
* @hidden
*/
export interface FetchManifestResp {

@@ -322,0 +35,0 @@ manifestJson: ManifestFileEntry[];

@@ -1,2 +0,2 @@

import { IDeployConfig } from './definitions';
import { IDeployConfig } from './IonicCordova';

@@ -3,0 +3,0 @@ export function isPluginConfig(o: object): o is IDeployConfig {

@@ -1,3 +0,76 @@

export { Deploy, IonicCordova } from './common';
import {
CallbackFunction,
IDeployConfig,
ISyncOptions,
} from './IonicCordova';
/**
* @hidden
*/
const deviceready = new Promise<IDeployPluginAPI>((resolve, rejects) => {
document.addEventListener('deviceready', () => {
if (window.IonicCordova) {
return resolve(window.IonicCordova.deploy);
}
return rejects('cordova-plugin-ionic not found. Are you sure you installed it?');
});
});
export * from './definitions';
export class DeployClass implements IDeployPluginAPI {
async configure(config: IDeployConfig) {
const deploy = await deviceready;
return deploy.configure(config);
}
async getConfiguration() {
const deploy = await deviceready;
return deploy.getConfiguration();
}
async checkForUpdate() {
const deploy = await deviceready;
return deploy.checkForUpdate();
}
async downloadUpdate(progress?: CallbackFunction<number>) {
const deploy = await deviceready;
return deploy.downloadUpdate(progress);
}
async extractUpdate(progress?: CallbackFunction<number>) {
const deploy = await deviceready;
return deploy.extractUpdate(progress);
}
async reloadApp() {
const deploy = await deviceready;
return deploy.reloadApp();
}
async sync(options: ISyncOptions, progress?: CallbackFunction<number>) {
const deploy = await deviceready;
return deploy.sync(options, progress);
}
async getCurrentVersion() {
const deploy = await deviceready;
return deploy.getCurrentVersion();
}
async getAvailableVersions() {
const deploy = await deviceready;
return deploy.getAvailableVersions();
}
async deleteVersionById(versionId: string) {
const deploy = await deviceready;
return deploy.deleteVersionById(versionId);
}
async getVersionById(versionId: string) {
const deploy = await deviceready;
return deploy.getVersionById(versionId);
}
}
export const Deploy = new DeployClass();

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc