@spencerls/react-native-nfc 1.0.9 → 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 +231 -104
- package/README.md +155 -166
- package/dist/index.d.mts +53 -71
- package/dist/index.d.ts +53 -71
- package/dist/index.js +437 -300
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +433 -304
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import * as react_native_nfc_manager from 'react-native-nfc-manager';
|
|
2
|
-
import {
|
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { NfcTech, RegisterTagEventOpts, TagEvent, NdefRecord, TNF, ISOLangCode, NdefStatus } from 'react-native-nfc-manager';
|
|
5
3
|
|
|
6
|
-
declare class
|
|
7
|
-
static
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
static
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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;
|
|
16
18
|
}
|
|
19
|
+
declare const nfcService: NfcService;
|
|
17
20
|
|
|
18
21
|
type NdefBuilder = (r: typeof Builder) => NdefRecord[];
|
|
19
22
|
interface BuildRecordInit {
|
|
@@ -30,45 +33,17 @@ interface NdefMessageResult {
|
|
|
30
33
|
canMakeReadOnly: boolean;
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
type NfcMode = "idle" | "starting" | "active" | "stopping" | "technology";
|
|
44
|
-
interface NfcState {
|
|
45
|
-
mode: NfcMode;
|
|
46
|
-
tag: TagEvent | null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
type NfcListener = (state: NfcState) => void;
|
|
50
|
-
declare class NfcService {
|
|
51
|
-
private state;
|
|
52
|
-
private listeners;
|
|
53
|
-
private isProcessingTag;
|
|
54
|
-
private currentOnTag?;
|
|
55
|
-
private currentCooldownMs;
|
|
56
|
-
private cooldownTimer?;
|
|
57
|
-
private readerModeFlags_ANDROID;
|
|
58
|
-
constructor();
|
|
59
|
-
enableReaderMode_ANDROID(flags: number): void;
|
|
60
|
-
private setState;
|
|
61
|
-
getState(): NfcState;
|
|
62
|
-
subscribe(fn: NfcListener): () => void;
|
|
63
|
-
startReader(onTag?: (tag: TagEvent) => Promise<void> | void, options?: {
|
|
64
|
-
cooldownMs?: number;
|
|
65
|
-
}): Promise<void>;
|
|
66
|
-
stopReader(): Promise<void>;
|
|
67
|
-
private _resetReaderState;
|
|
68
|
-
withTechnology<T>(tech: NfcTech | NfcTech[], handler: () => Promise<T>): Promise<T>;
|
|
69
|
-
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;
|
|
70
46
|
}
|
|
71
|
-
declare const nfcService: NfcService;
|
|
72
47
|
|
|
73
48
|
declare function readMessage$1(): Promise<NdefMessageResult>;
|
|
74
49
|
declare function write$1(records: NdefRecord[]): Promise<void>;
|
|
@@ -102,7 +77,17 @@ declare const nfcTag: {
|
|
|
102
77
|
readonly getTag: typeof getTag$1;
|
|
103
78
|
};
|
|
104
79
|
|
|
105
|
-
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
|
+
};
|
|
106
91
|
|
|
107
92
|
declare function transceive(bytes: number[]): Promise<number[]>;
|
|
108
93
|
declare function readBlock$1(tagId: string, blockNumber: number): Promise<Uint8Array>;
|
|
@@ -180,7 +165,7 @@ declare namespace utils {
|
|
|
180
165
|
}
|
|
181
166
|
|
|
182
167
|
declare const nfcVTag: {
|
|
183
|
-
readonly tech: react_native_nfc_manager.NfcTech
|
|
168
|
+
readonly tech: react_native_nfc_manager.NfcTech[];
|
|
184
169
|
readonly utils: typeof utils;
|
|
185
170
|
readonly transceive: typeof transceive;
|
|
186
171
|
readonly readBlock: typeof readBlock$1;
|
|
@@ -229,27 +214,24 @@ declare const nfc: {
|
|
|
229
214
|
};
|
|
230
215
|
};
|
|
231
216
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
declare function NfcProvider({ children }: PropsWithChildren): react_jsx_runtime.JSX.Element;
|
|
237
|
-
declare function useNfcContext(): NfcContextValue;
|
|
238
|
-
|
|
239
|
-
declare function useNfc(onTag: (tagId: string) => void, options: {
|
|
240
|
-
cooldownMs?: number;
|
|
241
|
-
}): void;
|
|
217
|
+
declare function useNfcTech(tech: NfcTech[], withTechnology: () => Promise<void>, afterTechnology?: () => Promise<void>, options?: RegisterTagEventOpts): {
|
|
218
|
+
startTech: () => void;
|
|
219
|
+
};
|
|
242
220
|
|
|
243
|
-
declare function
|
|
244
|
-
start: (
|
|
245
|
-
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;
|
|
246
225
|
};
|
|
247
226
|
|
|
248
|
-
declare function
|
|
227
|
+
declare function useNfcTagEvent(onTag: (tag: TagEvent) => Promise<void>): {
|
|
228
|
+
startTech: () => void;
|
|
229
|
+
};
|
|
249
230
|
|
|
250
|
-
declare function
|
|
251
|
-
|
|
252
|
-
|
|
231
|
+
declare function useNfcTagEventLoop(onTag: (tag: TagEvent) => Promise<void>, options?: RegisterTagEventOpts): {
|
|
232
|
+
start: () => Promise<void>;
|
|
233
|
+
stop: () => Promise<void>;
|
|
234
|
+
isRunning: boolean;
|
|
253
235
|
};
|
|
254
236
|
|
|
255
|
-
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 };
|