@capgo/capacitor-updater 7.4.0 → 7.5.1
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/README.md +85 -1
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +126 -5
- package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +134 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/ShakeDetector.java +72 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +169 -0
- package/dist/docs.json +212 -0
- package/dist/esm/definitions.d.ts +72 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +4 -1
- package/dist/esm/web.js +14 -2
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +14 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +14 -2
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +57 -7
- package/ios/Plugin/CapgoUpdater.swift +96 -39
- package/ios/Plugin/InternalUtils.swift +45 -0
- package/ios/Plugin/ShakeMenu.swift +112 -0
- package/package.json +1 -1
package/dist/esm/web.js
CHANGED
|
@@ -99,6 +99,13 @@ export class CapacitorUpdaterWeb extends WebPlugin {
|
|
|
99
99
|
error: 'Cannot getChannel in web',
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
+
async listChannels() {
|
|
103
|
+
console.warn('Cannot listChannels in web');
|
|
104
|
+
throw {
|
|
105
|
+
message: 'Cannot listChannels in web',
|
|
106
|
+
error: 'platform_not_supported',
|
|
107
|
+
};
|
|
108
|
+
}
|
|
102
109
|
async notifyAppReady() {
|
|
103
110
|
console.warn('Cannot notify App Ready in web');
|
|
104
111
|
return { bundle: BUNDLE_BUILTIN };
|
|
@@ -124,8 +131,13 @@ export class CapacitorUpdaterWeb extends WebPlugin {
|
|
|
124
131
|
return BUNDLE_BUILTIN;
|
|
125
132
|
}
|
|
126
133
|
async getNextBundle() {
|
|
127
|
-
|
|
128
|
-
|
|
134
|
+
return Promise.resolve(null);
|
|
135
|
+
}
|
|
136
|
+
async setShakeMenu(_options) {
|
|
137
|
+
throw this.unimplemented('Shake menu not available on web platform');
|
|
138
|
+
}
|
|
139
|
+
async isShakeMenuEnabled() {
|
|
140
|
+
return Promise.resolve({ enabled: false });
|
|
129
141
|
}
|
|
130
142
|
}
|
|
131
143
|
//# sourceMappingURL=web.js.map
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAgC5C,MAAM,cAAc,GAAe;IACjC,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,0BAA0B;IACtC,EAAE,EAAE,SAAS;IACb,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAChD,KAAK,CAAC,WAAW,CAAC,OAAiB;QACjC,OAAO,CAAC,IAAI,CAAC,2BAA2B,EAAE,OAAO,CAAC,CAAC;QACnD,OAAO;IACT,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,OAAkB;QACnC,OAAO,CAAC,IAAI,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;QACpD,OAAO;IACT,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAmB;QACrC,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,OAAO,CAAC,CAAC;QACrD,OAAO;IACT,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAwB;QACrC,OAAO,CAAC,IAAI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QAC/C,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAA6B;QAC/C,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,CAAC,CAAC;QACtE,OAAO;IACT,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAsB;QACnC,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;QAC/C,OAAO;IACT,CAAC;IAED,KAAK,CAAC,WAAW;QACf,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAC1C,OAAO;IACT,CAAC;IAED,KAAK,CAAC,qBAAqB;QACzB,OAAO,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QACpD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QACjD,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAA6B;QAC9C,MAAM,IAAI,CAAC,aAAa,CAAC,0CAA0C,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF","sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\n\nimport { WebPlugin } from '@capacitor/core';\n\nimport type {\n AppReadyResult,\n AutoUpdateEnabled,\n BundleId,\n BundleInfo,\n BundleListResult,\n CapacitorUpdaterPlugin,\n ChannelRes,\n ChannelUrl,\n CurrentBundleResult,\n DelayCondition,\n DeviceId,\n DownloadOptions,\n GetChannelRes,\n LatestVersion,\n ListChannelsResult,\n MultiDelayConditions,\n PluginVersion,\n ResetOptions,\n SetChannelOptions,\n SetCustomIdOptions,\n StatsUrl,\n UnsetChannelOptions,\n UpdateUrl,\n BuiltinVersion,\n AutoUpdateAvailable,\n SetShakeMenuOptions,\n ShakeMenuEnabled,\n} from './definitions';\n\nconst BUNDLE_BUILTIN: BundleInfo = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\n\nexport class CapacitorUpdaterWeb extends WebPlugin implements CapacitorUpdaterPlugin {\n async setStatsUrl(options: StatsUrl): Promise<void> {\n console.warn('Cannot setStatsUrl in web', options);\n return;\n }\n\n async setUpdateUrl(options: UpdateUrl): Promise<void> {\n console.warn('Cannot setUpdateUrl in web', options);\n return;\n }\n\n async setChannelUrl(options: ChannelUrl): Promise<void> {\n console.warn('Cannot setChannelUrl in web', options);\n return;\n }\n\n async download(options: DownloadOptions): Promise<BundleInfo> {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n\n async next(options: BundleId): Promise<BundleInfo> {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n\n async isAutoUpdateEnabled(): Promise<AutoUpdateEnabled> {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n\n async set(options: BundleId): Promise<void> {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n\n async getDeviceId(): Promise<DeviceId> {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n\n async getBuiltinVersion(): Promise<BuiltinVersion> {\n console.warn('Cannot get version in web');\n return { version: 'default' };\n }\n\n async getPluginVersion(): Promise<PluginVersion> {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n\n async delete(options: BundleId): Promise<void> {\n console.warn('Cannot delete bundle in web', options);\n }\n\n async list(): Promise<BundleListResult> {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n\n async reset(options?: ResetOptions): Promise<void> {\n console.warn('Cannot reset version in web', options);\n }\n\n async current(): Promise<CurrentBundleResult> {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n\n async reload(): Promise<void> {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n\n async getLatest(): Promise<LatestVersion> {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n\n async setChannel(options: SetChannelOptions): Promise<ChannelRes> {\n console.warn('Cannot setChannel in web', options);\n return {\n status: 'error',\n error: 'Cannot setChannel in web',\n };\n }\n\n async unsetChannel(options: UnsetChannelOptions): Promise<void> {\n console.warn('Cannot unsetChannel in web', options);\n return;\n }\n\n async setCustomId(options: SetCustomIdOptions): Promise<void> {\n console.warn('Cannot setCustomId in web', options);\n return;\n }\n\n async getChannel(): Promise<GetChannelRes> {\n console.warn('Cannot getChannel in web');\n return {\n status: 'error',\n error: 'Cannot getChannel in web',\n };\n }\n\n async listChannels(): Promise<ListChannelsResult> {\n console.warn('Cannot listChannels in web');\n throw {\n message: 'Cannot listChannels in web',\n error: 'platform_not_supported',\n };\n }\n\n async notifyAppReady(): Promise<AppReadyResult> {\n console.warn('Cannot notify App Ready in web');\n return { bundle: BUNDLE_BUILTIN };\n }\n\n async setMultiDelay(options: MultiDelayConditions): Promise<void> {\n console.warn('Cannot setMultiDelay in web', options?.delayConditions);\n return;\n }\n\n async setDelay(option: DelayCondition): Promise<void> {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n\n async cancelDelay(): Promise<void> {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n\n async isAutoUpdateAvailable(): Promise<AutoUpdateAvailable> {\n console.warn('Cannot isAutoUpdateAvailable in web');\n return { available: false };\n }\n\n async getCurrentBundle(): Promise<BundleInfo> {\n console.warn('Cannot get current bundle in web');\n return BUNDLE_BUILTIN;\n }\n\n async getNextBundle(): Promise<BundleInfo | null> {\n return Promise.resolve(null);\n }\n\n async setShakeMenu(_options: SetShakeMenuOptions): Promise<void> {\n throw this.unimplemented('Shake menu not available on web platform');\n }\n\n async isShakeMenuEnabled(): Promise<ShakeMenuEnabled> {\n return Promise.resolve({ enabled: false });\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -111,6 +111,13 @@ class CapacitorUpdaterWeb extends core.WebPlugin {
|
|
|
111
111
|
error: 'Cannot getChannel in web',
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
|
+
async listChannels() {
|
|
115
|
+
console.warn('Cannot listChannels in web');
|
|
116
|
+
throw {
|
|
117
|
+
message: 'Cannot listChannels in web',
|
|
118
|
+
error: 'platform_not_supported',
|
|
119
|
+
};
|
|
120
|
+
}
|
|
114
121
|
async notifyAppReady() {
|
|
115
122
|
console.warn('Cannot notify App Ready in web');
|
|
116
123
|
return { bundle: BUNDLE_BUILTIN };
|
|
@@ -136,8 +143,13 @@ class CapacitorUpdaterWeb extends core.WebPlugin {
|
|
|
136
143
|
return BUNDLE_BUILTIN;
|
|
137
144
|
}
|
|
138
145
|
async getNextBundle() {
|
|
139
|
-
|
|
140
|
-
|
|
146
|
+
return Promise.resolve(null);
|
|
147
|
+
}
|
|
148
|
+
async setShakeMenu(_options) {
|
|
149
|
+
throw this.unimplemented('Shake menu not available on web platform');
|
|
150
|
+
}
|
|
151
|
+
async isShakeMenuEnabled() {
|
|
152
|
+
return Promise.resolve({ enabled: false });
|
|
141
153
|
}
|
|
142
154
|
}
|
|
143
155
|
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async setStatsUrl(options) {\n console.warn('Cannot setStatsUrl in web', options);\n return;\n }\n async setUpdateUrl(options) {\n console.warn('Cannot setUpdateUrl in web', options);\n return;\n }\n async setChannelUrl(options) {\n console.warn('Cannot setChannelUrl in web', options);\n return;\n }\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n async getBuiltinVersion() {\n console.warn('Cannot get version in web');\n return { version: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async setChannel(options) {\n console.warn('Cannot setChannel in web', options);\n return {\n status: 'error',\n error: 'Cannot setChannel in web',\n };\n }\n async unsetChannel(options) {\n console.warn('Cannot unsetChannel in web', options);\n return;\n }\n async setCustomId(options) {\n console.warn('Cannot setCustomId in web', options);\n return;\n }\n async getChannel() {\n console.warn('Cannot getChannel in web');\n return {\n status: 'error',\n error: 'Cannot getChannel in web',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return { bundle: BUNDLE_BUILTIN };\n }\n async setMultiDelay(options) {\n console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);\n return;\n }\n async setDelay(option) {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n async isAutoUpdateAvailable() {\n console.warn('Cannot isAutoUpdateAvailable in web');\n return { available: false };\n }\n async getCurrentBundle() {\n console.warn('Cannot get current bundle in web');\n return BUNDLE_BUILTIN;\n }\n async getNextBundle() {\n
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async setStatsUrl(options) {\n console.warn('Cannot setStatsUrl in web', options);\n return;\n }\n async setUpdateUrl(options) {\n console.warn('Cannot setUpdateUrl in web', options);\n return;\n }\n async setChannelUrl(options) {\n console.warn('Cannot setChannelUrl in web', options);\n return;\n }\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n async getBuiltinVersion() {\n console.warn('Cannot get version in web');\n return { version: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async setChannel(options) {\n console.warn('Cannot setChannel in web', options);\n return {\n status: 'error',\n error: 'Cannot setChannel in web',\n };\n }\n async unsetChannel(options) {\n console.warn('Cannot unsetChannel in web', options);\n return;\n }\n async setCustomId(options) {\n console.warn('Cannot setCustomId in web', options);\n return;\n }\n async getChannel() {\n console.warn('Cannot getChannel in web');\n return {\n status: 'error',\n error: 'Cannot getChannel in web',\n };\n }\n async listChannels() {\n console.warn('Cannot listChannels in web');\n throw {\n message: 'Cannot listChannels in web',\n error: 'platform_not_supported',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return { bundle: BUNDLE_BUILTIN };\n }\n async setMultiDelay(options) {\n console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);\n return;\n }\n async setDelay(option) {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n async isAutoUpdateAvailable() {\n console.warn('Cannot isAutoUpdateAvailable in web');\n return { available: false };\n }\n async getCurrentBundle() {\n console.warn('Cannot get current bundle in web');\n return BUNDLE_BUILTIN;\n }\n async getNextBundle() {\n return Promise.resolve(null);\n }\n async setShakeMenu(_options) {\n throw this.unimplemented('Shake menu not available on web platform');\n }\n async isShakeMenuEnabled() {\n return Promise.resolve({ enabled: false });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AAEK,MAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;AAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;AACvE,CAAC;;ACRD;AACA;AACA;AACA;AACA;AAEA,MAAM,cAAc,GAAG;AACvB,IAAI,MAAM,EAAE,SAAS;AACrB,IAAI,OAAO,EAAE,EAAE;AACf,IAAI,UAAU,EAAE,0BAA0B;AAC1C,IAAI,EAAE,EAAE,SAAS;AACjB,IAAI,QAAQ,EAAE,EAAE;AAChB,CAAC;AACM,MAAM,mBAAmB,SAASC,cAAS,CAAC;AACnD,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;AAC/B,QAAQ,OAAO,CAAC,IAAI,CAAC,2BAA2B,EAAE,OAAO,CAAC;AAC1D,QAAQ;AACR;AACA,IAAI,MAA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AAC,IAAI,CAAC;AACpC;AACA,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;AACjC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,0CAA0C,CAAC;AAC5E;AACA,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAClD;AACA;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -110,6 +110,13 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
110
110
|
error: 'Cannot getChannel in web',
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
+
async listChannels() {
|
|
114
|
+
console.warn('Cannot listChannels in web');
|
|
115
|
+
throw {
|
|
116
|
+
message: 'Cannot listChannels in web',
|
|
117
|
+
error: 'platform_not_supported',
|
|
118
|
+
};
|
|
119
|
+
}
|
|
113
120
|
async notifyAppReady() {
|
|
114
121
|
console.warn('Cannot notify App Ready in web');
|
|
115
122
|
return { bundle: BUNDLE_BUILTIN };
|
|
@@ -135,8 +142,13 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
135
142
|
return BUNDLE_BUILTIN;
|
|
136
143
|
}
|
|
137
144
|
async getNextBundle() {
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
return Promise.resolve(null);
|
|
146
|
+
}
|
|
147
|
+
async setShakeMenu(_options) {
|
|
148
|
+
throw this.unimplemented('Shake menu not available on web platform');
|
|
149
|
+
}
|
|
150
|
+
async isShakeMenuEnabled() {
|
|
151
|
+
return Promise.resolve({ enabled: false });
|
|
140
152
|
}
|
|
141
153
|
}
|
|
142
154
|
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async setStatsUrl(options) {\n console.warn('Cannot setStatsUrl in web', options);\n return;\n }\n async setUpdateUrl(options) {\n console.warn('Cannot setUpdateUrl in web', options);\n return;\n }\n async setChannelUrl(options) {\n console.warn('Cannot setChannelUrl in web', options);\n return;\n }\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n async getBuiltinVersion() {\n console.warn('Cannot get version in web');\n return { version: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async setChannel(options) {\n console.warn('Cannot setChannel in web', options);\n return {\n status: 'error',\n error: 'Cannot setChannel in web',\n };\n }\n async unsetChannel(options) {\n console.warn('Cannot unsetChannel in web', options);\n return;\n }\n async setCustomId(options) {\n console.warn('Cannot setCustomId in web', options);\n return;\n }\n async getChannel() {\n console.warn('Cannot getChannel in web');\n return {\n status: 'error',\n error: 'Cannot getChannel in web',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return { bundle: BUNDLE_BUILTIN };\n }\n async setMultiDelay(options) {\n console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);\n return;\n }\n async setDelay(option) {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n async isAutoUpdateAvailable() {\n console.warn('Cannot isAutoUpdateAvailable in web');\n return { available: false };\n }\n async getCurrentBundle() {\n console.warn('Cannot get current bundle in web');\n return BUNDLE_BUILTIN;\n }\n async getNextBundle() {\n
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async setStatsUrl(options) {\n console.warn('Cannot setStatsUrl in web', options);\n return;\n }\n async setUpdateUrl(options) {\n console.warn('Cannot setUpdateUrl in web', options);\n return;\n }\n async setChannelUrl(options) {\n console.warn('Cannot setChannelUrl in web', options);\n return;\n }\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n async getBuiltinVersion() {\n console.warn('Cannot get version in web');\n return { version: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async setChannel(options) {\n console.warn('Cannot setChannel in web', options);\n return {\n status: 'error',\n error: 'Cannot setChannel in web',\n };\n }\n async unsetChannel(options) {\n console.warn('Cannot unsetChannel in web', options);\n return;\n }\n async setCustomId(options) {\n console.warn('Cannot setCustomId in web', options);\n return;\n }\n async getChannel() {\n console.warn('Cannot getChannel in web');\n return {\n status: 'error',\n error: 'Cannot getChannel in web',\n };\n }\n async listChannels() {\n console.warn('Cannot listChannels in web');\n throw {\n message: 'Cannot listChannels in web',\n error: 'platform_not_supported',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return { bundle: BUNDLE_BUILTIN };\n }\n async setMultiDelay(options) {\n console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);\n return;\n }\n async setDelay(option) {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n async isAutoUpdateAvailable() {\n console.warn('Cannot isAutoUpdateAvailable in web');\n return { available: false };\n }\n async getCurrentBundle() {\n console.warn('Cannot get current bundle in web');\n return BUNDLE_BUILTIN;\n }\n async getNextBundle() {\n return Promise.resolve(null);\n }\n async setShakeMenu(_options) {\n throw this.unimplemented('Shake menu not available on web platform');\n }\n async isShakeMenuEnabled() {\n return Promise.resolve({ enabled: false });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;AAEK,UAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;IAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;IACvE,CAAC;;ICRD;IACA;IACA;IACA;IACA;IAEA,MAAM,cAAc,GAAG;IACvB,IAAI,MAAM,EAAE,SAAS;IACrB,IAAI,OAAO,EAAE,EAAE;IACf,IAAI,UAAU,EAAE,0BAA0B;IAC1C,IAAI,EAAE,EAAE,SAAS;IACjB,IAAI,QAAQ,EAAE,EAAE;IAChB,CAAC;IACM,MAAM,mBAAmB,SAASC,cAAS,CAAC;IACnD,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,OAAO,CAAC,IAAI,CAAC,2BAA2B,EAAE,OAAO,CAAC;IAC1D,QAAQ;IACR;IACA,IAAI,MAAM,YAAY,CAAC,O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;IACpC;IACA,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;IACjC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,0CAA0C,CAAC;IAC5E;IACA,IAAI,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAClD;IACA;;;;;;;;;;;;;;;"}
|
|
@@ -14,7 +14,7 @@ import Version
|
|
|
14
14
|
*/
|
|
15
15
|
@objc(CapacitorUpdaterPlugin)
|
|
16
16
|
public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
17
|
-
|
|
17
|
+
let logger = Logger(withTag: "✨ CapgoUpdater")
|
|
18
18
|
|
|
19
19
|
public let identifier = "CapacitorUpdaterPlugin"
|
|
20
20
|
public let jsName = "CapacitorUpdater"
|
|
@@ -37,6 +37,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
37
37
|
CAPPluginMethod(name: "setChannel", returnType: CAPPluginReturnPromise),
|
|
38
38
|
CAPPluginMethod(name: "unsetChannel", returnType: CAPPluginReturnPromise),
|
|
39
39
|
CAPPluginMethod(name: "getChannel", returnType: CAPPluginReturnPromise),
|
|
40
|
+
CAPPluginMethod(name: "listChannels", returnType: CAPPluginReturnPromise),
|
|
40
41
|
CAPPluginMethod(name: "setCustomId", returnType: CAPPluginReturnPromise),
|
|
41
42
|
CAPPluginMethod(name: "getDeviceId", returnType: CAPPluginReturnPromise),
|
|
42
43
|
CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise),
|
|
@@ -44,10 +45,12 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
44
45
|
CAPPluginMethod(name: "isAutoUpdateEnabled", returnType: CAPPluginReturnPromise),
|
|
45
46
|
CAPPluginMethod(name: "getBuiltinVersion", returnType: CAPPluginReturnPromise),
|
|
46
47
|
CAPPluginMethod(name: "isAutoUpdateAvailable", returnType: CAPPluginReturnPromise),
|
|
47
|
-
CAPPluginMethod(name: "getNextBundle", returnType: CAPPluginReturnPromise)
|
|
48
|
+
CAPPluginMethod(name: "getNextBundle", returnType: CAPPluginReturnPromise),
|
|
49
|
+
CAPPluginMethod(name: "setShakeMenu", returnType: CAPPluginReturnPromise),
|
|
50
|
+
CAPPluginMethod(name: "isShakeMenuEnabled", returnType: CAPPluginReturnPromise)
|
|
48
51
|
]
|
|
49
52
|
public var implementation = CapgoUpdater()
|
|
50
|
-
private let PLUGIN_VERSION: String = "7.
|
|
53
|
+
private let PLUGIN_VERSION: String = "7.5.1"
|
|
51
54
|
static let updateUrlDefault = "https://plugin.capgo.app/updates"
|
|
52
55
|
static let statsUrlDefault = "https://plugin.capgo.app/stats"
|
|
53
56
|
static let channelUrlDefault = "https://plugin.capgo.app/channel_self"
|
|
@@ -67,6 +70,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
67
70
|
private var backgroundWork: DispatchWorkItem?
|
|
68
71
|
private var taskRunning = false
|
|
69
72
|
private var periodCheckDelay = 0
|
|
73
|
+
public var shakeMenuEnabled = false
|
|
70
74
|
let semaphoreReady = DispatchSemaphore(value: 0)
|
|
71
75
|
|
|
72
76
|
private var delayUpdateUtils: DelayUpdateUtils!
|
|
@@ -111,6 +115,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
111
115
|
appReadyTimeout = getConfig().getInt("appReadyTimeout", 10000)
|
|
112
116
|
implementation.timeout = Double(getConfig().getInt("responseTimeout", 20))
|
|
113
117
|
resetWhenUpdate = getConfig().getBoolean("resetWhenUpdate", true)
|
|
118
|
+
shakeMenuEnabled = getConfig().getBoolean("shakeMenu", false)
|
|
114
119
|
let periodCheckDelayValue = getConfig().getInt("periodCheckDelay", 0)
|
|
115
120
|
if periodCheckDelayValue >= 0 && periodCheckDelayValue > 600 {
|
|
116
121
|
periodCheckDelay = 600
|
|
@@ -493,7 +498,10 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
493
498
|
DispatchQueue.global(qos: .background).async {
|
|
494
499
|
let res = self.implementation.unsetChannel()
|
|
495
500
|
if res.error != "" {
|
|
496
|
-
call.reject(res.error
|
|
501
|
+
call.reject(res.error, "UNSETCHANNEL_FAILED", nil, [
|
|
502
|
+
"message": res.error,
|
|
503
|
+
"error": res.error.contains("Channel URL") ? "missing_config" : "request_failed"
|
|
504
|
+
])
|
|
497
505
|
} else {
|
|
498
506
|
if self._isAutoUpdateEnabled() && triggerAutoUpdate {
|
|
499
507
|
self.logger.info("Calling autoupdater after channel change!")
|
|
@@ -507,14 +515,20 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
507
515
|
@objc func setChannel(_ call: CAPPluginCall) {
|
|
508
516
|
guard let channel = call.getString("channel") else {
|
|
509
517
|
logger.error("setChannel called without channel")
|
|
510
|
-
call.reject("setChannel called without channel"
|
|
518
|
+
call.reject("setChannel called without channel", "SETCHANNEL_INVALID_PARAMS", nil, [
|
|
519
|
+
"message": "setChannel called without channel",
|
|
520
|
+
"error": "missing_parameter"
|
|
521
|
+
])
|
|
511
522
|
return
|
|
512
523
|
}
|
|
513
524
|
let triggerAutoUpdate = call.getBool("triggerAutoUpdate") ?? false
|
|
514
525
|
DispatchQueue.global(qos: .background).async {
|
|
515
526
|
let res = self.implementation.setChannel(channel: channel)
|
|
516
527
|
if res.error != "" {
|
|
517
|
-
call.reject(res.error
|
|
528
|
+
call.reject(res.error, "SETCHANNEL_FAILED", nil, [
|
|
529
|
+
"message": res.error,
|
|
530
|
+
"error": res.error.contains("Channel URL") ? "missing_config" : "request_failed"
|
|
531
|
+
])
|
|
518
532
|
} else {
|
|
519
533
|
if self._isAutoUpdateEnabled() && triggerAutoUpdate {
|
|
520
534
|
self.logger.info("Calling autoupdater after channel change!")
|
|
@@ -529,12 +543,30 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
529
543
|
DispatchQueue.global(qos: .background).async {
|
|
530
544
|
let res = self.implementation.getChannel()
|
|
531
545
|
if res.error != "" {
|
|
532
|
-
call.reject(res.error
|
|
546
|
+
call.reject(res.error, "GETCHANNEL_FAILED", nil, [
|
|
547
|
+
"message": res.error,
|
|
548
|
+
"error": res.error.contains("Channel URL") ? "missing_config" : "request_failed"
|
|
549
|
+
])
|
|
550
|
+
} else {
|
|
551
|
+
call.resolve(res.toDict())
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
@objc func listChannels(_ call: CAPPluginCall) {
|
|
557
|
+
DispatchQueue.global(qos: .background).async {
|
|
558
|
+
let res = self.implementation.listChannels()
|
|
559
|
+
if res.error != "" {
|
|
560
|
+
call.reject(res.error, "LISTCHANNELS_FAILED", nil, [
|
|
561
|
+
"message": res.error,
|
|
562
|
+
"error": res.error.contains("Channel URL") ? "missing_config" : "request_failed"
|
|
563
|
+
])
|
|
533
564
|
} else {
|
|
534
565
|
call.resolve(res.toDict())
|
|
535
566
|
}
|
|
536
567
|
}
|
|
537
568
|
}
|
|
569
|
+
|
|
538
570
|
@objc func setCustomId(_ call: CAPPluginCall) {
|
|
539
571
|
guard let customId = call.getString("customId") else {
|
|
540
572
|
logger.error("setCustomId called without customId")
|
|
@@ -960,4 +992,22 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
960
992
|
|
|
961
993
|
call.resolve(bundle!.toJSON())
|
|
962
994
|
}
|
|
995
|
+
|
|
996
|
+
@objc func setShakeMenu(_ call: CAPPluginCall) {
|
|
997
|
+
guard let enabled = call.getBool("enabled") else {
|
|
998
|
+
logger.error("setShakeMenu called without enabled parameter")
|
|
999
|
+
call.reject("setShakeMenu called without enabled parameter")
|
|
1000
|
+
return
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
self.shakeMenuEnabled = enabled
|
|
1004
|
+
logger.info("Shake menu \(enabled ? "enabled" : "disabled")")
|
|
1005
|
+
call.resolve()
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
@objc func isShakeMenuEnabled(_ call: CAPPluginCall) {
|
|
1009
|
+
call.resolve([
|
|
1010
|
+
"enabled": self.shakeMenuEnabled
|
|
1011
|
+
])
|
|
1012
|
+
}
|
|
963
1013
|
}
|
|
@@ -955,19 +955,17 @@ import UIKit
|
|
|
955
955
|
request.validate().responseDecodable(of: SetChannelDec.self) { response in
|
|
956
956
|
switch response.result {
|
|
957
957
|
case .success:
|
|
958
|
-
if let
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
setChannel.message = message
|
|
958
|
+
if let responseValue = response.value {
|
|
959
|
+
if let error = responseValue.error {
|
|
960
|
+
setChannel.error = error
|
|
961
|
+
} else {
|
|
962
|
+
setChannel.status = responseValue.status ?? ""
|
|
963
|
+
setChannel.message = responseValue.message ?? ""
|
|
964
|
+
}
|
|
966
965
|
}
|
|
967
966
|
case let .failure(error):
|
|
968
|
-
self.logger.error("Error unset Channel \(
|
|
969
|
-
setChannel.
|
|
970
|
-
setChannel.error = "response_error"
|
|
967
|
+
self.logger.error("Error unset Channel \(error)")
|
|
968
|
+
setChannel.error = "Request failed: \(error.localizedDescription)"
|
|
971
969
|
}
|
|
972
970
|
semaphore.signal()
|
|
973
971
|
}
|
|
@@ -992,19 +990,17 @@ import UIKit
|
|
|
992
990
|
request.validate().responseDecodable(of: SetChannelDec.self) { response in
|
|
993
991
|
switch response.result {
|
|
994
992
|
case .success:
|
|
995
|
-
if let
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
setChannel.message = message
|
|
993
|
+
if let responseValue = response.value {
|
|
994
|
+
if let error = responseValue.error {
|
|
995
|
+
setChannel.error = error
|
|
996
|
+
} else {
|
|
997
|
+
setChannel.status = responseValue.status ?? ""
|
|
998
|
+
setChannel.message = responseValue.message ?? ""
|
|
999
|
+
}
|
|
1003
1000
|
}
|
|
1004
1001
|
case let .failure(error):
|
|
1005
|
-
self.logger.error("Error set Channel \(
|
|
1006
|
-
setChannel.
|
|
1007
|
-
setChannel.error = "response_error"
|
|
1002
|
+
self.logger.error("Error set Channel \(error)")
|
|
1003
|
+
setChannel.error = "Request failed: \(error.localizedDescription)"
|
|
1008
1004
|
}
|
|
1009
1005
|
semaphore.signal()
|
|
1010
1006
|
}
|
|
@@ -1030,20 +1026,15 @@ import UIKit
|
|
|
1030
1026
|
}
|
|
1031
1027
|
switch response.result {
|
|
1032
1028
|
case .success:
|
|
1033
|
-
if let
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
if let channel = response.value?.channel {
|
|
1043
|
-
getChannel.channel = channel
|
|
1044
|
-
}
|
|
1045
|
-
if let allowSet = response.value?.allowSet {
|
|
1046
|
-
getChannel.allowSet = allowSet
|
|
1029
|
+
if let responseValue = response.value {
|
|
1030
|
+
if let error = responseValue.error {
|
|
1031
|
+
getChannel.error = error
|
|
1032
|
+
} else {
|
|
1033
|
+
getChannel.status = responseValue.status ?? ""
|
|
1034
|
+
getChannel.message = responseValue.message ?? ""
|
|
1035
|
+
getChannel.channel = responseValue.channel ?? ""
|
|
1036
|
+
getChannel.allowSet = responseValue.allowSet ?? true
|
|
1037
|
+
}
|
|
1047
1038
|
}
|
|
1048
1039
|
case let .failure(error):
|
|
1049
1040
|
if let data = response.data, let bodyString = String(data: data, encoding: .utf8) {
|
|
@@ -1054,15 +1045,81 @@ import UIKit
|
|
|
1054
1045
|
}
|
|
1055
1046
|
}
|
|
1056
1047
|
|
|
1057
|
-
self.logger.error("Error get Channel \(
|
|
1058
|
-
getChannel.
|
|
1059
|
-
getChannel.error = "response_error"
|
|
1048
|
+
self.logger.error("Error get Channel \(error)")
|
|
1049
|
+
getChannel.error = "Request failed: \(error.localizedDescription)"
|
|
1060
1050
|
}
|
|
1061
1051
|
}
|
|
1062
1052
|
semaphore.wait()
|
|
1063
1053
|
return getChannel
|
|
1064
1054
|
}
|
|
1065
1055
|
|
|
1056
|
+
func listChannels() -> ListChannels {
|
|
1057
|
+
let listChannels: ListChannels = ListChannels()
|
|
1058
|
+
if (self.channelUrl).isEmpty {
|
|
1059
|
+
logger.error("Channel URL is not set")
|
|
1060
|
+
listChannels.error = "Channel URL is not set"
|
|
1061
|
+
return listChannels
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
let semaphore: DispatchSemaphore = DispatchSemaphore(value: 0)
|
|
1065
|
+
|
|
1066
|
+
// Auto-detect values
|
|
1067
|
+
let appId = self.appId
|
|
1068
|
+
let platform = "ios"
|
|
1069
|
+
let isEmulator = self.isEmulator()
|
|
1070
|
+
let isProd = self.isProd()
|
|
1071
|
+
|
|
1072
|
+
// Create query parameters
|
|
1073
|
+
var urlComponents = URLComponents(string: self.channelUrl)
|
|
1074
|
+
urlComponents?.queryItems = [
|
|
1075
|
+
URLQueryItem(name: "app_id", value: appId),
|
|
1076
|
+
URLQueryItem(name: "platform", value: platform),
|
|
1077
|
+
URLQueryItem(name: "is_emulator", value: String(isEmulator)),
|
|
1078
|
+
URLQueryItem(name: "is_prod", value: String(isProd))
|
|
1079
|
+
]
|
|
1080
|
+
|
|
1081
|
+
guard let url = urlComponents?.url else {
|
|
1082
|
+
logger.error("Invalid channel URL")
|
|
1083
|
+
listChannels.error = "Invalid channel URL"
|
|
1084
|
+
return listChannels
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
let request = AF.request(url, method: .get, requestModifier: { $0.timeoutInterval = self.timeout })
|
|
1088
|
+
|
|
1089
|
+
request.validate().responseDecodable(of: ListChannelsDec.self) { response in
|
|
1090
|
+
defer {
|
|
1091
|
+
semaphore.signal()
|
|
1092
|
+
}
|
|
1093
|
+
switch response.result {
|
|
1094
|
+
case .success:
|
|
1095
|
+
if let responseValue = response.value {
|
|
1096
|
+
// Check for server-side errors
|
|
1097
|
+
if let error = responseValue.error {
|
|
1098
|
+
listChannels.error = error
|
|
1099
|
+
return
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
// Backend returns direct array, so channels should be populated by our custom decoder
|
|
1103
|
+
if let channels = responseValue.channels {
|
|
1104
|
+
listChannels.channels = channels.map { channel in
|
|
1105
|
+
var channelDict: [String: Any] = [:]
|
|
1106
|
+
channelDict["id"] = channel.id ?? ""
|
|
1107
|
+
channelDict["name"] = channel.name ?? ""
|
|
1108
|
+
channelDict["public"] = channel.public ?? false
|
|
1109
|
+
channelDict["allow_self_set"] = channel.allow_self_set ?? false
|
|
1110
|
+
return channelDict
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
case let .failure(error):
|
|
1115
|
+
self.logger.error("Error list channels \(error)")
|
|
1116
|
+
listChannels.error = "Request failed: \(error.localizedDescription)"
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
semaphore.wait()
|
|
1120
|
+
return listChannels
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1066
1123
|
private let operationQueue = OperationQueue()
|
|
1067
1124
|
|
|
1068
1125
|
func sendStats(action: String, versionName: String? = nil, oldVersionName: String? = "") {
|
|
@@ -67,6 +67,51 @@ extension GetChannel {
|
|
|
67
67
|
return dict
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
+
struct ChannelInfo: Codable {
|
|
71
|
+
let id: String?
|
|
72
|
+
let name: String?
|
|
73
|
+
let `public`: Bool?
|
|
74
|
+
let allow_self_set: Bool?
|
|
75
|
+
}
|
|
76
|
+
struct ListChannelsDec: Decodable {
|
|
77
|
+
let channels: [ChannelInfo]?
|
|
78
|
+
let error: String?
|
|
79
|
+
|
|
80
|
+
init(from decoder: Decoder) throws {
|
|
81
|
+
let container = try decoder.singleValueContainer()
|
|
82
|
+
|
|
83
|
+
if let channelsArray = try? container.decode([ChannelInfo].self) {
|
|
84
|
+
// Backend returns direct array
|
|
85
|
+
self.channels = channelsArray
|
|
86
|
+
self.error = nil
|
|
87
|
+
} else {
|
|
88
|
+
// Handle error response
|
|
89
|
+
let errorContainer = try decoder.container(keyedBy: CodingKeys.self)
|
|
90
|
+
self.channels = nil
|
|
91
|
+
self.error = try? errorContainer.decode(String.self, forKey: .error)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private enum CodingKeys: String, CodingKey {
|
|
96
|
+
case error
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
public class ListChannels: NSObject {
|
|
100
|
+
var channels: [[String: Any]] = []
|
|
101
|
+
var error: String = ""
|
|
102
|
+
}
|
|
103
|
+
extension ListChannels {
|
|
104
|
+
func toDict() -> [String: Any] {
|
|
105
|
+
var dict: [String: Any] = [String: Any]()
|
|
106
|
+
let otherSelf: Mirror = Mirror(reflecting: self)
|
|
107
|
+
for child: Mirror.Child in otherSelf.children {
|
|
108
|
+
if let key: String = child.label {
|
|
109
|
+
dict[key] = child.value
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return dict
|
|
113
|
+
}
|
|
114
|
+
}
|
|
70
115
|
struct InfoObject: Codable {
|
|
71
116
|
let platform: String?
|
|
72
117
|
let device_id: String?
|