Skip to content

Commit 15d21a4

Browse files
Apply embedded fixes
1 parent 740bb47 commit 15d21a4

File tree

9 files changed

+12728
-14160
lines changed

9 files changed

+12728
-14160
lines changed

Package.resolved

Lines changed: 21 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/DOM/Generated.swift

Lines changed: 12663 additions & 14101 deletions
Large diffs are not rendered by default.

Sources/DOM/Support.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ public typealias __UNSUPPORTED_BIGINT__ = JSValue
66

77
public typealias WindowProxy = Window
88

9-
public extension HTMLElement {
10-
convenience init?(from element: Element) {
11-
self.init(from: .object(element.jsObject))
12-
}
13-
}
14-
159
public let globalThis = Window(from: JSObject.global.jsValue)!
1610

1711
public typealias Uint8ClampedArray = JSUInt8ClampedArray

Sources/ECMAScript/ArrayBuffer.swift

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Created by Manuel Burghard. Licensed unter MIT.
33
//
44

5-
import _CJavaScriptKit
65
import JavaScriptKit
6+
import _CJavaScriptKit
77

88
public typealias Int8Array = JSTypedArray<Int8>
99
public typealias Int16Array = JSTypedArray<Int16>
@@ -30,7 +30,7 @@ public class ArrayBuffer: JSBridgedClass {
3030
}
3131

3232
@inlinable
33-
public static func isView(_ object: JSValueCompatible) -> Bool {
33+
public static func isView(_ object: some JSValueCompatible) -> Bool {
3434
JSObject.global.ArrayBuffer.object!.isView!(object).fromJSValue()!
3535
}
3636
}
@@ -52,7 +52,9 @@ public class SharedArrayBuffer: JSBridgedClass {
5252

5353
@inlinable
5454
public convenience init(length: Int, maxByteLength: Int) {
55-
self.init(unsafelyWrapping: Self.constructor!.new(length, ["maxByteLength": maxByteLength]))
55+
self.init(
56+
unsafelyWrapping: Self.constructor!.new(
57+
length, ["maxByteLength": maxByteLength.jsValue] as JSObject))
5658
}
5759

5860
@inlinable
@@ -79,44 +81,45 @@ public class SharedArrayBuffer: JSBridgedClass {
7981
public func slice(begin: Int) -> SharedArrayBuffer {
8082
jsObject.slice!(begin).fromJSValue()!
8183
}
84+
8285
@inlinable
8386
public func slice(begin: Int, end: Int) -> SharedArrayBuffer {
8487
jsObject.slice!(begin, end).fromJSValue()!
8588
}
8689
}
8790

88-
public extension JSTypedArray {
89-
convenience init(_ arrayBuffer: ArrayBuffer) {
91+
extension JSTypedArray {
92+
public convenience init(_ arrayBuffer: ArrayBuffer) {
9093
self.init(unsafelyWrapping: Self.constructor!.new(arrayBuffer))
9194
}
9295

93-
convenience init(_ sharedArrayBuffer: SharedArrayBuffer) {
96+
public convenience init(_ sharedArrayBuffer: SharedArrayBuffer) {
9497
self.init(unsafelyWrapping: Self.constructor!.new(sharedArrayBuffer))
9598
}
9699

97100
// Exactly one of these two properties will be non-nil.
98101
@inlinable
99-
var arrayBuffer: ArrayBuffer! {
102+
public var arrayBuffer: ArrayBuffer! {
100103
ArrayBuffer(from: jsObject.buffer)
101104
}
102105

103106
@inlinable
104-
var sharedArrayBuffer: SharedArrayBuffer! {
107+
public var sharedArrayBuffer: SharedArrayBuffer! {
105108
SharedArrayBuffer(from: jsObject.buffer)
106109
}
107110
}
108111

109112
#if canImport(Foundation)
110113
import Foundation
111114

112-
public extension Data {
113-
init(_ arrayBuffer: ArrayBuffer) {
115+
extension Data {
116+
public init(_ arrayBuffer: ArrayBuffer) {
114117
self = JSTypedArray<UInt8>(arrayBuffer).withUnsafeBytes {
115118
Data(buffer: $0)
116119
}
117120
}
118121

119-
init(_ sharedArrayBuffer: SharedArrayBuffer) {
122+
public init(_ sharedArrayBuffer: SharedArrayBuffer) {
120123
self = JSTypedArray<UInt8>(sharedArrayBuffer).withUnsafeBytes {
121124
Data(buffer: $0)
122125
}
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
import JavaScriptKit
22

3-
open class BridgedDictionary: JSValueCompatible {
4-
public let jsObject: JSObject
5-
6-
@inlinable public var jsValue: JSValue {
7-
jsObject.jsValue
8-
}
9-
10-
@inlinable public required init(unsafelyWrapping jsObject: JSObject) {
11-
self.jsObject = jsObject
12-
}
3+
public protocol JSDictionaryCompatible: JSValueCompatible {
4+
var jsObject: JSObject { get }
5+
init(unsafelyWrapping: JSObject)
6+
}
137

14-
@inlinable public static func construct(from value: JSValue) -> Self? {
8+
public extension JSDictionaryCompatible {
9+
static func construct(from value: JSValue) -> Self? {
1510
if let object = value.object {
16-
return Self.construct(from: object)
11+
return self.init(unsafelyWrapping: object)
12+
} else {
13+
return nil
1714
}
18-
return nil
1915
}
2016

21-
@inlinable public static func construct(from object: JSObject) -> Self? {
22-
Self(unsafelyWrapping: object)
17+
var jsValue: JSValue {
18+
.object(jsObject)
2319
}
2420
}
21+

Sources/ECMAScript/Iterators.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import JavaScriptEventLoop
21
import JavaScriptKit
2+
import _Concurrency
33

4-
public class ValueIterableIterator<SequenceType: JSBridgedClass & Sequence>: IteratorProtocol
4+
public struct ValueIterableIterator<SequenceType: JSBridgedClass & Sequence>: IteratorProtocol
55
where SequenceType.Element: ConstructibleFromJSValue
66
{
77
private let iterator: JSObject
@@ -19,8 +19,11 @@ public class ValueIterableIterator<SequenceType: JSBridgedClass & Sequence>: Ite
1919
}
2020
}
2121

22+
#if canImport(JavaScriptEventLoop)
23+
import JavaScriptEventLoop
24+
2225
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
23-
public class ValueIterableAsyncIterator<SequenceType: JSBridgedClass & AsyncSequence>: AsyncIteratorProtocol
26+
public struct ValueIterableAsyncIterator<SequenceType: JSBridgedClass & AsyncSequence>: AsyncIteratorProtocol
2427
where SequenceType.Element: ConstructibleFromJSValue
2528
{
2629
private var index: Int = 0
@@ -30,7 +33,7 @@ public class ValueIterableAsyncIterator<SequenceType: JSBridgedClass & AsyncSequ
3033
iterator = sequence.jsObject[JSSymbol.asyncIterator].function!().object!
3134
}
3235

33-
public func next() async throws -> SequenceType.Element? {
36+
public func next() async throws(JSException) -> SequenceType.Element? {
3437
let promise = JSPromise(from: iterator.next!())!
3538
let result = try await promise.value
3639
let done = result.done.boolean!
@@ -39,3 +42,5 @@ public class ValueIterableAsyncIterator<SequenceType: JSBridgedClass & AsyncSequ
3942
return result.value.fromJSValue()!
4043
}
4144
}
45+
46+
#endif

Sources/WebGL1/Support.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import DOM
22
import JavaScriptKit
33

4-
public typealias GLintptr = Int32
5-
64
extension WebGLRenderingContext: RenderingContext {
75
public static var contextID: JSString { "webgl" }
86
}

parse-idl/package-lock.json

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

parse-idl/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"prettier": "2.6.1"
99
},
1010
"dependencies": {
11-
"@webref/idl": "^3.5.0",
12-
"webidl2": "^24.2.1"
11+
"@webref/idl": "^3.60.3",
12+
"webidl2": "^24.4.1"
1313
}
1414
}

0 commit comments

Comments
 (0)