Skip to content

Commit 07fd6ce

Browse files
committed
Reflect changes in scala-js/scala-js-dom#806 after review
1 parent e6586e2 commit 07fd6ce

File tree

6 files changed

+43
-23
lines changed

6 files changed

+43
-23
lines changed

webapp/src/main/scala/org/scalajs/dom/NDEFMessage.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ import scala.scalajs.js.annotation.JSGlobal
77
* or could be written to an NFC tag. An instance is acquired by calling the NDEFMessage() constructor or from the
88
* NDEFReadingEvent.message property, which is passed to the reading event.
99
*
10-
* @param records
11-
* The records property of NDEFMessage interface represents a list of NDEFRecords present in the NDEF message.
10+
* @see
11+
* https://w3c.github.io/web-nfc/#the-ndefmessage-interface
12+
*
13+
* @param messageInit
14+
* property of NDEFMessage interface represents a list of NDEFRecords present in the NDEF message.
1215
*/
1316
@js.native
1417
@JSGlobal
15-
class NDEFMessage extends js.Object {
18+
class NDEFMessage(messageInit: js.Array[NDEFRecordInit]) extends js.Object {
1619

1720
/** Returns the list of NDEF records contained in the message. */
18-
var records: FrozenArray[NDEFRecord] = js.native
21+
def records: FrozenArray[NDEFRecord] = js.native
1922
}

webapp/src/main/scala/org/scalajs/dom/NDEFReader.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import scala.scalajs.js.annotation.JSGlobal
66
/** The [[NDEFReader]] interface of the Web NFC API (https://developer.mozilla.org/en-US/docs/Web/API/Web_NFC_API) is
77
* used to read from and write data to compatible NFC devices, e.g. NFC tags supporting NDEF, when these devices are
88
* within the reader's magnetic induction field.
9+
*
10+
* @see
11+
* https://w3c.github.io/web-nfc/#the-ndefreader-object
912
*/
1013
@JSGlobal("NDEFReader")
1114
@js.native
@@ -36,7 +39,9 @@ class NDEFReader() extends EventTarget {
3639
*/
3740
def write(message: String, options: NDEFWriteOptions): js.Promise[Unit] = js.native
3841
def write(message: js.typedarray.ArrayBuffer, options: NDEFWriteOptions): js.Promise[Unit] = js.native
39-
// def write(message:js.typedarray.TypedArray[NDEFRecord, ???] , options: NDEFWriteOptions = js.native): js.Promise[Unit] = js.native
42+
43+
def write(message: js.typedarray.TypedArray[_, _],
44+
options: NDEFWriteOptions = js.native): js.Promise[Unit] = js.native
4045
def write(message: js.typedarray.DataView, options: NDEFWriteOptions): js.Promise[Unit] = js.native
4146
def write(message: js.Array[NDEFRecord], options: NDEFWriteOptions): js.Promise[Unit] = js.native
4247

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
package org.scalajs.dom
22

33
import scala.scalajs.js
4+
import scala.scalajs.js.annotation.JSGlobal
45

56
/** The NDEFReadingEvent interface of the Web NFC API represents events dispatched on new NFC readings obtained by
67
* NDEFReader.
78
*
89
* @see
910
* https://developer.mozilla.org/en-US/docs/Web/API/NDEFReadingEvent
11+
* @see
12+
* https://w3c.github.io/web-nfc/#the-ndefreader-object
1013
*/
1114
@js.native
12-
trait NDEFReadingEvent extends Event {
15+
@JSGlobal
16+
class NDEFReadingEvent(typeArg: String, init: NDEFReadingEventInit) extends Event(typeArg, init) {
1317

1418
/** Returns an NDEFMessage object containing the received message. */
15-
var message: NDEFMessage = js.native
19+
def message: NDEFMessage = js.native
1620

1721
/** Returns the serial number of the device, which is used for anti-collision and identification, or an empty string
1822
* if no serial number is available.
1923
*/
20-
var serialNumber: String = js.native
21-
24+
def serialNumber: String = js.native
2225
}

webapp/src/main/scala/org/scalajs/dom/NDEFRecord.scala

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,40 @@ import scala.scalajs.js.annotation.JSGlobal
55

66
/** The [[NDEFRecord]] interface of the Web NFC API provides data that can be read from, or written to, compatible NFC
77
* devices, e.g. NFC tags supporting NDEF.
8+
*
9+
* @see
10+
* https://w3c.github.io/web-nfc/#the-ndefrecord-interface
811
*/
912
@js.native
1013
@JSGlobal
11-
class NDEFRecord extends js.Object {
14+
class NDEFRecord(init: NDEFRecordInit) extends js.Object {
1215

1316
/** Returns the record type of the record. Records must have either a standardized well-known type name such as
1417
* "empty", "text", "url", "smart-poster", "absolute-url", "mime", or "unknown" or else an external type name, which
1518
* consists of a domain name and custom type name separated by a colon (":").
1619
*/
17-
var recordType: String = js.native
20+
def recordType: String = js.native
1821

1922
/** Returns the MIME type of the record. This value will be null if recordType is not equal to "mime". */
20-
var mediaType: js.UndefOr[String] = js.native
23+
def mediaType: js.UndefOr[String] = js.native
2124

2225
/** Returns the record identifier, which is an absolute or relative URL used to identify the record.
2326
*
2427
* Note: The uniqueness of the identifier is enforced only by the generator of the record.
2528
*/
26-
var id: js.UndefOr[String] = js.native
29+
def id: js.UndefOr[String] = js.native
2730

2831
/** Returns a DataView containing the raw bytes of the record's payload. */
29-
var data: js.typedarray.DataView = js.native
32+
def data: js.typedarray.DataView = js.native
3033

3134
/** Returns the encoding of a textual payload, or null otherwise. */
32-
var encoding: js.UndefOr[String] = js.native
35+
def encoding: js.UndefOr[String] = js.native
3336

3437
/** Returns the language of a textual payload, or null if one was not supplied. */
35-
var lang: js.UndefOr[String] = js.native
38+
def lang: js.UndefOr[String] = js.native
3639

3740
/** Converts [[NDEFRecord.data]] to a sequence of records. This allows parsing the payloads of record types which may
3841
* contain nested records, such as smart poster and external type records.
3942
*/
40-
def toRecords(): js.Array[NDEFRecord] = js.native
43+
def toRecords(): js.UndefOr[js.Array[NDEFRecord]] = js.native
4144
}

webapp/src/main/scala/org/scalajs/dom/NDEFScanOptions.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package org.scalajs.dom
22

33
import scala.scalajs.js
44

5-
@js.native
5+
/** @see https://w3c.github.io/web-nfc/#the-ndefscanoptions-dictionary */
66
trait NDEFScanOptions extends js.Object {
77

88
/** An AbortSignal that allows the current write operation to be canceled. */
9-
def `signal`: js.UndefOr[AbortSignal] = js.native
9+
var `signal`: js.UndefOr[AbortSignal] = js.undefined
1010
}

webapp/src/main/scala/org/scalajs/dom/NDEFWriteOptions.scala

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ package org.scalajs.dom
22

33
import scala.scalajs.js
44

5-
@js.native
5+
/** @see
6+
* https://w3c.github.io/web-nfc/#the-ndefwriteoptions-dictionary
7+
* @see
8+
* https://developer.mozilla.org/en-US/docs/Web/API/NDEFReader/write
9+
*/
610
trait NDEFWriteOptions extends js.Object {
711

8-
/** A boolean value specifying whether or not existing records should be overwritten, if such exists. */
9-
def `overwrite`: Boolean = js.native
12+
/** A boolean value specifying whether or not existing records should be overwritten, if such exists. Default is true
13+
*/
14+
var `overwrite`: js.UndefOr[Boolean] = js.undefined
1015

1116
/** An AbortSignal that allows the current write operation to be canceled. */
12-
def `signal`: js.UndefOr[AbortSignal] = js.native
17+
var `signal`: js.UndefOr[AbortSignal] = js.undefined
18+
1319
}

0 commit comments

Comments
 (0)