Skip to content

Commit

Permalink
Add trait NDEFReadingEventInit and other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioPinheiro committed Sep 29, 2023
1 parent 4f7043a commit 65a35e3
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 61 deletions.
56 changes: 31 additions & 25 deletions api-reports/2_12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16464,7 +16464,7 @@ MutationRecord[JT] def previousSibling: Node
MutationRecord[JT] def removedNodes: NodeList[Node]
MutationRecord[JT] def target: Node
MutationRecord[JT] def `type`: String
NDEFMessage[JC] var records: FrozenArray[NDEFRecord]
NDEFMessage[JC] def records: FrozenArray[NDEFRecord]
NDEFReader[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
NDEFReader[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
NDEFReader[JC] def dispatchEvent(evt: Event): Boolean
Expand All @@ -16482,35 +16482,41 @@ NDEFReader[JC] def write(message: js.typedarray.ArrayBuffer, options: NDEFWriteO
NDEFReader[JC] def write(message: js.typedarray.DataView): js.Promise[Unit]
NDEFReader[JC] def write(message: js.typedarray.DataView, options: NDEFWriteOptions): js.Promise[Unit]
NDEFReader[JC] def write(message: js.typedarray.TypedArray[_, _], options: NDEFWriteOptions?): js.Promise[Unit]
NDEFReadingEvent[JT] def bubbles: Boolean
NDEFReadingEvent[JT] def cancelBubble: Boolean
NDEFReadingEvent[JT] def cancelable: Boolean
NDEFReadingEvent[JT] def composed: Boolean
NDEFReadingEvent[JT] def currentTarget: EventTarget
NDEFReadingEvent[JT] def defaultPrevented: Boolean
NDEFReadingEvent[JT] def eventPhase: Int
NDEFReadingEvent[JT] def isTrusted: Boolean
NDEFReadingEvent[JT] var message: NDEFMessage
NDEFReadingEvent[JT] def preventDefault(): Unit
NDEFReadingEvent[JT] var serialNumber: String
NDEFReadingEvent[JT] def stopImmediatePropagation(): Unit
NDEFReadingEvent[JT] def stopPropagation(): Unit
NDEFReadingEvent[JT] def target: EventTarget
NDEFReadingEvent[JT] def timeStamp: Double
NDEFReadingEvent[JT] def `type`: String
NDEFRecord[JC] var data: js.typedarray.DataView
NDEFRecord[JC] var encoding: js.UndefOr[String]
NDEFRecord[JC] var id: js.UndefOr[String]
NDEFRecord[JC] var lang: js.UndefOr[String]
NDEFRecord[JC] var mediaType: js.UndefOr[String]
NDEFRecord[JC] var recordType: String
NDEFRecord[JC] def toRecords(): js.Array[NDEFRecord]
NDEFReadingEvent[JC] def bubbles: Boolean
NDEFReadingEvent[JC] def cancelBubble: Boolean
NDEFReadingEvent[JC] def cancelable: Boolean
NDEFReadingEvent[JC] def composed: Boolean
NDEFReadingEvent[JC] def currentTarget: EventTarget
NDEFReadingEvent[JC] def defaultPrevented: Boolean
NDEFReadingEvent[JC] def eventPhase: Int
NDEFReadingEvent[JC] def isTrusted: Boolean
NDEFReadingEvent[JC] def message: NDEFMessage
NDEFReadingEvent[JC] def preventDefault(): Unit
NDEFReadingEvent[JC] def serialNumber: String
NDEFReadingEvent[JC] def stopImmediatePropagation(): Unit
NDEFReadingEvent[JC] def stopPropagation(): Unit
NDEFReadingEvent[JC] def target: EventTarget
NDEFReadingEvent[JC] def timeStamp: Double
NDEFReadingEvent[JC] def `type`: String
NDEFReadingEventInit[JT] var bubbles: js.UndefOr[Boolean]
NDEFReadingEventInit[JT] var cancelable: js.UndefOr[Boolean]
NDEFReadingEventInit[JT] var composed: js.UndefOr[Boolean]
NDEFReadingEventInit[JT] var message: NDEFRecordInit
NDEFReadingEventInit[JT] var scoped: js.UndefOr[Boolean]
NDEFReadingEventInit[JT] var serialNumber: js.UndefOr[AbortSignal]
NDEFRecord[JC] def data: js.typedarray.DataView
NDEFRecord[JC] def encoding: js.UndefOr[String]
NDEFRecord[JC] def id: js.UndefOr[String]
NDEFRecord[JC] def lang: js.UndefOr[String]
NDEFRecord[JC] def mediaType: js.UndefOr[String]
NDEFRecord[JC] def recordType: String
NDEFRecord[JC] def toRecords(): js.UndefOr[js.Array[NDEFRecord]]
NDEFRecordInit[JT] var data: js.UndefOr[String | js.typedarray.DataView | js.typedarray.ArrayBuffer | js.typedarray.TypedArray[_, _] | js.typedarray.DataView | js.Array[NDEFRecord]]
NDEFRecordInit[JT] var encoding: js.UndefOr[String]
NDEFRecordInit[JT] var id: js.UndefOr[String]
NDEFRecordInit[JT] var lang: js.UndefOr[String]
NDEFRecordInit[JT] var mediaType: js.UndefOr[String]
NDEFRecordInit[JT] var recordType: js.UndefOr[String]
NDEFRecordInit[JT] var recordType: String
NDEFScanOptions[JT] var signal: js.UndefOr[AbortSignal]
NDEFWriteOptions[JT] var overwrite: js.UndefOr[Boolean]
NDEFWriteOptions[JT] var signal: js.UndefOr[AbortSignal]
Expand Down
56 changes: 31 additions & 25 deletions api-reports/2_13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16464,7 +16464,7 @@ MutationRecord[JT] def previousSibling: Node
MutationRecord[JT] def removedNodes: NodeList[Node]
MutationRecord[JT] def target: Node
MutationRecord[JT] def `type`: String
NDEFMessage[JC] var records: FrozenArray[NDEFRecord]
NDEFMessage[JC] def records: FrozenArray[NDEFRecord]
NDEFReader[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
NDEFReader[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
NDEFReader[JC] def dispatchEvent(evt: Event): Boolean
Expand All @@ -16482,35 +16482,41 @@ NDEFReader[JC] def write(message: js.typedarray.ArrayBuffer, options: NDEFWriteO
NDEFReader[JC] def write(message: js.typedarray.DataView): js.Promise[Unit]
NDEFReader[JC] def write(message: js.typedarray.DataView, options: NDEFWriteOptions): js.Promise[Unit]
NDEFReader[JC] def write(message: js.typedarray.TypedArray[_, _], options: NDEFWriteOptions?): js.Promise[Unit]
NDEFReadingEvent[JT] def bubbles: Boolean
NDEFReadingEvent[JT] def cancelBubble: Boolean
NDEFReadingEvent[JT] def cancelable: Boolean
NDEFReadingEvent[JT] def composed: Boolean
NDEFReadingEvent[JT] def currentTarget: EventTarget
NDEFReadingEvent[JT] def defaultPrevented: Boolean
NDEFReadingEvent[JT] def eventPhase: Int
NDEFReadingEvent[JT] def isTrusted: Boolean
NDEFReadingEvent[JT] var message: NDEFMessage
NDEFReadingEvent[JT] def preventDefault(): Unit
NDEFReadingEvent[JT] var serialNumber: String
NDEFReadingEvent[JT] def stopImmediatePropagation(): Unit
NDEFReadingEvent[JT] def stopPropagation(): Unit
NDEFReadingEvent[JT] def target: EventTarget
NDEFReadingEvent[JT] def timeStamp: Double
NDEFReadingEvent[JT] def `type`: String
NDEFRecord[JC] var data: js.typedarray.DataView
NDEFRecord[JC] var encoding: js.UndefOr[String]
NDEFRecord[JC] var id: js.UndefOr[String]
NDEFRecord[JC] var lang: js.UndefOr[String]
NDEFRecord[JC] var mediaType: js.UndefOr[String]
NDEFRecord[JC] var recordType: String
NDEFRecord[JC] def toRecords(): js.Array[NDEFRecord]
NDEFReadingEvent[JC] def bubbles: Boolean
NDEFReadingEvent[JC] def cancelBubble: Boolean
NDEFReadingEvent[JC] def cancelable: Boolean
NDEFReadingEvent[JC] def composed: Boolean
NDEFReadingEvent[JC] def currentTarget: EventTarget
NDEFReadingEvent[JC] def defaultPrevented: Boolean
NDEFReadingEvent[JC] def eventPhase: Int
NDEFReadingEvent[JC] def isTrusted: Boolean
NDEFReadingEvent[JC] def message: NDEFMessage
NDEFReadingEvent[JC] def preventDefault(): Unit
NDEFReadingEvent[JC] def serialNumber: String
NDEFReadingEvent[JC] def stopImmediatePropagation(): Unit
NDEFReadingEvent[JC] def stopPropagation(): Unit
NDEFReadingEvent[JC] def target: EventTarget
NDEFReadingEvent[JC] def timeStamp: Double
NDEFReadingEvent[JC] def `type`: String
NDEFReadingEventInit[JT] var bubbles: js.UndefOr[Boolean]
NDEFReadingEventInit[JT] var cancelable: js.UndefOr[Boolean]
NDEFReadingEventInit[JT] var composed: js.UndefOr[Boolean]
NDEFReadingEventInit[JT] var message: NDEFRecordInit
NDEFReadingEventInit[JT] var scoped: js.UndefOr[Boolean]
NDEFReadingEventInit[JT] var serialNumber: js.UndefOr[AbortSignal]
NDEFRecord[JC] def data: js.typedarray.DataView
NDEFRecord[JC] def encoding: js.UndefOr[String]
NDEFRecord[JC] def id: js.UndefOr[String]
NDEFRecord[JC] def lang: js.UndefOr[String]
NDEFRecord[JC] def mediaType: js.UndefOr[String]
NDEFRecord[JC] def recordType: String
NDEFRecord[JC] def toRecords(): js.UndefOr[js.Array[NDEFRecord]]
NDEFRecordInit[JT] var data: js.UndefOr[String | js.typedarray.DataView | js.typedarray.ArrayBuffer | js.typedarray.TypedArray[_, _] | js.typedarray.DataView | js.Array[NDEFRecord]]
NDEFRecordInit[JT] var encoding: js.UndefOr[String]
NDEFRecordInit[JT] var id: js.UndefOr[String]
NDEFRecordInit[JT] var lang: js.UndefOr[String]
NDEFRecordInit[JT] var mediaType: js.UndefOr[String]
NDEFRecordInit[JT] var recordType: js.UndefOr[String]
NDEFRecordInit[JT] var recordType: String
NDEFScanOptions[JT] var signal: js.UndefOr[AbortSignal]
NDEFWriteOptions[JT] var overwrite: js.UndefOr[Boolean]
NDEFWriteOptions[JT] var signal: js.UndefOr[AbortSignal]
Expand Down
9 changes: 6 additions & 3 deletions dom/src/main/scala/org/scalajs/dom/NDEFMessage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import scala.scalajs.js.annotation.JSGlobal
* or could be written to an NFC tag. An instance is acquired by calling the NDEFMessage() constructor or from the
* NDEFReadingEvent.message property, which is passed to the reading event.
*
* @param records
* The records property of NDEFMessage interface represents a list of NDEFRecords present in the NDEF message.
* @see
* https://w3c.github.io/web-nfc/#the-ndefmessage-interface
*
* @param messageInit
* property of NDEFMessage interface represents a list of NDEFRecords present in the NDEF message.
*/
@js.native
@JSGlobal
class NDEFMessage(recordsAgr: js.Array[NDEFRecordInit]) extends js.Object {
class NDEFMessage(messageInit: js.Array[NDEFRecordInit]) extends js.Object {

/** Returns the list of NDEF records contained in the message. */
def records: FrozenArray[NDEFRecord] = js.native
Expand Down
3 changes: 3 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/NDEFReader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import scala.scalajs.js.annotation.JSGlobal
/** The [[NDEFReader]] interface of the Web NFC API (https://developer.mozilla.org/en-US/docs/Web/API/Web_NFC_API) is
* used to read from and write data to compatible NFC devices, e.g. NFC tags supporting NDEF, when these devices are
* within the reader's magnetic induction field.
*
* @see
* https://w3c.github.io/web-nfc/#the-ndefreader-object
*/
@JSGlobal("NDEFReader")
@js.native
Expand Down
7 changes: 5 additions & 2 deletions dom/src/main/scala/org/scalajs/dom/NDEFReadingEvent.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package org.scalajs.dom

import scala.scalajs.js
import scala.scalajs.js.annotation.JSGlobal

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

/** Returns an NDEFMessage object containing the received message. */
def message: NDEFMessage = js.native
Expand All @@ -18,5 +22,4 @@ trait NDEFReadingEvent extends Event {
* if no serial number is available.
*/
def serialNumber: String = js.native

}
24 changes: 24 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/NDEFReadingEventInit.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.scalajs.dom

import scala.scalajs.js

/** NDEFReadingEventInit is used to initialize a new event with a serial number and the NDEFMessageInit data via the
* message member. If serialNumber is not present or is null, empty string will be used to init the event.
*
* @see
* https://developer.mozilla.org/en-US/docs/Web/API/NDEFReadingEvent/NDEFReadingEvent#parameters
* @see
* https://w3c.github.io/web-nfc/#the-ndefreader-object
*/
trait NDEFReadingEventInit extends EventInit {

/** A string with the name of the event. It is case-sensitive and browsers always set it to reading. Default is "" an
* empty string
*/
var serialNumber: js.UndefOr[AbortSignal] = js.undefined

/** An object that, in addition of the properties defined in Event(), can have the following properties: serialNumber;
* message
*/
var message: NDEFRecordInit
}
7 changes: 5 additions & 2 deletions dom/src/main/scala/org/scalajs/dom/NDEFRecord.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import scala.scalajs.js.annotation.JSGlobal

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

/** Returns the record type of the record. Records must have either a standardized well-known type name such as
* "empty", "text", "url", "smart-poster", "absolute-url", "mime", or "unknown" or else an external type name, which
Expand Down Expand Up @@ -37,5 +40,5 @@ class NDEFRecord(options: NDEFRecordInit) extends js.Object {
/** Converts [[NDEFRecord.data]] to a sequence of records. This allows parsing the payloads of record types which may
* contain nested records, such as smart poster and external type records.
*/
def toRecords(): js.Array[NDEFRecord] = js.native
def toRecords(): js.UndefOr[js.Array[NDEFRecord]] = js.native
}
8 changes: 6 additions & 2 deletions dom/src/main/scala/org/scalajs/dom/NDEFRecordInit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ package org.scalajs.dom
import scala.scalajs.js
import scala.scalajs.js.|

/** @see
/** The NDEFRecordInit dictionary is used to initialize an NDEF record with its record type recordType, and optional
* record identifier id and payload data data.
* @see
* https://developer.mozilla.org/en-US/docs/Web/API/NDEFMessage/NDEFMessage
* @see
* https://developer.mozilla.org/en-US/docs/Web/API/NDEFRecord/NDEFRecord
* @see
* https://w3c.github.io/web-nfc/#the-ndefrecord-interface
*/
trait NDEFRecordInit extends js.Object {

Expand Down Expand Up @@ -47,5 +51,5 @@ trait NDEFRecordInit extends js.Object {
* - "unknown" - The record type is not known.
* - "URL" - A URL as defined by the NDEF-URI specification.
*/
var recordType: js.UndefOr[String] = js.undefined
var recordType: String
}
1 change: 1 addition & 0 deletions dom/src/main/scala/org/scalajs/dom/NDEFScanOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.scalajs.dom

import scala.scalajs.js

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

/** An AbortSignal that allows the current write operation to be canceled. */
Expand Down
9 changes: 7 additions & 2 deletions dom/src/main/scala/org/scalajs/dom/NDEFWriteOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ package org.scalajs.dom

import scala.scalajs.js

/** @see https://developer.mozilla.org/en-US/docs/Web/API/NDEFReader/write */
/** @see
* https://w3c.github.io/web-nfc/#the-ndefwriteoptions-dictionary
* @see
* https://developer.mozilla.org/en-US/docs/Web/API/NDEFReader/write
*/
trait NDEFWriteOptions extends js.Object {

/** A boolean value specifying whether or not existing records should be overwritten, if such exists. */
/** A boolean value specifying whether or not existing records should be overwritten, if such exists. Default is true
*/
var `overwrite`: js.UndefOr[Boolean] = js.undefined

/** An AbortSignal that allows the current write operation to be canceled. */
Expand Down

0 comments on commit 65a35e3

Please sign in to comment.