@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,144 @@
1
+ /**
2
+ * TCP Socket Plugin interface for Capacitor
3
+ * Provides methods for TCP socket communication
4
+ */
5
+ export interface TcpPrinterPlugin {
6
+ /**
7
+ * Connects to a TCP server
8
+ * @param options Connection options including IP address and port
9
+ * @returns Promise with the client identifier
10
+ */
11
+ connect(options: ConnectOptions): Promise<ConnectResult>;
12
+ /**
13
+ * Sends data to a connected TCP server
14
+ * @param options Send options including client ID, data and encoding
15
+ * @returns Promise that resolves when data is sent
16
+ */
17
+ send(options: SendOptions): Promise<void>;
18
+ /**
19
+ * Reads data from a connected TCP server
20
+ * @param options Read options including client ID, expected length and timeout
21
+ * @returns Promise with the data read from the server
22
+ */
23
+ read(options: ReadOptions): Promise<ReadResult>;
24
+ /**
25
+ * Disconnects from a TCP server
26
+ * @param options Disconnect options with client ID
27
+ * @returns Promise with the disconnected client ID
28
+ */
29
+ disconnect(options: DisconnectOptions): Promise<DisconnectResult>;
30
+ }
31
+ /**
32
+ * Options for connecting to a TCP server
33
+ */
34
+ export interface ConnectOptions {
35
+ /**
36
+ * IP address of the server to connect to
37
+ */
38
+ ipAddress: string;
39
+ /**
40
+ * Port number of the TCP server
41
+ * @default 9100
42
+ */
43
+ port?: number;
44
+ }
45
+ /**
46
+ * Result of a successful connection
47
+ */
48
+ export interface ConnectResult {
49
+ /**
50
+ * Client ID that can be used for subsequent operations
51
+ */
52
+ client: number;
53
+ }
54
+ /**
55
+ * Supported encoding types for data
56
+ */
57
+ export declare enum DataEncoding {
58
+ /**
59
+ * UTF-8 text encoding
60
+ */
61
+ UTF8 = "utf8",
62
+ /**
63
+ * Base64 encoded data
64
+ */
65
+ BASE64 = "base64",
66
+ /**
67
+ * Hexadecimal string
68
+ */
69
+ HEX = "hex"
70
+ }
71
+ /**
72
+ * Options for sending data to a TCP server
73
+ */
74
+ export interface SendOptions {
75
+ /**
76
+ * Client ID from a previous connect call
77
+ */
78
+ client: number;
79
+ /**
80
+ * Data string to send to the server
81
+ */
82
+ data: number[];
83
+ /**
84
+ * Encoding type for the data
85
+ * @default DataEncoding.UTF8
86
+ */
87
+ encoding?: DataEncoding;
88
+ }
89
+ /**
90
+ * Options for reading data from a TCP server
91
+ */
92
+ export interface ReadOptions {
93
+ /**
94
+ * Client ID from a previous connect call
95
+ */
96
+ client: number;
97
+ /**
98
+ * Expected number of bytes to read
99
+ */
100
+ expectLen: number;
101
+ /**
102
+ * Read timeout in seconds
103
+ * @default 10
104
+ * @note Only available on iOS platform
105
+ */
106
+ timeout?: number;
107
+ /**
108
+ * Preferred encoding for returned data
109
+ * @default DataEncoding.UTF8
110
+ */
111
+ encoding?: DataEncoding;
112
+ }
113
+ /**
114
+ * Result of a read operation
115
+ */
116
+ export interface ReadResult {
117
+ /**
118
+ * Data read from the server
119
+ * Can be UTF-8 string, Base64 encoded string, or Hex string depending on the encoding option
120
+ */
121
+ result?: string;
122
+ /**
123
+ * The encoding of the returned result
124
+ */
125
+ encoding?: DataEncoding;
126
+ }
127
+ /**
128
+ * Options for disconnecting from a TCP server
129
+ */
130
+ export interface DisconnectOptions {
131
+ /**
132
+ * Client ID from a previous connect call
133
+ */
134
+ client: number;
135
+ }
136
+ /**
137
+ * Result of a disconnect operation
138
+ */
139
+ export interface DisconnectResult {
140
+ /**
141
+ * Client ID that was disconnected
142
+ */
143
+ client: number;
144
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Supported encoding types for data
3
+ */
4
+ export var DataEncoding;
5
+ (function (DataEncoding) {
6
+ /**
7
+ * UTF-8 text encoding
8
+ */
9
+ DataEncoding["UTF8"] = "utf8";
10
+ /**
11
+ * Base64 encoded data
12
+ */
13
+ DataEncoding["BASE64"] = "base64";
14
+ /**
15
+ * Hexadecimal string
16
+ */
17
+ DataEncoding["HEX"] = "hex";
18
+ })(DataEncoding || (DataEncoding = {}));
19
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA8DA;;GAEG;AACH,MAAM,CAAN,IAAY,YAeX;AAfD,WAAY,YAAY;IACtB;;OAEG;IACH,6BAAa,CAAA;IAEb;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,2BAAW,CAAA;AACb,CAAC,EAfW,YAAY,KAAZ,YAAY,QAevB","sourcesContent":["/**\n * TCP Socket Plugin interface for Capacitor\n * Provides methods for TCP socket communication\n */\nexport interface TcpPrinterPlugin {\n /**\n * Connects to a TCP server\n * @param options Connection options including IP address and port\n * @returns Promise with the client identifier\n */\n connect(options: ConnectOptions): Promise<ConnectResult>;\n\n /**\n * Sends data to a connected TCP server\n * @param options Send options including client ID, data and encoding\n * @returns Promise that resolves when data is sent\n */\n send(options: SendOptions): Promise<void>;\n\n /**\n * Reads data from a connected TCP server\n * @param options Read options including client ID, expected length and timeout\n * @returns Promise with the data read from the server\n */\n read(options: ReadOptions): Promise<ReadResult>;\n\n /**\n * Disconnects from a TCP server\n * @param options Disconnect options with client ID\n * @returns Promise with the disconnected client ID\n */\n disconnect(options: DisconnectOptions): Promise<DisconnectResult>;\n}\n\n// Connection Options\n\n/**\n * Options for connecting to a TCP server\n */\nexport interface ConnectOptions {\n /**\n * IP address of the server to connect to\n */\n ipAddress: string;\n\n /**\n * Port number of the TCP server\n * @default 9100\n */\n port?: number;\n}\n\n/**\n * Result of a successful connection\n */\nexport interface ConnectResult {\n /**\n * Client ID that can be used for subsequent operations\n */\n client: number;\n}\n\n/**\n * Supported encoding types for data\n */\nexport enum DataEncoding {\n /**\n * UTF-8 text encoding\n */\n UTF8 = 'utf8',\n\n /**\n * Base64 encoded data\n */\n BASE64 = 'base64',\n\n /**\n * Hexadecimal string\n */\n HEX = 'hex',\n}\n\n/**\n * Options for sending data to a TCP server\n */\nexport interface SendOptions {\n /**\n * Client ID from a previous connect call\n */\n client: number;\n\n /**\n * Data string to send to the server\n */\n data: number[];\n\n /**\n * Encoding type for the data\n * @default DataEncoding.UTF8\n */\n encoding?: DataEncoding;\n}\n\n/**\n * Options for reading data from a TCP server\n */\nexport interface ReadOptions {\n /**\n * Client ID from a previous connect call\n */\n client: number;\n\n /**\n * Expected number of bytes to read\n */\n expectLen: number;\n\n /**\n * Read timeout in seconds\n * @default 10\n * @note Only available on iOS platform\n */\n timeout?: number;\n\n /**\n * Preferred encoding for returned data\n * @default DataEncoding.UTF8\n */\n encoding?: DataEncoding;\n}\n\n/**\n * Result of a read operation\n */\nexport interface ReadResult {\n /**\n * Data read from the server\n * Can be UTF-8 string, Base64 encoded string, or Hex string depending on the encoding option\n */\n result?: string;\n\n /**\n * The encoding of the returned result\n */\n encoding?: DataEncoding;\n}\n\n/**\n * Options for disconnecting from a TCP server\n */\nexport interface DisconnectOptions {\n /**\n * Client ID from a previous connect call\n */\n client: number;\n}\n\n/**\n * Result of a disconnect operation\n */\nexport interface DisconnectResult {\n /**\n * Client ID that was disconnected\n */\n client: number;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { TcpPrinterPlugin } from './definitions';
2
+ declare const TcpPrinter: TcpPrinterPlugin;
3
+ export * from './definitions';
4
+ export { TcpPrinter };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const TcpPrinter = registerPlugin('TcpPrinter', {
3
+ web: () => import('./web').then((m) => new m.TcpPrinterWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { TcpPrinter };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,UAAU,GAAG,cAAc,CAAmB,YAAY,EAAE;IAChE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;CAC9D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { TcpPrinterPlugin } from './definitions';\n\nconst TcpPrinter = registerPlugin<TcpPrinterPlugin>('TcpPrinter', {\n web: () => import('./web').then((m) => new m.TcpPrinterWeb()),\n});\n\nexport * from './definitions';\nexport { TcpPrinter };\n"]}
@@ -0,0 +1,27 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { ConnectOptions, ConnectResult, DisconnectOptions, DisconnectResult, ReadOptions, ReadResult, SendOptions, TcpPrinterPlugin } from './definitions';
3
+ /**
4
+ * Web implementation of the TcpPrinter plugin.
5
+ *
6
+ * Note: Direct TCP connections are not supported in web browsers due to security restrictions.
7
+ * Consider using WebSockets as an alternative for web applications.
8
+ */
9
+ export declare class TcpPrinterWeb extends WebPlugin implements TcpPrinterPlugin {
10
+ private readonly ERROR_MESSAGE;
11
+ /**
12
+ * Cannot connect directly via TCP from a browser.
13
+ */
14
+ connect(options: ConnectOptions): Promise<ConnectResult>;
15
+ /**
16
+ * Cannot send data via TCP from a browser.
17
+ */
18
+ send(options: SendOptions): Promise<void>;
19
+ /**
20
+ * Cannot read data via TCP from a browser.
21
+ */
22
+ read(options: ReadOptions): Promise<ReadResult>;
23
+ /**
24
+ * Cannot disconnect TCP socket from a browser.
25
+ */
26
+ disconnect(options: DisconnectOptions): Promise<DisconnectResult>;
27
+ }
@@ -0,0 +1,42 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ /**
3
+ * Web implementation of the TcpPrinter plugin.
4
+ *
5
+ * Note: Direct TCP connections are not supported in web browsers due to security restrictions.
6
+ * Consider using WebSockets as an alternative for web applications.
7
+ */
8
+ export class TcpPrinterWeb extends WebPlugin {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.ERROR_MESSAGE = 'TCP sockets are not supported in web browsers.';
12
+ }
13
+ /**
14
+ * Cannot connect directly via TCP from a browser.
15
+ */
16
+ connect(options) {
17
+ console.log('TCP connection attempted in web context:', options);
18
+ return Promise.reject(new Error(this.ERROR_MESSAGE));
19
+ }
20
+ /**
21
+ * Cannot send data via TCP from a browser.
22
+ */
23
+ send(options) {
24
+ console.log('TCP send attempted in web context:', options);
25
+ return Promise.reject(new Error(this.ERROR_MESSAGE));
26
+ }
27
+ /**
28
+ * Cannot read data via TCP from a browser.
29
+ */
30
+ read(options) {
31
+ console.log('TCP read attempted in web context:', options);
32
+ return Promise.reject(new Error(this.ERROR_MESSAGE));
33
+ }
34
+ /**
35
+ * Cannot disconnect TCP socket from a browser.
36
+ */
37
+ disconnect(options) {
38
+ console.log('TCP disconnect attempted in web context:', options);
39
+ return Promise.reject(new Error(this.ERROR_MESSAGE));
40
+ }
41
+ }
42
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAa5C;;;;;GAKG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAA5C;;QACmB,kBAAa,GAAG,gDAAgD,CAAC;IAiCpF,CAAC;IA/BC;;OAEG;IACH,OAAO,CAAC,OAAuB;QAC7B,OAAO,CAAC,GAAG,CAAC,0CAA0C,EAAE,OAAO,CAAC,CAAC;QACjE,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAAoB;QACvB,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,OAAO,CAAC,CAAC;QAC3D,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAAoB;QACvB,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,OAAO,CAAC,CAAC;QAC3D,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,OAA0B;QACnC,OAAO,CAAC,GAAG,CAAC,0CAA0C,EAAE,OAAO,CAAC,CAAC;QACjE,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;IACvD,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n ConnectOptions,\n ConnectResult,\n DisconnectOptions,\n DisconnectResult,\n ReadOptions,\n ReadResult,\n SendOptions,\n TcpPrinterPlugin,\n} from './definitions';\n\n/**\n * Web implementation of the TcpPrinter plugin.\n *\n * Note: Direct TCP connections are not supported in web browsers due to security restrictions.\n * Consider using WebSockets as an alternative for web applications.\n */\nexport class TcpPrinterWeb extends WebPlugin implements TcpPrinterPlugin {\n private readonly ERROR_MESSAGE = 'TCP sockets are not supported in web browsers.';\n\n /**\n * Cannot connect directly via TCP from a browser.\n */\n connect(options: ConnectOptions): Promise<ConnectResult> {\n console.log('TCP connection attempted in web context:', options);\n return Promise.reject(new Error(this.ERROR_MESSAGE));\n }\n\n /**\n * Cannot send data via TCP from a browser.\n */\n send(options: SendOptions): Promise<void> {\n console.log('TCP send attempted in web context:', options);\n return Promise.reject(new Error(this.ERROR_MESSAGE));\n }\n\n /**\n * Cannot read data via TCP from a browser.\n */\n read(options: ReadOptions): Promise<ReadResult> {\n console.log('TCP read attempted in web context:', options);\n return Promise.reject(new Error(this.ERROR_MESSAGE));\n }\n\n /**\n * Cannot disconnect TCP socket from a browser.\n */\n disconnect(options: DisconnectOptions): Promise<DisconnectResult> {\n console.log('TCP disconnect attempted in web context:', options);\n return Promise.reject(new Error(this.ERROR_MESSAGE));\n }\n}\n"]}
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ /**
6
+ * Supported encoding types for data
7
+ */
8
+ exports.DataEncoding = void 0;
9
+ (function (DataEncoding) {
10
+ /**
11
+ * UTF-8 text encoding
12
+ */
13
+ DataEncoding["UTF8"] = "utf8";
14
+ /**
15
+ * Base64 encoded data
16
+ */
17
+ DataEncoding["BASE64"] = "base64";
18
+ /**
19
+ * Hexadecimal string
20
+ */
21
+ DataEncoding["HEX"] = "hex";
22
+ })(exports.DataEncoding || (exports.DataEncoding = {}));
23
+
24
+ const TcpPrinter = core.registerPlugin('TcpPrinter', {
25
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.TcpPrinterWeb()),
26
+ });
27
+
28
+ /**
29
+ * Web implementation of the TcpPrinter plugin.
30
+ *
31
+ * Note: Direct TCP connections are not supported in web browsers due to security restrictions.
32
+ * Consider using WebSockets as an alternative for web applications.
33
+ */
34
+ class TcpPrinterWeb extends core.WebPlugin {
35
+ constructor() {
36
+ super(...arguments);
37
+ this.ERROR_MESSAGE = 'TCP sockets are not supported in web browsers.';
38
+ }
39
+ /**
40
+ * Cannot connect directly via TCP from a browser.
41
+ */
42
+ connect(options) {
43
+ console.log('TCP connection attempted in web context:', options);
44
+ return Promise.reject(new Error(this.ERROR_MESSAGE));
45
+ }
46
+ /**
47
+ * Cannot send data via TCP from a browser.
48
+ */
49
+ send(options) {
50
+ console.log('TCP send attempted in web context:', options);
51
+ return Promise.reject(new Error(this.ERROR_MESSAGE));
52
+ }
53
+ /**
54
+ * Cannot read data via TCP from a browser.
55
+ */
56
+ read(options) {
57
+ console.log('TCP read attempted in web context:', options);
58
+ return Promise.reject(new Error(this.ERROR_MESSAGE));
59
+ }
60
+ /**
61
+ * Cannot disconnect TCP socket from a browser.
62
+ */
63
+ disconnect(options) {
64
+ console.log('TCP disconnect attempted in web context:', options);
65
+ return Promise.reject(new Error(this.ERROR_MESSAGE));
66
+ }
67
+ }
68
+
69
+ var web = /*#__PURE__*/Object.freeze({
70
+ __proto__: null,
71
+ TcpPrinterWeb: TcpPrinterWeb
72
+ });
73
+
74
+ exports.TcpPrinter = TcpPrinter;
75
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Supported encoding types for data\n */\nexport var DataEncoding;\n(function (DataEncoding) {\n /**\n * UTF-8 text encoding\n */\n DataEncoding[\"UTF8\"] = \"utf8\";\n /**\n * Base64 encoded data\n */\n DataEncoding[\"BASE64\"] = \"base64\";\n /**\n * Hexadecimal string\n */\n DataEncoding[\"HEX\"] = \"hex\";\n})(DataEncoding || (DataEncoding = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst TcpPrinter = registerPlugin('TcpPrinter', {\n web: () => import('./web').then((m) => new m.TcpPrinterWeb()),\n});\nexport * from './definitions';\nexport { TcpPrinter };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the TcpPrinter plugin.\n *\n * Note: Direct TCP connections are not supported in web browsers due to security restrictions.\n * Consider using WebSockets as an alternative for web applications.\n */\nexport class TcpPrinterWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.ERROR_MESSAGE = 'TCP sockets are not supported in web browsers.';\n }\n /**\n * Cannot connect directly via TCP from a browser.\n */\n connect(options) {\n console.log('TCP connection attempted in web context:', options);\n return Promise.reject(new Error(this.ERROR_MESSAGE));\n }\n /**\n * Cannot send data via TCP from a browser.\n */\n send(options) {\n console.log('TCP send attempted in web context:', options);\n return Promise.reject(new Error(this.ERROR_MESSAGE));\n }\n /**\n * Cannot read data via TCP from a browser.\n */\n read(options) {\n console.log('TCP read attempted in web context:', options);\n return Promise.reject(new Error(this.ERROR_MESSAGE));\n }\n /**\n * Cannot disconnect TCP socket from a browser.\n */\n disconnect(options) {\n console.log('TCP disconnect attempted in web context:', options);\n return Promise.reject(new Error(this.ERROR_MESSAGE));\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["DataEncoding","registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACWA;AACX,CAAC,UAAU,YAAY,EAAE;AACzB;AACA;AACA;AACA,IAAI,YAAY,CAAC,MAAM,CAAC,GAAG,MAAM;AACjC;AACA;AACA;AACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ;AACrC;AACA;AACA;AACA,IAAI,YAAY,CAAC,KAAK,CAAC,GAAG,KAAK;AAC/B,CAAC,EAAEA,oBAAY,KAAKA,oBAAY,GAAG,EAAE,CAAC,CAAC;;AChBlC,MAAC,UAAU,GAAGC,mBAAc,CAAC,YAAY,EAAE;AAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;AACjE,CAAC;;ACFD;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,aAAa,SAASC,cAAS,CAAC;AAC7C,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC;AAC3B,QAAQ,IAAI,CAAC,aAAa,GAAG,gDAAgD;AAC7E,IAAI;AACJ;AACA;AACA;AACA,IAAI,OAAO,CAAC,OAAO,EAAE;AACrB,QAAQ,OAAO,CAAC,GAAG,CAAC,0CAA0C,EAAE,OAAO,CAAC;AACxE,QAAQ,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AAC5D,IAAI;AACJ;AACA;AACA;AACA,IAAI,IAAI,CAAC,OAAO,EAAE;AAClB,QAAQ,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,OAAO,CAAC;AAClE,QAAQ,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AAC5D,IAAI;AACJ;AACA;AACA;AACA,IAAI,IAAI,CAAC,OAAO,EAAE;AAClB,QAAQ,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,OAAO,CAAC;AAClE,QAAQ,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AAC5D,IAAI;AACJ;AACA;AACA;AACA,IAAI,UAAU,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,0CAA0C,EAAE,OAAO,CAAC;AACxE,QAAQ,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AAC5D,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,78 @@
1
+ var capacitorTcpPrinterPlugin = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ /**
5
+ * Supported encoding types for data
6
+ */
7
+ exports.DataEncoding = void 0;
8
+ (function (DataEncoding) {
9
+ /**
10
+ * UTF-8 text encoding
11
+ */
12
+ DataEncoding["UTF8"] = "utf8";
13
+ /**
14
+ * Base64 encoded data
15
+ */
16
+ DataEncoding["BASE64"] = "base64";
17
+ /**
18
+ * Hexadecimal string
19
+ */
20
+ DataEncoding["HEX"] = "hex";
21
+ })(exports.DataEncoding || (exports.DataEncoding = {}));
22
+
23
+ const TcpPrinter = core.registerPlugin('TcpPrinter', {
24
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.TcpPrinterWeb()),
25
+ });
26
+
27
+ /**
28
+ * Web implementation of the TcpPrinter plugin.
29
+ *
30
+ * Note: Direct TCP connections are not supported in web browsers due to security restrictions.
31
+ * Consider using WebSockets as an alternative for web applications.
32
+ */
33
+ class TcpPrinterWeb extends core.WebPlugin {
34
+ constructor() {
35
+ super(...arguments);
36
+ this.ERROR_MESSAGE = 'TCP sockets are not supported in web browsers.';
37
+ }
38
+ /**
39
+ * Cannot connect directly via TCP from a browser.
40
+ */
41
+ connect(options) {
42
+ console.log('TCP connection attempted in web context:', options);
43
+ return Promise.reject(new Error(this.ERROR_MESSAGE));
44
+ }
45
+ /**
46
+ * Cannot send data via TCP from a browser.
47
+ */
48
+ send(options) {
49
+ console.log('TCP send attempted in web context:', options);
50
+ return Promise.reject(new Error(this.ERROR_MESSAGE));
51
+ }
52
+ /**
53
+ * Cannot read data via TCP from a browser.
54
+ */
55
+ read(options) {
56
+ console.log('TCP read attempted in web context:', options);
57
+ return Promise.reject(new Error(this.ERROR_MESSAGE));
58
+ }
59
+ /**
60
+ * Cannot disconnect TCP socket from a browser.
61
+ */
62
+ disconnect(options) {
63
+ console.log('TCP disconnect attempted in web context:', options);
64
+ return Promise.reject(new Error(this.ERROR_MESSAGE));
65
+ }
66
+ }
67
+
68
+ var web = /*#__PURE__*/Object.freeze({
69
+ __proto__: null,
70
+ TcpPrinterWeb: TcpPrinterWeb
71
+ });
72
+
73
+ exports.TcpPrinter = TcpPrinter;
74
+
75
+ return exports;
76
+
77
+ })({}, capacitorExports);
78
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Supported encoding types for data\n */\nexport var DataEncoding;\n(function (DataEncoding) {\n /**\n * UTF-8 text encoding\n */\n DataEncoding[\"UTF8\"] = \"utf8\";\n /**\n * Base64 encoded data\n */\n DataEncoding[\"BASE64\"] = \"base64\";\n /**\n * Hexadecimal string\n */\n DataEncoding[\"HEX\"] = \"hex\";\n})(DataEncoding || (DataEncoding = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst TcpPrinter = registerPlugin('TcpPrinter', {\n web: () => import('./web').then((m) => new m.TcpPrinterWeb()),\n});\nexport * from './definitions';\nexport { TcpPrinter };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the TcpPrinter plugin.\n *\n * Note: Direct TCP connections are not supported in web browsers due to security restrictions.\n * Consider using WebSockets as an alternative for web applications.\n */\nexport class TcpPrinterWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.ERROR_MESSAGE = 'TCP sockets are not supported in web browsers.';\n }\n /**\n * Cannot connect directly via TCP from a browser.\n */\n connect(options) {\n console.log('TCP connection attempted in web context:', options);\n return Promise.reject(new Error(this.ERROR_MESSAGE));\n }\n /**\n * Cannot send data via TCP from a browser.\n */\n send(options) {\n console.log('TCP send attempted in web context:', options);\n return Promise.reject(new Error(this.ERROR_MESSAGE));\n }\n /**\n * Cannot read data via TCP from a browser.\n */\n read(options) {\n console.log('TCP read attempted in web context:', options);\n return Promise.reject(new Error(this.ERROR_MESSAGE));\n }\n /**\n * Cannot disconnect TCP socket from a browser.\n */\n disconnect(options) {\n console.log('TCP disconnect attempted in web context:', options);\n return Promise.reject(new Error(this.ERROR_MESSAGE));\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["DataEncoding","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;AACWA;IACX,CAAC,UAAU,YAAY,EAAE;IACzB;IACA;IACA;IACA,IAAI,YAAY,CAAC,MAAM,CAAC,GAAG,MAAM;IACjC;IACA;IACA;IACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ;IACrC;IACA;IACA;IACA,IAAI,YAAY,CAAC,KAAK,CAAC,GAAG,KAAK;IAC/B,CAAC,EAAEA,oBAAY,KAAKA,oBAAY,GAAG,EAAE,CAAC,CAAC;;AChBlC,UAAC,UAAU,GAAGC,mBAAc,CAAC,YAAY,EAAE;IAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;IACjE,CAAC;;ICFD;IACA;IACA;IACA;IACA;IACA;IACO,MAAM,aAAa,SAASC,cAAS,CAAC;IAC7C,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC;IAC3B,QAAQ,IAAI,CAAC,aAAa,GAAG,gDAAgD;IAC7E,IAAI;IACJ;IACA;IACA;IACA,IAAI,OAAO,CAAC,OAAO,EAAE;IACrB,QAAQ,OAAO,CAAC,GAAG,CAAC,0CAA0C,EAAE,OAAO,CAAC;IACxE,QAAQ,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC5D,IAAI;IACJ;IACA;IACA;IACA,IAAI,IAAI,CAAC,OAAO,EAAE;IAClB,QAAQ,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,OAAO,CAAC;IAClE,QAAQ,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC5D,IAAI;IACJ;IACA;IACA;IACA,IAAI,IAAI,CAAC,OAAO,EAAE;IAClB,QAAQ,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,OAAO,CAAC;IAClE,QAAQ,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC5D,IAAI;IACJ;IACA;IACA;IACA,IAAI,UAAU,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,0CAA0C,EAAE,OAAO,CAAC;IACxE,QAAQ,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC5D,IAAI;IACJ;;;;;;;;;;;;;;;"}