@centimoo/capacitor-tcp-printer 1.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.
@@ -0,0 +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 = 'CentimooCapacitorTcpPrinter'
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/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '15.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
package/Package.swift ADDED
@@ -0,0 +1,28 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "CentimooCapacitorTcpPrinter",
6
+ platforms: [.iOS(.v15)],
7
+ products: [
8
+ .library(
9
+ name: "CentimooCapacitorTcpPrinter",
10
+ targets: ["TcpPrinterPlugin"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
14
+ ],
15
+ targets: [
16
+ .target(
17
+ name: "TcpPrinterPlugin",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm")
21
+ ],
22
+ path: "ios/Sources/TcpPrinterPlugin"),
23
+ .testTarget(
24
+ name: "TcpPrinterPluginTests",
25
+ dependencies: ["TcpPrinterPlugin"],
26
+ path: "ios/Tests/TcpPrinterPluginTests")
27
+ ]
28
+ )
package/README.md ADDED
@@ -0,0 +1,181 @@
1
+ # @centimoo/capacitor-tcp-printer
2
+
3
+ Native TCP printer plugin for Capacitor using Apple Network.framework. Enables raw socket printing (ESC/POS) to LAN printers on iOS.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @centimoo/capacitor-tcp-printer
9
+ npx cap sync
10
+ ```
11
+
12
+ ## API
13
+
14
+ <docgen-index>
15
+
16
+ * [`connect(...)`](#connect)
17
+ * [`send(...)`](#send)
18
+ * [`read(...)`](#read)
19
+ * [`disconnect(...)`](#disconnect)
20
+ * [Interfaces](#interfaces)
21
+ * [Enums](#enums)
22
+
23
+ </docgen-index>
24
+
25
+ <docgen-api>
26
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
27
+
28
+ TCP Socket Plugin interface for Capacitor
29
+ Provides methods for TCP socket communication
30
+
31
+ ### connect(...)
32
+
33
+ ```typescript
34
+ connect(options: ConnectOptions) => Promise<ConnectResult>
35
+ ```
36
+
37
+ Connects to a TCP server
38
+
39
+ | Param | Type | Description |
40
+ | ------------- | --------------------------------------------------------- | ------------------------------------------------ |
41
+ | **`options`** | <code><a href="#connectoptions">ConnectOptions</a></code> | Connection options including IP address and port |
42
+
43
+ **Returns:** <code>Promise&lt;<a href="#connectresult">ConnectResult</a>&gt;</code>
44
+
45
+ --------------------
46
+
47
+
48
+ ### send(...)
49
+
50
+ ```typescript
51
+ send(options: SendOptions) => Promise<void>
52
+ ```
53
+
54
+ Sends data to a connected TCP server
55
+
56
+ | Param | Type | Description |
57
+ | ------------- | --------------------------------------------------- | --------------------------------------------------- |
58
+ | **`options`** | <code><a href="#sendoptions">SendOptions</a></code> | Send options including client ID, data and encoding |
59
+
60
+ --------------------
61
+
62
+
63
+ ### read(...)
64
+
65
+ ```typescript
66
+ read(options: ReadOptions) => Promise<ReadResult>
67
+ ```
68
+
69
+ Reads data from a connected TCP server
70
+
71
+ | Param | Type | Description |
72
+ | ------------- | --------------------------------------------------- | ------------------------------------------------------------- |
73
+ | **`options`** | <code><a href="#readoptions">ReadOptions</a></code> | Read options including client ID, expected length and timeout |
74
+
75
+ **Returns:** <code>Promise&lt;<a href="#readresult">ReadResult</a>&gt;</code>
76
+
77
+ --------------------
78
+
79
+
80
+ ### disconnect(...)
81
+
82
+ ```typescript
83
+ disconnect(options: DisconnectOptions) => Promise<DisconnectResult>
84
+ ```
85
+
86
+ Disconnects from a TCP server
87
+
88
+ | Param | Type | Description |
89
+ | ------------- | --------------------------------------------------------------- | --------------------------------- |
90
+ | **`options`** | <code><a href="#disconnectoptions">DisconnectOptions</a></code> | Disconnect options with client ID |
91
+
92
+ **Returns:** <code>Promise&lt;<a href="#disconnectresult">DisconnectResult</a>&gt;</code>
93
+
94
+ --------------------
95
+
96
+
97
+ ### Interfaces
98
+
99
+
100
+ #### ConnectResult
101
+
102
+ Result of a successful connection
103
+
104
+ | Prop | Type | Description |
105
+ | ------------ | ------------------- | ---------------------------------------------------- |
106
+ | **`client`** | <code>number</code> | Client ID that can be used for subsequent operations |
107
+
108
+
109
+ #### ConnectOptions
110
+
111
+ Options for connecting to a TCP server
112
+
113
+ | Prop | Type | Description | Default |
114
+ | --------------- | ------------------- | -------------------------------------- | ----------------- |
115
+ | **`ipAddress`** | <code>string</code> | IP address of the server to connect to | |
116
+ | **`port`** | <code>number</code> | Port number of the TCP server | <code>9100</code> |
117
+
118
+
119
+ #### SendOptions
120
+
121
+ Options for sending data to a TCP server
122
+
123
+ | Prop | Type | Description | Default |
124
+ | -------------- | ----------------------------------------------------- | -------------------------------------- | ------------------------------ |
125
+ | **`client`** | <code>number</code> | Client ID from a previous connect call | |
126
+ | **`data`** | <code>number[]</code> | Data string to send to the server | |
127
+ | **`encoding`** | <code><a href="#dataencoding">DataEncoding</a></code> | Encoding type for the data | <code>DataEncoding.UTF8</code> |
128
+
129
+
130
+ #### ReadResult
131
+
132
+ Result of a read operation
133
+
134
+ | Prop | Type | Description |
135
+ | -------------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
136
+ | **`result`** | <code>string</code> | Data read from the server Can be UTF-8 string, Base64 encoded string, or Hex string depending on the encoding option |
137
+ | **`encoding`** | <code><a href="#dataencoding">DataEncoding</a></code> | The encoding of the returned result |
138
+
139
+
140
+ #### ReadOptions
141
+
142
+ Options for reading data from a TCP server
143
+
144
+ | Prop | Type | Description | Default |
145
+ | --------------- | ----------------------------------------------------- | -------------------------------------- | ------------------------------ |
146
+ | **`client`** | <code>number</code> | Client ID from a previous connect call | |
147
+ | **`expectLen`** | <code>number</code> | Expected number of bytes to read | |
148
+ | **`timeout`** | <code>number</code> | Read timeout in seconds | <code>10</code> |
149
+ | **`encoding`** | <code><a href="#dataencoding">DataEncoding</a></code> | Preferred encoding for returned data | <code>DataEncoding.UTF8</code> |
150
+
151
+
152
+ #### DisconnectResult
153
+
154
+ Result of a disconnect operation
155
+
156
+ | Prop | Type | Description |
157
+ | ------------ | ------------------- | ------------------------------- |
158
+ | **`client`** | <code>number</code> | Client ID that was disconnected |
159
+
160
+
161
+ #### DisconnectOptions
162
+
163
+ Options for disconnecting from a TCP server
164
+
165
+ | Prop | Type | Description |
166
+ | ------------ | ------------------- | -------------------------------------- |
167
+ | **`client`** | <code>number</code> | Client ID from a previous connect call |
168
+
169
+
170
+ ### Enums
171
+
172
+
173
+ #### DataEncoding
174
+
175
+ | Members | Value | Description |
176
+ | ------------ | --------------------- | ------------------- |
177
+ | **`UTF8`** | <code>'utf8'</code> | UTF-8 text encoding |
178
+ | **`BASE64`** | <code>'base64'</code> | Base64 encoded data |
179
+ | **`HEX`** | <code>'hex'</code> | Hexadecimal string |
180
+
181
+ </docgen-api>
package/dist/docs.json ADDED
@@ -0,0 +1,343 @@
1
+ {
2
+ "api": {
3
+ "name": "TcpPrinterPlugin",
4
+ "slug": "tcpprinterplugin",
5
+ "docs": "TCP Socket Plugin interface for Capacitor\nProvides methods for TCP socket communication",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "connect",
10
+ "signature": "(options: ConnectOptions) => Promise<ConnectResult>",
11
+ "parameters": [
12
+ {
13
+ "name": "options",
14
+ "docs": "Connection options including IP address and port",
15
+ "type": "ConnectOptions"
16
+ }
17
+ ],
18
+ "returns": "Promise<ConnectResult>",
19
+ "tags": [
20
+ {
21
+ "name": "param",
22
+ "text": "options Connection options including IP address and port"
23
+ },
24
+ {
25
+ "name": "returns",
26
+ "text": "Promise with the client identifier"
27
+ }
28
+ ],
29
+ "docs": "Connects to a TCP server",
30
+ "complexTypes": [
31
+ "ConnectResult",
32
+ "ConnectOptions"
33
+ ],
34
+ "slug": "connect"
35
+ },
36
+ {
37
+ "name": "send",
38
+ "signature": "(options: SendOptions) => Promise<void>",
39
+ "parameters": [
40
+ {
41
+ "name": "options",
42
+ "docs": "Send options including client ID, data and encoding",
43
+ "type": "SendOptions"
44
+ }
45
+ ],
46
+ "returns": "Promise<void>",
47
+ "tags": [
48
+ {
49
+ "name": "param",
50
+ "text": "options Send options including client ID, data and encoding"
51
+ },
52
+ {
53
+ "name": "returns",
54
+ "text": "Promise that resolves when data is sent"
55
+ }
56
+ ],
57
+ "docs": "Sends data to a connected TCP server",
58
+ "complexTypes": [
59
+ "SendOptions"
60
+ ],
61
+ "slug": "send"
62
+ },
63
+ {
64
+ "name": "read",
65
+ "signature": "(options: ReadOptions) => Promise<ReadResult>",
66
+ "parameters": [
67
+ {
68
+ "name": "options",
69
+ "docs": "Read options including client ID, expected length and timeout",
70
+ "type": "ReadOptions"
71
+ }
72
+ ],
73
+ "returns": "Promise<ReadResult>",
74
+ "tags": [
75
+ {
76
+ "name": "param",
77
+ "text": "options Read options including client ID, expected length and timeout"
78
+ },
79
+ {
80
+ "name": "returns",
81
+ "text": "Promise with the data read from the server"
82
+ }
83
+ ],
84
+ "docs": "Reads data from a connected TCP server",
85
+ "complexTypes": [
86
+ "ReadResult",
87
+ "ReadOptions"
88
+ ],
89
+ "slug": "read"
90
+ },
91
+ {
92
+ "name": "disconnect",
93
+ "signature": "(options: DisconnectOptions) => Promise<DisconnectResult>",
94
+ "parameters": [
95
+ {
96
+ "name": "options",
97
+ "docs": "Disconnect options with client ID",
98
+ "type": "DisconnectOptions"
99
+ }
100
+ ],
101
+ "returns": "Promise<DisconnectResult>",
102
+ "tags": [
103
+ {
104
+ "name": "param",
105
+ "text": "options Disconnect options with client ID"
106
+ },
107
+ {
108
+ "name": "returns",
109
+ "text": "Promise with the disconnected client ID"
110
+ }
111
+ ],
112
+ "docs": "Disconnects from a TCP server",
113
+ "complexTypes": [
114
+ "DisconnectResult",
115
+ "DisconnectOptions"
116
+ ],
117
+ "slug": "disconnect"
118
+ }
119
+ ],
120
+ "properties": []
121
+ },
122
+ "interfaces": [
123
+ {
124
+ "name": "ConnectResult",
125
+ "slug": "connectresult",
126
+ "docs": "Result of a successful connection",
127
+ "tags": [],
128
+ "methods": [],
129
+ "properties": [
130
+ {
131
+ "name": "client",
132
+ "tags": [],
133
+ "docs": "Client ID that can be used for subsequent operations",
134
+ "complexTypes": [],
135
+ "type": "number"
136
+ }
137
+ ]
138
+ },
139
+ {
140
+ "name": "ConnectOptions",
141
+ "slug": "connectoptions",
142
+ "docs": "Options for connecting to a TCP server",
143
+ "tags": [],
144
+ "methods": [],
145
+ "properties": [
146
+ {
147
+ "name": "ipAddress",
148
+ "tags": [],
149
+ "docs": "IP address of the server to connect to",
150
+ "complexTypes": [],
151
+ "type": "string"
152
+ },
153
+ {
154
+ "name": "port",
155
+ "tags": [
156
+ {
157
+ "text": "9100",
158
+ "name": "default"
159
+ }
160
+ ],
161
+ "docs": "Port number of the TCP server",
162
+ "complexTypes": [],
163
+ "type": "number | undefined"
164
+ }
165
+ ]
166
+ },
167
+ {
168
+ "name": "SendOptions",
169
+ "slug": "sendoptions",
170
+ "docs": "Options for sending data to a TCP server",
171
+ "tags": [],
172
+ "methods": [],
173
+ "properties": [
174
+ {
175
+ "name": "client",
176
+ "tags": [],
177
+ "docs": "Client ID from a previous connect call",
178
+ "complexTypes": [],
179
+ "type": "number"
180
+ },
181
+ {
182
+ "name": "data",
183
+ "tags": [],
184
+ "docs": "Data string to send to the server",
185
+ "complexTypes": [],
186
+ "type": "number[]"
187
+ },
188
+ {
189
+ "name": "encoding",
190
+ "tags": [
191
+ {
192
+ "text": "DataEncoding.UTF8",
193
+ "name": "default"
194
+ }
195
+ ],
196
+ "docs": "Encoding type for the data",
197
+ "complexTypes": [
198
+ "DataEncoding"
199
+ ],
200
+ "type": "DataEncoding"
201
+ }
202
+ ]
203
+ },
204
+ {
205
+ "name": "ReadResult",
206
+ "slug": "readresult",
207
+ "docs": "Result of a read operation",
208
+ "tags": [],
209
+ "methods": [],
210
+ "properties": [
211
+ {
212
+ "name": "result",
213
+ "tags": [],
214
+ "docs": "Data read from the server\nCan be UTF-8 string, Base64 encoded string, or Hex string depending on the encoding option",
215
+ "complexTypes": [],
216
+ "type": "string | undefined"
217
+ },
218
+ {
219
+ "name": "encoding",
220
+ "tags": [],
221
+ "docs": "The encoding of the returned result",
222
+ "complexTypes": [
223
+ "DataEncoding"
224
+ ],
225
+ "type": "DataEncoding"
226
+ }
227
+ ]
228
+ },
229
+ {
230
+ "name": "ReadOptions",
231
+ "slug": "readoptions",
232
+ "docs": "Options for reading data from a TCP server",
233
+ "tags": [],
234
+ "methods": [],
235
+ "properties": [
236
+ {
237
+ "name": "client",
238
+ "tags": [],
239
+ "docs": "Client ID from a previous connect call",
240
+ "complexTypes": [],
241
+ "type": "number"
242
+ },
243
+ {
244
+ "name": "expectLen",
245
+ "tags": [],
246
+ "docs": "Expected number of bytes to read",
247
+ "complexTypes": [],
248
+ "type": "number"
249
+ },
250
+ {
251
+ "name": "timeout",
252
+ "tags": [
253
+ {
254
+ "text": "10",
255
+ "name": "default"
256
+ },
257
+ {
258
+ "text": "Only available on iOS platform",
259
+ "name": "note"
260
+ }
261
+ ],
262
+ "docs": "Read timeout in seconds",
263
+ "complexTypes": [],
264
+ "type": "number | undefined"
265
+ },
266
+ {
267
+ "name": "encoding",
268
+ "tags": [
269
+ {
270
+ "text": "DataEncoding.UTF8",
271
+ "name": "default"
272
+ }
273
+ ],
274
+ "docs": "Preferred encoding for returned data",
275
+ "complexTypes": [
276
+ "DataEncoding"
277
+ ],
278
+ "type": "DataEncoding"
279
+ }
280
+ ]
281
+ },
282
+ {
283
+ "name": "DisconnectResult",
284
+ "slug": "disconnectresult",
285
+ "docs": "Result of a disconnect operation",
286
+ "tags": [],
287
+ "methods": [],
288
+ "properties": [
289
+ {
290
+ "name": "client",
291
+ "tags": [],
292
+ "docs": "Client ID that was disconnected",
293
+ "complexTypes": [],
294
+ "type": "number"
295
+ }
296
+ ]
297
+ },
298
+ {
299
+ "name": "DisconnectOptions",
300
+ "slug": "disconnectoptions",
301
+ "docs": "Options for disconnecting from a TCP server",
302
+ "tags": [],
303
+ "methods": [],
304
+ "properties": [
305
+ {
306
+ "name": "client",
307
+ "tags": [],
308
+ "docs": "Client ID from a previous connect call",
309
+ "complexTypes": [],
310
+ "type": "number"
311
+ }
312
+ ]
313
+ }
314
+ ],
315
+ "enums": [
316
+ {
317
+ "name": "DataEncoding",
318
+ "slug": "dataencoding",
319
+ "members": [
320
+ {
321
+ "name": "UTF8",
322
+ "value": "'utf8'",
323
+ "tags": [],
324
+ "docs": "UTF-8 text encoding"
325
+ },
326
+ {
327
+ "name": "BASE64",
328
+ "value": "'base64'",
329
+ "tags": [],
330
+ "docs": "Base64 encoded data"
331
+ },
332
+ {
333
+ "name": "HEX",
334
+ "value": "'hex'",
335
+ "tags": [],
336
+ "docs": "Hexadecimal string"
337
+ }
338
+ ]
339
+ }
340
+ ],
341
+ "typeAliases": [],
342
+ "pluginConfigs": []
343
+ }