Skip to content

Commit

Permalink
socket.io-client-services: Fix throwing of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Nov 11, 2024
1 parent 5c21408 commit 8debc83
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 126 deletions.
4 changes: 2 additions & 2 deletions apps/whattheduck/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "net.ducksmanager.whattheduck"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 129
versionName "3.0.20"
versionCode 130
versionName "3.0.21"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
Expand Down
1 change: 0 additions & 1 deletion apps/whattheduck/android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ android {
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies {
implementation project(':capacitor-community-camera-preview')
implementation project(':capacitor-community-sqlite')
implementation project(':capacitor-app')
implementation project(':capacitor-camera')
implementation project(':capacitor-clipboard')
Expand Down
5 changes: 3 additions & 2 deletions apps/whattheduck/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version='1.0' encoding='utf-8' ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down Expand Up @@ -28,6 +31,4 @@
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
</provider>
</application>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
3 changes: 0 additions & 3 deletions apps/whattheduck/android/capacitor.settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ project(':capacitor-android').projectDir = new File('../../../node_modules/.pnpm
include ':capacitor-community-camera-preview'
project(':capacitor-community-camera-preview').projectDir = new File('../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor-community/camera-preview/android')

include ':capacitor-community-sqlite'
project(':capacitor-community-sqlite').projectDir = new File('../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor-community/sqlite/android')

include ':capacitor-app'
project(':capacitor-app').projectDir = new File('../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/app/android')

Expand Down
8 changes: 4 additions & 4 deletions apps/whattheduck/ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,15 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 129;
CURRENT_PROJECT_VERSION = 130;
DEVELOPMENT_TEAM = ZHTS8HRVD7;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.1;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 3.0.20;
MARKETING_VERSION = 3.0.21;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = net.ducksmanager.whattheduck;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -390,15 +390,15 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 129;
CURRENT_PROJECT_VERSION = 130;
DEVELOPMENT_TEAM = ZHTS8HRVD7;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.1;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 3.0.20;
MARKETING_VERSION = 3.0.21;
PRODUCT_BUNDLE_IDENTIFIER = net.ducksmanager.whattheduck;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
Expand Down
1 change: 0 additions & 1 deletion apps/whattheduck/ios/App/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def capacitor_pods
pod 'Capacitor', :path => '../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios'
pod 'CapacitorCommunityCameraPreview', :path => '../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor-community/camera-preview'
pod 'CapacitorCommunitySqlite', :path => '../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor-community/sqlite'
pod 'CapacitorApp', :path => '../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/app'
pod 'CapacitorCamera', :path => '../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/camera'
pod 'CapacitorClipboard', :path => '../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/clipboard'
Expand Down
20 changes: 1 addition & 19 deletions apps/whattheduck/ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ PODS:
- Capacitor
- CapacitorCommunityCameraPreview (6.0.0):
- Capacitor
- CapacitorCommunitySqlite (6.0.2):
- Capacitor
- SQLCipher
- ZIPFoundation
- CapacitorCordova (6.1.2)
- CapacitorHaptics (6.0.1):
- Capacitor
Expand All @@ -36,22 +32,15 @@ PODS:
- SentryCapacitor (1.0.1):
- Capacitor
- Sentry/HybridSDK (= 8.36.0)
- SQLCipher (4.6.0):
- SQLCipher/standard (= 4.6.0)
- SQLCipher/common (4.6.0)
- SQLCipher/standard (4.6.0):
- SQLCipher/common
- SSZipArchive (2.4.3)
- Version (0.8.0)
- ZIPFoundation (0.9.19)

DEPENDENCIES:
- "Capacitor (from `../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios`)"
- "CapacitorApp (from `../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/app`)"
- "CapacitorCamera (from `../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/camera`)"
- "CapacitorClipboard (from `../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/clipboard`)"
- "CapacitorCommunityCameraPreview (from `../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor-community/camera-preview`)"
- "CapacitorCommunitySqlite (from `../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor-community/sqlite`)"
- "CapacitorCordova (from `../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios`)"
- "CapacitorHaptics (from `../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/haptics`)"
- "CapacitorKeyboard (from `../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/keyboard`)"
Expand All @@ -66,10 +55,8 @@ SPEC REPOS:
trunk:
- Alamofire
- Sentry
- SQLCipher
- SSZipArchive
- Version
- ZIPFoundation

EXTERNAL SOURCES:
Capacitor:
Expand All @@ -82,8 +69,6 @@ EXTERNAL SOURCES:
:path: "../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/clipboard"
CapacitorCommunityCameraPreview:
:path: "../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor-community/camera-preview"
CapacitorCommunitySqlite:
:path: "../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor-community/sqlite"
CapacitorCordova:
:path: "../../../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor/ios"
CapacitorHaptics:
Expand All @@ -110,7 +95,6 @@ SPEC CHECKSUMS:
CapacitorCamera: 81ce64062cd82b82cc75a79616fda4bd09d7f643
CapacitorClipboard: 756cd7e83e8d5d19b0c74f40b57517c287bd5fe2
CapacitorCommunityCameraPreview: 9319cde1da660b7643833dac20aaa85135bd1441
CapacitorCommunitySqlite: 47dab3a2d9a9581a0fe7642cf9cffd34c5d5b358
CapacitorCordova: f48c89f96c319101cd2f0ce8a2b7449b5fb8b3dd
CapacitorHaptics: fe689ade56ef20ec9b041a753c6da70c5d8ec9a9
CapacitorKeyboard: 2700f9b18687be021e28b5a09b59eb151a46d5e0
Expand All @@ -121,11 +105,9 @@ SPEC CHECKSUMS:
CapgoCapacitorUpdater: 3414431eb976d68edafd28f2abfee6175aa1b76c
Sentry: f8374b5415bc38dfb5645941b3ae31230fbeae57
SentryCapacitor: 2137257959f06553337c81be4ed0c10acefef58b
SQLCipher: 30a8e81afa6128e600b17ffa77d0f92fa05ed208
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
Version: de5907f2c5d0f3cf21708db7801d1d5401139486
ZIPFoundation: b8c29ea7ae353b309bc810586181fd073cb3312c

PODFILE CHECKSUM: 05167ac1ae5094bdf5d1e598ae80868da5e8a3be
PODFILE CHECKSUM: 9fce238e711e75f665ec4326075dbdb099c2bcf6

COCOAPODS: 1.15.2
2 changes: 0 additions & 2 deletions apps/whattheduck/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
},
"dependencies": {
"@capacitor-community/camera-preview": "^6.0.0",
"@capacitor-community/sqlite": "^6.0.2",
"@capacitor/android": "^6.1.2",
"@capacitor/app": "^6.0.1",
"@capacitor/camera": "^6.1.0",
Expand Down Expand Up @@ -50,7 +49,6 @@
"dayjs": "^1.11.13",
"ionicons": "^7.4.0",
"js-cookie": "^3.0.5",
"localforage-cordovasqlitedriver": "^1.8.0",
"pinia": "^2.2.6",
"sass": "^1.80.6",
"universal-cookie": "^7.2.2",
Expand Down
26 changes: 15 additions & 11 deletions apps/whattheduck/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,30 @@ const assignSocket = () => {
const updateBundle = async () => {
const currentBundleVersion = (await CapacitorUpdater.current())?.bundle.version;
const bundle = await socket.value!.app.services.getBundleUrl({ version: currentBundleVersion });
if (Capacitor.isNativePlatform() && 'url' in bundle && bundle.url) {
CapacitorUpdater.addListener('download', ({ percent }) => {
bundleDownloadProgress.value = percent / 100;
});
const bundleInfo = await CapacitorUpdater.download(bundle);
await CapacitorUpdater.set(bundleInfo);
} else {
switch (bundle.error) {
try {
const bundle = await socket.value!.app.services.getBundleUrl({ version: currentBundleVersion });
console.log('Latest bundle', bundle);
if (Capacitor.isNativePlatform() && 'url' in bundle && bundle.url) {
CapacitorUpdater.addListener('download', ({ percent }) => {
bundleDownloadProgress.value = percent / 100;
});
const bundleInfo = await CapacitorUpdater.download(bundle);
await CapacitorUpdater.set(bundleInfo);
}
} catch (e) {
const { error, errorDetails } = e as unknown as { error: string; errorDetails: string };
switch (error) {
case 'Already up to date':
console.log('Bundle is already up to date');
break;
default:
console.warn(bundle.error, bundle.errorDetails);
console.warn(error, errorDetails);
}
}
};
assignSocket();
updateBundle().then(() => {
updateBundle().finally(() => {
watch(
token,
async () => {
Expand Down
10 changes: 4 additions & 6 deletions apps/whattheduck/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@ import { defineCustomElements } from '@ionic/pwa-elements/loader';
import { Drivers, Storage } from '@ionic/storage';
import { IonicVue } from '@ionic/vue';
import { init as sentryInit } from '@sentry/capacitor';
import CordovaSQLiteDriver from 'localforage-cordovasqlitedriver';
import { createPinia } from 'pinia';
import VueVirtualScroller from 'vue-virtual-scroller';

import { SocketClient } from '~socket.io-client-services/index';
import en from '~translations/en.json';
import sv from '~translations/sv.json';
import { i18n } from '~web';

import App from './App.vue';
import router from './router';

import en from '~translations/en.json';
import sv from '~translations/sv.json';

CapacitorUpdater.notifyAppReady();

const socketUrl = ['web', 'ios'].includes(Capacitor.getPlatform())
Expand Down Expand Up @@ -64,10 +63,9 @@ router.isReady().then(async () => {
});
}
const storage = new Storage({
driverOrder: [CordovaSQLiteDriver._driver, Drivers.IndexedDB, Drivers.LocalStorage],
driverOrder: [Drivers.IndexedDB, Drivers.LocalStorage],
name: 'whattheduck',
});
await storage.defineDriver(CordovaSQLiteDriver);
await storage.create();
app.provide('storage', storage);
app.mount('#app');
Expand Down
5 changes: 2 additions & 3 deletions packages/socket.io-client-services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,8 @@ export class SocketClient {
await debugCall();
const data = await socket!.emitWithAck(event, ...args);

if ("error" in data) {
console.error(data.error, data.errorDetails);
throw new Error(JSON.stringify(data));
if (typeof data === 'object' && "error" in data) {
throw data;
}
await debugCall(true);
if (cache && cacheKey) {
Expand Down
Loading

0 comments on commit 8debc83

Please sign in to comment.