Skip to content

Commit 963809a

Browse files
authored
Merge pull request #5 from numbersprotocol/feat/migrate-to-capacitor-8
feat: migrate to Capacitor 8
2 parents 54c6fc0 + 9d633a6 commit 963809a

14 files changed

Lines changed: 903 additions & 2581 deletions

‎.eslintignore‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎NumbersprotocolPreviewCamera.podspec‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
1111
s.author = package['author']
1212
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
1313
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14-
s.ios.deployment_target = '14.0'
14+
s.ios.deployment_target = '15.0'
1515
s.dependency 'Capacitor'
1616
s.swift_version = '5.1'
1717
end

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ flipCamera() => Promise<void>
129129
### getFlashModes()
130130

131131
```typescript
132-
getFlashModes() => Promise<any>
132+
getFlashModes() => Promise<{ result: string[]; }>
133133
```
134134

135-
**Returns:** <code>Promise&lt;any&gt;</code>
135+
**Returns:** <code>Promise&lt;{ result: string[]; }&gt;</code>
136136

137137
--------------------
138138

‎android/build.gradle‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
ext {
22
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
33
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
4-
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
5-
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
4+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
5+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
66
}
77

88
buildscript {
9-
ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.9.25'
9+
ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '2.2.20'
1010
repositories {
1111
google()
1212
mavenCentral()
1313
}
1414
dependencies {
15-
classpath 'com.android.tools.build:gradle:8.7.2'
15+
classpath 'com.android.tools.build:gradle:8.13.0'
1616
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1717
}
1818
}
@@ -21,33 +21,37 @@ apply plugin: 'com.android.library'
2121
apply plugin: 'kotlin-android'
2222

2323
android {
24-
namespace "io.numbersprotocol.capturelite.plugins.previewcamera"
25-
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
24+
namespace = "io.numbersprotocol.capturelite.plugins.previewcamera"
25+
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
2626
defaultConfig {
27-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
27+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
2828
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
2929
versionCode 1
3030
versionName "1.0"
3131
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3232
}
3333
buildFeatures {
34-
dataBinding true
34+
dataBinding = true
3535
}
3636
buildTypes {
3737
release {
38-
minifyEnabled false
38+
minifyEnabled = false
3939
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
4040
}
4141
}
4242
lintOptions {
43-
abortOnError false
43+
abortOnError = false
4444
}
4545
compileOptions {
4646
sourceCompatibility JavaVersion.VERSION_21
4747
targetCompatibility JavaVersion.VERSION_21
4848
}
4949
}
5050

51+
kotlin {
52+
jvmToolchain(21)
53+
}
54+
5155
repositories {
5256
google()
5357
mavenCentral()

‎android/gradle/wrapper/gradle-wrapper.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

‎eslint.config.mjs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import eslint from '@eslint/js';
2+
import tseslint from 'typescript-eslint';
3+
4+
export default tseslint.config(
5+
eslint.configs.recommended,
6+
...tseslint.configs.recommended,
7+
{
8+
ignores: ['build/', 'dist/', 'android/build/', 'ios/build/'],
9+
},
10+
{
11+
rules: {
12+
'@typescript-eslint/no-unused-vars': [
13+
'error',
14+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
15+
],
16+
},
17+
},
18+
);

‎ios/Plugin.xcodeproj/project.pbxproj‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@
394394
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
395395
GCC_WARN_UNUSED_FUNCTION = YES;
396396
GCC_WARN_UNUSED_VARIABLE = YES;
397-
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
397+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
398398
MTL_ENABLE_DEBUG_INFO = YES;
399399
ONLY_ACTIVE_ARCH = YES;
400400
SDKROOT = iphoneos;
@@ -454,7 +454,7 @@
454454
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
455455
GCC_WARN_UNUSED_FUNCTION = YES;
456456
GCC_WARN_UNUSED_VARIABLE = YES;
457-
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
457+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
458458
MTL_ENABLE_DEBUG_INFO = NO;
459459
SDKROOT = iphoneos;
460460
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
@@ -477,8 +477,8 @@
477477
DYLIB_INSTALL_NAME_BASE = "@rpath";
478478
INFOPLIST_FILE = Plugin/Info.plist;
479479
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
480-
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
481-
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2;
480+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
481+
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 15.0;
482482
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)\n$(FRAMEWORK_SEARCH_PATHS)\n$(FRAMEWORK_SEARCH_PATHS)";
483483
ONLY_ACTIVE_ARCH = YES;
484484
PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.Plugin;
@@ -503,8 +503,8 @@
503503
DYLIB_INSTALL_NAME_BASE = "@rpath";
504504
INFOPLIST_FILE = Plugin/Info.plist;
505505
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
506-
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
507-
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2;
506+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
507+
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 15.0;
508508
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)";
509509
ONLY_ACTIVE_ARCH = NO;
510510
PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.Plugin;

‎ios/Plugin/PreviewCamera.swift‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import Foundation
22
import UIKit
3+
import WebKit
34
import Capacitor
45
import AVFoundation
5-
import MobileCoreServices
6+
import UniformTypeIdentifiers
67

78
typealias CapacitorNotifyListeners = (_ eventName: String, _ data: [String : Any?]?) -> Void
89

@@ -14,7 +15,7 @@ enum CaptureQuality {
1415

1516
let notifyListeners: CapacitorNotifyListeners
1617

17-
var webView: UIView
18+
var webView: WKWebView
1819
var parentView: UIView
1920
var settings: CameraSettings
2021
// Camera Preview state
@@ -43,7 +44,7 @@ enum CaptureQuality {
4344

4445
var captureQuality = CaptureQuality.hq
4546

46-
init(webView: UIView, parentView: UIView, settings: CameraSettings, notifyListeners: @escaping CapacitorNotifyListeners) {
47+
init(webView: WKWebView, parentView: UIView, settings: CameraSettings, notifyListeners: @escaping CapacitorNotifyListeners) {
4748
self.webView = webView
4849
self.parentView = parentView
4950
self.settings = settings
@@ -416,16 +417,17 @@ enum CaptureQuality {
416417
}
417418

418419
public func saveFileToUserDevice(_ filePath: String) {
419-
guard let fileExtension = URL(fileURLWithPath: filePath).pathExtension as CFString?,
420-
let fileType = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, nil)?.takeRetainedValue() else {
420+
let fileExtension = URL(fileURLWithPath: filePath).pathExtension
421+
guard !fileExtension.isEmpty,
422+
let fileType = UTType(filenameExtension: fileExtension) else {
421423
print("Unable to determine file type.")
422424
return
423425
}
424426
// Remove `file://` prefix if any
425427
let filePathClean = filePath.replacingOccurrences(of: "file://", with: "")
426-
if UTTypeConformsTo(fileType, kUTTypeImage) {
428+
if fileType.conforms(to: .image) {
427429
saveImageToPhotoAlbum(filePathClean)
428-
} else if UTTypeConformsTo(fileType, kUTTypeMovie) {
430+
} else if fileType.conforms(to: .movie) {
429431
saveVideoToPhotoAlbum(videoPath: filePathClean)
430432
} else {
431433
print("File type is neither image nor video.")

‎ios/Podfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
platform :ios, '14.0'
1+
platform :ios, '15.0'
22

33
def capacitor_pods
44
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks

0 commit comments

Comments
 (0)