@simplymobile/capacitor-godex-printer 0.0.4 → 2.0.0

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 CHANGED
@@ -1,16 +1,16 @@
1
- # @simplymobile/capacitor-godex-printer
2
-
3
- Capacitor GoDEX printer plugin
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install @simplymobile/capacitor-godex-printer
9
- npx cap sync
10
- ```
11
-
12
- ## API
13
-
1
+ # @simplymobile/capacitor-godex-printer
2
+
3
+ Capacitor GoDEX printer plugin
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @simplymobile/capacitor-godex-printer
9
+ npx cap sync
10
+ ```
11
+
12
+ ## API
13
+
14
14
  <docgen-index>
15
15
 
16
16
  * [`getVersion()`](#getversion)
@@ -19,8 +19,8 @@ npx cap sync
19
19
  * [`disconnect()`](#disconnect)
20
20
  * [`getPrinterDPI()`](#getprinterdpi)
21
21
 
22
- </docgen-index>
23
-
22
+ </docgen-index>
23
+
24
24
  <docgen-api>
25
25
  <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
26
26
 
@@ -82,4 +82,4 @@ getPrinterDPI() => Promise<{ value: number; }>
82
82
 
83
83
  --------------------
84
84
 
85
- </docgen-api>
85
+ </docgen-api>
@@ -1,17 +1,17 @@
1
- require 'json'
2
-
3
- package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
-
5
- Pod::Spec.new do |s|
6
- s.name = 'SimplymobileCapacitorGodexPrinter'
7
- s.version = package['version']
8
- s.summary = package['description']
9
- s.license = package['license']
10
- s.homepage = package['repository']['url']
11
- s.author = package['author']
12
- s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
- s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
- s.ios.deployment_target = '13.0'
15
- s.dependency 'Capacitor'
16
- s.swift_version = '5.1'
17
- end
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'SimplymobileCapacitorGodexPrinter'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '13.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
@@ -1,57 +1,58 @@
1
- ext {
2
- junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
- androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
4
- androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
5
- androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
6
- }
7
-
8
- buildscript {
9
- repositories {
10
- google()
11
- mavenCentral()
12
- }
13
- dependencies {
14
- classpath 'com.android.tools.build:gradle:7.2.1'
15
- }
16
- }
17
-
18
- apply plugin: 'com.android.library'
19
-
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:8.0.0'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
20
  android {
21
- compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
22
- defaultConfig {
23
- minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
24
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
25
- versionCode 1
26
- versionName "1.0"
27
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
28
- }
29
- buildTypes {
30
- release {
31
- minifyEnabled false
32
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33
- }
34
- }
35
- lintOptions {
36
- abortOnError false
37
- }
38
- compileOptions {
39
- sourceCompatibility JavaVersion.VERSION_11
40
- targetCompatibility JavaVersion.VERSION_11
41
- }
42
- }
43
-
44
- repositories {
45
- google()
46
- mavenCentral()
47
- }
48
-
49
-
50
- dependencies {
51
- implementation fileTree(dir: 'libs', include: ['*.jar'])
52
- implementation project(':capacitor-android')
53
- implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
54
- testImplementation "junit:junit:$junitVersion"
55
- androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
56
- androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
57
- }
21
+ namespace "pl.simplymobile.plugins.godexprinter"
22
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
23
+ defaultConfig {
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
26
+ versionCode 1
27
+ versionName "1.0"
28
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29
+ }
30
+ buildTypes {
31
+ release {
32
+ minifyEnabled false
33
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34
+ }
35
+ }
36
+ lintOptions {
37
+ abortOnError false
38
+ }
39
+ compileOptions {
40
+ sourceCompatibility JavaVersion.VERSION_17
41
+ targetCompatibility JavaVersion.VERSION_17
42
+ }
43
+ }
44
+
45
+ repositories {
46
+ google()
47
+ mavenCentral()
48
+ }
49
+
50
+
51
+ dependencies {
52
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
53
+ implementation project(':capacitor-android')
54
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
+ testImplementation "junit:junit:$junitVersion"
56
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
58
+ }
Binary file
@@ -1,3 +1,3 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="pl.simplymobile.plugins.godexprinter">
3
- </manifest>
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ >
3
+ </manifest>
@@ -1,93 +1,122 @@
1
- package pl.simplymobile.plugins.godexprinter;
2
-
3
- import com.getcapacitor.JSObject;
4
- import com.getcapacitor.Plugin;
5
- import com.getcapacitor.PluginCall;
6
- import com.getcapacitor.PluginMethod;
7
- import com.getcapacitor.annotation.CapacitorPlugin;
8
-
9
- @CapacitorPlugin(name = "GodexPrinter")
10
- public class GodexPrinterPlugin extends Plugin {
11
-
12
- private GodexPrinter implementation;
13
-
14
- @Override
15
- public void load() {
16
- implementation = new GodexPrinter();
17
- implementation.setDefaults(this.getActivity().getApplicationContext());
18
- }
19
-
20
- @PluginMethod
21
- public void getVersion(PluginCall call) {
22
- JSObject ret = new JSObject();
23
- ret.put("version", implementation.getVersion());
24
- call.resolve(ret);
25
- }
26
-
27
- @PluginMethod
28
- public void connectToUSB(PluginCall call) {
29
- JSObject ret = new JSObject();
30
- var result = implementation.connectToUSB();
31
-
32
- if (result) {
33
- ret.put("value", "USB Connected");
34
- } else {
35
- ret.put("value", "USB Connect fail");
36
- }
37
-
38
- call.resolve(ret);
39
- }
40
-
41
- @PluginMethod
42
- public void printFromUSB(PluginCall call) {
43
- String value = call.getString("value");
44
- JSObject ret = new JSObject();
45
-
46
- var connectResult = implementation.connectToUSB();
47
- if (!connectResult) {
48
- ret.put("value", "USB Connect fail");
49
- call.resolve(ret);
50
- return;
51
- }
52
-
53
- var printResult = implementation.printFromUSB(value);
54
- if (!printResult) {
55
- ret.put("value", "Print fail");
56
- call.resolve(ret);
57
- return;
58
- }
59
-
60
- var disconnectResult = implementation.disconnect();
61
- if (!disconnectResult) {
62
- ret.put("value", "Disconnect fail");
63
- call.resolve(ret);
64
- return;
65
- }
66
-
67
- ret.put("value", "Print success!");
68
- call.resolve(ret);
69
- }
70
-
71
- @PluginMethod
72
- public void disconnect(PluginCall call) {
73
- JSObject ret = new JSObject();
74
- var result = implementation.disconnect();
75
-
76
- if (result) {
77
- ret.put("value", "Disconnected");
78
- } else {
79
- ret.put("value", "Disconnect fail");
80
- }
81
-
82
- call.resolve(ret);
83
- }
84
-
85
- @PluginMethod
86
- public void getPrinterDPI(PluginCall call) {
87
- JSObject ret = new JSObject();
88
-
89
- ret.put("value", implementation.getPrinterDPI());
90
-
91
- call.resolve(ret);
92
- }
93
- }
1
+ package pl.simplymobile.plugins.godexprinter;
2
+
3
+ import android.util.Log;
4
+
5
+ import com.getcapacitor.JSObject;
6
+ import com.getcapacitor.Plugin;
7
+ import com.getcapacitor.PluginCall;
8
+ import com.getcapacitor.PluginMethod;
9
+ import com.getcapacitor.annotation.CapacitorPlugin;
10
+ import com.godex.Godex;
11
+
12
+ import java.io.IOException;
13
+
14
+ @CapacitorPlugin(name = "GodexPrinter")
15
+ public class GodexPrinterPlugin extends Plugin {
16
+
17
+ private boolean connected = false;
18
+
19
+ @Override
20
+ public void load() {
21
+ Godex.debug(3);
22
+ var context = this.getActivity().getApplicationContext();
23
+ Godex.getMainContext(context);
24
+ try {
25
+ connected = Godex.openport(null, 3);
26
+ } catch (Exception e) {
27
+ Log.i("connectToUSB", e.getMessage());
28
+ }
29
+ }
30
+
31
+ @PluginMethod
32
+ public void getVersion(PluginCall call) {
33
+ JSObject ret = new JSObject();
34
+
35
+ var value = Godex.getVersion();
36
+ Log.i("getVersion", value + "test");
37
+
38
+ ret.put("version", value);
39
+ call.resolve(ret);
40
+ }
41
+
42
+ @PluginMethod
43
+ public void connectToUSB(PluginCall call) {
44
+ JSObject ret = new JSObject();
45
+ Log.i("connectToUSB", "connect started!");
46
+
47
+ try {
48
+ connected = Godex.openport(null, 3);
49
+ } catch (Exception e) {
50
+ Log.i("connectToUSB", e.getMessage());
51
+ ret.put("value", e.getMessage());
52
+ }
53
+
54
+ call.resolve(ret);
55
+ }
56
+
57
+ @PluginMethod
58
+ public void printFromUSB(PluginCall call) {
59
+ String value = call.getString("value");
60
+ JSObject ret = new JSObject();
61
+
62
+ connected = Godex.openport(null, 3);
63
+
64
+ if (!connected) {
65
+ ret.put("value", "Błąd połączenia USB");
66
+ call.resolve(ret);
67
+ return;
68
+ }
69
+
70
+ try {
71
+ var printResult = Godex.sendCommand(value);
72
+ if (!printResult) {
73
+ try {
74
+ Godex.close();
75
+ } catch (IOException e) {
76
+ Log.i("connectToUSB", e.getMessage());
77
+ }
78
+ ret.put("value", "Błąd wydruku! Spróbuj jeszcze raz.");
79
+ call.resolve(ret);
80
+ return;
81
+ }
82
+ ret.put("value", "Wydruk udany!");
83
+ } catch (Exception e) {
84
+ ret.put("value", "Zezwól na dostęp do USB i uruchom wydruk jeszcze raz.");
85
+ }
86
+
87
+ call.resolve(ret);
88
+ }
89
+
90
+ @PluginMethod
91
+ public void disconnectPrinter(PluginCall call) {
92
+ JSObject ret = new JSObject();
93
+ connected = false;
94
+ var result = false;
95
+
96
+ try {
97
+ result = Godex.close();
98
+ } catch (IOException e) {
99
+ Log.i("connectToUSB", e.getMessage());
100
+ }
101
+
102
+
103
+ if (result) {
104
+ ret.put("value", "Disconnected");
105
+ } else {
106
+ ret.put("value", "Disconnect fail");
107
+ }
108
+
109
+ call.resolve(ret);
110
+ }
111
+
112
+ @PluginMethod
113
+ public void getPrinterDPI(PluginCall call) {
114
+ JSObject ret = new JSObject();
115
+ Log.i("getPrinterDPI", "connect started!");
116
+ var value = Godex.getPrinterDPI();
117
+
118
+ ret.put("value", value);
119
+
120
+ call.resolve(ret);
121
+ }
122
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface GodexPrinterPlugin {\n getVersion(): Promise<{ version: string }>;\n connectToUSB(): Promise<{ value: string }>;\n printFromUSB(options: { value: string }): Promise<{ value: boolean }>;\n disconnect(): Promise<{ value: string }>;\n getPrinterDPI(): Promise<{ value: number }>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface GodexPrinterPlugin {\r\n getVersion(): Promise<{ version: string }>;\r\n connectToUSB(): Promise<{ value: string }>;\r\n printFromUSB(options: { value: string }): Promise<{ value: boolean }>;\r\n disconnect(): Promise<{ value: string }>;\r\n getPrinterDPI(): Promise<{ value: number }>;\r\n}\r\n"]}
@@ -1 +1 @@
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,cAAc,EAAE;IACtE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;CAC9D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { GodexPrinterPlugin } from './definitions';\n\nconst GodexPrinter = registerPlugin<GodexPrinterPlugin>('GodexPrinter', {\n web: () => import('./web').then(m => new m.GodexPrinterWeb()),\n});\n\nexport * from './definitions';\nexport { GodexPrinter };\n"]}
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,cAAc,EAAE;IACtE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;CAC9D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\r\n\r\nimport type { GodexPrinterPlugin } from './definitions';\r\n\r\nconst GodexPrinter = registerPlugin<GodexPrinterPlugin>('GodexPrinter', {\r\n web: () => import('./web').then(m => new m.GodexPrinterWeb()),\r\n});\r\n\r\nexport * from './definitions';\r\nexport { GodexPrinter };\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,UAAU;QACd,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,OAA0B;QAC3C,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACtB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { GodexPrinterPlugin } from './definitions';\n\nexport class GodexPrinterWeb extends WebPlugin implements GodexPrinterPlugin {\n async getVersion(): Promise<{ version: string }> {\n console.log('NOT IMPLEMENTED');\n return { version: 'NOT IMPLEMENTED' };\n }\n\n async connectToUSB(): Promise<{ value: string }> {\n console.log('NOT IMPLEMENTED');\n return { value: 'NOT IMPLEMENTED' };\n }\n\n async printFromUSB(options: { value: string }): Promise<{ value: boolean }> {\n console.log('NOT IMPLEMENTED', options.value);\n return { value: false };\n }\n\n async disconnect(): Promise<{ value: string }> {\n console.log('NOT IMPLEMENTED');\n return { value: 'NOT IMPLEMENTED' };\n }\n\n async getPrinterDPI(): Promise<{ value: number }> {\n console.log('NOT IMPLEMENTED');\n return { value: 0 };\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,UAAU;QACd,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,OAA0B;QAC3C,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACtB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\r\n\r\nimport type { GodexPrinterPlugin } from './definitions';\r\n\r\nexport class GodexPrinterWeb extends WebPlugin implements GodexPrinterPlugin {\r\n async getVersion(): Promise<{ version: string }> {\r\n console.log('NOT IMPLEMENTED');\r\n return { version: 'NOT IMPLEMENTED' };\r\n }\r\n\r\n async connectToUSB(): Promise<{ value: string }> {\r\n console.log('NOT IMPLEMENTED');\r\n return { value: 'NOT IMPLEMENTED' };\r\n }\r\n\r\n async printFromUSB(options: { value: string }): Promise<{ value: boolean }> {\r\n console.log('NOT IMPLEMENTED', options.value);\r\n return { value: false };\r\n }\r\n\r\n async disconnect(): Promise<{ value: string }> {\r\n console.log('NOT IMPLEMENTED');\r\n return { value: 'NOT IMPLEMENTED' };\r\n }\r\n\r\n async getPrinterDPI(): Promise<{ value: number }> {\r\n console.log('NOT IMPLEMENTED');\r\n return { value: 0 };\r\n }\r\n}\r\n"]}
@@ -1,8 +1,8 @@
1
- import Foundation
2
-
3
- @objc public class GodexPrinter: NSObject {
4
- @objc public func echo(_ value: String) -> String {
5
- print(value)
6
- return value
7
- }
8
- }
1
+ import Foundation
2
+
3
+ @objc public class GodexPrinter: NSObject {
4
+ @objc public func echo(_ value: String) -> String {
5
+ print(value)
6
+ return value
7
+ }
8
+ }
@@ -1,10 +1,10 @@
1
- #import <UIKit/UIKit.h>
2
-
3
- //! Project version number for Plugin.
4
- FOUNDATION_EXPORT double PluginVersionNumber;
5
-
6
- //! Project version string for Plugin.
7
- FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
-
9
- // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
-
1
+ #import <UIKit/UIKit.h>
2
+
3
+ //! Project version number for Plugin.
4
+ FOUNDATION_EXPORT double PluginVersionNumber;
5
+
6
+ //! Project version string for Plugin.
7
+ FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
+
9
+ // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
+
@@ -1,8 +1,8 @@
1
- #import <Foundation/Foundation.h>
2
- #import <Capacitor/Capacitor.h>
3
-
4
- // Define the plugin using the CAP_PLUGIN Macro, and
5
- // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
- CAP_PLUGIN(GodexPrinterPlugin, "GodexPrinter",
7
- CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
8
- )
1
+ #import <Foundation/Foundation.h>
2
+ #import <Capacitor/Capacitor.h>
3
+
4
+ // Define the plugin using the CAP_PLUGIN Macro, and
5
+ // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
+ CAP_PLUGIN(GodexPrinterPlugin, "GodexPrinter",
7
+ CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
8
+ )
@@ -1,18 +1,18 @@
1
- import Foundation
2
- import Capacitor
3
-
4
- /**
5
- * Please read the Capacitor iOS Plugin Development Guide
6
- * here: https://capacitorjs.com/docs/plugins/ios
7
- */
8
- @objc(GodexPrinterPlugin)
9
- public class GodexPrinterPlugin: CAPPlugin {
10
- private let implementation = GodexPrinter()
11
-
12
- @objc func echo(_ call: CAPPluginCall) {
13
- let value = call.getString("value") ?? ""
14
- call.resolve([
15
- "value": implementation.echo(value)
16
- ])
17
- }
18
- }
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ * Please read the Capacitor iOS Plugin Development Guide
6
+ * here: https://capacitorjs.com/docs/plugins/ios
7
+ */
8
+ @objc(GodexPrinterPlugin)
9
+ public class GodexPrinterPlugin: CAPPlugin {
10
+ private let implementation = GodexPrinter()
11
+
12
+ @objc func echo(_ call: CAPPluginCall) {
13
+ let value = call.getString("value") ?? ""
14
+ call.resolve([
15
+ "value": implementation.echo(value)
16
+ ])
17
+ }
18
+ }
@@ -1,24 +1,24 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>CFBundleDevelopmentRegion</key>
6
- <string>$(DEVELOPMENT_LANGUAGE)</string>
7
- <key>CFBundleExecutable</key>
8
- <string>$(EXECUTABLE_NAME)</string>
9
- <key>CFBundleIdentifier</key>
10
- <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
- <key>CFBundleInfoDictionaryVersion</key>
12
- <string>6.0</string>
13
- <key>CFBundleName</key>
14
- <string>$(PRODUCT_NAME)</string>
15
- <key>CFBundlePackageType</key>
16
- <string>FMWK</string>
17
- <key>CFBundleShortVersionString</key>
18
- <string>1.0</string>
19
- <key>CFBundleVersion</key>
20
- <string>$(CURRENT_PROJECT_VERSION)</string>
21
- <key>NSPrincipalClass</key>
22
- <string></string>
23
- </dict>
24
- </plist>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>$(CURRENT_PROJECT_VERSION)</string>
21
+ <key>NSPrincipalClass</key>
22
+ <string></string>
23
+ </dict>
24
+ </plist>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplymobile/capacitor-godex-printer",
3
- "version": "0.0.4",
3
+ "version": "2.0.0",
4
4
  "description": "Capacitor GoDEX printer plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -45,23 +45,23 @@
45
45
  "prepublishOnly": "npm run build"
46
46
  },
47
47
  "devDependencies": {
48
- "@capacitor/android": "^4.0.0",
49
- "@capacitor/core": "^4.0.0",
50
- "@capacitor/docgen": "^0.0.18",
51
- "@capacitor/ios": "^4.0.0",
48
+ "@capacitor/android": "^5.0.0",
49
+ "@capacitor/core": "^5.0.0",
50
+ "@capacitor/docgen": "^0.2.1",
51
+ "@capacitor/ios": "^5.0.0",
52
52
  "@ionic/eslint-config": "^0.3.0",
53
- "@ionic/prettier-config": "^1.0.1",
53
+ "@ionic/prettier-config": "^3.0.0",
54
54
  "@ionic/swiftlint-config": "^1.1.2",
55
55
  "eslint": "^7.11.0",
56
- "prettier": "~2.3.0",
57
- "prettier-plugin-java": "~1.0.2",
56
+ "prettier": "~2.8.8",
57
+ "prettier-plugin-java": "~2.1.0",
58
58
  "rimraf": "^3.0.2",
59
59
  "rollup": "^2.32.0",
60
60
  "swiftlint": "^1.0.1",
61
61
  "typescript": "~4.1.5"
62
62
  },
63
63
  "peerDependencies": {
64
- "@capacitor/core": "^4.0.0"
64
+ "@capacitor/core": "^5.0.0"
65
65
  },
66
66
  "prettier": "@ionic/prettier-config",
67
67
  "swiftlint": "@ionic/swiftlint-config",
@@ -1,55 +0,0 @@
1
- package pl.simplymobile.plugins.godexprinter;
2
-
3
- import android.content.Context;
4
- import android.util.Log;
5
-
6
- import com.godex.Godex;
7
-
8
- import java.io.IOException;
9
-
10
- public class GodexPrinter {
11
-
12
- private boolean connected = false;
13
-
14
- public void setDefaults(Context context) {
15
- Godex.debug(3);
16
- Godex.getMainContext(context);
17
- }
18
-
19
- public String getVersion() {
20
- var value = Godex.getVersion();
21
- Log.i("getVersion", value);
22
- return Godex.getVersion();
23
- }
24
-
25
- public boolean printFromUSB(String value) {
26
- Log.i("printFromUSB", "print started!");
27
- return Godex.sendCommand(value);
28
- }
29
-
30
- public boolean connectToUSB() {
31
- Log.i("connectToUSB", "connect started!");
32
-
33
- if (connected) {
34
- return true;
35
- }
36
-
37
- connected = Godex.openport(null, 3);
38
- return connected;
39
- }
40
-
41
- public int getPrinterDPI() {
42
- Log.i("getPrinterDPI", "connect started!");
43
- return Godex.getPrinterDPI();
44
- }
45
-
46
- public boolean disconnect() {
47
- connected = false;
48
- try {
49
- return Godex.close();
50
- } catch (IOException e) {
51
- Log.i("connectToUSB", e.getMessage());
52
- return false;
53
- }
54
- }
55
- }