1 | ;
|
2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7 | };
|
8 | var plugin_1 = require('./plugin');
|
9 | /**
|
10 | * Defines the possible result statuses of the window.codePush.sync operation.
|
11 | */
|
12 | (function (SyncStatus) {
|
13 | /**
|
14 | * The application is up to date.
|
15 | */
|
16 | SyncStatus[SyncStatus["UP_TO_DATE"] = 0] = "UP_TO_DATE";
|
17 | /**
|
18 | * An update is available, it has been downloaded, unzipped and copied to the deployment folder.
|
19 | * After the completion of the callback invoked with SyncStatus.UPDATE_INSTALLED, the application will be reloaded with the updated code and resources.
|
20 | */
|
21 | SyncStatus[SyncStatus["UPDATE_INSTALLED"] = 1] = "UPDATE_INSTALLED";
|
22 | /**
|
23 | * An optional update is available, but the user declined to install it. The update was not downloaded.
|
24 | */
|
25 | SyncStatus[SyncStatus["UPDATE_IGNORED"] = 2] = "UPDATE_IGNORED";
|
26 | /**
|
27 | * An error happened during the sync operation. This might be an error while communicating with the server, downloading or unziping the update.
|
28 | * The console logs should contain more information about what happened. No update has been applied in this case.
|
29 | */
|
30 | SyncStatus[SyncStatus["ERROR"] = 3] = "ERROR";
|
31 | /**
|
32 | * There is an ongoing sync in progress, so this attempt to sync has been aborted.
|
33 | */
|
34 | SyncStatus[SyncStatus["IN_PROGRESS"] = 4] = "IN_PROGRESS";
|
35 | /**
|
36 | * Intermediate status - the plugin is about to check for updates.
|
37 | */
|
38 | SyncStatus[SyncStatus["CHECKING_FOR_UPDATE"] = 5] = "CHECKING_FOR_UPDATE";
|
39 | /**
|
40 | * Intermediate status - a user dialog is about to be displayed. This status will be reported only if user interaction is enabled.
|
41 | */
|
42 | SyncStatus[SyncStatus["AWAITING_USER_ACTION"] = 6] = "AWAITING_USER_ACTION";
|
43 | /**
|
44 | * Intermediate status - the update package is about to be downloaded.
|
45 | */
|
46 | SyncStatus[SyncStatus["DOWNLOADING_PACKAGE"] = 7] = "DOWNLOADING_PACKAGE";
|
47 | /**
|
48 | * Intermediate status - the update package is about to be installed.
|
49 | */
|
50 | SyncStatus[SyncStatus["INSTALLING_UPDATE"] = 8] = "INSTALLING_UPDATE";
|
51 | })(exports.SyncStatus || (exports.SyncStatus = {}));
|
52 | var SyncStatus = exports.SyncStatus;
|
53 | /**
|
54 | * Defines the available install modes for updates.
|
55 | */
|
56 | (function (InstallMode) {
|
57 | /**
|
58 | * The update will be applied to the running application immediately. The application will be reloaded with the new content immediately.
|
59 | */
|
60 | InstallMode[InstallMode["IMMEDIATE"] = 0] = "IMMEDIATE";
|
61 | /**
|
62 | * The update is downloaded but not installed immediately. The new content will be available the next time the application is started.
|
63 | */
|
64 | InstallMode[InstallMode["ON_NEXT_RESTART"] = 1] = "ON_NEXT_RESTART";
|
65 | /**
|
66 | * The udpate is downloaded but not installed immediately. The new content will be available the next time the application is resumed or restarted, whichever event happends first.
|
67 | */
|
68 | InstallMode[InstallMode["ON_NEXT_RESUME"] = 2] = "ON_NEXT_RESUME";
|
69 | })(exports.InstallMode || (exports.InstallMode = {}));
|
70 | var InstallMode = exports.InstallMode;
|
71 | /**
|
72 | * @name CodePush
|
73 | * @description
|
74 | * CodePush plugin for Cordova by Microsoft that supports iOS and Android.
|
75 | *
|
76 | * For more info, please see https://github.com/ksachdeva/ionic2-code-push-example
|
77 | *
|
78 | * @usage
|
79 | * ```typescript
|
80 | * import { CodePush } from 'ionic-native';
|
81 | *
|
82 | * // note - mostly error & completed methods of observable will not fire
|
83 | * // as syncStatus will contain the current state of the update
|
84 | * CodePush.sync().subscribe((syncStatus) => console.log(syncStatus));
|
85 | *
|
86 | * const downloadProgress = (progress) => { console.log(`Downloaded ${progress.receivedBytes} of ${progress.totalBytes}`); }
|
87 | * CodePush.sync({}, downloadProgress).subscribe((syncStatus) => console.log(syncStatus));
|
88 | *
|
89 | * ```
|
90 | */
|
91 | var CodePush = (function () {
|
92 | function CodePush() {
|
93 | }
|
94 | /**
|
95 | * Get the current package information.
|
96 | *
|
97 | * @param packageSuccess Callback invoked with the currently deployed package information.
|
98 | * @param packageError Optional callback invoked in case of an error.
|
99 | * @returns {Promise<ILocalPackage>}
|
100 | */
|
101 | CodePush.getCurrentPackage = function () {
|
102 | return;
|
103 | };
|
104 | /**
|
105 | * Gets the pending package information, if any. A pending package is one that has been installed but the application still runs the old code.
|
106 | * This happends only after a package has been installed using ON_NEXT_RESTART or ON_NEXT_RESUME mode, but the application was not restarted/resumed yet.
|
107 | * @returns {Promise<ILocalPackage>}
|
108 | */
|
109 | CodePush.getPendingPackage = function () {
|
110 | return;
|
111 | };
|
112 | /**
|
113 | * Checks with the CodePush server if an update package is available for download.
|
114 | *
|
115 | * @param querySuccess Callback invoked in case of a successful response from the server.
|
116 | * The callback takes one RemotePackage parameter. A non-null package is a valid update.
|
117 | * A null package means the application is up to date for the current native application version.
|
118 | * @param queryError Optional callback invoked in case of an error.
|
119 | * @param deploymentKey Optional deployment key that overrides the config.xml setting.
|
120 | * @returns {Promise<IRemotePackage>}
|
121 | */
|
122 | CodePush.checkForUpdate = function (deploymentKey) {
|
123 | return;
|
124 | };
|
125 | /**
|
126 | * Notifies the plugin that the update operation succeeded and that the application is ready.
|
127 | * Calling this function is required on the first run after an update. On every subsequent application run, calling this function is a noop.
|
128 | * If using sync API, calling this function is not required since sync calls it internally.
|
129 | *
|
130 | * @param notifySucceeded Optional callback invoked if the plugin was successfully notified.
|
131 | * @param notifyFailed Optional callback invoked in case of an error during notifying the plugin.
|
132 | * @returns {Promise<void>}
|
133 | */
|
134 | CodePush.notifyApplicationReady = function () {
|
135 | return;
|
136 | };
|
137 | /**
|
138 | * Reloads the application. If there is a pending update package installed using ON_NEXT_RESTART or ON_NEXT_RESUME modes, the update
|
139 | * will be immediately visible to the user. Otherwise, calling this function will simply reload the current version of the application.
|
140 | * @returns {Promise<void>}
|
141 | */
|
142 | CodePush.restartApplication = function () {
|
143 | return;
|
144 | };
|
145 | /**
|
146 | * Convenience method for installing updates in one method call.
|
147 | * This method is provided for simplicity, and its behavior can be replicated by using window.codePush.checkForUpdate(), RemotePackage's download() and LocalPackage's install() methods.
|
148 | *
|
149 | * The algorithm of this method is the following:
|
150 | * - Checks for an update on the CodePush server.
|
151 | * - If an update is available
|
152 | * - If the update is mandatory and the alertMessage is set in options, the user will be informed that the application will be updated to the latest version.
|
153 | * The update package will then be downloaded and applied.
|
154 | * - If the update is not mandatory and the confirmMessage is set in options, the user will be asked if they want to update to the latest version.
|
155 | * If they decline, the syncCallback will be invoked with SyncStatus.UPDATE_IGNORED.
|
156 | * - Otherwise, the update package will be downloaded and applied with no user interaction.
|
157 | * - If no update is available on the server, or if a previously rolled back update is available and the ignoreFailedUpdates is set to true, the syncCallback will be invoked with the SyncStatus.UP_TO_DATE.
|
158 | * - If an error occurs during checking for update, downloading or installing it, the syncCallback will be invoked with the SyncStatus.ERROR.
|
159 | *
|
160 | * @param syncCallback Optional callback to be called with the status of the sync operation.
|
161 | * @param syncOptions Optional SyncOptions parameter configuring the behavior of the sync operation.
|
162 | * @param downloadProgress Optional callback invoked during the download process. It is called several times with one DownloadProgress parameter.
|
163 | * @returns {Observable<SyncStatus>}
|
164 | *
|
165 | */
|
166 | CodePush.sync = function (syncOptions, downloadProgress) {
|
167 | return;
|
168 | };
|
169 | __decorate([
|
170 | plugin_1.Cordova()
|
171 | ], CodePush, "getCurrentPackage", null);
|
172 | __decorate([
|
173 | plugin_1.Cordova()
|
174 | ], CodePush, "getPendingPackage", null);
|
175 | __decorate([
|
176 | plugin_1.Cordova({
|
177 | callbackOrder: 'reverse'
|
178 | })
|
179 | ], CodePush, "checkForUpdate", null);
|
180 | __decorate([
|
181 | plugin_1.Cordova()
|
182 | ], CodePush, "notifyApplicationReady", null);
|
183 | __decorate([
|
184 | plugin_1.Cordova()
|
185 | ], CodePush, "restartApplication", null);
|
186 | __decorate([
|
187 | plugin_1.Cordova({
|
188 | observable: true,
|
189 | successIndex: 0,
|
190 | errorIndex: 3 // we don't need this, so we set it to a value higher than # of args
|
191 | })
|
192 | ], CodePush, "sync", null);
|
193 | CodePush = __decorate([
|
194 | plugin_1.Plugin({
|
195 | pluginName: 'CodePush',
|
196 | plugin: 'cordova-plugin-code-push',
|
197 | pluginRef: 'codePush',
|
198 | repo: 'https://github.com/Microsoft/cordova-plugin-code-push',
|
199 | platforms: ['Android', 'iOS']
|
200 | })
|
201 | ], CodePush);
|
202 | return CodePush;
|
203 | }());
|
204 | exports.CodePush = CodePush;
|
205 | //# sourceMappingURL=code-push.js.map |
\ | No newline at end of file |