@spencerls/react-native-nfc 1.0.3 → 1.0.5
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/API.md +214 -0
- package/README.md +153 -26
- package/dist/index.d.mts +102 -96
- package/dist/index.d.ts +102 -96
- package/dist/index.js +201 -109
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +203 -111
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,114 +1,28 @@
|
|
|
1
1
|
import * as react_native_nfc_manager from 'react-native-nfc-manager';
|
|
2
2
|
import { TagEvent, NfcTech, NdefRecord } from 'react-native-nfc-manager';
|
|
3
3
|
|
|
4
|
-
type NfcMode = "idle" | "starting" | "active" | "stopping" | "technology";
|
|
5
|
-
|
|
6
|
-
interface NfcState {
|
|
7
|
-
mode: NfcMode;
|
|
8
|
-
tag: TagEvent | null;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
type NfcListener = (state: NfcState) => void;
|
|
12
|
-
declare class NfcService {
|
|
13
|
-
private state;
|
|
14
|
-
private listeners;
|
|
15
|
-
constructor();
|
|
16
|
-
private setState;
|
|
17
|
-
getState(): NfcState;
|
|
18
|
-
subscribe(fn: NfcListener): () => void;
|
|
19
|
-
startReader(readerModeFlags: number, onTag?: (tag: TagEvent) => void): Promise<void>;
|
|
20
|
-
stopReader(): Promise<void>;
|
|
21
|
-
withTechnology<T>(tech: NfcTech | NfcTech[], handler: () => Promise<T>): Promise<T>;
|
|
22
|
-
}
|
|
23
|
-
declare const nfcService: NfcService;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* NFC root namespace providing access to:
|
|
27
|
-
* - NfcService
|
|
28
|
-
* - ISO15693 NFC-V ops
|
|
29
|
-
* - NFC-A ops
|
|
30
|
-
* - NDEF operations
|
|
31
|
-
*/
|
|
32
|
-
declare const nfc: {
|
|
33
|
-
readonly service: NfcService;
|
|
34
|
-
/** ISO15693 protocol helpers and high-level operations */
|
|
35
|
-
readonly v: {
|
|
36
|
-
readonly utils: {
|
|
37
|
-
readonly tech: react_native_nfc_manager.NfcTech.NfcV | react_native_nfc_manager.NfcTech[];
|
|
38
|
-
readonly Flags: {
|
|
39
|
-
readonly HIGH_DATA_RATE: 2;
|
|
40
|
-
readonly ADDRESSED: 32;
|
|
41
|
-
};
|
|
42
|
-
readonly Commands: {
|
|
43
|
-
readonly READ_SINGLE_BLOCK: 32;
|
|
44
|
-
readonly WRITE_SINGLE_BLOCK: 33;
|
|
45
|
-
readonly GET_SYSTEM_INFO: 43;
|
|
46
|
-
};
|
|
47
|
-
readonly flags: (...bits: number[]) => number;
|
|
48
|
-
readonly reverseUid: (tagIdHex: string) => number[];
|
|
49
|
-
readonly buildReadBlock: (uidReversed: number[], blockNumber: number) => number[];
|
|
50
|
-
readonly buildWriteBlock: (uidReversed: number[], blockNumber: number, data: Uint8Array) => number[];
|
|
51
|
-
readonly buildGetSystemInfo: (uidReversed: number[]) => number[];
|
|
52
|
-
readonly parseReadResponse: (resp: number[]) => Uint8Array;
|
|
53
|
-
readonly parseWriteResponse: (resp: number[]) => void;
|
|
54
|
-
readonly parseSystemInfo: (resp: number[]) => any;
|
|
55
|
-
readonly detectManufacturer: (uid: string) => string;
|
|
56
|
-
};
|
|
57
|
-
readonly withVTag: <T>(handler: (tag: react_native_nfc_manager.TagEvent & {
|
|
58
|
-
id: string;
|
|
59
|
-
}) => Promise<T>) => Promise<T>;
|
|
60
|
-
readonly writeBlockNfcV: (blockNumber: number, data: Uint8Array) => Promise<void>;
|
|
61
|
-
readonly readBlockNfcV: (blockNumber: number) => Promise<Uint8Array<ArrayBufferLike>>;
|
|
62
|
-
readonly getSystemInfoNfcV: () => Promise<any>;
|
|
63
|
-
};
|
|
64
|
-
/** NFC-A / Type 2 helpers and operations */
|
|
65
|
-
readonly a: {
|
|
66
|
-
readonly utils: {};
|
|
67
|
-
readonly transceive: (data: number[]) => Promise<number[]>;
|
|
68
|
-
};
|
|
69
|
-
/** NDEF read/write utilities and operations */
|
|
70
|
-
readonly ndef: {
|
|
71
|
-
readonly utils: {};
|
|
72
|
-
readonly writeNdef: (records: react_native_nfc_manager.NdefRecord[]) => Promise<void>;
|
|
73
|
-
readonly writeTextNdef: (text: string) => Promise<void>;
|
|
74
|
-
readonly writeUriNdef: (uri: string) => Promise<void>;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
|
|
78
4
|
declare const operations$2: {
|
|
79
5
|
transceive(data: number[]): Promise<number[]>;
|
|
80
6
|
};
|
|
81
7
|
|
|
82
|
-
declare const
|
|
8
|
+
declare const utils$2: {};
|
|
83
9
|
|
|
84
|
-
declare const index$2_NfcAUtils: typeof NfcAUtils;
|
|
85
10
|
declare namespace index$2 {
|
|
86
|
-
export {
|
|
11
|
+
export { operations$2 as operations, utils$2 as utils };
|
|
87
12
|
}
|
|
88
13
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
writeTextNdef(text: string): Promise<void>;
|
|
92
|
-
writeUriNdef(uri: string): Promise<void>;
|
|
14
|
+
type StrictTagEvent = TagEvent & {
|
|
15
|
+
id: string;
|
|
93
16
|
};
|
|
94
17
|
|
|
95
|
-
declare const
|
|
96
|
-
|
|
97
|
-
declare const index$1_NdefUtils: typeof NdefUtils;
|
|
98
|
-
declare namespace index$1 {
|
|
99
|
-
export { index$1_NdefUtils as NdefUtils, operations$1 as operations };
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
declare const operations: {
|
|
103
|
-
withVTag<T>(handler: (tag: TagEvent & {
|
|
104
|
-
id: string;
|
|
105
|
-
}) => Promise<T>): Promise<T>;
|
|
18
|
+
declare const operations$1: {
|
|
19
|
+
withVTag<T>(handler: (tag: StrictTagEvent) => Promise<T>): Promise<T>;
|
|
106
20
|
writeBlockNfcV(blockNumber: number, data: Uint8Array): Promise<void>;
|
|
107
21
|
readBlockNfcV(blockNumber: number): Promise<Uint8Array<ArrayBufferLike>>;
|
|
108
22
|
getSystemInfoNfcV(): Promise<any>;
|
|
109
23
|
};
|
|
110
24
|
|
|
111
|
-
declare const
|
|
25
|
+
declare const utils$1: {
|
|
112
26
|
readonly tech: NfcTech.NfcV | NfcTech[];
|
|
113
27
|
readonly Flags: {
|
|
114
28
|
readonly HIGH_DATA_RATE: 2;
|
|
@@ -164,10 +78,102 @@ declare const NfcVUtils: {
|
|
|
164
78
|
readonly detectManufacturer: (uid: string) => string;
|
|
165
79
|
};
|
|
166
80
|
|
|
167
|
-
declare
|
|
81
|
+
declare namespace index$1 {
|
|
82
|
+
export { operations$1 as operations, utils$1 as utils };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare const operations: {
|
|
86
|
+
writeNdef(records: NdefRecord[]): Promise<void>;
|
|
87
|
+
writeTextNdef(text: string): Promise<void>;
|
|
88
|
+
writeUriNdef(uri: string): Promise<void>;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
declare const utils: {};
|
|
92
|
+
|
|
168
93
|
declare const index_operations: typeof operations;
|
|
94
|
+
declare const index_utils: typeof utils;
|
|
169
95
|
declare namespace index {
|
|
170
|
-
export {
|
|
96
|
+
export { index_operations as operations, index_utils as utils };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
type NfcMode = "idle" | "starting" | "active" | "stopping" | "technology";
|
|
100
|
+
|
|
101
|
+
interface NfcState {
|
|
102
|
+
mode: NfcMode;
|
|
103
|
+
tag: TagEvent | null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
type NfcListener = (state: NfcState) => void;
|
|
107
|
+
declare class NfcService {
|
|
108
|
+
private state;
|
|
109
|
+
private listeners;
|
|
110
|
+
private isProcessingTag;
|
|
111
|
+
private currentOnTag?;
|
|
112
|
+
private currentCooldownMs;
|
|
113
|
+
private lastUsedReaderFlags;
|
|
114
|
+
constructor();
|
|
115
|
+
private setState;
|
|
116
|
+
getState(): NfcState;
|
|
117
|
+
subscribe(fn: NfcListener): () => void;
|
|
118
|
+
startReader(readerModeFlags: number, onTag?: (tag: TagEvent) => Promise<void> | void, options?: {
|
|
119
|
+
cooldownMs?: number;
|
|
120
|
+
}): Promise<void>;
|
|
121
|
+
stopReader(): Promise<void>;
|
|
122
|
+
private _resetReaderState;
|
|
123
|
+
private _restartIosReader;
|
|
124
|
+
withTechnology<T>(tech: NfcTech | NfcTech[], handler: () => Promise<T>): Promise<T>;
|
|
171
125
|
}
|
|
126
|
+
declare const nfcService: NfcService;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* NFC root namespace providing access to:
|
|
130
|
+
* - NfcService
|
|
131
|
+
* - ISO15693 NFC-V ops
|
|
132
|
+
* - NFC-A ops
|
|
133
|
+
* - NDEF operations
|
|
134
|
+
*/
|
|
135
|
+
declare const nfc: {
|
|
136
|
+
readonly service: NfcService;
|
|
137
|
+
/** ISO15693 protocol helpers and high-level operations */
|
|
138
|
+
readonly v: {
|
|
139
|
+
readonly utils: {
|
|
140
|
+
readonly tech: react_native_nfc_manager.NfcTech.NfcV | react_native_nfc_manager.NfcTech[];
|
|
141
|
+
readonly Flags: {
|
|
142
|
+
readonly HIGH_DATA_RATE: 2;
|
|
143
|
+
readonly ADDRESSED: 32;
|
|
144
|
+
};
|
|
145
|
+
readonly Commands: {
|
|
146
|
+
readonly READ_SINGLE_BLOCK: 32;
|
|
147
|
+
readonly WRITE_SINGLE_BLOCK: 33;
|
|
148
|
+
readonly GET_SYSTEM_INFO: 43;
|
|
149
|
+
};
|
|
150
|
+
readonly flags: (...bits: number[]) => number;
|
|
151
|
+
readonly reverseUid: (tagIdHex: string) => number[];
|
|
152
|
+
readonly buildReadBlock: (uidReversed: number[], blockNumber: number) => number[];
|
|
153
|
+
readonly buildWriteBlock: (uidReversed: number[], blockNumber: number, data: Uint8Array) => number[];
|
|
154
|
+
readonly buildGetSystemInfo: (uidReversed: number[]) => number[];
|
|
155
|
+
readonly parseReadResponse: (resp: number[]) => Uint8Array;
|
|
156
|
+
readonly parseWriteResponse: (resp: number[]) => void;
|
|
157
|
+
readonly parseSystemInfo: (resp: number[]) => any;
|
|
158
|
+
readonly detectManufacturer: (uid: string) => string;
|
|
159
|
+
};
|
|
160
|
+
readonly withVTag: <T>(handler: (tag: StrictTagEvent) => Promise<T>) => Promise<T>;
|
|
161
|
+
readonly writeBlockNfcV: (blockNumber: number, data: Uint8Array) => Promise<void>;
|
|
162
|
+
readonly readBlockNfcV: (blockNumber: number) => Promise<Uint8Array<ArrayBufferLike>>;
|
|
163
|
+
readonly getSystemInfoNfcV: () => Promise<any>;
|
|
164
|
+
};
|
|
165
|
+
/** NFC-A / Type 2 helpers and operations */
|
|
166
|
+
readonly a: {
|
|
167
|
+
readonly utils: {};
|
|
168
|
+
readonly transceive: (data: number[]) => Promise<number[]>;
|
|
169
|
+
};
|
|
170
|
+
/** NDEF read/write utilities and operations */
|
|
171
|
+
readonly ndef: {
|
|
172
|
+
readonly utils: {};
|
|
173
|
+
readonly writeNdef: (records: react_native_nfc_manager.NdefRecord[]) => Promise<void>;
|
|
174
|
+
readonly writeTextNdef: (text: string) => Promise<void>;
|
|
175
|
+
readonly writeUriNdef: (uri: string) => Promise<void>;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
172
178
|
|
|
173
|
-
export { type NfcMode, type NfcState, index$
|
|
179
|
+
export { type NfcMode, type NfcState, nfc, index$2 as nfcA, index as nfcNdef, nfcService, index$1 as nfcV };
|