@spencerls/react-native-nfc 1.0.10 → 1.0.11
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 +234 -94
- package/README.md +155 -150
- package/dist/index.d.mts +53 -62
- package/dist/index.d.ts +53 -62
- package/dist/index.js +440 -281
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +435 -281
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import * as react_native_nfc_manager from 'react-native-nfc-manager';
|
|
2
|
-
import {
|
|
2
|
+
import { NfcTech, RegisterTagEventOpts, TagEvent, NdefRecord, TNF, ISOLangCode, NdefStatus } from 'react-native-nfc-manager';
|
|
3
3
|
|
|
4
|
-
declare class
|
|
5
|
-
static
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
static
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
declare class NfcService {
|
|
5
|
+
private static instance;
|
|
6
|
+
private strategies;
|
|
7
|
+
private stateMachine;
|
|
8
|
+
private jobRetry;
|
|
9
|
+
private isExecutingJobs;
|
|
10
|
+
static getInstance(): NfcService;
|
|
11
|
+
startTech(tech: NfcTech[], withTechnology: () => Promise<void>, afterTechnology?: () => Promise<void>, options?: RegisterTagEventOpts): Promise<void>;
|
|
12
|
+
startTechLoop(tech: NfcTech[], withTechnology: () => Promise<void>, afterTechnology?: () => Promise<void>, options?: RegisterTagEventOpts): Promise<void>;
|
|
13
|
+
startTagEvent(onTag: (tag: TagEvent) => Promise<void>): Promise<void>;
|
|
14
|
+
startTagEventLoop(onTag: (tag: TagEvent) => Promise<void>, options?: RegisterTagEventOpts): Promise<void>;
|
|
15
|
+
stop(): Promise<void>;
|
|
16
|
+
private executeOrQueue;
|
|
17
|
+
private executeJob;
|
|
14
18
|
}
|
|
19
|
+
declare const nfcService: NfcService;
|
|
15
20
|
|
|
16
21
|
type NdefBuilder = (r: typeof Builder) => NdefRecord[];
|
|
17
22
|
interface BuildRecordInit {
|
|
@@ -28,45 +33,17 @@ interface NdefMessageResult {
|
|
|
28
33
|
canMakeReadOnly: boolean;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
type NfcMode = "idle" | "starting" | "active" | "stopping" | "technology";
|
|
42
|
-
interface NfcState {
|
|
43
|
-
mode: NfcMode;
|
|
44
|
-
tag: TagEvent | null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
type NfcListener = (state: NfcState) => void;
|
|
48
|
-
declare class NfcService {
|
|
49
|
-
private state;
|
|
50
|
-
private listeners;
|
|
51
|
-
private isProcessingTag;
|
|
52
|
-
private currentOnTag?;
|
|
53
|
-
private currentCooldownMs;
|
|
54
|
-
private cooldownTimer?;
|
|
55
|
-
private readerModeFlags_ANDROID;
|
|
56
|
-
constructor();
|
|
57
|
-
enableReaderMode_ANDROID(flags: number): void;
|
|
58
|
-
private setState;
|
|
59
|
-
getState(): NfcState;
|
|
60
|
-
subscribe(fn: NfcListener): () => void;
|
|
61
|
-
startReader(onTag?: (tag: TagEvent) => Promise<void> | void, options?: {
|
|
62
|
-
cooldownMs?: number;
|
|
63
|
-
}): Promise<void>;
|
|
64
|
-
stopReader(): Promise<void>;
|
|
65
|
-
private _resetReaderState;
|
|
66
|
-
withTechnology<T>(tech: NfcTech | NfcTech[], handler: () => Promise<T>): Promise<T>;
|
|
67
|
-
private withTechnologyReaderMode_ANDROID;
|
|
36
|
+
declare class Builder {
|
|
37
|
+
static records(b: NdefBuilder): NdefRecord[];
|
|
38
|
+
static message(b: NdefBuilder): number[];
|
|
39
|
+
static record(init: BuildRecordInit): NdefRecord;
|
|
40
|
+
static textRecord(text: string, lang?: ISOLangCode, encoding?: "utf8" | "utf16", id?: string): NdefRecord;
|
|
41
|
+
static uriRecord(uri: string, id?: string): NdefRecord;
|
|
42
|
+
static jsonRecord(payload: string | Uint8Array | number[], id?: string): NdefRecord;
|
|
43
|
+
static mimeRecord(mimeType: string, payload: string | Uint8Array | number[], id?: string): NdefRecord;
|
|
44
|
+
static externalRecord(domain: string, type: string, payload: string | Uint8Array | number[], id?: string): NdefRecord;
|
|
45
|
+
static createEmpty(): NdefRecord;
|
|
68
46
|
}
|
|
69
|
-
declare const nfcService: NfcService;
|
|
70
47
|
|
|
71
48
|
declare function readMessage$1(): Promise<NdefMessageResult>;
|
|
72
49
|
declare function write$1(records: NdefRecord[]): Promise<void>;
|
|
@@ -100,7 +77,17 @@ declare const nfcTag: {
|
|
|
100
77
|
readonly getTag: typeof getTag$1;
|
|
101
78
|
};
|
|
102
79
|
|
|
103
|
-
declare function getTag(tech: NfcTech
|
|
80
|
+
declare function getTag(tech: NfcTech[]): Promise<TagEvent>;
|
|
81
|
+
|
|
82
|
+
type SystemInfo = {
|
|
83
|
+
uid?: string;
|
|
84
|
+
dsfid?: number;
|
|
85
|
+
afi?: number;
|
|
86
|
+
numberOfBlocks?: number;
|
|
87
|
+
blockSize?: number;
|
|
88
|
+
icReference?: number;
|
|
89
|
+
manufacturer?: string;
|
|
90
|
+
};
|
|
104
91
|
|
|
105
92
|
declare function transceive(bytes: number[]): Promise<number[]>;
|
|
106
93
|
declare function readBlock$1(tagId: string, blockNumber: number): Promise<Uint8Array>;
|
|
@@ -178,7 +165,7 @@ declare namespace utils {
|
|
|
178
165
|
}
|
|
179
166
|
|
|
180
167
|
declare const nfcVTag: {
|
|
181
|
-
readonly tech: react_native_nfc_manager.NfcTech
|
|
168
|
+
readonly tech: react_native_nfc_manager.NfcTech[];
|
|
182
169
|
readonly utils: typeof utils;
|
|
183
170
|
readonly transceive: typeof transceive;
|
|
184
171
|
readonly readBlock: typeof readBlock$1;
|
|
@@ -227,20 +214,24 @@ declare const nfc: {
|
|
|
227
214
|
};
|
|
228
215
|
};
|
|
229
216
|
|
|
230
|
-
declare function
|
|
231
|
-
|
|
232
|
-
}
|
|
217
|
+
declare function useNfcTech(tech: NfcTech[], withTechnology: () => Promise<void>, afterTechnology?: () => Promise<void>, options?: RegisterTagEventOpts): {
|
|
218
|
+
startTech: () => void;
|
|
219
|
+
};
|
|
233
220
|
|
|
234
|
-
declare function
|
|
235
|
-
start: (
|
|
236
|
-
stop: () => void
|
|
221
|
+
declare function useNfcTechLoop(tech: NfcTech[], withTechnology: () => Promise<void>, afterTechnology?: () => Promise<void>, options?: RegisterTagEventOpts): {
|
|
222
|
+
start: () => Promise<void>;
|
|
223
|
+
stop: () => Promise<void>;
|
|
224
|
+
isRunning: boolean;
|
|
237
225
|
};
|
|
238
226
|
|
|
239
|
-
declare function
|
|
227
|
+
declare function useNfcTagEvent(onTag: (tag: TagEvent) => Promise<void>): {
|
|
228
|
+
startTech: () => void;
|
|
229
|
+
};
|
|
240
230
|
|
|
241
|
-
declare function
|
|
242
|
-
|
|
243
|
-
|
|
231
|
+
declare function useNfcTagEventLoop(onTag: (tag: TagEvent) => Promise<void>, options?: RegisterTagEventOpts): {
|
|
232
|
+
start: () => Promise<void>;
|
|
233
|
+
stop: () => Promise<void>;
|
|
234
|
+
isRunning: boolean;
|
|
244
235
|
};
|
|
245
236
|
|
|
246
|
-
export { type BuildRecordInit, type NdefBuilder, type NdefMessageResult, type
|
|
237
|
+
export { type BuildRecordInit, type NdefBuilder, type NdefMessageResult, type SystemInfo, nfc, nfcNdefTag, nfcService, nfcTag, nfcVTag, useNfcTagEvent, useNfcTagEventLoop, useNfcTech, useNfcTechLoop };
|