akanjs 2.2.0 → 2.2.1-rc.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.
Files changed (2) hide show
  1. package/client/capacitor.ts +19 -17
  2. package/package.json +1 -1
@@ -169,56 +169,58 @@ const loadCapacitorModule = <K extends keyof CapacitorModuleMap>(
169
169
  return loaded;
170
170
  };
171
171
 
172
- const asCapacitorModule = <T>(modulePromise: Promise<unknown>) => modulePromise as Promise<T>;
172
+ const importNativeModule = <T>(specifier: string) => import(specifier) as Promise<T>;
173
+
174
+ const capacitorPackage = (name: string) => `@capacitor/${name}`;
175
+
176
+ const capacitorCommunityPackage = (name: string) => `@capacitor-community/${name}`;
173
177
 
174
178
  export const loadCapacitorApp = () =>
175
- loadCapacitorModule("app", () => asCapacitorModule<CapacitorAppModule>(import("@capacitor/app")));
179
+ loadCapacitorModule("app", () => importNativeModule<CapacitorAppModule>(capacitorPackage("app")));
176
180
 
177
181
  export const loadCapacitorBrowser = () =>
178
- loadCapacitorModule("browser", () => asCapacitorModule<CapacitorBrowserModule>(import("@capacitor/browser")));
182
+ loadCapacitorModule("browser", () => importNativeModule<CapacitorBrowserModule>(capacitorPackage("browser")));
179
183
 
180
184
  export const loadCapacitorCamera = () =>
181
- loadCapacitorModule("camera", () => asCapacitorModule<CapacitorCameraModule>(import("@capacitor/camera")));
185
+ loadCapacitorModule("camera", () => importNativeModule<CapacitorCameraModule>(capacitorPackage("camera")));
182
186
 
183
187
  export const loadCapacitorContacts = () =>
184
188
  loadCapacitorModule("contacts", () =>
185
- asCapacitorModule<CapacitorContactsModule>(import("@capacitor-community/contacts")),
189
+ importNativeModule<CapacitorContactsModule>(capacitorCommunityPackage("contacts")),
186
190
  );
187
191
 
188
192
  export const loadCapacitorCore = () =>
189
- loadCapacitorModule("core", () => asCapacitorModule<CapacitorCoreModule>(import("@capacitor/core")));
193
+ loadCapacitorModule("core", () => importNativeModule<CapacitorCoreModule>(capacitorPackage("core")));
190
194
 
191
195
  export const loadCapacitorDevice = () =>
192
- loadCapacitorModule("device", () => asCapacitorModule<CapacitorDeviceModule>(import("@capacitor/device")));
196
+ loadCapacitorModule("device", () => importNativeModule<CapacitorDeviceModule>(capacitorPackage("device")));
193
197
 
194
198
  export const loadCapacitorFcm = () =>
195
- loadCapacitorModule("fcm", () => asCapacitorModule<CapacitorFcmModule>(import("@capacitor-community/fcm")));
199
+ loadCapacitorModule("fcm", () => importNativeModule<CapacitorFcmModule>(capacitorCommunityPackage("fcm")));
196
200
 
197
201
  export const loadCapacitorGeolocation = () =>
198
202
  loadCapacitorModule("geolocation", () =>
199
- asCapacitorModule<CapacitorGeolocationModule>(import("@capacitor/geolocation")),
203
+ importNativeModule<CapacitorGeolocationModule>(capacitorPackage("geolocation")),
200
204
  );
201
205
 
202
206
  export const loadCapacitorHaptics = () =>
203
- loadCapacitorModule("haptics", () => asCapacitorModule<CapacitorHapticsModule>(import("@capacitor/haptics")));
207
+ loadCapacitorModule("haptics", () => importNativeModule<CapacitorHapticsModule>(capacitorPackage("haptics")));
204
208
 
205
209
  export const loadCapacitorKeyboard = () =>
206
- loadCapacitorModule("keyboard", () => asCapacitorModule<CapacitorKeyboardModule>(import("@capacitor/keyboard")));
210
+ loadCapacitorModule("keyboard", () => importNativeModule<CapacitorKeyboardModule>(capacitorPackage("keyboard")));
207
211
 
208
212
  export const loadCapacitorPreferences = () =>
209
213
  loadCapacitorModule("preferences", () =>
210
- asCapacitorModule<CapacitorPreferencesModule>(import("@capacitor/preferences")),
214
+ importNativeModule<CapacitorPreferencesModule>(capacitorPackage("preferences")),
211
215
  );
212
216
 
213
217
  export const loadCapacitorPushNotifications = () =>
214
218
  loadCapacitorModule("pushNotifications", () =>
215
- asCapacitorModule<CapacitorPushNotificationsModule>(import("@capacitor/push-notifications")),
219
+ importNativeModule<CapacitorPushNotificationsModule>(capacitorPackage("push-notifications")),
216
220
  );
217
221
 
218
222
  export const loadCapacitorSafeArea = () =>
219
- loadCapacitorModule("safeArea", () =>
220
- asCapacitorModule<CapacitorSafeAreaModule>(import("capacitor-plugin-safe-area")),
221
- );
223
+ loadCapacitorModule("safeArea", () => importNativeModule<CapacitorSafeAreaModule>("capacitor-plugin-safe-area"));
222
224
 
223
225
  export const loadCapacitorUpdater = () =>
224
- loadCapacitorModule("updater", () => asCapacitorModule<CapacitorUpdaterModule>(import("@capgo/capacitor-updater")));
226
+ loadCapacitorModule("updater", () => importNativeModule<CapacitorUpdaterModule>("@capgo/capacitor-updater"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akanjs",
3
- "version": "2.2.0",
3
+ "version": "2.2.1-rc.1",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {