@tauri-apps/plugin-nfc
Advanced tools
+49
-49
@@ -36,12 +36,12 @@ 'use strict'; | ||
| format, | ||
| kind: typeof kind === "string" | ||
| kind: typeof kind === 'string' | ||
| ? Array.from(new TextEncoder().encode(kind)) | ||
| : kind, | ||
| id: typeof id === "string" ? Array.from(new TextEncoder().encode(id)) : id, | ||
| payload: typeof payload === "string" | ||
| id: typeof id === 'string' ? Array.from(new TextEncoder().encode(id)) : id, | ||
| payload: typeof payload === 'string' | ||
| ? Array.from(new TextEncoder().encode(payload)) | ||
| : payload, | ||
| : payload | ||
| }; | ||
| } | ||
| function textRecord(text, id, language = "en") { | ||
| function textRecord(text, id, language = 'en') { | ||
| const payload = Array.from(new TextEncoder().encode(language + text)); | ||
@@ -52,43 +52,43 @@ payload.unshift(language.length); | ||
| const protocols = [ | ||
| "", | ||
| "http://www.", | ||
| "https://www.", | ||
| "http://", | ||
| "https://", | ||
| "tel:", | ||
| "mailto:", | ||
| "ftp://anonymous:anonymous@", | ||
| "ftp://ftp.", | ||
| "ftps://", | ||
| "sftp://", | ||
| "smb://", | ||
| "nfs://", | ||
| "ftp://", | ||
| "dav://", | ||
| "news:", | ||
| "telnet://", | ||
| "imap:", | ||
| "rtsp://", | ||
| "urn:", | ||
| "pop:", | ||
| "sip:", | ||
| "sips:", | ||
| "tftp:", | ||
| "btspp://", | ||
| "btl2cap://", | ||
| "btgoep://", | ||
| "tcpobex://", | ||
| "irdaobex://", | ||
| "file://", | ||
| "urn:epc:id:", | ||
| "urn:epc:tag:", | ||
| "urn:epc:pat:", | ||
| "urn:epc:raw:", | ||
| "urn:epc:", | ||
| "urn:nfc:", | ||
| '', | ||
| 'http://www.', | ||
| 'https://www.', | ||
| 'http://', | ||
| 'https://', | ||
| 'tel:', | ||
| 'mailto:', | ||
| 'ftp://anonymous:anonymous@', | ||
| 'ftp://ftp.', | ||
| 'ftps://', | ||
| 'sftp://', | ||
| 'smb://', | ||
| 'nfs://', | ||
| 'ftp://', | ||
| 'dav://', | ||
| 'news:', | ||
| 'telnet://', | ||
| 'imap:', | ||
| 'rtsp://', | ||
| 'urn:', | ||
| 'pop:', | ||
| 'sip:', | ||
| 'sips:', | ||
| 'tftp:', | ||
| 'btspp://', | ||
| 'btl2cap://', | ||
| 'btgoep://', | ||
| 'tcpobex://', | ||
| 'irdaobex://', | ||
| 'file://', | ||
| 'urn:epc:id:', | ||
| 'urn:epc:tag:', | ||
| 'urn:epc:pat:', | ||
| 'urn:epc:raw:', | ||
| 'urn:epc:', | ||
| 'urn:nfc:' | ||
| ]; | ||
| function encodeURI(uri) { | ||
| let prefix = ""; | ||
| let prefix = ''; | ||
| protocols.slice(1).forEach(function (protocol) { | ||
| if ((prefix.length === 0 || prefix === "urn:") && | ||
| if ((prefix.length === 0 || prefix === 'urn:') && | ||
| uri.indexOf(protocol) === 0) { | ||
@@ -99,3 +99,3 @@ prefix = protocol; | ||
| if (prefix.length === 0) { | ||
| prefix = ""; | ||
| prefix = ''; | ||
| } | ||
@@ -130,5 +130,5 @@ const encoded = Array.from(new TextEncoder().encode(uri.slice(prefix.length))); | ||
| async function scan(kind, options) { | ||
| return await core.invoke("plugin:nfc|scan", { | ||
| return await core.invoke('plugin:nfc|scan', { | ||
| kind: mapScanKind(kind), | ||
| ...options, | ||
| ...options | ||
| }); | ||
@@ -157,9 +157,9 @@ } | ||
| } | ||
| await core.invoke("plugin:nfc|write", { | ||
| await core.invoke('plugin:nfc|write', { | ||
| records, | ||
| ...opts, | ||
| ...opts | ||
| }); | ||
| } | ||
| async function isAvailable() { | ||
| return await core.invoke("plugin:nfc|is_available"); | ||
| return await core.invoke('plugin:nfc|is_available'); | ||
| } | ||
@@ -166,0 +166,0 @@ |
@@ -21,7 +21,7 @@ export declare const RTD_TEXT: number[]; | ||
| export type ScanKind = { | ||
| type: "tag"; | ||
| type: 'tag'; | ||
| uri?: UriFilter; | ||
| mimeType?: string; | ||
| } | { | ||
| type: "ndef"; | ||
| type: 'ndef'; | ||
| uri?: UriFilter; | ||
@@ -28,0 +28,0 @@ mimeType?: string; |
+49
-49
@@ -34,12 +34,12 @@ import { invoke } from '@tauri-apps/api/core'; | ||
| format, | ||
| kind: typeof kind === "string" | ||
| kind: typeof kind === 'string' | ||
| ? Array.from(new TextEncoder().encode(kind)) | ||
| : kind, | ||
| id: typeof id === "string" ? Array.from(new TextEncoder().encode(id)) : id, | ||
| payload: typeof payload === "string" | ||
| id: typeof id === 'string' ? Array.from(new TextEncoder().encode(id)) : id, | ||
| payload: typeof payload === 'string' | ||
| ? Array.from(new TextEncoder().encode(payload)) | ||
| : payload, | ||
| : payload | ||
| }; | ||
| } | ||
| function textRecord(text, id, language = "en") { | ||
| function textRecord(text, id, language = 'en') { | ||
| const payload = Array.from(new TextEncoder().encode(language + text)); | ||
@@ -50,43 +50,43 @@ payload.unshift(language.length); | ||
| const protocols = [ | ||
| "", | ||
| "http://www.", | ||
| "https://www.", | ||
| "http://", | ||
| "https://", | ||
| "tel:", | ||
| "mailto:", | ||
| "ftp://anonymous:anonymous@", | ||
| "ftp://ftp.", | ||
| "ftps://", | ||
| "sftp://", | ||
| "smb://", | ||
| "nfs://", | ||
| "ftp://", | ||
| "dav://", | ||
| "news:", | ||
| "telnet://", | ||
| "imap:", | ||
| "rtsp://", | ||
| "urn:", | ||
| "pop:", | ||
| "sip:", | ||
| "sips:", | ||
| "tftp:", | ||
| "btspp://", | ||
| "btl2cap://", | ||
| "btgoep://", | ||
| "tcpobex://", | ||
| "irdaobex://", | ||
| "file://", | ||
| "urn:epc:id:", | ||
| "urn:epc:tag:", | ||
| "urn:epc:pat:", | ||
| "urn:epc:raw:", | ||
| "urn:epc:", | ||
| "urn:nfc:", | ||
| '', | ||
| 'http://www.', | ||
| 'https://www.', | ||
| 'http://', | ||
| 'https://', | ||
| 'tel:', | ||
| 'mailto:', | ||
| 'ftp://anonymous:anonymous@', | ||
| 'ftp://ftp.', | ||
| 'ftps://', | ||
| 'sftp://', | ||
| 'smb://', | ||
| 'nfs://', | ||
| 'ftp://', | ||
| 'dav://', | ||
| 'news:', | ||
| 'telnet://', | ||
| 'imap:', | ||
| 'rtsp://', | ||
| 'urn:', | ||
| 'pop:', | ||
| 'sip:', | ||
| 'sips:', | ||
| 'tftp:', | ||
| 'btspp://', | ||
| 'btl2cap://', | ||
| 'btgoep://', | ||
| 'tcpobex://', | ||
| 'irdaobex://', | ||
| 'file://', | ||
| 'urn:epc:id:', | ||
| 'urn:epc:tag:', | ||
| 'urn:epc:pat:', | ||
| 'urn:epc:raw:', | ||
| 'urn:epc:', | ||
| 'urn:nfc:' | ||
| ]; | ||
| function encodeURI(uri) { | ||
| let prefix = ""; | ||
| let prefix = ''; | ||
| protocols.slice(1).forEach(function (protocol) { | ||
| if ((prefix.length === 0 || prefix === "urn:") && | ||
| if ((prefix.length === 0 || prefix === 'urn:') && | ||
| uri.indexOf(protocol) === 0) { | ||
@@ -97,3 +97,3 @@ prefix = protocol; | ||
| if (prefix.length === 0) { | ||
| prefix = ""; | ||
| prefix = ''; | ||
| } | ||
@@ -128,5 +128,5 @@ const encoded = Array.from(new TextEncoder().encode(uri.slice(prefix.length))); | ||
| async function scan(kind, options) { | ||
| return await invoke("plugin:nfc|scan", { | ||
| return await invoke('plugin:nfc|scan', { | ||
| kind: mapScanKind(kind), | ||
| ...options, | ||
| ...options | ||
| }); | ||
@@ -155,11 +155,11 @@ } | ||
| } | ||
| await invoke("plugin:nfc|write", { | ||
| await invoke('plugin:nfc|write', { | ||
| records, | ||
| ...opts, | ||
| ...opts | ||
| }); | ||
| } | ||
| async function isAvailable() { | ||
| return await invoke("plugin:nfc|is_available"); | ||
| return await invoke('plugin:nfc|is_available'); | ||
| } | ||
| export { NFCTypeNameFormat, RTD_TEXT, RTD_URI, TechKind, isAvailable, record, scan, textRecord, uriRecord, write }; |
+3
-3
| { | ||
| "name": "@tauri-apps/plugin-nfc", | ||
| "version": "2.0.0-rc.1", | ||
| "license": "MIT or APACHE-2.0", | ||
| "version": "2.0.0", | ||
| "license": "MIT OR Apache-2.0", | ||
| "authors": [ | ||
@@ -28,4 +28,4 @@ "Tauri Programme within The Commons Conservancy" | ||
| "dependencies": { | ||
| "@tauri-apps/api": "^2.0.0-rc.4" | ||
| "@tauri-apps/api": "^2.0.0" | ||
| } | ||
| } |
+12
-4
@@ -5,2 +5,10 @@  | ||
| | Platform | Supported | | ||
| | -------- | --------- | | ||
| | Linux | x | | ||
| | Windows | x | | ||
| | macOS | x | | ||
| | Android | ✓ | | ||
| | iOS | ✓ | | ||
| ## Install | ||
@@ -22,3 +30,3 @@ | ||
| [dependencies] | ||
| tauri-plugin-nfc = "2.0.0-rc" | ||
| tauri-plugin-nfc = "2.0.0" | ||
| # alternatively with Git: | ||
@@ -67,5 +75,5 @@ tauri-plugin-nfc = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } | ||
| ```javascript | ||
| import { scan, textRecord, write } from "@tauri-apps/plugin-nfc"; | ||
| await scan({ type: "tag", keepSessionAlive: true }); | ||
| await write([textRecord("Tauri is awesome!")]); | ||
| import { scan, textRecord, write } from '@tauri-apps/plugin-nfc' | ||
| await scan({ type: 'tag', keepSessionAlive: true }) | ||
| await write([textRecord('Tauri is awesome!')]) | ||
| ``` | ||
@@ -72,0 +80,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
18548
0.85%1
-50%122
7.02%Updated