@rdlabo/capacitor-brotherprint 2.0.0-3 → 2.0.0-4
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/android/src/main/java/jp/rdlabo/capacitor/plugin/brotherprint/BrotherPrint.java +67 -59
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/plugin.cjs.js +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/package.json +2 -1
|
@@ -6,9 +6,12 @@ import android.graphics.Bitmap;
|
|
|
6
6
|
import android.graphics.BitmapFactory;
|
|
7
7
|
import android.util.Base64;
|
|
8
8
|
import android.util.Log;
|
|
9
|
-
|
|
10
9
|
import com.brother.ptouch.sdk.BLEPrinter;
|
|
10
|
+
import com.brother.ptouch.sdk.LabelInfo;
|
|
11
11
|
import com.brother.ptouch.sdk.NetPrinter;
|
|
12
|
+
import com.brother.ptouch.sdk.Printer;
|
|
13
|
+
import com.brother.ptouch.sdk.PrinterInfo;
|
|
14
|
+
import com.brother.ptouch.sdk.PrinterInfo.Model;
|
|
12
15
|
import com.brother.ptouch.sdk.PrinterStatus;
|
|
13
16
|
import com.getcapacitor.JSArray;
|
|
14
17
|
import com.getcapacitor.JSObject;
|
|
@@ -16,18 +19,13 @@ import com.getcapacitor.NativePlugin;
|
|
|
16
19
|
import com.getcapacitor.Plugin;
|
|
17
20
|
import com.getcapacitor.PluginCall;
|
|
18
21
|
import com.getcapacitor.PluginMethod;
|
|
19
|
-
|
|
20
|
-
import com.brother.ptouch.sdk.Printer;
|
|
21
|
-
import com.brother.ptouch.sdk.PrinterInfo;
|
|
22
|
-
import com.brother.ptouch.sdk.PrinterInfo.Model;
|
|
23
|
-
import com.brother.ptouch.sdk.LabelInfo;
|
|
24
|
-
|
|
22
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
25
23
|
import java.util.List;
|
|
26
24
|
|
|
27
|
-
@
|
|
25
|
+
@CapacitorPlugin
|
|
28
26
|
public class BrotherPrint extends Plugin {
|
|
29
27
|
|
|
30
|
-
@PluginMethod
|
|
28
|
+
@PluginMethod
|
|
31
29
|
public void printImage(PluginCall call) {
|
|
32
30
|
// object.encodedImageで値を入力
|
|
33
31
|
final String encodedImage = call.getString("encodedImage");
|
|
@@ -58,17 +56,20 @@ public class BrotherPrint extends Plugin {
|
|
|
58
56
|
final String ipAddress = call.getString("ipAddress");
|
|
59
57
|
|
|
60
58
|
if (localName != null) {
|
|
59
|
+
Log.d("protocol", "localName");
|
|
61
60
|
settings.port = PrinterInfo.Port.BLUETOOTH;
|
|
62
61
|
settings.setLocalName(localName);
|
|
63
62
|
} else if (ipAddress != null) {
|
|
63
|
+
Log.d("protocol", "ipAddress");
|
|
64
64
|
settings.port = PrinterInfo.Port.NET;
|
|
65
65
|
settings.ipAddress = ipAddress;
|
|
66
66
|
} else {
|
|
67
|
+
Log.d("protocol", "USB");
|
|
67
68
|
settings.port = PrinterInfo.Port.USB;
|
|
68
69
|
}
|
|
69
70
|
break;
|
|
70
71
|
default:
|
|
71
|
-
call.
|
|
72
|
+
call.reject("[ERROR] This printerType is not available");
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -92,72 +93,79 @@ public class BrotherPrint extends Plugin {
|
|
|
92
93
|
|
|
93
94
|
try {
|
|
94
95
|
Log.d(getLogTag(), "Start Printer Thread");
|
|
95
|
-
new Thread(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
new Thread(
|
|
97
|
+
new Runnable() {
|
|
98
|
+
@Override
|
|
99
|
+
public void run() {
|
|
100
|
+
if (printer.startCommunication()) {
|
|
101
|
+
PrinterStatus result = printer.printImage(decodedByte);
|
|
102
|
+
|
|
103
|
+
if (result.errorCode == PrinterInfo.ErrorCode.ERROR_NONE) {
|
|
104
|
+
notifyListeners("onPrint", new JSObject().put("value", result));
|
|
105
|
+
} else {
|
|
106
|
+
Log.d("TAG", "ERROR - " + result.errorCode);
|
|
107
|
+
notifyListeners("onPrintError", new JSObject().put("value", result.errorCode));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
printer.endCommunication();
|
|
103
111
|
} else {
|
|
104
|
-
|
|
105
|
-
notifyListeners("onPrintError", new JSObject().put("value", result.errorCode));
|
|
112
|
+
notifyListeners("onPrintFailedCommunication", new JSObject().put("value", ""));
|
|
106
113
|
}
|
|
107
|
-
|
|
108
|
-
printer.endCommunication();
|
|
109
|
-
} else {
|
|
110
|
-
notifyListeners("onPrintFailedCommunication", new JSObject().put("value", ""));
|
|
111
114
|
}
|
|
112
115
|
}
|
|
113
|
-
|
|
114
|
-
|
|
116
|
+
)
|
|
117
|
+
.start();
|
|
118
|
+
call.resolve();
|
|
115
119
|
} catch (Exception ex) {
|
|
116
120
|
notifyListeners("onPrintFailedCommunication", new JSObject().put("value", ""));
|
|
117
|
-
call.
|
|
121
|
+
call.reject(ex.getLocalizedMessage(), ex);
|
|
118
122
|
}
|
|
119
123
|
}
|
|
120
124
|
|
|
121
|
-
@PluginMethod
|
|
125
|
+
@PluginMethod
|
|
122
126
|
public void searchWiFiPrinter(PluginCall call) {
|
|
123
|
-
new Thread(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
new Thread(
|
|
128
|
+
new Runnable() {
|
|
129
|
+
@Override
|
|
130
|
+
public void run() {
|
|
131
|
+
Printer printer = new Printer();
|
|
132
|
+
NetPrinter[] printerList = printer.getNetPrinters("QL-820NWB");
|
|
133
|
+
|
|
134
|
+
JSArray resultList = new JSArray();
|
|
135
|
+
for (NetPrinter device : printerList) {
|
|
136
|
+
Log.d("TAG", String.format("Model: %s, IP Address: %s", device.modelName, device.ipAddress));
|
|
137
|
+
resultList.put(device.ipAddress);
|
|
138
|
+
}
|
|
139
|
+
notifyListeners("onIpAddressAvailable", new JSObject().put("ipAddressList", resultList));
|
|
133
140
|
}
|
|
134
|
-
notifyListeners("onIpAddressAvailable", new JSObject().put("ipAddressList", resultList));
|
|
135
141
|
}
|
|
136
|
-
|
|
137
|
-
|
|
142
|
+
)
|
|
143
|
+
.start();
|
|
144
|
+
call.resolve();
|
|
138
145
|
}
|
|
139
146
|
|
|
140
|
-
@PluginMethod
|
|
147
|
+
@PluginMethod
|
|
141
148
|
public void searchBLEPrinter(PluginCall call) {
|
|
142
|
-
new Thread(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
new Thread(
|
|
150
|
+
new Runnable() {
|
|
151
|
+
@Override
|
|
152
|
+
public void run() {
|
|
153
|
+
Printer printer = new Printer();
|
|
154
|
+
List<BLEPrinter> printerList = printer.getBLEPrinters(BluetoothAdapter.getDefaultAdapter(), 30);
|
|
155
|
+
|
|
156
|
+
JSArray resultList = new JSArray();
|
|
157
|
+
for (BLEPrinter device : printerList) {
|
|
158
|
+
resultList.put(device.localName);
|
|
159
|
+
}
|
|
152
160
|
|
|
153
|
-
|
|
161
|
+
notifyListeners("onBLEAvailable", new JSObject().put("localNameList", resultList));
|
|
162
|
+
}
|
|
154
163
|
}
|
|
155
|
-
|
|
156
|
-
|
|
164
|
+
)
|
|
165
|
+
.start();
|
|
166
|
+
call.resolve();
|
|
157
167
|
}
|
|
158
168
|
|
|
159
|
-
@PluginMethod
|
|
160
|
-
public void stopSearchBLEPrinter(PluginCall call) {
|
|
161
|
-
|
|
162
|
-
}
|
|
169
|
+
@PluginMethod
|
|
170
|
+
public void stopSearchBLEPrinter(PluginCall call) {}
|
|
163
171
|
}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -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,
|
|
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,cAAc,OAAO,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { BrotherPrintPlugin } from './definitions';\n\nconst BrotherPrint = registerPlugin<BrotherPrintPlugin>('BrotherPrint', {\n web: () => import('./web').then(m => new m.BrotherPrintWeb()),\n});\n\nexport * from './definitions';\nexport * from './web';\nexport { BrotherPrint };\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -34,7 +34,7 @@ var web = /*#__PURE__*/Object.freeze({
|
|
|
34
34
|
BrotherPrintWeb: BrotherPrintWeb
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
const BrotherPrint = core.registerPlugin('
|
|
37
|
+
const BrotherPrint = core.registerPlugin('BrotherPrint', {
|
|
38
38
|
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.BrotherPrintWeb()),
|
|
39
39
|
});
|
|
40
40
|
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/web.js","esm/index.js"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\nexport class BrotherPrintWeb extends WebPlugin {\n constructor() {\n super({\n name: 'BrotherPrint',\n platforms: ['web'],\n });\n }\n /**\n * Print with Base64\n */\n async printImage(_options) {\n return {\n value: true,\n };\n }\n /**\n * Search Wifi Printer\n */\n async searchWiFiPrinter() { }\n /**\n * search Bluetooth Printer\n */\n async searchBLEPrinter() { }\n}\n//# sourceMappingURL=web.js.map","import { registerPlugin } from '@capacitor/core';\nconst BrotherPrint = registerPlugin('
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/web.js","esm/index.js"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\nexport class BrotherPrintWeb extends WebPlugin {\n constructor() {\n super({\n name: 'BrotherPrint',\n platforms: ['web'],\n });\n }\n /**\n * Print with Base64\n */\n async printImage(_options) {\n return {\n value: true,\n };\n }\n /**\n * Search Wifi Printer\n */\n async searchWiFiPrinter() { }\n /**\n * search Bluetooth Printer\n */\n async searchBLEPrinter() { }\n}\n//# sourceMappingURL=web.js.map","import { registerPlugin } from '@capacitor/core';\nconst BrotherPrint = registerPlugin('BrotherPrint', {\n web: () => import('./web').then(m => new m.BrotherPrintWeb()),\n});\nexport * from './definitions';\nexport * from './web';\nexport { BrotherPrint };\n//# sourceMappingURL=index.js.map"],"names":["WebPlugin","registerPlugin"],"mappings":";;;;;;AACO,MAAM,eAAe,SAASA,cAAS,CAAC;AAC/C,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,CAAC;AACd,YAAY,IAAI,EAAE,cAAc;AAChC,YAAY,SAAS,EAAE,CAAC,KAAK,CAAC;AAC9B,SAAS,CAAC,CAAC;AACX,KAAK;AACL;AACA;AACA;AACA,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,OAAO;AACf,YAAY,KAAK,EAAE,IAAI;AACvB,SAAS,CAAC;AACV,KAAK;AACL;AACA;AACA;AACA,IAAI,MAAM,iBAAiB,GAAG,GAAG;AACjC;AACA;AACA;AACA,IAAI,MAAM,gBAAgB,GAAG,GAAG;AAChC;;;;;;;ACvBK,MAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACjE,CAAC;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -31,7 +31,7 @@ var BrotherPrint = (function (exports, core) {
|
|
|
31
31
|
BrotherPrintWeb: BrotherPrintWeb
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
const BrotherPrint = core.registerPlugin('
|
|
34
|
+
const BrotherPrint = core.registerPlugin('BrotherPrint', {
|
|
35
35
|
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.BrotherPrintWeb()),
|
|
36
36
|
});
|
|
37
37
|
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/web.js","esm/index.js"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\nexport class BrotherPrintWeb extends WebPlugin {\n constructor() {\n super({\n name: 'BrotherPrint',\n platforms: ['web'],\n });\n }\n /**\n * Print with Base64\n */\n async printImage(_options) {\n return {\n value: true,\n };\n }\n /**\n * Search Wifi Printer\n */\n async searchWiFiPrinter() { }\n /**\n * search Bluetooth Printer\n */\n async searchBLEPrinter() { }\n}\n//# sourceMappingURL=web.js.map","import { registerPlugin } from '@capacitor/core';\nconst BrotherPrint = registerPlugin('
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/web.js","esm/index.js"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\nexport class BrotherPrintWeb extends WebPlugin {\n constructor() {\n super({\n name: 'BrotherPrint',\n platforms: ['web'],\n });\n }\n /**\n * Print with Base64\n */\n async printImage(_options) {\n return {\n value: true,\n };\n }\n /**\n * Search Wifi Printer\n */\n async searchWiFiPrinter() { }\n /**\n * search Bluetooth Printer\n */\n async searchBLEPrinter() { }\n}\n//# sourceMappingURL=web.js.map","import { registerPlugin } from '@capacitor/core';\nconst BrotherPrint = registerPlugin('BrotherPrint', {\n web: () => import('./web').then(m => new m.BrotherPrintWeb()),\n});\nexport * from './definitions';\nexport * from './web';\nexport { BrotherPrint };\n//# sourceMappingURL=index.js.map"],"names":["WebPlugin","registerPlugin"],"mappings":";;;IACO,MAAM,eAAe,SAASA,cAAS,CAAC;IAC/C,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,CAAC;IACd,YAAY,IAAI,EAAE,cAAc;IAChC,YAAY,SAAS,EAAE,CAAC,KAAK,CAAC;IAC9B,SAAS,CAAC,CAAC;IACX,KAAK;IACL;IACA;IACA;IACA,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,QAAQ,OAAO;IACf,YAAY,KAAK,EAAE,IAAI;IACvB,SAAS,CAAC;IACV,KAAK;IACL;IACA;IACA;IACA,IAAI,MAAM,iBAAiB,GAAG,GAAG;IACjC;IACA;IACA;IACA,IAAI,MAAM,gBAAgB,GAAG,GAAG;IAChC;;;;;;;ACvBK,UAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjE,CAAC;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rdlabo/capacitor-brotherprint",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-4",
|
|
4
4
|
"description": "Capacitor plugin for Brother Print SDK",
|
|
5
5
|
"main": "dist/plugin.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"clean": "rimraf ./dist",
|
|
21
21
|
"watch": "tsc --watch",
|
|
22
22
|
"prepublishOnly": "npm run build",
|
|
23
|
+
"release": "np --no-tests",
|
|
23
24
|
"npm-publish": "np --no-tests"
|
|
24
25
|
},
|
|
25
26
|
"author": "Masahiko Sakakibara<sakakibara@rdlabo.jp>",
|