@otakit/capacitor-updater 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Package.swift +27 -0
- package/README.md +164 -128
- package/android/src/main/java/com/otakit/updater/BundleStore.java +37 -8
- package/android/src/main/java/com/otakit/updater/DeviceEventClient.java +2 -3
- package/android/src/main/java/com/otakit/updater/ManifestClient.java +20 -7
- package/android/src/main/java/com/otakit/updater/UpdaterCoordinator.java +726 -0
- package/android/src/main/java/com/otakit/updater/UpdaterPlugin.java +551 -493
- package/dist/esm/definitions.d.ts +41 -66
- package/dist/esm/definitions.d.ts.map +1 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -47
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +4 -3
- package/dist/esm/web.d.ts.map +1 -1
- package/dist/esm/web.js +5 -2
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +10 -49
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +10 -49
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/UpdaterPlugin/BundleStore.swift +28 -6
- package/ios/Sources/UpdaterPlugin/ManifestClient.swift +7 -3
- package/ios/Sources/UpdaterPlugin/UpdaterCoordinator.swift +635 -0
- package/ios/Sources/UpdaterPlugin/UpdaterPlugin.m +1 -0
- package/ios/Sources/UpdaterPlugin/UpdaterPlugin.swift +498 -489
- package/package.json +5 -3
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { PluginListenerHandle } from '@capacitor/core';
|
|
2
1
|
/**
|
|
3
2
|
* Bundle status enum.
|
|
4
3
|
*/
|
|
@@ -43,8 +42,6 @@ export interface LatestVersion {
|
|
|
43
42
|
sha256: string;
|
|
44
43
|
/** Bundle size in bytes */
|
|
45
44
|
size: number;
|
|
46
|
-
/** True when this exact update is already staged locally. */
|
|
47
|
-
downloaded?: boolean;
|
|
48
45
|
/** Release history ID associated with this manifest */
|
|
49
46
|
releaseId: string;
|
|
50
47
|
}
|
|
@@ -54,11 +51,31 @@ export interface OtaKitState {
|
|
|
54
51
|
staged: BundleInfo | null;
|
|
55
52
|
builtinVersion: string;
|
|
56
53
|
}
|
|
57
|
-
export type
|
|
54
|
+
export type OtaKitPolicy = 'off' | 'shadow' | 'apply-staged' | 'immediate';
|
|
58
55
|
export interface OtaKitManifestKey {
|
|
59
56
|
kid: string;
|
|
60
57
|
key: string;
|
|
61
58
|
}
|
|
59
|
+
export interface CheckNoUpdateResult {
|
|
60
|
+
kind: 'no_update';
|
|
61
|
+
}
|
|
62
|
+
export interface CheckAlreadyStagedResult {
|
|
63
|
+
kind: 'already_staged';
|
|
64
|
+
latest: LatestVersion;
|
|
65
|
+
}
|
|
66
|
+
export interface CheckUpdateAvailableResult {
|
|
67
|
+
kind: 'update_available';
|
|
68
|
+
latest: LatestVersion;
|
|
69
|
+
}
|
|
70
|
+
export type CheckResult = CheckNoUpdateResult | CheckAlreadyStagedResult | CheckUpdateAvailableResult;
|
|
71
|
+
export interface DownloadNoUpdateResult {
|
|
72
|
+
kind: 'no_update';
|
|
73
|
+
}
|
|
74
|
+
export interface DownloadStagedResult {
|
|
75
|
+
kind: 'staged';
|
|
76
|
+
bundle: BundleInfo;
|
|
77
|
+
}
|
|
78
|
+
export type DownloadResult = DownloadNoUpdateResult | DownloadStagedResult;
|
|
62
79
|
/**
|
|
63
80
|
* Plugin configuration for capacitor.config.ts.
|
|
64
81
|
*/
|
|
@@ -69,12 +86,17 @@ export interface OtaKitConfig {
|
|
|
69
86
|
channel?: string;
|
|
70
87
|
/** Optional native compatibility lane. Set this when a new store build should start a new OTA line. */
|
|
71
88
|
runtimeVersion?: string;
|
|
72
|
-
/**
|
|
73
|
-
|
|
89
|
+
/** Cold-start policy after runtime has already been resolved. Defaults to apply-staged. */
|
|
90
|
+
launchPolicy?: OtaKitPolicy;
|
|
91
|
+
/** Foreground resume policy. Defaults to shadow. */
|
|
92
|
+
resumePolicy?: OtaKitPolicy;
|
|
93
|
+
/** Cold-start policy when runtimeVersion changes or resolves for the first time. Defaults to immediate. */
|
|
94
|
+
runtimePolicy?: OtaKitPolicy;
|
|
74
95
|
/**
|
|
75
|
-
* Minimum milliseconds between automatic
|
|
76
|
-
* Applies only to
|
|
77
|
-
*
|
|
96
|
+
* Minimum milliseconds between automatic background resume checks.
|
|
97
|
+
* Applies only to `resumePolicy: "shadow"` and `resumePolicy: "apply-staged"`
|
|
98
|
+
* when no staged bundle is already waiting. Defaults to 600000 (10 min).
|
|
99
|
+
* Set to 0 or a negative value to disable resume throttling.
|
|
78
100
|
*/
|
|
79
101
|
checkInterval?: number;
|
|
80
102
|
/** Milliseconds to wait for notifyAppReady(). Defaults to 10000. */
|
|
@@ -90,7 +112,6 @@ export interface OtaKitConfig {
|
|
|
90
112
|
/** Allow HTTP only for localhost development. Defaults to false. */
|
|
91
113
|
allowInsecureUrls?: boolean;
|
|
92
114
|
}
|
|
93
|
-
export type OtaKitEvent = 'downloadStarted' | 'downloadComplete' | 'downloadFailed' | 'updateAvailable' | 'noUpdateAvailable' | 'appReady' | 'rollback';
|
|
94
115
|
export interface OtaKitPlugin {
|
|
95
116
|
/**
|
|
96
117
|
* Inspect the current updater state.
|
|
@@ -98,40 +119,33 @@ export interface OtaKitPlugin {
|
|
|
98
119
|
getState(): Promise<OtaKitState>;
|
|
99
120
|
/**
|
|
100
121
|
* Check the configured channel for a newer version without downloading it.
|
|
101
|
-
* When `downloaded` is true, the latest update is already staged locally.
|
|
102
122
|
*/
|
|
103
|
-
check(): Promise<
|
|
123
|
+
check(): Promise<CheckResult>;
|
|
104
124
|
/**
|
|
105
|
-
* Check the configured channel and
|
|
106
|
-
* The latest bundle is staged for later activation. If it is already staged,
|
|
107
|
-
* the existing staged bundle is returned without re-downloading it.
|
|
125
|
+
* Check the configured channel and ensure the latest bundle is staged locally.
|
|
108
126
|
*/
|
|
109
|
-
download(): Promise<
|
|
127
|
+
download(): Promise<DownloadResult>;
|
|
110
128
|
/**
|
|
111
129
|
* Activate the currently staged bundle and reload the WebView.
|
|
112
130
|
*
|
|
113
131
|
* **WARNING: TERMINAL OPERATION**
|
|
132
|
+
* On success this call does not resolve back into the old JS context.
|
|
114
133
|
* Code after this call may not execute. The WebView will reload.
|
|
115
134
|
*/
|
|
116
135
|
apply(): Promise<void>;
|
|
117
136
|
/**
|
|
118
137
|
* Friendly manual-mode helper.
|
|
119
|
-
* Bring the app to the newest available update now
|
|
120
|
-
*
|
|
121
|
-
* Otherwise download it and apply it.
|
|
138
|
+
* Bring the app to the newest available update now using one native
|
|
139
|
+
* immediate-flow operation.
|
|
122
140
|
*
|
|
123
141
|
* **WARNING: TERMINAL OPERATION**
|
|
142
|
+
* If an update is applied, this call does not resolve back into the old JS context.
|
|
124
143
|
* Code after this call may not execute if an update is applied.
|
|
125
144
|
*/
|
|
126
145
|
update(): Promise<void>;
|
|
127
146
|
/**
|
|
128
147
|
* **CRITICAL**: Call this when your app has successfully started.
|
|
129
148
|
* Must be called within appReadyTimeout (default 10s) or rollback occurs.
|
|
130
|
-
*
|
|
131
|
-
* This confirms the current bundle is working and:
|
|
132
|
-
* - Marks the bundle as SUCCESS
|
|
133
|
-
* - Updates the fallback bundle pointer
|
|
134
|
-
* - Removes the older fallback bundle once the new bundle proves healthy
|
|
135
149
|
*/
|
|
136
150
|
notifyAppReady(): Promise<void>;
|
|
137
151
|
/**
|
|
@@ -139,53 +153,14 @@ export interface OtaKitPlugin {
|
|
|
139
153
|
* Returns null if no failure has occurred.
|
|
140
154
|
*/
|
|
141
155
|
getLastFailure(): Promise<BundleInfo | null>;
|
|
142
|
-
/**
|
|
143
|
-
* Add listener for update events
|
|
144
|
-
*/
|
|
145
|
-
addListener(event: 'downloadStarted', callback: (data: {
|
|
146
|
-
version: string;
|
|
147
|
-
}) => void): Promise<PluginListenerHandle>;
|
|
148
|
-
addListener(event: 'downloadComplete', callback: (data: BundleInfo) => void): Promise<PluginListenerHandle>;
|
|
149
|
-
addListener(event: 'downloadFailed', callback: (data: {
|
|
150
|
-
version: string;
|
|
151
|
-
error: string;
|
|
152
|
-
}) => void): Promise<PluginListenerHandle>;
|
|
153
|
-
addListener(event: 'updateAvailable', callback: (data: LatestVersion) => void): Promise<PluginListenerHandle>;
|
|
154
|
-
addListener(event: 'noUpdateAvailable', callback: () => void): Promise<PluginListenerHandle>;
|
|
155
|
-
addListener(event: 'appReady', callback: (data: BundleInfo) => void): Promise<PluginListenerHandle>;
|
|
156
|
-
addListener(event: 'rollback', callback: (data: {
|
|
157
|
-
from: BundleInfo;
|
|
158
|
-
to: BundleInfo;
|
|
159
|
-
reason?: string;
|
|
160
|
-
}) => void): Promise<PluginListenerHandle>;
|
|
161
|
-
/**
|
|
162
|
-
* Remove all listeners for this plugin
|
|
163
|
-
*/
|
|
164
|
-
removeAllListeners(): Promise<void>;
|
|
165
156
|
}
|
|
166
157
|
export interface OtaKitBridgePlugin {
|
|
167
158
|
getState(): Promise<OtaKitState>;
|
|
168
|
-
check(): Promise<
|
|
169
|
-
download(): Promise<
|
|
159
|
+
check(): Promise<CheckResult>;
|
|
160
|
+
download(): Promise<DownloadResult>;
|
|
170
161
|
apply(): Promise<void>;
|
|
162
|
+
update(): Promise<void>;
|
|
171
163
|
notifyAppReady(): Promise<void>;
|
|
172
164
|
getLastFailure(): Promise<BundleInfo | null>;
|
|
173
|
-
addListener(event: 'downloadStarted', callback: (data: {
|
|
174
|
-
version: string;
|
|
175
|
-
}) => void): Promise<PluginListenerHandle>;
|
|
176
|
-
addListener(event: 'downloadComplete', callback: (data: BundleInfo) => void): Promise<PluginListenerHandle>;
|
|
177
|
-
addListener(event: 'downloadFailed', callback: (data: {
|
|
178
|
-
version: string;
|
|
179
|
-
error: string;
|
|
180
|
-
}) => void): Promise<PluginListenerHandle>;
|
|
181
|
-
addListener(event: 'updateAvailable', callback: (data: LatestVersion) => void): Promise<PluginListenerHandle>;
|
|
182
|
-
addListener(event: 'noUpdateAvailable', callback: () => void): Promise<PluginListenerHandle>;
|
|
183
|
-
addListener(event: 'appReady', callback: (data: BundleInfo) => void): Promise<PluginListenerHandle>;
|
|
184
|
-
addListener(event: 'rollback', callback: (data: {
|
|
185
|
-
from: BundleInfo;
|
|
186
|
-
to: BundleInfo;
|
|
187
|
-
reason?: string;
|
|
188
|
-
}) => void): Promise<PluginListenerHandle>;
|
|
189
|
-
removeAllListeners(): Promise<void>;
|
|
190
165
|
}
|
|
191
166
|
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,YAAY;IACtB,+BAA+B;IAC/B,OAAO,YAAY;IACnB,iDAAiD;IACjD,OAAO,YAAY;IACnB,mCAAmC;IACnC,KAAK,UAAU;IACf,wBAAwB;IACxB,OAAO,YAAY;IACnB,yDAAyD;IACzD,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,+BAA+B;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mCAAmC;IACnC,MAAM,EAAE,YAAY,CAAC;IACrB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,cAAc,C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AAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,cAAc,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;CAC9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,YAWX;AAXD,WAAY,YAAY;IACtB,+BAA+B;IAC/B,mCAAmB,CAAA;IACnB,iDAAiD;IACjD,mCAAmB,CAAA;IACnB,mCAAmC;IACnC,+BAAe,CAAA;IACf,wBAAwB;IACxB,mCAAmB,CAAA;IACnB,yDAAyD;IACzD,+BAAe,CAAA;AACjB,CAAC,EAXW,YAAY,KAAZ,YAAY,QAWvB"}
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAsB,YAAY,EAAc,MAAM,eAAe,CAAC;AAqBlF,QAAA,MAAM,MAAM,EAAE,YASb,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -15,56 +15,14 @@ function isEmptyObject(obj) {
|
|
|
15
15
|
function normalizeNullable(value) {
|
|
16
16
|
return isEmptyObject(value) ? null : value;
|
|
17
17
|
}
|
|
18
|
-
async function getState() {
|
|
19
|
-
return NativeOtaKit.getState();
|
|
20
|
-
}
|
|
21
|
-
async function check() {
|
|
22
|
-
return normalizeNullable(await NativeOtaKit.check());
|
|
23
|
-
}
|
|
24
|
-
async function download() {
|
|
25
|
-
return normalizeNullable(await NativeOtaKit.download());
|
|
26
|
-
}
|
|
27
|
-
function apply() {
|
|
28
|
-
return NativeOtaKit.apply();
|
|
29
|
-
}
|
|
30
|
-
async function update() {
|
|
31
|
-
const state = await getState();
|
|
32
|
-
let latest;
|
|
33
|
-
try {
|
|
34
|
-
latest = await check();
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
if (state.staged) {
|
|
38
|
-
await apply();
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
throw error;
|
|
42
|
-
}
|
|
43
|
-
if (latest) {
|
|
44
|
-
if (latest.downloaded) {
|
|
45
|
-
await apply();
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const bundle = await download();
|
|
49
|
-
if (bundle) {
|
|
50
|
-
await apply();
|
|
51
|
-
}
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (state.staged) {
|
|
55
|
-
await apply();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
18
|
const OtaKit = {
|
|
59
|
-
getState,
|
|
60
|
-
check,
|
|
61
|
-
download,
|
|
62
|
-
apply,
|
|
63
|
-
update,
|
|
19
|
+
getState: () => NativeOtaKit.getState(),
|
|
20
|
+
check: () => NativeOtaKit.check(),
|
|
21
|
+
download: () => NativeOtaKit.download(),
|
|
22
|
+
apply: () => NativeOtaKit.apply(),
|
|
23
|
+
update: () => NativeOtaKit.update(),
|
|
64
24
|
notifyAppReady: () => NativeOtaKit.notifyAppReady(),
|
|
65
25
|
getLastFailure: async () => normalizeNullable(await NativeOtaKit.getLastFailure()),
|
|
66
|
-
addListener: NativeOtaKit.addListener.bind(NativeOtaKit),
|
|
67
|
-
removeAllListeners: () => NativeOtaKit.removeAllListeners(),
|
|
68
26
|
};
|
|
69
27
|
export * from './definitions';
|
|
70
28
|
export { OtaKit };
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,YAAY,GAAG,cAAc,CAAqB,QAAQ,EAAE;IAChE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;CAC1D,CAAC,CAAC;AAEH;;GAEG;AACH,SAAS,aAAa,CAAC,GAAY;IACjC,OAAO,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AAClF,CAAC;AAED;;;GAGG;AACH,SAAS,iBAAiB,CAAI,KAAQ;IACpC,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7C,CAAC;AAED,MAAM,MAAM,GAAiB;IAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE;IACvC,KAAK,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE;IACjC,QAAQ,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE;IACvC,KAAK,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE;IACjC,MAAM,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE;IACnC,cAAc,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE;IACnD,cAAc,EAAE,KAAK,IAAgC,EAAE,CACrD,iBAAiB,CAAC,MAAM,YAAY,CAAC,cAAc,EAAE,CAAC;CACzD,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import type { OtaKitBridgePlugin, BundleInfo,
|
|
2
|
+
import type { OtaKitBridgePlugin, BundleInfo, CheckResult, DownloadResult, OtaKitState } from './definitions';
|
|
3
3
|
/**
|
|
4
4
|
* Web implementation of the native bridge.
|
|
5
5
|
* Most methods are no-ops since OTA updates don't apply to web.
|
|
@@ -7,9 +7,10 @@ import type { OtaKitBridgePlugin, BundleInfo, LatestVersion, OtaKitState } from
|
|
|
7
7
|
export declare class OtaKitWeb extends WebPlugin implements OtaKitBridgePlugin {
|
|
8
8
|
private readonly BUILTIN_BUNDLE;
|
|
9
9
|
getState(): Promise<OtaKitState>;
|
|
10
|
-
check(): Promise<
|
|
11
|
-
download(): Promise<
|
|
10
|
+
check(): Promise<CheckResult>;
|
|
11
|
+
download(): Promise<DownloadResult>;
|
|
12
12
|
apply(): Promise<void>;
|
|
13
|
+
update(): Promise<void>;
|
|
13
14
|
notifyAppReady(): Promise<void>;
|
|
14
15
|
getLastFailure(): Promise<BundleInfo | null>;
|
|
15
16
|
}
|
package/dist/esm/web.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EAEV,WAAW,EACX,cAAc,EACd,WAAW,EACZ,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,qBAAa,SAAU,SAAQ,SAAU,YAAW,kBAAkB;IACpE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAI7B;IAEI,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC;IAShC,KAAK,IAAI,OAAO,CAAC,WAAW,CAAC;IAK7B,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IAKnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAKtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,cAAc,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAGnD"}
|
package/dist/esm/web.js
CHANGED
|
@@ -19,16 +19,19 @@ export class OtaKitWeb extends WebPlugin {
|
|
|
19
19
|
}
|
|
20
20
|
async check() {
|
|
21
21
|
console.warn('OtaKit.check() is not supported on web');
|
|
22
|
-
return
|
|
22
|
+
return { kind: 'no_update' };
|
|
23
23
|
}
|
|
24
24
|
async download() {
|
|
25
25
|
console.warn('OtaKit.download() is not supported on web');
|
|
26
|
-
return
|
|
26
|
+
return { kind: 'no_update' };
|
|
27
27
|
}
|
|
28
28
|
async apply() {
|
|
29
29
|
console.warn('OtaKit.apply() is not supported on web');
|
|
30
30
|
throw new Error('OtaKit.apply() is not supported on web');
|
|
31
31
|
}
|
|
32
|
+
async update() {
|
|
33
|
+
await this.download();
|
|
34
|
+
}
|
|
32
35
|
async notifyAppReady() {
|
|
33
36
|
// No-op on web, but don't warn - apps should call this unconditionally
|
|
34
37
|
}
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,SAAS;IACrB,cAAc,GAAe;QAC5C,EAAE,EAAE,SAAS;QACb,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,SAAyB;KAClC,CAAC;IAEF,KAAK,CAAC,QAAQ;QACZ,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,cAAc;YAC5B,QAAQ,EAAE,IAAI,CAAC,cAAc;YAC7B,MAAM,EAAE,IAAI;YACZ,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO;SAC5C,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;QACvD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,OAAO,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;QAC1D,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,uEAAuE;IACzE,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -35,56 +35,14 @@ function isEmptyObject(obj) {
|
|
|
35
35
|
function normalizeNullable(value) {
|
|
36
36
|
return isEmptyObject(value) ? null : value;
|
|
37
37
|
}
|
|
38
|
-
async function getState() {
|
|
39
|
-
return NativeOtaKit.getState();
|
|
40
|
-
}
|
|
41
|
-
async function check() {
|
|
42
|
-
return normalizeNullable(await NativeOtaKit.check());
|
|
43
|
-
}
|
|
44
|
-
async function download() {
|
|
45
|
-
return normalizeNullable(await NativeOtaKit.download());
|
|
46
|
-
}
|
|
47
|
-
function apply() {
|
|
48
|
-
return NativeOtaKit.apply();
|
|
49
|
-
}
|
|
50
|
-
async function update() {
|
|
51
|
-
const state = await getState();
|
|
52
|
-
let latest;
|
|
53
|
-
try {
|
|
54
|
-
latest = await check();
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
if (state.staged) {
|
|
58
|
-
await apply();
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
throw error;
|
|
62
|
-
}
|
|
63
|
-
if (latest) {
|
|
64
|
-
if (latest.downloaded) {
|
|
65
|
-
await apply();
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const bundle = await download();
|
|
69
|
-
if (bundle) {
|
|
70
|
-
await apply();
|
|
71
|
-
}
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
if (state.staged) {
|
|
75
|
-
await apply();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
38
|
const OtaKit = {
|
|
79
|
-
getState,
|
|
80
|
-
check,
|
|
81
|
-
download,
|
|
82
|
-
apply,
|
|
83
|
-
update,
|
|
39
|
+
getState: () => NativeOtaKit.getState(),
|
|
40
|
+
check: () => NativeOtaKit.check(),
|
|
41
|
+
download: () => NativeOtaKit.download(),
|
|
42
|
+
apply: () => NativeOtaKit.apply(),
|
|
43
|
+
update: () => NativeOtaKit.update(),
|
|
84
44
|
notifyAppReady: () => NativeOtaKit.notifyAppReady(),
|
|
85
45
|
getLastFailure: async () => normalizeNullable(await NativeOtaKit.getLastFailure()),
|
|
86
|
-
addListener: NativeOtaKit.addListener.bind(NativeOtaKit),
|
|
87
|
-
removeAllListeners: () => NativeOtaKit.removeAllListeners(),
|
|
88
46
|
};
|
|
89
47
|
|
|
90
48
|
/**
|
|
@@ -107,16 +65,19 @@ class OtaKitWeb extends core.WebPlugin {
|
|
|
107
65
|
}
|
|
108
66
|
async check() {
|
|
109
67
|
console.warn('OtaKit.check() is not supported on web');
|
|
110
|
-
return
|
|
68
|
+
return { kind: 'no_update' };
|
|
111
69
|
}
|
|
112
70
|
async download() {
|
|
113
71
|
console.warn('OtaKit.download() is not supported on web');
|
|
114
|
-
return
|
|
72
|
+
return { kind: 'no_update' };
|
|
115
73
|
}
|
|
116
74
|
async apply() {
|
|
117
75
|
console.warn('OtaKit.apply() is not supported on web');
|
|
118
76
|
throw new Error('OtaKit.apply() is not supported on web');
|
|
119
77
|
}
|
|
78
|
+
async update() {
|
|
79
|
+
await this.download();
|
|
80
|
+
}
|
|
120
81
|
async notifyAppReady() {
|
|
121
82
|
// No-op on web, but don't warn - apps should call this unconditionally
|
|
122
83
|
}
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Bundle status enum.\n */\nexport var BundleStatus;\n(function (BundleStatus) {\n /** Factory-installed bundle */\n BundleStatus[\"BUILTIN\"] = \"builtin\";\n /** Downloaded and staged, awaiting activation */\n BundleStatus[\"PENDING\"] = \"pending\";\n /** Active but not yet confirmed */\n BundleStatus[\"TRIAL\"] = \"trial\";\n /** Confirmed working */\n BundleStatus[\"SUCCESS\"] = \"success\";\n /** Failed (hash mismatch, extraction error, rollback) */\n BundleStatus[\"ERROR\"] = \"error\";\n})(BundleStatus || (BundleStatus = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst NativeOtaKit = registerPlugin('OtaKit', {\n web: () => import('./web').then((m) => new m.OtaKitWeb()),\n});\n/**\n * Check if result is an empty object (iOS returns {} instead of null)\n */\nfunction isEmptyObject(obj) {\n return obj !== null && typeof obj === 'object' && Object.keys(obj).length === 0;\n}\n/**\n * Wrapped plugin that normalizes null returns from native code.\n * iOS call.resolve() without arguments returns {} instead of null.\n */\nfunction normalizeNullable(value) {\n return isEmptyObject(value) ? null : value;\n}\
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Bundle status enum.\n */\nexport var BundleStatus;\n(function (BundleStatus) {\n /** Factory-installed bundle */\n BundleStatus[\"BUILTIN\"] = \"builtin\";\n /** Downloaded and staged, awaiting activation */\n BundleStatus[\"PENDING\"] = \"pending\";\n /** Active but not yet confirmed */\n BundleStatus[\"TRIAL\"] = \"trial\";\n /** Confirmed working */\n BundleStatus[\"SUCCESS\"] = \"success\";\n /** Failed (hash mismatch, extraction error, rollback) */\n BundleStatus[\"ERROR\"] = \"error\";\n})(BundleStatus || (BundleStatus = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst NativeOtaKit = registerPlugin('OtaKit', {\n web: () => import('./web').then((m) => new m.OtaKitWeb()),\n});\n/**\n * Check if result is an empty object (iOS returns {} instead of null)\n */\nfunction isEmptyObject(obj) {\n return obj !== null && typeof obj === 'object' && Object.keys(obj).length === 0;\n}\n/**\n * Wrapped plugin that normalizes null returns from native code.\n * iOS call.resolve() without arguments returns {} instead of null.\n */\nfunction normalizeNullable(value) {\n return isEmptyObject(value) ? null : value;\n}\nconst OtaKit = {\n getState: () => NativeOtaKit.getState(),\n check: () => NativeOtaKit.check(),\n download: () => NativeOtaKit.download(),\n apply: () => NativeOtaKit.apply(),\n update: () => NativeOtaKit.update(),\n notifyAppReady: () => NativeOtaKit.notifyAppReady(),\n getLastFailure: async () => normalizeNullable(await NativeOtaKit.getLastFailure()),\n};\nexport * from './definitions';\nexport { OtaKit };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the native bridge.\n * Most methods are no-ops since OTA updates don't apply to web.\n */\nexport class OtaKitWeb extends WebPlugin {\n BUILTIN_BUNDLE = {\n id: 'builtin',\n version: '0.0.0',\n status: 'builtin',\n };\n async getState() {\n return {\n current: this.BUILTIN_BUNDLE,\n fallback: this.BUILTIN_BUNDLE,\n staged: null,\n builtinVersion: this.BUILTIN_BUNDLE.version,\n };\n }\n async check() {\n console.warn('OtaKit.check() is not supported on web');\n return { kind: 'no_update' };\n }\n async download() {\n console.warn('OtaKit.download() is not supported on web');\n return { kind: 'no_update' };\n }\n async apply() {\n console.warn('OtaKit.apply() is not supported on web');\n throw new Error('OtaKit.apply() is not supported on web');\n }\n async update() {\n await this.download();\n }\n async notifyAppReady() {\n // No-op on web, but don't warn - apps should call this unconditionally\n }\n async getLastFailure() {\n return null;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BundleStatus","registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACWA;AACX,CAAC,UAAU,YAAY,EAAE;AACzB;AACA,IAAI,YAAY,CAAC,SAAS,CAAC,GAAG,SAAS;AACvC;AACA,IAAI,YAAY,CAAC,SAAS,CAAC,GAAG,SAAS;AACvC;AACA,IAAI,YAAY,CAAC,OAAO,CAAC,GAAG,OAAO;AACnC;AACA,IAAI,YAAY,CAAC,SAAS,CAAC,GAAG,SAAS;AACvC;AACA,IAAI,YAAY,CAAC,OAAO,CAAC,GAAG,OAAO;AACnC,CAAC,EAAEA,oBAAY,KAAKA,oBAAY,GAAG,EAAE,CAAC,CAAC;;ACdvC,MAAM,YAAY,GAAGC,mBAAc,CAAC,QAAQ,EAAE;AAC9C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC7D,CAAC,CAAC;AACF;AACA;AACA;AACA,SAAS,aAAa,CAAC,GAAG,EAAE;AAC5B,IAAI,OAAO,GAAG,KAAK,I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,EAAE;AACpC,IAAI;AACJ,IAAI,MAAM,QAAQ,GAAG;AACrB,QAAQ,OAAO,CAAC,IAAI,CAAC,2CAA2C,CAAC;AACjE,QAAQ,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE;AACpC,IAAI;AACJ,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC;AAC9D,QAAQ,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC;AACjE,IAAI;AACJ,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,MAAM,IAAI,CAAC,QAAQ,EAAE;AAC7B,IAAI;AACJ,IAAI,MAAM,cAAc,GAAG;AAC3B;AACA,IAAI;AACJ,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,OAAO,IAAI;AACnB,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -34,56 +34,14 @@ var capacitorUpdater = (function (exports, core) {
|
|
|
34
34
|
function normalizeNullable(value) {
|
|
35
35
|
return isEmptyObject(value) ? null : value;
|
|
36
36
|
}
|
|
37
|
-
async function getState() {
|
|
38
|
-
return NativeOtaKit.getState();
|
|
39
|
-
}
|
|
40
|
-
async function check() {
|
|
41
|
-
return normalizeNullable(await NativeOtaKit.check());
|
|
42
|
-
}
|
|
43
|
-
async function download() {
|
|
44
|
-
return normalizeNullable(await NativeOtaKit.download());
|
|
45
|
-
}
|
|
46
|
-
function apply() {
|
|
47
|
-
return NativeOtaKit.apply();
|
|
48
|
-
}
|
|
49
|
-
async function update() {
|
|
50
|
-
const state = await getState();
|
|
51
|
-
let latest;
|
|
52
|
-
try {
|
|
53
|
-
latest = await check();
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
if (state.staged) {
|
|
57
|
-
await apply();
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
if (latest) {
|
|
63
|
-
if (latest.downloaded) {
|
|
64
|
-
await apply();
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const bundle = await download();
|
|
68
|
-
if (bundle) {
|
|
69
|
-
await apply();
|
|
70
|
-
}
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (state.staged) {
|
|
74
|
-
await apply();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
37
|
const OtaKit = {
|
|
78
|
-
getState,
|
|
79
|
-
check,
|
|
80
|
-
download,
|
|
81
|
-
apply,
|
|
82
|
-
update,
|
|
38
|
+
getState: () => NativeOtaKit.getState(),
|
|
39
|
+
check: () => NativeOtaKit.check(),
|
|
40
|
+
download: () => NativeOtaKit.download(),
|
|
41
|
+
apply: () => NativeOtaKit.apply(),
|
|
42
|
+
update: () => NativeOtaKit.update(),
|
|
83
43
|
notifyAppReady: () => NativeOtaKit.notifyAppReady(),
|
|
84
44
|
getLastFailure: async () => normalizeNullable(await NativeOtaKit.getLastFailure()),
|
|
85
|
-
addListener: NativeOtaKit.addListener.bind(NativeOtaKit),
|
|
86
|
-
removeAllListeners: () => NativeOtaKit.removeAllListeners(),
|
|
87
45
|
};
|
|
88
46
|
|
|
89
47
|
/**
|
|
@@ -106,16 +64,19 @@ var capacitorUpdater = (function (exports, core) {
|
|
|
106
64
|
}
|
|
107
65
|
async check() {
|
|
108
66
|
console.warn('OtaKit.check() is not supported on web');
|
|
109
|
-
return
|
|
67
|
+
return { kind: 'no_update' };
|
|
110
68
|
}
|
|
111
69
|
async download() {
|
|
112
70
|
console.warn('OtaKit.download() is not supported on web');
|
|
113
|
-
return
|
|
71
|
+
return { kind: 'no_update' };
|
|
114
72
|
}
|
|
115
73
|
async apply() {
|
|
116
74
|
console.warn('OtaKit.apply() is not supported on web');
|
|
117
75
|
throw new Error('OtaKit.apply() is not supported on web');
|
|
118
76
|
}
|
|
77
|
+
async update() {
|
|
78
|
+
await this.download();
|
|
79
|
+
}
|
|
119
80
|
async notifyAppReady() {
|
|
120
81
|
// No-op on web, but don't warn - apps should call this unconditionally
|
|
121
82
|
}
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Bundle status enum.\n */\nexport var BundleStatus;\n(function (BundleStatus) {\n /** Factory-installed bundle */\n BundleStatus[\"BUILTIN\"] = \"builtin\";\n /** Downloaded and staged, awaiting activation */\n BundleStatus[\"PENDING\"] = \"pending\";\n /** Active but not yet confirmed */\n BundleStatus[\"TRIAL\"] = \"trial\";\n /** Confirmed working */\n BundleStatus[\"SUCCESS\"] = \"success\";\n /** Failed (hash mismatch, extraction error, rollback) */\n BundleStatus[\"ERROR\"] = \"error\";\n})(BundleStatus || (BundleStatus = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst NativeOtaKit = registerPlugin('OtaKit', {\n web: () => import('./web').then((m) => new m.OtaKitWeb()),\n});\n/**\n * Check if result is an empty object (iOS returns {} instead of null)\n */\nfunction isEmptyObject(obj) {\n return obj !== null && typeof obj === 'object' && Object.keys(obj).length === 0;\n}\n/**\n * Wrapped plugin that normalizes null returns from native code.\n * iOS call.resolve() without arguments returns {} instead of null.\n */\nfunction normalizeNullable(value) {\n return isEmptyObject(value) ? null : value;\n}\
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Bundle status enum.\n */\nexport var BundleStatus;\n(function (BundleStatus) {\n /** Factory-installed bundle */\n BundleStatus[\"BUILTIN\"] = \"builtin\";\n /** Downloaded and staged, awaiting activation */\n BundleStatus[\"PENDING\"] = \"pending\";\n /** Active but not yet confirmed */\n BundleStatus[\"TRIAL\"] = \"trial\";\n /** Confirmed working */\n BundleStatus[\"SUCCESS\"] = \"success\";\n /** Failed (hash mismatch, extraction error, rollback) */\n BundleStatus[\"ERROR\"] = \"error\";\n})(BundleStatus || (BundleStatus = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst NativeOtaKit = registerPlugin('OtaKit', {\n web: () => import('./web').then((m) => new m.OtaKitWeb()),\n});\n/**\n * Check if result is an empty object (iOS returns {} instead of null)\n */\nfunction isEmptyObject(obj) {\n return obj !== null && typeof obj === 'object' && Object.keys(obj).length === 0;\n}\n/**\n * Wrapped plugin that normalizes null returns from native code.\n * iOS call.resolve() without arguments returns {} instead of null.\n */\nfunction normalizeNullable(value) {\n return isEmptyObject(value) ? null : value;\n}\nconst OtaKit = {\n getState: () => NativeOtaKit.getState(),\n check: () => NativeOtaKit.check(),\n download: () => NativeOtaKit.download(),\n apply: () => NativeOtaKit.apply(),\n update: () => NativeOtaKit.update(),\n notifyAppReady: () => NativeOtaKit.notifyAppReady(),\n getLastFailure: async () => normalizeNullable(await NativeOtaKit.getLastFailure()),\n};\nexport * from './definitions';\nexport { OtaKit };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the native bridge.\n * Most methods are no-ops since OTA updates don't apply to web.\n */\nexport class OtaKitWeb extends WebPlugin {\n BUILTIN_BUNDLE = {\n id: 'builtin',\n version: '0.0.0',\n status: 'builtin',\n };\n async getState() {\n return {\n current: this.BUILTIN_BUNDLE,\n fallback: this.BUILTIN_BUNDLE,\n staged: null,\n builtinVersion: this.BUILTIN_BUNDLE.version,\n };\n }\n async check() {\n console.warn('OtaKit.check() is not supported on web');\n return { kind: 'no_update' };\n }\n async download() {\n console.warn('OtaKit.download() is not supported on web');\n return { kind: 'no_update' };\n }\n async apply() {\n console.warn('OtaKit.apply() is not supported on web');\n throw new Error('OtaKit.apply() is not supported on web');\n }\n async update() {\n await this.download();\n }\n async notifyAppReady() {\n // No-op on web, but don't warn - apps should call this unconditionally\n }\n async getLastFailure() {\n return null;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BundleStatus","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;A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