|
| 1 | +// Type definitions for Web NFC |
| 2 | +// Project: https://github.com/w3c/web-nfc |
| 3 | +// Definitions by: Takefumi Yoshii <https://github.com/takefumi-yoshii> |
| 4 | +// TypeScript Version: 3.9 |
| 5 | + |
| 6 | +// This type definitions referenced to WebIDL. |
| 7 | +// https://w3c.github.io/web-nfc/#actual-idl-index |
| 8 | + |
| 9 | +interface Window { |
| 10 | + NDEFMEssage: NDEFMEssage |
| 11 | +} |
| 12 | +declare class NDEFMEssage { |
| 13 | + constructor(messageInit: NDEFMessageInit) |
| 14 | + readonly records: NDEFRecord[] |
| 15 | +} |
| 16 | +declare interface NDEFMessageInit { |
| 17 | + records: NDEFRecordInit[] |
| 18 | +} |
| 19 | + |
| 20 | +declare type NDEFRecordDataSource = string | BufferSource | NDEFMessageInit |
| 21 | + |
| 22 | +interface Window { |
| 23 | + NDEFRecord: NDEFRecord |
| 24 | +} |
| 25 | +declare class NDEFRecord { |
| 26 | + constructor(recordInit: NDEFRecordInit) |
| 27 | + readonly recordType: string |
| 28 | + readonly mediaType?: string |
| 29 | + readonly id?: string |
| 30 | + readonly data?: DataView |
| 31 | + readonly encoding?: string |
| 32 | + readonly lang?: string |
| 33 | + toRecords?: () => NDEFRecord[] |
| 34 | +} |
| 35 | +declare interface NDEFRecordInit { |
| 36 | + recordType: string |
| 37 | + mediaType?: string |
| 38 | + id?: string |
| 39 | + encoding?: string |
| 40 | + lang?: string |
| 41 | + data?: NDEFRecordDataSource |
| 42 | +} |
| 43 | + |
| 44 | +declare type NDEFMessageSource = string | BufferSource | NDEFMessageInit |
| 45 | + |
| 46 | +interface Window { |
| 47 | + NDEFWriter: NDEFWriter |
| 48 | +} |
| 49 | +declare class NDEFWriter { |
| 50 | + constructor() |
| 51 | + write: ( |
| 52 | + message: NDEFMessageSource, |
| 53 | + options?: NDEFWriteOptions |
| 54 | + ) => Promise<void> |
| 55 | +} |
| 56 | + |
| 57 | +interface Window { |
| 58 | + NDEFReader: NDEFReader |
| 59 | +} |
| 60 | +declare class NDEFReader extends EventTarget { |
| 61 | + constructor() |
| 62 | + onerror: (error: any) => void |
| 63 | + onreading: (event: NDEFReadingEvent) => void |
| 64 | + scan: (options?: NDEFScanOptions) => Promise<void> |
| 65 | +} |
| 66 | + |
| 67 | +interface Window { |
| 68 | + NDEFReadingEvent: NDEFReadingEvent |
| 69 | +} |
| 70 | +declare class NDEFReadingEvent extends Event { |
| 71 | + constructor(type: string, readingEventInitDict: NDEFReadingEventInit) |
| 72 | + serialNumber: string |
| 73 | + message: NDEFMEssage |
| 74 | +} |
| 75 | +interface NDEFReadingEventInit extends EventInit { |
| 76 | + serialNumber?: string |
| 77 | + message: NDEFMessageInit |
| 78 | +} |
| 79 | + |
| 80 | +interface NDEFWriteOptions { |
| 81 | + ignoreRead?: boolean |
| 82 | + overwrite?: boolean |
| 83 | + signal?: AbortSignal |
| 84 | +} |
| 85 | +interface NDEFScanOptions { |
| 86 | + id?: string |
| 87 | + recordType?: string |
| 88 | + mediaType?: string |
| 89 | + signal?: any |
| 90 | +} |
0 commit comments