Skip to content

Commit cac7c0f

Browse files
committed
Remove AnyJSValueCodable
1 parent b255366 commit cac7c0f

21 files changed

+120
-148
lines changed

Sources/DOMKit/ECMAScript/ArrayBuffer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class ArrayBuffer: JSBridgedClass {
2929
self.init(withCompatibleObject: Self.constructor.new( length))
3030
}
3131

32-
public static func isView(_ object: AnyJSValueCodable) -> Bool {
32+
public static func isView(_ object: JSValueCodable) -> Bool {
3333
return JSObject.global.ArrayBuffer.object!.isView!(object).fromJSValue()!
3434
}
3535
}

Sources/DOMKit/WebIDL/AddEventListenerOptions.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ public struct AddEventListenerOptions: ExpressibleByDictionaryLiteral, JSBridged
1010
case capture, passive, once
1111
}
1212

13-
public typealias Value = AnyJSValueCodable
13+
private let dictionary: [String: JSValue]
1414

15-
private let dictionary: [String: AnyJSValueCodable]
16-
17-
public init(uniqueKeysWithValues elements: [(Key, Value)]) {
18-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
15+
public init(uniqueKeysWithValues elements: [(Key, JSValueConvertible)]) {
16+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
1917
}
2018

21-
public init(dictionaryLiteral elements: (Key, AnyJSValueCodable)...) {
22-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
19+
public init(dictionaryLiteral elements: (Key, JSValueConvertible)...) {
20+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
2321
}
2422

25-
subscript(_ key: Key) -> AnyJSValueCodable? {
23+
subscript(_ key: Key) -> JSValue? {
2624
dictionary[key.rawValue]
2725
}
2826

2927
public init?(from value: JSValue) {
30-
if let dictionary: [String: AnyJSValueCodable] = value.fromJSValue() {
28+
if let dictionary: [String: JSValue] = value.fromJSValue() {
3129
self.dictionary = dictionary
3230
}
3331
return nil

Sources/DOMKit/WebIDL/AssignedNodesOptions.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ public struct AssignedNodesOptions: ExpressibleByDictionaryLiteral, JSBridgedTyp
1010
case flatten
1111
}
1212

13-
public typealias Value = AnyJSValueCodable
13+
private let dictionary: [String: JSValue]
1414

15-
private let dictionary: [String: AnyJSValueCodable]
16-
17-
public init(uniqueKeysWithValues elements: [(Key, Value)]) {
18-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
15+
public init(uniqueKeysWithValues elements: [(Key, JSValueConvertible)]) {
16+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
1917
}
2018

21-
public init(dictionaryLiteral elements: (Key, AnyJSValueCodable)...) {
22-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
19+
public init(dictionaryLiteral elements: (Key, JSValueConvertible)...) {
20+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
2321
}
2422

25-
subscript(_ key: Key) -> AnyJSValueCodable? {
23+
subscript(_ key: Key) -> JSValue? {
2624
dictionary[key.rawValue]
2725
}
2826

2927
public init?(from value: JSValue) {
30-
if let dictionary: [String: AnyJSValueCodable] = value.fromJSValue() {
28+
if let dictionary: [String: JSValue] = value.fromJSValue() {
3129
self.dictionary = dictionary
3230
}
3331
return nil

Sources/DOMKit/WebIDL/BlobPropertyBag.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ public struct BlobPropertyBag: ExpressibleByDictionaryLiteral, JSBridgedType {
1010
case type, endings
1111
}
1212

13-
public typealias Value = AnyJSValueCodable
13+
private let dictionary: [String: JSValue]
1414

15-
private let dictionary: [String: AnyJSValueCodable]
16-
17-
public init(uniqueKeysWithValues elements: [(Key, Value)]) {
18-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
15+
public init(uniqueKeysWithValues elements: [(Key, JSValueConvertible)]) {
16+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
1917
}
2018

21-
public init(dictionaryLiteral elements: (Key, AnyJSValueCodable)...) {
22-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
19+
public init(dictionaryLiteral elements: (Key, JSValueConvertible)...) {
20+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
2321
}
2422

25-
subscript(_ key: Key) -> AnyJSValueCodable? {
23+
subscript(_ key: Key) -> JSValue? {
2624
dictionary[key.rawValue]
2725
}
2826

2927
public init?(from value: JSValue) {
30-
if let dictionary: [String: AnyJSValueCodable] = value.fromJSValue() {
28+
if let dictionary: [String: JSValue] = value.fromJSValue() {
3129
self.dictionary = dictionary
3230
}
3331
return nil

Sources/DOMKit/WebIDL/CustomEvent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public class CustomEvent: Event {
1818
}
1919

2020
@ReadonlyAttribute
21-
public var detail: AnyJSValueCodable
21+
public var detail: JSValue
2222

23-
public func initCustomEvent(type: String, bubbles: Bool = false, cancelable: Bool = false, detail: AnyJSValueCodable = nil) {
23+
public func initCustomEvent(type: String, bubbles: Bool = false, cancelable: Bool = false, detail: JSValue = nil) {
2424
_ = jsObject.initCustomEvent!(type.jsValue(), bubbles.jsValue(), cancelable.jsValue(), detail.jsValue())
2525
}
2626
}

Sources/DOMKit/WebIDL/CustomEventInit.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ public struct CustomEventInit: ExpressibleByDictionaryLiteral, JSBridgedType {
1010
case bubbles, cancelable, composed, detail
1111
}
1212

13-
public typealias Value = AnyJSValueCodable
13+
private let dictionary: [String: JSValue]
1414

15-
private let dictionary: [String: AnyJSValueCodable]
16-
17-
public init(uniqueKeysWithValues elements: [(Key, Value)]) {
18-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
15+
public init(uniqueKeysWithValues elements: [(Key, JSValueConvertible)]) {
16+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
1917
}
2018

21-
public init(dictionaryLiteral elements: (Key, AnyJSValueCodable)...) {
22-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
19+
public init(dictionaryLiteral elements: (Key, JSValueConvertible)...) {
20+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
2321
}
2422

25-
subscript(_ key: Key) -> AnyJSValueCodable? {
23+
subscript(_ key: Key) -> JSValue? {
2624
dictionary[key.rawValue]
2725
}
2826

2927
public init?(from value: JSValue) {
30-
if let dictionary: [String: AnyJSValueCodable] = value.fromJSValue() {
28+
if let dictionary: [String: JSValue] = value.fromJSValue() {
3129
self.dictionary = dictionary
3230
}
3331
return nil

Sources/DOMKit/WebIDL/ElementCreationOptions.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ public struct ElementCreationOptions: ExpressibleByDictionaryLiteral, JSBridgedT
1010
case `is`
1111
}
1212

13-
public typealias Value = AnyJSValueCodable
13+
private let dictionary: [String: JSValue]
1414

15-
private let dictionary: [String: AnyJSValueCodable]
16-
17-
public init(uniqueKeysWithValues elements: [(Key, Value)]) {
18-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
15+
public init(uniqueKeysWithValues elements: [(Key, JSValueConvertible)]) {
16+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
1917
}
2018

21-
public init(dictionaryLiteral elements: (Key, AnyJSValueCodable)...) {
22-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
19+
public init(dictionaryLiteral elements: (Key, JSValueConvertible)...) {
20+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
2321
}
2422

25-
subscript(_ key: Key) -> AnyJSValueCodable? {
23+
subscript(_ key: Key) -> JSValue? {
2624
dictionary[key.rawValue]
2725
}
2826

2927
public init?(from value: JSValue) {
30-
if let dictionary: [String: AnyJSValueCodable] = value.fromJSValue() {
28+
if let dictionary: [String: JSValue] = value.fromJSValue() {
3129
self.dictionary = dictionary
3230
}
3331
return nil

Sources/DOMKit/WebIDL/EventHandlerNonNull.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
import JavaScriptKit
77

8-
public typealias EventHandlerNonNull = ((Event) -> AnyJSValueCodable)
8+
public typealias EventHandlerNonNull = ((Event) -> JSValue)

Sources/DOMKit/WebIDL/EventInit.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ public struct EventInit: ExpressibleByDictionaryLiteral, JSBridgedType {
1010
case bubbles, cancelable, composed
1111
}
1212

13-
public typealias Value = AnyJSValueCodable
13+
private let dictionary: [String: JSValue]
1414

15-
private let dictionary: [String: AnyJSValueCodable]
16-
17-
public init(uniqueKeysWithValues elements: [(Key, Value)]) {
18-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
15+
public init(uniqueKeysWithValues elements: [(Key, JSValueConvertible)]) {
16+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
1917
}
2018

21-
public init(dictionaryLiteral elements: (Key, AnyJSValueCodable)...) {
22-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
19+
public init(dictionaryLiteral elements: (Key, JSValueConvertible)...) {
20+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
2321
}
2422

25-
subscript(_ key: Key) -> AnyJSValueCodable? {
23+
subscript(_ key: Key) -> JSValue? {
2624
dictionary[key.rawValue]
2725
}
2826

2927
public init?(from value: JSValue) {
30-
if let dictionary: [String: AnyJSValueCodable] = value.fromJSValue() {
28+
if let dictionary: [String: JSValue] = value.fromJSValue() {
3129
self.dictionary = dictionary
3230
}
3331
return nil

Sources/DOMKit/WebIDL/EventListenerOptions.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ public struct EventListenerOptions: ExpressibleByDictionaryLiteral, JSBridgedTyp
1010
case capture
1111
}
1212

13-
public typealias Value = AnyJSValueCodable
13+
private let dictionary: [String: JSValue]
1414

15-
private let dictionary: [String: AnyJSValueCodable]
16-
17-
public init(uniqueKeysWithValues elements: [(Key, Value)]) {
18-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
15+
public init(uniqueKeysWithValues elements: [(Key, JSValueConvertible)]) {
16+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
1917
}
2018

21-
public init(dictionaryLiteral elements: (Key, AnyJSValueCodable)...) {
22-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
19+
public init(dictionaryLiteral elements: (Key, JSValueConvertible)...) {
20+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
2321
}
2422

25-
subscript(_ key: Key) -> AnyJSValueCodable? {
23+
subscript(_ key: Key) -> JSValue? {
2624
dictionary[key.rawValue]
2725
}
2826

2927
public init?(from value: JSValue) {
30-
if let dictionary: [String: AnyJSValueCodable] = value.fromJSValue() {
28+
if let dictionary: [String: JSValue] = value.fromJSValue() {
3129
self.dictionary = dictionary
3230
}
3331
return nil

Sources/DOMKit/WebIDL/FilePropertyBag.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ public struct FilePropertyBag: ExpressibleByDictionaryLiteral, JSBridgedType {
1010
case type, endings, lastModified
1111
}
1212

13-
public typealias Value = AnyJSValueCodable
13+
private let dictionary: [String: JSValue]
1414

15-
private let dictionary: [String: AnyJSValueCodable]
16-
17-
public init(uniqueKeysWithValues elements: [(Key, Value)]) {
18-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
15+
public init(uniqueKeysWithValues elements: [(Key, JSValueConvertible)]) {
16+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
1917
}
2018

21-
public init(dictionaryLiteral elements: (Key, AnyJSValueCodable)...) {
22-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
19+
public init(dictionaryLiteral elements: (Key, JSValueConvertible)...) {
20+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
2321
}
2422

25-
subscript(_ key: Key) -> AnyJSValueCodable? {
23+
subscript(_ key: Key) -> JSValue? {
2624
dictionary[key.rawValue]
2725
}
2826

2927
public init?(from value: JSValue) {
30-
if let dictionary: [String: AnyJSValueCodable] = value.fromJSValue() {
28+
if let dictionary: [String: JSValue] = value.fromJSValue() {
3129
self.dictionary = dictionary
3230
}
3331
return nil

Sources/DOMKit/WebIDL/FocusOptions.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ public struct FocusOptions: ExpressibleByDictionaryLiteral, JSBridgedType {
1010
case preventScroll
1111
}
1212

13-
public typealias Value = AnyJSValueCodable
13+
private let dictionary: [String: JSValue]
1414

15-
private let dictionary: [String: AnyJSValueCodable]
16-
17-
public init(uniqueKeysWithValues elements: [(Key, Value)]) {
18-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
15+
public init(uniqueKeysWithValues elements: [(Key, JSValueConvertible)]) {
16+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
1917
}
2018

21-
public init(dictionaryLiteral elements: (Key, AnyJSValueCodable)...) {
22-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
19+
public init(dictionaryLiteral elements: (Key, JSValueConvertible)...) {
20+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
2321
}
2422

25-
subscript(_ key: Key) -> AnyJSValueCodable? {
23+
subscript(_ key: Key) -> JSValue? {
2624
dictionary[key.rawValue]
2725
}
2826

2927
public init?(from value: JSValue) {
30-
if let dictionary: [String: AnyJSValueCodable] = value.fromJSValue() {
28+
if let dictionary: [String: JSValue] = value.fromJSValue() {
3129
self.dictionary = dictionary
3230
}
3331
return nil

Sources/DOMKit/WebIDL/Function.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
import JavaScriptKit
77

8-
public typealias Function = ((AnyJSValueCodable) -> AnyJSValueCodable)
8+
public typealias Function = ((JSValue) -> JSValue)

Sources/DOMKit/WebIDL/GetRootNodeOptions.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ public struct GetRootNodeOptions: ExpressibleByDictionaryLiteral, JSBridgedType
1010
case composed
1111
}
1212

13-
public typealias Value = AnyJSValueCodable
13+
private let dictionary: [String: JSValue]
1414

15-
private let dictionary: [String: AnyJSValueCodable]
16-
17-
public init(uniqueKeysWithValues elements: [(Key, Value)]) {
18-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
15+
public init(uniqueKeysWithValues elements: [(Key, JSValueConvertible)]) {
16+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
1917
}
2018

21-
public init(dictionaryLiteral elements: (Key, AnyJSValueCodable)...) {
22-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
19+
public init(dictionaryLiteral elements: (Key, JSValueConvertible)...) {
20+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
2321
}
2422

25-
subscript(_ key: Key) -> AnyJSValueCodable? {
23+
subscript(_ key: Key) -> JSValue? {
2624
dictionary[key.rawValue]
2725
}
2826

2927
public init?(from value: JSValue) {
30-
if let dictionary: [String: AnyJSValueCodable] = value.fromJSValue() {
28+
if let dictionary: [String: JSValue] = value.fromJSValue() {
3129
self.dictionary = dictionary
3230
}
3331
return nil

Sources/DOMKit/WebIDL/MutationObserverInit.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ public struct MutationObserverInit: ExpressibleByDictionaryLiteral, JSBridgedTyp
1010
case childList, attributes, characterData, subtree, attributeOldValue, characterDataOldValue, attributeFilter
1111
}
1212

13-
public typealias Value = AnyJSValueCodable
13+
private let dictionary: [String: JSValue]
1414

15-
private let dictionary: [String: AnyJSValueCodable]
16-
17-
public init(uniqueKeysWithValues elements: [(Key, Value)]) {
18-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
15+
public init(uniqueKeysWithValues elements: [(Key, JSValueConvertible)]) {
16+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
1917
}
2018

21-
public init(dictionaryLiteral elements: (Key, AnyJSValueCodable)...) {
22-
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
19+
public init(dictionaryLiteral elements: (Key, JSValueConvertible)...) {
20+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) })
2321
}
2422

25-
subscript(_ key: Key) -> AnyJSValueCodable? {
23+
subscript(_ key: Key) -> JSValue? {
2624
dictionary[key.rawValue]
2725
}
2826

2927
public init?(from value: JSValue) {
30-
if let dictionary: [String: AnyJSValueCodable] = value.fromJSValue() {
28+
if let dictionary: [String: JSValue] = value.fromJSValue() {
3129
self.dictionary = dictionary
3230
}
3331
return nil

Sources/DOMKit/WebIDL/OnErrorEventHandlerNonNull.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
import JavaScriptKit
77

8-
public typealias OnErrorEventHandlerNonNull = ((EventOrString, String, UInt32, UInt32, AnyJSValueCodable) -> AnyJSValueCodable)
8+
public typealias OnErrorEventHandlerNonNull = ((EventOrString, String, UInt32, UInt32, JSValue) -> JSValue)

0 commit comments

Comments
 (0)