diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e70c82c9..bbd84f3a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ on: jobs: macos_test: - runs-on: macos-11.0 + runs-on: macos-12 steps: - uses: actions/checkout@v2 @@ -15,7 +15,7 @@ jobs: shell: bash run: | set -ex - sudo xcode-select --switch /Applications/Xcode_12.3.app/Contents/Developer/ + sudo xcode-select --switch /Applications/Xcode_13.3.1.app/Contents/Developer/ brew install swiftwasm/tap/carton diff --git a/.gitignore b/.gitignore index 95c43209..970bd4ca 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /Packages /*.xcodeproj xcuserdata/ +node_modules diff --git a/Package.resolved b/Package.resolved index bd43c161..60906fdc 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,9 +5,9 @@ "package": "JavaScriptKit", "repositoryURL": "https://github.com/swiftwasm/JavaScriptKit.git", "state": { - "branch": null, - "revision": "b7a02434c6e973c08c3fd5069105ef44dd82b891", - "version": "0.9.0" + "branch": "main", + "revision": "95d0c4cd78b48ffc7e19c618d57c3244917be09a", + "version": null } } ] diff --git a/Package.swift b/Package.swift index dd8874db..82799a74 100644 --- a/Package.swift +++ b/Package.swift @@ -12,21 +12,25 @@ let package = Package( .library( name: "DOMKit", targets: ["DOMKit"]), + .library(name: "WebIDL", targets: ["WebIDL"]), + .executable(name: "WebIDLToSwift", targets: ["WebIDLToSwift"]), ], dependencies: [ .package( - name: "JavaScriptKit", url: "https://github.com/swiftwasm/JavaScriptKit.git", - .upToNextMinor(from: "0.9.0")), + .branch("main")), ], targets: [ .target( name: "DOMKitDemo", - dependencies: ["DOMKit"] - ), + dependencies: ["DOMKit"]), .target( name: "DOMKit", - dependencies: ["JavaScriptKit"]), + dependencies: ["JavaScriptKit", .product(name: "JavaScriptEventLoop", package: "JavaScriptKit")]), + .target(name: "WebIDL"), + .target( + name: "WebIDLToSwift", + dependencies: ["WebIDL"]), .testTarget( name: "DOMKitTests", dependencies: ["DOMKit"]), diff --git a/Sources/DOMKit/ECMAScript/ArrayBuffer.swift b/Sources/DOMKit/ECMAScript/ArrayBuffer.swift index f225825e..195bbd54 100644 --- a/Sources/DOMKit/ECMAScript/ArrayBuffer.swift +++ b/Sources/DOMKit/ECMAScript/ArrayBuffer.swift @@ -11,7 +11,6 @@ public typealias Int32Array = JSTypedArray public typealias Uint8Array = JSTypedArray public typealias Uint16Array = JSTypedArray public typealias Uint32Array = JSTypedArray -//public typealias Uint8ClampedArray = JSTypedArray public typealias Float32Array = JSTypedArray public typealias Float64Array = JSTypedArray diff --git a/Sources/DOMKit/ECMAScript/ArrayBufferView.swift b/Sources/DOMKit/ECMAScript/ArrayBufferView.swift new file mode 100644 index 00000000..ffa932d8 --- /dev/null +++ b/Sources/DOMKit/ECMAScript/ArrayBufferView.swift @@ -0,0 +1,93 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +// TODO: expand this to BigInt arrays +public protocol AnyArrayBufferView: ConvertibleToJSValue {} +extension DataView: AnyArrayBufferView {} +extension JSTypedArray: AnyArrayBufferView {} + +public enum ArrayBufferView: JSValueCompatible, AnyArrayBufferView { + case dataView(DataView) + // case bigInt64Array(BigInt64Array) + // case bigUint64Array(BigUint64Array) + case float32Array(Float32Array) + case float64Array(Float64Array) + case int16Array(Int16Array) + case int32Array(Int32Array) + case int8Array(Int8Array) + case uint16Array(Uint16Array) + case uint32Array(Uint32Array) + case uint8Array(Uint8Array) + case uint8ClampedArray(Uint8ClampedArray) + + public static func construct(from value: JSValue) -> Self? { + // if let bigInt64Array: BigInt64Array = value.fromJSValue() { + // return .bigInt64Array(bigInt64Array) + // } + // if let bigUint64Array: BigUint64Array = value.fromJSValue() { + // return .bigUint64Array(bigUint64Array) + // } + if let dataView: DataView = value.fromJSValue() { + return .dataView(dataView) + } + if let float32Array: Float32Array = value.fromJSValue() { + return .float32Array(float32Array) + } + if let float64Array: Float64Array = value.fromJSValue() { + return .float64Array(float64Array) + } + if let int16Array: Int16Array = value.fromJSValue() { + return .int16Array(int16Array) + } + if let int32Array: Int32Array = value.fromJSValue() { + return .int32Array(int32Array) + } + if let int8Array: Int8Array = value.fromJSValue() { + return .int8Array(int8Array) + } + if let uint16Array: Uint16Array = value.fromJSValue() { + return .uint16Array(uint16Array) + } + if let uint32Array: Uint32Array = value.fromJSValue() { + return .uint32Array(uint32Array) + } + if let uint8Array: Uint8Array = value.fromJSValue() { + return .uint8Array(uint8Array) + } + if let uint8ClampedArray: Uint8ClampedArray = value.fromJSValue() { + return .uint8ClampedArray(uint8ClampedArray) + } + return nil + } + + public var jsValue: JSValue { + switch self { +// case let .bigInt64Array(bigInt64Array): +// return bigInt64Array.jsValue +// case let .bigUint64Array(bigUint64Array): +// return bigUint64Array.jsValue + case let .dataView(dataView): + return dataView.jsValue + case let .float32Array(float32Array): + return float32Array.jsValue + case let .float64Array(float64Array): + return float64Array.jsValue + case let .int16Array(int16Array): + return int16Array.jsValue + case let .int32Array(int32Array): + return int32Array.jsValue + case let .int8Array(int8Array): + return int8Array.jsValue + case let .uint16Array(uint16Array): + return uint16Array.jsValue + case let .uint32Array(uint32Array): + return uint32Array.jsValue + case let .uint8Array(uint8Array): + return uint8Array.jsValue + case let .uint8ClampedArray(uint8ClampedArray): + return uint8ClampedArray.jsValue + } + } +} diff --git a/Sources/DOMKit/ECMAScript/Attributes.swift b/Sources/DOMKit/ECMAScript/Attributes.swift new file mode 100644 index 00000000..842cd627 --- /dev/null +++ b/Sources/DOMKit/ECMAScript/Attributes.swift @@ -0,0 +1,39 @@ +import JavaScriptKit + +@propertyWrapper public struct ReadWriteAttribute { + @usableFromInline let jsObject: JSObject + @usableFromInline let name: JSString + + public init(jsObject: JSObject, name: JSString) { + self.jsObject = jsObject + self.name = name + } + + @inlinable public var wrappedValue: Wrapped { + get { ReadWriteAttribute[name, in: jsObject] } + nonmutating set { ReadWriteAttribute[name, in: jsObject] = newValue } + } + + @inlinable public static subscript(name: JSString, in jsObject: JSObject) -> Wrapped { + get { jsObject[name].fromJSValue()! } + set { jsObject[name] = newValue.jsValue } + } +} + +@propertyWrapper public struct ReadonlyAttribute { + @usableFromInline let jsObject: JSObject + @usableFromInline let name: JSString + + public init(jsObject: JSObject, name: JSString) { + self.jsObject = jsObject + self.name = name + } + + @inlinable public var wrappedValue: Wrapped { + ReadonlyAttribute[name, in: jsObject] + } + + @inlinable public static subscript(name: JSString, in jsObject: JSObject) -> Wrapped { + jsObject[name].fromJSValue()! + } +} diff --git a/Sources/DOMKit/ECMAScript/BridgedDictionary.swift b/Sources/DOMKit/ECMAScript/BridgedDictionary.swift new file mode 100644 index 00000000..813e0a66 --- /dev/null +++ b/Sources/DOMKit/ECMAScript/BridgedDictionary.swift @@ -0,0 +1,24 @@ +import JavaScriptKit + +public class BridgedDictionary: JSValueCompatible { + public let jsObject: JSObject + + public var jsValue: JSValue { + jsObject.jsValue + } + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + public static func construct(from value: JSValue) -> Self? { + if let object = value.object { + return Self.construct(from: object) + } + return nil + } + + public static func construct(from object: JSObject) -> Self? { + Self(unsafelyWrapping: object) + } +} diff --git a/Sources/DOMKit/ECMAScript/CanvasImageSource.swift b/Sources/DOMKit/ECMAScript/CanvasImageSource.swift new file mode 100644 index 00000000..9c93d9b6 --- /dev/null +++ b/Sources/DOMKit/ECMAScript/CanvasImageSource.swift @@ -0,0 +1,102 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_CanvasImageSource: ConvertibleToJSValue {} +extension HTMLCanvasElement: Any_CanvasImageSource {} +extension HTMLOrSVGImageElement: Any_CanvasImageSource {} +extension HTMLVideoElement: Any_CanvasImageSource {} +extension ImageBitmap: Any_CanvasImageSource {} +extension OffscreenCanvas: Any_CanvasImageSource {} +//extension VideoFrame: Any_CanvasImageSource {} + +public enum CanvasImageSource: JSValueCompatible, Any_CanvasImageSource { + case htmlCanvasElement(HTMLCanvasElement) + case htmlOrSVGImageElement(HTMLOrSVGImageElement) + case htmlVideoElement(HTMLVideoElement) + case imageBitmap(ImageBitmap) + case offscreenCanvas(OffscreenCanvas) +// case videoFrame(VideoFrame) + + var htmlCanvasElement: HTMLCanvasElement? { + switch self { + case let .htmlCanvasElement(htmlCanvasElement): return htmlCanvasElement + default: return nil + } + } + + var htmlOrSVGImageElement: HTMLOrSVGImageElement? { + switch self { + case let .htmlOrSVGImageElement(htmlOrSVGImageElement): return htmlOrSVGImageElement + default: return nil + } + } + + var htmlVideoElement: HTMLVideoElement? { + switch self { + case let .htmlVideoElement(htmlVideoElement): return htmlVideoElement + default: return nil + } + } + + var imageBitmap: ImageBitmap? { + switch self { + case let .imageBitmap(imageBitmap): return imageBitmap + default: return nil + } + } + + var offscreenCanvas: OffscreenCanvas? { + switch self { + case let .offscreenCanvas(offscreenCanvas): return offscreenCanvas + default: return nil + } + } + +// var videoFrame: VideoFrame? { +// switch self { +// case let .videoFrame(videoFrame): return videoFrame +// default: return nil +// } +// } + + public static func construct(from value: JSValue) -> Self? { + if let htmlCanvasElement: HTMLCanvasElement = value.fromJSValue() { + return .htmlCanvasElement(htmlCanvasElement) + } + if let htmlOrSVGImageElement: HTMLOrSVGImageElement = value.fromJSValue() { + return .htmlOrSVGImageElement(htmlOrSVGImageElement) + } + if let htmlVideoElement: HTMLVideoElement = value.fromJSValue() { + return .htmlVideoElement(htmlVideoElement) + } + if let imageBitmap: ImageBitmap = value.fromJSValue() { + return .imageBitmap(imageBitmap) + } + if let offscreenCanvas: OffscreenCanvas = value.fromJSValue() { + return .offscreenCanvas(offscreenCanvas) + } +// if let videoFrame: VideoFrame = value.fromJSValue() { +// return .videoFrame(videoFrame) +// } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .htmlCanvasElement(htmlCanvasElement): + return htmlCanvasElement.jsValue + case let .htmlOrSVGImageElement(htmlOrSVGImageElement): + return htmlOrSVGImageElement.jsValue + case let .htmlVideoElement(htmlVideoElement): + return htmlVideoElement.jsValue + case let .imageBitmap(imageBitmap): + return imageBitmap.jsValue + case let .offscreenCanvas(offscreenCanvas): + return offscreenCanvas.jsValue +// case let .videoFrame(videoFrame): +// return videoFrame.jsValue + } + } +} diff --git a/Sources/DOMKit/ECMAScript/DataView.swift b/Sources/DOMKit/ECMAScript/DataView.swift index e9a89a60..f21e6d9a 100644 --- a/Sources/DOMKit/ECMAScript/DataView.swift +++ b/Sources/DOMKit/ECMAScript/DataView.swift @@ -5,7 +5,6 @@ import JavaScriptKit public class DataView: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.DataView.function! } public let jsObject: JSObject @@ -18,18 +17,15 @@ public class DataView: JSBridgedClass { } public convenience init(buffer: ArrayBuffer) { - - self.init(unsafelyWrapping: DataView.constructor.new(buffer.jsValue())) + self.init(unsafelyWrapping: DataView.constructor.new(buffer.jsValue)) } public convenience init(buffer: ArrayBuffer, byteOffset: UInt32) { - - self.init(unsafelyWrapping: DataView.constructor.new(buffer.jsValue(), byteOffset.jsValue())) + self.init(unsafelyWrapping: DataView.constructor.new(buffer.jsValue, byteOffset.jsValue)) } public convenience init(buffer: ArrayBuffer, byteOffset: UInt32, byteLength: UInt32) { - - self.init(unsafelyWrapping: DataView.constructor.new(buffer.jsValue(), byteOffset.jsValue(), byteLength.jsValue())) + self.init(unsafelyWrapping: DataView.constructor.new(buffer.jsValue, byteOffset.jsValue, byteLength.jsValue)) } @ReadonlyAttribute @@ -41,131 +37,115 @@ public class DataView: JSBridgedClass { @ReadonlyAttribute public var byteLength: UInt32 - public func getFloat32(byteOffset: UInt32) -> Float { - - return jsObject.getFloat32!(byteOffset.jsValue()).fromJSValue()! + jsObject.getFloat32!(byteOffset.jsValue).fromJSValue()! } public func getFloat32(byteOffset: UInt32, littleEndian: Bool) -> Float { - - return jsObject.getFloat32!(byteOffset.jsValue(), littleEndian.jsValue()).fromJSValue()! + jsObject.getFloat32!(byteOffset.jsValue, littleEndian.jsValue).fromJSValue()! } public func getFloat64(byteOffset: UInt32) -> Double { - - return jsObject.getFloat64!(byteOffset.jsValue()).fromJSValue()! + jsObject.getFloat64!(byteOffset.jsValue).fromJSValue()! } public func getFloat64(byteOffset: UInt32, littleEndian: Bool) -> Double { - - return jsObject.getFloat64!(byteOffset.jsValue(), littleEndian.jsValue()).fromJSValue()! + jsObject.getFloat64!(byteOffset.jsValue, littleEndian.jsValue).fromJSValue()! } public func getUint8(byteOffset: UInt32) -> UInt8 { - - return jsObject.getUint8!(byteOffset.jsValue()).fromJSValue()! + jsObject.getUint8!(byteOffset.jsValue).fromJSValue()! } public func getUint16(byteOffset: UInt32) -> UInt16 { - - return jsObject.getUint16!(byteOffset.jsValue()).fromJSValue()! + jsObject.getUint16!(byteOffset.jsValue).fromJSValue()! } public func getUint16(byteOffset: UInt32, littleEndian: Bool) -> UInt16 { - - return jsObject.getUint16!(byteOffset.jsValue(), littleEndian.jsValue()).fromJSValue()! + jsObject.getUint16!(byteOffset.jsValue, littleEndian.jsValue).fromJSValue()! } public func getUint32(byteOffset: UInt32) -> UInt32 { - - return jsObject.getUint32!(byteOffset.jsValue()).fromJSValue()! + jsObject.getUint32!(byteOffset.jsValue).fromJSValue()! } public func getUint32(byteOffset: UInt32, littleEndian: Bool) -> UInt32 { - - return jsObject.getUint32!(byteOffset.jsValue(), littleEndian.jsValue()).fromJSValue()! + jsObject.getUint32!(byteOffset.jsValue, littleEndian.jsValue).fromJSValue()! } public func getInt8(byteOffset: UInt32) -> Int8 { - - return jsObject.getInt8!(byteOffset.jsValue()).fromJSValue()! + jsObject.getInt8!(byteOffset.jsValue).fromJSValue()! } public func getInt16(byteOffset: UInt32) -> Int16 { - - return jsObject.getInt16!(byteOffset.jsValue()).fromJSValue()! + jsObject.getInt16!(byteOffset.jsValue).fromJSValue()! } public func getInt16(byteOffset: UInt32, littleEndian: Bool) -> Int16 { - - return jsObject.getInt16!(byteOffset.jsValue(), littleEndian.jsValue()).fromJSValue()! + jsObject.getInt16!(byteOffset.jsValue, littleEndian.jsValue).fromJSValue()! } public func getInt32(byteOffset: UInt32) -> Int32 { - - return jsObject.getInt32!(byteOffset.jsValue()).fromJSValue()! + jsObject.getInt32!(byteOffset.jsValue).fromJSValue()! } public func getInt32(byteOffset: UInt32, littleEndian: Bool) -> Int32 { - - return jsObject.getInt32!(byteOffset.jsValue(), littleEndian.jsValue()).fromJSValue()! + jsObject.getInt32!(byteOffset.jsValue, littleEndian.jsValue).fromJSValue()! } public func setUint8(byteOffset: UInt32, value: UInt8) { - _ = jsObject.setUint8!(byteOffset.jsValue(), value.jsValue()) + _ = jsObject.setUint8!(byteOffset.jsValue, value.jsValue) } public func setUint16(byteOffset: UInt32, value: UInt16) { - _ = jsObject.setUint16!(byteOffset.jsValue(), value.jsValue()) + _ = jsObject.setUint16!(byteOffset.jsValue, value.jsValue) } public func setUint16(byteOffset: UInt32, value: UInt16, littleEndian: Bool) { - _ = jsObject.setUint16!(byteOffset.jsValue(), value.jsValue(), littleEndian.jsValue()) + _ = jsObject.setUint16!(byteOffset.jsValue, value.jsValue, littleEndian.jsValue) } public func setUint32(byteOffset: UInt32, value: UInt32) { - _ = jsObject.setUint32!(byteOffset.jsValue(), value.jsValue()) + _ = jsObject.setUint32!(byteOffset.jsValue, value.jsValue) } public func setUint32(byteOffset: UInt32, value: UInt32, littleEndian: Bool) { - _ = jsObject.setUint32!(byteOffset.jsValue(), value.jsValue(), littleEndian.jsValue()) + _ = jsObject.setUint32!(byteOffset.jsValue, value.jsValue, littleEndian.jsValue) } public func setInt8(byteOffset: UInt32, value: Int8) { - _ = jsObject.setUint8!(byteOffset.jsValue(), value.jsValue()) + _ = jsObject.setUint8!(byteOffset.jsValue, value.jsValue) } public func setInt16(byteOffset: UInt32, value: Int16) { - _ = jsObject.setInt16!(byteOffset.jsValue(), value.jsValue()) + _ = jsObject.setInt16!(byteOffset.jsValue, value.jsValue) } public func setInt16(byteOffset: UInt32, value: Int16, littleEndian: Bool) { - _ = jsObject.setInt16!(byteOffset.jsValue(), value.jsValue(), littleEndian.jsValue()) + _ = jsObject.setInt16!(byteOffset.jsValue, value.jsValue, littleEndian.jsValue) } public func setInt32(byteOffset: UInt32, value: Int32) { - _ = jsObject.setInt32!(byteOffset.jsValue(), value.jsValue()) + _ = jsObject.setInt32!(byteOffset.jsValue, value.jsValue) } public func setInt32(byteOffset: UInt32, value: Int32, littleEndian: Bool) { - _ = jsObject.setInt32!(byteOffset.jsValue(), value.jsValue(), littleEndian.jsValue()) + _ = jsObject.setInt32!(byteOffset.jsValue, value.jsValue, littleEndian.jsValue) } public func setFloat32(byteOffset: UInt32, value: Float) { - _ = jsObject.setFloat32!(byteOffset.jsValue(), value.jsValue()) + _ = jsObject.setFloat32!(byteOffset.jsValue, value.jsValue) } public func setFloat32(byteOffset: UInt32, value: Float, littleEndian: Bool) { - _ = jsObject.setFloat32!(byteOffset.jsValue(), value.jsValue(), littleEndian.jsValue()) + _ = jsObject.setFloat32!(byteOffset.jsValue, value.jsValue, littleEndian.jsValue) } public func setFloat64(byteOffset: UInt32, value: Double) { - _ = jsObject.setFloat64!(byteOffset.jsValue(), value.jsValue()) + _ = jsObject.setFloat64!(byteOffset.jsValue, value.jsValue) } public func setFloat64(byteOffset: UInt32, value: Double, littleEndian: Bool) { - _ = jsObject.setFloat64!(byteOffset.jsValue(), value.jsValue(), littleEndian.jsValue()) + _ = jsObject.setFloat64!(byteOffset.jsValue, value.jsValue, littleEndian.jsValue) } } - diff --git a/Sources/DOMKit/ECMAScript/Iterators.swift b/Sources/DOMKit/ECMAScript/Iterators.swift new file mode 100644 index 00000000..9fe63e15 --- /dev/null +++ b/Sources/DOMKit/ECMAScript/Iterators.swift @@ -0,0 +1,41 @@ +import JavaScriptEventLoop +import JavaScriptKit + +public class ValueIterableIterator: IteratorProtocol + where SequenceType.Element: ConstructibleFromJSValue +{ + private let iterator: JSObject + + public init(sequence: SequenceType) { + iterator = sequence.jsObject[JSSymbol.iterator].function!().object! + } + + public func next() -> SequenceType.Element? { + let result = iterator.next!().object! + let done = result.done.boolean! + guard !done else { return nil } + + return result.value.fromJSValue()! + } +} + +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) +public class ValueIterableAsyncIterator: AsyncIteratorProtocol + where SequenceType.Element: ConstructibleFromJSValue +{ + private var index: Int = 0 + private let iterator: JSObject + + public init(sequence: SequenceType) { + iterator = sequence.jsObject[JSSymbol.asyncIterator].function!().object! + } + + public func next() async throws -> SequenceType.Element? { + let promise = JSPromise(from: iterator.next!())! + let result = try await promise.value + let done = result.done.boolean! + guard !done else { return nil } + + return result.value.fromJSValue()! + } +} diff --git a/Sources/DOMKit/ECMAScript/OffscreenRenderingContext.swift b/Sources/DOMKit/ECMAScript/OffscreenRenderingContext.swift new file mode 100644 index 00000000..12bcb462 --- /dev/null +++ b/Sources/DOMKit/ECMAScript/OffscreenRenderingContext.swift @@ -0,0 +1,88 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_OffscreenRenderingContext: ConvertibleToJSValue {} +//extension GPUCanvasContext: Any_OffscreenRenderingContext {} +extension ImageBitmapRenderingContext: Any_OffscreenRenderingContext {} +extension OffscreenCanvasRenderingContext2D: Any_OffscreenRenderingContext {} +//extension WebGL2RenderingContext: Any_OffscreenRenderingContext {} +//extension WebGLRenderingContext: Any_OffscreenRenderingContext {} + +public enum OffscreenRenderingContext: JSValueCompatible, Any_OffscreenRenderingContext { +// case gpuCanvasContext(GPUCanvasContext) + case imageBitmapRenderingContext(ImageBitmapRenderingContext) + case offscreenCanvasRenderingContext2D(OffscreenCanvasRenderingContext2D) +// case webGL2RenderingContext(WebGL2RenderingContext) +// case webGLRenderingContext(WebGLRenderingContext) + +// var gpuCanvasContext: GPUCanvasContext? { +// switch self { +// case let .gpuCanvasContext(gpuCanvasContext): return gpuCanvasContext +// default: return nil +// } +// } + + var imageBitmapRenderingContext: ImageBitmapRenderingContext? { + switch self { + case let .imageBitmapRenderingContext(imageBitmapRenderingContext): return imageBitmapRenderingContext + default: return nil + } + } + + var offscreenCanvasRenderingContext2D: OffscreenCanvasRenderingContext2D? { + switch self { + case let .offscreenCanvasRenderingContext2D(offscreenCanvasRenderingContext2D): return offscreenCanvasRenderingContext2D + default: return nil + } + } + +// var webGL2RenderingContext: WebGL2RenderingContext? { +// switch self { +// case let .webGL2RenderingContext(webGL2RenderingContext): return webGL2RenderingContext +// default: return nil +// } +// } +// +// var webGLRenderingContext: WebGLRenderingContext? { +// switch self { +// case let .webGLRenderingContext(webGLRenderingContext): return webGLRenderingContext +// default: return nil +// } +// } + + public static func construct(from value: JSValue) -> Self? { +// if let gpuCanvasContext: GPUCanvasContext = value.fromJSValue() { +// return .gpuCanvasContext(gpuCanvasContext) +// } + if let imageBitmapRenderingContext: ImageBitmapRenderingContext = value.fromJSValue() { + return .imageBitmapRenderingContext(imageBitmapRenderingContext) + } + if let offscreenCanvasRenderingContext2D: OffscreenCanvasRenderingContext2D = value.fromJSValue() { + return .offscreenCanvasRenderingContext2D(offscreenCanvasRenderingContext2D) + } +// if let webGL2RenderingContext: WebGL2RenderingContext = value.fromJSValue() { +// return .webGL2RenderingContext(webGL2RenderingContext) +// } +// if let webGLRenderingContext: WebGLRenderingContext = value.fromJSValue() { +// return .webGLRenderingContext(webGLRenderingContext) +// } + return nil + } + + public var jsValue: JSValue { + switch self { +// case let .gpuCanvasContext(gpuCanvasContext): +// return gpuCanvasContext.jsValue + case let .imageBitmapRenderingContext(imageBitmapRenderingContext): + return imageBitmapRenderingContext.jsValue + case let .offscreenCanvasRenderingContext2D(offscreenCanvasRenderingContext2D): + return offscreenCanvasRenderingContext2D.jsValue +// case let .webGL2RenderingContext(webGL2RenderingContext): +// return webGL2RenderingContext.jsValue +// case let .webGLRenderingContext(webGLRenderingContext): +// return webGLRenderingContext.jsValue + } + } +} diff --git a/Sources/DOMKit/ECMAScript/RenderingContext.swift b/Sources/DOMKit/ECMAScript/RenderingContext.swift new file mode 100644 index 00000000..ad42b922 --- /dev/null +++ b/Sources/DOMKit/ECMAScript/RenderingContext.swift @@ -0,0 +1,88 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_RenderingContext: ConvertibleToJSValue {} +extension CanvasRenderingContext2D: Any_RenderingContext {} +//extension GPUCanvasContext: Any_RenderingContext {} +extension ImageBitmapRenderingContext: Any_RenderingContext {} +//extension WebGL2RenderingContext: Any_RenderingContext {} +//extension WebGLRenderingContext: Any_RenderingContext {} + +public enum RenderingContext: JSValueCompatible, Any_RenderingContext { + case canvasRenderingContext2D(CanvasRenderingContext2D) +// case gpuCanvasContext(GPUCanvasContext) + case imageBitmapRenderingContext(ImageBitmapRenderingContext) +// case webGL2RenderingContext(WebGL2RenderingContext) +// case webGLRenderingContext(WebGLRenderingContext) + + var canvasRenderingContext2D: CanvasRenderingContext2D? { + switch self { + case let .canvasRenderingContext2D(canvasRenderingContext2D): return canvasRenderingContext2D + default: return nil + } + } + +// var gpuCanvasContext: GPUCanvasContext? { +// switch self { +// case let .gpuCanvasContext(gpuCanvasContext): return gpuCanvasContext +// default: return nil +// } +// } + + var imageBitmapRenderingContext: ImageBitmapRenderingContext? { + switch self { + case let .imageBitmapRenderingContext(imageBitmapRenderingContext): return imageBitmapRenderingContext + default: return nil + } + } + +// var webGL2RenderingContext: WebGL2RenderingContext? { +// switch self { +// case let .webGL2RenderingContext(webGL2RenderingContext): return webGL2RenderingContext +// default: return nil +// } +// } +// +// var webGLRenderingContext: WebGLRenderingContext? { +// switch self { +// case let .webGLRenderingContext(webGLRenderingContext): return webGLRenderingContext +// default: return nil +// } +// } + + public static func construct(from value: JSValue) -> Self? { + if let canvasRenderingContext2D: CanvasRenderingContext2D = value.fromJSValue() { + return .canvasRenderingContext2D(canvasRenderingContext2D) + } +// if let gpuCanvasContext: GPUCanvasContext = value.fromJSValue() { +// return .gpuCanvasContext(gpuCanvasContext) +// } + if let imageBitmapRenderingContext: ImageBitmapRenderingContext = value.fromJSValue() { + return .imageBitmapRenderingContext(imageBitmapRenderingContext) + } +// if let webGL2RenderingContext: WebGL2RenderingContext = value.fromJSValue() { +// return .webGL2RenderingContext(webGL2RenderingContext) +// } +// if let webGLRenderingContext: WebGLRenderingContext = value.fromJSValue() { +// return .webGLRenderingContext(webGLRenderingContext) +// } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .canvasRenderingContext2D(canvasRenderingContext2D): + return canvasRenderingContext2D.jsValue +// case let .gpuCanvasContext(gpuCanvasContext): +// return gpuCanvasContext.jsValue + case let .imageBitmapRenderingContext(imageBitmapRenderingContext): + return imageBitmapRenderingContext.jsValue +// case let .webGL2RenderingContext(webGL2RenderingContext): +// return webGL2RenderingContext.jsValue +// case let .webGLRenderingContext(webGLRenderingContext): +// return webGLRenderingContext.jsValue + } + } +} diff --git a/Sources/DOMKit/ECMAScript/RotationMatrixType.swift b/Sources/DOMKit/ECMAScript/RotationMatrixType.swift new file mode 100644 index 00000000..d14e2c74 --- /dev/null +++ b/Sources/DOMKit/ECMAScript/RotationMatrixType.swift @@ -0,0 +1,8 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol RotationMatrixType: ConvertibleToJSValue {} +extension DOMMatrix: RotationMatrixType {} +extension JSTypedArray: RotationMatrixType where Element: FloatingPoint {} diff --git a/Sources/DOMKit/ECMAScript/Support.swift b/Sources/DOMKit/ECMAScript/Support.swift index 45736af2..4bc3794a 100644 --- a/Sources/DOMKit/ECMAScript/Support.swift +++ b/Sources/DOMKit/ECMAScript/Support.swift @@ -1,18 +1,9 @@ -// -// Created by Manuel Burghard. Licensed unter MIT. -// - import JavaScriptKit -public extension Window { - public var document: Document { Document(unsafelyWrapping: jsObject.document.object!) } -} +/* TODO: fix this */ +public typealias __UNSUPPORTED_BIGINT__ = JSValue -public extension Document { - var body: HTMLElement { - .init(unsafelyWrapping: jsObject.body.object!) - } -} +public typealias WindowProxy = Window public extension HTMLElement { convenience init?(from element: Element) { @@ -20,143 +11,13 @@ public extension HTMLElement { } } -public let globalThis = Window(from: JSObject.global.jsValue())! - -public class ReadableStream: JSBridgedClass { - - public static var constructor: JSFunction { JSObject.global.ReadableStream.function! } - - public let jsObject: JSObject - - public required init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - public subscript(dynamicMember name: String) -> JSValue { - get { jsObject[name] } - set { jsObject[name] = newValue } - } -} - -@propertyWrapper public final class OptionalClosureHandler -where ArgumentType: JSValueCompatible, ReturnType: JSValueCompatible { - let jsObject: JSObject - let name: String - var closure: JSClosure? - - public init(jsObject: JSObject, name: String) { - self.jsObject = jsObject - self.name = name - } - - deinit { - closure?.release() - } - - public var wrappedValue: ((ArgumentType) -> ReturnType)? { - get { - guard let function = jsObject[name].function else { - return nil - } - return { function($0.jsValue()).fromJSValue()! } - } - set { - if let closure = closure { - closure.release() - } - if let newValue = newValue { - let closure = JSClosure { newValue($0[0].fromJSValue()!).jsValue() } - jsObject[name] = closure.jsValue() - self.closure = closure - } else { - jsObject[name] = .null - } - } - } -} - -@propertyWrapper public struct ReadWriteAttribute { - - let jsObject: JSObject - let name: String - - public init(jsObject: JSObject, name: String) { - self.jsObject = jsObject - self.name = name - } - - public var wrappedValue: Wrapped { - get { - return jsObject[name].fromJSValue()! - } - set { - jsObject[name] = newValue.jsValue() - } - } -} +public let globalThis = Window(from: JSObject.global.jsValue)! -@propertyWrapper public struct ReadonlyAttribute { - - let jsObject: JSObject - let name: String - - public init(jsObject: JSObject, name: String) { - self.jsObject = jsObject - self.name = name - } - - public var wrappedValue: Wrapped { - get { - return jsObject[name].fromJSValue()! - } - } -} - -public class ValueIterableIterator: IteratorProtocol where SequenceType.Element: ConstructibleFromJSValue { - - private var index: Int = 0 - private let sequence: SequenceType - - public init(sequence: SequenceType) { - self.sequence = sequence - } - - public func next() -> SequenceType.Element? { - defer { - index += 1 - } - let value = sequence.jsObject[index] - guard value != .undefined else { - return nil - } - - return value.fromJSValue() - } -} - -public protocol KeyValueSequence: Sequence where Element == (String, Value) { - associatedtype Value -} - -public class PairIterableIterator: IteratorProtocol where SequenceType.Value: ConstructibleFromJSValue { - - private let iterator: JSObject - private let sequence: SequenceType - - public init(sequence: SequenceType) { - self.sequence = sequence - self.iterator = sequence.jsObject.entries!().object! - } - - public func next() -> SequenceType.Element? { - - let next: JSObject = iterator.next!().object! - - guard next.done.boolean! == false else { - return nil - } - - let keyValue: [JSValue] = next.value.fromJSValue()! - return (keyValue[0].fromJSValue()!, keyValue[1].fromJSValue()!) - } -} +public typealias Uint8ClampedArray = JSUInt8ClampedArray +// public typealias CSSColorValue_or_CSSStyleValue = CSSStyleValue +// public typealias Any_CSSColorValue_or_CSSStyleValue = CSSStyleValue +public typealias Blob_or_MediaSource = Blob +public typealias HTMLOrSVGImageElement = HTMLImageElement +public typealias HTMLOrSVGScriptElement = HTMLScriptElement +public typealias BodyInit = XMLHttpRequestBodyInit +public typealias CustomElementConstructor = JSFunction diff --git a/Sources/DOMKit/WebIDL/ARIAMixin.swift b/Sources/DOMKit/WebIDL/ARIAMixin.swift new file mode 100644 index 00000000..b1ec9cf9 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ARIAMixin.swift @@ -0,0 +1,212 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol ARIAMixin: JSBridgedClass {} +public extension ARIAMixin { + @inlinable var role: String? { + get { ReadWriteAttribute[Strings.role, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.role, in: jsObject] = newValue } + } + + @inlinable var ariaAtomic: String? { + get { ReadWriteAttribute[Strings.ariaAtomic, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaAtomic, in: jsObject] = newValue } + } + + @inlinable var ariaAutoComplete: String? { + get { ReadWriteAttribute[Strings.ariaAutoComplete, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaAutoComplete, in: jsObject] = newValue } + } + + @inlinable var ariaBusy: String? { + get { ReadWriteAttribute[Strings.ariaBusy, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaBusy, in: jsObject] = newValue } + } + + @inlinable var ariaChecked: String? { + get { ReadWriteAttribute[Strings.ariaChecked, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaChecked, in: jsObject] = newValue } + } + + @inlinable var ariaColCount: String? { + get { ReadWriteAttribute[Strings.ariaColCount, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaColCount, in: jsObject] = newValue } + } + + @inlinable var ariaColIndex: String? { + get { ReadWriteAttribute[Strings.ariaColIndex, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaColIndex, in: jsObject] = newValue } + } + + @inlinable var ariaColIndexText: String? { + get { ReadWriteAttribute[Strings.ariaColIndexText, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaColIndexText, in: jsObject] = newValue } + } + + @inlinable var ariaColSpan: String? { + get { ReadWriteAttribute[Strings.ariaColSpan, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaColSpan, in: jsObject] = newValue } + } + + @inlinable var ariaCurrent: String? { + get { ReadWriteAttribute[Strings.ariaCurrent, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaCurrent, in: jsObject] = newValue } + } + + @inlinable var ariaDescription: String? { + get { ReadWriteAttribute[Strings.ariaDescription, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaDescription, in: jsObject] = newValue } + } + + @inlinable var ariaDisabled: String? { + get { ReadWriteAttribute[Strings.ariaDisabled, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaDisabled, in: jsObject] = newValue } + } + + @inlinable var ariaExpanded: String? { + get { ReadWriteAttribute[Strings.ariaExpanded, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaExpanded, in: jsObject] = newValue } + } + + @inlinable var ariaHasPopup: String? { + get { ReadWriteAttribute[Strings.ariaHasPopup, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaHasPopup, in: jsObject] = newValue } + } + + @inlinable var ariaHidden: String? { + get { ReadWriteAttribute[Strings.ariaHidden, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaHidden, in: jsObject] = newValue } + } + + @inlinable var ariaInvalid: String? { + get { ReadWriteAttribute[Strings.ariaInvalid, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaInvalid, in: jsObject] = newValue } + } + + @inlinable var ariaKeyShortcuts: String? { + get { ReadWriteAttribute[Strings.ariaKeyShortcuts, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaKeyShortcuts, in: jsObject] = newValue } + } + + @inlinable var ariaLabel: String? { + get { ReadWriteAttribute[Strings.ariaLabel, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaLabel, in: jsObject] = newValue } + } + + @inlinable var ariaLevel: String? { + get { ReadWriteAttribute[Strings.ariaLevel, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaLevel, in: jsObject] = newValue } + } + + @inlinable var ariaLive: String? { + get { ReadWriteAttribute[Strings.ariaLive, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaLive, in: jsObject] = newValue } + } + + @inlinable var ariaModal: String? { + get { ReadWriteAttribute[Strings.ariaModal, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaModal, in: jsObject] = newValue } + } + + @inlinable var ariaMultiLine: String? { + get { ReadWriteAttribute[Strings.ariaMultiLine, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaMultiLine, in: jsObject] = newValue } + } + + @inlinable var ariaMultiSelectable: String? { + get { ReadWriteAttribute[Strings.ariaMultiSelectable, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaMultiSelectable, in: jsObject] = newValue } + } + + @inlinable var ariaOrientation: String? { + get { ReadWriteAttribute[Strings.ariaOrientation, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaOrientation, in: jsObject] = newValue } + } + + @inlinable var ariaPlaceholder: String? { + get { ReadWriteAttribute[Strings.ariaPlaceholder, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaPlaceholder, in: jsObject] = newValue } + } + + @inlinable var ariaPosInSet: String? { + get { ReadWriteAttribute[Strings.ariaPosInSet, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaPosInSet, in: jsObject] = newValue } + } + + @inlinable var ariaPressed: String? { + get { ReadWriteAttribute[Strings.ariaPressed, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaPressed, in: jsObject] = newValue } + } + + @inlinable var ariaReadOnly: String? { + get { ReadWriteAttribute[Strings.ariaReadOnly, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaReadOnly, in: jsObject] = newValue } + } + + @inlinable var ariaRequired: String? { + get { ReadWriteAttribute[Strings.ariaRequired, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaRequired, in: jsObject] = newValue } + } + + @inlinable var ariaRoleDescription: String? { + get { ReadWriteAttribute[Strings.ariaRoleDescription, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaRoleDescription, in: jsObject] = newValue } + } + + @inlinable var ariaRowCount: String? { + get { ReadWriteAttribute[Strings.ariaRowCount, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaRowCount, in: jsObject] = newValue } + } + + @inlinable var ariaRowIndex: String? { + get { ReadWriteAttribute[Strings.ariaRowIndex, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaRowIndex, in: jsObject] = newValue } + } + + @inlinable var ariaRowIndexText: String? { + get { ReadWriteAttribute[Strings.ariaRowIndexText, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaRowIndexText, in: jsObject] = newValue } + } + + @inlinable var ariaRowSpan: String? { + get { ReadWriteAttribute[Strings.ariaRowSpan, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaRowSpan, in: jsObject] = newValue } + } + + @inlinable var ariaSelected: String? { + get { ReadWriteAttribute[Strings.ariaSelected, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaSelected, in: jsObject] = newValue } + } + + @inlinable var ariaSetSize: String? { + get { ReadWriteAttribute[Strings.ariaSetSize, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaSetSize, in: jsObject] = newValue } + } + + @inlinable var ariaSort: String? { + get { ReadWriteAttribute[Strings.ariaSort, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaSort, in: jsObject] = newValue } + } + + @inlinable var ariaValueMax: String? { + get { ReadWriteAttribute[Strings.ariaValueMax, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaValueMax, in: jsObject] = newValue } + } + + @inlinable var ariaValueMin: String? { + get { ReadWriteAttribute[Strings.ariaValueMin, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaValueMin, in: jsObject] = newValue } + } + + @inlinable var ariaValueNow: String? { + get { ReadWriteAttribute[Strings.ariaValueNow, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaValueNow, in: jsObject] = newValue } + } + + @inlinable var ariaValueText: String? { + get { ReadWriteAttribute[Strings.ariaValueText, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.ariaValueText, in: jsObject] = newValue } + } +} diff --git a/Sources/DOMKit/WebIDL/AbortController.swift b/Sources/DOMKit/WebIDL/AbortController.swift index 1e1aa5f3..12ea808f 100644 --- a/Sources/DOMKit/WebIDL/AbortController.swift +++ b/Sources/DOMKit/WebIDL/AbortController.swift @@ -1,28 +1,27 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class AbortController: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.AbortController.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.AbortController].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _signal = ReadonlyAttribute(jsObject: jsObject, name: "signal") + _signal = ReadonlyAttribute(jsObject: jsObject, name: Strings.signal) self.jsObject = jsObject } - public convenience init() { - self.init(unsafelyWrapping: AbortController.constructor.new()) + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) } @ReadonlyAttribute public var signal: AbortSignal - public func abort() { - _ = jsObject.abort!() + @inlinable public func abort(reason: JSValue? = nil) { + let this = jsObject + _ = this[Strings.abort].function!(this: this, arguments: [reason?.jsValue ?? .undefined]) } } diff --git a/Sources/DOMKit/WebIDL/AbortSignal.swift b/Sources/DOMKit/WebIDL/AbortSignal.swift index 3ce72586..39d006f6 100644 --- a/Sources/DOMKit/WebIDL/AbortSignal.swift +++ b/Sources/DOMKit/WebIDL/AbortSignal.swift @@ -1,22 +1,39 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class AbortSignal: EventTarget { - override public class var constructor: JSFunction { JSObject.global.AbortSignal.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.AbortSignal].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _aborted = ReadonlyAttribute(jsObject: jsObject, name: "aborted") - _onabort = OptionalClosureHandler(jsObject: jsObject, name: "onabort") + _aborted = ReadonlyAttribute(jsObject: jsObject, name: Strings.aborted) + _reason = ReadonlyAttribute(jsObject: jsObject, name: Strings.reason) + _onabort = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onabort) super.init(unsafelyWrapping: jsObject) } + @inlinable public static func abort(reason: JSValue? = nil) -> Self { + let this = constructor + return this[Strings.abort].function!(this: this, arguments: [reason?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public static func timeout(milliseconds: UInt64) -> Self { + let this = constructor + return this[Strings.timeout].function!(this: this, arguments: [milliseconds.jsValue]).fromJSValue()! + } + @ReadonlyAttribute public var aborted: Bool - @OptionalClosureHandler + @ReadonlyAttribute + public var reason: JSValue + + @inlinable public func throwIfAborted() { + let this = jsObject + _ = this[Strings.throwIfAborted].function!(this: this, arguments: []) + } + + @ClosureAttribute1Optional public var onabort: EventHandler } diff --git a/Sources/DOMKit/WebIDL/AbstractRange.swift b/Sources/DOMKit/WebIDL/AbstractRange.swift index 8bd9f93d..8ef0573c 100644 --- a/Sources/DOMKit/WebIDL/AbstractRange.swift +++ b/Sources/DOMKit/WebIDL/AbstractRange.swift @@ -1,21 +1,19 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class AbstractRange: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.AbstractRange.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.AbstractRange].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _startContainer = ReadonlyAttribute(jsObject: jsObject, name: "startContainer") - _startOffset = ReadonlyAttribute(jsObject: jsObject, name: "startOffset") - _endContainer = ReadonlyAttribute(jsObject: jsObject, name: "endContainer") - _endOffset = ReadonlyAttribute(jsObject: jsObject, name: "endOffset") - _collapsed = ReadonlyAttribute(jsObject: jsObject, name: "collapsed") + _startContainer = ReadonlyAttribute(jsObject: jsObject, name: Strings.startContainer) + _startOffset = ReadonlyAttribute(jsObject: jsObject, name: Strings.startOffset) + _endContainer = ReadonlyAttribute(jsObject: jsObject, name: Strings.endContainer) + _endOffset = ReadonlyAttribute(jsObject: jsObject, name: Strings.endOffset) + _collapsed = ReadonlyAttribute(jsObject: jsObject, name: Strings.collapsed) self.jsObject = jsObject } diff --git a/Sources/DOMKit/WebIDL/AbstractWorker.swift b/Sources/DOMKit/WebIDL/AbstractWorker.swift new file mode 100644 index 00000000..eba7eaf0 --- /dev/null +++ b/Sources/DOMKit/WebIDL/AbstractWorker.swift @@ -0,0 +1,12 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol AbstractWorker: JSBridgedClass {} +public extension AbstractWorker { + @inlinable var onerror: EventHandler { + get { ClosureAttribute1Optional[Strings.onerror, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onerror, in: jsObject] = newValue } + } +} diff --git a/Sources/DOMKit/WebIDL/AddEventListenerOptions.swift b/Sources/DOMKit/WebIDL/AddEventListenerOptions.swift index 52ecbe6b..8cd62fd8 100644 --- a/Sources/DOMKit/WebIDL/AddEventListenerOptions.swift +++ b/Sources/DOMKit/WebIDL/AddEventListenerOptions.swift @@ -1,39 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public struct AddEventListenerOptions: ExpressibleByDictionaryLiteral, JSBridgedType { - public enum Key: String, Hashable { - case capture, passive, once - } - - private let dictionary: [String: JSValue] - - public init(uniqueKeysWithValues elements: [(Key, ConvertibleToJSValue)]) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) +public class AddEventListenerOptions: BridgedDictionary { + public convenience init(passive: Bool, once: Bool, signal: AbortSignal) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.passive] = passive.jsValue + object[Strings.once] = once.jsValue + object[Strings.signal] = signal.jsValue + self.init(unsafelyWrapping: object) } - public init(dictionaryLiteral elements: (Key, ConvertibleToJSValue)...) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) + public required init(unsafelyWrapping object: JSObject) { + _passive = ReadWriteAttribute(jsObject: object, name: Strings.passive) + _once = ReadWriteAttribute(jsObject: object, name: Strings.once) + _signal = ReadWriteAttribute(jsObject: object, name: Strings.signal) + super.init(unsafelyWrapping: object) } - subscript(_ key: Key) -> JSValue? { - dictionary[key.rawValue] - } - - public init?(from value: JSValue) { - if let dictionary: [String: JSValue] = value.fromJSValue() { - self.dictionary = dictionary - } - return nil - } + @ReadWriteAttribute + public var passive: Bool - public var value: JSValue { jsValue() } + @ReadWriteAttribute + public var once: Bool - public func jsValue() -> JSValue { - return dictionary.jsValue() - } + @ReadWriteAttribute + public var signal: AbortSignal } diff --git a/Sources/DOMKit/WebIDL/AddEventListenerOptionsOrBool.swift b/Sources/DOMKit/WebIDL/AddEventListenerOptionsOrBool.swift deleted file mode 100644 index 4fb8eed7..00000000 --- a/Sources/DOMKit/WebIDL/AddEventListenerOptionsOrBool.swift +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public enum AddEventListenerOptionsOrBool: JSBridgedType, ExpressibleByBooleanLiteral, ExpressibleByDictionaryLiteral { - case addEventListenerOptions(AddEventListenerOptions) - case bool(Bool) - - public init?(from value: JSValue) { - if let decoded: AddEventListenerOptions = value.fromJSValue() { - self = .addEventListenerOptions(decoded) - } else if let decoded: Bool = value.fromJSValue() { - self = .bool(decoded) - } else { - return nil - } - } - - public init(dictionaryLiteral elements: (AddEventListenerOptions.Key, AddEventListenerOptions.Value)...) { - self = .addEventListenerOptions(.init(uniqueKeysWithValues: elements)) - } - - public init(booleanLiteral value: Bool) { - self = .bool(value) - } - - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - switch self { - case let .addEventListenerOptions(v): return v.jsValue() - case let .bool(v): return v.jsValue() - } - } -} diff --git a/Sources/DOMKit/WebIDL/Animatable.swift b/Sources/DOMKit/WebIDL/Animatable.swift new file mode 100644 index 00000000..74890d13 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Animatable.swift @@ -0,0 +1,17 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Animatable: JSBridgedClass {} +public extension Animatable { + @inlinable func animate(keyframes: JSObject?, options: Double_or_KeyframeAnimationOptions? = nil) -> Animation { + let this = jsObject + return this[Strings.animate].function!(this: this, arguments: [keyframes.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable func getAnimations(options: GetAnimationsOptions? = nil) -> [Animation] { + let this = jsObject + return this[Strings.getAnimations].function!(this: this, arguments: [options?.jsValue ?? .undefined]).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/Animation.swift b/Sources/DOMKit/WebIDL/Animation.swift new file mode 100644 index 00000000..10ac8a0b --- /dev/null +++ b/Sources/DOMKit/WebIDL/Animation.swift @@ -0,0 +1,104 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class Animation: EventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.Animation].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _id = ReadWriteAttribute(jsObject: jsObject, name: Strings.id) + _effect = ReadWriteAttribute(jsObject: jsObject, name: Strings.effect) + _timeline = ReadWriteAttribute(jsObject: jsObject, name: Strings.timeline) + _playbackRate = ReadWriteAttribute(jsObject: jsObject, name: Strings.playbackRate) + _playState = ReadonlyAttribute(jsObject: jsObject, name: Strings.playState) + _replaceState = ReadonlyAttribute(jsObject: jsObject, name: Strings.replaceState) + _pending = ReadonlyAttribute(jsObject: jsObject, name: Strings.pending) + _ready = ReadonlyAttribute(jsObject: jsObject, name: Strings.ready) + _finished = ReadonlyAttribute(jsObject: jsObject, name: Strings.finished) + _onfinish = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onfinish) + _oncancel = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.oncancel) + _onremove = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onremove) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(effect: AnimationEffect? = nil, timeline: AnimationTimeline? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [effect?.jsValue ?? .undefined, timeline?.jsValue ?? .undefined])) + } + + @ReadWriteAttribute + public var id: String + + @ReadWriteAttribute + public var effect: AnimationEffect? + + @ReadWriteAttribute + public var timeline: AnimationTimeline? + + @ReadWriteAttribute + public var playbackRate: Double + + @ReadonlyAttribute + public var playState: AnimationPlayState + + @ReadonlyAttribute + public var replaceState: AnimationReplaceState + + @ReadonlyAttribute + public var pending: Bool + + @ReadonlyAttribute + public var ready: JSPromise + + @ReadonlyAttribute + public var finished: JSPromise + + @ClosureAttribute1Optional + public var onfinish: EventHandler + + @ClosureAttribute1Optional + public var oncancel: EventHandler + + @ClosureAttribute1Optional + public var onremove: EventHandler + + @inlinable public func cancel() { + let this = jsObject + _ = this[Strings.cancel].function!(this: this, arguments: []) + } + + @inlinable public func finish() { + let this = jsObject + _ = this[Strings.finish].function!(this: this, arguments: []) + } + + @inlinable public func play() { + let this = jsObject + _ = this[Strings.play].function!(this: this, arguments: []) + } + + @inlinable public func pause() { + let this = jsObject + _ = this[Strings.pause].function!(this: this, arguments: []) + } + + @inlinable public func updatePlaybackRate(playbackRate: Double) { + let this = jsObject + _ = this[Strings.updatePlaybackRate].function!(this: this, arguments: [playbackRate.jsValue]) + } + + @inlinable public func reverse() { + let this = jsObject + _ = this[Strings.reverse].function!(this: this, arguments: []) + } + + @inlinable public func persist() { + let this = jsObject + _ = this[Strings.persist].function!(this: this, arguments: []) + } + + @inlinable public func commitStyles() { + let this = jsObject + _ = this[Strings.commitStyles].function!(this: this, arguments: []) + } +} diff --git a/Sources/DOMKit/WebIDL/AnimationEffect.swift b/Sources/DOMKit/WebIDL/AnimationEffect.swift new file mode 100644 index 00000000..9865ddd3 --- /dev/null +++ b/Sources/DOMKit/WebIDL/AnimationEffect.swift @@ -0,0 +1,29 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class AnimationEffect: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.AnimationEffect].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + @inlinable public func getTiming() -> EffectTiming { + let this = jsObject + return this[Strings.getTiming].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func getComputedTiming() -> ComputedEffectTiming { + let this = jsObject + return this[Strings.getComputedTiming].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func updateTiming(timing: OptionalEffectTiming? = nil) { + let this = jsObject + _ = this[Strings.updateTiming].function!(this: this, arguments: [timing?.jsValue ?? .undefined]) + } +} diff --git a/Sources/DOMKit/WebIDL/AnimationFrameProvider.swift b/Sources/DOMKit/WebIDL/AnimationFrameProvider.swift new file mode 100644 index 00000000..49db0432 --- /dev/null +++ b/Sources/DOMKit/WebIDL/AnimationFrameProvider.swift @@ -0,0 +1,14 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol AnimationFrameProvider: JSBridgedClass {} +public extension AnimationFrameProvider { + // XXX: method 'requestAnimationFrame' is ignored + + @inlinable func cancelAnimationFrame(handle: UInt32) { + let this = jsObject + _ = this[Strings.cancelAnimationFrame].function!(this: this, arguments: [handle.jsValue]) + } +} diff --git a/Sources/DOMKit/WebIDL/AnimationPlayState.swift b/Sources/DOMKit/WebIDL/AnimationPlayState.swift new file mode 100644 index 00000000..2231613f --- /dev/null +++ b/Sources/DOMKit/WebIDL/AnimationPlayState.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum AnimationPlayState: JSString, JSValueCompatible { + case idle = "idle" + case running = "running" + case paused = "paused" + case finished = "finished" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/AnimationReplaceState.swift b/Sources/DOMKit/WebIDL/AnimationReplaceState.swift new file mode 100644 index 00000000..02e0796c --- /dev/null +++ b/Sources/DOMKit/WebIDL/AnimationReplaceState.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum AnimationReplaceState: JSString, JSValueCompatible { + case active = "active" + case removed = "removed" + case persisted = "persisted" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/AnimationTimeline.swift b/Sources/DOMKit/WebIDL/AnimationTimeline.swift new file mode 100644 index 00000000..96e84a17 --- /dev/null +++ b/Sources/DOMKit/WebIDL/AnimationTimeline.swift @@ -0,0 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class AnimationTimeline: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.AnimationTimeline].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _currentTime = ReadonlyAttribute(jsObject: jsObject, name: Strings.currentTime) + _phase = ReadonlyAttribute(jsObject: jsObject, name: Strings.phase) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var currentTime: Double? + + @ReadonlyAttribute + public var phase: TimelinePhase +} diff --git a/Sources/DOMKit/WebIDL/AnyChildNode.swift b/Sources/DOMKit/WebIDL/AnyChildNode.swift deleted file mode 100644 index 3e33134c..00000000 --- a/Sources/DOMKit/WebIDL/AnyChildNode.swift +++ /dev/null @@ -1,16 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -class AnyChildNode: JSBridgedClass, ChildNode { - public class var constructor: JSFunction { JSObject.global.ChildNode.function! } - - let jsObject: JSObject - - required init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } -} diff --git a/Sources/DOMKit/WebIDL/AnyDocumentOrShadowRoot.swift b/Sources/DOMKit/WebIDL/AnyDocumentOrShadowRoot.swift deleted file mode 100644 index 8970399d..00000000 --- a/Sources/DOMKit/WebIDL/AnyDocumentOrShadowRoot.swift +++ /dev/null @@ -1,16 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -class AnyDocumentOrShadowRoot: JSBridgedClass, DocumentOrShadowRoot { - public class var constructor: JSFunction { JSObject.global.DocumentOrShadowRoot.function! } - - let jsObject: JSObject - - required init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } -} diff --git a/Sources/DOMKit/WebIDL/AnyElementContentEditable.swift b/Sources/DOMKit/WebIDL/AnyElementContentEditable.swift deleted file mode 100644 index 68deb5c7..00000000 --- a/Sources/DOMKit/WebIDL/AnyElementContentEditable.swift +++ /dev/null @@ -1,16 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -class AnyElementContentEditable: JSBridgedClass, ElementContentEditable { - public class var constructor: JSFunction { JSObject.global.ElementContentEditable.function! } - - let jsObject: JSObject - - required init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } -} diff --git a/Sources/DOMKit/WebIDL/AnyEventListener.swift b/Sources/DOMKit/WebIDL/AnyEventListener.swift deleted file mode 100644 index 9692354f..00000000 --- a/Sources/DOMKit/WebIDL/AnyEventListener.swift +++ /dev/null @@ -1,20 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -class AnyEventListener: JSBridgedClass, EventListener { - public class var constructor: JSFunction { JSObject.global.EventListener.function! } - - let jsObject: JSObject - - required init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - public func handleEvent(event: Event) { - _ = jsObject.handleEvent!(event.jsValue()) - } -} diff --git a/Sources/DOMKit/WebIDL/AnyHTMLOrSVGElement.swift b/Sources/DOMKit/WebIDL/AnyHTMLOrSVGElement.swift deleted file mode 100644 index 1f19b418..00000000 --- a/Sources/DOMKit/WebIDL/AnyHTMLOrSVGElement.swift +++ /dev/null @@ -1,16 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -class AnyHTMLOrSVGElement: JSBridgedClass, HTMLOrSVGElement { - public class var constructor: JSFunction { JSObject.global.HTMLOrSVGElement.function! } - - let jsObject: JSObject - - required init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } -} diff --git a/Sources/DOMKit/WebIDL/AnyNodeFilter.swift b/Sources/DOMKit/WebIDL/AnyNodeFilter.swift deleted file mode 100644 index 1cabf105..00000000 --- a/Sources/DOMKit/WebIDL/AnyNodeFilter.swift +++ /dev/null @@ -1,20 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -class AnyNodeFilter: JSBridgedClass, NodeFilter { - public class var constructor: JSFunction { JSObject.global.NodeFilter.function! } - - let jsObject: JSObject - - required init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - public func acceptNode(node: Node) -> UInt16 { - return jsObject.acceptNode!(node.jsValue()).fromJSValue()! - } -} diff --git a/Sources/DOMKit/WebIDL/AnyNonDocumentTypeChildNode.swift b/Sources/DOMKit/WebIDL/AnyNonDocumentTypeChildNode.swift deleted file mode 100644 index a56a017c..00000000 --- a/Sources/DOMKit/WebIDL/AnyNonDocumentTypeChildNode.swift +++ /dev/null @@ -1,16 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -class AnyNonDocumentTypeChildNode: JSBridgedClass, NonDocumentTypeChildNode { - public class var constructor: JSFunction { JSObject.global.NonDocumentTypeChildNode.function! } - - let jsObject: JSObject - - required init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } -} diff --git a/Sources/DOMKit/WebIDL/AnyNonElementParentNode.swift b/Sources/DOMKit/WebIDL/AnyNonElementParentNode.swift deleted file mode 100644 index 5eb2c437..00000000 --- a/Sources/DOMKit/WebIDL/AnyNonElementParentNode.swift +++ /dev/null @@ -1,16 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -class AnyNonElementParentNode: JSBridgedClass, NonElementParentNode { - public class var constructor: JSFunction { JSObject.global.NonElementParentNode.function! } - - let jsObject: JSObject - - required init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } -} diff --git a/Sources/DOMKit/WebIDL/AnyParentNode.swift b/Sources/DOMKit/WebIDL/AnyParentNode.swift deleted file mode 100644 index 4bea759d..00000000 --- a/Sources/DOMKit/WebIDL/AnyParentNode.swift +++ /dev/null @@ -1,16 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -class AnyParentNode: JSBridgedClass, ParentNode { - public class var constructor: JSFunction { JSObject.global.ParentNode.function! } - - let jsObject: JSObject - - required init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } -} diff --git a/Sources/DOMKit/WebIDL/AnySlotable.swift b/Sources/DOMKit/WebIDL/AnySlotable.swift deleted file mode 100644 index 48257cc5..00000000 --- a/Sources/DOMKit/WebIDL/AnySlotable.swift +++ /dev/null @@ -1,16 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -class AnySlotable: JSBridgedClass, Slotable { - public class var constructor: JSFunction { JSObject.global.Slotable.function! } - - let jsObject: JSObject - - required init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } -} diff --git a/Sources/DOMKit/WebIDL/AnyWindowEventHandlers.swift b/Sources/DOMKit/WebIDL/AnyWindowEventHandlers.swift deleted file mode 100644 index bba0e745..00000000 --- a/Sources/DOMKit/WebIDL/AnyWindowEventHandlers.swift +++ /dev/null @@ -1,16 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -class AnyWindowEventHandlers: JSBridgedClass, WindowEventHandlers { - public class var constructor: JSFunction { JSObject.global.WindowEventHandlers.function! } - - let jsObject: JSObject - - required init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } -} diff --git a/Sources/DOMKit/WebIDL/AnyXPathEvaluatorBase.swift b/Sources/DOMKit/WebIDL/AnyXPathEvaluatorBase.swift deleted file mode 100644 index 354dac84..00000000 --- a/Sources/DOMKit/WebIDL/AnyXPathEvaluatorBase.swift +++ /dev/null @@ -1,16 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -class AnyXPathEvaluatorBase: JSBridgedClass, XPathEvaluatorBase { - public class var constructor: JSFunction { JSObject.global.XPathEvaluatorBase.function! } - - let jsObject: JSObject - - required init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } -} diff --git a/Sources/DOMKit/WebIDL/AnyXPathNSResolver.swift b/Sources/DOMKit/WebIDL/AnyXPathNSResolver.swift deleted file mode 100644 index 81095b32..00000000 --- a/Sources/DOMKit/WebIDL/AnyXPathNSResolver.swift +++ /dev/null @@ -1,20 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -class AnyXPathNSResolver: JSBridgedClass, XPathNSResolver { - public class var constructor: JSFunction { JSObject.global.XPathNSResolver.function! } - - let jsObject: JSObject - - required init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - public func lookupNamespaceURI(prefix: String?) -> String? { - return jsObject.lookupNamespaceURI!(prefix.jsValue()).fromJSValue()! - } -} diff --git a/Sources/DOMKit/WebIDL/ArrayBufferView.swift b/Sources/DOMKit/WebIDL/ArrayBufferView.swift deleted file mode 100644 index 1cc4e1c2..00000000 --- a/Sources/DOMKit/WebIDL/ArrayBufferView.swift +++ /dev/null @@ -1,62 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public enum ArrayBufferView: JSBridgedType { - case int8Array(JSTypedArray) - case int16Array(JSTypedArray) - case int32Array(JSTypedArray) - case uint8Array(JSTypedArray) - case uint16Array(JSTypedArray) - case uint32Array(JSTypedArray) - case uint8ClampedArray(JSTypedArray) - case float32Array(JSTypedArray) - case float64Array(JSTypedArray) - case dataView(DataView) - - public init?(from value: JSValue) { - if let decoded: JSTypedArray = value.fromJSValue() { - self = .int8Array(decoded) - } else if let decoded: JSTypedArray = value.fromJSValue() { - self = .int16Array(decoded) - } else if let decoded: JSTypedArray = value.fromJSValue() { - self = .int32Array(decoded) - } else if let decoded: JSTypedArray = value.fromJSValue() { - self = .uint8Array(decoded) - } else if let decoded: JSTypedArray = value.fromJSValue() { - self = .uint16Array(decoded) - } else if let decoded: JSTypedArray = value.fromJSValue() { - self = .uint32Array(decoded) - } else if let decoded: JSTypedArray = value.fromJSValue() { - self = .uint8ClampedArray(decoded) - } else if let decoded: JSTypedArray = value.fromJSValue() { - self = .float32Array(decoded) - } else if let decoded: JSTypedArray = value.fromJSValue() { - self = .float64Array(decoded) - } else if let decoded: DataView = value.fromJSValue() { - self = .dataView(decoded) - } else { - return nil - } - } - - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - switch self { - case let .int8Array(v): return v.jsValue() - case let .int16Array(v): return v.jsValue() - case let .int32Array(v): return v.jsValue() - case let .uint8Array(v): return v.jsValue() - case let .uint16Array(v): return v.jsValue() - case let .uint32Array(v): return v.jsValue() - case let .uint8ClampedArray(v): return v.jsValue() - case let .float32Array(v): return v.jsValue() - case let .float64Array(v): return v.jsValue() - case let .dataView(v): return v.jsValue() - } - } -} diff --git a/Sources/DOMKit/WebIDL/ArrayBufferViewOrArrayBuffer.swift b/Sources/DOMKit/WebIDL/ArrayBufferViewOrArrayBuffer.swift deleted file mode 100644 index 2f97f7e7..00000000 --- a/Sources/DOMKit/WebIDL/ArrayBufferViewOrArrayBuffer.swift +++ /dev/null @@ -1,30 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public enum ArrayBufferViewOrArrayBuffer: JSBridgedType { - case arrayBufferView(ArrayBufferView) - case arrayBuffer(ArrayBuffer) - - public init?(from value: JSValue) { - if let decoded: ArrayBufferView = value.fromJSValue() { - self = .arrayBufferView(decoded) - } else if let decoded: ArrayBuffer = value.fromJSValue() { - self = .arrayBuffer(decoded) - } else { - return nil - } - } - - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - switch self { - case let .arrayBufferView(v): return v.jsValue() - case let .arrayBuffer(v): return v.jsValue() - } - } -} diff --git a/Sources/DOMKit/WebIDL/ArrayBuffer_or_String.swift b/Sources/DOMKit/WebIDL/ArrayBuffer_or_String.swift new file mode 100644 index 00000000..9fc28f17 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ArrayBuffer_or_String.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_ArrayBuffer_or_String: ConvertibleToJSValue {} +extension ArrayBuffer: Any_ArrayBuffer_or_String {} +extension String: Any_ArrayBuffer_or_String {} + +public enum ArrayBuffer_or_String: JSValueCompatible, Any_ArrayBuffer_or_String { + case arrayBuffer(ArrayBuffer) + case string(String) + + var arrayBuffer: ArrayBuffer? { + switch self { + case let .arrayBuffer(arrayBuffer): return arrayBuffer + default: return nil + } + } + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let arrayBuffer: ArrayBuffer = value.fromJSValue() { + return .arrayBuffer(arrayBuffer) + } + if let string: String = value.fromJSValue() { + return .string(string) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .arrayBuffer(arrayBuffer): + return arrayBuffer.jsValue + case let .string(string): + return string.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/AssignedNodesOptions.swift b/Sources/DOMKit/WebIDL/AssignedNodesOptions.swift index 8754b6ac..65a10d5c 100644 --- a/Sources/DOMKit/WebIDL/AssignedNodesOptions.swift +++ b/Sources/DOMKit/WebIDL/AssignedNodesOptions.swift @@ -1,39 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public struct AssignedNodesOptions: ExpressibleByDictionaryLiteral, JSBridgedType { - public enum Key: String, Hashable { - case flatten - } - - private let dictionary: [String: JSValue] - - public init(uniqueKeysWithValues elements: [(Key, ConvertibleToJSValue)]) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } - - public init(dictionaryLiteral elements: (Key, ConvertibleToJSValue)...) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } - - subscript(_ key: Key) -> JSValue? { - dictionary[key.rawValue] +public class AssignedNodesOptions: BridgedDictionary { + public convenience init(flatten: Bool) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.flatten] = flatten.jsValue + self.init(unsafelyWrapping: object) } - public init?(from value: JSValue) { - if let dictionary: [String: JSValue] = value.fromJSValue() { - self.dictionary = dictionary - } - return nil + public required init(unsafelyWrapping object: JSObject) { + _flatten = ReadWriteAttribute(jsObject: object, name: Strings.flatten) + super.init(unsafelyWrapping: object) } - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - return dictionary.jsValue() - } + @ReadWriteAttribute + public var flatten: Bool } diff --git a/Sources/DOMKit/WebIDL/Attr.swift b/Sources/DOMKit/WebIDL/Attr.swift index 7de219b2..226dfbea 100644 --- a/Sources/DOMKit/WebIDL/Attr.swift +++ b/Sources/DOMKit/WebIDL/Attr.swift @@ -1,21 +1,19 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class Attr: Node { - override public class var constructor: JSFunction { JSObject.global.Attr.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.Attr].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _namespaceURI = ReadonlyAttribute(jsObject: jsObject, name: "namespaceURI") - _prefix = ReadonlyAttribute(jsObject: jsObject, name: "prefix") - _localName = ReadonlyAttribute(jsObject: jsObject, name: "localName") - _name = ReadonlyAttribute(jsObject: jsObject, name: "name") - _value = ReadWriteAttribute(jsObject: jsObject, name: "value") - _ownerElement = ReadonlyAttribute(jsObject: jsObject, name: "ownerElement") - _specified = ReadonlyAttribute(jsObject: jsObject, name: "specified") + _namespaceURI = ReadonlyAttribute(jsObject: jsObject, name: Strings.namespaceURI) + _prefix = ReadonlyAttribute(jsObject: jsObject, name: Strings.prefix) + _localName = ReadonlyAttribute(jsObject: jsObject, name: Strings.localName) + _name = ReadonlyAttribute(jsObject: jsObject, name: Strings.name) + _value = ReadWriteAttribute(jsObject: jsObject, name: Strings.value) + _ownerElement = ReadonlyAttribute(jsObject: jsObject, name: Strings.ownerElement) + _specified = ReadonlyAttribute(jsObject: jsObject, name: Strings.specified) super.init(unsafelyWrapping: jsObject) } diff --git a/Sources/DOMKit/WebIDL/AudioTrack.swift b/Sources/DOMKit/WebIDL/AudioTrack.swift new file mode 100644 index 00000000..5ff80c06 --- /dev/null +++ b/Sources/DOMKit/WebIDL/AudioTrack.swift @@ -0,0 +1,34 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class AudioTrack: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.AudioTrack].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _id = ReadonlyAttribute(jsObject: jsObject, name: Strings.id) + _kind = ReadonlyAttribute(jsObject: jsObject, name: Strings.kind) + _label = ReadonlyAttribute(jsObject: jsObject, name: Strings.label) + _language = ReadonlyAttribute(jsObject: jsObject, name: Strings.language) + _enabled = ReadWriteAttribute(jsObject: jsObject, name: Strings.enabled) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var id: String + + @ReadonlyAttribute + public var kind: String + + @ReadonlyAttribute + public var label: String + + @ReadonlyAttribute + public var language: String + + @ReadWriteAttribute + public var enabled: Bool +} diff --git a/Sources/DOMKit/WebIDL/AudioTrackList.swift b/Sources/DOMKit/WebIDL/AudioTrackList.swift new file mode 100644 index 00000000..0fd4aea7 --- /dev/null +++ b/Sources/DOMKit/WebIDL/AudioTrackList.swift @@ -0,0 +1,37 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class AudioTrackList: EventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.AudioTrackList].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + _onchange = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onchange) + _onaddtrack = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onaddtrack) + _onremovetrack = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onremovetrack) + super.init(unsafelyWrapping: jsObject) + } + + @ReadonlyAttribute + public var length: UInt32 + + @inlinable public subscript(key: Int) -> AudioTrack { + jsObject[key].fromJSValue()! + } + + @inlinable public func getTrackById(id: String) -> AudioTrack? { + let this = jsObject + return this[Strings.getTrackById].function!(this: this, arguments: [id.jsValue]).fromJSValue()! + } + + @ClosureAttribute1Optional + public var onchange: EventHandler + + @ClosureAttribute1Optional + public var onaddtrack: EventHandler + + @ClosureAttribute1Optional + public var onremovetrack: EventHandler +} diff --git a/Sources/DOMKit/WebIDL/AudioTrack_or_TextTrack_or_VideoTrack.swift b/Sources/DOMKit/WebIDL/AudioTrack_or_TextTrack_or_VideoTrack.swift new file mode 100644 index 00000000..10ac922e --- /dev/null +++ b/Sources/DOMKit/WebIDL/AudioTrack_or_TextTrack_or_VideoTrack.swift @@ -0,0 +1,60 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_AudioTrack_or_TextTrack_or_VideoTrack: ConvertibleToJSValue {} +extension AudioTrack: Any_AudioTrack_or_TextTrack_or_VideoTrack {} +extension TextTrack: Any_AudioTrack_or_TextTrack_or_VideoTrack {} +extension VideoTrack: Any_AudioTrack_or_TextTrack_or_VideoTrack {} + +public enum AudioTrack_or_TextTrack_or_VideoTrack: JSValueCompatible, Any_AudioTrack_or_TextTrack_or_VideoTrack { + case audioTrack(AudioTrack) + case textTrack(TextTrack) + case videoTrack(VideoTrack) + + var audioTrack: AudioTrack? { + switch self { + case let .audioTrack(audioTrack): return audioTrack + default: return nil + } + } + + var textTrack: TextTrack? { + switch self { + case let .textTrack(textTrack): return textTrack + default: return nil + } + } + + var videoTrack: VideoTrack? { + switch self { + case let .videoTrack(videoTrack): return videoTrack + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let audioTrack: AudioTrack = value.fromJSValue() { + return .audioTrack(audioTrack) + } + if let textTrack: TextTrack = value.fromJSValue() { + return .textTrack(textTrack) + } + if let videoTrack: VideoTrack = value.fromJSValue() { + return .videoTrack(videoTrack) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .audioTrack(audioTrack): + return audioTrack.jsValue + case let .textTrack(textTrack): + return textTrack.jsValue + case let .videoTrack(videoTrack): + return videoTrack.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/BarProp.swift b/Sources/DOMKit/WebIDL/BarProp.swift new file mode 100644 index 00000000..23a2f8ad --- /dev/null +++ b/Sources/DOMKit/WebIDL/BarProp.swift @@ -0,0 +1,18 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class BarProp: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.BarProp].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _visible = ReadonlyAttribute(jsObject: jsObject, name: Strings.visible) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var visible: Bool +} diff --git a/Sources/DOMKit/WebIDL/BaseComputedKeyframe.swift b/Sources/DOMKit/WebIDL/BaseComputedKeyframe.swift new file mode 100644 index 00000000..3a88e7dc --- /dev/null +++ b/Sources/DOMKit/WebIDL/BaseComputedKeyframe.swift @@ -0,0 +1,35 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class BaseComputedKeyframe: BridgedDictionary { + public convenience init(offset: Double?, computedOffset: Double, easing: String, composite: CompositeOperationOrAuto) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.offset] = offset.jsValue + object[Strings.computedOffset] = computedOffset.jsValue + object[Strings.easing] = easing.jsValue + object[Strings.composite] = composite.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _offset = ReadWriteAttribute(jsObject: object, name: Strings.offset) + _computedOffset = ReadWriteAttribute(jsObject: object, name: Strings.computedOffset) + _easing = ReadWriteAttribute(jsObject: object, name: Strings.easing) + _composite = ReadWriteAttribute(jsObject: object, name: Strings.composite) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var offset: Double? + + @ReadWriteAttribute + public var computedOffset: Double + + @ReadWriteAttribute + public var easing: String + + @ReadWriteAttribute + public var composite: CompositeOperationOrAuto +} diff --git a/Sources/DOMKit/WebIDL/BaseKeyframe.swift b/Sources/DOMKit/WebIDL/BaseKeyframe.swift new file mode 100644 index 00000000..74d9634a --- /dev/null +++ b/Sources/DOMKit/WebIDL/BaseKeyframe.swift @@ -0,0 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class BaseKeyframe: BridgedDictionary { + public convenience init(offset: Double?, easing: String, composite: CompositeOperationOrAuto) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.offset] = offset.jsValue + object[Strings.easing] = easing.jsValue + object[Strings.composite] = composite.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _offset = ReadWriteAttribute(jsObject: object, name: Strings.offset) + _easing = ReadWriteAttribute(jsObject: object, name: Strings.easing) + _composite = ReadWriteAttribute(jsObject: object, name: Strings.composite) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var offset: Double? + + @ReadWriteAttribute + public var easing: String + + @ReadWriteAttribute + public var composite: CompositeOperationOrAuto +} diff --git a/Sources/DOMKit/WebIDL/BasePropertyIndexedKeyframe.swift b/Sources/DOMKit/WebIDL/BasePropertyIndexedKeyframe.swift new file mode 100644 index 00000000..9e0f1e22 --- /dev/null +++ b/Sources/DOMKit/WebIDL/BasePropertyIndexedKeyframe.swift @@ -0,0 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class BasePropertyIndexedKeyframe: BridgedDictionary { + public convenience init(offset: nullable_Double_or_seq_of_nullable_Double, easing: String_or_seq_of_String, composite: CompositeOperationOrAuto_or_seq_of_CompositeOperationOrAuto) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.offset] = offset.jsValue + object[Strings.easing] = easing.jsValue + object[Strings.composite] = composite.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _offset = ReadWriteAttribute(jsObject: object, name: Strings.offset) + _easing = ReadWriteAttribute(jsObject: object, name: Strings.easing) + _composite = ReadWriteAttribute(jsObject: object, name: Strings.composite) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var offset: nullable_Double_or_seq_of_nullable_Double + + @ReadWriteAttribute + public var easing: String_or_seq_of_String + + @ReadWriteAttribute + public var composite: CompositeOperationOrAuto_or_seq_of_CompositeOperationOrAuto +} diff --git a/Sources/DOMKit/WebIDL/BeforeUnloadEvent.swift b/Sources/DOMKit/WebIDL/BeforeUnloadEvent.swift new file mode 100644 index 00000000..2a0e7506 --- /dev/null +++ b/Sources/DOMKit/WebIDL/BeforeUnloadEvent.swift @@ -0,0 +1,14 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class BeforeUnloadEvent: Event { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.BeforeUnloadEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + super.init(unsafelyWrapping: jsObject) + } + + // XXX: member 'returnValue' is ignored +} diff --git a/Sources/DOMKit/WebIDL/Blob.swift b/Sources/DOMKit/WebIDL/Blob.swift index e568adb1..c8eb905a 100644 --- a/Sources/DOMKit/WebIDL/Blob.swift +++ b/Sources/DOMKit/WebIDL/Blob.swift @@ -1,27 +1,21 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class Blob: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.Blob.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.Blob].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _size = ReadonlyAttribute(jsObject: jsObject, name: "size") - _type = ReadonlyAttribute(jsObject: jsObject, name: "type") + _size = ReadonlyAttribute(jsObject: jsObject, name: Strings.size) + _type = ReadonlyAttribute(jsObject: jsObject, name: Strings.type) self.jsObject = jsObject } - public convenience init(blobParts: [BlobPart], options: BlobPropertyBag = [:]) { - self.init(unsafelyWrapping: Blob.constructor.new(blobParts.jsValue(), options.jsValue())) - } - - public convenience init() { - self.init(unsafelyWrapping: Blob.constructor.new()) + @inlinable public convenience init(blobParts: [BlobPart]? = nil, options: BlobPropertyBag? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [blobParts?.jsValue ?? .undefined, options?.jsValue ?? .undefined])) } @ReadonlyAttribute @@ -30,31 +24,34 @@ public class Blob: JSBridgedClass { @ReadonlyAttribute public var type: String - public func slice(start: Int64, end: Int64, contentType: String) -> Blob { - return jsObject.slice!(start.jsValue(), end.jsValue(), contentType.jsValue()).fromJSValue()! + @inlinable public func slice(start: Int64? = nil, end: Int64? = nil, contentType: String? = nil) -> Self { + let this = jsObject + return this[Strings.slice].function!(this: this, arguments: [start?.jsValue ?? .undefined, end?.jsValue ?? .undefined, contentType?.jsValue ?? .undefined]).fromJSValue()! } - public func slice(start: Int64, end: Int64) -> Blob { - return jsObject.slice!(start.jsValue(), end.jsValue()).fromJSValue()! - } - - public func slice(start: Int64) -> Blob { - return jsObject.slice!(start.jsValue()).fromJSValue()! - } + // XXX: member 'stream' is ignored - public func slice() -> Blob { - return jsObject.slice!().fromJSValue()! + @inlinable public func text() -> JSPromise { + let this = jsObject + return this[Strings.text].function!(this: this, arguments: []).fromJSValue()! } - public func stream() -> ReadableStream { - return jsObject.stream!().fromJSValue()! + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func text() async throws -> String { + let this = jsObject + let _promise: JSPromise = this[Strings.text].function!(this: this, arguments: []).fromJSValue()! + return try await _promise.value.fromJSValue()! } - public func text() -> JSPromise { - return jsObject.text!().fromJSValue()! + @inlinable public func arrayBuffer() -> JSPromise { + let this = jsObject + return this[Strings.arrayBuffer].function!(this: this, arguments: []).fromJSValue()! } - public func arrayBuffer() -> JSPromise { - return jsObject.arrayBuffer!().fromJSValue()! + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func arrayBuffer() async throws -> ArrayBuffer { + let this = jsObject + let _promise: JSPromise = this[Strings.arrayBuffer].function!(this: this, arguments: []).fromJSValue()! + return try await _promise.value.fromJSValue()! } } diff --git a/Sources/DOMKit/WebIDL/BlobPart.swift b/Sources/DOMKit/WebIDL/BlobPart.swift index fd2c3bea..ea19e902 100644 --- a/Sources/DOMKit/WebIDL/BlobPart.swift +++ b/Sources/DOMKit/WebIDL/BlobPart.swift @@ -1,8 +1,60 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public typealias BlobPart = BufferSourceOrBlobOrString +public protocol Any_BlobPart: ConvertibleToJSValue {} +extension Blob: Any_BlobPart {} +extension BufferSource: Any_BlobPart {} +extension String: Any_BlobPart {} + +public enum BlobPart: JSValueCompatible, Any_BlobPart { + case blob(Blob) + case bufferSource(BufferSource) + case string(String) + + var blob: Blob? { + switch self { + case let .blob(blob): return blob + default: return nil + } + } + + var bufferSource: BufferSource? { + switch self { + case let .bufferSource(bufferSource): return bufferSource + default: return nil + } + } + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let blob: Blob = value.fromJSValue() { + return .blob(blob) + } + if let bufferSource: BufferSource = value.fromJSValue() { + return .bufferSource(bufferSource) + } + if let string: String = value.fromJSValue() { + return .string(string) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .blob(blob): + return blob.jsValue + case let .bufferSource(bufferSource): + return bufferSource.jsValue + case let .string(string): + return string.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/BlobPropertyBag.swift b/Sources/DOMKit/WebIDL/BlobPropertyBag.swift index 8dd21c0f..3db421ff 100644 --- a/Sources/DOMKit/WebIDL/BlobPropertyBag.swift +++ b/Sources/DOMKit/WebIDL/BlobPropertyBag.swift @@ -1,39 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public struct BlobPropertyBag: ExpressibleByDictionaryLiteral, JSBridgedType { - public enum Key: String, Hashable { - case type, endings +public class BlobPropertyBag: BridgedDictionary { + public convenience init(type: String, endings: EndingType) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.type] = type.jsValue + object[Strings.endings] = endings.jsValue + self.init(unsafelyWrapping: object) } - private let dictionary: [String: JSValue] - - public init(uniqueKeysWithValues elements: [(Key, ConvertibleToJSValue)]) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) + public required init(unsafelyWrapping object: JSObject) { + _type = ReadWriteAttribute(jsObject: object, name: Strings.type) + _endings = ReadWriteAttribute(jsObject: object, name: Strings.endings) + super.init(unsafelyWrapping: object) } - public init(dictionaryLiteral elements: (Key, ConvertibleToJSValue)...) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } - - subscript(_ key: Key) -> JSValue? { - dictionary[key.rawValue] - } + @ReadWriteAttribute + public var type: String - public init?(from value: JSValue) { - if let dictionary: [String: JSValue] = value.fromJSValue() { - self.dictionary = dictionary - } - return nil - } - - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - return dictionary.jsValue() - } + @ReadWriteAttribute + public var endings: EndingType } diff --git a/Sources/DOMKit/WebIDL/Body.swift b/Sources/DOMKit/WebIDL/Body.swift new file mode 100644 index 00000000..687e62b6 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Body.swift @@ -0,0 +1,71 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Body: JSBridgedClass {} +public extension Body { + // XXX: attribute 'body' is ignored + + @inlinable var bodyUsed: Bool { ReadonlyAttribute[Strings.bodyUsed, in: jsObject] } + + @inlinable func arrayBuffer() -> JSPromise { + let this = jsObject + return this[Strings.arrayBuffer].function!(this: this, arguments: []).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable func arrayBuffer() async throws -> ArrayBuffer { + let this = jsObject + let _promise: JSPromise = this[Strings.arrayBuffer].function!(this: this, arguments: []).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable func blob() -> JSPromise { + let this = jsObject + return this[Strings.blob].function!(this: this, arguments: []).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable func blob() async throws -> Blob { + let this = jsObject + let _promise: JSPromise = this[Strings.blob].function!(this: this, arguments: []).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable func formData() -> JSPromise { + let this = jsObject + return this[Strings.formData].function!(this: this, arguments: []).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable func formData() async throws -> FormData { + let this = jsObject + let _promise: JSPromise = this[Strings.formData].function!(this: this, arguments: []).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable func json() -> JSPromise { + let this = jsObject + return this[Strings.json].function!(this: this, arguments: []).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable func json() async throws -> JSValue { + let this = jsObject + let _promise: JSPromise = this[Strings.json].function!(this: this, arguments: []).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable func text() -> JSPromise { + let this = jsObject + return this[Strings.text].function!(this: this, arguments: []).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable func text() async throws -> String { + let this = jsObject + let _promise: JSPromise = this[Strings.text].function!(this: this, arguments: []).fromJSValue()! + return try await _promise.value.fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/BroadcastChannel.swift b/Sources/DOMKit/WebIDL/BroadcastChannel.swift new file mode 100644 index 00000000..fcec4d0d --- /dev/null +++ b/Sources/DOMKit/WebIDL/BroadcastChannel.swift @@ -0,0 +1,38 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class BroadcastChannel: EventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.BroadcastChannel].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _name = ReadonlyAttribute(jsObject: jsObject, name: Strings.name) + _onmessage = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onmessage) + _onmessageerror = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onmessageerror) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(name: String) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [name.jsValue])) + } + + @ReadonlyAttribute + public var name: String + + @inlinable public func postMessage(message: JSValue) { + let this = jsObject + _ = this[Strings.postMessage].function!(this: this, arguments: [message.jsValue]) + } + + @inlinable public func close() { + let this = jsObject + _ = this[Strings.close].function!(this: this, arguments: []) + } + + @ClosureAttribute1Optional + public var onmessage: EventHandler + + @ClosureAttribute1Optional + public var onmessageerror: EventHandler +} diff --git a/Sources/DOMKit/WebIDL/BufferSource.swift b/Sources/DOMKit/WebIDL/BufferSource.swift index 93c62692..6e6a2f33 100644 --- a/Sources/DOMKit/WebIDL/BufferSource.swift +++ b/Sources/DOMKit/WebIDL/BufferSource.swift @@ -1,8 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public typealias BufferSource = ArrayBufferViewOrArrayBuffer +public protocol Any_BufferSource: ConvertibleToJSValue {} +extension ArrayBuffer: Any_BufferSource {} +extension ArrayBufferView: Any_BufferSource {} + +public enum BufferSource: JSValueCompatible, Any_BufferSource { + case arrayBuffer(ArrayBuffer) + case arrayBufferView(ArrayBufferView) + + var arrayBuffer: ArrayBuffer? { + switch self { + case let .arrayBuffer(arrayBuffer): return arrayBuffer + default: return nil + } + } + + var arrayBufferView: ArrayBufferView? { + switch self { + case let .arrayBufferView(arrayBufferView): return arrayBufferView + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let arrayBuffer: ArrayBuffer = value.fromJSValue() { + return .arrayBuffer(arrayBuffer) + } + if let arrayBufferView: ArrayBufferView = value.fromJSValue() { + return .arrayBufferView(arrayBufferView) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .arrayBuffer(arrayBuffer): + return arrayBuffer.jsValue + case let .arrayBufferView(arrayBufferView): + return arrayBufferView.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/BufferSourceOrBlobOrString.swift b/Sources/DOMKit/WebIDL/BufferSourceOrBlobOrString.swift deleted file mode 100644 index 992e339d..00000000 --- a/Sources/DOMKit/WebIDL/BufferSourceOrBlobOrString.swift +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public enum BufferSourceOrBlobOrString: JSBridgedType, ExpressibleByStringLiteral { - case bufferSource(BufferSource) - case blob(Blob) - case string(String) - - public init?(from value: JSValue) { - if let decoded: BufferSource = value.fromJSValue() { - self = .bufferSource(decoded) - } else if let decoded: Blob = value.fromJSValue() { - self = .blob(decoded) - } else if let decoded: String = value.fromJSValue() { - self = .string(decoded) - } else { - return nil - } - } - - public init(stringLiteral value: String) { - self = .string(value) - } - - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - switch self { - case let .bufferSource(v): return v.jsValue() - case let .blob(v): return v.jsValue() - case let .string(v): return v.jsValue() - } - } -} diff --git a/Sources/DOMKit/WebIDL/CDATASection.swift b/Sources/DOMKit/WebIDL/CDATASection.swift index a37141c1..99b6d27f 100644 --- a/Sources/DOMKit/WebIDL/CDATASection.swift +++ b/Sources/DOMKit/WebIDL/CDATASection.swift @@ -1,12 +1,10 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class CDATASection: Text { - override public class var constructor: JSFunction { JSObject.global.CDATASection.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.CDATASection].function! } public required init(unsafelyWrapping jsObject: JSObject) { super.init(unsafelyWrapping: jsObject) diff --git a/Sources/DOMKit/WebIDL/Cache.swift b/Sources/DOMKit/WebIDL/Cache.swift new file mode 100644 index 00000000..6b344dce --- /dev/null +++ b/Sources/DOMKit/WebIDL/Cache.swift @@ -0,0 +1,98 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class Cache: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.Cache].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + @inlinable public func match(request: RequestInfo, options: CacheQueryOptions? = nil) -> JSPromise { + let this = jsObject + return this[Strings.match].function!(this: this, arguments: [request.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func match(request: RequestInfo, options: CacheQueryOptions? = nil) async throws -> Response? { + let this = jsObject + let _promise: JSPromise = this[Strings.match].function!(this: this, arguments: [request.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable public func matchAll(request: RequestInfo? = nil, options: CacheQueryOptions? = nil) -> JSPromise { + let this = jsObject + return this[Strings.matchAll].function!(this: this, arguments: [request?.jsValue ?? .undefined, options?.jsValue ?? .undefined]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func matchAll(request: RequestInfo? = nil, options: CacheQueryOptions? = nil) async throws -> [Response] { + let this = jsObject + let _promise: JSPromise = this[Strings.matchAll].function!(this: this, arguments: [request?.jsValue ?? .undefined, options?.jsValue ?? .undefined]).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable public func add(request: RequestInfo) -> JSPromise { + let this = jsObject + return this[Strings.add].function!(this: this, arguments: [request.jsValue]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func add(request: RequestInfo) async throws { + let this = jsObject + let _promise: JSPromise = this[Strings.add].function!(this: this, arguments: [request.jsValue]).fromJSValue()! + _ = try await _promise.value + } + + @inlinable public func addAll(requests: [RequestInfo]) -> JSPromise { + let this = jsObject + return this[Strings.addAll].function!(this: this, arguments: [requests.jsValue]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func addAll(requests: [RequestInfo]) async throws { + let this = jsObject + let _promise: JSPromise = this[Strings.addAll].function!(this: this, arguments: [requests.jsValue]).fromJSValue()! + _ = try await _promise.value + } + + @inlinable public func put(request: RequestInfo, response: Response) -> JSPromise { + let this = jsObject + return this[Strings.put].function!(this: this, arguments: [request.jsValue, response.jsValue]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func put(request: RequestInfo, response: Response) async throws { + let this = jsObject + let _promise: JSPromise = this[Strings.put].function!(this: this, arguments: [request.jsValue, response.jsValue]).fromJSValue()! + _ = try await _promise.value + } + + @inlinable public func delete(request: RequestInfo, options: CacheQueryOptions? = nil) -> JSPromise { + let this = jsObject + return this[Strings.delete].function!(this: this, arguments: [request.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func delete(request: RequestInfo, options: CacheQueryOptions? = nil) async throws -> Bool { + let this = jsObject + let _promise: JSPromise = this[Strings.delete].function!(this: this, arguments: [request.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable public func keys(request: RequestInfo? = nil, options: CacheQueryOptions? = nil) -> JSPromise { + let this = jsObject + return this[Strings.keys].function!(this: this, arguments: [request?.jsValue ?? .undefined, options?.jsValue ?? .undefined]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func keys(request: RequestInfo? = nil, options: CacheQueryOptions? = nil) async throws -> [Request] { + let this = jsObject + let _promise: JSPromise = this[Strings.keys].function!(this: this, arguments: [request?.jsValue ?? .undefined, options?.jsValue ?? .undefined]).fromJSValue()! + return try await _promise.value.fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/CacheQueryOptions.swift b/Sources/DOMKit/WebIDL/CacheQueryOptions.swift new file mode 100644 index 00000000..cb0feec1 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CacheQueryOptions.swift @@ -0,0 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class CacheQueryOptions: BridgedDictionary { + public convenience init(ignoreSearch: Bool, ignoreMethod: Bool, ignoreVary: Bool) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.ignoreSearch] = ignoreSearch.jsValue + object[Strings.ignoreMethod] = ignoreMethod.jsValue + object[Strings.ignoreVary] = ignoreVary.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _ignoreSearch = ReadWriteAttribute(jsObject: object, name: Strings.ignoreSearch) + _ignoreMethod = ReadWriteAttribute(jsObject: object, name: Strings.ignoreMethod) + _ignoreVary = ReadWriteAttribute(jsObject: object, name: Strings.ignoreVary) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var ignoreSearch: Bool + + @ReadWriteAttribute + public var ignoreMethod: Bool + + @ReadWriteAttribute + public var ignoreVary: Bool +} diff --git a/Sources/DOMKit/WebIDL/CacheStorage.swift b/Sources/DOMKit/WebIDL/CacheStorage.swift new file mode 100644 index 00000000..e03f63b1 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CacheStorage.swift @@ -0,0 +1,74 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class CacheStorage: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.CacheStorage].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + @inlinable public func match(request: RequestInfo, options: MultiCacheQueryOptions? = nil) -> JSPromise { + let this = jsObject + return this[Strings.match].function!(this: this, arguments: [request.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func match(request: RequestInfo, options: MultiCacheQueryOptions? = nil) async throws -> Response? { + let this = jsObject + let _promise: JSPromise = this[Strings.match].function!(this: this, arguments: [request.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable public func has(cacheName: String) -> JSPromise { + let this = jsObject + return this[Strings.has].function!(this: this, arguments: [cacheName.jsValue]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func has(cacheName: String) async throws -> Bool { + let this = jsObject + let _promise: JSPromise = this[Strings.has].function!(this: this, arguments: [cacheName.jsValue]).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable public func open(cacheName: String) -> JSPromise { + let this = jsObject + return this[Strings.open].function!(this: this, arguments: [cacheName.jsValue]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func open(cacheName: String) async throws -> Cache { + let this = jsObject + let _promise: JSPromise = this[Strings.open].function!(this: this, arguments: [cacheName.jsValue]).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable public func delete(cacheName: String) -> JSPromise { + let this = jsObject + return this[Strings.delete].function!(this: this, arguments: [cacheName.jsValue]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func delete(cacheName: String) async throws -> Bool { + let this = jsObject + let _promise: JSPromise = this[Strings.delete].function!(this: this, arguments: [cacheName.jsValue]).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable public func keys() -> JSPromise { + let this = jsObject + return this[Strings.keys].function!(this: this, arguments: []).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func keys() async throws -> [String] { + let this = jsObject + let _promise: JSPromise = this[Strings.keys].function!(this: this, arguments: []).fromJSValue()! + return try await _promise.value.fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/CanPlayTypeResult.swift b/Sources/DOMKit/WebIDL/CanPlayTypeResult.swift new file mode 100644 index 00000000..3daa302c --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanPlayTypeResult.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum CanPlayTypeResult: JSString, JSValueCompatible { + case _empty = "" + case maybe = "maybe" + case probably = "probably" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/CanvasCompositing.swift b/Sources/DOMKit/WebIDL/CanvasCompositing.swift new file mode 100644 index 00000000..9268b4ee --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasCompositing.swift @@ -0,0 +1,17 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasCompositing: JSBridgedClass {} +public extension CanvasCompositing { + @inlinable var globalAlpha: Double { + get { ReadWriteAttribute[Strings.globalAlpha, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.globalAlpha, in: jsObject] = newValue } + } + + @inlinable var globalCompositeOperation: String { + get { ReadWriteAttribute[Strings.globalCompositeOperation, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.globalCompositeOperation, in: jsObject] = newValue } + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasDirection.swift b/Sources/DOMKit/WebIDL/CanvasDirection.swift new file mode 100644 index 00000000..d2aab51e --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasDirection.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum CanvasDirection: JSString, JSValueCompatible { + case ltr = "ltr" + case rtl = "rtl" + case inherit = "inherit" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/CanvasDrawImage.swift b/Sources/DOMKit/WebIDL/CanvasDrawImage.swift new file mode 100644 index 00000000..a45379b6 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasDrawImage.swift @@ -0,0 +1,31 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasDrawImage: JSBridgedClass {} +public extension CanvasDrawImage { + @inlinable func drawImage(image: CanvasImageSource, dx: Double, dy: Double) { + let this = jsObject + _ = this[Strings.drawImage].function!(this: this, arguments: [image.jsValue, dx.jsValue, dy.jsValue]) + } + + @inlinable func drawImage(image: CanvasImageSource, dx: Double, dy: Double, dw: Double, dh: Double) { + let this = jsObject + _ = this[Strings.drawImage].function!(this: this, arguments: [image.jsValue, dx.jsValue, dy.jsValue, dw.jsValue, dh.jsValue]) + } + + @inlinable func drawImage(image: CanvasImageSource, sx: Double, sy: Double, sw: Double, sh: Double, dx: Double, dy: Double, dw: Double, dh: Double) { + let _arg0 = image.jsValue + let _arg1 = sx.jsValue + let _arg2 = sy.jsValue + let _arg3 = sw.jsValue + let _arg4 = sh.jsValue + let _arg5 = dx.jsValue + let _arg6 = dy.jsValue + let _arg7 = dw.jsValue + let _arg8 = dh.jsValue + let this = jsObject + _ = this[Strings.drawImage].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8]) + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasDrawPath.swift b/Sources/DOMKit/WebIDL/CanvasDrawPath.swift new file mode 100644 index 00000000..1b2986e9 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasDrawPath.swift @@ -0,0 +1,62 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasDrawPath: JSBridgedClass {} +public extension CanvasDrawPath { + @inlinable func beginPath() { + let this = jsObject + _ = this[Strings.beginPath].function!(this: this, arguments: []) + } + + @inlinable func fill(fillRule: CanvasFillRule? = nil) { + let this = jsObject + _ = this[Strings.fill].function!(this: this, arguments: [fillRule?.jsValue ?? .undefined]) + } + + @inlinable func fill(path: Path2D, fillRule: CanvasFillRule? = nil) { + let this = jsObject + _ = this[Strings.fill].function!(this: this, arguments: [path.jsValue, fillRule?.jsValue ?? .undefined]) + } + + @inlinable func stroke() { + let this = jsObject + _ = this[Strings.stroke].function!(this: this, arguments: []) + } + + @inlinable func stroke(path: Path2D) { + let this = jsObject + _ = this[Strings.stroke].function!(this: this, arguments: [path.jsValue]) + } + + @inlinable func clip(fillRule: CanvasFillRule? = nil) { + let this = jsObject + _ = this[Strings.clip].function!(this: this, arguments: [fillRule?.jsValue ?? .undefined]) + } + + @inlinable func clip(path: Path2D, fillRule: CanvasFillRule? = nil) { + let this = jsObject + _ = this[Strings.clip].function!(this: this, arguments: [path.jsValue, fillRule?.jsValue ?? .undefined]) + } + + @inlinable func isPointInPath(x: Double, y: Double, fillRule: CanvasFillRule? = nil) -> Bool { + let this = jsObject + return this[Strings.isPointInPath].function!(this: this, arguments: [x.jsValue, y.jsValue, fillRule?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable func isPointInPath(path: Path2D, x: Double, y: Double, fillRule: CanvasFillRule? = nil) -> Bool { + let this = jsObject + return this[Strings.isPointInPath].function!(this: this, arguments: [path.jsValue, x.jsValue, y.jsValue, fillRule?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable func isPointInStroke(x: Double, y: Double) -> Bool { + let this = jsObject + return this[Strings.isPointInStroke].function!(this: this, arguments: [x.jsValue, y.jsValue]).fromJSValue()! + } + + @inlinable func isPointInStroke(path: Path2D, x: Double, y: Double) -> Bool { + let this = jsObject + return this[Strings.isPointInStroke].function!(this: this, arguments: [path.jsValue, x.jsValue, y.jsValue]).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasFillRule.swift b/Sources/DOMKit/WebIDL/CanvasFillRule.swift new file mode 100644 index 00000000..17694dc2 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasFillRule.swift @@ -0,0 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum CanvasFillRule: JSString, JSValueCompatible { + case nonzero = "nonzero" + case evenodd = "evenodd" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/CanvasFillStrokeStyles.swift b/Sources/DOMKit/WebIDL/CanvasFillStrokeStyles.swift new file mode 100644 index 00000000..1e9d0875 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasFillStrokeStyles.swift @@ -0,0 +1,43 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasFillStrokeStyles: JSBridgedClass {} +public extension CanvasFillStrokeStyles { + @inlinable var strokeStyle: CanvasGradient_or_CanvasPattern_or_String { + get { ReadWriteAttribute[Strings.strokeStyle, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.strokeStyle, in: jsObject] = newValue } + } + + @inlinable var fillStyle: CanvasGradient_or_CanvasPattern_or_String { + get { ReadWriteAttribute[Strings.fillStyle, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.fillStyle, in: jsObject] = newValue } + } + + @inlinable func createLinearGradient(x0: Double, y0: Double, x1: Double, y1: Double) -> CanvasGradient { + let this = jsObject + return this[Strings.createLinearGradient].function!(this: this, arguments: [x0.jsValue, y0.jsValue, x1.jsValue, y1.jsValue]).fromJSValue()! + } + + @inlinable func createRadialGradient(x0: Double, y0: Double, r0: Double, x1: Double, y1: Double, r1: Double) -> CanvasGradient { + let _arg0 = x0.jsValue + let _arg1 = y0.jsValue + let _arg2 = r0.jsValue + let _arg3 = x1.jsValue + let _arg4 = y1.jsValue + let _arg5 = r1.jsValue + let this = jsObject + return this[Strings.createRadialGradient].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5]).fromJSValue()! + } + + @inlinable func createConicGradient(startAngle: Double, x: Double, y: Double) -> CanvasGradient { + let this = jsObject + return this[Strings.createConicGradient].function!(this: this, arguments: [startAngle.jsValue, x.jsValue, y.jsValue]).fromJSValue()! + } + + @inlinable func createPattern(image: CanvasImageSource, repetition: String) -> CanvasPattern? { + let this = jsObject + return this[Strings.createPattern].function!(this: this, arguments: [image.jsValue, repetition.jsValue]).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasFilter.swift b/Sources/DOMKit/WebIDL/CanvasFilter.swift new file mode 100644 index 00000000..322447f3 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasFilter.swift @@ -0,0 +1,18 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class CanvasFilter: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.CanvasFilter].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + @inlinable public convenience init(filters: CanvasFilterInput_or_seq_of_CanvasFilterInput? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [filters?.jsValue ?? .undefined])) + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasFilterInput_or_seq_of_CanvasFilterInput.swift b/Sources/DOMKit/WebIDL/CanvasFilterInput_or_seq_of_CanvasFilterInput.swift new file mode 100644 index 00000000..2989a091 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasFilterInput_or_seq_of_CanvasFilterInput.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_CanvasFilterInput_or_seq_of_CanvasFilterInput: ConvertibleToJSValue {} +extension CanvasFilterInput: Any_CanvasFilterInput_or_seq_of_CanvasFilterInput {} +extension Array: Any_CanvasFilterInput_or_seq_of_CanvasFilterInput where Element == CanvasFilterInput {} + +public enum CanvasFilterInput_or_seq_of_CanvasFilterInput: JSValueCompatible, Any_CanvasFilterInput_or_seq_of_CanvasFilterInput { + case canvasFilterInput(CanvasFilterInput) + case seq_of_CanvasFilterInput([CanvasFilterInput]) + + var canvasFilterInput: CanvasFilterInput? { + switch self { + case let .canvasFilterInput(canvasFilterInput): return canvasFilterInput + default: return nil + } + } + + var seq_of_CanvasFilterInput: [CanvasFilterInput]? { + switch self { + case let .seq_of_CanvasFilterInput(seq_of_CanvasFilterInput): return seq_of_CanvasFilterInput + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let canvasFilterInput: CanvasFilterInput = value.fromJSValue() { + return .canvasFilterInput(canvasFilterInput) + } + if let seq_of_CanvasFilterInput: [CanvasFilterInput] = value.fromJSValue() { + return .seq_of_CanvasFilterInput(seq_of_CanvasFilterInput) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .canvasFilterInput(canvasFilterInput): + return canvasFilterInput.jsValue + case let .seq_of_CanvasFilterInput(seq_of_CanvasFilterInput): + return seq_of_CanvasFilterInput.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasFilter_or_String.swift b/Sources/DOMKit/WebIDL/CanvasFilter_or_String.swift new file mode 100644 index 00000000..6b4acf85 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasFilter_or_String.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_CanvasFilter_or_String: ConvertibleToJSValue {} +extension CanvasFilter: Any_CanvasFilter_or_String {} +extension String: Any_CanvasFilter_or_String {} + +public enum CanvasFilter_or_String: JSValueCompatible, Any_CanvasFilter_or_String { + case canvasFilter(CanvasFilter) + case string(String) + + var canvasFilter: CanvasFilter? { + switch self { + case let .canvasFilter(canvasFilter): return canvasFilter + default: return nil + } + } + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let canvasFilter: CanvasFilter = value.fromJSValue() { + return .canvasFilter(canvasFilter) + } + if let string: String = value.fromJSValue() { + return .string(string) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .canvasFilter(canvasFilter): + return canvasFilter.jsValue + case let .string(string): + return string.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasFilters.swift b/Sources/DOMKit/WebIDL/CanvasFilters.swift new file mode 100644 index 00000000..071d548a --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasFilters.swift @@ -0,0 +1,12 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasFilters: JSBridgedClass {} +public extension CanvasFilters { + @inlinable var filter: CanvasFilter_or_String { + get { ReadWriteAttribute[Strings.filter, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.filter, in: jsObject] = newValue } + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasFontKerning.swift b/Sources/DOMKit/WebIDL/CanvasFontKerning.swift new file mode 100644 index 00000000..08539582 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasFontKerning.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum CanvasFontKerning: JSString, JSValueCompatible { + case auto = "auto" + case normal = "normal" + case none = "none" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/CanvasFontStretch.swift b/Sources/DOMKit/WebIDL/CanvasFontStretch.swift new file mode 100644 index 00000000..005a3b8a --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasFontStretch.swift @@ -0,0 +1,29 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum CanvasFontStretch: JSString, JSValueCompatible { + case ultraCondensed = "ultra-condensed" + case extraCondensed = "extra-condensed" + case condensed = "condensed" + case semiCondensed = "semi-condensed" + case normal = "normal" + case semiExpanded = "semi-expanded" + case expanded = "expanded" + case extraExpanded = "extra-expanded" + case ultraExpanded = "ultra-expanded" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/CanvasFontVariantCaps.swift b/Sources/DOMKit/WebIDL/CanvasFontVariantCaps.swift new file mode 100644 index 00000000..4d9bd07c --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasFontVariantCaps.swift @@ -0,0 +1,27 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum CanvasFontVariantCaps: JSString, JSValueCompatible { + case normal = "normal" + case smallCaps = "small-caps" + case allSmallCaps = "all-small-caps" + case petiteCaps = "petite-caps" + case allPetiteCaps = "all-petite-caps" + case unicase = "unicase" + case titlingCaps = "titling-caps" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/CanvasGradient.swift b/Sources/DOMKit/WebIDL/CanvasGradient.swift new file mode 100644 index 00000000..f968ea7f --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasGradient.swift @@ -0,0 +1,19 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class CanvasGradient: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.CanvasGradient].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + @inlinable public func addColorStop(offset: Double, color: String) { + let this = jsObject + _ = this[Strings.addColorStop].function!(this: this, arguments: [offset.jsValue, color.jsValue]) + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasGradient_or_CanvasPattern_or_String.swift b/Sources/DOMKit/WebIDL/CanvasGradient_or_CanvasPattern_or_String.swift new file mode 100644 index 00000000..77e1d93d --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasGradient_or_CanvasPattern_or_String.swift @@ -0,0 +1,60 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_CanvasGradient_or_CanvasPattern_or_String: ConvertibleToJSValue {} +extension CanvasGradient: Any_CanvasGradient_or_CanvasPattern_or_String {} +extension CanvasPattern: Any_CanvasGradient_or_CanvasPattern_or_String {} +extension String: Any_CanvasGradient_or_CanvasPattern_or_String {} + +public enum CanvasGradient_or_CanvasPattern_or_String: JSValueCompatible, Any_CanvasGradient_or_CanvasPattern_or_String { + case canvasGradient(CanvasGradient) + case canvasPattern(CanvasPattern) + case string(String) + + var canvasGradient: CanvasGradient? { + switch self { + case let .canvasGradient(canvasGradient): return canvasGradient + default: return nil + } + } + + var canvasPattern: CanvasPattern? { + switch self { + case let .canvasPattern(canvasPattern): return canvasPattern + default: return nil + } + } + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let canvasGradient: CanvasGradient = value.fromJSValue() { + return .canvasGradient(canvasGradient) + } + if let canvasPattern: CanvasPattern = value.fromJSValue() { + return .canvasPattern(canvasPattern) + } + if let string: String = value.fromJSValue() { + return .string(string) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .canvasGradient(canvasGradient): + return canvasGradient.jsValue + case let .canvasPattern(canvasPattern): + return canvasPattern.jsValue + case let .string(string): + return string.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasImageData.swift b/Sources/DOMKit/WebIDL/CanvasImageData.swift new file mode 100644 index 00000000..d3318b0b --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasImageData.swift @@ -0,0 +1,39 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasImageData: JSBridgedClass {} +public extension CanvasImageData { + @inlinable func createImageData(sw: Int32, sh: Int32, settings: ImageDataSettings? = nil) -> ImageData { + let this = jsObject + return this[Strings.createImageData].function!(this: this, arguments: [sw.jsValue, sh.jsValue, settings?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable func createImageData(imagedata: ImageData) -> ImageData { + let this = jsObject + return this[Strings.createImageData].function!(this: this, arguments: [imagedata.jsValue]).fromJSValue()! + } + + @inlinable func getImageData(sx: Int32, sy: Int32, sw: Int32, sh: Int32, settings: ImageDataSettings? = nil) -> ImageData { + let this = jsObject + return this[Strings.getImageData].function!(this: this, arguments: [sx.jsValue, sy.jsValue, sw.jsValue, sh.jsValue, settings?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable func putImageData(imagedata: ImageData, dx: Int32, dy: Int32) { + let this = jsObject + _ = this[Strings.putImageData].function!(this: this, arguments: [imagedata.jsValue, dx.jsValue, dy.jsValue]) + } + + @inlinable func putImageData(imagedata: ImageData, dx: Int32, dy: Int32, dirtyX: Int32, dirtyY: Int32, dirtyWidth: Int32, dirtyHeight: Int32) { + let _arg0 = imagedata.jsValue + let _arg1 = dx.jsValue + let _arg2 = dy.jsValue + let _arg3 = dirtyX.jsValue + let _arg4 = dirtyY.jsValue + let _arg5 = dirtyWidth.jsValue + let _arg6 = dirtyHeight.jsValue + let this = jsObject + _ = this[Strings.putImageData].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6]) + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasImageSmoothing.swift b/Sources/DOMKit/WebIDL/CanvasImageSmoothing.swift new file mode 100644 index 00000000..37b13cf5 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasImageSmoothing.swift @@ -0,0 +1,17 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasImageSmoothing: JSBridgedClass {} +public extension CanvasImageSmoothing { + @inlinable var imageSmoothingEnabled: Bool { + get { ReadWriteAttribute[Strings.imageSmoothingEnabled, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.imageSmoothingEnabled, in: jsObject] = newValue } + } + + @inlinable var imageSmoothingQuality: ImageSmoothingQuality { + get { ReadWriteAttribute[Strings.imageSmoothingQuality, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.imageSmoothingQuality, in: jsObject] = newValue } + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasLineCap.swift b/Sources/DOMKit/WebIDL/CanvasLineCap.swift new file mode 100644 index 00000000..abc5b1b9 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasLineCap.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum CanvasLineCap: JSString, JSValueCompatible { + case butt = "butt" + case round = "round" + case square = "square" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/CanvasLineJoin.swift b/Sources/DOMKit/WebIDL/CanvasLineJoin.swift new file mode 100644 index 00000000..4bfc3d9e --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasLineJoin.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum CanvasLineJoin: JSString, JSValueCompatible { + case round = "round" + case bevel = "bevel" + case miter = "miter" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/CanvasPath.swift b/Sources/DOMKit/WebIDL/CanvasPath.swift new file mode 100644 index 00000000..618d84ae --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasPath.swift @@ -0,0 +1,77 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasPath: JSBridgedClass {} +public extension CanvasPath { + @inlinable func closePath() { + let this = jsObject + _ = this[Strings.closePath].function!(this: this, arguments: []) + } + + @inlinable func moveTo(x: Double, y: Double) { + let this = jsObject + _ = this[Strings.moveTo].function!(this: this, arguments: [x.jsValue, y.jsValue]) + } + + @inlinable func lineTo(x: Double, y: Double) { + let this = jsObject + _ = this[Strings.lineTo].function!(this: this, arguments: [x.jsValue, y.jsValue]) + } + + @inlinable func quadraticCurveTo(cpx: Double, cpy: Double, x: Double, y: Double) { + let this = jsObject + _ = this[Strings.quadraticCurveTo].function!(this: this, arguments: [cpx.jsValue, cpy.jsValue, x.jsValue, y.jsValue]) + } + + @inlinable func bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double) { + let _arg0 = cp1x.jsValue + let _arg1 = cp1y.jsValue + let _arg2 = cp2x.jsValue + let _arg3 = cp2y.jsValue + let _arg4 = x.jsValue + let _arg5 = y.jsValue + let this = jsObject + _ = this[Strings.bezierCurveTo].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5]) + } + + @inlinable func arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double) { + let this = jsObject + _ = this[Strings.arcTo].function!(this: this, arguments: [x1.jsValue, y1.jsValue, x2.jsValue, y2.jsValue, radius.jsValue]) + } + + @inlinable func rect(x: Double, y: Double, w: Double, h: Double) { + let this = jsObject + _ = this[Strings.rect].function!(this: this, arguments: [x.jsValue, y.jsValue, w.jsValue, h.jsValue]) + } + + @inlinable func roundRect(x: Double, y: Double, w: Double, h: Double, radii: DOMPointInit_or_Double_or_seq_of_DOMPointInit_or_Double? = nil) { + let this = jsObject + _ = this[Strings.roundRect].function!(this: this, arguments: [x.jsValue, y.jsValue, w.jsValue, h.jsValue, radii?.jsValue ?? .undefined]) + } + + @inlinable func arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double, counterclockwise: Bool? = nil) { + let _arg0 = x.jsValue + let _arg1 = y.jsValue + let _arg2 = radius.jsValue + let _arg3 = startAngle.jsValue + let _arg4 = endAngle.jsValue + let _arg5 = counterclockwise?.jsValue ?? .undefined + let this = jsObject + _ = this[Strings.arc].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5]) + } + + @inlinable func ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, endAngle: Double, counterclockwise: Bool? = nil) { + let _arg0 = x.jsValue + let _arg1 = y.jsValue + let _arg2 = radiusX.jsValue + let _arg3 = radiusY.jsValue + let _arg4 = rotation.jsValue + let _arg5 = startAngle.jsValue + let _arg6 = endAngle.jsValue + let _arg7 = counterclockwise?.jsValue ?? .undefined + let this = jsObject + _ = this[Strings.ellipse].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7]) + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasPathDrawingStyles.swift b/Sources/DOMKit/WebIDL/CanvasPathDrawingStyles.swift new file mode 100644 index 00000000..fa980115 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasPathDrawingStyles.swift @@ -0,0 +1,42 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasPathDrawingStyles: JSBridgedClass {} +public extension CanvasPathDrawingStyles { + @inlinable var lineWidth: Double { + get { ReadWriteAttribute[Strings.lineWidth, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.lineWidth, in: jsObject] = newValue } + } + + @inlinable var lineCap: CanvasLineCap { + get { ReadWriteAttribute[Strings.lineCap, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.lineCap, in: jsObject] = newValue } + } + + @inlinable var lineJoin: CanvasLineJoin { + get { ReadWriteAttribute[Strings.lineJoin, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.lineJoin, in: jsObject] = newValue } + } + + @inlinable var miterLimit: Double { + get { ReadWriteAttribute[Strings.miterLimit, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.miterLimit, in: jsObject] = newValue } + } + + @inlinable func setLineDash(segments: [Double]) { + let this = jsObject + _ = this[Strings.setLineDash].function!(this: this, arguments: [segments.jsValue]) + } + + @inlinable func getLineDash() -> [Double] { + let this = jsObject + return this[Strings.getLineDash].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable var lineDashOffset: Double { + get { ReadWriteAttribute[Strings.lineDashOffset, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.lineDashOffset, in: jsObject] = newValue } + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasPattern.swift b/Sources/DOMKit/WebIDL/CanvasPattern.swift new file mode 100644 index 00000000..0c5b037d --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasPattern.swift @@ -0,0 +1,19 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class CanvasPattern: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.CanvasPattern].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + @inlinable public func setTransform(transform: DOMMatrix2DInit? = nil) { + let this = jsObject + _ = this[Strings.setTransform].function!(this: this, arguments: [transform?.jsValue ?? .undefined]) + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasRect.swift b/Sources/DOMKit/WebIDL/CanvasRect.swift new file mode 100644 index 00000000..97ae72d1 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasRect.swift @@ -0,0 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasRect: JSBridgedClass {} +public extension CanvasRect { + @inlinable func clearRect(x: Double, y: Double, w: Double, h: Double) { + let this = jsObject + _ = this[Strings.clearRect].function!(this: this, arguments: [x.jsValue, y.jsValue, w.jsValue, h.jsValue]) + } + + @inlinable func fillRect(x: Double, y: Double, w: Double, h: Double) { + let this = jsObject + _ = this[Strings.fillRect].function!(this: this, arguments: [x.jsValue, y.jsValue, w.jsValue, h.jsValue]) + } + + @inlinable func strokeRect(x: Double, y: Double, w: Double, h: Double) { + let this = jsObject + _ = this[Strings.strokeRect].function!(this: this, arguments: [x.jsValue, y.jsValue, w.jsValue, h.jsValue]) + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasRenderingContext2D.swift b/Sources/DOMKit/WebIDL/CanvasRenderingContext2D.swift new file mode 100644 index 00000000..0c962e81 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasRenderingContext2D.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class CanvasRenderingContext2D: JSBridgedClass, CanvasState, CanvasTransform, CanvasCompositing, CanvasImageSmoothing, CanvasFillStrokeStyles, CanvasShadowStyles, CanvasFilters, CanvasRect, CanvasDrawPath, CanvasUserInterface, CanvasText, CanvasDrawImage, CanvasImageData, CanvasPathDrawingStyles, CanvasTextDrawingStyles, CanvasPath { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.CanvasRenderingContext2D].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _canvas = ReadonlyAttribute(jsObject: jsObject, name: Strings.canvas) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var canvas: HTMLCanvasElement + + @inlinable public func getContextAttributes() -> CanvasRenderingContext2DSettings { + let this = jsObject + return this[Strings.getContextAttributes].function!(this: this, arguments: []).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasRenderingContext2DSettings.swift b/Sources/DOMKit/WebIDL/CanvasRenderingContext2DSettings.swift new file mode 100644 index 00000000..9dc2ceb0 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasRenderingContext2DSettings.swift @@ -0,0 +1,35 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class CanvasRenderingContext2DSettings: BridgedDictionary { + public convenience init(alpha: Bool, desynchronized: Bool, colorSpace: PredefinedColorSpace, willReadFrequently: Bool) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.alpha] = alpha.jsValue + object[Strings.desynchronized] = desynchronized.jsValue + object[Strings.colorSpace] = colorSpace.jsValue + object[Strings.willReadFrequently] = willReadFrequently.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _alpha = ReadWriteAttribute(jsObject: object, name: Strings.alpha) + _desynchronized = ReadWriteAttribute(jsObject: object, name: Strings.desynchronized) + _colorSpace = ReadWriteAttribute(jsObject: object, name: Strings.colorSpace) + _willReadFrequently = ReadWriteAttribute(jsObject: object, name: Strings.willReadFrequently) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var alpha: Bool + + @ReadWriteAttribute + public var desynchronized: Bool + + @ReadWriteAttribute + public var colorSpace: PredefinedColorSpace + + @ReadWriteAttribute + public var willReadFrequently: Bool +} diff --git a/Sources/DOMKit/WebIDL/CanvasShadowStyles.swift b/Sources/DOMKit/WebIDL/CanvasShadowStyles.swift new file mode 100644 index 00000000..6d009735 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasShadowStyles.swift @@ -0,0 +1,27 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasShadowStyles: JSBridgedClass {} +public extension CanvasShadowStyles { + @inlinable var shadowOffsetX: Double { + get { ReadWriteAttribute[Strings.shadowOffsetX, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.shadowOffsetX, in: jsObject] = newValue } + } + + @inlinable var shadowOffsetY: Double { + get { ReadWriteAttribute[Strings.shadowOffsetY, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.shadowOffsetY, in: jsObject] = newValue } + } + + @inlinable var shadowBlur: Double { + get { ReadWriteAttribute[Strings.shadowBlur, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.shadowBlur, in: jsObject] = newValue } + } + + @inlinable var shadowColor: String { + get { ReadWriteAttribute[Strings.shadowColor, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.shadowColor, in: jsObject] = newValue } + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasState.swift b/Sources/DOMKit/WebIDL/CanvasState.swift new file mode 100644 index 00000000..f8e914dc --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasState.swift @@ -0,0 +1,27 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasState: JSBridgedClass {} +public extension CanvasState { + @inlinable func save() { + let this = jsObject + _ = this[Strings.save].function!(this: this, arguments: []) + } + + @inlinable func restore() { + let this = jsObject + _ = this[Strings.restore].function!(this: this, arguments: []) + } + + @inlinable func reset() { + let this = jsObject + _ = this[Strings.reset].function!(this: this, arguments: []) + } + + @inlinable func isContextLost() -> Bool { + let this = jsObject + return this[Strings.isContextLost].function!(this: this, arguments: []).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasText.swift b/Sources/DOMKit/WebIDL/CanvasText.swift new file mode 100644 index 00000000..9e48702d --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasText.swift @@ -0,0 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasText: JSBridgedClass {} +public extension CanvasText { + @inlinable func fillText(text: String, x: Double, y: Double, maxWidth: Double? = nil) { + let this = jsObject + _ = this[Strings.fillText].function!(this: this, arguments: [text.jsValue, x.jsValue, y.jsValue, maxWidth?.jsValue ?? .undefined]) + } + + @inlinable func strokeText(text: String, x: Double, y: Double, maxWidth: Double? = nil) { + let this = jsObject + _ = this[Strings.strokeText].function!(this: this, arguments: [text.jsValue, x.jsValue, y.jsValue, maxWidth?.jsValue ?? .undefined]) + } + + @inlinable func measureText(text: String) -> TextMetrics { + let this = jsObject + return this[Strings.measureText].function!(this: this, arguments: [text.jsValue]).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasTextAlign.swift b/Sources/DOMKit/WebIDL/CanvasTextAlign.swift new file mode 100644 index 00000000..40992b7d --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasTextAlign.swift @@ -0,0 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum CanvasTextAlign: JSString, JSValueCompatible { + case start = "start" + case end = "end" + case left = "left" + case right = "right" + case center = "center" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/CanvasTextBaseline.swift b/Sources/DOMKit/WebIDL/CanvasTextBaseline.swift new file mode 100644 index 00000000..4fc1c759 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasTextBaseline.swift @@ -0,0 +1,26 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum CanvasTextBaseline: JSString, JSValueCompatible { + case top = "top" + case hanging = "hanging" + case middle = "middle" + case alphabetic = "alphabetic" + case ideographic = "ideographic" + case bottom = "bottom" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/CanvasTextDrawingStyles.swift b/Sources/DOMKit/WebIDL/CanvasTextDrawingStyles.swift new file mode 100644 index 00000000..c5c9af38 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasTextDrawingStyles.swift @@ -0,0 +1,57 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasTextDrawingStyles: JSBridgedClass {} +public extension CanvasTextDrawingStyles { + @inlinable var font: String { + get { ReadWriteAttribute[Strings.font, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.font, in: jsObject] = newValue } + } + + @inlinable var textAlign: CanvasTextAlign { + get { ReadWriteAttribute[Strings.textAlign, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.textAlign, in: jsObject] = newValue } + } + + @inlinable var textBaseline: CanvasTextBaseline { + get { ReadWriteAttribute[Strings.textBaseline, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.textBaseline, in: jsObject] = newValue } + } + + @inlinable var direction: CanvasDirection { + get { ReadWriteAttribute[Strings.direction, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.direction, in: jsObject] = newValue } + } + + @inlinable var letterSpacing: String { + get { ReadWriteAttribute[Strings.letterSpacing, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.letterSpacing, in: jsObject] = newValue } + } + + @inlinable var fontKerning: CanvasFontKerning { + get { ReadWriteAttribute[Strings.fontKerning, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.fontKerning, in: jsObject] = newValue } + } + + @inlinable var fontStretch: CanvasFontStretch { + get { ReadWriteAttribute[Strings.fontStretch, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.fontStretch, in: jsObject] = newValue } + } + + @inlinable var fontVariantCaps: CanvasFontVariantCaps { + get { ReadWriteAttribute[Strings.fontVariantCaps, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.fontVariantCaps, in: jsObject] = newValue } + } + + @inlinable var textRendering: CanvasTextRendering { + get { ReadWriteAttribute[Strings.textRendering, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.textRendering, in: jsObject] = newValue } + } + + @inlinable var wordSpacing: String { + get { ReadWriteAttribute[Strings.wordSpacing, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.wordSpacing, in: jsObject] = newValue } + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasTextRendering.swift b/Sources/DOMKit/WebIDL/CanvasTextRendering.swift new file mode 100644 index 00000000..e529cf10 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasTextRendering.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum CanvasTextRendering: JSString, JSValueCompatible { + case auto = "auto" + case optimizeSpeed = "optimizeSpeed" + case optimizeLegibility = "optimizeLegibility" + case geometricPrecision = "geometricPrecision" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/CanvasTransform.swift b/Sources/DOMKit/WebIDL/CanvasTransform.swift new file mode 100644 index 00000000..83337e04 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasTransform.swift @@ -0,0 +1,59 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasTransform: JSBridgedClass {} +public extension CanvasTransform { + @inlinable func scale(x: Double, y: Double) { + let this = jsObject + _ = this[Strings.scale].function!(this: this, arguments: [x.jsValue, y.jsValue]) + } + + @inlinable func rotate(angle: Double) { + let this = jsObject + _ = this[Strings.rotate].function!(this: this, arguments: [angle.jsValue]) + } + + @inlinable func translate(x: Double, y: Double) { + let this = jsObject + _ = this[Strings.translate].function!(this: this, arguments: [x.jsValue, y.jsValue]) + } + + @inlinable func transform(a: Double, b: Double, c: Double, d: Double, e: Double, f: Double) { + let _arg0 = a.jsValue + let _arg1 = b.jsValue + let _arg2 = c.jsValue + let _arg3 = d.jsValue + let _arg4 = e.jsValue + let _arg5 = f.jsValue + let this = jsObject + _ = this[Strings.transform].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5]) + } + + @inlinable func getTransform() -> DOMMatrix { + let this = jsObject + return this[Strings.getTransform].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable func setTransform(a: Double, b: Double, c: Double, d: Double, e: Double, f: Double) { + let _arg0 = a.jsValue + let _arg1 = b.jsValue + let _arg2 = c.jsValue + let _arg3 = d.jsValue + let _arg4 = e.jsValue + let _arg5 = f.jsValue + let this = jsObject + _ = this[Strings.setTransform].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5]) + } + + @inlinable func setTransform(transform: DOMMatrix2DInit? = nil) { + let this = jsObject + _ = this[Strings.setTransform].function!(this: this, arguments: [transform?.jsValue ?? .undefined]) + } + + @inlinable func resetTransform() { + let this = jsObject + _ = this[Strings.resetTransform].function!(this: this, arguments: []) + } +} diff --git a/Sources/DOMKit/WebIDL/CanvasUserInterface.swift b/Sources/DOMKit/WebIDL/CanvasUserInterface.swift new file mode 100644 index 00000000..74673ac0 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CanvasUserInterface.swift @@ -0,0 +1,27 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol CanvasUserInterface: JSBridgedClass {} +public extension CanvasUserInterface { + @inlinable func drawFocusIfNeeded(element: Element) { + let this = jsObject + _ = this[Strings.drawFocusIfNeeded].function!(this: this, arguments: [element.jsValue]) + } + + @inlinable func drawFocusIfNeeded(path: Path2D, element: Element) { + let this = jsObject + _ = this[Strings.drawFocusIfNeeded].function!(this: this, arguments: [path.jsValue, element.jsValue]) + } + + @inlinable func scrollPathIntoView() { + let this = jsObject + _ = this[Strings.scrollPathIntoView].function!(this: this, arguments: []) + } + + @inlinable func scrollPathIntoView(path: Path2D) { + let this = jsObject + _ = this[Strings.scrollPathIntoView].function!(this: this, arguments: [path.jsValue]) + } +} diff --git a/Sources/DOMKit/WebIDL/CharacterData.swift b/Sources/DOMKit/WebIDL/CharacterData.swift index fcbc89a9..dcfe0231 100644 --- a/Sources/DOMKit/WebIDL/CharacterData.swift +++ b/Sources/DOMKit/WebIDL/CharacterData.swift @@ -1,16 +1,14 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public class CharacterData: Node, ChildNode, NonDocumentTypeChildNode { - override public class var constructor: JSFunction { JSObject.global.CharacterData.function! } +public class CharacterData: Node, NonDocumentTypeChildNode, ChildNode { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.CharacterData].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _data = ReadWriteAttribute(jsObject: jsObject, name: "data") - _length = ReadonlyAttribute(jsObject: jsObject, name: "length") + _data = ReadWriteAttribute(jsObject: jsObject, name: Strings.data) + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) super.init(unsafelyWrapping: jsObject) } @@ -20,23 +18,28 @@ public class CharacterData: Node, ChildNode, NonDocumentTypeChildNode { @ReadonlyAttribute public var length: UInt32 - public func substringData(offset: UInt32, count: UInt32) -> String { - return jsObject.substringData!(offset.jsValue(), count.jsValue()).fromJSValue()! + @inlinable public func substringData(offset: UInt32, count: UInt32) -> String { + let this = jsObject + return this[Strings.substringData].function!(this: this, arguments: [offset.jsValue, count.jsValue]).fromJSValue()! } - public func appendData(data: String) { - _ = jsObject.appendData!(data.jsValue()) + @inlinable public func appendData(data: String) { + let this = jsObject + _ = this[Strings.appendData].function!(this: this, arguments: [data.jsValue]) } - public func insertData(offset: UInt32, data: String) { - _ = jsObject.insertData!(offset.jsValue(), data.jsValue()) + @inlinable public func insertData(offset: UInt32, data: String) { + let this = jsObject + _ = this[Strings.insertData].function!(this: this, arguments: [offset.jsValue, data.jsValue]) } - public func deleteData(offset: UInt32, count: UInt32) { - _ = jsObject.deleteData!(offset.jsValue(), count.jsValue()) + @inlinable public func deleteData(offset: UInt32, count: UInt32) { + let this = jsObject + _ = this[Strings.deleteData].function!(this: this, arguments: [offset.jsValue, count.jsValue]) } - public func replaceData(offset: UInt32, count: UInt32, data: String) { - _ = jsObject.replaceData!(offset.jsValue(), count.jsValue(), data.jsValue()) + @inlinable public func replaceData(offset: UInt32, count: UInt32, data: String) { + let this = jsObject + _ = this[Strings.replaceData].function!(this: this, arguments: [offset.jsValue, count.jsValue, data.jsValue]) } } diff --git a/Sources/DOMKit/WebIDL/ChildNode.swift b/Sources/DOMKit/WebIDL/ChildNode.swift index 185bf7f5..e2377621 100644 --- a/Sources/DOMKit/WebIDL/ChildNode.swift +++ b/Sources/DOMKit/WebIDL/ChildNode.swift @@ -1,38 +1,27 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public protocol ChildNode: JSBridgedClass {} - public extension ChildNode { - func before(nodes: NodeOrString...) { - _ = jsObject.before!(nodes.jsValue()) - } - - func before() { - _ = jsObject.before!() - } - - func after(nodes: NodeOrString...) { - _ = jsObject.after!(nodes.jsValue()) - } - - func after() { - _ = jsObject.after!() + @inlinable func before(nodes: Node_or_String...) { + let this = jsObject + _ = this[Strings.before].function!(this: this, arguments: nodes.map(\.jsValue)) } - func replaceWith(nodes: NodeOrString...) { - _ = jsObject.replaceWith!(nodes.jsValue()) + @inlinable func after(nodes: Node_or_String...) { + let this = jsObject + _ = this[Strings.after].function!(this: this, arguments: nodes.map(\.jsValue)) } - func replaceWith() { - _ = jsObject.replaceWith!() + @inlinable func replaceWith(nodes: Node_or_String...) { + let this = jsObject + _ = this[Strings.replaceWith].function!(this: this, arguments: nodes.map(\.jsValue)) } - func remove() { - _ = jsObject.remove!() + @inlinable func remove() { + let this = jsObject + _ = this[Strings.remove].function!(this: this, arguments: []) } } diff --git a/Sources/DOMKit/WebIDL/ClientQueryOptions.swift b/Sources/DOMKit/WebIDL/ClientQueryOptions.swift new file mode 100644 index 00000000..3b4a2778 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ClientQueryOptions.swift @@ -0,0 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ClientQueryOptions: BridgedDictionary { + public convenience init(includeUncontrolled: Bool, type: ClientType) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.includeUncontrolled] = includeUncontrolled.jsValue + object[Strings.type] = type.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _includeUncontrolled = ReadWriteAttribute(jsObject: object, name: Strings.includeUncontrolled) + _type = ReadWriteAttribute(jsObject: object, name: Strings.type) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var includeUncontrolled: Bool + + @ReadWriteAttribute + public var type: ClientType +} diff --git a/Sources/DOMKit/WebIDL/ClientType.swift b/Sources/DOMKit/WebIDL/ClientType.swift new file mode 100644 index 00000000..91197c8f --- /dev/null +++ b/Sources/DOMKit/WebIDL/ClientType.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum ClientType: JSString, JSValueCompatible { + case window = "window" + case worker = "worker" + case sharedworker = "sharedworker" + case all = "all" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/ClosureAttribute.swift b/Sources/DOMKit/WebIDL/ClosureAttribute.swift new file mode 100644 index 00000000..82e24bb3 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ClosureAttribute.swift @@ -0,0 +1,327 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +/* variadic generics please */ +@propertyWrapper public final class ClosureAttribute0OptionalVoid { + @usableFromInline let jsObject: JSObject + @usableFromInline let name: JSString + + public init(jsObject: JSObject, name: JSString) { + self.jsObject = jsObject + self.name = name + } + + @inlinable public var wrappedValue: (() -> Void)? { + get { ClosureAttribute0OptionalVoid[name, in: jsObject] } + set { ClosureAttribute0OptionalVoid[name, in: jsObject] = newValue } + } + + @inlinable public static subscript(name: JSString, in jsObject: JSObject) -> (() -> Void)? { + get { + guard let function = jsObject[name].function else { + return nil + } + return { function() } + } + set { + if let newValue = newValue { + jsObject[name] = JSClosure { _ in + newValue() + return .undefined + }.jsValue + } else { + jsObject[name] = .null + } + } + } +} + +@propertyWrapper public final class ClosureAttribute0Void { + @usableFromInline let jsObject: JSObject + @usableFromInline let name: JSString + + public init(jsObject: JSObject, name: JSString) { + self.jsObject = jsObject + self.name = name + } + + @inlinable public var wrappedValue: () -> Void { + get { ClosureAttribute0Void[name, in: jsObject] } + set { ClosureAttribute0Void[name, in: jsObject] = newValue } + } + + @inlinable public static subscript(name: JSString, in jsObject: JSObject) -> () -> Void { + get { + let function = jsObject[name].function! + return { function() } + } + set { + jsObject[name] = JSClosure { _ in + newValue() + return .undefined + }.jsValue + } + } +} + +@propertyWrapper public final class ClosureAttribute1 + where A0: JSValueCompatible, ReturnType: JSValueCompatible +{ + @usableFromInline let jsObject: JSObject + @usableFromInline let name: JSString + + public init(jsObject: JSObject, name: JSString) { + self.jsObject = jsObject + self.name = name + } + + @inlinable public var wrappedValue: (A0) -> ReturnType { + get { ClosureAttribute1[name, in: jsObject] } + set { ClosureAttribute1[name, in: jsObject] = newValue } + } + + @inlinable public static subscript(name: JSString, in jsObject: JSObject) -> (A0) -> ReturnType { + get { + let function = jsObject[name].function! + return { function($0.jsValue).fromJSValue()! } + } + set { + jsObject[name] = JSClosure { + newValue($0[0].fromJSValue()!).jsValue + }.jsValue + } + } +} + +@propertyWrapper public final class ClosureAttribute1Optional + where A0: JSValueCompatible, ReturnType: JSValueCompatible +{ + @usableFromInline let jsObject: JSObject + @usableFromInline let name: JSString + + public init(jsObject: JSObject, name: JSString) { + self.jsObject = jsObject + self.name = name + } + + @inlinable public var wrappedValue: ((A0) -> ReturnType)? { + get { ClosureAttribute1Optional[name, in: jsObject] } + set { ClosureAttribute1Optional[name, in: jsObject] = newValue } + } + + @inlinable public static subscript(name: JSString, in jsObject: JSObject) -> ((A0) -> ReturnType)? { + get { + guard let function = jsObject[name].function else { + return nil + } + return { function($0.jsValue).fromJSValue()! } + } + set { + if let newValue = newValue { + jsObject[name] = JSClosure { + newValue($0[0].fromJSValue()!).jsValue + }.jsValue + } else { + jsObject[name] = .null + } + } + } +} + +@propertyWrapper public final class ClosureAttribute1OptionalVoid + where A0: JSValueCompatible +{ + @usableFromInline let jsObject: JSObject + @usableFromInline let name: JSString + + public init(jsObject: JSObject, name: JSString) { + self.jsObject = jsObject + self.name = name + } + + @inlinable public var wrappedValue: ((A0) -> Void)? { + get { ClosureAttribute1OptionalVoid[name, in: jsObject] } + set { ClosureAttribute1OptionalVoid[name, in: jsObject] = newValue } + } + + @inlinable public static subscript(name: JSString, in jsObject: JSObject) -> ((A0) -> Void)? { + get { + guard let function = jsObject[name].function else { + return nil + } + return { function($0.jsValue) } + } + set { + if let newValue = newValue { + jsObject[name] = JSClosure { + newValue($0[0].fromJSValue()!) + return .undefined + }.jsValue + } else { + jsObject[name] = .null + } + } + } +} + +@propertyWrapper public final class ClosureAttribute1Void + where A0: JSValueCompatible +{ + @usableFromInline let jsObject: JSObject + @usableFromInline let name: JSString + + public init(jsObject: JSObject, name: JSString) { + self.jsObject = jsObject + self.name = name + } + + @inlinable public var wrappedValue: (A0) -> Void { + get { ClosureAttribute1Void[name, in: jsObject] } + set { ClosureAttribute1Void[name, in: jsObject] = newValue } + } + + @inlinable public static subscript(name: JSString, in jsObject: JSObject) -> (A0) -> Void { + get { + let function = jsObject[name].function! + return { function($0.jsValue) } + } + set { + jsObject[name] = JSClosure { + newValue($0[0].fromJSValue()!) + return .undefined + }.jsValue + } + } +} + +@propertyWrapper public final class ClosureAttribute2OptionalVoid + where A0: JSValueCompatible, A1: JSValueCompatible +{ + @usableFromInline let jsObject: JSObject + @usableFromInline let name: JSString + + public init(jsObject: JSObject, name: JSString) { + self.jsObject = jsObject + self.name = name + } + + @inlinable public var wrappedValue: ((A0, A1) -> Void)? { + get { ClosureAttribute2OptionalVoid[name, in: jsObject] } + set { ClosureAttribute2OptionalVoid[name, in: jsObject] = newValue } + } + + @inlinable public static subscript(name: JSString, in jsObject: JSObject) -> ((A0, A1) -> Void)? { + get { + guard let function = jsObject[name].function else { + return nil + } + return { function($0.jsValue, $1.jsValue) } + } + set { + if let newValue = newValue { + jsObject[name] = JSClosure { + newValue($0[0].fromJSValue()!, $0[1].fromJSValue()!) + return .undefined + }.jsValue + } else { + jsObject[name] = .null + } + } + } +} + +@propertyWrapper public final class ClosureAttribute2Void + where A0: JSValueCompatible, A1: JSValueCompatible +{ + @usableFromInline let jsObject: JSObject + @usableFromInline let name: JSString + + public init(jsObject: JSObject, name: JSString) { + self.jsObject = jsObject + self.name = name + } + + @inlinable public var wrappedValue: (A0, A1) -> Void { + get { ClosureAttribute2Void[name, in: jsObject] } + set { ClosureAttribute2Void[name, in: jsObject] = newValue } + } + + @inlinable public static subscript(name: JSString, in jsObject: JSObject) -> (A0, A1) -> Void { + get { + let function = jsObject[name].function! + return { function($0.jsValue, $1.jsValue) } + } + set { + jsObject[name] = JSClosure { + newValue($0[0].fromJSValue()!, $0[1].fromJSValue()!) + return .undefined + }.jsValue + } + } +} + +@propertyWrapper public final class ClosureAttribute5 + where A0: JSValueCompatible, A1: JSValueCompatible, A2: JSValueCompatible, A3: JSValueCompatible, A4: JSValueCompatible, ReturnType: JSValueCompatible +{ + @usableFromInline let jsObject: JSObject + @usableFromInline let name: JSString + + public init(jsObject: JSObject, name: JSString) { + self.jsObject = jsObject + self.name = name + } + + @inlinable public var wrappedValue: (A0, A1, A2, A3, A4) -> ReturnType { + get { ClosureAttribute5[name, in: jsObject] } + set { ClosureAttribute5[name, in: jsObject] = newValue } + } + + @inlinable public static subscript(name: JSString, in jsObject: JSObject) -> (A0, A1, A2, A3, A4) -> ReturnType { + get { + let function = jsObject[name].function! + return { function($0.jsValue, $1.jsValue, $2.jsValue, $3.jsValue, $4.jsValue).fromJSValue()! } + } + set { + jsObject[name] = JSClosure { + newValue($0[0].fromJSValue()!, $0[1].fromJSValue()!, $0[2].fromJSValue()!, $0[3].fromJSValue()!, $0[4].fromJSValue()!).jsValue + }.jsValue + } + } +} + +@propertyWrapper public final class ClosureAttribute5Optional + where A0: JSValueCompatible, A1: JSValueCompatible, A2: JSValueCompatible, A3: JSValueCompatible, A4: JSValueCompatible, ReturnType: JSValueCompatible +{ + @usableFromInline let jsObject: JSObject + @usableFromInline let name: JSString + + public init(jsObject: JSObject, name: JSString) { + self.jsObject = jsObject + self.name = name + } + + @inlinable public var wrappedValue: ((A0, A1, A2, A3, A4) -> ReturnType)? { + get { ClosureAttribute5Optional[name, in: jsObject] } + set { ClosureAttribute5Optional[name, in: jsObject] = newValue } + } + + @inlinable public static subscript(name: JSString, in jsObject: JSObject) -> ((A0, A1, A2, A3, A4) -> ReturnType)? { + get { + guard let function = jsObject[name].function else { + return nil + } + return { function($0.jsValue, $1.jsValue, $2.jsValue, $3.jsValue, $4.jsValue).fromJSValue()! } + } + set { + if let newValue = newValue { + jsObject[name] = JSClosure { + newValue($0[0].fromJSValue()!, $0[1].fromJSValue()!, $0[2].fromJSValue()!, $0[3].fromJSValue()!, $0[4].fromJSValue()!).jsValue + }.jsValue + } else { + jsObject[name] = .null + } + } + } +} diff --git a/Sources/DOMKit/WebIDL/ColorSpaceConversion.swift b/Sources/DOMKit/WebIDL/ColorSpaceConversion.swift new file mode 100644 index 00000000..862682ed --- /dev/null +++ b/Sources/DOMKit/WebIDL/ColorSpaceConversion.swift @@ -0,0 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum ColorSpaceConversion: JSString, JSValueCompatible { + case none = "none" + case `default` = "default" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/Comment.swift b/Sources/DOMKit/WebIDL/Comment.swift index e2375fb0..50ca3b54 100644 --- a/Sources/DOMKit/WebIDL/Comment.swift +++ b/Sources/DOMKit/WebIDL/Comment.swift @@ -1,18 +1,16 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class Comment: CharacterData { - override public class var constructor: JSFunction { JSObject.global.Comment.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.Comment].function! } public required init(unsafelyWrapping jsObject: JSObject) { super.init(unsafelyWrapping: jsObject) } - public convenience init(data: String = "") { - self.init(unsafelyWrapping: Comment.constructor.new(data.jsValue())) + @inlinable public convenience init(data: String? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [data?.jsValue ?? .undefined])) } } diff --git a/Sources/DOMKit/WebIDL/CompositeOperation.swift b/Sources/DOMKit/WebIDL/CompositeOperation.swift new file mode 100644 index 00000000..5dd32127 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CompositeOperation.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum CompositeOperation: JSString, JSValueCompatible { + case replace = "replace" + case add = "add" + case accumulate = "accumulate" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/CompositeOperationOrAuto.swift b/Sources/DOMKit/WebIDL/CompositeOperationOrAuto.swift new file mode 100644 index 00000000..7099d596 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CompositeOperationOrAuto.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum CompositeOperationOrAuto: JSString, JSValueCompatible { + case replace = "replace" + case add = "add" + case accumulate = "accumulate" + case auto = "auto" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/CompositeOperationOrAuto_or_seq_of_CompositeOperationOrAuto.swift b/Sources/DOMKit/WebIDL/CompositeOperationOrAuto_or_seq_of_CompositeOperationOrAuto.swift new file mode 100644 index 00000000..ff36a42d --- /dev/null +++ b/Sources/DOMKit/WebIDL/CompositeOperationOrAuto_or_seq_of_CompositeOperationOrAuto.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_CompositeOperationOrAuto_or_seq_of_CompositeOperationOrAuto: ConvertibleToJSValue {} +extension CompositeOperationOrAuto: Any_CompositeOperationOrAuto_or_seq_of_CompositeOperationOrAuto {} +extension Array: Any_CompositeOperationOrAuto_or_seq_of_CompositeOperationOrAuto where Element == CompositeOperationOrAuto {} + +public enum CompositeOperationOrAuto_or_seq_of_CompositeOperationOrAuto: JSValueCompatible, Any_CompositeOperationOrAuto_or_seq_of_CompositeOperationOrAuto { + case compositeOperationOrAuto(CompositeOperationOrAuto) + case seq_of_CompositeOperationOrAuto([CompositeOperationOrAuto]) + + var compositeOperationOrAuto: CompositeOperationOrAuto? { + switch self { + case let .compositeOperationOrAuto(compositeOperationOrAuto): return compositeOperationOrAuto + default: return nil + } + } + + var seq_of_CompositeOperationOrAuto: [CompositeOperationOrAuto]? { + switch self { + case let .seq_of_CompositeOperationOrAuto(seq_of_CompositeOperationOrAuto): return seq_of_CompositeOperationOrAuto + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let compositeOperationOrAuto: CompositeOperationOrAuto = value.fromJSValue() { + return .compositeOperationOrAuto(compositeOperationOrAuto) + } + if let seq_of_CompositeOperationOrAuto: [CompositeOperationOrAuto] = value.fromJSValue() { + return .seq_of_CompositeOperationOrAuto(seq_of_CompositeOperationOrAuto) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .compositeOperationOrAuto(compositeOperationOrAuto): + return compositeOperationOrAuto.jsValue + case let .seq_of_CompositeOperationOrAuto(seq_of_CompositeOperationOrAuto): + return seq_of_CompositeOperationOrAuto.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/CompositionEvent.swift b/Sources/DOMKit/WebIDL/CompositionEvent.swift new file mode 100644 index 00000000..f5426676 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CompositionEvent.swift @@ -0,0 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class CompositionEvent: UIEvent { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.CompositionEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _data = ReadonlyAttribute(jsObject: jsObject, name: Strings.data) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: CompositionEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var data: String + + @inlinable public func initCompositionEvent(typeArg: String, bubblesArg: Bool? = nil, cancelableArg: Bool? = nil, viewArg: WindowProxy? = nil, dataArg: String? = nil) { + let this = jsObject + _ = this[Strings.initCompositionEvent].function!(this: this, arguments: [typeArg.jsValue, bubblesArg?.jsValue ?? .undefined, cancelableArg?.jsValue ?? .undefined, viewArg?.jsValue ?? .undefined, dataArg?.jsValue ?? .undefined]) + } +} diff --git a/Sources/DOMKit/WebIDL/CompositionEventInit.swift b/Sources/DOMKit/WebIDL/CompositionEventInit.swift new file mode 100644 index 00000000..f3fa15f7 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CompositionEventInit.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class CompositionEventInit: BridgedDictionary { + public convenience init(data: String) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.data] = data.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _data = ReadWriteAttribute(jsObject: object, name: Strings.data) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var data: String +} diff --git a/Sources/DOMKit/WebIDL/ComputedEffectTiming.swift b/Sources/DOMKit/WebIDL/ComputedEffectTiming.swift new file mode 100644 index 00000000..b95ffc91 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ComputedEffectTiming.swift @@ -0,0 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ComputedEffectTiming: BridgedDictionary { + public convenience init(progress: Double?, currentIteration: Double?) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.progress] = progress.jsValue + object[Strings.currentIteration] = currentIteration.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _progress = ReadWriteAttribute(jsObject: object, name: Strings.progress) + _currentIteration = ReadWriteAttribute(jsObject: object, name: Strings.currentIteration) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var progress: Double? + + @ReadWriteAttribute + public var currentIteration: Double? +} diff --git a/Sources/DOMKit/WebIDL/CustomElementRegistry.swift b/Sources/DOMKit/WebIDL/CustomElementRegistry.swift new file mode 100644 index 00000000..18c39967 --- /dev/null +++ b/Sources/DOMKit/WebIDL/CustomElementRegistry.swift @@ -0,0 +1,41 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class CustomElementRegistry: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.CustomElementRegistry].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + @inlinable public func define(name: String, constructor: CustomElementConstructor, options: ElementDefinitionOptions? = nil) { + let this = jsObject + _ = this[Strings.define].function!(this: this, arguments: [name.jsValue, constructor.jsValue, options?.jsValue ?? .undefined]) + } + + @inlinable public func get(name: String) -> CustomElementConstructor? { + let this = jsObject + return this[Strings.get].function!(this: this, arguments: [name.jsValue]).fromJSValue()! + } + + @inlinable public func whenDefined(name: String) -> JSPromise { + let this = jsObject + return this[Strings.whenDefined].function!(this: this, arguments: [name.jsValue]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func whenDefined(name: String) async throws -> CustomElementConstructor { + let this = jsObject + let _promise: JSPromise = this[Strings.whenDefined].function!(this: this, arguments: [name.jsValue]).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable public func upgrade(root: Node) { + let this = jsObject + _ = this[Strings.upgrade].function!(this: this, arguments: [root.jsValue]) + } +} diff --git a/Sources/DOMKit/WebIDL/CustomEvent.swift b/Sources/DOMKit/WebIDL/CustomEvent.swift index 01eb4d3f..cb6978e7 100644 --- a/Sources/DOMKit/WebIDL/CustomEvent.swift +++ b/Sources/DOMKit/WebIDL/CustomEvent.swift @@ -1,26 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class CustomEvent: Event { - override public class var constructor: JSFunction { JSObject.global.CustomEvent.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.CustomEvent].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _detail = ReadonlyAttribute(jsObject: jsObject, name: "detail") + _detail = ReadonlyAttribute(jsObject: jsObject, name: Strings.detail) super.init(unsafelyWrapping: jsObject) } - public convenience init(type: String, eventInitDict: CustomEventInit = [:]) { - self.init(unsafelyWrapping: CustomEvent.constructor.new(type.jsValue(), eventInitDict.jsValue())) + @inlinable public convenience init(type: String, eventInitDict: CustomEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) } @ReadonlyAttribute public var detail: JSValue - public func initCustomEvent(type: String, bubbles: Bool = false, cancelable: Bool = false, detail: JSValue = nil) { - _ = jsObject.initCustomEvent!(type.jsValue(), bubbles.jsValue(), cancelable.jsValue(), detail.jsValue()) + @inlinable public func initCustomEvent(type: String, bubbles: Bool? = nil, cancelable: Bool? = nil, detail: JSValue? = nil) { + let this = jsObject + _ = this[Strings.initCustomEvent].function!(this: this, arguments: [type.jsValue, bubbles?.jsValue ?? .undefined, cancelable?.jsValue ?? .undefined, detail?.jsValue ?? .undefined]) } } diff --git a/Sources/DOMKit/WebIDL/CustomEventInit.swift b/Sources/DOMKit/WebIDL/CustomEventInit.swift index 52c858d6..7447c406 100644 --- a/Sources/DOMKit/WebIDL/CustomEventInit.swift +++ b/Sources/DOMKit/WebIDL/CustomEventInit.swift @@ -1,39 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public struct CustomEventInit: ExpressibleByDictionaryLiteral, JSBridgedType { - public enum Key: String, Hashable { - case bubbles, cancelable, composed, detail - } - - private let dictionary: [String: JSValue] - - public init(uniqueKeysWithValues elements: [(Key, ConvertibleToJSValue)]) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } - - public init(dictionaryLiteral elements: (Key, ConvertibleToJSValue)...) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } - - subscript(_ key: Key) -> JSValue? { - dictionary[key.rawValue] +public class CustomEventInit: BridgedDictionary { + public convenience init(detail: JSValue) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.detail] = detail.jsValue + self.init(unsafelyWrapping: object) } - public init?(from value: JSValue) { - if let dictionary: [String: JSValue] = value.fromJSValue() { - self.dictionary = dictionary - } - return nil + public required init(unsafelyWrapping object: JSObject) { + _detail = ReadWriteAttribute(jsObject: object, name: Strings.detail) + super.init(unsafelyWrapping: object) } - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - return dictionary.jsValue() - } + @ReadWriteAttribute + public var detail: JSValue } diff --git a/Sources/DOMKit/WebIDL/DOMException.swift b/Sources/DOMKit/WebIDL/DOMException.swift index f72cc1cb..9dc26feb 100644 --- a/Sources/DOMKit/WebIDL/DOMException.swift +++ b/Sources/DOMKit/WebIDL/DOMException.swift @@ -1,24 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class DOMException: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.DOMException.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.DOMException].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _name = ReadonlyAttribute(jsObject: jsObject, name: "name") - _message = ReadonlyAttribute(jsObject: jsObject, name: "message") - _code = ReadonlyAttribute(jsObject: jsObject, name: "code") + _name = ReadonlyAttribute(jsObject: jsObject, name: Strings.name) + _message = ReadonlyAttribute(jsObject: jsObject, name: Strings.message) + _code = ReadonlyAttribute(jsObject: jsObject, name: Strings.code) self.jsObject = jsObject } - public convenience init(message: String = "", name: String = "Error") { - self.init(unsafelyWrapping: DOMException.constructor.new(message.jsValue(), name.jsValue())) + @inlinable public convenience init(message: String? = nil, name: String? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [message?.jsValue ?? .undefined, name?.jsValue ?? .undefined])) } @ReadonlyAttribute @@ -30,53 +28,53 @@ public class DOMException: JSBridgedClass { @ReadonlyAttribute public var code: UInt16 - public let INDEX_SIZE_ERR: UInt16 = 1 + public static let INDEX_SIZE_ERR: UInt16 = 1 - public let DOMSTRING_SIZE_ERR: UInt16 = 2 + public static let DOMSTRING_SIZE_ERR: UInt16 = 2 - public let HIERARCHY_REQUEST_ERR: UInt16 = 3 + public static let HIERARCHY_REQUEST_ERR: UInt16 = 3 - public let WRONG_DOCUMENT_ERR: UInt16 = 4 + public static let WRONG_DOCUMENT_ERR: UInt16 = 4 - public let INVALID_CHARACTER_ERR: UInt16 = 5 + public static let INVALID_CHARACTER_ERR: UInt16 = 5 - public let NO_DATA_ALLOWED_ERR: UInt16 = 6 + public static let NO_DATA_ALLOWED_ERR: UInt16 = 6 - public let NO_MODIFICATION_ALLOWED_ERR: UInt16 = 7 + public static let NO_MODIFICATION_ALLOWED_ERR: UInt16 = 7 - public let NOT_FOUND_ERR: UInt16 = 8 + public static let NOT_FOUND_ERR: UInt16 = 8 - public let NOT_SUPPORTED_ERR: UInt16 = 9 + public static let NOT_SUPPORTED_ERR: UInt16 = 9 - public let INUSE_ATTRIBUTE_ERR: UInt16 = 10 + public static let INUSE_ATTRIBUTE_ERR: UInt16 = 10 - public let INVALID_STATE_ERR: UInt16 = 11 + public static let INVALID_STATE_ERR: UInt16 = 11 - public let SYNTAX_ERR: UInt16 = 12 + public static let SYNTAX_ERR: UInt16 = 12 - public let INVALID_MODIFICATION_ERR: UInt16 = 13 + public static let INVALID_MODIFICATION_ERR: UInt16 = 13 - public let NAMESPACE_ERR: UInt16 = 14 + public static let NAMESPACE_ERR: UInt16 = 14 - public let INVALID_ACCESS_ERR: UInt16 = 15 + public static let INVALID_ACCESS_ERR: UInt16 = 15 - public let VALIDATION_ERR: UInt16 = 16 + public static let VALIDATION_ERR: UInt16 = 16 - public let TYPE_MISMATCH_ERR: UInt16 = 17 + public static let TYPE_MISMATCH_ERR: UInt16 = 17 - public let SECURITY_ERR: UInt16 = 18 + public static let SECURITY_ERR: UInt16 = 18 - public let NETWORK_ERR: UInt16 = 19 + public static let NETWORK_ERR: UInt16 = 19 - public let ABORT_ERR: UInt16 = 20 + public static let ABORT_ERR: UInt16 = 20 - public let URL_MISMATCH_ERR: UInt16 = 21 + public static let URL_MISMATCH_ERR: UInt16 = 21 - public let QUOTA_EXCEEDED_ERR: UInt16 = 22 + public static let QUOTA_EXCEEDED_ERR: UInt16 = 22 - public let TIMEOUT_ERR: UInt16 = 23 + public static let TIMEOUT_ERR: UInt16 = 23 - public let INVALID_NODE_TYPE_ERR: UInt16 = 24 + public static let INVALID_NODE_TYPE_ERR: UInt16 = 24 - public let DATA_CLONE_ERR: UInt16 = 25 + public static let DATA_CLONE_ERR: UInt16 = 25 } diff --git a/Sources/DOMKit/WebIDL/DOMHighResTimeStamp.swift b/Sources/DOMKit/WebIDL/DOMHighResTimeStamp.swift deleted file mode 100644 index 6918922d..00000000 --- a/Sources/DOMKit/WebIDL/DOMHighResTimeStamp.swift +++ /dev/null @@ -1,8 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public typealias DOMHighResTimeStamp = Double diff --git a/Sources/DOMKit/WebIDL/DOMImplementation.swift b/Sources/DOMKit/WebIDL/DOMImplementation.swift index 6fa292cf..c4a0457b 100644 --- a/Sources/DOMKit/WebIDL/DOMImplementation.swift +++ b/Sources/DOMKit/WebIDL/DOMImplementation.swift @@ -1,12 +1,10 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class DOMImplementation: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.DOMImplementation.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.DOMImplementation].function! } public let jsObject: JSObject @@ -14,23 +12,23 @@ public class DOMImplementation: JSBridgedClass { self.jsObject = jsObject } - public func createDocumentType(qualifiedName: String, publicId: String, systemId: String) -> DocumentType { - return jsObject.createDocumentType!(qualifiedName.jsValue(), publicId.jsValue(), systemId.jsValue()).fromJSValue()! - } - - public func createDocument(namespace: String?, qualifiedName: String, doctype: DocumentType? = nil) -> XMLDocument { - return jsObject.createDocument!(namespace.jsValue(), qualifiedName.jsValue(), doctype.jsValue()).fromJSValue()! + @inlinable public func createDocumentType(qualifiedName: String, publicId: String, systemId: String) -> DocumentType { + let this = jsObject + return this[Strings.createDocumentType].function!(this: this, arguments: [qualifiedName.jsValue, publicId.jsValue, systemId.jsValue]).fromJSValue()! } - public func createHTMLDocument(title: String) -> Document { - return jsObject.createHTMLDocument!(title.jsValue()).fromJSValue()! + @inlinable public func createDocument(namespace: String?, qualifiedName: String, doctype: DocumentType? = nil) -> XMLDocument { + let this = jsObject + return this[Strings.createDocument].function!(this: this, arguments: [namespace.jsValue, qualifiedName.jsValue, doctype?.jsValue ?? .undefined]).fromJSValue()! } - public func createHTMLDocument() -> Document { - return jsObject.createHTMLDocument!().fromJSValue()! + @inlinable public func createHTMLDocument(title: String? = nil) -> Document { + let this = jsObject + return this[Strings.createHTMLDocument].function!(this: this, arguments: [title?.jsValue ?? .undefined]).fromJSValue()! } - public func hasFeature() -> Bool { - return jsObject.hasFeature!().fromJSValue()! + @inlinable public func hasFeature() -> Bool { + let this = jsObject + return this[Strings.hasFeature].function!(this: this, arguments: []).fromJSValue()! } } diff --git a/Sources/DOMKit/WebIDL/DOMMatrix.swift b/Sources/DOMKit/WebIDL/DOMMatrix.swift new file mode 100644 index 00000000..18cf4dd3 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMMatrix.swift @@ -0,0 +1,245 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DOMMatrix: DOMMatrixReadOnly { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.DOMMatrix].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _a = ReadWriteAttribute(jsObject: jsObject, name: Strings.a) + _b = ReadWriteAttribute(jsObject: jsObject, name: Strings.b) + _c = ReadWriteAttribute(jsObject: jsObject, name: Strings.c) + _d = ReadWriteAttribute(jsObject: jsObject, name: Strings.d) + _e = ReadWriteAttribute(jsObject: jsObject, name: Strings.e) + _f = ReadWriteAttribute(jsObject: jsObject, name: Strings.f) + _m11 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m11) + _m12 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m12) + _m13 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m13) + _m14 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m14) + _m21 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m21) + _m22 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m22) + _m23 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m23) + _m24 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m24) + _m31 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m31) + _m32 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m32) + _m33 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m33) + _m34 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m34) + _m41 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m41) + _m42 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m42) + _m43 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m43) + _m44 = ReadWriteAttribute(jsObject: jsObject, name: Strings.m44) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(init: String_or_seq_of_Double? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [`init`?.jsValue ?? .undefined])) + } + + // XXX: illegal static override + // override public static func fromMatrix(other: DOMMatrixInit? = nil) -> Self + + // XXX: illegal static override + // override public static func fromFloat32Array(array32: Float32Array) -> Self + + // XXX: illegal static override + // override public static func fromFloat64Array(array64: Float64Array) -> Self + + @usableFromInline let _a: ReadWriteAttribute + @inlinable override public var a: Double { + get { _a.wrappedValue } + set { _a.wrappedValue = newValue } + } + + @usableFromInline let _b: ReadWriteAttribute + @inlinable override public var b: Double { + get { _b.wrappedValue } + set { _b.wrappedValue = newValue } + } + + @usableFromInline let _c: ReadWriteAttribute + @inlinable override public var c: Double { + get { _c.wrappedValue } + set { _c.wrappedValue = newValue } + } + + @usableFromInline let _d: ReadWriteAttribute + @inlinable override public var d: Double { + get { _d.wrappedValue } + set { _d.wrappedValue = newValue } + } + + @usableFromInline let _e: ReadWriteAttribute + @inlinable override public var e: Double { + get { _e.wrappedValue } + set { _e.wrappedValue = newValue } + } + + @usableFromInline let _f: ReadWriteAttribute + @inlinable override public var f: Double { + get { _f.wrappedValue } + set { _f.wrappedValue = newValue } + } + + @usableFromInline let _m11: ReadWriteAttribute + @inlinable override public var m11: Double { + get { _m11.wrappedValue } + set { _m11.wrappedValue = newValue } + } + + @usableFromInline let _m12: ReadWriteAttribute + @inlinable override public var m12: Double { + get { _m12.wrappedValue } + set { _m12.wrappedValue = newValue } + } + + @usableFromInline let _m13: ReadWriteAttribute + @inlinable override public var m13: Double { + get { _m13.wrappedValue } + set { _m13.wrappedValue = newValue } + } + + @usableFromInline let _m14: ReadWriteAttribute + @inlinable override public var m14: Double { + get { _m14.wrappedValue } + set { _m14.wrappedValue = newValue } + } + + @usableFromInline let _m21: ReadWriteAttribute + @inlinable override public var m21: Double { + get { _m21.wrappedValue } + set { _m21.wrappedValue = newValue } + } + + @usableFromInline let _m22: ReadWriteAttribute + @inlinable override public var m22: Double { + get { _m22.wrappedValue } + set { _m22.wrappedValue = newValue } + } + + @usableFromInline let _m23: ReadWriteAttribute + @inlinable override public var m23: Double { + get { _m23.wrappedValue } + set { _m23.wrappedValue = newValue } + } + + @usableFromInline let _m24: ReadWriteAttribute + @inlinable override public var m24: Double { + get { _m24.wrappedValue } + set { _m24.wrappedValue = newValue } + } + + @usableFromInline let _m31: ReadWriteAttribute + @inlinable override public var m31: Double { + get { _m31.wrappedValue } + set { _m31.wrappedValue = newValue } + } + + @usableFromInline let _m32: ReadWriteAttribute + @inlinable override public var m32: Double { + get { _m32.wrappedValue } + set { _m32.wrappedValue = newValue } + } + + @usableFromInline let _m33: ReadWriteAttribute + @inlinable override public var m33: Double { + get { _m33.wrappedValue } + set { _m33.wrappedValue = newValue } + } + + @usableFromInline let _m34: ReadWriteAttribute + @inlinable override public var m34: Double { + get { _m34.wrappedValue } + set { _m34.wrappedValue = newValue } + } + + @usableFromInline let _m41: ReadWriteAttribute + @inlinable override public var m41: Double { + get { _m41.wrappedValue } + set { _m41.wrappedValue = newValue } + } + + @usableFromInline let _m42: ReadWriteAttribute + @inlinable override public var m42: Double { + get { _m42.wrappedValue } + set { _m42.wrappedValue = newValue } + } + + @usableFromInline let _m43: ReadWriteAttribute + @inlinable override public var m43: Double { + get { _m43.wrappedValue } + set { _m43.wrappedValue = newValue } + } + + @usableFromInline let _m44: ReadWriteAttribute + @inlinable override public var m44: Double { + get { _m44.wrappedValue } + set { _m44.wrappedValue = newValue } + } + + @inlinable public func multiplySelf(other: DOMMatrixInit? = nil) -> Self { + let this = jsObject + return this[Strings.multiplySelf].function!(this: this, arguments: [other?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func preMultiplySelf(other: DOMMatrixInit? = nil) -> Self { + let this = jsObject + return this[Strings.preMultiplySelf].function!(this: this, arguments: [other?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func translateSelf(tx: Double? = nil, ty: Double? = nil, tz: Double? = nil) -> Self { + let this = jsObject + return this[Strings.translateSelf].function!(this: this, arguments: [tx?.jsValue ?? .undefined, ty?.jsValue ?? .undefined, tz?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func scaleSelf(scaleX: Double? = nil, scaleY: Double? = nil, scaleZ: Double? = nil, originX: Double? = nil, originY: Double? = nil, originZ: Double? = nil) -> Self { + let _arg0 = scaleX?.jsValue ?? .undefined + let _arg1 = scaleY?.jsValue ?? .undefined + let _arg2 = scaleZ?.jsValue ?? .undefined + let _arg3 = originX?.jsValue ?? .undefined + let _arg4 = originY?.jsValue ?? .undefined + let _arg5 = originZ?.jsValue ?? .undefined + let this = jsObject + return this[Strings.scaleSelf].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5]).fromJSValue()! + } + + @inlinable public func scale3dSelf(scale: Double? = nil, originX: Double? = nil, originY: Double? = nil, originZ: Double? = nil) -> Self { + let this = jsObject + return this[Strings.scale3dSelf].function!(this: this, arguments: [scale?.jsValue ?? .undefined, originX?.jsValue ?? .undefined, originY?.jsValue ?? .undefined, originZ?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func rotateSelf(rotX: Double? = nil, rotY: Double? = nil, rotZ: Double? = nil) -> Self { + let this = jsObject + return this[Strings.rotateSelf].function!(this: this, arguments: [rotX?.jsValue ?? .undefined, rotY?.jsValue ?? .undefined, rotZ?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func rotateFromVectorSelf(x: Double? = nil, y: Double? = nil) -> Self { + let this = jsObject + return this[Strings.rotateFromVectorSelf].function!(this: this, arguments: [x?.jsValue ?? .undefined, y?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func rotateAxisAngleSelf(x: Double? = nil, y: Double? = nil, z: Double? = nil, angle: Double? = nil) -> Self { + let this = jsObject + return this[Strings.rotateAxisAngleSelf].function!(this: this, arguments: [x?.jsValue ?? .undefined, y?.jsValue ?? .undefined, z?.jsValue ?? .undefined, angle?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func skewXSelf(sx: Double? = nil) -> Self { + let this = jsObject + return this[Strings.skewXSelf].function!(this: this, arguments: [sx?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func skewYSelf(sy: Double? = nil) -> Self { + let this = jsObject + return this[Strings.skewYSelf].function!(this: this, arguments: [sy?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func invertSelf() -> Self { + let this = jsObject + return this[Strings.invertSelf].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func setMatrixValue(transformList: String) -> Self { + let this = jsObject + return this[Strings.setMatrixValue].function!(this: this, arguments: [transformList.jsValue]).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/DOMMatrix2DInit.swift b/Sources/DOMKit/WebIDL/DOMMatrix2DInit.swift new file mode 100644 index 00000000..06a3d09e --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMMatrix2DInit.swift @@ -0,0 +1,75 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DOMMatrix2DInit: BridgedDictionary { + public convenience init(a: Double, b: Double, c: Double, d: Double, e: Double, f: Double, m11: Double, m12: Double, m21: Double, m22: Double, m41: Double, m42: Double) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.a] = a.jsValue + object[Strings.b] = b.jsValue + object[Strings.c] = c.jsValue + object[Strings.d] = d.jsValue + object[Strings.e] = e.jsValue + object[Strings.f] = f.jsValue + object[Strings.m11] = m11.jsValue + object[Strings.m12] = m12.jsValue + object[Strings.m21] = m21.jsValue + object[Strings.m22] = m22.jsValue + object[Strings.m41] = m41.jsValue + object[Strings.m42] = m42.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _a = ReadWriteAttribute(jsObject: object, name: Strings.a) + _b = ReadWriteAttribute(jsObject: object, name: Strings.b) + _c = ReadWriteAttribute(jsObject: object, name: Strings.c) + _d = ReadWriteAttribute(jsObject: object, name: Strings.d) + _e = ReadWriteAttribute(jsObject: object, name: Strings.e) + _f = ReadWriteAttribute(jsObject: object, name: Strings.f) + _m11 = ReadWriteAttribute(jsObject: object, name: Strings.m11) + _m12 = ReadWriteAttribute(jsObject: object, name: Strings.m12) + _m21 = ReadWriteAttribute(jsObject: object, name: Strings.m21) + _m22 = ReadWriteAttribute(jsObject: object, name: Strings.m22) + _m41 = ReadWriteAttribute(jsObject: object, name: Strings.m41) + _m42 = ReadWriteAttribute(jsObject: object, name: Strings.m42) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var a: Double + + @ReadWriteAttribute + public var b: Double + + @ReadWriteAttribute + public var c: Double + + @ReadWriteAttribute + public var d: Double + + @ReadWriteAttribute + public var e: Double + + @ReadWriteAttribute + public var f: Double + + @ReadWriteAttribute + public var m11: Double + + @ReadWriteAttribute + public var m12: Double + + @ReadWriteAttribute + public var m21: Double + + @ReadWriteAttribute + public var m22: Double + + @ReadWriteAttribute + public var m41: Double + + @ReadWriteAttribute + public var m42: Double +} diff --git a/Sources/DOMKit/WebIDL/DOMMatrixInit.swift b/Sources/DOMKit/WebIDL/DOMMatrixInit.swift new file mode 100644 index 00000000..ad1d2d1d --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMMatrixInit.swift @@ -0,0 +1,70 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DOMMatrixInit: BridgedDictionary { + public convenience init(m13: Double, m14: Double, m23: Double, m24: Double, m31: Double, m32: Double, m33: Double, m34: Double, m43: Double, m44: Double, is2D: Bool) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.m13] = m13.jsValue + object[Strings.m14] = m14.jsValue + object[Strings.m23] = m23.jsValue + object[Strings.m24] = m24.jsValue + object[Strings.m31] = m31.jsValue + object[Strings.m32] = m32.jsValue + object[Strings.m33] = m33.jsValue + object[Strings.m34] = m34.jsValue + object[Strings.m43] = m43.jsValue + object[Strings.m44] = m44.jsValue + object[Strings.is2D] = is2D.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _m13 = ReadWriteAttribute(jsObject: object, name: Strings.m13) + _m14 = ReadWriteAttribute(jsObject: object, name: Strings.m14) + _m23 = ReadWriteAttribute(jsObject: object, name: Strings.m23) + _m24 = ReadWriteAttribute(jsObject: object, name: Strings.m24) + _m31 = ReadWriteAttribute(jsObject: object, name: Strings.m31) + _m32 = ReadWriteAttribute(jsObject: object, name: Strings.m32) + _m33 = ReadWriteAttribute(jsObject: object, name: Strings.m33) + _m34 = ReadWriteAttribute(jsObject: object, name: Strings.m34) + _m43 = ReadWriteAttribute(jsObject: object, name: Strings.m43) + _m44 = ReadWriteAttribute(jsObject: object, name: Strings.m44) + _is2D = ReadWriteAttribute(jsObject: object, name: Strings.is2D) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var m13: Double + + @ReadWriteAttribute + public var m14: Double + + @ReadWriteAttribute + public var m23: Double + + @ReadWriteAttribute + public var m24: Double + + @ReadWriteAttribute + public var m31: Double + + @ReadWriteAttribute + public var m32: Double + + @ReadWriteAttribute + public var m33: Double + + @ReadWriteAttribute + public var m34: Double + + @ReadWriteAttribute + public var m43: Double + + @ReadWriteAttribute + public var m44: Double + + @ReadWriteAttribute + public var is2D: Bool +} diff --git a/Sources/DOMKit/WebIDL/DOMMatrixReadOnly.swift b/Sources/DOMKit/WebIDL/DOMMatrixReadOnly.swift new file mode 100644 index 00000000..beec4a60 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMMatrixReadOnly.swift @@ -0,0 +1,224 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DOMMatrixReadOnly: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.DOMMatrixReadOnly].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _a = ReadonlyAttribute(jsObject: jsObject, name: Strings.a) + _b = ReadonlyAttribute(jsObject: jsObject, name: Strings.b) + _c = ReadonlyAttribute(jsObject: jsObject, name: Strings.c) + _d = ReadonlyAttribute(jsObject: jsObject, name: Strings.d) + _e = ReadonlyAttribute(jsObject: jsObject, name: Strings.e) + _f = ReadonlyAttribute(jsObject: jsObject, name: Strings.f) + _m11 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m11) + _m12 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m12) + _m13 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m13) + _m14 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m14) + _m21 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m21) + _m22 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m22) + _m23 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m23) + _m24 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m24) + _m31 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m31) + _m32 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m32) + _m33 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m33) + _m34 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m34) + _m41 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m41) + _m42 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m42) + _m43 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m43) + _m44 = ReadonlyAttribute(jsObject: jsObject, name: Strings.m44) + _is2D = ReadonlyAttribute(jsObject: jsObject, name: Strings.is2D) + _isIdentity = ReadonlyAttribute(jsObject: jsObject, name: Strings.isIdentity) + self.jsObject = jsObject + } + + @inlinable public convenience init(init: String_or_seq_of_Double? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [`init`?.jsValue ?? .undefined])) + } + + @inlinable public static func fromMatrix(other: DOMMatrixInit? = nil) -> Self { + let this = constructor + return this[Strings.fromMatrix].function!(this: this, arguments: [other?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public static func fromFloat32Array(array32: Float32Array) -> Self { + let this = constructor + return this[Strings.fromFloat32Array].function!(this: this, arguments: [array32.jsValue]).fromJSValue()! + } + + @inlinable public static func fromFloat64Array(array64: Float64Array) -> Self { + let this = constructor + return this[Strings.fromFloat64Array].function!(this: this, arguments: [array64.jsValue]).fromJSValue()! + } + + @ReadonlyAttribute + public var a: Double + + @ReadonlyAttribute + public var b: Double + + @ReadonlyAttribute + public var c: Double + + @ReadonlyAttribute + public var d: Double + + @ReadonlyAttribute + public var e: Double + + @ReadonlyAttribute + public var f: Double + + @ReadonlyAttribute + public var m11: Double + + @ReadonlyAttribute + public var m12: Double + + @ReadonlyAttribute + public var m13: Double + + @ReadonlyAttribute + public var m14: Double + + @ReadonlyAttribute + public var m21: Double + + @ReadonlyAttribute + public var m22: Double + + @ReadonlyAttribute + public var m23: Double + + @ReadonlyAttribute + public var m24: Double + + @ReadonlyAttribute + public var m31: Double + + @ReadonlyAttribute + public var m32: Double + + @ReadonlyAttribute + public var m33: Double + + @ReadonlyAttribute + public var m34: Double + + @ReadonlyAttribute + public var m41: Double + + @ReadonlyAttribute + public var m42: Double + + @ReadonlyAttribute + public var m43: Double + + @ReadonlyAttribute + public var m44: Double + + @ReadonlyAttribute + public var is2D: Bool + + @ReadonlyAttribute + public var isIdentity: Bool + + @inlinable public func translate(tx: Double? = nil, ty: Double? = nil, tz: Double? = nil) -> DOMMatrix { + let this = jsObject + return this[Strings.translate].function!(this: this, arguments: [tx?.jsValue ?? .undefined, ty?.jsValue ?? .undefined, tz?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func scale(scaleX: Double? = nil, scaleY: Double? = nil, scaleZ: Double? = nil, originX: Double? = nil, originY: Double? = nil, originZ: Double? = nil) -> DOMMatrix { + let _arg0 = scaleX?.jsValue ?? .undefined + let _arg1 = scaleY?.jsValue ?? .undefined + let _arg2 = scaleZ?.jsValue ?? .undefined + let _arg3 = originX?.jsValue ?? .undefined + let _arg4 = originY?.jsValue ?? .undefined + let _arg5 = originZ?.jsValue ?? .undefined + let this = jsObject + return this[Strings.scale].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5]).fromJSValue()! + } + + @inlinable public func scaleNonUniform(scaleX: Double? = nil, scaleY: Double? = nil) -> DOMMatrix { + let this = jsObject + return this[Strings.scaleNonUniform].function!(this: this, arguments: [scaleX?.jsValue ?? .undefined, scaleY?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func scale3d(scale: Double? = nil, originX: Double? = nil, originY: Double? = nil, originZ: Double? = nil) -> DOMMatrix { + let this = jsObject + return this[Strings.scale3d].function!(this: this, arguments: [scale?.jsValue ?? .undefined, originX?.jsValue ?? .undefined, originY?.jsValue ?? .undefined, originZ?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func rotate(rotX: Double? = nil, rotY: Double? = nil, rotZ: Double? = nil) -> DOMMatrix { + let this = jsObject + return this[Strings.rotate].function!(this: this, arguments: [rotX?.jsValue ?? .undefined, rotY?.jsValue ?? .undefined, rotZ?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func rotateFromVector(x: Double? = nil, y: Double? = nil) -> DOMMatrix { + let this = jsObject + return this[Strings.rotateFromVector].function!(this: this, arguments: [x?.jsValue ?? .undefined, y?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func rotateAxisAngle(x: Double? = nil, y: Double? = nil, z: Double? = nil, angle: Double? = nil) -> DOMMatrix { + let this = jsObject + return this[Strings.rotateAxisAngle].function!(this: this, arguments: [x?.jsValue ?? .undefined, y?.jsValue ?? .undefined, z?.jsValue ?? .undefined, angle?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func skewX(sx: Double? = nil) -> DOMMatrix { + let this = jsObject + return this[Strings.skewX].function!(this: this, arguments: [sx?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func skewY(sy: Double? = nil) -> DOMMatrix { + let this = jsObject + return this[Strings.skewY].function!(this: this, arguments: [sy?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func multiply(other: DOMMatrixInit? = nil) -> DOMMatrix { + let this = jsObject + return this[Strings.multiply].function!(this: this, arguments: [other?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func flipX() -> DOMMatrix { + let this = jsObject + return this[Strings.flipX].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func flipY() -> DOMMatrix { + let this = jsObject + return this[Strings.flipY].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func inverse() -> DOMMatrix { + let this = jsObject + return this[Strings.inverse].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func transformPoint(point: DOMPointInit? = nil) -> DOMPoint { + let this = jsObject + return this[Strings.transformPoint].function!(this: this, arguments: [point?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func toFloat32Array() -> Float32Array { + let this = jsObject + return this[Strings.toFloat32Array].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func toFloat64Array() -> Float64Array { + let this = jsObject + return this[Strings.toFloat64Array].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public var description: String { + jsObject[Strings.toString]!().fromJSValue()! + } + + @inlinable public func toJSON() -> JSObject { + let this = jsObject + return this[Strings.toJSON].function!(this: this, arguments: []).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/DOMParser.swift b/Sources/DOMKit/WebIDL/DOMParser.swift new file mode 100644 index 00000000..05ae1ed7 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMParser.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DOMParser: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.DOMParser].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @inlinable public func parseFromString(string: String, type: DOMParserSupportedType) -> Document { + let this = jsObject + return this[Strings.parseFromString].function!(this: this, arguments: [string.jsValue, type.jsValue]).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/DOMParserSupportedType.swift b/Sources/DOMKit/WebIDL/DOMParserSupportedType.swift new file mode 100644 index 00000000..273ffda3 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMParserSupportedType.swift @@ -0,0 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum DOMParserSupportedType: JSString, JSValueCompatible { + case textHtml = "text/html" + case textXml = "text/xml" + case applicationXml = "application/xml" + case applicationXhtmlXml = "application/xhtml+xml" + case imageSvgXml = "image/svg+xml" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/DOMPoint.swift b/Sources/DOMKit/WebIDL/DOMPoint.swift new file mode 100644 index 00000000..a6a4c7af --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMPoint.swift @@ -0,0 +1,47 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DOMPoint: DOMPointReadOnly { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.DOMPoint].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _x = ReadWriteAttribute(jsObject: jsObject, name: Strings.x) + _y = ReadWriteAttribute(jsObject: jsObject, name: Strings.y) + _z = ReadWriteAttribute(jsObject: jsObject, name: Strings.z) + _w = ReadWriteAttribute(jsObject: jsObject, name: Strings.w) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(x: Double? = nil, y: Double? = nil, z: Double? = nil, w: Double? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [x?.jsValue ?? .undefined, y?.jsValue ?? .undefined, z?.jsValue ?? .undefined, w?.jsValue ?? .undefined])) + } + + // XXX: illegal static override + // override public static func fromPoint(other: DOMPointInit? = nil) -> Self + + @usableFromInline let _x: ReadWriteAttribute + @inlinable override public var x: Double { + get { _x.wrappedValue } + set { _x.wrappedValue = newValue } + } + + @usableFromInline let _y: ReadWriteAttribute + @inlinable override public var y: Double { + get { _y.wrappedValue } + set { _y.wrappedValue = newValue } + } + + @usableFromInline let _z: ReadWriteAttribute + @inlinable override public var z: Double { + get { _z.wrappedValue } + set { _z.wrappedValue = newValue } + } + + @usableFromInline let _w: ReadWriteAttribute + @inlinable override public var w: Double { + get { _w.wrappedValue } + set { _w.wrappedValue = newValue } + } +} diff --git a/Sources/DOMKit/WebIDL/DOMPointInit.swift b/Sources/DOMKit/WebIDL/DOMPointInit.swift new file mode 100644 index 00000000..375d2f33 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMPointInit.swift @@ -0,0 +1,35 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DOMPointInit: BridgedDictionary { + public convenience init(x: Double, y: Double, z: Double, w: Double) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.x] = x.jsValue + object[Strings.y] = y.jsValue + object[Strings.z] = z.jsValue + object[Strings.w] = w.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _x = ReadWriteAttribute(jsObject: object, name: Strings.x) + _y = ReadWriteAttribute(jsObject: object, name: Strings.y) + _z = ReadWriteAttribute(jsObject: object, name: Strings.z) + _w = ReadWriteAttribute(jsObject: object, name: Strings.w) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var x: Double + + @ReadWriteAttribute + public var y: Double + + @ReadWriteAttribute + public var z: Double + + @ReadWriteAttribute + public var w: Double +} diff --git a/Sources/DOMKit/WebIDL/DOMPointInit_or_Double.swift b/Sources/DOMKit/WebIDL/DOMPointInit_or_Double.swift new file mode 100644 index 00000000..8fdec85e --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMPointInit_or_Double.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_DOMPointInit_or_Double: ConvertibleToJSValue {} +extension DOMPointInit: Any_DOMPointInit_or_Double {} +extension Double: Any_DOMPointInit_or_Double {} + +public enum DOMPointInit_or_Double: JSValueCompatible, Any_DOMPointInit_or_Double { + case domPointInit(DOMPointInit) + case double(Double) + + var domPointInit: DOMPointInit? { + switch self { + case let .domPointInit(domPointInit): return domPointInit + default: return nil + } + } + + var double: Double? { + switch self { + case let .double(double): return double + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let domPointInit: DOMPointInit = value.fromJSValue() { + return .domPointInit(domPointInit) + } + if let double: Double = value.fromJSValue() { + return .double(double) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .domPointInit(domPointInit): + return domPointInit.jsValue + case let .double(double): + return double.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/DOMPointInit_or_Double_or_seq_of_DOMPointInit_or_Double.swift b/Sources/DOMKit/WebIDL/DOMPointInit_or_Double_or_seq_of_DOMPointInit_or_Double.swift new file mode 100644 index 00000000..e8a88b4d --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMPointInit_or_Double_or_seq_of_DOMPointInit_or_Double.swift @@ -0,0 +1,60 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_DOMPointInit_or_Double_or_seq_of_DOMPointInit_or_Double: ConvertibleToJSValue {} +extension DOMPointInit: Any_DOMPointInit_or_Double_or_seq_of_DOMPointInit_or_Double {} +extension Double: Any_DOMPointInit_or_Double_or_seq_of_DOMPointInit_or_Double {} +extension Array: Any_DOMPointInit_or_Double_or_seq_of_DOMPointInit_or_Double where Element == DOMPointInit_or_Double {} + +public enum DOMPointInit_or_Double_or_seq_of_DOMPointInit_or_Double: JSValueCompatible, Any_DOMPointInit_or_Double_or_seq_of_DOMPointInit_or_Double { + case domPointInit(DOMPointInit) + case double(Double) + case seq_of_DOMPointInit_or_Double([DOMPointInit_or_Double]) + + var domPointInit: DOMPointInit? { + switch self { + case let .domPointInit(domPointInit): return domPointInit + default: return nil + } + } + + var double: Double? { + switch self { + case let .double(double): return double + default: return nil + } + } + + var seq_of_DOMPointInit_or_Double: [DOMPointInit_or_Double]? { + switch self { + case let .seq_of_DOMPointInit_or_Double(seq_of_DOMPointInit_or_Double): return seq_of_DOMPointInit_or_Double + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let domPointInit: DOMPointInit = value.fromJSValue() { + return .domPointInit(domPointInit) + } + if let double: Double = value.fromJSValue() { + return .double(double) + } + if let seq_of_DOMPointInit_or_Double: [DOMPointInit_or_Double] = value.fromJSValue() { + return .seq_of_DOMPointInit_or_Double(seq_of_DOMPointInit_or_Double) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .domPointInit(domPointInit): + return domPointInit.jsValue + case let .double(double): + return double.jsValue + case let .seq_of_DOMPointInit_or_Double(seq_of_DOMPointInit_or_Double): + return seq_of_DOMPointInit_or_Double.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/DOMPointReadOnly.swift b/Sources/DOMKit/WebIDL/DOMPointReadOnly.swift new file mode 100644 index 00000000..40a34293 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMPointReadOnly.swift @@ -0,0 +1,49 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DOMPointReadOnly: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.DOMPointReadOnly].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _x = ReadonlyAttribute(jsObject: jsObject, name: Strings.x) + _y = ReadonlyAttribute(jsObject: jsObject, name: Strings.y) + _z = ReadonlyAttribute(jsObject: jsObject, name: Strings.z) + _w = ReadonlyAttribute(jsObject: jsObject, name: Strings.w) + self.jsObject = jsObject + } + + @inlinable public convenience init(x: Double? = nil, y: Double? = nil, z: Double? = nil, w: Double? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [x?.jsValue ?? .undefined, y?.jsValue ?? .undefined, z?.jsValue ?? .undefined, w?.jsValue ?? .undefined])) + } + + @inlinable public static func fromPoint(other: DOMPointInit? = nil) -> Self { + let this = constructor + return this[Strings.fromPoint].function!(this: this, arguments: [other?.jsValue ?? .undefined]).fromJSValue()! + } + + @ReadonlyAttribute + public var x: Double + + @ReadonlyAttribute + public var y: Double + + @ReadonlyAttribute + public var z: Double + + @ReadonlyAttribute + public var w: Double + + @inlinable public func matrixTransform(matrix: DOMMatrixInit? = nil) -> DOMPoint { + let this = jsObject + return this[Strings.matrixTransform].function!(this: this, arguments: [matrix?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func toJSON() -> JSObject { + let this = jsObject + return this[Strings.toJSON].function!(this: this, arguments: []).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/DOMQuad.swift b/Sources/DOMKit/WebIDL/DOMQuad.swift new file mode 100644 index 00000000..258b0fd5 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMQuad.swift @@ -0,0 +1,54 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DOMQuad: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.DOMQuad].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _p1 = ReadonlyAttribute(jsObject: jsObject, name: Strings.p1) + _p2 = ReadonlyAttribute(jsObject: jsObject, name: Strings.p2) + _p3 = ReadonlyAttribute(jsObject: jsObject, name: Strings.p3) + _p4 = ReadonlyAttribute(jsObject: jsObject, name: Strings.p4) + self.jsObject = jsObject + } + + @inlinable public convenience init(p1: DOMPointInit? = nil, p2: DOMPointInit? = nil, p3: DOMPointInit? = nil, p4: DOMPointInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [p1?.jsValue ?? .undefined, p2?.jsValue ?? .undefined, p3?.jsValue ?? .undefined, p4?.jsValue ?? .undefined])) + } + + @inlinable public static func fromRect(other: DOMRectInit? = nil) -> Self { + let this = constructor + return this[Strings.fromRect].function!(this: this, arguments: [other?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public static func fromQuad(other: DOMQuadInit? = nil) -> Self { + let this = constructor + return this[Strings.fromQuad].function!(this: this, arguments: [other?.jsValue ?? .undefined]).fromJSValue()! + } + + @ReadonlyAttribute + public var p1: DOMPoint + + @ReadonlyAttribute + public var p2: DOMPoint + + @ReadonlyAttribute + public var p3: DOMPoint + + @ReadonlyAttribute + public var p4: DOMPoint + + @inlinable public func getBounds() -> DOMRect { + let this = jsObject + return this[Strings.getBounds].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func toJSON() -> JSObject { + let this = jsObject + return this[Strings.toJSON].function!(this: this, arguments: []).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/DOMQuadInit.swift b/Sources/DOMKit/WebIDL/DOMQuadInit.swift new file mode 100644 index 00000000..19faf473 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMQuadInit.swift @@ -0,0 +1,35 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DOMQuadInit: BridgedDictionary { + public convenience init(p1: DOMPointInit, p2: DOMPointInit, p3: DOMPointInit, p4: DOMPointInit) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.p1] = p1.jsValue + object[Strings.p2] = p2.jsValue + object[Strings.p3] = p3.jsValue + object[Strings.p4] = p4.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _p1 = ReadWriteAttribute(jsObject: object, name: Strings.p1) + _p2 = ReadWriteAttribute(jsObject: object, name: Strings.p2) + _p3 = ReadWriteAttribute(jsObject: object, name: Strings.p3) + _p4 = ReadWriteAttribute(jsObject: object, name: Strings.p4) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var p1: DOMPointInit + + @ReadWriteAttribute + public var p2: DOMPointInit + + @ReadWriteAttribute + public var p3: DOMPointInit + + @ReadWriteAttribute + public var p4: DOMPointInit +} diff --git a/Sources/DOMKit/WebIDL/DOMRect.swift b/Sources/DOMKit/WebIDL/DOMRect.swift new file mode 100644 index 00000000..8214b20d --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMRect.swift @@ -0,0 +1,47 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DOMRect: DOMRectReadOnly { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.DOMRect].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _x = ReadWriteAttribute(jsObject: jsObject, name: Strings.x) + _y = ReadWriteAttribute(jsObject: jsObject, name: Strings.y) + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + _height = ReadWriteAttribute(jsObject: jsObject, name: Strings.height) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(x: Double? = nil, y: Double? = nil, width: Double? = nil, height: Double? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [x?.jsValue ?? .undefined, y?.jsValue ?? .undefined, width?.jsValue ?? .undefined, height?.jsValue ?? .undefined])) + } + + // XXX: illegal static override + // override public static func fromRect(other: DOMRectInit? = nil) -> Self + + @usableFromInline let _x: ReadWriteAttribute + @inlinable override public var x: Double { + get { _x.wrappedValue } + set { _x.wrappedValue = newValue } + } + + @usableFromInline let _y: ReadWriteAttribute + @inlinable override public var y: Double { + get { _y.wrappedValue } + set { _y.wrappedValue = newValue } + } + + @usableFromInline let _width: ReadWriteAttribute + @inlinable override public var width: Double { + get { _width.wrappedValue } + set { _width.wrappedValue = newValue } + } + + @usableFromInline let _height: ReadWriteAttribute + @inlinable override public var height: Double { + get { _height.wrappedValue } + set { _height.wrappedValue = newValue } + } +} diff --git a/Sources/DOMKit/WebIDL/DOMRectInit.swift b/Sources/DOMKit/WebIDL/DOMRectInit.swift new file mode 100644 index 00000000..0c6ec947 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMRectInit.swift @@ -0,0 +1,35 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DOMRectInit: BridgedDictionary { + public convenience init(x: Double, y: Double, width: Double, height: Double) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.x] = x.jsValue + object[Strings.y] = y.jsValue + object[Strings.width] = width.jsValue + object[Strings.height] = height.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _x = ReadWriteAttribute(jsObject: object, name: Strings.x) + _y = ReadWriteAttribute(jsObject: object, name: Strings.y) + _width = ReadWriteAttribute(jsObject: object, name: Strings.width) + _height = ReadWriteAttribute(jsObject: object, name: Strings.height) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var x: Double + + @ReadWriteAttribute + public var y: Double + + @ReadWriteAttribute + public var width: Double + + @ReadWriteAttribute + public var height: Double +} diff --git a/Sources/DOMKit/WebIDL/DOMRectList.swift b/Sources/DOMKit/WebIDL/DOMRectList.swift new file mode 100644 index 00000000..8884a007 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMRectList.swift @@ -0,0 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DOMRectList: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.DOMRectList].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var length: UInt32 + + @inlinable public subscript(key: Int) -> DOMRect? { + jsObject[key].fromJSValue() + } +} diff --git a/Sources/DOMKit/WebIDL/DOMRectReadOnly.swift b/Sources/DOMKit/WebIDL/DOMRectReadOnly.swift new file mode 100644 index 00000000..c4d49955 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMRectReadOnly.swift @@ -0,0 +1,60 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DOMRectReadOnly: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.DOMRectReadOnly].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _x = ReadonlyAttribute(jsObject: jsObject, name: Strings.x) + _y = ReadonlyAttribute(jsObject: jsObject, name: Strings.y) + _width = ReadonlyAttribute(jsObject: jsObject, name: Strings.width) + _height = ReadonlyAttribute(jsObject: jsObject, name: Strings.height) + _top = ReadonlyAttribute(jsObject: jsObject, name: Strings.top) + _right = ReadonlyAttribute(jsObject: jsObject, name: Strings.right) + _bottom = ReadonlyAttribute(jsObject: jsObject, name: Strings.bottom) + _left = ReadonlyAttribute(jsObject: jsObject, name: Strings.left) + self.jsObject = jsObject + } + + @inlinable public convenience init(x: Double? = nil, y: Double? = nil, width: Double? = nil, height: Double? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [x?.jsValue ?? .undefined, y?.jsValue ?? .undefined, width?.jsValue ?? .undefined, height?.jsValue ?? .undefined])) + } + + @inlinable public static func fromRect(other: DOMRectInit? = nil) -> Self { + let this = constructor + return this[Strings.fromRect].function!(this: this, arguments: [other?.jsValue ?? .undefined]).fromJSValue()! + } + + @ReadonlyAttribute + public var x: Double + + @ReadonlyAttribute + public var y: Double + + @ReadonlyAttribute + public var width: Double + + @ReadonlyAttribute + public var height: Double + + @ReadonlyAttribute + public var top: Double + + @ReadonlyAttribute + public var right: Double + + @ReadonlyAttribute + public var bottom: Double + + @ReadonlyAttribute + public var left: Double + + @inlinable public func toJSON() -> JSObject { + let this = jsObject + return this[Strings.toJSON].function!(this: this, arguments: []).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/DOMStringList.swift b/Sources/DOMKit/WebIDL/DOMStringList.swift new file mode 100644 index 00000000..78686c50 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DOMStringList.swift @@ -0,0 +1,27 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DOMStringList: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.DOMStringList].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var length: UInt32 + + @inlinable public subscript(key: Int) -> String? { + jsObject[key].fromJSValue() + } + + @inlinable public func contains(string: String) -> Bool { + let this = jsObject + return this[Strings.contains].function!(this: this, arguments: [string.jsValue]).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/DOMStringMap.swift b/Sources/DOMKit/WebIDL/DOMStringMap.swift index 9b1cc086..ce5c6ab5 100644 --- a/Sources/DOMKit/WebIDL/DOMStringMap.swift +++ b/Sources/DOMKit/WebIDL/DOMStringMap.swift @@ -1,12 +1,10 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class DOMStringMap: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.DOMStringMap.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.DOMStringMap].function! } public let jsObject: JSObject @@ -14,12 +12,11 @@ public class DOMStringMap: JSBridgedClass { self.jsObject = jsObject } - public subscript(_: String) -> String? { - get { - return jsObject.name.fromJSValue()! - } - set { - jsObject.name = newValue.jsValue() - } + @inlinable public subscript(key: String) -> String { + jsObject[key].fromJSValue()! } + + // XXX: unsupported setter for keys of type String + + // XXX: unsupported deleter for keys of type String } diff --git a/Sources/DOMKit/WebIDL/DOMTimeStamp.swift b/Sources/DOMKit/WebIDL/DOMTimeStamp.swift deleted file mode 100644 index cdc83efe..00000000 --- a/Sources/DOMKit/WebIDL/DOMTimeStamp.swift +++ /dev/null @@ -1,8 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public typealias DOMTimeStamp = UInt64 diff --git a/Sources/DOMKit/WebIDL/DOMTokenList.swift b/Sources/DOMKit/WebIDL/DOMTokenList.swift index 0690bcf4..4cc9cd76 100644 --- a/Sources/DOMKit/WebIDL/DOMTokenList.swift +++ b/Sources/DOMKit/WebIDL/DOMTokenList.swift @@ -1,60 +1,61 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class DOMTokenList: JSBridgedClass, Sequence { - public class var constructor: JSFunction { JSObject.global.DOMTokenList.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.DOMTokenList].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _length = ReadonlyAttribute(jsObject: jsObject, name: "length") + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + _value = ReadWriteAttribute(jsObject: jsObject, name: Strings.value) self.jsObject = jsObject } - public typealias Element = String - @ReadonlyAttribute public var length: UInt32 - public func contains(token: String) -> Bool { - return jsObject.contains!(token.jsValue()).fromJSValue()! + @inlinable public subscript(key: Int) -> String? { + jsObject[key].fromJSValue() } - public func add(tokens: String...) { - _ = jsObject.add!(tokens.jsValue()) + @inlinable public func contains(token: String) -> Bool { + let this = jsObject + return this[Strings.contains].function!(this: this, arguments: [token.jsValue]).fromJSValue()! } - public func add() { - _ = jsObject.add!() + @inlinable public func add(tokens: String...) { + let this = jsObject + _ = this[Strings.add].function!(this: this, arguments: tokens.map(\.jsValue)) } - public func remove(tokens: String...) { - _ = jsObject.remove!(tokens.jsValue()) + @inlinable public func remove(tokens: String...) { + let this = jsObject + _ = this[Strings.remove].function!(this: this, arguments: tokens.map(\.jsValue)) } - public func remove() { - _ = jsObject.remove!() + @inlinable public func toggle(token: String, force: Bool? = nil) -> Bool { + let this = jsObject + return this[Strings.toggle].function!(this: this, arguments: [token.jsValue, force?.jsValue ?? .undefined]).fromJSValue()! } - public func toggle(token: String, force: Bool) -> Bool { - return jsObject.toggle!(token.jsValue(), force.jsValue()).fromJSValue()! + @inlinable public func replace(token: String, newToken: String) -> Bool { + let this = jsObject + return this[Strings.replace].function!(this: this, arguments: [token.jsValue, newToken.jsValue]).fromJSValue()! } - public func toggle(token: String) -> Bool { - return jsObject.toggle!(token.jsValue()).fromJSValue()! + @inlinable public func supports(token: String) -> Bool { + let this = jsObject + return this[Strings.supports].function!(this: this, arguments: [token.jsValue]).fromJSValue()! } - public func replace(token: String, newToken: String) -> Bool { - return jsObject.replace!(token.jsValue(), newToken.jsValue()).fromJSValue()! - } + @ReadWriteAttribute + public var value: String - public func supports(token: String) -> Bool { - return jsObject.supports!(token.jsValue()).fromJSValue()! + public typealias Element = String + public func makeIterator() -> ValueIterableIterator { + ValueIterableIterator(sequence: self) } - - public func makeIterator() -> ValueIterableIterator { return ValueIterableIterator(sequence: self) } } diff --git a/Sources/DOMKit/WebIDL/DataTransfer.swift b/Sources/DOMKit/WebIDL/DataTransfer.swift new file mode 100644 index 00000000..a96259e9 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DataTransfer.swift @@ -0,0 +1,58 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DataTransfer: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.DataTransfer].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _dropEffect = ReadWriteAttribute(jsObject: jsObject, name: Strings.dropEffect) + _effectAllowed = ReadWriteAttribute(jsObject: jsObject, name: Strings.effectAllowed) + _items = ReadonlyAttribute(jsObject: jsObject, name: Strings.items) + _types = ReadonlyAttribute(jsObject: jsObject, name: Strings.types) + _files = ReadonlyAttribute(jsObject: jsObject, name: Strings.files) + self.jsObject = jsObject + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var dropEffect: String + + @ReadWriteAttribute + public var effectAllowed: String + + @ReadonlyAttribute + public var items: DataTransferItemList + + @inlinable public func setDragImage(image: Element, x: Int32, y: Int32) { + let this = jsObject + _ = this[Strings.setDragImage].function!(this: this, arguments: [image.jsValue, x.jsValue, y.jsValue]) + } + + @ReadonlyAttribute + public var types: [String] + + @inlinable public func getData(format: String) -> String { + let this = jsObject + return this[Strings.getData].function!(this: this, arguments: [format.jsValue]).fromJSValue()! + } + + @inlinable public func setData(format: String, data: String) { + let this = jsObject + _ = this[Strings.setData].function!(this: this, arguments: [format.jsValue, data.jsValue]) + } + + @inlinable public func clearData(format: String? = nil) { + let this = jsObject + _ = this[Strings.clearData].function!(this: this, arguments: [format?.jsValue ?? .undefined]) + } + + @ReadonlyAttribute + public var files: FileList +} diff --git a/Sources/DOMKit/WebIDL/DataTransferItem.swift b/Sources/DOMKit/WebIDL/DataTransferItem.swift new file mode 100644 index 00000000..efe475e0 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DataTransferItem.swift @@ -0,0 +1,29 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DataTransferItem: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.DataTransferItem].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _kind = ReadonlyAttribute(jsObject: jsObject, name: Strings.kind) + _type = ReadonlyAttribute(jsObject: jsObject, name: Strings.type) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var kind: String + + @ReadonlyAttribute + public var type: String + + // XXX: member 'getAsString' is ignored + + @inlinable public func getAsFile() -> File? { + let this = jsObject + return this[Strings.getAsFile].function!(this: this, arguments: []).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/DataTransferItemList.swift b/Sources/DOMKit/WebIDL/DataTransferItemList.swift new file mode 100644 index 00000000..0e00f762 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DataTransferItemList.swift @@ -0,0 +1,42 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DataTransferItemList: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.DataTransferItemList].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var length: UInt32 + + @inlinable public subscript(key: Int) -> DataTransferItem { + jsObject[key].fromJSValue()! + } + + @inlinable public func add(data: String, type: String) -> DataTransferItem? { + let this = jsObject + return this[Strings.add].function!(this: this, arguments: [data.jsValue, type.jsValue]).fromJSValue()! + } + + @inlinable public func add(data: File) -> DataTransferItem? { + let this = jsObject + return this[Strings.add].function!(this: this, arguments: [data.jsValue]).fromJSValue()! + } + + @inlinable public func remove(index: UInt32) { + let this = jsObject + _ = this[Strings.remove].function!(this: this, arguments: [index.jsValue]) + } + + @inlinable public func clear() { + let this = jsObject + _ = this[Strings.clear].function!(this: this, arguments: []) + } +} diff --git a/Sources/DOMKit/WebIDL/Document.swift b/Sources/DOMKit/WebIDL/Document.swift index 003c084b..e4c2ae73 100644 --- a/Sources/DOMKit/WebIDL/Document.swift +++ b/Sources/DOMKit/WebIDL/Document.swift @@ -1,29 +1,59 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public class Document: Node, DocumentOrShadowRoot, NonElementParentNode, ParentNode, XPathEvaluatorBase { - override public class var constructor: JSFunction { JSObject.global.Document.function! } +public class Document: Node, NonElementParentNode, DocumentOrShadowRoot, ParentNode, XPathEvaluatorBase, GlobalEventHandlers, DocumentAndElementEventHandlers { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.Document].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _implementation = ReadonlyAttribute(jsObject: jsObject, name: "implementation") - _URL = ReadonlyAttribute(jsObject: jsObject, name: "URL") - _documentURI = ReadonlyAttribute(jsObject: jsObject, name: "documentURI") - _compatMode = ReadonlyAttribute(jsObject: jsObject, name: "compatMode") - _characterSet = ReadonlyAttribute(jsObject: jsObject, name: "characterSet") - _charset = ReadonlyAttribute(jsObject: jsObject, name: "charset") - _inputEncoding = ReadonlyAttribute(jsObject: jsObject, name: "inputEncoding") - _contentType = ReadonlyAttribute(jsObject: jsObject, name: "contentType") - _doctype = ReadonlyAttribute(jsObject: jsObject, name: "doctype") - _documentElement = ReadonlyAttribute(jsObject: jsObject, name: "documentElement") + _implementation = ReadonlyAttribute(jsObject: jsObject, name: Strings.implementation) + _URL = ReadonlyAttribute(jsObject: jsObject, name: Strings.URL) + _documentURI = ReadonlyAttribute(jsObject: jsObject, name: Strings.documentURI) + _compatMode = ReadonlyAttribute(jsObject: jsObject, name: Strings.compatMode) + _characterSet = ReadonlyAttribute(jsObject: jsObject, name: Strings.characterSet) + _charset = ReadonlyAttribute(jsObject: jsObject, name: Strings.charset) + _inputEncoding = ReadonlyAttribute(jsObject: jsObject, name: Strings.inputEncoding) + _contentType = ReadonlyAttribute(jsObject: jsObject, name: Strings.contentType) + _doctype = ReadonlyAttribute(jsObject: jsObject, name: Strings.doctype) + _documentElement = ReadonlyAttribute(jsObject: jsObject, name: Strings.documentElement) + _location = ReadonlyAttribute(jsObject: jsObject, name: Strings.location) + _domain = ReadWriteAttribute(jsObject: jsObject, name: Strings.domain) + _referrer = ReadonlyAttribute(jsObject: jsObject, name: Strings.referrer) + _cookie = ReadWriteAttribute(jsObject: jsObject, name: Strings.cookie) + _lastModified = ReadonlyAttribute(jsObject: jsObject, name: Strings.lastModified) + _readyState = ReadonlyAttribute(jsObject: jsObject, name: Strings.readyState) + _title = ReadWriteAttribute(jsObject: jsObject, name: Strings.title) + _dir = ReadWriteAttribute(jsObject: jsObject, name: Strings.dir) + _body = ReadWriteAttribute(jsObject: jsObject, name: Strings.body) + _head = ReadonlyAttribute(jsObject: jsObject, name: Strings.head) + _images = ReadonlyAttribute(jsObject: jsObject, name: Strings.images) + _embeds = ReadonlyAttribute(jsObject: jsObject, name: Strings.embeds) + _plugins = ReadonlyAttribute(jsObject: jsObject, name: Strings.plugins) + _links = ReadonlyAttribute(jsObject: jsObject, name: Strings.links) + _forms = ReadonlyAttribute(jsObject: jsObject, name: Strings.forms) + _scripts = ReadonlyAttribute(jsObject: jsObject, name: Strings.scripts) + _currentScript = ReadonlyAttribute(jsObject: jsObject, name: Strings.currentScript) + _defaultView = ReadonlyAttribute(jsObject: jsObject, name: Strings.defaultView) + _designMode = ReadWriteAttribute(jsObject: jsObject, name: Strings.designMode) + _hidden = ReadonlyAttribute(jsObject: jsObject, name: Strings.hidden) + _visibilityState = ReadonlyAttribute(jsObject: jsObject, name: Strings.visibilityState) + _onreadystatechange = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onreadystatechange) + _onvisibilitychange = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onvisibilitychange) + _fgColor = ReadWriteAttribute(jsObject: jsObject, name: Strings.fgColor) + _linkColor = ReadWriteAttribute(jsObject: jsObject, name: Strings.linkColor) + _vlinkColor = ReadWriteAttribute(jsObject: jsObject, name: Strings.vlinkColor) + _alinkColor = ReadWriteAttribute(jsObject: jsObject, name: Strings.alinkColor) + _bgColor = ReadWriteAttribute(jsObject: jsObject, name: Strings.bgColor) + _anchors = ReadonlyAttribute(jsObject: jsObject, name: Strings.anchors) + _applets = ReadonlyAttribute(jsObject: jsObject, name: Strings.applets) + _all = ReadonlyAttribute(jsObject: jsObject, name: Strings.all) + _timeline = ReadonlyAttribute(jsObject: jsObject, name: Strings.timeline) super.init(unsafelyWrapping: jsObject) } - public convenience init() { - self.init(unsafelyWrapping: Document.constructor.new()) + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) } @ReadonlyAttribute @@ -56,83 +86,267 @@ public class Document: Node, DocumentOrShadowRoot, NonElementParentNode, ParentN @ReadonlyAttribute public var documentElement: Element? - public func getElementsByTagName(qualifiedName: String) -> HTMLCollection { - return jsObject.getElementsByTagName!(qualifiedName.jsValue()).fromJSValue()! + @inlinable public func getElementsByTagName(qualifiedName: String) -> HTMLCollection { + let this = jsObject + return this[Strings.getElementsByTagName].function!(this: this, arguments: [qualifiedName.jsValue]).fromJSValue()! + } + + @inlinable public func getElementsByTagNameNS(namespace: String?, localName: String) -> HTMLCollection { + let this = jsObject + return this[Strings.getElementsByTagNameNS].function!(this: this, arguments: [namespace.jsValue, localName.jsValue]).fromJSValue()! + } + + @inlinable public func getElementsByClassName(classNames: String) -> HTMLCollection { + let this = jsObject + return this[Strings.getElementsByClassName].function!(this: this, arguments: [classNames.jsValue]).fromJSValue()! + } + + @inlinable public func createElement(localName: String, options: ElementCreationOptions_or_String? = nil) -> Element { + let this = jsObject + return this[Strings.createElement].function!(this: this, arguments: [localName.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func createElementNS(namespace: String?, qualifiedName: String, options: ElementCreationOptions_or_String? = nil) -> Element { + let this = jsObject + return this[Strings.createElementNS].function!(this: this, arguments: [namespace.jsValue, qualifiedName.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func createDocumentFragment() -> DocumentFragment { + let this = jsObject + return this[Strings.createDocumentFragment].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func createTextNode(data: String) -> Text { + let this = jsObject + return this[Strings.createTextNode].function!(this: this, arguments: [data.jsValue]).fromJSValue()! + } + + @inlinable public func createCDATASection(data: String) -> CDATASection { + let this = jsObject + return this[Strings.createCDATASection].function!(this: this, arguments: [data.jsValue]).fromJSValue()! + } + + @inlinable public func createComment(data: String) -> Comment { + let this = jsObject + return this[Strings.createComment].function!(this: this, arguments: [data.jsValue]).fromJSValue()! + } + + @inlinable public func createProcessingInstruction(target: String, data: String) -> ProcessingInstruction { + let this = jsObject + return this[Strings.createProcessingInstruction].function!(this: this, arguments: [target.jsValue, data.jsValue]).fromJSValue()! + } + + @inlinable public func importNode(node: Node, deep: Bool? = nil) -> Node { + let this = jsObject + return this[Strings.importNode].function!(this: this, arguments: [node.jsValue, deep?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func adoptNode(node: Node) -> Node { + let this = jsObject + return this[Strings.adoptNode].function!(this: this, arguments: [node.jsValue]).fromJSValue()! + } + + @inlinable public func createAttribute(localName: String) -> Attr { + let this = jsObject + return this[Strings.createAttribute].function!(this: this, arguments: [localName.jsValue]).fromJSValue()! } - public func getElementsByTagNameNS(namespace: String?, localName: String) -> HTMLCollection { - return jsObject.getElementsByTagNameNS!(namespace.jsValue(), localName.jsValue()).fromJSValue()! + @inlinable public func createAttributeNS(namespace: String?, qualifiedName: String) -> Attr { + let this = jsObject + return this[Strings.createAttributeNS].function!(this: this, arguments: [namespace.jsValue, qualifiedName.jsValue]).fromJSValue()! } - public func getElementsByClassName(classNames: String) -> HTMLCollection { - return jsObject.getElementsByClassName!(classNames.jsValue()).fromJSValue()! + @inlinable public func createEvent(interface: String) -> Event { + let this = jsObject + return this[Strings.createEvent].function!(this: this, arguments: [interface.jsValue]).fromJSValue()! } - public func createElement(localName: String, options: StringOrElementCreationOptions = [:]) -> Element { - return jsObject.createElement!(localName.jsValue(), options.jsValue()).fromJSValue()! + @inlinable public func createRange() -> Range { + let this = jsObject + return this[Strings.createRange].function!(this: this, arguments: []).fromJSValue()! + } + + // XXX: member 'createNodeIterator' is ignored + + // XXX: member 'createTreeWalker' is ignored + + @ReadonlyAttribute + public var location: Location? + + @ReadWriteAttribute + public var domain: String + + @ReadonlyAttribute + public var referrer: String + + @ReadWriteAttribute + public var cookie: String + + @ReadonlyAttribute + public var lastModified: String + + @ReadonlyAttribute + public var readyState: DocumentReadyState + + @inlinable public subscript(key: String) -> JSObject { + jsObject[key].fromJSValue()! } - public func createElementNS(namespace: String?, qualifiedName: String, options: StringOrElementCreationOptions = [:]) -> Element { - return jsObject.createElementNS!(namespace.jsValue(), qualifiedName.jsValue(), options.jsValue()).fromJSValue()! + @ReadWriteAttribute + public var title: String + + @ReadWriteAttribute + public var dir: String + + @ReadWriteAttribute + public var body: HTMLElement? + + @ReadonlyAttribute + public var head: HTMLHeadElement? + + @ReadonlyAttribute + public var images: HTMLCollection + + @ReadonlyAttribute + public var embeds: HTMLCollection + + @ReadonlyAttribute + public var plugins: HTMLCollection + + @ReadonlyAttribute + public var links: HTMLCollection + + @ReadonlyAttribute + public var forms: HTMLCollection + + @ReadonlyAttribute + public var scripts: HTMLCollection + + @inlinable public func getElementsByName(elementName: String) -> NodeList { + let this = jsObject + return this[Strings.getElementsByName].function!(this: this, arguments: [elementName.jsValue]).fromJSValue()! } - public func createDocumentFragment() -> DocumentFragment { - return jsObject.createDocumentFragment!().fromJSValue()! + @ReadonlyAttribute + public var currentScript: HTMLOrSVGScriptElement? + + @inlinable public func open(unused1: String? = nil, unused2: String? = nil) -> Self { + let this = jsObject + return this[Strings.open].function!(this: this, arguments: [unused1?.jsValue ?? .undefined, unused2?.jsValue ?? .undefined]).fromJSValue()! } - public func createTextNode(data: String) -> Text { - return jsObject.createTextNode!(data.jsValue()).fromJSValue()! + @inlinable public func open(url: String, name: String, features: String) -> WindowProxy? { + let this = jsObject + return this[Strings.open].function!(this: this, arguments: [url.jsValue, name.jsValue, features.jsValue]).fromJSValue()! } - public func createCDATASection(data: String) -> CDATASection { - return jsObject.createCDATASection!(data.jsValue()).fromJSValue()! + @inlinable public func close() { + let this = jsObject + _ = this[Strings.close].function!(this: this, arguments: []) } - public func createComment(data: String) -> Comment { - return jsObject.createComment!(data.jsValue()).fromJSValue()! + @inlinable public func write(text: String...) { + let this = jsObject + _ = this[Strings.write].function!(this: this, arguments: text.map(\.jsValue)) } - public func createProcessingInstruction(target: String, data: String) -> ProcessingInstruction { - return jsObject.createProcessingInstruction!(target.jsValue(), data.jsValue()).fromJSValue()! + @inlinable public func writeln(text: String...) { + let this = jsObject + _ = this[Strings.writeln].function!(this: this, arguments: text.map(\.jsValue)) } - public func importNode(node: Node, deep: Bool = false) -> Node { - return jsObject.importNode!(node.jsValue(), deep.jsValue()).fromJSValue()! + @ReadonlyAttribute + public var defaultView: WindowProxy? + + @inlinable public func hasFocus() -> Bool { + let this = jsObject + return this[Strings.hasFocus].function!(this: this, arguments: []).fromJSValue()! } - public func adoptNode(node: Node) -> Node { - return jsObject.adoptNode!(node.jsValue()).fromJSValue()! + @ReadWriteAttribute + public var designMode: String + + @inlinable public func execCommand(commandId: String, showUI: Bool? = nil, value: String? = nil) -> Bool { + let this = jsObject + return this[Strings.execCommand].function!(this: this, arguments: [commandId.jsValue, showUI?.jsValue ?? .undefined, value?.jsValue ?? .undefined]).fromJSValue()! } - public func createAttribute(localName: String) -> Attr { - return jsObject.createAttribute!(localName.jsValue()).fromJSValue()! + @inlinable public func queryCommandEnabled(commandId: String) -> Bool { + let this = jsObject + return this[Strings.queryCommandEnabled].function!(this: this, arguments: [commandId.jsValue]).fromJSValue()! } - public func createAttributeNS(namespace: String?, qualifiedName: String) -> Attr { - return jsObject.createAttributeNS!(namespace.jsValue(), qualifiedName.jsValue()).fromJSValue()! + @inlinable public func queryCommandIndeterm(commandId: String) -> Bool { + let this = jsObject + return this[Strings.queryCommandIndeterm].function!(this: this, arguments: [commandId.jsValue]).fromJSValue()! } - public func createEvent(interface: String) -> Event { - return jsObject.createEvent!(interface.jsValue()).fromJSValue()! + @inlinable public func queryCommandState(commandId: String) -> Bool { + let this = jsObject + return this[Strings.queryCommandState].function!(this: this, arguments: [commandId.jsValue]).fromJSValue()! } - public func createRange() -> Range { - return jsObject.createRange!().fromJSValue()! + @inlinable public func queryCommandSupported(commandId: String) -> Bool { + let this = jsObject + return this[Strings.queryCommandSupported].function!(this: this, arguments: [commandId.jsValue]).fromJSValue()! } - public func createNodeIterator(root: Node, whatToShow: UInt32 = 4_294_967_295, filter: NodeFilterType? = nil) -> NodeIterator { - return jsObject.createNodeIterator!(root.jsValue(), whatToShow.jsValue(), filter.jsValue()).fromJSValue()! + @inlinable public func queryCommandValue(commandId: String) -> String { + let this = jsObject + return this[Strings.queryCommandValue].function!(this: this, arguments: [commandId.jsValue]).fromJSValue()! } - public func createNodeIterator(root: Node, whatToShow: UInt32 = 4_294_967_295, filter: ((Node) -> UInt16)? = nil) -> NodeIterator { - return jsObject.createNodeIterator!(root.jsValue(), whatToShow.jsValue(), filter == nil ? nil : JSClosure { filter!($0[0].fromJSValue()!).jsValue() }).fromJSValue()! + @ReadonlyAttribute + public var hidden: Bool + + @ReadonlyAttribute + public var visibilityState: DocumentVisibilityState + + @ClosureAttribute1Optional + public var onreadystatechange: EventHandler + + @ClosureAttribute1Optional + public var onvisibilitychange: EventHandler + + @ReadWriteAttribute + public var fgColor: String + + @ReadWriteAttribute + public var linkColor: String + + @ReadWriteAttribute + public var vlinkColor: String + + @ReadWriteAttribute + public var alinkColor: String + + @ReadWriteAttribute + public var bgColor: String + + @ReadonlyAttribute + public var anchors: HTMLCollection + + @ReadonlyAttribute + public var applets: HTMLCollection + + @inlinable public func clear() { + let this = jsObject + _ = this[Strings.clear].function!(this: this, arguments: []) } - public func createTreeWalker(root: Node, whatToShow: UInt32 = 4_294_967_295, filter: NodeFilterType? = nil) -> TreeWalker { - return jsObject.createTreeWalker!(root.jsValue(), whatToShow.jsValue(), filter.jsValue()).fromJSValue()! + @inlinable public func captureEvents() { + let this = jsObject + _ = this[Strings.captureEvents].function!(this: this, arguments: []) } - public func createTreeWalker(root: Node, whatToShow: UInt32 = 4_294_967_295, filter: ((Node) -> UInt16)? = nil) -> TreeWalker { - return jsObject.createTreeWalker!(root.jsValue(), whatToShow.jsValue(), filter == nil ? nil : JSClosure { filter!($0[0].fromJSValue()!).jsValue() }).fromJSValue()! + @inlinable public func releaseEvents() { + let this = jsObject + _ = this[Strings.releaseEvents].function!(this: this, arguments: []) } + + @ReadonlyAttribute + public var all: HTMLAllCollection + + @ReadonlyAttribute + public var timeline: DocumentTimeline } diff --git a/Sources/DOMKit/WebIDL/DocumentAndElementEventHandlers.swift b/Sources/DOMKit/WebIDL/DocumentAndElementEventHandlers.swift index 93e4f09b..c9e9b57e 100644 --- a/Sources/DOMKit/WebIDL/DocumentAndElementEventHandlers.swift +++ b/Sources/DOMKit/WebIDL/DocumentAndElementEventHandlers.swift @@ -1,64 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public protocol DocumentAndElementEventHandlers: JSBridgedClass {} - public extension DocumentAndElementEventHandlers { - var oncopy: EventHandler { - get { - guard let function = jsObject.oncopy.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.oncopy = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.oncopy = .null - } - } + @inlinable var oncopy: EventHandler { + get { ClosureAttribute1Optional[Strings.oncopy, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.oncopy, in: jsObject] = newValue } } - var oncut: EventHandler { - get { - guard let function = jsObject.oncut.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.oncut = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.oncut = .null - } - } + @inlinable var oncut: EventHandler { + get { ClosureAttribute1Optional[Strings.oncut, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.oncut, in: jsObject] = newValue } } - var onpaste: EventHandler { - get { - guard let function = jsObject.onpaste.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onpaste = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onpaste = .null - } - } + @inlinable var onpaste: EventHandler { + get { ClosureAttribute1Optional[Strings.onpaste, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onpaste, in: jsObject] = newValue } } } diff --git a/Sources/DOMKit/WebIDL/DocumentFragment.swift b/Sources/DOMKit/WebIDL/DocumentFragment.swift index a239bd96..f8155865 100644 --- a/Sources/DOMKit/WebIDL/DocumentFragment.swift +++ b/Sources/DOMKit/WebIDL/DocumentFragment.swift @@ -1,18 +1,16 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class DocumentFragment: Node, NonElementParentNode, ParentNode { - override public class var constructor: JSFunction { JSObject.global.DocumentFragment.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.DocumentFragment].function! } public required init(unsafelyWrapping jsObject: JSObject) { super.init(unsafelyWrapping: jsObject) } - public convenience init() { - self.init(unsafelyWrapping: DocumentFragment.constructor.new()) + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) } } diff --git a/Sources/DOMKit/WebIDL/DocumentOrShadowRoot.swift b/Sources/DOMKit/WebIDL/DocumentOrShadowRoot.swift index e74bc690..2eaba575 100644 --- a/Sources/DOMKit/WebIDL/DocumentOrShadowRoot.swift +++ b/Sources/DOMKit/WebIDL/DocumentOrShadowRoot.swift @@ -1,8 +1,14 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public protocol DocumentOrShadowRoot: JSBridgedClass {} +public extension DocumentOrShadowRoot { + @inlinable var activeElement: Element? { ReadonlyAttribute[Strings.activeElement, in: jsObject] } + + @inlinable func getAnimations() -> [Animation] { + let this = jsObject + return this[Strings.getAnimations].function!(this: this, arguments: []).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/DocumentReadyState.swift b/Sources/DOMKit/WebIDL/DocumentReadyState.swift new file mode 100644 index 00000000..ae8f31c1 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DocumentReadyState.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum DocumentReadyState: JSString, JSValueCompatible { + case loading = "loading" + case interactive = "interactive" + case complete = "complete" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/DocumentTimeline.swift b/Sources/DOMKit/WebIDL/DocumentTimeline.swift new file mode 100644 index 00000000..e12a8aa8 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DocumentTimeline.swift @@ -0,0 +1,16 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DocumentTimeline: AnimationTimeline { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.DocumentTimeline].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(options: DocumentTimelineOptions? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [options?.jsValue ?? .undefined])) + } +} diff --git a/Sources/DOMKit/WebIDL/DocumentTimelineOptions.swift b/Sources/DOMKit/WebIDL/DocumentTimelineOptions.swift new file mode 100644 index 00000000..e45f94da --- /dev/null +++ b/Sources/DOMKit/WebIDL/DocumentTimelineOptions.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DocumentTimelineOptions: BridgedDictionary { + public convenience init(originTime: DOMHighResTimeStamp) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.originTime] = originTime.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _originTime = ReadWriteAttribute(jsObject: object, name: Strings.originTime) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var originTime: DOMHighResTimeStamp +} diff --git a/Sources/DOMKit/WebIDL/DocumentType.swift b/Sources/DOMKit/WebIDL/DocumentType.swift index 2ae6a5da..c8969178 100644 --- a/Sources/DOMKit/WebIDL/DocumentType.swift +++ b/Sources/DOMKit/WebIDL/DocumentType.swift @@ -1,17 +1,15 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class DocumentType: Node, ChildNode { - override public class var constructor: JSFunction { JSObject.global.DocumentType.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.DocumentType].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _name = ReadonlyAttribute(jsObject: jsObject, name: "name") - _publicId = ReadonlyAttribute(jsObject: jsObject, name: "publicId") - _systemId = ReadonlyAttribute(jsObject: jsObject, name: "systemId") + _name = ReadonlyAttribute(jsObject: jsObject, name: Strings.name) + _publicId = ReadonlyAttribute(jsObject: jsObject, name: Strings.publicId) + _systemId = ReadonlyAttribute(jsObject: jsObject, name: Strings.systemId) super.init(unsafelyWrapping: jsObject) } diff --git a/Sources/DOMKit/WebIDL/DocumentVisibilityState.swift b/Sources/DOMKit/WebIDL/DocumentVisibilityState.swift new file mode 100644 index 00000000..a9d2497f --- /dev/null +++ b/Sources/DOMKit/WebIDL/DocumentVisibilityState.swift @@ -0,0 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum DocumentVisibilityState: JSString, JSValueCompatible { + case visible = "visible" + case hidden = "hidden" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/Document_or_XMLHttpRequestBodyInit.swift b/Sources/DOMKit/WebIDL/Document_or_XMLHttpRequestBodyInit.swift new file mode 100644 index 00000000..73264860 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Document_or_XMLHttpRequestBodyInit.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_Document_or_XMLHttpRequestBodyInit: ConvertibleToJSValue {} +extension Document: Any_Document_or_XMLHttpRequestBodyInit {} +extension XMLHttpRequestBodyInit: Any_Document_or_XMLHttpRequestBodyInit {} + +public enum Document_or_XMLHttpRequestBodyInit: JSValueCompatible, Any_Document_or_XMLHttpRequestBodyInit { + case document(Document) + case xmlHttpRequestBodyInit(XMLHttpRequestBodyInit) + + var document: Document? { + switch self { + case let .document(document): return document + default: return nil + } + } + + var xmlHttpRequestBodyInit: XMLHttpRequestBodyInit? { + switch self { + case let .xmlHttpRequestBodyInit(xmlHttpRequestBodyInit): return xmlHttpRequestBodyInit + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let document: Document = value.fromJSValue() { + return .document(document) + } + if let xmlHttpRequestBodyInit: XMLHttpRequestBodyInit = value.fromJSValue() { + return .xmlHttpRequestBodyInit(xmlHttpRequestBodyInit) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .document(document): + return document.jsValue + case let .xmlHttpRequestBodyInit(xmlHttpRequestBodyInit): + return xmlHttpRequestBodyInit.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/Double_or_KeyframeAnimationOptions.swift b/Sources/DOMKit/WebIDL/Double_or_KeyframeAnimationOptions.swift new file mode 100644 index 00000000..41f4906b --- /dev/null +++ b/Sources/DOMKit/WebIDL/Double_or_KeyframeAnimationOptions.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_Double_or_KeyframeAnimationOptions: ConvertibleToJSValue {} +extension Double: Any_Double_or_KeyframeAnimationOptions {} +extension KeyframeAnimationOptions: Any_Double_or_KeyframeAnimationOptions {} + +public enum Double_or_KeyframeAnimationOptions: JSValueCompatible, Any_Double_or_KeyframeAnimationOptions { + case double(Double) + case keyframeAnimationOptions(KeyframeAnimationOptions) + + var double: Double? { + switch self { + case let .double(double): return double + default: return nil + } + } + + var keyframeAnimationOptions: KeyframeAnimationOptions? { + switch self { + case let .keyframeAnimationOptions(keyframeAnimationOptions): return keyframeAnimationOptions + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let double: Double = value.fromJSValue() { + return .double(double) + } + if let keyframeAnimationOptions: KeyframeAnimationOptions = value.fromJSValue() { + return .keyframeAnimationOptions(keyframeAnimationOptions) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .double(double): + return double.jsValue + case let .keyframeAnimationOptions(keyframeAnimationOptions): + return keyframeAnimationOptions.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/Double_or_KeyframeEffectOptions.swift b/Sources/DOMKit/WebIDL/Double_or_KeyframeEffectOptions.swift new file mode 100644 index 00000000..67a79f8d --- /dev/null +++ b/Sources/DOMKit/WebIDL/Double_or_KeyframeEffectOptions.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_Double_or_KeyframeEffectOptions: ConvertibleToJSValue {} +extension Double: Any_Double_or_KeyframeEffectOptions {} +extension KeyframeEffectOptions: Any_Double_or_KeyframeEffectOptions {} + +public enum Double_or_KeyframeEffectOptions: JSValueCompatible, Any_Double_or_KeyframeEffectOptions { + case double(Double) + case keyframeEffectOptions(KeyframeEffectOptions) + + var double: Double? { + switch self { + case let .double(double): return double + default: return nil + } + } + + var keyframeEffectOptions: KeyframeEffectOptions? { + switch self { + case let .keyframeEffectOptions(keyframeEffectOptions): return keyframeEffectOptions + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let double: Double = value.fromJSValue() { + return .double(double) + } + if let keyframeEffectOptions: KeyframeEffectOptions = value.fromJSValue() { + return .keyframeEffectOptions(keyframeEffectOptions) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .double(double): + return double.jsValue + case let .keyframeEffectOptions(keyframeEffectOptions): + return keyframeEffectOptions.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/Double_or_String.swift b/Sources/DOMKit/WebIDL/Double_or_String.swift new file mode 100644 index 00000000..b74a49c8 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Double_or_String.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_Double_or_String: ConvertibleToJSValue {} +extension Double: Any_Double_or_String {} +extension String: Any_Double_or_String {} + +public enum Double_or_String: JSValueCompatible, Any_Double_or_String { + case double(Double) + case string(String) + + var double: Double? { + switch self { + case let .double(double): return double + default: return nil + } + } + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let double: Double = value.fromJSValue() { + return .double(double) + } + if let string: String = value.fromJSValue() { + return .string(string) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .double(double): + return double.jsValue + case let .string(string): + return string.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/DragEvent.swift b/Sources/DOMKit/WebIDL/DragEvent.swift new file mode 100644 index 00000000..feeb3434 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DragEvent.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DragEvent: MouseEvent { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.DragEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _dataTransfer = ReadonlyAttribute(jsObject: jsObject, name: Strings.dataTransfer) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: DragEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var dataTransfer: DataTransfer? +} diff --git a/Sources/DOMKit/WebIDL/DragEventInit.swift b/Sources/DOMKit/WebIDL/DragEventInit.swift new file mode 100644 index 00000000..e7afb2e3 --- /dev/null +++ b/Sources/DOMKit/WebIDL/DragEventInit.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class DragEventInit: BridgedDictionary { + public convenience init(dataTransfer: DataTransfer?) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.dataTransfer] = dataTransfer.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _dataTransfer = ReadWriteAttribute(jsObject: object, name: Strings.dataTransfer) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var dataTransfer: DataTransfer? +} diff --git a/Sources/DOMKit/WebIDL/EffectTiming.swift b/Sources/DOMKit/WebIDL/EffectTiming.swift new file mode 100644 index 00000000..af69722e --- /dev/null +++ b/Sources/DOMKit/WebIDL/EffectTiming.swift @@ -0,0 +1,50 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class EffectTiming: BridgedDictionary { + public convenience init(delay: Double, endDelay: Double, fill: FillMode, iterationStart: Double, iterations: Double, direction: PlaybackDirection, easing: String) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.delay] = delay.jsValue + object[Strings.endDelay] = endDelay.jsValue + object[Strings.fill] = fill.jsValue + object[Strings.iterationStart] = iterationStart.jsValue + object[Strings.iterations] = iterations.jsValue + object[Strings.direction] = direction.jsValue + object[Strings.easing] = easing.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _delay = ReadWriteAttribute(jsObject: object, name: Strings.delay) + _endDelay = ReadWriteAttribute(jsObject: object, name: Strings.endDelay) + _fill = ReadWriteAttribute(jsObject: object, name: Strings.fill) + _iterationStart = ReadWriteAttribute(jsObject: object, name: Strings.iterationStart) + _iterations = ReadWriteAttribute(jsObject: object, name: Strings.iterations) + _direction = ReadWriteAttribute(jsObject: object, name: Strings.direction) + _easing = ReadWriteAttribute(jsObject: object, name: Strings.easing) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var delay: Double + + @ReadWriteAttribute + public var endDelay: Double + + @ReadWriteAttribute + public var fill: FillMode + + @ReadWriteAttribute + public var iterationStart: Double + + @ReadWriteAttribute + public var iterations: Double + + @ReadWriteAttribute + public var direction: PlaybackDirection + + @ReadWriteAttribute + public var easing: String +} diff --git a/Sources/DOMKit/WebIDL/Element.swift b/Sources/DOMKit/WebIDL/Element.swift index 5374059d..6e400022 100644 --- a/Sources/DOMKit/WebIDL/Element.swift +++ b/Sources/DOMKit/WebIDL/Element.swift @@ -1,24 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public class Element: Node, ChildNode, NonDocumentTypeChildNode, ParentNode, Slotable { - override public class var constructor: JSFunction { JSObject.global.Element.function! } +public class Element: Node, ParentNode, NonDocumentTypeChildNode, ChildNode, Slottable, ARIAMixin, Animatable { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.Element].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _namespaceURI = ReadonlyAttribute(jsObject: jsObject, name: "namespaceURI") - _prefix = ReadonlyAttribute(jsObject: jsObject, name: "prefix") - _localName = ReadonlyAttribute(jsObject: jsObject, name: "localName") - _tagName = ReadonlyAttribute(jsObject: jsObject, name: "tagName") - _id = ReadWriteAttribute(jsObject: jsObject, name: "id") - _className = ReadWriteAttribute(jsObject: jsObject, name: "className") - _classList = ReadonlyAttribute(jsObject: jsObject, name: "classList") - _slot = ReadWriteAttribute(jsObject: jsObject, name: "slot") - _attributes = ReadonlyAttribute(jsObject: jsObject, name: "attributes") - _shadowRoot = ReadonlyAttribute(jsObject: jsObject, name: "shadowRoot") + _namespaceURI = ReadonlyAttribute(jsObject: jsObject, name: Strings.namespaceURI) + _prefix = ReadonlyAttribute(jsObject: jsObject, name: Strings.prefix) + _localName = ReadonlyAttribute(jsObject: jsObject, name: Strings.localName) + _tagName = ReadonlyAttribute(jsObject: jsObject, name: Strings.tagName) + _id = ReadWriteAttribute(jsObject: jsObject, name: Strings.id) + _className = ReadWriteAttribute(jsObject: jsObject, name: Strings.className) + _classList = ReadonlyAttribute(jsObject: jsObject, name: Strings.classList) + _slot = ReadWriteAttribute(jsObject: jsObject, name: Strings.slot) + _attributes = ReadonlyAttribute(jsObject: jsObject, name: Strings.attributes) + _shadowRoot = ReadonlyAttribute(jsObject: jsObject, name: Strings.shadowRoot) super.init(unsafelyWrapping: jsObject) } @@ -46,113 +44,134 @@ public class Element: Node, ChildNode, NonDocumentTypeChildNode, ParentNode, Slo @ReadWriteAttribute public var slot: String - public func hasAttributes() -> Bool { - return jsObject.hasAttributes!().fromJSValue()! + @inlinable public func hasAttributes() -> Bool { + let this = jsObject + return this[Strings.hasAttributes].function!(this: this, arguments: []).fromJSValue()! } @ReadonlyAttribute public var attributes: NamedNodeMap - public func getAttributeNames() -> [String] { - return jsObject.getAttributeNames!().fromJSValue()! - } - - public func getAttribute(qualifiedName: String) -> String? { - return jsObject.getAttribute!(qualifiedName.jsValue()).fromJSValue()! + @inlinable public func getAttributeNames() -> [String] { + let this = jsObject + return this[Strings.getAttributeNames].function!(this: this, arguments: []).fromJSValue()! } - public func getAttributeNS(namespace: String?, localName: String) -> String? { - return jsObject.getAttributeNS!(namespace.jsValue(), localName.jsValue()).fromJSValue()! + @inlinable public func getAttribute(qualifiedName: String) -> String? { + let this = jsObject + return this[Strings.getAttribute].function!(this: this, arguments: [qualifiedName.jsValue]).fromJSValue()! } - public func setAttribute(qualifiedName: String, value: String) { - _ = jsObject.setAttribute!(qualifiedName.jsValue(), value.jsValue()) + @inlinable public func getAttributeNS(namespace: String?, localName: String) -> String? { + let this = jsObject + return this[Strings.getAttributeNS].function!(this: this, arguments: [namespace.jsValue, localName.jsValue]).fromJSValue()! } - public func setAttributeNS(namespace: String?, qualifiedName: String, value: String) { - _ = jsObject.setAttributeNS!(namespace.jsValue(), qualifiedName.jsValue(), value.jsValue()) + @inlinable public func setAttribute(qualifiedName: String, value: String) { + let this = jsObject + _ = this[Strings.setAttribute].function!(this: this, arguments: [qualifiedName.jsValue, value.jsValue]) } - public func removeAttribute(qualifiedName: String) { - _ = jsObject.removeAttribute!(qualifiedName.jsValue()) + @inlinable public func setAttributeNS(namespace: String?, qualifiedName: String, value: String) { + let this = jsObject + _ = this[Strings.setAttributeNS].function!(this: this, arguments: [namespace.jsValue, qualifiedName.jsValue, value.jsValue]) } - public func removeAttributeNS(namespace: String?, localName: String) { - _ = jsObject.removeAttributeNS!(namespace.jsValue(), localName.jsValue()) + @inlinable public func removeAttribute(qualifiedName: String) { + let this = jsObject + _ = this[Strings.removeAttribute].function!(this: this, arguments: [qualifiedName.jsValue]) } - public func toggleAttribute(qualifiedName: String, force: Bool) -> Bool { - return jsObject.toggleAttribute!(qualifiedName.jsValue(), force.jsValue()).fromJSValue()! + @inlinable public func removeAttributeNS(namespace: String?, localName: String) { + let this = jsObject + _ = this[Strings.removeAttributeNS].function!(this: this, arguments: [namespace.jsValue, localName.jsValue]) } - public func toggleAttribute(qualifiedName: String) -> Bool { - return jsObject.toggleAttribute!(qualifiedName.jsValue()).fromJSValue()! + @inlinable public func toggleAttribute(qualifiedName: String, force: Bool? = nil) -> Bool { + let this = jsObject + return this[Strings.toggleAttribute].function!(this: this, arguments: [qualifiedName.jsValue, force?.jsValue ?? .undefined]).fromJSValue()! } - public func hasAttribute(qualifiedName: String) -> Bool { - return jsObject.hasAttribute!(qualifiedName.jsValue()).fromJSValue()! + @inlinable public func hasAttribute(qualifiedName: String) -> Bool { + let this = jsObject + return this[Strings.hasAttribute].function!(this: this, arguments: [qualifiedName.jsValue]).fromJSValue()! } - public func hasAttributeNS(namespace: String?, localName: String) -> Bool { - return jsObject.hasAttributeNS!(namespace.jsValue(), localName.jsValue()).fromJSValue()! + @inlinable public func hasAttributeNS(namespace: String?, localName: String) -> Bool { + let this = jsObject + return this[Strings.hasAttributeNS].function!(this: this, arguments: [namespace.jsValue, localName.jsValue]).fromJSValue()! } - public func getAttributeNode(qualifiedName: String) -> Attr? { - return jsObject.getAttributeNode!(qualifiedName.jsValue()).fromJSValue()! + @inlinable public func getAttributeNode(qualifiedName: String) -> Attr? { + let this = jsObject + return this[Strings.getAttributeNode].function!(this: this, arguments: [qualifiedName.jsValue]).fromJSValue()! } - public func getAttributeNodeNS(namespace: String?, localName: String) -> Attr? { - return jsObject.getAttributeNodeNS!(namespace.jsValue(), localName.jsValue()).fromJSValue()! + @inlinable public func getAttributeNodeNS(namespace: String?, localName: String) -> Attr? { + let this = jsObject + return this[Strings.getAttributeNodeNS].function!(this: this, arguments: [namespace.jsValue, localName.jsValue]).fromJSValue()! } - public func setAttributeNode(attr: Attr) -> Attr? { - return jsObject.setAttributeNode!(attr.jsValue()).fromJSValue()! + @inlinable public func setAttributeNode(attr: Attr) -> Attr? { + let this = jsObject + return this[Strings.setAttributeNode].function!(this: this, arguments: [attr.jsValue]).fromJSValue()! } - public func setAttributeNodeNS(attr: Attr) -> Attr? { - return jsObject.setAttributeNodeNS!(attr.jsValue()).fromJSValue()! + @inlinable public func setAttributeNodeNS(attr: Attr) -> Attr? { + let this = jsObject + return this[Strings.setAttributeNodeNS].function!(this: this, arguments: [attr.jsValue]).fromJSValue()! } - public func removeAttributeNode(attr: Attr) -> Attr { - return jsObject.removeAttributeNode!(attr.jsValue()).fromJSValue()! + @inlinable public func removeAttributeNode(attr: Attr) -> Attr { + let this = jsObject + return this[Strings.removeAttributeNode].function!(this: this, arguments: [attr.jsValue]).fromJSValue()! } - public func attachShadow(init: ShadowRootInit) -> ShadowRoot { - return jsObject.attachShadow!(`init`.jsValue()).fromJSValue()! + @inlinable public func attachShadow(init: ShadowRootInit) -> ShadowRoot { + let this = jsObject + return this[Strings.attachShadow].function!(this: this, arguments: [`init`.jsValue]).fromJSValue()! } @ReadonlyAttribute public var shadowRoot: ShadowRoot? - public func closest(selectors: String) -> Element? { - return jsObject.closest!(selectors.jsValue()).fromJSValue()! + @inlinable public func closest(selectors: String) -> Element? { + let this = jsObject + return this[Strings.closest].function!(this: this, arguments: [selectors.jsValue]).fromJSValue()! } - public func matches(selectors: String) -> Bool { - return jsObject.matches!(selectors.jsValue()).fromJSValue()! + @inlinable public func matches(selectors: String) -> Bool { + let this = jsObject + return this[Strings.matches].function!(this: this, arguments: [selectors.jsValue]).fromJSValue()! } - public func webkitMatchesSelector(selectors: String) -> Bool { - return jsObject.webkitMatchesSelector!(selectors.jsValue()).fromJSValue()! + @inlinable public func webkitMatchesSelector(selectors: String) -> Bool { + let this = jsObject + return this[Strings.webkitMatchesSelector].function!(this: this, arguments: [selectors.jsValue]).fromJSValue()! } - public func getElementsByTagName(qualifiedName: String) -> HTMLCollection { - return jsObject.getElementsByTagName!(qualifiedName.jsValue()).fromJSValue()! + @inlinable public func getElementsByTagName(qualifiedName: String) -> HTMLCollection { + let this = jsObject + return this[Strings.getElementsByTagName].function!(this: this, arguments: [qualifiedName.jsValue]).fromJSValue()! } - public func getElementsByTagNameNS(namespace: String?, localName: String) -> HTMLCollection { - return jsObject.getElementsByTagNameNS!(namespace.jsValue(), localName.jsValue()).fromJSValue()! + @inlinable public func getElementsByTagNameNS(namespace: String?, localName: String) -> HTMLCollection { + let this = jsObject + return this[Strings.getElementsByTagNameNS].function!(this: this, arguments: [namespace.jsValue, localName.jsValue]).fromJSValue()! } - public func getElementsByClassName(classNames: String) -> HTMLCollection { - return jsObject.getElementsByClassName!(classNames.jsValue()).fromJSValue()! + @inlinable public func getElementsByClassName(classNames: String) -> HTMLCollection { + let this = jsObject + return this[Strings.getElementsByClassName].function!(this: this, arguments: [classNames.jsValue]).fromJSValue()! } - public func insertAdjacentElement(where: String, element: Element) -> Element? { - return jsObject.insertAdjacentElement!(`where`.jsValue(), element.jsValue()).fromJSValue()! + @inlinable public func insertAdjacentElement(where: String, element: Element) -> Element? { + let this = jsObject + return this[Strings.insertAdjacentElement].function!(this: this, arguments: [`where`.jsValue, element.jsValue]).fromJSValue()! } - public func insertAdjacentText(where: String, data: String) { - _ = jsObject.insertAdjacentText!(`where`.jsValue(), data.jsValue()) + @inlinable public func insertAdjacentText(where: String, data: String) { + let this = jsObject + _ = this[Strings.insertAdjacentText].function!(this: this, arguments: [`where`.jsValue, data.jsValue]) } } diff --git a/Sources/DOMKit/WebIDL/ElementContentEditable.swift b/Sources/DOMKit/WebIDL/ElementContentEditable.swift index afdf3b4c..8687472c 100644 --- a/Sources/DOMKit/WebIDL/ElementContentEditable.swift +++ b/Sources/DOMKit/WebIDL/ElementContentEditable.swift @@ -1,41 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public protocol ElementContentEditable: JSBridgedClass {} - public extension ElementContentEditable { - var contentEditable: String { - get { - return jsObject.contentEditable.fromJSValue()! - } - set { - jsObject.contentEditable = newValue.jsValue() - } + @inlinable var contentEditable: String { + get { ReadWriteAttribute[Strings.contentEditable, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.contentEditable, in: jsObject] = newValue } } - var enterKeyHint: String { - get { - return jsObject.enterKeyHint.fromJSValue()! - } - set { - jsObject.enterKeyHint = newValue.jsValue() - } + @inlinable var enterKeyHint: String { + get { ReadWriteAttribute[Strings.enterKeyHint, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.enterKeyHint, in: jsObject] = newValue } } - var isContentEditable: Bool { - return jsObject.isContentEditable.fromJSValue()! - } + @inlinable var isContentEditable: Bool { ReadonlyAttribute[Strings.isContentEditable, in: jsObject] } - var inputMode: String { - get { - return jsObject.inputMode.fromJSValue()! - } - set { - jsObject.inputMode = newValue.jsValue() - } + @inlinable var inputMode: String { + get { ReadWriteAttribute[Strings.inputMode, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.inputMode, in: jsObject] = newValue } } } diff --git a/Sources/DOMKit/WebIDL/ElementCreationOptions.swift b/Sources/DOMKit/WebIDL/ElementCreationOptions.swift index 0a2b9c15..0ef2f4b9 100644 --- a/Sources/DOMKit/WebIDL/ElementCreationOptions.swift +++ b/Sources/DOMKit/WebIDL/ElementCreationOptions.swift @@ -1,39 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public struct ElementCreationOptions: ExpressibleByDictionaryLiteral, JSBridgedType { - public enum Key: String, Hashable { - case `is` - } - - private let dictionary: [String: JSValue] - - public init(uniqueKeysWithValues elements: [(Key, ConvertibleToJSValue)]) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } - - public init(dictionaryLiteral elements: (Key, ConvertibleToJSValue)...) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } - - subscript(_ key: Key) -> JSValue? { - dictionary[key.rawValue] +public class ElementCreationOptions: BridgedDictionary { + public convenience init(is: String) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.is] = `is`.jsValue + self.init(unsafelyWrapping: object) } - public init?(from value: JSValue) { - if let dictionary: [String: JSValue] = value.fromJSValue() { - self.dictionary = dictionary - } - return nil + public required init(unsafelyWrapping object: JSObject) { + _is = ReadWriteAttribute(jsObject: object, name: Strings.is) + super.init(unsafelyWrapping: object) } - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - return dictionary.jsValue() - } + @ReadWriteAttribute + public var `is`: String } diff --git a/Sources/DOMKit/WebIDL/ElementCreationOptions_or_String.swift b/Sources/DOMKit/WebIDL/ElementCreationOptions_or_String.swift new file mode 100644 index 00000000..72a7769f --- /dev/null +++ b/Sources/DOMKit/WebIDL/ElementCreationOptions_or_String.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_ElementCreationOptions_or_String: ConvertibleToJSValue {} +extension ElementCreationOptions: Any_ElementCreationOptions_or_String {} +extension String: Any_ElementCreationOptions_or_String {} + +public enum ElementCreationOptions_or_String: JSValueCompatible, Any_ElementCreationOptions_or_String { + case elementCreationOptions(ElementCreationOptions) + case string(String) + + var elementCreationOptions: ElementCreationOptions? { + switch self { + case let .elementCreationOptions(elementCreationOptions): return elementCreationOptions + default: return nil + } + } + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let elementCreationOptions: ElementCreationOptions = value.fromJSValue() { + return .elementCreationOptions(elementCreationOptions) + } + if let string: String = value.fromJSValue() { + return .string(string) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .elementCreationOptions(elementCreationOptions): + return elementCreationOptions.jsValue + case let .string(string): + return string.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/ElementDefinitionOptions.swift b/Sources/DOMKit/WebIDL/ElementDefinitionOptions.swift new file mode 100644 index 00000000..c6bb95d5 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ElementDefinitionOptions.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ElementDefinitionOptions: BridgedDictionary { + public convenience init(extends: String) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.extends] = extends.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _extends = ReadWriteAttribute(jsObject: object, name: Strings.extends) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var extends: String +} diff --git a/Sources/DOMKit/WebIDL/ElementInternals.swift b/Sources/DOMKit/WebIDL/ElementInternals.swift index ead9ef83..397bcc09 100644 --- a/Sources/DOMKit/WebIDL/ElementInternals.swift +++ b/Sources/DOMKit/WebIDL/ElementInternals.swift @@ -1,45 +1,37 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public class ElementInternals: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.ElementInternals.function! } +public class ElementInternals: JSBridgedClass, ARIAMixin { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.ElementInternals].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _form = ReadonlyAttribute(jsObject: jsObject, name: "form") - _willValidate = ReadonlyAttribute(jsObject: jsObject, name: "willValidate") - _validity = ReadonlyAttribute(jsObject: jsObject, name: "validity") - _validationMessage = ReadonlyAttribute(jsObject: jsObject, name: "validationMessage") - _labels = ReadonlyAttribute(jsObject: jsObject, name: "labels") + _shadowRoot = ReadonlyAttribute(jsObject: jsObject, name: Strings.shadowRoot) + _form = ReadonlyAttribute(jsObject: jsObject, name: Strings.form) + _willValidate = ReadonlyAttribute(jsObject: jsObject, name: Strings.willValidate) + _validity = ReadonlyAttribute(jsObject: jsObject, name: Strings.validity) + _validationMessage = ReadonlyAttribute(jsObject: jsObject, name: Strings.validationMessage) + _labels = ReadonlyAttribute(jsObject: jsObject, name: Strings.labels) self.jsObject = jsObject } - public func setFormValue(value: FileOrStringOrFormData?, state: FileOrStringOrFormData?) { - _ = jsObject.setFormValue!(value.jsValue(), state.jsValue()) - } + @ReadonlyAttribute + public var shadowRoot: ShadowRoot? - public func setFormValue(value: FileOrStringOrFormData?) { - _ = jsObject.setFormValue!(value.jsValue()) + @inlinable public func setFormValue(value: File_or_FormData_or_String?, state: File_or_FormData_or_String? = nil) { + let this = jsObject + _ = this[Strings.setFormValue].function!(this: this, arguments: [value.jsValue, state?.jsValue ?? .undefined]) } @ReadonlyAttribute public var form: HTMLFormElement? - public func setValidity(flags: ValidityStateFlags, message: String, anchor: HTMLElement) { - _ = jsObject.setValidity!(flags.jsValue(), message.jsValue(), anchor.jsValue()) - } - - public func setValidity(flags: ValidityStateFlags, message: String) { - _ = jsObject.setValidity!(flags.jsValue(), message.jsValue()) - } - - public func setValidity(flags: ValidityStateFlags) { - _ = jsObject.setValidity!(flags.jsValue()) + @inlinable public func setValidity(flags: ValidityStateFlags? = nil, message: String? = nil, anchor: HTMLElement? = nil) { + let this = jsObject + _ = this[Strings.setValidity].function!(this: this, arguments: [flags?.jsValue ?? .undefined, message?.jsValue ?? .undefined, anchor?.jsValue ?? .undefined]) } @ReadonlyAttribute @@ -51,12 +43,14 @@ public class ElementInternals: JSBridgedClass { @ReadonlyAttribute public var validationMessage: String - public func checkValidity() -> Bool { - return jsObject.checkValidity!().fromJSValue()! + @inlinable public func checkValidity() -> Bool { + let this = jsObject + return this[Strings.checkValidity].function!(this: this, arguments: []).fromJSValue()! } - public func reportValidity() -> Bool { - return jsObject.reportValidity!().fromJSValue()! + @inlinable public func reportValidity() -> Bool { + let this = jsObject + return this[Strings.reportValidity].function!(this: this, arguments: []).fromJSValue()! } @ReadonlyAttribute diff --git a/Sources/DOMKit/WebIDL/Element_or_HTMLCollection.swift b/Sources/DOMKit/WebIDL/Element_or_HTMLCollection.swift new file mode 100644 index 00000000..eb92bcd6 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Element_or_HTMLCollection.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_Element_or_HTMLCollection: ConvertibleToJSValue {} +extension Element: Any_Element_or_HTMLCollection {} +extension HTMLCollection: Any_Element_or_HTMLCollection {} + +public enum Element_or_HTMLCollection: JSValueCompatible, Any_Element_or_HTMLCollection { + case element(Element) + case htmlCollection(HTMLCollection) + + var element: Element? { + switch self { + case let .element(element): return element + default: return nil + } + } + + var htmlCollection: HTMLCollection? { + switch self { + case let .htmlCollection(htmlCollection): return htmlCollection + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let element: Element = value.fromJSValue() { + return .element(element) + } + if let htmlCollection: HTMLCollection = value.fromJSValue() { + return .htmlCollection(htmlCollection) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .element(element): + return element.jsValue + case let .htmlCollection(htmlCollection): + return htmlCollection.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/Element_or_RadioNodeList.swift b/Sources/DOMKit/WebIDL/Element_or_RadioNodeList.swift new file mode 100644 index 00000000..1b9a126d --- /dev/null +++ b/Sources/DOMKit/WebIDL/Element_or_RadioNodeList.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_Element_or_RadioNodeList: ConvertibleToJSValue {} +extension Element: Any_Element_or_RadioNodeList {} +extension RadioNodeList: Any_Element_or_RadioNodeList {} + +public enum Element_or_RadioNodeList: JSValueCompatible, Any_Element_or_RadioNodeList { + case element(Element) + case radioNodeList(RadioNodeList) + + var element: Element? { + switch self { + case let .element(element): return element + default: return nil + } + } + + var radioNodeList: RadioNodeList? { + switch self { + case let .radioNodeList(radioNodeList): return radioNodeList + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let element: Element = value.fromJSValue() { + return .element(element) + } + if let radioNodeList: RadioNodeList = value.fromJSValue() { + return .radioNodeList(radioNodeList) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .element(element): + return element.jsValue + case let .radioNodeList(radioNodeList): + return radioNodeList.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/Element_or_Text.swift b/Sources/DOMKit/WebIDL/Element_or_Text.swift new file mode 100644 index 00000000..1f9dc971 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Element_or_Text.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_Element_or_Text: ConvertibleToJSValue {} +extension Element: Any_Element_or_Text {} +extension Text: Any_Element_or_Text {} + +public enum Element_or_Text: JSValueCompatible, Any_Element_or_Text { + case element(Element) + case text(Text) + + var element: Element? { + switch self { + case let .element(element): return element + default: return nil + } + } + + var text: Text? { + switch self { + case let .text(text): return text + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let element: Element = value.fromJSValue() { + return .element(element) + } + if let text: Text = value.fromJSValue() { + return .text(text) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .element(element): + return element.jsValue + case let .text(text): + return text.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/EndingType.swift b/Sources/DOMKit/WebIDL/EndingType.swift index 91a975d3..247cc899 100644 --- a/Sources/DOMKit/WebIDL/EndingType.swift +++ b/Sources/DOMKit/WebIDL/EndingType.swift @@ -1,23 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public enum EndingType: String, JSValueCompatible { - public static func construct(from jsValue: JSValue) -> EndingType? { - if let string = jsValue.string, - let value = EndingType(rawValue: string) - { - return value +public enum EndingType: JSString, JSValueCompatible { + case transparent = "transparent" + case native = "native" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) } return nil } - case transparent - case native - public func jsValue() -> JSValue { - return rawValue.jsValue() + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } } diff --git a/Sources/DOMKit/WebIDL/ErrorEvent.swift b/Sources/DOMKit/WebIDL/ErrorEvent.swift new file mode 100644 index 00000000..44547d64 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ErrorEvent.swift @@ -0,0 +1,36 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ErrorEvent: Event { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.ErrorEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _message = ReadonlyAttribute(jsObject: jsObject, name: Strings.message) + _filename = ReadonlyAttribute(jsObject: jsObject, name: Strings.filename) + _lineno = ReadonlyAttribute(jsObject: jsObject, name: Strings.lineno) + _colno = ReadonlyAttribute(jsObject: jsObject, name: Strings.colno) + _error = ReadonlyAttribute(jsObject: jsObject, name: Strings.error) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: ErrorEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var message: String + + @ReadonlyAttribute + public var filename: String + + @ReadonlyAttribute + public var lineno: UInt32 + + @ReadonlyAttribute + public var colno: UInt32 + + @ReadonlyAttribute + public var error: JSValue +} diff --git a/Sources/DOMKit/WebIDL/ErrorEventInit.swift b/Sources/DOMKit/WebIDL/ErrorEventInit.swift new file mode 100644 index 00000000..b558e880 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ErrorEventInit.swift @@ -0,0 +1,40 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ErrorEventInit: BridgedDictionary { + public convenience init(message: String, filename: String, lineno: UInt32, colno: UInt32, error: JSValue) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.message] = message.jsValue + object[Strings.filename] = filename.jsValue + object[Strings.lineno] = lineno.jsValue + object[Strings.colno] = colno.jsValue + object[Strings.error] = error.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _message = ReadWriteAttribute(jsObject: object, name: Strings.message) + _filename = ReadWriteAttribute(jsObject: object, name: Strings.filename) + _lineno = ReadWriteAttribute(jsObject: object, name: Strings.lineno) + _colno = ReadWriteAttribute(jsObject: object, name: Strings.colno) + _error = ReadWriteAttribute(jsObject: object, name: Strings.error) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var message: String + + @ReadWriteAttribute + public var filename: String + + @ReadWriteAttribute + public var lineno: UInt32 + + @ReadWriteAttribute + public var colno: UInt32 + + @ReadWriteAttribute + public var error: JSValue +} diff --git a/Sources/DOMKit/WebIDL/Event.swift b/Sources/DOMKit/WebIDL/Event.swift index 1c873e2e..41015cf6 100644 --- a/Sources/DOMKit/WebIDL/Event.swift +++ b/Sources/DOMKit/WebIDL/Event.swift @@ -1,34 +1,32 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class Event: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.Event.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.Event].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _type = ReadonlyAttribute(jsObject: jsObject, name: "type") - _target = ReadonlyAttribute(jsObject: jsObject, name: "target") - _srcElement = ReadonlyAttribute(jsObject: jsObject, name: "srcElement") - _currentTarget = ReadonlyAttribute(jsObject: jsObject, name: "currentTarget") - _eventPhase = ReadonlyAttribute(jsObject: jsObject, name: "eventPhase") - _cancelBubble = ReadWriteAttribute(jsObject: jsObject, name: "cancelBubble") - _bubbles = ReadonlyAttribute(jsObject: jsObject, name: "bubbles") - _cancelable = ReadonlyAttribute(jsObject: jsObject, name: "cancelable") - _returnValue = ReadWriteAttribute(jsObject: jsObject, name: "returnValue") - _defaultPrevented = ReadonlyAttribute(jsObject: jsObject, name: "defaultPrevented") - _composed = ReadonlyAttribute(jsObject: jsObject, name: "composed") - _isTrusted = ReadonlyAttribute(jsObject: jsObject, name: "isTrusted") - _timeStamp = ReadonlyAttribute(jsObject: jsObject, name: "timeStamp") + _type = ReadonlyAttribute(jsObject: jsObject, name: Strings.type) + _target = ReadonlyAttribute(jsObject: jsObject, name: Strings.target) + _srcElement = ReadonlyAttribute(jsObject: jsObject, name: Strings.srcElement) + _currentTarget = ReadonlyAttribute(jsObject: jsObject, name: Strings.currentTarget) + _eventPhase = ReadonlyAttribute(jsObject: jsObject, name: Strings.eventPhase) + _cancelBubble = ReadWriteAttribute(jsObject: jsObject, name: Strings.cancelBubble) + _bubbles = ReadonlyAttribute(jsObject: jsObject, name: Strings.bubbles) + _cancelable = ReadonlyAttribute(jsObject: jsObject, name: Strings.cancelable) + _returnValue = ReadWriteAttribute(jsObject: jsObject, name: Strings.returnValue) + _defaultPrevented = ReadonlyAttribute(jsObject: jsObject, name: Strings.defaultPrevented) + _composed = ReadonlyAttribute(jsObject: jsObject, name: Strings.composed) + _isTrusted = ReadonlyAttribute(jsObject: jsObject, name: Strings.isTrusted) + _timeStamp = ReadonlyAttribute(jsObject: jsObject, name: Strings.timeStamp) self.jsObject = jsObject } - public convenience init(type: String, eventInitDict: EventInit = [:]) { - self.init(unsafelyWrapping: Event.constructor.new(type.jsValue(), eventInitDict.jsValue())) + @inlinable public convenience init(type: String, eventInitDict: EventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) } @ReadonlyAttribute @@ -43,30 +41,33 @@ public class Event: JSBridgedClass { @ReadonlyAttribute public var currentTarget: EventTarget? - public func composedPath() -> [EventTarget] { - return jsObject.composedPath!().fromJSValue()! + @inlinable public func composedPath() -> [EventTarget] { + let this = jsObject + return this[Strings.composedPath].function!(this: this, arguments: []).fromJSValue()! } - public let NONE: UInt16 = 0 + public static let NONE: UInt16 = 0 - public let CAPTURING_PHASE: UInt16 = 1 + public static let CAPTURING_PHASE: UInt16 = 1 - public let AT_TARGET: UInt16 = 2 + public static let AT_TARGET: UInt16 = 2 - public let BUBBLING_PHASE: UInt16 = 3 + public static let BUBBLING_PHASE: UInt16 = 3 @ReadonlyAttribute public var eventPhase: UInt16 - public func stopPropagation() { - _ = jsObject.stopPropagation!() + @inlinable public func stopPropagation() { + let this = jsObject + _ = this[Strings.stopPropagation].function!(this: this, arguments: []) } @ReadWriteAttribute public var cancelBubble: Bool - public func stopImmediatePropagation() { - _ = jsObject.stopImmediatePropagation!() + @inlinable public func stopImmediatePropagation() { + let this = jsObject + _ = this[Strings.stopImmediatePropagation].function!(this: this, arguments: []) } @ReadonlyAttribute @@ -78,8 +79,9 @@ public class Event: JSBridgedClass { @ReadWriteAttribute public var returnValue: Bool - public func preventDefault() { - _ = jsObject.preventDefault!() + @inlinable public func preventDefault() { + let this = jsObject + _ = this[Strings.preventDefault].function!(this: this, arguments: []) } @ReadonlyAttribute @@ -94,7 +96,8 @@ public class Event: JSBridgedClass { @ReadonlyAttribute public var timeStamp: DOMHighResTimeStamp - public func initEvent(type: String, bubbles: Bool = false, cancelable: Bool = false) { - _ = jsObject.initEvent!(type.jsValue(), bubbles.jsValue(), cancelable.jsValue()) + @inlinable public func initEvent(type: String, bubbles: Bool? = nil, cancelable: Bool? = nil) { + let this = jsObject + _ = this[Strings.initEvent].function!(this: this, arguments: [type.jsValue, bubbles?.jsValue ?? .undefined, cancelable?.jsValue ?? .undefined]) } } diff --git a/Sources/DOMKit/WebIDL/EventHandler.swift b/Sources/DOMKit/WebIDL/EventHandler.swift deleted file mode 100644 index 35c30f68..00000000 --- a/Sources/DOMKit/WebIDL/EventHandler.swift +++ /dev/null @@ -1,8 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public typealias EventHandler = EventHandlerNonNull? diff --git a/Sources/DOMKit/WebIDL/EventHandlerNonNull.swift b/Sources/DOMKit/WebIDL/EventHandlerNonNull.swift deleted file mode 100644 index cf2672b6..00000000 --- a/Sources/DOMKit/WebIDL/EventHandlerNonNull.swift +++ /dev/null @@ -1,8 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public typealias EventHandlerNonNull = ((Event) -> JSValue) diff --git a/Sources/DOMKit/WebIDL/EventInit.swift b/Sources/DOMKit/WebIDL/EventInit.swift index 30322086..ac6bfe1f 100644 --- a/Sources/DOMKit/WebIDL/EventInit.swift +++ b/Sources/DOMKit/WebIDL/EventInit.swift @@ -1,39 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public struct EventInit: ExpressibleByDictionaryLiteral, JSBridgedType { - public enum Key: String, Hashable { - case bubbles, cancelable, composed - } - - private let dictionary: [String: JSValue] - - public init(uniqueKeysWithValues elements: [(Key, ConvertibleToJSValue)]) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) +public class EventInit: BridgedDictionary { + public convenience init(bubbles: Bool, cancelable: Bool, composed: Bool) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.bubbles] = bubbles.jsValue + object[Strings.cancelable] = cancelable.jsValue + object[Strings.composed] = composed.jsValue + self.init(unsafelyWrapping: object) } - public init(dictionaryLiteral elements: (Key, ConvertibleToJSValue)...) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) + public required init(unsafelyWrapping object: JSObject) { + _bubbles = ReadWriteAttribute(jsObject: object, name: Strings.bubbles) + _cancelable = ReadWriteAttribute(jsObject: object, name: Strings.cancelable) + _composed = ReadWriteAttribute(jsObject: object, name: Strings.composed) + super.init(unsafelyWrapping: object) } - subscript(_ key: Key) -> JSValue? { - dictionary[key.rawValue] - } - - public init?(from value: JSValue) { - if let dictionary: [String: JSValue] = value.fromJSValue() { - self.dictionary = dictionary - } - return nil - } + @ReadWriteAttribute + public var bubbles: Bool - public var value: JSValue { jsValue() } + @ReadWriteAttribute + public var cancelable: Bool - public func jsValue() -> JSValue { - return dictionary.jsValue() - } + @ReadWriteAttribute + public var composed: Bool } diff --git a/Sources/DOMKit/WebIDL/EventListener.swift b/Sources/DOMKit/WebIDL/EventListener.swift deleted file mode 100644 index 493a6072..00000000 --- a/Sources/DOMKit/WebIDL/EventListener.swift +++ /dev/null @@ -1,10 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public protocol EventListener: JSBridgedType { - func handleEvent(event: Event) -} diff --git a/Sources/DOMKit/WebIDL/EventListenerOptions.swift b/Sources/DOMKit/WebIDL/EventListenerOptions.swift index 2786767f..b4f9d1c3 100644 --- a/Sources/DOMKit/WebIDL/EventListenerOptions.swift +++ b/Sources/DOMKit/WebIDL/EventListenerOptions.swift @@ -1,39 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public struct EventListenerOptions: ExpressibleByDictionaryLiteral, JSBridgedType { - public enum Key: String, Hashable { - case capture - } - - private let dictionary: [String: JSValue] - - public init(uniqueKeysWithValues elements: [(Key, ConvertibleToJSValue)]) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } - - public init(dictionaryLiteral elements: (Key, ConvertibleToJSValue)...) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } - - subscript(_ key: Key) -> JSValue? { - dictionary[key.rawValue] +public class EventListenerOptions: BridgedDictionary { + public convenience init(capture: Bool) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.capture] = capture.jsValue + self.init(unsafelyWrapping: object) } - public init?(from value: JSValue) { - if let dictionary: [String: JSValue] = value.fromJSValue() { - self.dictionary = dictionary - } - return nil + public required init(unsafelyWrapping object: JSObject) { + _capture = ReadWriteAttribute(jsObject: object, name: Strings.capture) + super.init(unsafelyWrapping: object) } - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - return dictionary.jsValue() - } + @ReadWriteAttribute + public var capture: Bool } diff --git a/Sources/DOMKit/WebIDL/EventListenerOptionsOrBool.swift b/Sources/DOMKit/WebIDL/EventListenerOptionsOrBool.swift deleted file mode 100644 index 29c516d5..00000000 --- a/Sources/DOMKit/WebIDL/EventListenerOptionsOrBool.swift +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public enum EventListenerOptionsOrBool: JSBridgedType, ExpressibleByBooleanLiteral, ExpressibleByDictionaryLiteral { - case eventListenerOptions(EventListenerOptions) - case bool(Bool) - - public init?(from value: JSValue) { - if let decoded: EventListenerOptions = value.fromJSValue() { - self = .eventListenerOptions(decoded) - } else if let decoded: Bool = value.fromJSValue() { - self = .bool(decoded) - } else { - return nil - } - } - - public init(dictionaryLiteral elements: (EventListenerOptions.Key, EventListenerOptions.Value)...) { - self = .eventListenerOptions(.init(uniqueKeysWithValues: elements)) - } - - public init(booleanLiteral value: Bool) { - self = .bool(value) - } - - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - switch self { - case let .eventListenerOptions(v): return v.jsValue() - case let .bool(v): return v.jsValue() - } - } -} diff --git a/Sources/DOMKit/WebIDL/EventModifierInit.swift b/Sources/DOMKit/WebIDL/EventModifierInit.swift new file mode 100644 index 00000000..8139f6f0 --- /dev/null +++ b/Sources/DOMKit/WebIDL/EventModifierInit.swift @@ -0,0 +1,85 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class EventModifierInit: BridgedDictionary { + public convenience init(ctrlKey: Bool, shiftKey: Bool, altKey: Bool, metaKey: Bool, modifierAltGraph: Bool, modifierCapsLock: Bool, modifierFn: Bool, modifierFnLock: Bool, modifierHyper: Bool, modifierNumLock: Bool, modifierScrollLock: Bool, modifierSuper: Bool, modifierSymbol: Bool, modifierSymbolLock: Bool) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.ctrlKey] = ctrlKey.jsValue + object[Strings.shiftKey] = shiftKey.jsValue + object[Strings.altKey] = altKey.jsValue + object[Strings.metaKey] = metaKey.jsValue + object[Strings.modifierAltGraph] = modifierAltGraph.jsValue + object[Strings.modifierCapsLock] = modifierCapsLock.jsValue + object[Strings.modifierFn] = modifierFn.jsValue + object[Strings.modifierFnLock] = modifierFnLock.jsValue + object[Strings.modifierHyper] = modifierHyper.jsValue + object[Strings.modifierNumLock] = modifierNumLock.jsValue + object[Strings.modifierScrollLock] = modifierScrollLock.jsValue + object[Strings.modifierSuper] = modifierSuper.jsValue + object[Strings.modifierSymbol] = modifierSymbol.jsValue + object[Strings.modifierSymbolLock] = modifierSymbolLock.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _ctrlKey = ReadWriteAttribute(jsObject: object, name: Strings.ctrlKey) + _shiftKey = ReadWriteAttribute(jsObject: object, name: Strings.shiftKey) + _altKey = ReadWriteAttribute(jsObject: object, name: Strings.altKey) + _metaKey = ReadWriteAttribute(jsObject: object, name: Strings.metaKey) + _modifierAltGraph = ReadWriteAttribute(jsObject: object, name: Strings.modifierAltGraph) + _modifierCapsLock = ReadWriteAttribute(jsObject: object, name: Strings.modifierCapsLock) + _modifierFn = ReadWriteAttribute(jsObject: object, name: Strings.modifierFn) + _modifierFnLock = ReadWriteAttribute(jsObject: object, name: Strings.modifierFnLock) + _modifierHyper = ReadWriteAttribute(jsObject: object, name: Strings.modifierHyper) + _modifierNumLock = ReadWriteAttribute(jsObject: object, name: Strings.modifierNumLock) + _modifierScrollLock = ReadWriteAttribute(jsObject: object, name: Strings.modifierScrollLock) + _modifierSuper = ReadWriteAttribute(jsObject: object, name: Strings.modifierSuper) + _modifierSymbol = ReadWriteAttribute(jsObject: object, name: Strings.modifierSymbol) + _modifierSymbolLock = ReadWriteAttribute(jsObject: object, name: Strings.modifierSymbolLock) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var ctrlKey: Bool + + @ReadWriteAttribute + public var shiftKey: Bool + + @ReadWriteAttribute + public var altKey: Bool + + @ReadWriteAttribute + public var metaKey: Bool + + @ReadWriteAttribute + public var modifierAltGraph: Bool + + @ReadWriteAttribute + public var modifierCapsLock: Bool + + @ReadWriteAttribute + public var modifierFn: Bool + + @ReadWriteAttribute + public var modifierFnLock: Bool + + @ReadWriteAttribute + public var modifierHyper: Bool + + @ReadWriteAttribute + public var modifierNumLock: Bool + + @ReadWriteAttribute + public var modifierScrollLock: Bool + + @ReadWriteAttribute + public var modifierSuper: Bool + + @ReadWriteAttribute + public var modifierSymbol: Bool + + @ReadWriteAttribute + public var modifierSymbolLock: Bool +} diff --git a/Sources/DOMKit/WebIDL/EventOrString.swift b/Sources/DOMKit/WebIDL/EventOrString.swift deleted file mode 100644 index 416e87c7..00000000 --- a/Sources/DOMKit/WebIDL/EventOrString.swift +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public enum EventOrString: JSBridgedType, ExpressibleByStringLiteral { - case event(Event) - case string(String) - - public init?(from value: JSValue) { - if let decoded: Event = value.fromJSValue() { - self = .event(decoded) - } else if let decoded: String = value.fromJSValue() { - self = .string(decoded) - } else { - return nil - } - } - - public init(stringLiteral value: String) { - self = .string(value) - } - - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - switch self { - case let .event(v): return v.jsValue() - case let .string(v): return v.jsValue() - } - } -} diff --git a/Sources/DOMKit/WebIDL/EventSource.swift b/Sources/DOMKit/WebIDL/EventSource.swift new file mode 100644 index 00000000..9a95df8a --- /dev/null +++ b/Sources/DOMKit/WebIDL/EventSource.swift @@ -0,0 +1,51 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class EventSource: EventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.EventSource].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _url = ReadonlyAttribute(jsObject: jsObject, name: Strings.url) + _withCredentials = ReadonlyAttribute(jsObject: jsObject, name: Strings.withCredentials) + _readyState = ReadonlyAttribute(jsObject: jsObject, name: Strings.readyState) + _onopen = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onopen) + _onmessage = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onmessage) + _onerror = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onerror) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(url: String, eventSourceInitDict: EventSourceInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [url.jsValue, eventSourceInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var url: String + + @ReadonlyAttribute + public var withCredentials: Bool + + public static let CONNECTING: UInt16 = 0 + + public static let OPEN: UInt16 = 1 + + public static let CLOSED: UInt16 = 2 + + @ReadonlyAttribute + public var readyState: UInt16 + + @ClosureAttribute1Optional + public var onopen: EventHandler + + @ClosureAttribute1Optional + public var onmessage: EventHandler + + @ClosureAttribute1Optional + public var onerror: EventHandler + + @inlinable public func close() { + let this = jsObject + _ = this[Strings.close].function!(this: this, arguments: []) + } +} diff --git a/Sources/DOMKit/WebIDL/EventSourceInit.swift b/Sources/DOMKit/WebIDL/EventSourceInit.swift new file mode 100644 index 00000000..c44cc13c --- /dev/null +++ b/Sources/DOMKit/WebIDL/EventSourceInit.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class EventSourceInit: BridgedDictionary { + public convenience init(withCredentials: Bool) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.withCredentials] = withCredentials.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _withCredentials = ReadWriteAttribute(jsObject: object, name: Strings.withCredentials) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var withCredentials: Bool +} diff --git a/Sources/DOMKit/WebIDL/EventTarget.swift b/Sources/DOMKit/WebIDL/EventTarget.swift index f5496619..9848b2cb 100644 --- a/Sources/DOMKit/WebIDL/EventTarget.swift +++ b/Sources/DOMKit/WebIDL/EventTarget.swift @@ -1,18 +1,10 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class EventTarget: JSBridgedClass { - public struct Token { - var type: String - var index: Int - } - public class var constructor: JSFunction { JSObject.global.EventTarget.function! } - - var eventListeners = [String: [JSClosure]]() + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.EventTarget].function! } public let jsObject: JSObject @@ -20,70 +12,16 @@ public class EventTarget: JSBridgedClass { self.jsObject = jsObject } - public convenience init() { - self.init(unsafelyWrapping: EventTarget.constructor.new()) - } - - deinit { - for (_, listeners) in eventListeners { - for closure in listeners { - closure.release() - } - } - } - - public func addEventListener( - type: String, - options: AddEventListenerOptionsOrBool = [:], - callback: EventListenerType) { - _ = jsObject.addEventListener!(type.jsValue(), callback.jsValue(), options.jsValue()) + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) } - public func addEventListener( - type: String, - options: AddEventListenerOptionsOrBool = [:], - callback: @escaping (Event) -> () - ) -> Token { - let closure = JSClosure { callback($0[0].fromJSValue()!) } - let token: Token - let listeners: [JSClosure] - if var existingListeners = eventListeners[type] { - token = Token(type: type, index: existingListeners.count) - existingListeners.append(closure) - listeners = existingListeners - } else { - token = Token(type: type, index: 0) - listeners = [closure] - } - eventListeners[type] = listeners + // XXX: member 'addEventListener' is ignored - _ = jsObject.addEventListener!(type.jsValue(), closure, options.jsValue()) - - return token - } - - public func removeEventListener( - type: String, - options: EventListenerOptionsOrBool = [:], - callback: EventListenerType - ) { - _ = jsObject.removeEventListener!(type.jsValue(), callback.jsValue(), options.jsValue()) - } - - public func removeEventListener( - type: String, - token: Token, - options: EventListenerOptionsOrBool = [:] - ) { - guard var listeners = eventListeners[type] else { return } - - let closure = listeners[token.index] - _ = jsObject.removeEventListener!(type.jsValue(), closure, options.jsValue()) - listeners.remove(at: token.index) - closure.release() - } + // XXX: member 'removeEventListener' is ignored - public func dispatchEvent(event: Event) -> Bool { - return jsObject.dispatchEvent!(event.jsValue()).fromJSValue()! + @inlinable public func dispatchEvent(event: Event) -> Bool { + let this = jsObject + return this[Strings.dispatchEvent].function!(this: this, arguments: [event.jsValue]).fromJSValue()! } } diff --git a/Sources/DOMKit/WebIDL/Event_or_String.swift b/Sources/DOMKit/WebIDL/Event_or_String.swift new file mode 100644 index 00000000..24c91293 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Event_or_String.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_Event_or_String: ConvertibleToJSValue {} +extension Event: Any_Event_or_String {} +extension String: Any_Event_or_String {} + +public enum Event_or_String: JSValueCompatible, Any_Event_or_String { + case event(Event) + case string(String) + + var event: Event? { + switch self { + case let .event(event): return event + default: return nil + } + } + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let event: Event = value.fromJSValue() { + return .event(event) + } + if let string: String = value.fromJSValue() { + return .string(string) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .event(event): + return event.jsValue + case let .string(string): + return string.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/ExtendableEventInit.swift b/Sources/DOMKit/WebIDL/ExtendableEventInit.swift new file mode 100644 index 00000000..efb5d334 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ExtendableEventInit.swift @@ -0,0 +1,16 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ExtendableEventInit: BridgedDictionary { + public convenience init() { + let object = JSObject.global[Strings.Object].function!.new() + + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + super.init(unsafelyWrapping: object) + } +} diff --git a/Sources/DOMKit/WebIDL/External.swift b/Sources/DOMKit/WebIDL/External.swift new file mode 100644 index 00000000..302e99da --- /dev/null +++ b/Sources/DOMKit/WebIDL/External.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class External: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.External].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + @inlinable public func AddSearchProvider() { + let this = jsObject + _ = this[Strings.AddSearchProvider].function!(this: this, arguments: []) + } + + @inlinable public func IsSearchProviderInstalled() { + let this = jsObject + _ = this[Strings.IsSearchProviderInstalled].function!(this: this, arguments: []) + } +} diff --git a/Sources/DOMKit/WebIDL/FetchEventInit.swift b/Sources/DOMKit/WebIDL/FetchEventInit.swift new file mode 100644 index 00000000..065f527a --- /dev/null +++ b/Sources/DOMKit/WebIDL/FetchEventInit.swift @@ -0,0 +1,45 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class FetchEventInit: BridgedDictionary { + public convenience init(request: Request, preloadResponse: JSPromise, clientId: String, resultingClientId: String, replacesClientId: String, handled: JSPromise) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.request] = request.jsValue + object[Strings.preloadResponse] = preloadResponse.jsValue + object[Strings.clientId] = clientId.jsValue + object[Strings.resultingClientId] = resultingClientId.jsValue + object[Strings.replacesClientId] = replacesClientId.jsValue + object[Strings.handled] = handled.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _request = ReadWriteAttribute(jsObject: object, name: Strings.request) + _preloadResponse = ReadWriteAttribute(jsObject: object, name: Strings.preloadResponse) + _clientId = ReadWriteAttribute(jsObject: object, name: Strings.clientId) + _resultingClientId = ReadWriteAttribute(jsObject: object, name: Strings.resultingClientId) + _replacesClientId = ReadWriteAttribute(jsObject: object, name: Strings.replacesClientId) + _handled = ReadWriteAttribute(jsObject: object, name: Strings.handled) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var request: Request + + @ReadWriteAttribute + public var preloadResponse: JSPromise + + @ReadWriteAttribute + public var clientId: String + + @ReadWriteAttribute + public var resultingClientId: String + + @ReadWriteAttribute + public var replacesClientId: String + + @ReadWriteAttribute + public var handled: JSPromise +} diff --git a/Sources/DOMKit/WebIDL/File.swift b/Sources/DOMKit/WebIDL/File.swift index b483c911..7489440b 100644 --- a/Sources/DOMKit/WebIDL/File.swift +++ b/Sources/DOMKit/WebIDL/File.swift @@ -1,21 +1,19 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class File: Blob { - override public class var constructor: JSFunction { JSObject.global.File.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.File].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _name = ReadonlyAttribute(jsObject: jsObject, name: "name") - _lastModified = ReadonlyAttribute(jsObject: jsObject, name: "lastModified") + _name = ReadonlyAttribute(jsObject: jsObject, name: Strings.name) + _lastModified = ReadonlyAttribute(jsObject: jsObject, name: Strings.lastModified) super.init(unsafelyWrapping: jsObject) } - public convenience init(fileBits: [BlobPart], fileName: String, options: FilePropertyBag = [:]) { - self.init(unsafelyWrapping: File.constructor.new(fileBits.jsValue(), fileName.jsValue(), options.jsValue())) + @inlinable public convenience init(fileBits: [BlobPart], fileName: String, options: FilePropertyBag? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [fileBits.jsValue, fileName.jsValue, options?.jsValue ?? .undefined])) } @ReadonlyAttribute diff --git a/Sources/DOMKit/WebIDL/FileList.swift b/Sources/DOMKit/WebIDL/FileList.swift index 73d1b7ea..6cab3da3 100644 --- a/Sources/DOMKit/WebIDL/FileList.swift +++ b/Sources/DOMKit/WebIDL/FileList.swift @@ -1,20 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class FileList: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.FileList.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.FileList].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _length = ReadonlyAttribute(jsObject: jsObject, name: "length") + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) self.jsObject = jsObject } + @inlinable public subscript(key: Int) -> File? { + jsObject[key].fromJSValue() + } + @ReadonlyAttribute public var length: UInt32 } diff --git a/Sources/DOMKit/WebIDL/FileOrString.swift b/Sources/DOMKit/WebIDL/FileOrString.swift deleted file mode 100644 index 18779852..00000000 --- a/Sources/DOMKit/WebIDL/FileOrString.swift +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public enum FileOrString: JSBridgedType, ExpressibleByStringLiteral { - case file(File) - case string(String) - - public init?(from value: JSValue) { - if let decoded: File = value.fromJSValue() { - self = .file(decoded) - } else if let decoded: String = value.fromJSValue() { - self = .string(decoded) - } else { - return nil - } - } - - public init(stringLiteral value: String) { - self = .string(value) - } - - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - switch self { - case let .file(v): return v.jsValue() - case let .string(v): return v.jsValue() - } - } -} diff --git a/Sources/DOMKit/WebIDL/FileOrStringOrFormData.swift b/Sources/DOMKit/WebIDL/FileOrStringOrFormData.swift deleted file mode 100644 index 630bf795..00000000 --- a/Sources/DOMKit/WebIDL/FileOrStringOrFormData.swift +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public enum FileOrStringOrFormData: JSBridgedType, ExpressibleByStringLiteral { - case file(File) - case string(String) - case formData(FormData) - - public init?(from value: JSValue) { - if let decoded: File = value.fromJSValue() { - self = .file(decoded) - } else if let decoded: String = value.fromJSValue() { - self = .string(decoded) - } else if let decoded: FormData = value.fromJSValue() { - self = .formData(decoded) - } else { - return nil - } - } - - public init(stringLiteral value: String) { - self = .string(value) - } - - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - switch self { - case let .file(v): return v.jsValue() - case let .string(v): return v.jsValue() - case let .formData(v): return v.jsValue() - } - } -} diff --git a/Sources/DOMKit/WebIDL/FilePropertyBag.swift b/Sources/DOMKit/WebIDL/FilePropertyBag.swift index 6415c050..d1c97803 100644 --- a/Sources/DOMKit/WebIDL/FilePropertyBag.swift +++ b/Sources/DOMKit/WebIDL/FilePropertyBag.swift @@ -1,39 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public struct FilePropertyBag: ExpressibleByDictionaryLiteral, JSBridgedType { - public enum Key: String, Hashable { - case type, endings, lastModified - } - - private let dictionary: [String: JSValue] - - public init(uniqueKeysWithValues elements: [(Key, ConvertibleToJSValue)]) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } - - public init(dictionaryLiteral elements: (Key, ConvertibleToJSValue)...) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } - - subscript(_ key: Key) -> JSValue? { - dictionary[key.rawValue] +public class FilePropertyBag: BridgedDictionary { + public convenience init(lastModified: Int64) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.lastModified] = lastModified.jsValue + self.init(unsafelyWrapping: object) } - public init?(from value: JSValue) { - if let dictionary: [String: JSValue] = value.fromJSValue() { - self.dictionary = dictionary - } - return nil + public required init(unsafelyWrapping object: JSObject) { + _lastModified = ReadWriteAttribute(jsObject: object, name: Strings.lastModified) + super.init(unsafelyWrapping: object) } - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - return dictionary.jsValue() - } + @ReadWriteAttribute + public var lastModified: Int64 } diff --git a/Sources/DOMKit/WebIDL/FileReader.swift b/Sources/DOMKit/WebIDL/FileReader.swift index 103dd64f..90cbd578 100644 --- a/Sources/DOMKit/WebIDL/FileReader.swift +++ b/Sources/DOMKit/WebIDL/FileReader.swift @@ -1,84 +1,83 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class FileReader: EventTarget { - override public class var constructor: JSFunction { JSObject.global.FileReader.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.FileReader].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _readyState = ReadonlyAttribute(jsObject: jsObject, name: "readyState") - _result = ReadonlyAttribute(jsObject: jsObject, name: "result") - _error = ReadonlyAttribute(jsObject: jsObject, name: "error") - _onloadstart = OptionalClosureHandler(jsObject: jsObject, name: "onloadstart") - _onprogress = OptionalClosureHandler(jsObject: jsObject, name: "onprogress") - _onload = OptionalClosureHandler(jsObject: jsObject, name: "onload") - _onabort = OptionalClosureHandler(jsObject: jsObject, name: "onabort") - _onerror = OptionalClosureHandler(jsObject: jsObject, name: "onerror") - _onloadend = OptionalClosureHandler(jsObject: jsObject, name: "onloadend") + _readyState = ReadonlyAttribute(jsObject: jsObject, name: Strings.readyState) + _result = ReadonlyAttribute(jsObject: jsObject, name: Strings.result) + _error = ReadonlyAttribute(jsObject: jsObject, name: Strings.error) + _onloadstart = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onloadstart) + _onprogress = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onprogress) + _onload = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onload) + _onabort = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onabort) + _onerror = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onerror) + _onloadend = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onloadend) super.init(unsafelyWrapping: jsObject) } - public convenience init() { - self.init(unsafelyWrapping: FileReader.constructor.new()) - } - - public func readAsArrayBuffer(blob: Blob) { - _ = jsObject.readAsArrayBuffer!(blob.jsValue()) + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) } - public func readAsBinaryString(blob: Blob) { - _ = jsObject.readAsBinaryString!(blob.jsValue()) + @inlinable public func readAsArrayBuffer(blob: Blob) { + let this = jsObject + _ = this[Strings.readAsArrayBuffer].function!(this: this, arguments: [blob.jsValue]) } - public func readAsText(blob: Blob, encoding: String) { - _ = jsObject.readAsText!(blob.jsValue(), encoding.jsValue()) + @inlinable public func readAsBinaryString(blob: Blob) { + let this = jsObject + _ = this[Strings.readAsBinaryString].function!(this: this, arguments: [blob.jsValue]) } - public func readAsText(blob: Blob) { - _ = jsObject.readAsText!(blob.jsValue()) + @inlinable public func readAsText(blob: Blob, encoding: String? = nil) { + let this = jsObject + _ = this[Strings.readAsText].function!(this: this, arguments: [blob.jsValue, encoding?.jsValue ?? .undefined]) } - public func readAsDataURL(blob: Blob) { - _ = jsObject.readAsDataURL!(blob.jsValue()) + @inlinable public func readAsDataURL(blob: Blob) { + let this = jsObject + _ = this[Strings.readAsDataURL].function!(this: this, arguments: [blob.jsValue]) } - public func abort() { - _ = jsObject.abort!() + @inlinable public func abort() { + let this = jsObject + _ = this[Strings.abort].function!(this: this, arguments: []) } - public let EMPTY: UInt16 = 0 + public static let EMPTY: UInt16 = 0 - public let LOADING: UInt16 = 1 + public static let LOADING: UInt16 = 1 - public let DONE: UInt16 = 2 + public static let DONE: UInt16 = 2 @ReadonlyAttribute public var readyState: UInt16 @ReadonlyAttribute - public var result: StringOrArrayBuffer? + public var result: ArrayBuffer_or_String? @ReadonlyAttribute public var error: DOMException? - @OptionalClosureHandler + @ClosureAttribute1Optional public var onloadstart: EventHandler - @OptionalClosureHandler + @ClosureAttribute1Optional public var onprogress: EventHandler - @OptionalClosureHandler + @ClosureAttribute1Optional public var onload: EventHandler - @OptionalClosureHandler + @ClosureAttribute1Optional public var onabort: EventHandler - @OptionalClosureHandler + @ClosureAttribute1Optional public var onerror: EventHandler - @OptionalClosureHandler + @ClosureAttribute1Optional public var onloadend: EventHandler } diff --git a/Sources/DOMKit/WebIDL/FileReaderSync.swift b/Sources/DOMKit/WebIDL/FileReaderSync.swift deleted file mode 100644 index c1a0fbd2..00000000 --- a/Sources/DOMKit/WebIDL/FileReaderSync.swift +++ /dev/null @@ -1,40 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public class FileReaderSync: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.FileReaderSync.function! } - - public let jsObject: JSObject - - public required init(unsafelyWrapping jsObject: JSObject) { - self.jsObject = jsObject - } - - public convenience init() { - self.init(unsafelyWrapping: FileReaderSync.constructor.new()) - } - - public func readAsArrayBuffer(blob: Blob) -> ArrayBuffer { - return jsObject.readAsArrayBuffer!(blob.jsValue()).fromJSValue()! - } - - public func readAsBinaryString(blob: Blob) -> String { - return jsObject.readAsBinaryString!(blob.jsValue()).fromJSValue()! - } - - public func readAsText(blob: Blob, encoding: String) -> String { - return jsObject.readAsText!(blob.jsValue(), encoding.jsValue()).fromJSValue()! - } - - public func readAsText(blob: Blob) -> String { - return jsObject.readAsText!(blob.jsValue()).fromJSValue()! - } - - public func readAsDataURL(blob: Blob) -> String { - return jsObject.readAsDataURL!(blob.jsValue()).fromJSValue()! - } -} diff --git a/Sources/DOMKit/WebIDL/File_or_FormData_or_String.swift b/Sources/DOMKit/WebIDL/File_or_FormData_or_String.swift new file mode 100644 index 00000000..c420970c --- /dev/null +++ b/Sources/DOMKit/WebIDL/File_or_FormData_or_String.swift @@ -0,0 +1,60 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_File_or_FormData_or_String: ConvertibleToJSValue {} +extension File: Any_File_or_FormData_or_String {} +extension FormData: Any_File_or_FormData_or_String {} +extension String: Any_File_or_FormData_or_String {} + +public enum File_or_FormData_or_String: JSValueCompatible, Any_File_or_FormData_or_String { + case file(File) + case formData(FormData) + case string(String) + + var file: File? { + switch self { + case let .file(file): return file + default: return nil + } + } + + var formData: FormData? { + switch self { + case let .formData(formData): return formData + default: return nil + } + } + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let file: File = value.fromJSValue() { + return .file(file) + } + if let formData: FormData = value.fromJSValue() { + return .formData(formData) + } + if let string: String = value.fromJSValue() { + return .string(string) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .file(file): + return file.jsValue + case let .formData(formData): + return formData.jsValue + case let .string(string): + return string.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/FillMode.swift b/Sources/DOMKit/WebIDL/FillMode.swift new file mode 100644 index 00000000..b1063c23 --- /dev/null +++ b/Sources/DOMKit/WebIDL/FillMode.swift @@ -0,0 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum FillMode: JSString, JSValueCompatible { + case none = "none" + case forwards = "forwards" + case backwards = "backwards" + case both = "both" + case auto = "auto" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/FocusEvent.swift b/Sources/DOMKit/WebIDL/FocusEvent.swift new file mode 100644 index 00000000..8fc35205 --- /dev/null +++ b/Sources/DOMKit/WebIDL/FocusEvent.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class FocusEvent: UIEvent { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.FocusEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _relatedTarget = ReadonlyAttribute(jsObject: jsObject, name: Strings.relatedTarget) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: FocusEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var relatedTarget: EventTarget? +} diff --git a/Sources/DOMKit/WebIDL/FocusEventInit.swift b/Sources/DOMKit/WebIDL/FocusEventInit.swift new file mode 100644 index 00000000..d2a1efb8 --- /dev/null +++ b/Sources/DOMKit/WebIDL/FocusEventInit.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class FocusEventInit: BridgedDictionary { + public convenience init(relatedTarget: EventTarget?) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.relatedTarget] = relatedTarget.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _relatedTarget = ReadWriteAttribute(jsObject: object, name: Strings.relatedTarget) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var relatedTarget: EventTarget? +} diff --git a/Sources/DOMKit/WebIDL/FocusOptions.swift b/Sources/DOMKit/WebIDL/FocusOptions.swift index ff3f0a1a..ce7b2385 100644 --- a/Sources/DOMKit/WebIDL/FocusOptions.swift +++ b/Sources/DOMKit/WebIDL/FocusOptions.swift @@ -1,39 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public struct FocusOptions: ExpressibleByDictionaryLiteral, JSBridgedType { - public enum Key: String, Hashable { - case preventScroll - } - - private let dictionary: [String: JSValue] - - public init(uniqueKeysWithValues elements: [(Key, ConvertibleToJSValue)]) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } - - public init(dictionaryLiteral elements: (Key, ConvertibleToJSValue)...) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } - - subscript(_ key: Key) -> JSValue? { - dictionary[key.rawValue] +public class FocusOptions: BridgedDictionary { + public convenience init(preventScroll: Bool) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.preventScroll] = preventScroll.jsValue + self.init(unsafelyWrapping: object) } - public init?(from value: JSValue) { - if let dictionary: [String: JSValue] = value.fromJSValue() { - self.dictionary = dictionary - } - return nil + public required init(unsafelyWrapping object: JSObject) { + _preventScroll = ReadWriteAttribute(jsObject: object, name: Strings.preventScroll) + super.init(unsafelyWrapping: object) } - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - return dictionary.jsValue() - } + @ReadWriteAttribute + public var preventScroll: Bool } diff --git a/Sources/DOMKit/WebIDL/FormData.swift b/Sources/DOMKit/WebIDL/FormData.swift index 44ab9165..ff3d1973 100644 --- a/Sources/DOMKit/WebIDL/FormData.swift +++ b/Sources/DOMKit/WebIDL/FormData.swift @@ -1,12 +1,10 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public class FormData: JSBridgedClass, KeyValueSequence { - public class var constructor: JSFunction { JSObject.global.FormData.function! } +public class FormData: JSBridgedClass, Sequence { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.FormData].function! } public let jsObject: JSObject @@ -14,55 +12,52 @@ public class FormData: JSBridgedClass, KeyValueSequence { self.jsObject = jsObject } - public typealias Value = FormDataEntryValue - - public convenience init(form: HTMLFormElement) { - self.init(unsafelyWrapping: FormData.constructor.new(form.jsValue())) - } - - public convenience init() { - self.init(unsafelyWrapping: FormData.constructor.new()) + @inlinable public convenience init(form: HTMLFormElement? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [form?.jsValue ?? .undefined])) } - public func append(name: String, value: String) { - _ = jsObject.append!(name.jsValue(), value.jsValue()) + @inlinable public func append(name: String, value: String) { + let this = jsObject + _ = this[Strings.append].function!(this: this, arguments: [name.jsValue, value.jsValue]) } - public func append(name: String, blobValue: Blob, filename: String) { - _ = jsObject.append!(name.jsValue(), blobValue.jsValue(), filename.jsValue()) + @inlinable public func append(name: String, blobValue: Blob, filename: String? = nil) { + let this = jsObject + _ = this[Strings.append].function!(this: this, arguments: [name.jsValue, blobValue.jsValue, filename?.jsValue ?? .undefined]) } - public func append(name: String, blobValue: Blob) { - _ = jsObject.append!(name.jsValue(), blobValue.jsValue()) + @inlinable public func delete(name: String) { + let this = jsObject + _ = this[Strings.delete].function!(this: this, arguments: [name.jsValue]) } - public func delete(name: String) { - _ = jsObject.delete!(name.jsValue()) + @inlinable public func get(name: String) -> FormDataEntryValue? { + let this = jsObject + return this[Strings.get].function!(this: this, arguments: [name.jsValue]).fromJSValue()! } - public func get(name: String) -> FormDataEntryValue? { - return jsObject.get!(name.jsValue()).fromJSValue()! + @inlinable public func getAll(name: String) -> [FormDataEntryValue] { + let this = jsObject + return this[Strings.getAll].function!(this: this, arguments: [name.jsValue]).fromJSValue()! } - public func getAll(name: String) -> [FormDataEntryValue] { - return jsObject.getAll!(name.jsValue()).fromJSValue()! + @inlinable public func has(name: String) -> Bool { + let this = jsObject + return this[Strings.has].function!(this: this, arguments: [name.jsValue]).fromJSValue()! } - public func has(name: String) -> Bool { - return jsObject.has!(name.jsValue()).fromJSValue()! + @inlinable public func set(name: String, value: String) { + let this = jsObject + _ = this[Strings.set].function!(this: this, arguments: [name.jsValue, value.jsValue]) } - public func set(name: String, value: String) { - _ = jsObject.set!(name.jsValue(), value.jsValue()) + @inlinable public func set(name: String, blobValue: Blob, filename: String? = nil) { + let this = jsObject + _ = this[Strings.set].function!(this: this, arguments: [name.jsValue, blobValue.jsValue, filename?.jsValue ?? .undefined]) } - public func set(name: String, blobValue: Blob, filename: String) { - _ = jsObject.set!(name.jsValue(), blobValue.jsValue(), filename.jsValue()) + public typealias Element = String + public func makeIterator() -> ValueIterableIterator { + ValueIterableIterator(sequence: self) } - - public func set(name: String, blobValue: Blob) { - _ = jsObject.set!(name.jsValue(), blobValue.jsValue()) - } - - public func makeIterator() -> PairIterableIterator { return PairIterableIterator(sequence: self) } } diff --git a/Sources/DOMKit/WebIDL/FormDataEntryValue.swift b/Sources/DOMKit/WebIDL/FormDataEntryValue.swift index fb8f934f..14b0433d 100644 --- a/Sources/DOMKit/WebIDL/FormDataEntryValue.swift +++ b/Sources/DOMKit/WebIDL/FormDataEntryValue.swift @@ -1,8 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public typealias FormDataEntryValue = FileOrString +public protocol Any_FormDataEntryValue: ConvertibleToJSValue {} +extension File: Any_FormDataEntryValue {} +extension String: Any_FormDataEntryValue {} + +public enum FormDataEntryValue: JSValueCompatible, Any_FormDataEntryValue { + case file(File) + case string(String) + + var file: File? { + switch self { + case let .file(file): return file + default: return nil + } + } + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let file: File = value.fromJSValue() { + return .file(file) + } + if let string: String = value.fromJSValue() { + return .string(string) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .file(file): + return file.jsValue + case let .string(string): + return string.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/FormDataEvent.swift b/Sources/DOMKit/WebIDL/FormDataEvent.swift new file mode 100644 index 00000000..d5ae7f7f --- /dev/null +++ b/Sources/DOMKit/WebIDL/FormDataEvent.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class FormDataEvent: Event { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.FormDataEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _formData = ReadonlyAttribute(jsObject: jsObject, name: Strings.formData) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: FormDataEventInit) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict.jsValue])) + } + + @ReadonlyAttribute + public var formData: FormData +} diff --git a/Sources/DOMKit/WebIDL/FormDataEventInit.swift b/Sources/DOMKit/WebIDL/FormDataEventInit.swift new file mode 100644 index 00000000..183075f9 --- /dev/null +++ b/Sources/DOMKit/WebIDL/FormDataEventInit.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class FormDataEventInit: BridgedDictionary { + public convenience init(formData: FormData) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.formData] = formData.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _formData = ReadWriteAttribute(jsObject: object, name: Strings.formData) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var formData: FormData +} diff --git a/Sources/DOMKit/WebIDL/FrameType.swift b/Sources/DOMKit/WebIDL/FrameType.swift new file mode 100644 index 00000000..d9f5fe35 --- /dev/null +++ b/Sources/DOMKit/WebIDL/FrameType.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum FrameType: JSString, JSValueCompatible { + case auxiliary = "auxiliary" + case topLevel = "top-level" + case nested = "nested" + case none = "none" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/Function.swift b/Sources/DOMKit/WebIDL/Function.swift deleted file mode 100644 index 2ae482e9..00000000 --- a/Sources/DOMKit/WebIDL/Function.swift +++ /dev/null @@ -1,8 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public typealias Function = ((JSValue) -> JSValue) diff --git a/Sources/DOMKit/WebIDL/GetAnimationsOptions.swift b/Sources/DOMKit/WebIDL/GetAnimationsOptions.swift new file mode 100644 index 00000000..7acb68cd --- /dev/null +++ b/Sources/DOMKit/WebIDL/GetAnimationsOptions.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class GetAnimationsOptions: BridgedDictionary { + public convenience init(subtree: Bool) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.subtree] = subtree.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _subtree = ReadWriteAttribute(jsObject: object, name: Strings.subtree) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var subtree: Bool +} diff --git a/Sources/DOMKit/WebIDL/GetRootNodeOptions.swift b/Sources/DOMKit/WebIDL/GetRootNodeOptions.swift index cc024db8..642eaae9 100644 --- a/Sources/DOMKit/WebIDL/GetRootNodeOptions.swift +++ b/Sources/DOMKit/WebIDL/GetRootNodeOptions.swift @@ -1,39 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public struct GetRootNodeOptions: ExpressibleByDictionaryLiteral, JSBridgedType { - public enum Key: String, Hashable { - case composed - } - - private let dictionary: [String: JSValue] - - public init(uniqueKeysWithValues elements: [(Key, ConvertibleToJSValue)]) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } - - public init(dictionaryLiteral elements: (Key, ConvertibleToJSValue)...) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } - - subscript(_ key: Key) -> JSValue? { - dictionary[key.rawValue] +public class GetRootNodeOptions: BridgedDictionary { + public convenience init(composed: Bool) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.composed] = composed.jsValue + self.init(unsafelyWrapping: object) } - public init?(from value: JSValue) { - if let dictionary: [String: JSValue] = value.fromJSValue() { - self.dictionary = dictionary - } - return nil + public required init(unsafelyWrapping object: JSObject) { + _composed = ReadWriteAttribute(jsObject: object, name: Strings.composed) + super.init(unsafelyWrapping: object) } - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - return dictionary.jsValue() - } + @ReadWriteAttribute + public var composed: Bool } diff --git a/Sources/DOMKit/WebIDL/GlobalEventHandlers.swift b/Sources/DOMKit/WebIDL/GlobalEventHandlers.swift new file mode 100644 index 00000000..b2acb292 --- /dev/null +++ b/Sources/DOMKit/WebIDL/GlobalEventHandlers.swift @@ -0,0 +1,347 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol GlobalEventHandlers: JSBridgedClass {} +public extension GlobalEventHandlers { + @inlinable var onabort: EventHandler { + get { ClosureAttribute1Optional[Strings.onabort, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onabort, in: jsObject] = newValue } + } + + @inlinable var onauxclick: EventHandler { + get { ClosureAttribute1Optional[Strings.onauxclick, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onauxclick, in: jsObject] = newValue } + } + + @inlinable var onblur: EventHandler { + get { ClosureAttribute1Optional[Strings.onblur, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onblur, in: jsObject] = newValue } + } + + @inlinable var oncancel: EventHandler { + get { ClosureAttribute1Optional[Strings.oncancel, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.oncancel, in: jsObject] = newValue } + } + + @inlinable var oncanplay: EventHandler { + get { ClosureAttribute1Optional[Strings.oncanplay, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.oncanplay, in: jsObject] = newValue } + } + + @inlinable var oncanplaythrough: EventHandler { + get { ClosureAttribute1Optional[Strings.oncanplaythrough, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.oncanplaythrough, in: jsObject] = newValue } + } + + @inlinable var onchange: EventHandler { + get { ClosureAttribute1Optional[Strings.onchange, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onchange, in: jsObject] = newValue } + } + + @inlinable var onclick: EventHandler { + get { ClosureAttribute1Optional[Strings.onclick, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onclick, in: jsObject] = newValue } + } + + @inlinable var onclose: EventHandler { + get { ClosureAttribute1Optional[Strings.onclose, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onclose, in: jsObject] = newValue } + } + + @inlinable var oncontextlost: EventHandler { + get { ClosureAttribute1Optional[Strings.oncontextlost, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.oncontextlost, in: jsObject] = newValue } + } + + @inlinable var oncontextmenu: EventHandler { + get { ClosureAttribute1Optional[Strings.oncontextmenu, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.oncontextmenu, in: jsObject] = newValue } + } + + @inlinable var oncontextrestored: EventHandler { + get { ClosureAttribute1Optional[Strings.oncontextrestored, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.oncontextrestored, in: jsObject] = newValue } + } + + @inlinable var oncuechange: EventHandler { + get { ClosureAttribute1Optional[Strings.oncuechange, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.oncuechange, in: jsObject] = newValue } + } + + @inlinable var ondblclick: EventHandler { + get { ClosureAttribute1Optional[Strings.ondblclick, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.ondblclick, in: jsObject] = newValue } + } + + @inlinable var ondrag: EventHandler { + get { ClosureAttribute1Optional[Strings.ondrag, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.ondrag, in: jsObject] = newValue } + } + + @inlinable var ondragend: EventHandler { + get { ClosureAttribute1Optional[Strings.ondragend, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.ondragend, in: jsObject] = newValue } + } + + @inlinable var ondragenter: EventHandler { + get { ClosureAttribute1Optional[Strings.ondragenter, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.ondragenter, in: jsObject] = newValue } + } + + @inlinable var ondragleave: EventHandler { + get { ClosureAttribute1Optional[Strings.ondragleave, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.ondragleave, in: jsObject] = newValue } + } + + @inlinable var ondragover: EventHandler { + get { ClosureAttribute1Optional[Strings.ondragover, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.ondragover, in: jsObject] = newValue } + } + + @inlinable var ondragstart: EventHandler { + get { ClosureAttribute1Optional[Strings.ondragstart, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.ondragstart, in: jsObject] = newValue } + } + + @inlinable var ondrop: EventHandler { + get { ClosureAttribute1Optional[Strings.ondrop, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.ondrop, in: jsObject] = newValue } + } + + @inlinable var ondurationchange: EventHandler { + get { ClosureAttribute1Optional[Strings.ondurationchange, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.ondurationchange, in: jsObject] = newValue } + } + + @inlinable var onemptied: EventHandler { + get { ClosureAttribute1Optional[Strings.onemptied, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onemptied, in: jsObject] = newValue } + } + + @inlinable var onended: EventHandler { + get { ClosureAttribute1Optional[Strings.onended, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onended, in: jsObject] = newValue } + } + + @inlinable var onerror: OnErrorEventHandler { + get { ClosureAttribute5Optional[Strings.onerror, in: jsObject] } + nonmutating set { ClosureAttribute5Optional[Strings.onerror, in: jsObject] = newValue } + } + + @inlinable var onfocus: EventHandler { + get { ClosureAttribute1Optional[Strings.onfocus, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onfocus, in: jsObject] = newValue } + } + + @inlinable var onformdata: EventHandler { + get { ClosureAttribute1Optional[Strings.onformdata, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onformdata, in: jsObject] = newValue } + } + + @inlinable var oninput: EventHandler { + get { ClosureAttribute1Optional[Strings.oninput, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.oninput, in: jsObject] = newValue } + } + + @inlinable var oninvalid: EventHandler { + get { ClosureAttribute1Optional[Strings.oninvalid, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.oninvalid, in: jsObject] = newValue } + } + + @inlinable var onkeydown: EventHandler { + get { ClosureAttribute1Optional[Strings.onkeydown, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onkeydown, in: jsObject] = newValue } + } + + @inlinable var onkeypress: EventHandler { + get { ClosureAttribute1Optional[Strings.onkeypress, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onkeypress, in: jsObject] = newValue } + } + + @inlinable var onkeyup: EventHandler { + get { ClosureAttribute1Optional[Strings.onkeyup, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onkeyup, in: jsObject] = newValue } + } + + @inlinable var onload: EventHandler { + get { ClosureAttribute1Optional[Strings.onload, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onload, in: jsObject] = newValue } + } + + @inlinable var onloadeddata: EventHandler { + get { ClosureAttribute1Optional[Strings.onloadeddata, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onloadeddata, in: jsObject] = newValue } + } + + @inlinable var onloadedmetadata: EventHandler { + get { ClosureAttribute1Optional[Strings.onloadedmetadata, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onloadedmetadata, in: jsObject] = newValue } + } + + @inlinable var onloadstart: EventHandler { + get { ClosureAttribute1Optional[Strings.onloadstart, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onloadstart, in: jsObject] = newValue } + } + + @inlinable var onmousedown: EventHandler { + get { ClosureAttribute1Optional[Strings.onmousedown, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onmousedown, in: jsObject] = newValue } + } + + @inlinable var onmouseenter: EventHandler { + get { ClosureAttribute1Optional[Strings.onmouseenter, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onmouseenter, in: jsObject] = newValue } + } + + @inlinable var onmouseleave: EventHandler { + get { ClosureAttribute1Optional[Strings.onmouseleave, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onmouseleave, in: jsObject] = newValue } + } + + @inlinable var onmousemove: EventHandler { + get { ClosureAttribute1Optional[Strings.onmousemove, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onmousemove, in: jsObject] = newValue } + } + + @inlinable var onmouseout: EventHandler { + get { ClosureAttribute1Optional[Strings.onmouseout, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onmouseout, in: jsObject] = newValue } + } + + @inlinable var onmouseover: EventHandler { + get { ClosureAttribute1Optional[Strings.onmouseover, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onmouseover, in: jsObject] = newValue } + } + + @inlinable var onmouseup: EventHandler { + get { ClosureAttribute1Optional[Strings.onmouseup, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onmouseup, in: jsObject] = newValue } + } + + @inlinable var onpause: EventHandler { + get { ClosureAttribute1Optional[Strings.onpause, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onpause, in: jsObject] = newValue } + } + + @inlinable var onplay: EventHandler { + get { ClosureAttribute1Optional[Strings.onplay, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onplay, in: jsObject] = newValue } + } + + @inlinable var onplaying: EventHandler { + get { ClosureAttribute1Optional[Strings.onplaying, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onplaying, in: jsObject] = newValue } + } + + @inlinable var onprogress: EventHandler { + get { ClosureAttribute1Optional[Strings.onprogress, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onprogress, in: jsObject] = newValue } + } + + @inlinable var onratechange: EventHandler { + get { ClosureAttribute1Optional[Strings.onratechange, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onratechange, in: jsObject] = newValue } + } + + @inlinable var onreset: EventHandler { + get { ClosureAttribute1Optional[Strings.onreset, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onreset, in: jsObject] = newValue } + } + + @inlinable var onresize: EventHandler { + get { ClosureAttribute1Optional[Strings.onresize, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onresize, in: jsObject] = newValue } + } + + @inlinable var onscroll: EventHandler { + get { ClosureAttribute1Optional[Strings.onscroll, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onscroll, in: jsObject] = newValue } + } + + @inlinable var onsecuritypolicyviolation: EventHandler { + get { ClosureAttribute1Optional[Strings.onsecuritypolicyviolation, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onsecuritypolicyviolation, in: jsObject] = newValue } + } + + @inlinable var onseeked: EventHandler { + get { ClosureAttribute1Optional[Strings.onseeked, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onseeked, in: jsObject] = newValue } + } + + @inlinable var onseeking: EventHandler { + get { ClosureAttribute1Optional[Strings.onseeking, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onseeking, in: jsObject] = newValue } + } + + @inlinable var onselect: EventHandler { + get { ClosureAttribute1Optional[Strings.onselect, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onselect, in: jsObject] = newValue } + } + + @inlinable var onslotchange: EventHandler { + get { ClosureAttribute1Optional[Strings.onslotchange, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onslotchange, in: jsObject] = newValue } + } + + @inlinable var onstalled: EventHandler { + get { ClosureAttribute1Optional[Strings.onstalled, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onstalled, in: jsObject] = newValue } + } + + @inlinable var onsubmit: EventHandler { + get { ClosureAttribute1Optional[Strings.onsubmit, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onsubmit, in: jsObject] = newValue } + } + + @inlinable var onsuspend: EventHandler { + get { ClosureAttribute1Optional[Strings.onsuspend, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onsuspend, in: jsObject] = newValue } + } + + @inlinable var ontimeupdate: EventHandler { + get { ClosureAttribute1Optional[Strings.ontimeupdate, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.ontimeupdate, in: jsObject] = newValue } + } + + @inlinable var ontoggle: EventHandler { + get { ClosureAttribute1Optional[Strings.ontoggle, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.ontoggle, in: jsObject] = newValue } + } + + @inlinable var onvolumechange: EventHandler { + get { ClosureAttribute1Optional[Strings.onvolumechange, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onvolumechange, in: jsObject] = newValue } + } + + @inlinable var onwaiting: EventHandler { + get { ClosureAttribute1Optional[Strings.onwaiting, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onwaiting, in: jsObject] = newValue } + } + + @inlinable var onwebkitanimationend: EventHandler { + get { ClosureAttribute1Optional[Strings.onwebkitanimationend, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onwebkitanimationend, in: jsObject] = newValue } + } + + @inlinable var onwebkitanimationiteration: EventHandler { + get { ClosureAttribute1Optional[Strings.onwebkitanimationiteration, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onwebkitanimationiteration, in: jsObject] = newValue } + } + + @inlinable var onwebkitanimationstart: EventHandler { + get { ClosureAttribute1Optional[Strings.onwebkitanimationstart, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onwebkitanimationstart, in: jsObject] = newValue } + } + + @inlinable var onwebkittransitionend: EventHandler { + get { ClosureAttribute1Optional[Strings.onwebkittransitionend, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onwebkittransitionend, in: jsObject] = newValue } + } + + @inlinable var onwheel: EventHandler { + get { ClosureAttribute1Optional[Strings.onwheel, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onwheel, in: jsObject] = newValue } + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLAllCollection.swift b/Sources/DOMKit/WebIDL/HTMLAllCollection.swift new file mode 100644 index 00000000..6aec5e93 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLAllCollection.swift @@ -0,0 +1,31 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLAllCollection: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.HTMLAllCollection].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var length: UInt32 + + @inlinable public subscript(key: Int) -> Element { + jsObject[key].fromJSValue()! + } + + @inlinable public subscript(key: String) -> Element_or_HTMLCollection? { + jsObject[key].fromJSValue() + } + + @inlinable public func item(nameOrIndex: String? = nil) -> Element_or_HTMLCollection? { + let this = jsObject + return this[Strings.item].function!(this: this, arguments: [nameOrIndex?.jsValue ?? .undefined]).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLAnchorElement.swift b/Sources/DOMKit/WebIDL/HTMLAnchorElement.swift new file mode 100644 index 00000000..be82d0bf --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLAnchorElement.swift @@ -0,0 +1,72 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLAnchorElement: HTMLElement, HTMLHyperlinkElementUtils { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLAnchorElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _target = ReadWriteAttribute(jsObject: jsObject, name: Strings.target) + _download = ReadWriteAttribute(jsObject: jsObject, name: Strings.download) + _ping = ReadWriteAttribute(jsObject: jsObject, name: Strings.ping) + _rel = ReadWriteAttribute(jsObject: jsObject, name: Strings.rel) + _relList = ReadonlyAttribute(jsObject: jsObject, name: Strings.relList) + _hreflang = ReadWriteAttribute(jsObject: jsObject, name: Strings.hreflang) + _type = ReadWriteAttribute(jsObject: jsObject, name: Strings.type) + _text = ReadWriteAttribute(jsObject: jsObject, name: Strings.text) + _referrerPolicy = ReadWriteAttribute(jsObject: jsObject, name: Strings.referrerPolicy) + _coords = ReadWriteAttribute(jsObject: jsObject, name: Strings.coords) + _charset = ReadWriteAttribute(jsObject: jsObject, name: Strings.charset) + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _rev = ReadWriteAttribute(jsObject: jsObject, name: Strings.rev) + _shape = ReadWriteAttribute(jsObject: jsObject, name: Strings.shape) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var target: String + + @ReadWriteAttribute + public var download: String + + @ReadWriteAttribute + public var ping: String + + @ReadWriteAttribute + public var rel: String + + @ReadonlyAttribute + public var relList: DOMTokenList + + @ReadWriteAttribute + public var hreflang: String + + @ReadWriteAttribute + public var type: String + + @ReadWriteAttribute + public var text: String + + @ReadWriteAttribute + public var referrerPolicy: String + + @ReadWriteAttribute + public var coords: String + + @ReadWriteAttribute + public var charset: String + + @ReadWriteAttribute + public var name: String + + @ReadWriteAttribute + public var rev: String + + @ReadWriteAttribute + public var shape: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLAreaElement.swift b/Sources/DOMKit/WebIDL/HTMLAreaElement.swift new file mode 100644 index 00000000..edb88a62 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLAreaElement.swift @@ -0,0 +1,56 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLAreaElement: HTMLElement, HTMLHyperlinkElementUtils { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLAreaElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _alt = ReadWriteAttribute(jsObject: jsObject, name: Strings.alt) + _coords = ReadWriteAttribute(jsObject: jsObject, name: Strings.coords) + _shape = ReadWriteAttribute(jsObject: jsObject, name: Strings.shape) + _target = ReadWriteAttribute(jsObject: jsObject, name: Strings.target) + _download = ReadWriteAttribute(jsObject: jsObject, name: Strings.download) + _ping = ReadWriteAttribute(jsObject: jsObject, name: Strings.ping) + _rel = ReadWriteAttribute(jsObject: jsObject, name: Strings.rel) + _relList = ReadonlyAttribute(jsObject: jsObject, name: Strings.relList) + _referrerPolicy = ReadWriteAttribute(jsObject: jsObject, name: Strings.referrerPolicy) + _noHref = ReadWriteAttribute(jsObject: jsObject, name: Strings.noHref) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var alt: String + + @ReadWriteAttribute + public var coords: String + + @ReadWriteAttribute + public var shape: String + + @ReadWriteAttribute + public var target: String + + @ReadWriteAttribute + public var download: String + + @ReadWriteAttribute + public var ping: String + + @ReadWriteAttribute + public var rel: String + + @ReadonlyAttribute + public var relList: DOMTokenList + + @ReadWriteAttribute + public var referrerPolicy: String + + @ReadWriteAttribute + public var noHref: Bool +} diff --git a/Sources/DOMKit/WebIDL/HTMLAudioElement.swift b/Sources/DOMKit/WebIDL/HTMLAudioElement.swift new file mode 100644 index 00000000..18ef1c2d --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLAudioElement.swift @@ -0,0 +1,16 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLAudioElement: HTMLMediaElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLAudioElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLBRElement.swift b/Sources/DOMKit/WebIDL/HTMLBRElement.swift new file mode 100644 index 00000000..909dc0e8 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLBRElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLBRElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLBRElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _clear = ReadWriteAttribute(jsObject: jsObject, name: Strings.clear) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var clear: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLBaseElement.swift b/Sources/DOMKit/WebIDL/HTMLBaseElement.swift new file mode 100644 index 00000000..706fd766 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLBaseElement.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLBaseElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLBaseElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _href = ReadWriteAttribute(jsObject: jsObject, name: Strings.href) + _target = ReadWriteAttribute(jsObject: jsObject, name: Strings.target) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var href: String + + @ReadWriteAttribute + public var target: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLBodyElement.swift b/Sources/DOMKit/WebIDL/HTMLBodyElement.swift new file mode 100644 index 00000000..2597a3cb --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLBodyElement.swift @@ -0,0 +1,40 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLBodyElement: HTMLElement, WindowEventHandlers { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLBodyElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _text = ReadWriteAttribute(jsObject: jsObject, name: Strings.text) + _link = ReadWriteAttribute(jsObject: jsObject, name: Strings.link) + _vLink = ReadWriteAttribute(jsObject: jsObject, name: Strings.vLink) + _aLink = ReadWriteAttribute(jsObject: jsObject, name: Strings.aLink) + _bgColor = ReadWriteAttribute(jsObject: jsObject, name: Strings.bgColor) + _background = ReadWriteAttribute(jsObject: jsObject, name: Strings.background) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var text: String + + @ReadWriteAttribute + public var link: String + + @ReadWriteAttribute + public var vLink: String + + @ReadWriteAttribute + public var aLink: String + + @ReadWriteAttribute + public var bgColor: String + + @ReadWriteAttribute + public var background: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLButtonElement.swift b/Sources/DOMKit/WebIDL/HTMLButtonElement.swift new file mode 100644 index 00000000..2b7112a4 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLButtonElement.swift @@ -0,0 +1,87 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLButtonElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLButtonElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _disabled = ReadWriteAttribute(jsObject: jsObject, name: Strings.disabled) + _form = ReadonlyAttribute(jsObject: jsObject, name: Strings.form) + _formAction = ReadWriteAttribute(jsObject: jsObject, name: Strings.formAction) + _formEnctype = ReadWriteAttribute(jsObject: jsObject, name: Strings.formEnctype) + _formMethod = ReadWriteAttribute(jsObject: jsObject, name: Strings.formMethod) + _formNoValidate = ReadWriteAttribute(jsObject: jsObject, name: Strings.formNoValidate) + _formTarget = ReadWriteAttribute(jsObject: jsObject, name: Strings.formTarget) + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _type = ReadWriteAttribute(jsObject: jsObject, name: Strings.type) + _value = ReadWriteAttribute(jsObject: jsObject, name: Strings.value) + _willValidate = ReadonlyAttribute(jsObject: jsObject, name: Strings.willValidate) + _validity = ReadonlyAttribute(jsObject: jsObject, name: Strings.validity) + _validationMessage = ReadonlyAttribute(jsObject: jsObject, name: Strings.validationMessage) + _labels = ReadonlyAttribute(jsObject: jsObject, name: Strings.labels) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var disabled: Bool + + @ReadonlyAttribute + public var form: HTMLFormElement? + + @ReadWriteAttribute + public var formAction: String + + @ReadWriteAttribute + public var formEnctype: String + + @ReadWriteAttribute + public var formMethod: String + + @ReadWriteAttribute + public var formNoValidate: Bool + + @ReadWriteAttribute + public var formTarget: String + + @ReadWriteAttribute + public var name: String + + @ReadWriteAttribute + public var type: String + + @ReadWriteAttribute + public var value: String + + @ReadonlyAttribute + public var willValidate: Bool + + @ReadonlyAttribute + public var validity: ValidityState + + @ReadonlyAttribute + public var validationMessage: String + + @inlinable public func checkValidity() -> Bool { + let this = jsObject + return this[Strings.checkValidity].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func reportValidity() -> Bool { + let this = jsObject + return this[Strings.reportValidity].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func setCustomValidity(error: String) { + let this = jsObject + _ = this[Strings.setCustomValidity].function!(this: this, arguments: [error.jsValue]) + } + + @ReadonlyAttribute + public var labels: NodeList +} diff --git a/Sources/DOMKit/WebIDL/HTMLCanvasElement.swift b/Sources/DOMKit/WebIDL/HTMLCanvasElement.swift new file mode 100644 index 00000000..6d29b873 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLCanvasElement.swift @@ -0,0 +1,41 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLCanvasElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLCanvasElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + _height = ReadWriteAttribute(jsObject: jsObject, name: Strings.height) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var width: UInt32 + + @ReadWriteAttribute + public var height: UInt32 + + @inlinable public func getContext(contextId: String, options: JSValue? = nil) -> RenderingContext? { + let this = jsObject + return this[Strings.getContext].function!(this: this, arguments: [contextId.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func toDataURL(type: String? = nil, quality: JSValue? = nil) -> String { + let this = jsObject + return this[Strings.toDataURL].function!(this: this, arguments: [type?.jsValue ?? .undefined, quality?.jsValue ?? .undefined]).fromJSValue()! + } + + // XXX: member 'toBlob' is ignored + + @inlinable public func transferControlToOffscreen() -> OffscreenCanvas { + let this = jsObject + return this[Strings.transferControlToOffscreen].function!(this: this, arguments: []).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLCanvasElement_or_OffscreenCanvas.swift b/Sources/DOMKit/WebIDL/HTMLCanvasElement_or_OffscreenCanvas.swift new file mode 100644 index 00000000..99288d31 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLCanvasElement_or_OffscreenCanvas.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_HTMLCanvasElement_or_OffscreenCanvas: ConvertibleToJSValue {} +extension HTMLCanvasElement: Any_HTMLCanvasElement_or_OffscreenCanvas {} +extension OffscreenCanvas: Any_HTMLCanvasElement_or_OffscreenCanvas {} + +public enum HTMLCanvasElement_or_OffscreenCanvas: JSValueCompatible, Any_HTMLCanvasElement_or_OffscreenCanvas { + case htmlCanvasElement(HTMLCanvasElement) + case offscreenCanvas(OffscreenCanvas) + + var htmlCanvasElement: HTMLCanvasElement? { + switch self { + case let .htmlCanvasElement(htmlCanvasElement): return htmlCanvasElement + default: return nil + } + } + + var offscreenCanvas: OffscreenCanvas? { + switch self { + case let .offscreenCanvas(offscreenCanvas): return offscreenCanvas + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let htmlCanvasElement: HTMLCanvasElement = value.fromJSValue() { + return .htmlCanvasElement(htmlCanvasElement) + } + if let offscreenCanvas: OffscreenCanvas = value.fromJSValue() { + return .offscreenCanvas(offscreenCanvas) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .htmlCanvasElement(htmlCanvasElement): + return htmlCanvasElement.jsValue + case let .offscreenCanvas(offscreenCanvas): + return offscreenCanvas.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLCollection.swift b/Sources/DOMKit/WebIDL/HTMLCollection.swift index 8b4b1622..4597482a 100644 --- a/Sources/DOMKit/WebIDL/HTMLCollection.swift +++ b/Sources/DOMKit/WebIDL/HTMLCollection.swift @@ -1,24 +1,26 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class HTMLCollection: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.HTMLCollection.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.HTMLCollection].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _length = ReadonlyAttribute(jsObject: jsObject, name: "length") + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) self.jsObject = jsObject } - public subscript(_: String) -> Element?? { - return jsObject.name.fromJSValue()! - } - @ReadonlyAttribute public var length: UInt32 + + @inlinable public subscript(key: Int) -> Element? { + jsObject[key].fromJSValue() + } + + @inlinable public subscript(key: String) -> Element? { + jsObject[key].fromJSValue() + } } diff --git a/Sources/DOMKit/WebIDL/HTMLDListElement.swift b/Sources/DOMKit/WebIDL/HTMLDListElement.swift new file mode 100644 index 00000000..084fa859 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLDListElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLDListElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLDListElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _compact = ReadWriteAttribute(jsObject: jsObject, name: Strings.compact) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var compact: Bool +} diff --git a/Sources/DOMKit/WebIDL/HTMLDataElement.swift b/Sources/DOMKit/WebIDL/HTMLDataElement.swift new file mode 100644 index 00000000..7366bf0c --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLDataElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLDataElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLDataElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _value = ReadWriteAttribute(jsObject: jsObject, name: Strings.value) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var value: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLDataListElement.swift b/Sources/DOMKit/WebIDL/HTMLDataListElement.swift new file mode 100644 index 00000000..84ec303e --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLDataListElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLDataListElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLDataListElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _options = ReadonlyAttribute(jsObject: jsObject, name: Strings.options) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadonlyAttribute + public var options: HTMLCollection +} diff --git a/Sources/DOMKit/WebIDL/HTMLDetailsElement.swift b/Sources/DOMKit/WebIDL/HTMLDetailsElement.swift new file mode 100644 index 00000000..a0383357 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLDetailsElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLDetailsElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLDetailsElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _open = ReadWriteAttribute(jsObject: jsObject, name: Strings.open) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var open: Bool +} diff --git a/Sources/DOMKit/WebIDL/HTMLDialogElement.swift b/Sources/DOMKit/WebIDL/HTMLDialogElement.swift new file mode 100644 index 00000000..cbd398b3 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLDialogElement.swift @@ -0,0 +1,39 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLDialogElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLDialogElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _open = ReadWriteAttribute(jsObject: jsObject, name: Strings.open) + _returnValue = ReadWriteAttribute(jsObject: jsObject, name: Strings.returnValue) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var open: Bool + + @ReadWriteAttribute + public var returnValue: String + + @inlinable public func show() { + let this = jsObject + _ = this[Strings.show].function!(this: this, arguments: []) + } + + @inlinable public func showModal() { + let this = jsObject + _ = this[Strings.showModal].function!(this: this, arguments: []) + } + + @inlinable public func close(returnValue: String? = nil) { + let this = jsObject + _ = this[Strings.close].function!(this: this, arguments: [returnValue?.jsValue ?? .undefined]) + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLDirectoryElement.swift b/Sources/DOMKit/WebIDL/HTMLDirectoryElement.swift new file mode 100644 index 00000000..840849e5 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLDirectoryElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLDirectoryElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLDirectoryElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _compact = ReadWriteAttribute(jsObject: jsObject, name: Strings.compact) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var compact: Bool +} diff --git a/Sources/DOMKit/WebIDL/HTMLDivElement.swift b/Sources/DOMKit/WebIDL/HTMLDivElement.swift new file mode 100644 index 00000000..437437a4 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLDivElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLDivElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLDivElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var align: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLElement+EventHandler.swift b/Sources/DOMKit/WebIDL/HTMLElement+EventHandler.swift deleted file mode 100644 index 41d678e8..00000000 --- a/Sources/DOMKit/WebIDL/HTMLElement+EventHandler.swift +++ /dev/null @@ -1,1549 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public extension HTMLElement { - var onabort: EventHandler { - get { - guard let function = jsObject.onabort.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onabort"] { - oldClosure.release() - } - eventHandlerClosures["onabort"] = closure - jsObject.onabort = closure.jsValue() - } else { - jsObject.onabort = .null - } - } - } - - var onauxclick: EventHandler { - get { - guard let function = jsObject.onauxclick.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onauxclick"] { - oldClosure.release() - } - eventHandlerClosures["onauxclick"] = closure - jsObject.onauxclick = closure.jsValue() - } else { - jsObject.onauxclick = .null - } - } - } - - var onblur: EventHandler { - get { - guard let function = jsObject.onblur.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onblur"] { - oldClosure.release() - } - eventHandlerClosures["onblur"] = closure - jsObject.onblur = closure.jsValue() - } else { - jsObject.onblur = .null - } - } - } - - var oncancel: EventHandler { - get { - guard let function = jsObject.oncancel.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["oncancel"] { - oldClosure.release() - } - eventHandlerClosures["oncancel"] = closure - jsObject.oncancel = closure.jsValue() - } else { - jsObject.oncancel = .null - } - } - } - - var oncanplay: EventHandler { - get { - guard let function = jsObject.oncanplay.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["oncanplay"] { - oldClosure.release() - } - eventHandlerClosures["oncanplay"] = closure - jsObject.oncanplay = closure.jsValue() - } else { - jsObject.oncanplay = .null - } - } - } - - var oncanplaythrough: EventHandler { - get { - guard let function = jsObject.oncanplaythrough.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["oncanplaythrough"] { - oldClosure.release() - } - eventHandlerClosures["oncanplaythrough"] = closure - jsObject.oncanplaythrough = closure.jsValue() - } else { - jsObject.oncanplaythrough = .null - } - } - } - - var onchange: EventHandler { - get { - guard let function = jsObject.onchange.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onchange"] { - oldClosure.release() - } - eventHandlerClosures["onchange"] = closure - jsObject.onchange = closure.jsValue() - } else { - jsObject.onchange = .null - } - } - } - - var onclick: EventHandler { - get { - guard let function = jsObject.onclick.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onclick"] { - oldClosure.release() - } - eventHandlerClosures["onclick"] = closure - jsObject.onclick = closure.jsValue() - } else { - jsObject.onclick = .null - } - } - } - - var onclose: EventHandler { - get { - guard let function = jsObject.onclose.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onclose"] { - oldClosure.release() - } - eventHandlerClosures["onclose"] = closure - jsObject.onclose = closure.jsValue() - } else { - jsObject.onclose = .null - } - } - } - - var oncontextmenu: EventHandler { - get { - guard let function = jsObject.oncontextmenu.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["oncontextmenu"] { - oldClosure.release() - } - eventHandlerClosures["oncontextmenu"] = closure - jsObject.oncontextmenu = closure.jsValue() - } else { - jsObject.oncontextmenu = .null - } - } - } - - var oncuechange: EventHandler { - get { - guard let function = jsObject.oncuechange.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["oncuechange"] { - oldClosure.release() - } - eventHandlerClosures["oncuechange"] = closure - jsObject.oncuechange = closure.jsValue() - } else { - jsObject.oncuechange = .null - } - } - } - - var ondblclick: EventHandler { - get { - guard let function = jsObject.ondblclick.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["ondblclick"] { - oldClosure.release() - } - eventHandlerClosures["ondblclick"] = closure - jsObject.ondblclick = closure.jsValue() - } else { - jsObject.ondblclick = .null - } - } - } - - var ondrag: EventHandler { - get { - guard let function = jsObject.ondrag.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["ondrag"] { - oldClosure.release() - } - eventHandlerClosures["ondrag"] = closure - jsObject.ondrag = closure.jsValue() - } else { - jsObject.ondrag = .null - } - } - } - - var ondragend: EventHandler { - get { - guard let function = jsObject.ondragend.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["ondragend"] { - oldClosure.release() - } - eventHandlerClosures["ondragend"] = closure - jsObject.ondragend = closure.jsValue() - } else { - jsObject.ondragend = .null - } - } - } - - var ondragenter: EventHandler { - get { - guard let function = jsObject.ondragenter.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["ondragenter"] { - oldClosure.release() - } - eventHandlerClosures["ondragenter"] = closure - jsObject.ondragenter = closure.jsValue() - } else { - jsObject.ondragenter = .null - } - } - } - - var ondragexit: EventHandler { - get { - guard let function = jsObject.ondragexit.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["ondragexit"] { - oldClosure.release() - } - eventHandlerClosures["ondragexit"] = closure - jsObject.ondragexit = closure.jsValue() - } else { - jsObject.ondragexit = .null - } - } - } - - var ondragleave: EventHandler { - get { - guard let function = jsObject.ondragleave.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["ondragleave"] { - oldClosure.release() - } - eventHandlerClosures["ondragleave"] = closure - jsObject.ondragleave = closure.jsValue() - } else { - jsObject.ondragleave = .null - } - } - } - - var ondragover: EventHandler { - get { - guard let function = jsObject.ondragover.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["ondragover"] { - oldClosure.release() - } - eventHandlerClosures["ondragover"] = closure - jsObject.ondragover = closure.jsValue() - } else { - jsObject.ondragover = .null - } - } - } - - var ondragstart: EventHandler { - get { - guard let function = jsObject.ondragstart.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["ondragstart"] { - oldClosure.release() - } - eventHandlerClosures["ondragstart"] = closure - jsObject.ondragstart = closure.jsValue() - } else { - jsObject.ondragstart = .null - } - } - } - - var ondrop: EventHandler { - get { - guard let function = jsObject.ondrop.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["ondrop"] { - oldClosure.release() - } - eventHandlerClosures["ondrop"] = closure - jsObject.ondrop = closure.jsValue() - } else { - jsObject.ondrop = .null - } - } - } - - var ondurationchange: EventHandler { - get { - guard let function = jsObject.ondurationchange.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["ondurationchange"] { - oldClosure.release() - } - eventHandlerClosures["ondurationchange"] = closure - jsObject.ondurationchange = closure.jsValue() - } else { - jsObject.ondurationchange = .null - } - } - } - - var onemptied: EventHandler { - get { - guard let function = jsObject.onemptied.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onemptied"] { - oldClosure.release() - } - eventHandlerClosures["onemptied"] = closure - jsObject.onemptied = closure.jsValue() - } else { - jsObject.onemptied = .null - } - } - } - - var onended: EventHandler { - get { - guard let function = jsObject.onended.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onended"] { - oldClosure.release() - } - eventHandlerClosures["onended"] = closure - jsObject.onended = closure.jsValue() - } else { - jsObject.onended = .null - } - } - } - - var onerror: OnErrorEventHandler { - get { - guard let function = jsObject.onerror.function else { - return nil - } - return { arg0, arg1, arg2, arg3, arg4 in function(arg0, arg1, arg2, arg3, arg4).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!, arguments[1].fromJSValue()!, arguments[2].fromJSValue()!, arguments[3].fromJSValue()!, arguments[4].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onerror"] { - oldClosure.release() - } - eventHandlerClosures["onerror"] = closure - jsObject.onerror = closure.jsValue() - } else { - jsObject.onerror = .null - } - } - } - - var onfocus: EventHandler { - get { - guard let function = jsObject.onfocus.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onfocus"] { - oldClosure.release() - } - eventHandlerClosures["onfocus"] = closure - jsObject.onfocus = closure.jsValue() - } else { - jsObject.onfocus = .null - } - } - } - - var onformdata: EventHandler { - get { - guard let function = jsObject.onformdata.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onformdata"] { - oldClosure.release() - } - eventHandlerClosures["onformdata"] = closure - jsObject.onformdata = closure.jsValue() - } else { - jsObject.onformdata = .null - } - } - } - - var oninput: EventHandler { - get { - guard let function = jsObject.oninput.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["oninput"] { - oldClosure.release() - } - eventHandlerClosures["oninput"] = closure - jsObject.oninput = closure.jsValue() - } else { - jsObject.oninput = .null - } - } - } - - var oninvalid: EventHandler { - get { - guard let function = jsObject.oninvalid.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["oninvalid"] { - oldClosure.release() - } - eventHandlerClosures["oninvalid"] = closure - jsObject.oninvalid = closure.jsValue() - } else { - jsObject.oninvalid = .null - } - } - } - - var onkeydown: EventHandler { - get { - guard let function = jsObject.onkeydown.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onkeydown"] { - oldClosure.release() - } - eventHandlerClosures["onkeydown"] = closure - jsObject.onkeydown = closure.jsValue() - } else { - jsObject.onkeydown = .null - } - } - } - - var onkeypress: EventHandler { - get { - guard let function = jsObject.onkeypress.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onkeypress"] { - oldClosure.release() - } - eventHandlerClosures["onkeypress"] = closure - jsObject.onkeypress = closure.jsValue() - } else { - jsObject.onkeypress = .null - } - } - } - - var onkeyup: EventHandler { - get { - guard let function = jsObject.onkeyup.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onkeyup"] { - oldClosure.release() - } - eventHandlerClosures["onkeyup"] = closure - jsObject.onkeyup = closure.jsValue() - } else { - jsObject.onkeyup = .null - } - } - } - - var onload: EventHandler { - get { - guard let function = jsObject.onload.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onload"] { - oldClosure.release() - } - eventHandlerClosures["onload"] = closure - jsObject.onload = closure.jsValue() - } else { - jsObject.onload = .null - } - } - } - - var onloadeddata: EventHandler { - get { - guard let function = jsObject.onloadeddata.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onloadeddata"] { - oldClosure.release() - } - eventHandlerClosures["onloadeddata"] = closure - jsObject.onloadeddata = closure.jsValue() - } else { - jsObject.onloadeddata = .null - } - } - } - - var onloadedmetadata: EventHandler { - get { - guard let function = jsObject.onloadedmetadata.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onloadedmetadata"] { - oldClosure.release() - } - eventHandlerClosures["onloadedmetadata"] = closure - jsObject.onloadedmetadata = closure.jsValue() - } else { - jsObject.onloadedmetadata = .null - } - } - } - - var onloadstart: EventHandler { - get { - guard let function = jsObject.onloadstart.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onloadstart"] { - oldClosure.release() - } - eventHandlerClosures["onloadstart"] = closure - jsObject.onloadstart = closure.jsValue() - } else { - jsObject.onloadstart = .null - } - } - } - - var onmousedown: EventHandler { - get { - guard let function = jsObject.onmousedown.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onmousedown"] { - oldClosure.release() - } - eventHandlerClosures["onmousedown"] = closure - jsObject.onmousedown = closure.jsValue() - } else { - jsObject.onmousedown = .null - } - } - } - - var onmouseenter: EventHandler { - get { - guard let function = jsObject.onmouseenter.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onmouseenter"] { - oldClosure.release() - } - eventHandlerClosures["onmouseenter"] = closure - jsObject.onmouseenter = closure.jsValue() - } else { - jsObject.onmouseenter = .null - } - } - } - - var onmouseleave: EventHandler { - get { - guard let function = jsObject.onmouseleave.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onmouseleave"] { - oldClosure.release() - } - eventHandlerClosures["onmouseleave"] = closure - jsObject.onmouseleave = closure.jsValue() - } else { - jsObject.onmouseleave = .null - } - } - } - - var onmousemove: EventHandler { - get { - guard let function = jsObject.onmousemove.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onmousemove"] { - oldClosure.release() - } - eventHandlerClosures["onmousemove"] = closure - jsObject.onmousemove = closure.jsValue() - } else { - jsObject.onmousemove = .null - } - } - } - - var onmouseout: EventHandler { - get { - guard let function = jsObject.onmouseout.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onmouseout"] { - oldClosure.release() - } - eventHandlerClosures["onmouseout"] = closure - jsObject.onmouseout = closure.jsValue() - } else { - jsObject.onmouseout = .null - } - } - } - - var onmouseover: EventHandler { - get { - guard let function = jsObject.onmouseover.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onmouseover"] { - oldClosure.release() - } - eventHandlerClosures["onmouseover"] = closure - jsObject.onmouseover = closure.jsValue() - } else { - jsObject.onmouseover = .null - } - } - } - - var onmouseup: EventHandler { - get { - guard let function = jsObject.onmouseup.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onmouseup"] { - oldClosure.release() - } - eventHandlerClosures["onmouseup"] = closure - jsObject.onmouseup = closure.jsValue() - } else { - jsObject.onmouseup = .null - } - } - } - - var onpause: EventHandler { - get { - guard let function = jsObject.onpause.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onpause"] { - oldClosure.release() - } - eventHandlerClosures["onpause"] = closure - jsObject.onpause = closure.jsValue() - } else { - jsObject.onpause = .null - } - } - } - - var onplay: EventHandler { - get { - guard let function = jsObject.onplay.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onplay"] { - oldClosure.release() - } - eventHandlerClosures["onplay"] = closure - jsObject.onplay = closure.jsValue() - } else { - jsObject.onplay = .null - } - } - } - - var onplaying: EventHandler { - get { - guard let function = jsObject.onplaying.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onplaying"] { - oldClosure.release() - } - eventHandlerClosures["onplaying"] = closure - jsObject.onplaying = closure.jsValue() - } else { - jsObject.onplaying = .null - } - } - } - - var onprogress: EventHandler { - get { - guard let function = jsObject.onprogress.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onprogress"] { - oldClosure.release() - } - eventHandlerClosures["onprogress"] = closure - jsObject.onprogress = closure.jsValue() - } else { - jsObject.onprogress = .null - } - } - } - - var onratechange: EventHandler { - get { - guard let function = jsObject.onratechange.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onratechange"] { - oldClosure.release() - } - eventHandlerClosures["onratechange"] = closure - jsObject.onratechange = closure.jsValue() - } else { - jsObject.onratechange = .null - } - } - } - - var onreset: EventHandler { - get { - guard let function = jsObject.onreset.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onreset"] { - oldClosure.release() - } - eventHandlerClosures["onreset"] = closure - jsObject.onreset = closure.jsValue() - } else { - jsObject.onreset = .null - } - } - } - - var onresize: EventHandler { - get { - guard let function = jsObject.onresize.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onresize"] { - oldClosure.release() - } - eventHandlerClosures["onresize"] = closure - jsObject.onresize = closure.jsValue() - } else { - jsObject.onresize = .null - } - } - } - - var onscroll: EventHandler { - get { - guard let function = jsObject.onscroll.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onscroll"] { - oldClosure.release() - } - eventHandlerClosures["onscroll"] = closure - jsObject.onscroll = closure.jsValue() - } else { - jsObject.onscroll = .null - } - } - } - - var onsecuritypolicyviolation: EventHandler { - get { - guard let function = jsObject.onsecuritypolicyviolation.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onsecuritypolicyviolation"] { - oldClosure.release() - } - eventHandlerClosures["onsecuritypolicyviolation"] = closure - jsObject.onsecuritypolicyviolation = closure.jsValue() - } else { - jsObject.onsecuritypolicyviolation = .null - } - } - } - - var onseeked: EventHandler { - get { - guard let function = jsObject.onseeked.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onseeked"] { - oldClosure.release() - } - eventHandlerClosures["onseeked"] = closure - jsObject.onseeked = closure.jsValue() - } else { - jsObject.onseeked = .null - } - } - } - - var onseeking: EventHandler { - get { - guard let function = jsObject.onseeking.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onseeking"] { - oldClosure.release() - } - eventHandlerClosures["onseeking"] = closure - jsObject.onseeking = closure.jsValue() - } else { - jsObject.onseeking = .null - } - } - } - - var onselect: EventHandler { - get { - guard let function = jsObject.onselect.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onselect"] { - oldClosure.release() - } - eventHandlerClosures["onselect"] = closure - jsObject.onselect = closure.jsValue() - } else { - jsObject.onselect = .null - } - } - } - - var onslotchange: EventHandler { - get { - guard let function = jsObject.onslotchange.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onslotchange"] { - oldClosure.release() - } - eventHandlerClosures["onslotchange"] = closure - jsObject.onslotchange = closure.jsValue() - } else { - jsObject.onslotchange = .null - } - } - } - - var onstalled: EventHandler { - get { - guard let function = jsObject.onstalled.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onstalled"] { - oldClosure.release() - } - eventHandlerClosures["onstalled"] = closure - jsObject.onstalled = closure.jsValue() - } else { - jsObject.onstalled = .null - } - } - } - - var onsubmit: EventHandler { - get { - guard let function = jsObject.onsubmit.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onsubmit"] { - oldClosure.release() - } - eventHandlerClosures["onsubmit"] = closure - jsObject.onsubmit = closure.jsValue() - } else { - jsObject.onsubmit = .null - } - } - } - - var onsuspend: EventHandler { - get { - guard let function = jsObject.onsuspend.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onsuspend"] { - oldClosure.release() - } - eventHandlerClosures["onsuspend"] = closure - jsObject.onsuspend = closure.jsValue() - } else { - jsObject.onsuspend = .null - } - } - } - - var ontimeupdate: EventHandler { - get { - guard let function = jsObject.ontimeupdate.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["ontimeupdate"] { - oldClosure.release() - } - eventHandlerClosures["ontimeupdate"] = closure - jsObject.ontimeupdate = closure.jsValue() - } else { - jsObject.ontimeupdate = .null - } - } - } - - var ontoggle: EventHandler { - get { - guard let function = jsObject.ontoggle.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["ontoggle"] { - oldClosure.release() - } - eventHandlerClosures["ontoggle"] = closure - jsObject.ontoggle = closure.jsValue() - } else { - jsObject.ontoggle = .null - } - } - } - - var onvolumechange: EventHandler { - get { - guard let function = jsObject.onvolumechange.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onvolumechange"] { - oldClosure.release() - } - eventHandlerClosures["onvolumechange"] = closure - jsObject.onvolumechange = closure.jsValue() - } else { - jsObject.onvolumechange = .null - } - } - } - - var onwaiting: EventHandler { - get { - guard let function = jsObject.onwaiting.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onwaiting"] { - oldClosure.release() - } - eventHandlerClosures["onwaiting"] = closure - jsObject.onwaiting = closure.jsValue() - } else { - jsObject.onwaiting = .null - } - } - } - - var onwebkitanimationend: EventHandler { - get { - guard let function = jsObject.onwebkitanimationend.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onwebkitanimationend"] { - oldClosure.release() - } - eventHandlerClosures["onwebkitanimationend"] = closure - jsObject.onwebkitanimationend = closure.jsValue() - } else { - jsObject.onwebkitanimationend = .null - } - } - } - - var onwebkitanimationiteration: EventHandler { - get { - guard let function = jsObject.onwebkitanimationiteration.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onwebkitanimationiteration"] { - oldClosure.release() - } - eventHandlerClosures["onwebkitanimationiteration"] = closure - jsObject.onwebkitanimationiteration = closure.jsValue() - } else { - jsObject.onwebkitanimationiteration = .null - } - } - } - - var onwebkitanimationstart: EventHandler { - get { - guard let function = jsObject.onwebkitanimationstart.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onwebkitanimationstart"] { - oldClosure.release() - } - eventHandlerClosures["onwebkitanimationstart"] = closure - jsObject.onwebkitanimationstart = closure.jsValue() - } else { - jsObject.onwebkitanimationstart = .null - } - } - } - - var onwebkittransitionend: EventHandler { - get { - guard let function = jsObject.onwebkittransitionend.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onwebkittransitionend"] { - oldClosure.release() - } - eventHandlerClosures["onwebkittransitionend"] = closure - jsObject.onwebkittransitionend = closure.jsValue() - } else { - jsObject.onwebkittransitionend = .null - } - } - } - - var onwheel: EventHandler { - get { - guard let function = jsObject.onwheel.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - let closure = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - } - if let oldClosure = eventHandlerClosures["onwheel"] { - oldClosure.release() - } - eventHandlerClosures["onwheel"] = closure - jsObject.onwheel = closure.jsValue() - } else { - jsObject.onwheel = .null - } - } - } -} diff --git a/Sources/DOMKit/WebIDL/HTMLElement.swift b/Sources/DOMKit/WebIDL/HTMLElement.swift index da6d96b9..fd504169 100644 --- a/Sources/DOMKit/WebIDL/HTMLElement.swift +++ b/Sources/DOMKit/WebIDL/HTMLElement.swift @@ -1,32 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public class HTMLElement: Element, DocumentAndElementEventHandlers, ElementContentEditable, HTMLOrSVGElement { - override public class var constructor: JSFunction { JSObject.global.HTMLElement.function! } - - var eventHandlerClosures = [String: JSClosure]() +public class HTMLElement: Element, GlobalEventHandlers, DocumentAndElementEventHandlers, ElementContentEditable, HTMLOrSVGElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLElement].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _title = ReadWriteAttribute(jsObject: jsObject, name: "title") - _lang = ReadWriteAttribute(jsObject: jsObject, name: "lang") - _translate = ReadWriteAttribute(jsObject: jsObject, name: "translate") - _dir = ReadWriteAttribute(jsObject: jsObject, name: "dir") - _hidden = ReadWriteAttribute(jsObject: jsObject, name: "hidden") - _accessKey = ReadWriteAttribute(jsObject: jsObject, name: "accessKey") - _accessKeyLabel = ReadonlyAttribute(jsObject: jsObject, name: "accessKeyLabel") - _draggable = ReadWriteAttribute(jsObject: jsObject, name: "draggable") - _spellcheck = ReadWriteAttribute(jsObject: jsObject, name: "spellcheck") - _autocapitalize = ReadWriteAttribute(jsObject: jsObject, name: "autocapitalize") - _innerText = ReadWriteAttribute(jsObject: jsObject, name: "innerText") + _title = ReadWriteAttribute(jsObject: jsObject, name: Strings.title) + _lang = ReadWriteAttribute(jsObject: jsObject, name: Strings.lang) + _translate = ReadWriteAttribute(jsObject: jsObject, name: Strings.translate) + _dir = ReadWriteAttribute(jsObject: jsObject, name: Strings.dir) + _hidden = ReadWriteAttribute(jsObject: jsObject, name: Strings.hidden) + _inert = ReadWriteAttribute(jsObject: jsObject, name: Strings.inert) + _accessKey = ReadWriteAttribute(jsObject: jsObject, name: Strings.accessKey) + _accessKeyLabel = ReadonlyAttribute(jsObject: jsObject, name: Strings.accessKeyLabel) + _draggable = ReadWriteAttribute(jsObject: jsObject, name: Strings.draggable) + _spellcheck = ReadWriteAttribute(jsObject: jsObject, name: Strings.spellcheck) + _autocapitalize = ReadWriteAttribute(jsObject: jsObject, name: Strings.autocapitalize) + _innerText = ReadWriteAttribute(jsObject: jsObject, name: Strings.innerText) + _outerText = ReadWriteAttribute(jsObject: jsObject, name: Strings.outerText) super.init(unsafelyWrapping: jsObject) } - public convenience init() { - self.init(unsafelyWrapping: HTMLElement.constructor.new()) + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) } @ReadWriteAttribute @@ -44,8 +42,12 @@ public class HTMLElement: Element, DocumentAndElementEventHandlers, ElementConte @ReadWriteAttribute public var hidden: Bool - public func click() { - _ = jsObject.click!() + @ReadWriteAttribute + public var inert: Bool + + @inlinable public func click() { + let this = jsObject + _ = this[Strings.click].function!(this: this, arguments: []) } @ReadWriteAttribute @@ -66,13 +68,11 @@ public class HTMLElement: Element, DocumentAndElementEventHandlers, ElementConte @ReadWriteAttribute public var innerText: String - public func attachInternals() -> ElementInternals { - return jsObject.attachInternals!().fromJSValue()! - } + @ReadWriteAttribute + public var outerText: String - deinit { - for (_, closure) in eventHandlerClosures { - closure.release() - } + @inlinable public func attachInternals() -> ElementInternals { + let this = jsObject + return this[Strings.attachInternals].function!(this: this, arguments: []).fromJSValue()! } } diff --git a/Sources/DOMKit/WebIDL/HTMLElement_or_Int32.swift b/Sources/DOMKit/WebIDL/HTMLElement_or_Int32.swift new file mode 100644 index 00000000..d32bd33d --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLElement_or_Int32.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_HTMLElement_or_Int32: ConvertibleToJSValue {} +extension HTMLElement: Any_HTMLElement_or_Int32 {} +extension Int32: Any_HTMLElement_or_Int32 {} + +public enum HTMLElement_or_Int32: JSValueCompatible, Any_HTMLElement_or_Int32 { + case htmlElement(HTMLElement) + case int32(Int32) + + var htmlElement: HTMLElement? { + switch self { + case let .htmlElement(htmlElement): return htmlElement + default: return nil + } + } + + var int32: Int32? { + switch self { + case let .int32(int32): return int32 + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let htmlElement: HTMLElement = value.fromJSValue() { + return .htmlElement(htmlElement) + } + if let int32: Int32 = value.fromJSValue() { + return .int32(int32) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .htmlElement(htmlElement): + return htmlElement.jsValue + case let .int32(int32): + return int32.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLEmbedElement.swift b/Sources/DOMKit/WebIDL/HTMLEmbedElement.swift new file mode 100644 index 00000000..e5f0d228 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLEmbedElement.swift @@ -0,0 +1,45 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLEmbedElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLEmbedElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _src = ReadWriteAttribute(jsObject: jsObject, name: Strings.src) + _type = ReadWriteAttribute(jsObject: jsObject, name: Strings.type) + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + _height = ReadWriteAttribute(jsObject: jsObject, name: Strings.height) + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var src: String + + @ReadWriteAttribute + public var type: String + + @ReadWriteAttribute + public var width: String + + @ReadWriteAttribute + public var height: String + + @inlinable public func getSVGDocument() -> Document? { + let this = jsObject + return this[Strings.getSVGDocument].function!(this: this, arguments: []).fromJSValue()! + } + + @ReadWriteAttribute + public var align: String + + @ReadWriteAttribute + public var name: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLFieldSetElement.swift b/Sources/DOMKit/WebIDL/HTMLFieldSetElement.swift new file mode 100644 index 00000000..9cff89b1 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLFieldSetElement.swift @@ -0,0 +1,63 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLFieldSetElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLFieldSetElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _disabled = ReadWriteAttribute(jsObject: jsObject, name: Strings.disabled) + _form = ReadonlyAttribute(jsObject: jsObject, name: Strings.form) + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _type = ReadonlyAttribute(jsObject: jsObject, name: Strings.type) + _elements = ReadonlyAttribute(jsObject: jsObject, name: Strings.elements) + _willValidate = ReadonlyAttribute(jsObject: jsObject, name: Strings.willValidate) + _validity = ReadonlyAttribute(jsObject: jsObject, name: Strings.validity) + _validationMessage = ReadonlyAttribute(jsObject: jsObject, name: Strings.validationMessage) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var disabled: Bool + + @ReadonlyAttribute + public var form: HTMLFormElement? + + @ReadWriteAttribute + public var name: String + + @ReadonlyAttribute + public var type: String + + @ReadonlyAttribute + public var elements: HTMLCollection + + @ReadonlyAttribute + public var willValidate: Bool + + @ReadonlyAttribute + public var validity: ValidityState + + @ReadonlyAttribute + public var validationMessage: String + + @inlinable public func checkValidity() -> Bool { + let this = jsObject + return this[Strings.checkValidity].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func reportValidity() -> Bool { + let this = jsObject + return this[Strings.reportValidity].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func setCustomValidity(error: String) { + let this = jsObject + _ = this[Strings.setCustomValidity].function!(this: this, arguments: [error.jsValue]) + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLFontElement.swift b/Sources/DOMKit/WebIDL/HTMLFontElement.swift new file mode 100644 index 00000000..f3c7b5ab --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLFontElement.swift @@ -0,0 +1,28 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLFontElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLFontElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _color = ReadWriteAttribute(jsObject: jsObject, name: Strings.color) + _face = ReadWriteAttribute(jsObject: jsObject, name: Strings.face) + _size = ReadWriteAttribute(jsObject: jsObject, name: Strings.size) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var color: String + + @ReadWriteAttribute + public var face: String + + @ReadWriteAttribute + public var size: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLFormControlsCollection.swift b/Sources/DOMKit/WebIDL/HTMLFormControlsCollection.swift index 8b323e5e..bc0a9c1e 100644 --- a/Sources/DOMKit/WebIDL/HTMLFormControlsCollection.swift +++ b/Sources/DOMKit/WebIDL/HTMLFormControlsCollection.swift @@ -1,18 +1,16 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class HTMLFormControlsCollection: HTMLCollection { - override public class var constructor: JSFunction { JSObject.global.HTMLFormControlsCollection.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLFormControlsCollection].function! } public required init(unsafelyWrapping jsObject: JSObject) { super.init(unsafelyWrapping: jsObject) } - public subscript(_: String) -> RadioNodeListOrElement?? { - return jsObject.name.fromJSValue()! + @inlinable public subscript(key: String) -> Element_or_RadioNodeList? { + jsObject[key].fromJSValue() } } diff --git a/Sources/DOMKit/WebIDL/HTMLFormElement.swift b/Sources/DOMKit/WebIDL/HTMLFormElement.swift index e1544505..4f10d86d 100644 --- a/Sources/DOMKit/WebIDL/HTMLFormElement.swift +++ b/Sources/DOMKit/WebIDL/HTMLFormElement.swift @@ -1,36 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class HTMLFormElement: HTMLElement { - override public class var constructor: JSFunction { JSObject.global.HTMLFormElement.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLFormElement].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _acceptCharset = ReadWriteAttribute(jsObject: jsObject, name: "acceptCharset") - _action = ReadWriteAttribute(jsObject: jsObject, name: "action") - _autocomplete = ReadWriteAttribute(jsObject: jsObject, name: "autocomplete") - _enctype = ReadWriteAttribute(jsObject: jsObject, name: "enctype") - _encoding = ReadWriteAttribute(jsObject: jsObject, name: "encoding") - _method = ReadWriteAttribute(jsObject: jsObject, name: "method") - _name = ReadWriteAttribute(jsObject: jsObject, name: "name") - _noValidate = ReadWriteAttribute(jsObject: jsObject, name: "noValidate") - _target = ReadWriteAttribute(jsObject: jsObject, name: "target") - _rel = ReadWriteAttribute(jsObject: jsObject, name: "rel") - _relList = ReadonlyAttribute(jsObject: jsObject, name: "relList") - _elements = ReadonlyAttribute(jsObject: jsObject, name: "elements") - _length = ReadonlyAttribute(jsObject: jsObject, name: "length") + _acceptCharset = ReadWriteAttribute(jsObject: jsObject, name: Strings.acceptCharset) + _action = ReadWriteAttribute(jsObject: jsObject, name: Strings.action) + _autocomplete = ReadWriteAttribute(jsObject: jsObject, name: Strings.autocomplete) + _enctype = ReadWriteAttribute(jsObject: jsObject, name: Strings.enctype) + _encoding = ReadWriteAttribute(jsObject: jsObject, name: Strings.encoding) + _method = ReadWriteAttribute(jsObject: jsObject, name: Strings.method) + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _noValidate = ReadWriteAttribute(jsObject: jsObject, name: Strings.noValidate) + _target = ReadWriteAttribute(jsObject: jsObject, name: Strings.target) + _rel = ReadWriteAttribute(jsObject: jsObject, name: Strings.rel) + _relList = ReadonlyAttribute(jsObject: jsObject, name: Strings.relList) + _elements = ReadonlyAttribute(jsObject: jsObject, name: Strings.elements) + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) super.init(unsafelyWrapping: jsObject) } - public subscript(_: String) -> RadioNodeListOrElement? { - return jsObject.name.fromJSValue()! - } - - public convenience init() { - self.init(unsafelyWrapping: HTMLFormElement.constructor.new()) + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) } @ReadWriteAttribute @@ -72,23 +66,36 @@ public class HTMLFormElement: HTMLElement { @ReadonlyAttribute public var length: UInt32 - public func submit() { - _ = jsObject.submit!() + @inlinable public subscript(key: Int) -> Element { + jsObject[key].fromJSValue()! + } + + @inlinable public subscript(key: String) -> Element_or_RadioNodeList { + jsObject[key].fromJSValue()! + } + + @inlinable public func submit() { + let this = jsObject + _ = this[Strings.submit].function!(this: this, arguments: []) } - public func requestSubmit(submitter: HTMLElement? = nil) { - _ = jsObject.requestSubmit!(submitter.jsValue()) + @inlinable public func requestSubmit(submitter: HTMLElement? = nil) { + let this = jsObject + _ = this[Strings.requestSubmit].function!(this: this, arguments: [submitter?.jsValue ?? .undefined]) } - public func reset() { - _ = jsObject.reset!() + @inlinable public func reset() { + let this = jsObject + _ = this[Strings.reset].function!(this: this, arguments: []) } - public func checkValidity() -> Bool { - return jsObject.checkValidity!().fromJSValue()! + @inlinable public func checkValidity() -> Bool { + let this = jsObject + return this[Strings.checkValidity].function!(this: this, arguments: []).fromJSValue()! } - public func reportValidity() -> Bool { - return jsObject.reportValidity!().fromJSValue()! + @inlinable public func reportValidity() -> Bool { + let this = jsObject + return this[Strings.reportValidity].function!(this: this, arguments: []).fromJSValue()! } } diff --git a/Sources/DOMKit/WebIDL/HTMLFrameElement.swift b/Sources/DOMKit/WebIDL/HTMLFrameElement.swift new file mode 100644 index 00000000..7c0f3bf5 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLFrameElement.swift @@ -0,0 +1,56 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLFrameElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLFrameElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _scrolling = ReadWriteAttribute(jsObject: jsObject, name: Strings.scrolling) + _src = ReadWriteAttribute(jsObject: jsObject, name: Strings.src) + _frameBorder = ReadWriteAttribute(jsObject: jsObject, name: Strings.frameBorder) + _longDesc = ReadWriteAttribute(jsObject: jsObject, name: Strings.longDesc) + _noResize = ReadWriteAttribute(jsObject: jsObject, name: Strings.noResize) + _contentDocument = ReadonlyAttribute(jsObject: jsObject, name: Strings.contentDocument) + _contentWindow = ReadonlyAttribute(jsObject: jsObject, name: Strings.contentWindow) + _marginHeight = ReadWriteAttribute(jsObject: jsObject, name: Strings.marginHeight) + _marginWidth = ReadWriteAttribute(jsObject: jsObject, name: Strings.marginWidth) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var name: String + + @ReadWriteAttribute + public var scrolling: String + + @ReadWriteAttribute + public var src: String + + @ReadWriteAttribute + public var frameBorder: String + + @ReadWriteAttribute + public var longDesc: String + + @ReadWriteAttribute + public var noResize: Bool + + @ReadonlyAttribute + public var contentDocument: Document? + + @ReadonlyAttribute + public var contentWindow: WindowProxy? + + @ReadWriteAttribute + public var marginHeight: String + + @ReadWriteAttribute + public var marginWidth: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLFrameSetElement.swift b/Sources/DOMKit/WebIDL/HTMLFrameSetElement.swift new file mode 100644 index 00000000..01d50eb6 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLFrameSetElement.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLFrameSetElement: HTMLElement, WindowEventHandlers { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLFrameSetElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _cols = ReadWriteAttribute(jsObject: jsObject, name: Strings.cols) + _rows = ReadWriteAttribute(jsObject: jsObject, name: Strings.rows) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var cols: String + + @ReadWriteAttribute + public var rows: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLHRElement.swift b/Sources/DOMKit/WebIDL/HTMLHRElement.swift new file mode 100644 index 00000000..e9030cd1 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLHRElement.swift @@ -0,0 +1,36 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLHRElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLHRElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + _color = ReadWriteAttribute(jsObject: jsObject, name: Strings.color) + _noShade = ReadWriteAttribute(jsObject: jsObject, name: Strings.noShade) + _size = ReadWriteAttribute(jsObject: jsObject, name: Strings.size) + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var align: String + + @ReadWriteAttribute + public var color: String + + @ReadWriteAttribute + public var noShade: Bool + + @ReadWriteAttribute + public var size: String + + @ReadWriteAttribute + public var width: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLHeadElement.swift b/Sources/DOMKit/WebIDL/HTMLHeadElement.swift new file mode 100644 index 00000000..4a2e8d24 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLHeadElement.swift @@ -0,0 +1,16 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLHeadElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLHeadElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLHeadingElement.swift b/Sources/DOMKit/WebIDL/HTMLHeadingElement.swift new file mode 100644 index 00000000..5420f27b --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLHeadingElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLHeadingElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLHeadingElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var align: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLHtmlElement.swift b/Sources/DOMKit/WebIDL/HTMLHtmlElement.swift new file mode 100644 index 00000000..b7d8e824 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLHtmlElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLHtmlElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLHtmlElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _version = ReadWriteAttribute(jsObject: jsObject, name: Strings.version) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var version: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLHyperlinkElementUtils.swift b/Sources/DOMKit/WebIDL/HTMLHyperlinkElementUtils.swift new file mode 100644 index 00000000..37ed259e --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLHyperlinkElementUtils.swift @@ -0,0 +1,59 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol HTMLHyperlinkElementUtils: JSBridgedClass {} +public extension HTMLHyperlinkElementUtils { + @inlinable var href: String { + get { ReadWriteAttribute[Strings.href, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.href, in: jsObject] = newValue } + } + + @inlinable var origin: String { ReadonlyAttribute[Strings.origin, in: jsObject] } + + @inlinable var `protocol`: String { + get { ReadWriteAttribute[Strings.protocol, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.protocol, in: jsObject] = newValue } + } + + @inlinable var username: String { + get { ReadWriteAttribute[Strings.username, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.username, in: jsObject] = newValue } + } + + @inlinable var password: String { + get { ReadWriteAttribute[Strings.password, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.password, in: jsObject] = newValue } + } + + @inlinable var host: String { + get { ReadWriteAttribute[Strings.host, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.host, in: jsObject] = newValue } + } + + @inlinable var hostname: String { + get { ReadWriteAttribute[Strings.hostname, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.hostname, in: jsObject] = newValue } + } + + @inlinable var port: String { + get { ReadWriteAttribute[Strings.port, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.port, in: jsObject] = newValue } + } + + @inlinable var pathname: String { + get { ReadWriteAttribute[Strings.pathname, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.pathname, in: jsObject] = newValue } + } + + @inlinable var search: String { + get { ReadWriteAttribute[Strings.search, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.search, in: jsObject] = newValue } + } + + @inlinable var hash: String { + get { ReadWriteAttribute[Strings.hash, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.hash, in: jsObject] = newValue } + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLIFrameElement.swift b/Sources/DOMKit/WebIDL/HTMLIFrameElement.swift new file mode 100644 index 00000000..3f2be596 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLIFrameElement.swift @@ -0,0 +1,93 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLIFrameElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLIFrameElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _src = ReadWriteAttribute(jsObject: jsObject, name: Strings.src) + _srcdoc = ReadWriteAttribute(jsObject: jsObject, name: Strings.srcdoc) + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _sandbox = ReadonlyAttribute(jsObject: jsObject, name: Strings.sandbox) + _allow = ReadWriteAttribute(jsObject: jsObject, name: Strings.allow) + _allowFullscreen = ReadWriteAttribute(jsObject: jsObject, name: Strings.allowFullscreen) + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + _height = ReadWriteAttribute(jsObject: jsObject, name: Strings.height) + _referrerPolicy = ReadWriteAttribute(jsObject: jsObject, name: Strings.referrerPolicy) + _loading = ReadWriteAttribute(jsObject: jsObject, name: Strings.loading) + _contentDocument = ReadonlyAttribute(jsObject: jsObject, name: Strings.contentDocument) + _contentWindow = ReadonlyAttribute(jsObject: jsObject, name: Strings.contentWindow) + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + _scrolling = ReadWriteAttribute(jsObject: jsObject, name: Strings.scrolling) + _frameBorder = ReadWriteAttribute(jsObject: jsObject, name: Strings.frameBorder) + _longDesc = ReadWriteAttribute(jsObject: jsObject, name: Strings.longDesc) + _marginHeight = ReadWriteAttribute(jsObject: jsObject, name: Strings.marginHeight) + _marginWidth = ReadWriteAttribute(jsObject: jsObject, name: Strings.marginWidth) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var src: String + + @ReadWriteAttribute + public var srcdoc: String + + @ReadWriteAttribute + public var name: String + + @ReadonlyAttribute + public var sandbox: DOMTokenList + + @ReadWriteAttribute + public var allow: String + + @ReadWriteAttribute + public var allowFullscreen: Bool + + @ReadWriteAttribute + public var width: String + + @ReadWriteAttribute + public var height: String + + @ReadWriteAttribute + public var referrerPolicy: String + + @ReadWriteAttribute + public var loading: String + + @ReadonlyAttribute + public var contentDocument: Document? + + @ReadonlyAttribute + public var contentWindow: WindowProxy? + + @inlinable public func getSVGDocument() -> Document? { + let this = jsObject + return this[Strings.getSVGDocument].function!(this: this, arguments: []).fromJSValue()! + } + + @ReadWriteAttribute + public var align: String + + @ReadWriteAttribute + public var scrolling: String + + @ReadWriteAttribute + public var frameBorder: String + + @ReadWriteAttribute + public var longDesc: String + + @ReadWriteAttribute + public var marginHeight: String + + @ReadWriteAttribute + public var marginWidth: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLImageElement.swift b/Sources/DOMKit/WebIDL/HTMLImageElement.swift new file mode 100644 index 00000000..6fb16310 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLImageElement.swift @@ -0,0 +1,120 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLImageElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLImageElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _alt = ReadWriteAttribute(jsObject: jsObject, name: Strings.alt) + _src = ReadWriteAttribute(jsObject: jsObject, name: Strings.src) + _srcset = ReadWriteAttribute(jsObject: jsObject, name: Strings.srcset) + _sizes = ReadWriteAttribute(jsObject: jsObject, name: Strings.sizes) + _crossOrigin = ReadWriteAttribute(jsObject: jsObject, name: Strings.crossOrigin) + _useMap = ReadWriteAttribute(jsObject: jsObject, name: Strings.useMap) + _isMap = ReadWriteAttribute(jsObject: jsObject, name: Strings.isMap) + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + _height = ReadWriteAttribute(jsObject: jsObject, name: Strings.height) + _naturalWidth = ReadonlyAttribute(jsObject: jsObject, name: Strings.naturalWidth) + _naturalHeight = ReadonlyAttribute(jsObject: jsObject, name: Strings.naturalHeight) + _complete = ReadonlyAttribute(jsObject: jsObject, name: Strings.complete) + _currentSrc = ReadonlyAttribute(jsObject: jsObject, name: Strings.currentSrc) + _referrerPolicy = ReadWriteAttribute(jsObject: jsObject, name: Strings.referrerPolicy) + _decoding = ReadWriteAttribute(jsObject: jsObject, name: Strings.decoding) + _loading = ReadWriteAttribute(jsObject: jsObject, name: Strings.loading) + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _lowsrc = ReadWriteAttribute(jsObject: jsObject, name: Strings.lowsrc) + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + _hspace = ReadWriteAttribute(jsObject: jsObject, name: Strings.hspace) + _vspace = ReadWriteAttribute(jsObject: jsObject, name: Strings.vspace) + _longDesc = ReadWriteAttribute(jsObject: jsObject, name: Strings.longDesc) + _border = ReadWriteAttribute(jsObject: jsObject, name: Strings.border) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var alt: String + + @ReadWriteAttribute + public var src: String + + @ReadWriteAttribute + public var srcset: String + + @ReadWriteAttribute + public var sizes: String + + @ReadWriteAttribute + public var crossOrigin: String? + + @ReadWriteAttribute + public var useMap: String + + @ReadWriteAttribute + public var isMap: Bool + + @ReadWriteAttribute + public var width: UInt32 + + @ReadWriteAttribute + public var height: UInt32 + + @ReadonlyAttribute + public var naturalWidth: UInt32 + + @ReadonlyAttribute + public var naturalHeight: UInt32 + + @ReadonlyAttribute + public var complete: Bool + + @ReadonlyAttribute + public var currentSrc: String + + @ReadWriteAttribute + public var referrerPolicy: String + + @ReadWriteAttribute + public var decoding: String + + @ReadWriteAttribute + public var loading: String + + @inlinable public func decode() -> JSPromise { + let this = jsObject + return this[Strings.decode].function!(this: this, arguments: []).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func decode() async throws { + let this = jsObject + let _promise: JSPromise = this[Strings.decode].function!(this: this, arguments: []).fromJSValue()! + _ = try await _promise.value + } + + @ReadWriteAttribute + public var name: String + + @ReadWriteAttribute + public var lowsrc: String + + @ReadWriteAttribute + public var align: String + + @ReadWriteAttribute + public var hspace: UInt32 + + @ReadWriteAttribute + public var vspace: UInt32 + + @ReadWriteAttribute + public var longDesc: String + + @ReadWriteAttribute + public var border: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLInputElement.swift b/Sources/DOMKit/WebIDL/HTMLInputElement.swift new file mode 100644 index 00000000..d20d436e --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLInputElement.swift @@ -0,0 +1,246 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLInputElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLInputElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _accept = ReadWriteAttribute(jsObject: jsObject, name: Strings.accept) + _alt = ReadWriteAttribute(jsObject: jsObject, name: Strings.alt) + _autocomplete = ReadWriteAttribute(jsObject: jsObject, name: Strings.autocomplete) + _defaultChecked = ReadWriteAttribute(jsObject: jsObject, name: Strings.defaultChecked) + _checked = ReadWriteAttribute(jsObject: jsObject, name: Strings.checked) + _dirName = ReadWriteAttribute(jsObject: jsObject, name: Strings.dirName) + _disabled = ReadWriteAttribute(jsObject: jsObject, name: Strings.disabled) + _form = ReadonlyAttribute(jsObject: jsObject, name: Strings.form) + _files = ReadWriteAttribute(jsObject: jsObject, name: Strings.files) + _formAction = ReadWriteAttribute(jsObject: jsObject, name: Strings.formAction) + _formEnctype = ReadWriteAttribute(jsObject: jsObject, name: Strings.formEnctype) + _formMethod = ReadWriteAttribute(jsObject: jsObject, name: Strings.formMethod) + _formNoValidate = ReadWriteAttribute(jsObject: jsObject, name: Strings.formNoValidate) + _formTarget = ReadWriteAttribute(jsObject: jsObject, name: Strings.formTarget) + _height = ReadWriteAttribute(jsObject: jsObject, name: Strings.height) + _indeterminate = ReadWriteAttribute(jsObject: jsObject, name: Strings.indeterminate) + _list = ReadonlyAttribute(jsObject: jsObject, name: Strings.list) + _max = ReadWriteAttribute(jsObject: jsObject, name: Strings.max) + _maxLength = ReadWriteAttribute(jsObject: jsObject, name: Strings.maxLength) + _min = ReadWriteAttribute(jsObject: jsObject, name: Strings.min) + _minLength = ReadWriteAttribute(jsObject: jsObject, name: Strings.minLength) + _multiple = ReadWriteAttribute(jsObject: jsObject, name: Strings.multiple) + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _pattern = ReadWriteAttribute(jsObject: jsObject, name: Strings.pattern) + _placeholder = ReadWriteAttribute(jsObject: jsObject, name: Strings.placeholder) + _readOnly = ReadWriteAttribute(jsObject: jsObject, name: Strings.readOnly) + _required = ReadWriteAttribute(jsObject: jsObject, name: Strings.required) + _size = ReadWriteAttribute(jsObject: jsObject, name: Strings.size) + _src = ReadWriteAttribute(jsObject: jsObject, name: Strings.src) + _step = ReadWriteAttribute(jsObject: jsObject, name: Strings.step) + _type = ReadWriteAttribute(jsObject: jsObject, name: Strings.type) + _defaultValue = ReadWriteAttribute(jsObject: jsObject, name: Strings.defaultValue) + _value = ReadWriteAttribute(jsObject: jsObject, name: Strings.value) + _valueAsDate = ReadWriteAttribute(jsObject: jsObject, name: Strings.valueAsDate) + _valueAsNumber = ReadWriteAttribute(jsObject: jsObject, name: Strings.valueAsNumber) + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + _willValidate = ReadonlyAttribute(jsObject: jsObject, name: Strings.willValidate) + _validity = ReadonlyAttribute(jsObject: jsObject, name: Strings.validity) + _validationMessage = ReadonlyAttribute(jsObject: jsObject, name: Strings.validationMessage) + _labels = ReadonlyAttribute(jsObject: jsObject, name: Strings.labels) + _selectionStart = ReadWriteAttribute(jsObject: jsObject, name: Strings.selectionStart) + _selectionEnd = ReadWriteAttribute(jsObject: jsObject, name: Strings.selectionEnd) + _selectionDirection = ReadWriteAttribute(jsObject: jsObject, name: Strings.selectionDirection) + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + _useMap = ReadWriteAttribute(jsObject: jsObject, name: Strings.useMap) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var accept: String + + @ReadWriteAttribute + public var alt: String + + @ReadWriteAttribute + public var autocomplete: String + + @ReadWriteAttribute + public var defaultChecked: Bool + + @ReadWriteAttribute + public var checked: Bool + + @ReadWriteAttribute + public var dirName: String + + @ReadWriteAttribute + public var disabled: Bool + + @ReadonlyAttribute + public var form: HTMLFormElement? + + @ReadWriteAttribute + public var files: FileList? + + @ReadWriteAttribute + public var formAction: String + + @ReadWriteAttribute + public var formEnctype: String + + @ReadWriteAttribute + public var formMethod: String + + @ReadWriteAttribute + public var formNoValidate: Bool + + @ReadWriteAttribute + public var formTarget: String + + @ReadWriteAttribute + public var height: UInt32 + + @ReadWriteAttribute + public var indeterminate: Bool + + @ReadonlyAttribute + public var list: HTMLElement? + + @ReadWriteAttribute + public var max: String + + @ReadWriteAttribute + public var maxLength: Int32 + + @ReadWriteAttribute + public var min: String + + @ReadWriteAttribute + public var minLength: Int32 + + @ReadWriteAttribute + public var multiple: Bool + + @ReadWriteAttribute + public var name: String + + @ReadWriteAttribute + public var pattern: String + + @ReadWriteAttribute + public var placeholder: String + + @ReadWriteAttribute + public var readOnly: Bool + + @ReadWriteAttribute + public var required: Bool + + @ReadWriteAttribute + public var size: UInt32 + + @ReadWriteAttribute + public var src: String + + @ReadWriteAttribute + public var step: String + + @ReadWriteAttribute + public var type: String + + @ReadWriteAttribute + public var defaultValue: String + + @ReadWriteAttribute + public var value: String + + @ReadWriteAttribute + public var valueAsDate: JSObject? + + @ReadWriteAttribute + public var valueAsNumber: Double + + @ReadWriteAttribute + public var width: UInt32 + + @inlinable public func stepUp(n: Int32? = nil) { + let this = jsObject + _ = this[Strings.stepUp].function!(this: this, arguments: [n?.jsValue ?? .undefined]) + } + + @inlinable public func stepDown(n: Int32? = nil) { + let this = jsObject + _ = this[Strings.stepDown].function!(this: this, arguments: [n?.jsValue ?? .undefined]) + } + + @ReadonlyAttribute + public var willValidate: Bool + + @ReadonlyAttribute + public var validity: ValidityState + + @ReadonlyAttribute + public var validationMessage: String + + @inlinable public func checkValidity() -> Bool { + let this = jsObject + return this[Strings.checkValidity].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func reportValidity() -> Bool { + let this = jsObject + return this[Strings.reportValidity].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func setCustomValidity(error: String) { + let this = jsObject + _ = this[Strings.setCustomValidity].function!(this: this, arguments: [error.jsValue]) + } + + @ReadonlyAttribute + public var labels: NodeList? + + @inlinable public func select() { + let this = jsObject + _ = this[Strings.select].function!(this: this, arguments: []) + } + + @ReadWriteAttribute + public var selectionStart: UInt32? + + @ReadWriteAttribute + public var selectionEnd: UInt32? + + @ReadWriteAttribute + public var selectionDirection: String? + + @inlinable public func setRangeText(replacement: String) { + let this = jsObject + _ = this[Strings.setRangeText].function!(this: this, arguments: [replacement.jsValue]) + } + + @inlinable public func setRangeText(replacement: String, start: UInt32, end: UInt32, selectionMode: SelectionMode? = nil) { + let this = jsObject + _ = this[Strings.setRangeText].function!(this: this, arguments: [replacement.jsValue, start.jsValue, end.jsValue, selectionMode?.jsValue ?? .undefined]) + } + + @inlinable public func setSelectionRange(start: UInt32, end: UInt32, direction: String? = nil) { + let this = jsObject + _ = this[Strings.setSelectionRange].function!(this: this, arguments: [start.jsValue, end.jsValue, direction?.jsValue ?? .undefined]) + } + + @inlinable public func showPicker() { + let this = jsObject + _ = this[Strings.showPicker].function!(this: this, arguments: []) + } + + @ReadWriteAttribute + public var align: String + + @ReadWriteAttribute + public var useMap: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLLIElement.swift b/Sources/DOMKit/WebIDL/HTMLLIElement.swift new file mode 100644 index 00000000..e3b89ece --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLLIElement.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLLIElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLLIElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _value = ReadWriteAttribute(jsObject: jsObject, name: Strings.value) + _type = ReadWriteAttribute(jsObject: jsObject, name: Strings.type) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var value: Int32 + + @ReadWriteAttribute + public var type: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLLabelElement.swift b/Sources/DOMKit/WebIDL/HTMLLabelElement.swift new file mode 100644 index 00000000..5140458b --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLLabelElement.swift @@ -0,0 +1,28 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLLabelElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLLabelElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _form = ReadonlyAttribute(jsObject: jsObject, name: Strings.form) + _htmlFor = ReadWriteAttribute(jsObject: jsObject, name: Strings.htmlFor) + _control = ReadonlyAttribute(jsObject: jsObject, name: Strings.control) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadonlyAttribute + public var form: HTMLFormElement? + + @ReadWriteAttribute + public var htmlFor: String + + @ReadonlyAttribute + public var control: HTMLElement? +} diff --git a/Sources/DOMKit/WebIDL/HTMLLegendElement.swift b/Sources/DOMKit/WebIDL/HTMLLegendElement.swift new file mode 100644 index 00000000..af091033 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLLegendElement.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLLegendElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLLegendElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _form = ReadonlyAttribute(jsObject: jsObject, name: Strings.form) + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadonlyAttribute + public var form: HTMLFormElement? + + @ReadWriteAttribute + public var align: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLLinkElement.swift b/Sources/DOMKit/WebIDL/HTMLLinkElement.swift new file mode 100644 index 00000000..78cffb76 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLLinkElement.swift @@ -0,0 +1,88 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLLinkElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLLinkElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _href = ReadWriteAttribute(jsObject: jsObject, name: Strings.href) + _crossOrigin = ReadWriteAttribute(jsObject: jsObject, name: Strings.crossOrigin) + _rel = ReadWriteAttribute(jsObject: jsObject, name: Strings.rel) + _as = ReadWriteAttribute(jsObject: jsObject, name: Strings.as) + _relList = ReadonlyAttribute(jsObject: jsObject, name: Strings.relList) + _media = ReadWriteAttribute(jsObject: jsObject, name: Strings.media) + _integrity = ReadWriteAttribute(jsObject: jsObject, name: Strings.integrity) + _hreflang = ReadWriteAttribute(jsObject: jsObject, name: Strings.hreflang) + _type = ReadWriteAttribute(jsObject: jsObject, name: Strings.type) + _sizes = ReadonlyAttribute(jsObject: jsObject, name: Strings.sizes) + _imageSrcset = ReadWriteAttribute(jsObject: jsObject, name: Strings.imageSrcset) + _imageSizes = ReadWriteAttribute(jsObject: jsObject, name: Strings.imageSizes) + _referrerPolicy = ReadWriteAttribute(jsObject: jsObject, name: Strings.referrerPolicy) + _blocking = ReadonlyAttribute(jsObject: jsObject, name: Strings.blocking) + _disabled = ReadWriteAttribute(jsObject: jsObject, name: Strings.disabled) + _charset = ReadWriteAttribute(jsObject: jsObject, name: Strings.charset) + _rev = ReadWriteAttribute(jsObject: jsObject, name: Strings.rev) + _target = ReadWriteAttribute(jsObject: jsObject, name: Strings.target) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var href: String + + @ReadWriteAttribute + public var crossOrigin: String? + + @ReadWriteAttribute + public var rel: String + + @ReadWriteAttribute + public var `as`: String + + @ReadonlyAttribute + public var relList: DOMTokenList + + @ReadWriteAttribute + public var media: String + + @ReadWriteAttribute + public var integrity: String + + @ReadWriteAttribute + public var hreflang: String + + @ReadWriteAttribute + public var type: String + + @ReadonlyAttribute + public var sizes: DOMTokenList + + @ReadWriteAttribute + public var imageSrcset: String + + @ReadWriteAttribute + public var imageSizes: String + + @ReadWriteAttribute + public var referrerPolicy: String + + @ReadonlyAttribute + public var blocking: DOMTokenList + + @ReadWriteAttribute + public var disabled: Bool + + @ReadWriteAttribute + public var charset: String + + @ReadWriteAttribute + public var rev: String + + @ReadWriteAttribute + public var target: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLMapElement.swift b/Sources/DOMKit/WebIDL/HTMLMapElement.swift new file mode 100644 index 00000000..47389672 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLMapElement.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLMapElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLMapElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _areas = ReadonlyAttribute(jsObject: jsObject, name: Strings.areas) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var name: String + + @ReadonlyAttribute + public var areas: HTMLCollection +} diff --git a/Sources/DOMKit/WebIDL/HTMLMarqueeElement.swift b/Sources/DOMKit/WebIDL/HTMLMarqueeElement.swift new file mode 100644 index 00000000..9747d62c --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLMarqueeElement.swift @@ -0,0 +1,70 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLMarqueeElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLMarqueeElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _behavior = ReadWriteAttribute(jsObject: jsObject, name: Strings.behavior) + _bgColor = ReadWriteAttribute(jsObject: jsObject, name: Strings.bgColor) + _direction = ReadWriteAttribute(jsObject: jsObject, name: Strings.direction) + _height = ReadWriteAttribute(jsObject: jsObject, name: Strings.height) + _hspace = ReadWriteAttribute(jsObject: jsObject, name: Strings.hspace) + _loop = ReadWriteAttribute(jsObject: jsObject, name: Strings.loop) + _scrollAmount = ReadWriteAttribute(jsObject: jsObject, name: Strings.scrollAmount) + _scrollDelay = ReadWriteAttribute(jsObject: jsObject, name: Strings.scrollDelay) + _trueSpeed = ReadWriteAttribute(jsObject: jsObject, name: Strings.trueSpeed) + _vspace = ReadWriteAttribute(jsObject: jsObject, name: Strings.vspace) + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var behavior: String + + @ReadWriteAttribute + public var bgColor: String + + @ReadWriteAttribute + public var direction: String + + @ReadWriteAttribute + public var height: String + + @ReadWriteAttribute + public var hspace: UInt32 + + @ReadWriteAttribute + public var loop: Int32 + + @ReadWriteAttribute + public var scrollAmount: UInt32 + + @ReadWriteAttribute + public var scrollDelay: UInt32 + + @ReadWriteAttribute + public var trueSpeed: Bool + + @ReadWriteAttribute + public var vspace: UInt32 + + @ReadWriteAttribute + public var width: String + + @inlinable public func start() { + let this = jsObject + _ = this[Strings.start].function!(this: this, arguments: []) + } + + @inlinable public func stop() { + let this = jsObject + _ = this[Strings.stop].function!(this: this, arguments: []) + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLMediaElement.swift b/Sources/DOMKit/WebIDL/HTMLMediaElement.swift new file mode 100644 index 00000000..fe74c1b3 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLMediaElement.swift @@ -0,0 +1,182 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLMediaElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLMediaElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _error = ReadonlyAttribute(jsObject: jsObject, name: Strings.error) + _src = ReadWriteAttribute(jsObject: jsObject, name: Strings.src) + _currentSrc = ReadonlyAttribute(jsObject: jsObject, name: Strings.currentSrc) + _crossOrigin = ReadWriteAttribute(jsObject: jsObject, name: Strings.crossOrigin) + _networkState = ReadonlyAttribute(jsObject: jsObject, name: Strings.networkState) + _preload = ReadWriteAttribute(jsObject: jsObject, name: Strings.preload) + _buffered = ReadonlyAttribute(jsObject: jsObject, name: Strings.buffered) + _readyState = ReadonlyAttribute(jsObject: jsObject, name: Strings.readyState) + _seeking = ReadonlyAttribute(jsObject: jsObject, name: Strings.seeking) + _currentTime = ReadWriteAttribute(jsObject: jsObject, name: Strings.currentTime) + _duration = ReadonlyAttribute(jsObject: jsObject, name: Strings.duration) + _paused = ReadonlyAttribute(jsObject: jsObject, name: Strings.paused) + _defaultPlaybackRate = ReadWriteAttribute(jsObject: jsObject, name: Strings.defaultPlaybackRate) + _playbackRate = ReadWriteAttribute(jsObject: jsObject, name: Strings.playbackRate) + _preservesPitch = ReadWriteAttribute(jsObject: jsObject, name: Strings.preservesPitch) + _played = ReadonlyAttribute(jsObject: jsObject, name: Strings.played) + _seekable = ReadonlyAttribute(jsObject: jsObject, name: Strings.seekable) + _ended = ReadonlyAttribute(jsObject: jsObject, name: Strings.ended) + _autoplay = ReadWriteAttribute(jsObject: jsObject, name: Strings.autoplay) + _loop = ReadWriteAttribute(jsObject: jsObject, name: Strings.loop) + _controls = ReadWriteAttribute(jsObject: jsObject, name: Strings.controls) + _volume = ReadWriteAttribute(jsObject: jsObject, name: Strings.volume) + _muted = ReadWriteAttribute(jsObject: jsObject, name: Strings.muted) + _defaultMuted = ReadWriteAttribute(jsObject: jsObject, name: Strings.defaultMuted) + _audioTracks = ReadonlyAttribute(jsObject: jsObject, name: Strings.audioTracks) + _videoTracks = ReadonlyAttribute(jsObject: jsObject, name: Strings.videoTracks) + _textTracks = ReadonlyAttribute(jsObject: jsObject, name: Strings.textTracks) + super.init(unsafelyWrapping: jsObject) + } + + @ReadonlyAttribute + public var error: MediaError? + + @ReadWriteAttribute + public var src: String + + // XXX: member 'srcObject' is ignored + + @ReadonlyAttribute + public var currentSrc: String + + @ReadWriteAttribute + public var crossOrigin: String? + + public static let NETWORK_EMPTY: UInt16 = 0 + + public static let NETWORK_IDLE: UInt16 = 1 + + public static let NETWORK_LOADING: UInt16 = 2 + + public static let NETWORK_NO_SOURCE: UInt16 = 3 + + @ReadonlyAttribute + public var networkState: UInt16 + + @ReadWriteAttribute + public var preload: String + + @ReadonlyAttribute + public var buffered: TimeRanges + + @inlinable public func load() { + let this = jsObject + _ = this[Strings.load].function!(this: this, arguments: []) + } + + @inlinable public func canPlayType(type: String) -> CanPlayTypeResult { + let this = jsObject + return this[Strings.canPlayType].function!(this: this, arguments: [type.jsValue]).fromJSValue()! + } + + public static let HAVE_NOTHING: UInt16 = 0 + + public static let HAVE_METADATA: UInt16 = 1 + + public static let HAVE_CURRENT_DATA: UInt16 = 2 + + public static let HAVE_FUTURE_DATA: UInt16 = 3 + + public static let HAVE_ENOUGH_DATA: UInt16 = 4 + + @ReadonlyAttribute + public var readyState: UInt16 + + @ReadonlyAttribute + public var seeking: Bool + + @ReadWriteAttribute + public var currentTime: Double + + @inlinable public func fastSeek(time: Double) { + let this = jsObject + _ = this[Strings.fastSeek].function!(this: this, arguments: [time.jsValue]) + } + + @ReadonlyAttribute + public var duration: Double + + @inlinable public func getStartDate() -> JSObject { + let this = jsObject + return this[Strings.getStartDate].function!(this: this, arguments: []).fromJSValue()! + } + + @ReadonlyAttribute + public var paused: Bool + + @ReadWriteAttribute + public var defaultPlaybackRate: Double + + @ReadWriteAttribute + public var playbackRate: Double + + @ReadWriteAttribute + public var preservesPitch: Bool + + @ReadonlyAttribute + public var played: TimeRanges + + @ReadonlyAttribute + public var seekable: TimeRanges + + @ReadonlyAttribute + public var ended: Bool + + @ReadWriteAttribute + public var autoplay: Bool + + @ReadWriteAttribute + public var loop: Bool + + @inlinable public func play() -> JSPromise { + let this = jsObject + return this[Strings.play].function!(this: this, arguments: []).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func play() async throws { + let this = jsObject + let _promise: JSPromise = this[Strings.play].function!(this: this, arguments: []).fromJSValue()! + _ = try await _promise.value + } + + @inlinable public func pause() { + let this = jsObject + _ = this[Strings.pause].function!(this: this, arguments: []) + } + + @ReadWriteAttribute + public var controls: Bool + + @ReadWriteAttribute + public var volume: Double + + @ReadWriteAttribute + public var muted: Bool + + @ReadWriteAttribute + public var defaultMuted: Bool + + @ReadonlyAttribute + public var audioTracks: AudioTrackList + + @ReadonlyAttribute + public var videoTracks: VideoTrackList + + @ReadonlyAttribute + public var textTracks: TextTrackList + + @inlinable public func addTextTrack(kind: TextTrackKind, label: String? = nil, language: String? = nil) -> TextTrack { + let this = jsObject + return this[Strings.addTextTrack].function!(this: this, arguments: [kind.jsValue, label?.jsValue ?? .undefined, language?.jsValue ?? .undefined]).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLMenuElement.swift b/Sources/DOMKit/WebIDL/HTMLMenuElement.swift new file mode 100644 index 00000000..633819a0 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLMenuElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLMenuElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLMenuElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _compact = ReadWriteAttribute(jsObject: jsObject, name: Strings.compact) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var compact: Bool +} diff --git a/Sources/DOMKit/WebIDL/HTMLMetaElement.swift b/Sources/DOMKit/WebIDL/HTMLMetaElement.swift new file mode 100644 index 00000000..1874c76c --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLMetaElement.swift @@ -0,0 +1,36 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLMetaElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLMetaElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _httpEquiv = ReadWriteAttribute(jsObject: jsObject, name: Strings.httpEquiv) + _content = ReadWriteAttribute(jsObject: jsObject, name: Strings.content) + _media = ReadWriteAttribute(jsObject: jsObject, name: Strings.media) + _scheme = ReadWriteAttribute(jsObject: jsObject, name: Strings.scheme) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var name: String + + @ReadWriteAttribute + public var httpEquiv: String + + @ReadWriteAttribute + public var content: String + + @ReadWriteAttribute + public var media: String + + @ReadWriteAttribute + public var scheme: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLMeterElement.swift b/Sources/DOMKit/WebIDL/HTMLMeterElement.swift new file mode 100644 index 00000000..111eac84 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLMeterElement.swift @@ -0,0 +1,44 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLMeterElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLMeterElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _value = ReadWriteAttribute(jsObject: jsObject, name: Strings.value) + _min = ReadWriteAttribute(jsObject: jsObject, name: Strings.min) + _max = ReadWriteAttribute(jsObject: jsObject, name: Strings.max) + _low = ReadWriteAttribute(jsObject: jsObject, name: Strings.low) + _high = ReadWriteAttribute(jsObject: jsObject, name: Strings.high) + _optimum = ReadWriteAttribute(jsObject: jsObject, name: Strings.optimum) + _labels = ReadonlyAttribute(jsObject: jsObject, name: Strings.labels) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var value: Double + + @ReadWriteAttribute + public var min: Double + + @ReadWriteAttribute + public var max: Double + + @ReadWriteAttribute + public var low: Double + + @ReadWriteAttribute + public var high: Double + + @ReadWriteAttribute + public var optimum: Double + + @ReadonlyAttribute + public var labels: NodeList +} diff --git a/Sources/DOMKit/WebIDL/HTMLModElement.swift b/Sources/DOMKit/WebIDL/HTMLModElement.swift new file mode 100644 index 00000000..7b4ebe9f --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLModElement.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLModElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLModElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _cite = ReadWriteAttribute(jsObject: jsObject, name: Strings.cite) + _dateTime = ReadWriteAttribute(jsObject: jsObject, name: Strings.dateTime) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var cite: String + + @ReadWriteAttribute + public var dateTime: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLOListElement.swift b/Sources/DOMKit/WebIDL/HTMLOListElement.swift new file mode 100644 index 00000000..edc55fef --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLOListElement.swift @@ -0,0 +1,32 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLOListElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLOListElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _reversed = ReadWriteAttribute(jsObject: jsObject, name: Strings.reversed) + _start = ReadWriteAttribute(jsObject: jsObject, name: Strings.start) + _type = ReadWriteAttribute(jsObject: jsObject, name: Strings.type) + _compact = ReadWriteAttribute(jsObject: jsObject, name: Strings.compact) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var reversed: Bool + + @ReadWriteAttribute + public var start: Int32 + + @ReadWriteAttribute + public var type: String + + @ReadWriteAttribute + public var compact: Bool +} diff --git a/Sources/DOMKit/WebIDL/HTMLObjectElement.swift b/Sources/DOMKit/WebIDL/HTMLObjectElement.swift new file mode 100644 index 00000000..9ac6eb2b --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLObjectElement.swift @@ -0,0 +1,124 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLObjectElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLObjectElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _data = ReadWriteAttribute(jsObject: jsObject, name: Strings.data) + _type = ReadWriteAttribute(jsObject: jsObject, name: Strings.type) + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _form = ReadonlyAttribute(jsObject: jsObject, name: Strings.form) + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + _height = ReadWriteAttribute(jsObject: jsObject, name: Strings.height) + _contentDocument = ReadonlyAttribute(jsObject: jsObject, name: Strings.contentDocument) + _contentWindow = ReadonlyAttribute(jsObject: jsObject, name: Strings.contentWindow) + _willValidate = ReadonlyAttribute(jsObject: jsObject, name: Strings.willValidate) + _validity = ReadonlyAttribute(jsObject: jsObject, name: Strings.validity) + _validationMessage = ReadonlyAttribute(jsObject: jsObject, name: Strings.validationMessage) + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + _archive = ReadWriteAttribute(jsObject: jsObject, name: Strings.archive) + _code = ReadWriteAttribute(jsObject: jsObject, name: Strings.code) + _declare = ReadWriteAttribute(jsObject: jsObject, name: Strings.declare) + _hspace = ReadWriteAttribute(jsObject: jsObject, name: Strings.hspace) + _standby = ReadWriteAttribute(jsObject: jsObject, name: Strings.standby) + _vspace = ReadWriteAttribute(jsObject: jsObject, name: Strings.vspace) + _codeBase = ReadWriteAttribute(jsObject: jsObject, name: Strings.codeBase) + _codeType = ReadWriteAttribute(jsObject: jsObject, name: Strings.codeType) + _useMap = ReadWriteAttribute(jsObject: jsObject, name: Strings.useMap) + _border = ReadWriteAttribute(jsObject: jsObject, name: Strings.border) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var data: String + + @ReadWriteAttribute + public var type: String + + @ReadWriteAttribute + public var name: String + + @ReadonlyAttribute + public var form: HTMLFormElement? + + @ReadWriteAttribute + public var width: String + + @ReadWriteAttribute + public var height: String + + @ReadonlyAttribute + public var contentDocument: Document? + + @ReadonlyAttribute + public var contentWindow: WindowProxy? + + @inlinable public func getSVGDocument() -> Document? { + let this = jsObject + return this[Strings.getSVGDocument].function!(this: this, arguments: []).fromJSValue()! + } + + @ReadonlyAttribute + public var willValidate: Bool + + @ReadonlyAttribute + public var validity: ValidityState + + @ReadonlyAttribute + public var validationMessage: String + + @inlinable public func checkValidity() -> Bool { + let this = jsObject + return this[Strings.checkValidity].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func reportValidity() -> Bool { + let this = jsObject + return this[Strings.reportValidity].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func setCustomValidity(error: String) { + let this = jsObject + _ = this[Strings.setCustomValidity].function!(this: this, arguments: [error.jsValue]) + } + + @ReadWriteAttribute + public var align: String + + @ReadWriteAttribute + public var archive: String + + @ReadWriteAttribute + public var code: String + + @ReadWriteAttribute + public var declare: Bool + + @ReadWriteAttribute + public var hspace: UInt32 + + @ReadWriteAttribute + public var standby: String + + @ReadWriteAttribute + public var vspace: UInt32 + + @ReadWriteAttribute + public var codeBase: String + + @ReadWriteAttribute + public var codeType: String + + @ReadWriteAttribute + public var useMap: String + + @ReadWriteAttribute + public var border: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLOptGroupElement.swift b/Sources/DOMKit/WebIDL/HTMLOptGroupElement.swift new file mode 100644 index 00000000..32c1e198 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLOptGroupElement.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLOptGroupElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLOptGroupElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _disabled = ReadWriteAttribute(jsObject: jsObject, name: Strings.disabled) + _label = ReadWriteAttribute(jsObject: jsObject, name: Strings.label) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var disabled: Bool + + @ReadWriteAttribute + public var label: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLOptGroupElement_or_HTMLOptionElement.swift b/Sources/DOMKit/WebIDL/HTMLOptGroupElement_or_HTMLOptionElement.swift new file mode 100644 index 00000000..470cc23f --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLOptGroupElement_or_HTMLOptionElement.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_HTMLOptGroupElement_or_HTMLOptionElement: ConvertibleToJSValue {} +extension HTMLOptGroupElement: Any_HTMLOptGroupElement_or_HTMLOptionElement {} +extension HTMLOptionElement: Any_HTMLOptGroupElement_or_HTMLOptionElement {} + +public enum HTMLOptGroupElement_or_HTMLOptionElement: JSValueCompatible, Any_HTMLOptGroupElement_or_HTMLOptionElement { + case htmlOptGroupElement(HTMLOptGroupElement) + case htmlOptionElement(HTMLOptionElement) + + var htmlOptGroupElement: HTMLOptGroupElement? { + switch self { + case let .htmlOptGroupElement(htmlOptGroupElement): return htmlOptGroupElement + default: return nil + } + } + + var htmlOptionElement: HTMLOptionElement? { + switch self { + case let .htmlOptionElement(htmlOptionElement): return htmlOptionElement + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let htmlOptGroupElement: HTMLOptGroupElement = value.fromJSValue() { + return .htmlOptGroupElement(htmlOptGroupElement) + } + if let htmlOptionElement: HTMLOptionElement = value.fromJSValue() { + return .htmlOptionElement(htmlOptionElement) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .htmlOptGroupElement(htmlOptGroupElement): + return htmlOptGroupElement.jsValue + case let .htmlOptionElement(htmlOptionElement): + return htmlOptionElement.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLOptionElement.swift b/Sources/DOMKit/WebIDL/HTMLOptionElement.swift new file mode 100644 index 00000000..7b45c2cc --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLOptionElement.swift @@ -0,0 +1,48 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLOptionElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLOptionElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _disabled = ReadWriteAttribute(jsObject: jsObject, name: Strings.disabled) + _form = ReadonlyAttribute(jsObject: jsObject, name: Strings.form) + _label = ReadWriteAttribute(jsObject: jsObject, name: Strings.label) + _defaultSelected = ReadWriteAttribute(jsObject: jsObject, name: Strings.defaultSelected) + _selected = ReadWriteAttribute(jsObject: jsObject, name: Strings.selected) + _value = ReadWriteAttribute(jsObject: jsObject, name: Strings.value) + _text = ReadWriteAttribute(jsObject: jsObject, name: Strings.text) + _index = ReadonlyAttribute(jsObject: jsObject, name: Strings.index) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var disabled: Bool + + @ReadonlyAttribute + public var form: HTMLFormElement? + + @ReadWriteAttribute + public var label: String + + @ReadWriteAttribute + public var defaultSelected: Bool + + @ReadWriteAttribute + public var selected: Bool + + @ReadWriteAttribute + public var value: String + + @ReadWriteAttribute + public var text: String + + @ReadonlyAttribute + public var index: Int32 +} diff --git a/Sources/DOMKit/WebIDL/HTMLOptionsCollection.swift b/Sources/DOMKit/WebIDL/HTMLOptionsCollection.swift new file mode 100644 index 00000000..3b6256af --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLOptionsCollection.swift @@ -0,0 +1,35 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLOptionsCollection: HTMLCollection { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLOptionsCollection].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _length = ReadWriteAttribute(jsObject: jsObject, name: Strings.length) + _selectedIndex = ReadWriteAttribute(jsObject: jsObject, name: Strings.selectedIndex) + super.init(unsafelyWrapping: jsObject) + } + + @usableFromInline let _length: ReadWriteAttribute + @inlinable override public var length: UInt32 { + get { _length.wrappedValue } + set { _length.wrappedValue = newValue } + } + + // XXX: unsupported setter for keys of type UInt32 + + @inlinable public func add(element: HTMLOptGroupElement_or_HTMLOptionElement, before: HTMLElement_or_Int32? = nil) { + let this = jsObject + _ = this[Strings.add].function!(this: this, arguments: [element.jsValue, before?.jsValue ?? .undefined]) + } + + @inlinable public func remove(index: Int32) { + let this = jsObject + _ = this[Strings.remove].function!(this: this, arguments: [index.jsValue]) + } + + @ReadWriteAttribute + public var selectedIndex: Int32 +} diff --git a/Sources/DOMKit/WebIDL/HTMLOrSVGElement.swift b/Sources/DOMKit/WebIDL/HTMLOrSVGElement.swift index 1f0b0f53..867d1ed9 100644 --- a/Sources/DOMKit/WebIDL/HTMLOrSVGElement.swift +++ b/Sources/DOMKit/WebIDL/HTMLOrSVGElement.swift @@ -1,49 +1,34 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public protocol HTMLOrSVGElement: JSBridgedClass {} - public extension HTMLOrSVGElement { - var dataset: DOMStringMap { - return jsObject.dataset.fromJSValue()! - } + @inlinable var dataset: DOMStringMap { ReadonlyAttribute[Strings.dataset, in: jsObject] } - var nonce: String { - get { - return jsObject.nonce.fromJSValue()! - } - set { - jsObject.nonce = newValue.jsValue() - } + @inlinable var nonce: String { + get { ReadWriteAttribute[Strings.nonce, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.nonce, in: jsObject] = newValue } } - var autofocus: Bool { - get { - return jsObject.autofocus.fromJSValue()! - } - set { - jsObject.autofocus = newValue.jsValue() - } + @inlinable var autofocus: Bool { + get { ReadWriteAttribute[Strings.autofocus, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.autofocus, in: jsObject] = newValue } } - var tabIndex: Int32 { - get { - return jsObject.tabIndex.fromJSValue()! - } - set { - jsObject.tabIndex = newValue.jsValue() - } + @inlinable var tabIndex: Int32 { + get { ReadWriteAttribute[Strings.tabIndex, in: jsObject] } + nonmutating set { ReadWriteAttribute[Strings.tabIndex, in: jsObject] = newValue } } - func focus(options: FocusOptions = [:]) { - _ = jsObject.focus!(options.jsValue()) + @inlinable func focus(options: FocusOptions? = nil) { + let this = jsObject + _ = this[Strings.focus].function!(this: this, arguments: [options?.jsValue ?? .undefined]) } - func blur() { - _ = jsObject.blur!() + @inlinable func blur() { + let this = jsObject + _ = this[Strings.blur].function!(this: this, arguments: []) } } diff --git a/Sources/DOMKit/WebIDL/HTMLOutputElement.swift b/Sources/DOMKit/WebIDL/HTMLOutputElement.swift new file mode 100644 index 00000000..02c11f69 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLOutputElement.swift @@ -0,0 +1,71 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLOutputElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLOutputElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _htmlFor = ReadonlyAttribute(jsObject: jsObject, name: Strings.htmlFor) + _form = ReadonlyAttribute(jsObject: jsObject, name: Strings.form) + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _type = ReadonlyAttribute(jsObject: jsObject, name: Strings.type) + _defaultValue = ReadWriteAttribute(jsObject: jsObject, name: Strings.defaultValue) + _value = ReadWriteAttribute(jsObject: jsObject, name: Strings.value) + _willValidate = ReadonlyAttribute(jsObject: jsObject, name: Strings.willValidate) + _validity = ReadonlyAttribute(jsObject: jsObject, name: Strings.validity) + _validationMessage = ReadonlyAttribute(jsObject: jsObject, name: Strings.validationMessage) + _labels = ReadonlyAttribute(jsObject: jsObject, name: Strings.labels) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadonlyAttribute + public var htmlFor: DOMTokenList + + @ReadonlyAttribute + public var form: HTMLFormElement? + + @ReadWriteAttribute + public var name: String + + @ReadonlyAttribute + public var type: String + + @ReadWriteAttribute + public var defaultValue: String + + @ReadWriteAttribute + public var value: String + + @ReadonlyAttribute + public var willValidate: Bool + + @ReadonlyAttribute + public var validity: ValidityState + + @ReadonlyAttribute + public var validationMessage: String + + @inlinable public func checkValidity() -> Bool { + let this = jsObject + return this[Strings.checkValidity].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func reportValidity() -> Bool { + let this = jsObject + return this[Strings.reportValidity].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func setCustomValidity(error: String) { + let this = jsObject + _ = this[Strings.setCustomValidity].function!(this: this, arguments: [error.jsValue]) + } + + @ReadonlyAttribute + public var labels: NodeList +} diff --git a/Sources/DOMKit/WebIDL/HTMLParagraphElement.swift b/Sources/DOMKit/WebIDL/HTMLParagraphElement.swift new file mode 100644 index 00000000..11aeed63 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLParagraphElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLParagraphElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLParagraphElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var align: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLParamElement.swift b/Sources/DOMKit/WebIDL/HTMLParamElement.swift new file mode 100644 index 00000000..25181450 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLParamElement.swift @@ -0,0 +1,32 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLParamElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLParamElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _value = ReadWriteAttribute(jsObject: jsObject, name: Strings.value) + _type = ReadWriteAttribute(jsObject: jsObject, name: Strings.type) + _valueType = ReadWriteAttribute(jsObject: jsObject, name: Strings.valueType) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var name: String + + @ReadWriteAttribute + public var value: String + + @ReadWriteAttribute + public var type: String + + @ReadWriteAttribute + public var valueType: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLPictureElement.swift b/Sources/DOMKit/WebIDL/HTMLPictureElement.swift new file mode 100644 index 00000000..1c41e52a --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLPictureElement.swift @@ -0,0 +1,16 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLPictureElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLPictureElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLPreElement.swift b/Sources/DOMKit/WebIDL/HTMLPreElement.swift new file mode 100644 index 00000000..e4baf35f --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLPreElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLPreElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLPreElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var width: Int32 +} diff --git a/Sources/DOMKit/WebIDL/HTMLProgressElement.swift b/Sources/DOMKit/WebIDL/HTMLProgressElement.swift new file mode 100644 index 00000000..b976c2e9 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLProgressElement.swift @@ -0,0 +1,32 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLProgressElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLProgressElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _value = ReadWriteAttribute(jsObject: jsObject, name: Strings.value) + _max = ReadWriteAttribute(jsObject: jsObject, name: Strings.max) + _position = ReadonlyAttribute(jsObject: jsObject, name: Strings.position) + _labels = ReadonlyAttribute(jsObject: jsObject, name: Strings.labels) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var value: Double + + @ReadWriteAttribute + public var max: Double + + @ReadonlyAttribute + public var position: Double + + @ReadonlyAttribute + public var labels: NodeList +} diff --git a/Sources/DOMKit/WebIDL/HTMLQuoteElement.swift b/Sources/DOMKit/WebIDL/HTMLQuoteElement.swift new file mode 100644 index 00000000..a898cf8e --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLQuoteElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLQuoteElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLQuoteElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _cite = ReadWriteAttribute(jsObject: jsObject, name: Strings.cite) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var cite: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLScriptElement.swift b/Sources/DOMKit/WebIDL/HTMLScriptElement.swift new file mode 100644 index 00000000..a9094699 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLScriptElement.swift @@ -0,0 +1,73 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLScriptElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLScriptElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _src = ReadWriteAttribute(jsObject: jsObject, name: Strings.src) + _type = ReadWriteAttribute(jsObject: jsObject, name: Strings.type) + _noModule = ReadWriteAttribute(jsObject: jsObject, name: Strings.noModule) + _async = ReadWriteAttribute(jsObject: jsObject, name: Strings.async) + _defer = ReadWriteAttribute(jsObject: jsObject, name: Strings.defer) + _crossOrigin = ReadWriteAttribute(jsObject: jsObject, name: Strings.crossOrigin) + _text = ReadWriteAttribute(jsObject: jsObject, name: Strings.text) + _integrity = ReadWriteAttribute(jsObject: jsObject, name: Strings.integrity) + _referrerPolicy = ReadWriteAttribute(jsObject: jsObject, name: Strings.referrerPolicy) + _blocking = ReadonlyAttribute(jsObject: jsObject, name: Strings.blocking) + _charset = ReadWriteAttribute(jsObject: jsObject, name: Strings.charset) + _event = ReadWriteAttribute(jsObject: jsObject, name: Strings.event) + _htmlFor = ReadWriteAttribute(jsObject: jsObject, name: Strings.htmlFor) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var src: String + + @ReadWriteAttribute + public var type: String + + @ReadWriteAttribute + public var noModule: Bool + + @ReadWriteAttribute + public var async: Bool + + @ReadWriteAttribute + public var `defer`: Bool + + @ReadWriteAttribute + public var crossOrigin: String? + + @ReadWriteAttribute + public var text: String + + @ReadWriteAttribute + public var integrity: String + + @ReadWriteAttribute + public var referrerPolicy: String + + @ReadonlyAttribute + public var blocking: DOMTokenList + + @inlinable public static func supports(type: String) -> Bool { + let this = constructor + return this[Strings.supports].function!(this: this, arguments: [type.jsValue]).fromJSValue()! + } + + @ReadWriteAttribute + public var charset: String + + @ReadWriteAttribute + public var event: String + + @ReadWriteAttribute + public var htmlFor: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLSelectElement.swift b/Sources/DOMKit/WebIDL/HTMLSelectElement.swift new file mode 100644 index 00000000..926d37f6 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLSelectElement.swift @@ -0,0 +1,125 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLSelectElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLSelectElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _autocomplete = ReadWriteAttribute(jsObject: jsObject, name: Strings.autocomplete) + _disabled = ReadWriteAttribute(jsObject: jsObject, name: Strings.disabled) + _form = ReadonlyAttribute(jsObject: jsObject, name: Strings.form) + _multiple = ReadWriteAttribute(jsObject: jsObject, name: Strings.multiple) + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _required = ReadWriteAttribute(jsObject: jsObject, name: Strings.required) + _size = ReadWriteAttribute(jsObject: jsObject, name: Strings.size) + _type = ReadonlyAttribute(jsObject: jsObject, name: Strings.type) + _options = ReadonlyAttribute(jsObject: jsObject, name: Strings.options) + _length = ReadWriteAttribute(jsObject: jsObject, name: Strings.length) + _selectedOptions = ReadonlyAttribute(jsObject: jsObject, name: Strings.selectedOptions) + _selectedIndex = ReadWriteAttribute(jsObject: jsObject, name: Strings.selectedIndex) + _value = ReadWriteAttribute(jsObject: jsObject, name: Strings.value) + _willValidate = ReadonlyAttribute(jsObject: jsObject, name: Strings.willValidate) + _validity = ReadonlyAttribute(jsObject: jsObject, name: Strings.validity) + _validationMessage = ReadonlyAttribute(jsObject: jsObject, name: Strings.validationMessage) + _labels = ReadonlyAttribute(jsObject: jsObject, name: Strings.labels) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var autocomplete: String + + @ReadWriteAttribute + public var disabled: Bool + + @ReadonlyAttribute + public var form: HTMLFormElement? + + @ReadWriteAttribute + public var multiple: Bool + + @ReadWriteAttribute + public var name: String + + @ReadWriteAttribute + public var required: Bool + + @ReadWriteAttribute + public var size: UInt32 + + @ReadonlyAttribute + public var type: String + + @ReadonlyAttribute + public var options: HTMLOptionsCollection + + @ReadWriteAttribute + public var length: UInt32 + + @inlinable public subscript(key: Int) -> HTMLOptionElement? { + jsObject[key].fromJSValue() + } + + @inlinable public func namedItem(name: String) -> HTMLOptionElement? { + let this = jsObject + return this[Strings.namedItem].function!(this: this, arguments: [name.jsValue]).fromJSValue()! + } + + @inlinable public func add(element: HTMLOptGroupElement_or_HTMLOptionElement, before: HTMLElement_or_Int32? = nil) { + let this = jsObject + _ = this[Strings.add].function!(this: this, arguments: [element.jsValue, before?.jsValue ?? .undefined]) + } + + @inlinable public func remove() { + let this = jsObject + _ = this[Strings.remove].function!(this: this, arguments: []) + } + + @inlinable public func remove(index: Int32) { + let this = jsObject + _ = this[Strings.remove].function!(this: this, arguments: [index.jsValue]) + } + + // XXX: unsupported setter for keys of type UInt32 + + @ReadonlyAttribute + public var selectedOptions: HTMLCollection + + @ReadWriteAttribute + public var selectedIndex: Int32 + + @ReadWriteAttribute + public var value: String + + @ReadonlyAttribute + public var willValidate: Bool + + @ReadonlyAttribute + public var validity: ValidityState + + @ReadonlyAttribute + public var validationMessage: String + + @inlinable public func checkValidity() -> Bool { + let this = jsObject + return this[Strings.checkValidity].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func reportValidity() -> Bool { + let this = jsObject + return this[Strings.reportValidity].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func setCustomValidity(error: String) { + let this = jsObject + _ = this[Strings.setCustomValidity].function!(this: this, arguments: [error.jsValue]) + } + + @ReadonlyAttribute + public var labels: NodeList +} diff --git a/Sources/DOMKit/WebIDL/HTMLSlotElement.swift b/Sources/DOMKit/WebIDL/HTMLSlotElement.swift index 7934b56d..a3806034 100644 --- a/Sources/DOMKit/WebIDL/HTMLSlotElement.swift +++ b/Sources/DOMKit/WebIDL/HTMLSlotElement.swift @@ -1,30 +1,35 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class HTMLSlotElement: HTMLElement { - override public class var constructor: JSFunction { JSObject.global.HTMLSlotElement.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLSlotElement].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _name = ReadWriteAttribute(jsObject: jsObject, name: "name") + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) super.init(unsafelyWrapping: jsObject) } - public convenience init() { - self.init(unsafelyWrapping: HTMLSlotElement.constructor.new()) + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) } @ReadWriteAttribute public var name: String - public func assignedNodes(options: AssignedNodesOptions = [:]) -> [Node] { - return jsObject.assignedNodes!(options.jsValue()).fromJSValue()! + @inlinable public func assignedNodes(options: AssignedNodesOptions? = nil) -> [Node] { + let this = jsObject + return this[Strings.assignedNodes].function!(this: this, arguments: [options?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func assignedElements(options: AssignedNodesOptions? = nil) -> [Element] { + let this = jsObject + return this[Strings.assignedElements].function!(this: this, arguments: [options?.jsValue ?? .undefined]).fromJSValue()! } - public func assignedElements(options: AssignedNodesOptions = [:]) -> [Element] { - return jsObject.assignedElements!(options.jsValue()).fromJSValue()! + @inlinable public func assign(nodes: Element_or_Text...) { + let this = jsObject + _ = this[Strings.assign].function!(this: this, arguments: nodes.map(\.jsValue)) } } diff --git a/Sources/DOMKit/WebIDL/HTMLSourceElement.swift b/Sources/DOMKit/WebIDL/HTMLSourceElement.swift new file mode 100644 index 00000000..6edd2ebb --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLSourceElement.swift @@ -0,0 +1,44 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLSourceElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLSourceElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _src = ReadWriteAttribute(jsObject: jsObject, name: Strings.src) + _type = ReadWriteAttribute(jsObject: jsObject, name: Strings.type) + _srcset = ReadWriteAttribute(jsObject: jsObject, name: Strings.srcset) + _sizes = ReadWriteAttribute(jsObject: jsObject, name: Strings.sizes) + _media = ReadWriteAttribute(jsObject: jsObject, name: Strings.media) + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + _height = ReadWriteAttribute(jsObject: jsObject, name: Strings.height) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var src: String + + @ReadWriteAttribute + public var type: String + + @ReadWriteAttribute + public var srcset: String + + @ReadWriteAttribute + public var sizes: String + + @ReadWriteAttribute + public var media: String + + @ReadWriteAttribute + public var width: UInt32 + + @ReadWriteAttribute + public var height: UInt32 +} diff --git a/Sources/DOMKit/WebIDL/HTMLSpanElement.swift b/Sources/DOMKit/WebIDL/HTMLSpanElement.swift new file mode 100644 index 00000000..6a91c7f1 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLSpanElement.swift @@ -0,0 +1,16 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLSpanElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLSpanElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLStyleElement.swift b/Sources/DOMKit/WebIDL/HTMLStyleElement.swift new file mode 100644 index 00000000..adabe306 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLStyleElement.swift @@ -0,0 +1,28 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLStyleElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLStyleElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _media = ReadWriteAttribute(jsObject: jsObject, name: Strings.media) + _blocking = ReadonlyAttribute(jsObject: jsObject, name: Strings.blocking) + _type = ReadWriteAttribute(jsObject: jsObject, name: Strings.type) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var media: String + + @ReadonlyAttribute + public var blocking: DOMTokenList + + @ReadWriteAttribute + public var type: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLTableCaptionElement.swift b/Sources/DOMKit/WebIDL/HTMLTableCaptionElement.swift new file mode 100644 index 00000000..20c6c3e0 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLTableCaptionElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLTableCaptionElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLTableCaptionElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var align: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLTableCellElement.swift b/Sources/DOMKit/WebIDL/HTMLTableCellElement.swift new file mode 100644 index 00000000..424c1e41 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLTableCellElement.swift @@ -0,0 +1,76 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLTableCellElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLTableCellElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _colSpan = ReadWriteAttribute(jsObject: jsObject, name: Strings.colSpan) + _rowSpan = ReadWriteAttribute(jsObject: jsObject, name: Strings.rowSpan) + _headers = ReadWriteAttribute(jsObject: jsObject, name: Strings.headers) + _cellIndex = ReadonlyAttribute(jsObject: jsObject, name: Strings.cellIndex) + _scope = ReadWriteAttribute(jsObject: jsObject, name: Strings.scope) + _abbr = ReadWriteAttribute(jsObject: jsObject, name: Strings.abbr) + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + _axis = ReadWriteAttribute(jsObject: jsObject, name: Strings.axis) + _height = ReadWriteAttribute(jsObject: jsObject, name: Strings.height) + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + _ch = ReadWriteAttribute(jsObject: jsObject, name: Strings.ch) + _chOff = ReadWriteAttribute(jsObject: jsObject, name: Strings.chOff) + _noWrap = ReadWriteAttribute(jsObject: jsObject, name: Strings.noWrap) + _vAlign = ReadWriteAttribute(jsObject: jsObject, name: Strings.vAlign) + _bgColor = ReadWriteAttribute(jsObject: jsObject, name: Strings.bgColor) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var colSpan: UInt32 + + @ReadWriteAttribute + public var rowSpan: UInt32 + + @ReadWriteAttribute + public var headers: String + + @ReadonlyAttribute + public var cellIndex: Int32 + + @ReadWriteAttribute + public var scope: String + + @ReadWriteAttribute + public var abbr: String + + @ReadWriteAttribute + public var align: String + + @ReadWriteAttribute + public var axis: String + + @ReadWriteAttribute + public var height: String + + @ReadWriteAttribute + public var width: String + + @ReadWriteAttribute + public var ch: String + + @ReadWriteAttribute + public var chOff: String + + @ReadWriteAttribute + public var noWrap: Bool + + @ReadWriteAttribute + public var vAlign: String + + @ReadWriteAttribute + public var bgColor: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLTableColElement.swift b/Sources/DOMKit/WebIDL/HTMLTableColElement.swift new file mode 100644 index 00000000..eeffb588 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLTableColElement.swift @@ -0,0 +1,40 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLTableColElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLTableColElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _span = ReadWriteAttribute(jsObject: jsObject, name: Strings.span) + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + _ch = ReadWriteAttribute(jsObject: jsObject, name: Strings.ch) + _chOff = ReadWriteAttribute(jsObject: jsObject, name: Strings.chOff) + _vAlign = ReadWriteAttribute(jsObject: jsObject, name: Strings.vAlign) + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var span: UInt32 + + @ReadWriteAttribute + public var align: String + + @ReadWriteAttribute + public var ch: String + + @ReadWriteAttribute + public var chOff: String + + @ReadWriteAttribute + public var vAlign: String + + @ReadWriteAttribute + public var width: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLTableElement.swift b/Sources/DOMKit/WebIDL/HTMLTableElement.swift new file mode 100644 index 00000000..b6ac1f84 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLTableElement.swift @@ -0,0 +1,117 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLTableElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLTableElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _caption = ReadWriteAttribute(jsObject: jsObject, name: Strings.caption) + _tHead = ReadWriteAttribute(jsObject: jsObject, name: Strings.tHead) + _tFoot = ReadWriteAttribute(jsObject: jsObject, name: Strings.tFoot) + _tBodies = ReadonlyAttribute(jsObject: jsObject, name: Strings.tBodies) + _rows = ReadonlyAttribute(jsObject: jsObject, name: Strings.rows) + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + _border = ReadWriteAttribute(jsObject: jsObject, name: Strings.border) + _frame = ReadWriteAttribute(jsObject: jsObject, name: Strings.frame) + _rules = ReadWriteAttribute(jsObject: jsObject, name: Strings.rules) + _summary = ReadWriteAttribute(jsObject: jsObject, name: Strings.summary) + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + _bgColor = ReadWriteAttribute(jsObject: jsObject, name: Strings.bgColor) + _cellPadding = ReadWriteAttribute(jsObject: jsObject, name: Strings.cellPadding) + _cellSpacing = ReadWriteAttribute(jsObject: jsObject, name: Strings.cellSpacing) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var caption: HTMLTableCaptionElement? + + @inlinable public func createCaption() -> HTMLTableCaptionElement { + let this = jsObject + return this[Strings.createCaption].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func deleteCaption() { + let this = jsObject + _ = this[Strings.deleteCaption].function!(this: this, arguments: []) + } + + @ReadWriteAttribute + public var tHead: HTMLTableSectionElement? + + @inlinable public func createTHead() -> HTMLTableSectionElement { + let this = jsObject + return this[Strings.createTHead].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func deleteTHead() { + let this = jsObject + _ = this[Strings.deleteTHead].function!(this: this, arguments: []) + } + + @ReadWriteAttribute + public var tFoot: HTMLTableSectionElement? + + @inlinable public func createTFoot() -> HTMLTableSectionElement { + let this = jsObject + return this[Strings.createTFoot].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func deleteTFoot() { + let this = jsObject + _ = this[Strings.deleteTFoot].function!(this: this, arguments: []) + } + + @ReadonlyAttribute + public var tBodies: HTMLCollection + + @inlinable public func createTBody() -> HTMLTableSectionElement { + let this = jsObject + return this[Strings.createTBody].function!(this: this, arguments: []).fromJSValue()! + } + + @ReadonlyAttribute + public var rows: HTMLCollection + + @inlinable public func insertRow(index: Int32? = nil) -> HTMLTableRowElement { + let this = jsObject + return this[Strings.insertRow].function!(this: this, arguments: [index?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func deleteRow(index: Int32) { + let this = jsObject + _ = this[Strings.deleteRow].function!(this: this, arguments: [index.jsValue]) + } + + @ReadWriteAttribute + public var align: String + + @ReadWriteAttribute + public var border: String + + @ReadWriteAttribute + public var frame: String + + @ReadWriteAttribute + public var rules: String + + @ReadWriteAttribute + public var summary: String + + @ReadWriteAttribute + public var width: String + + @ReadWriteAttribute + public var bgColor: String + + @ReadWriteAttribute + public var cellPadding: String + + @ReadWriteAttribute + public var cellSpacing: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLTableRowElement.swift b/Sources/DOMKit/WebIDL/HTMLTableRowElement.swift new file mode 100644 index 00000000..418cf8d9 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLTableRowElement.swift @@ -0,0 +1,58 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLTableRowElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLTableRowElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _rowIndex = ReadonlyAttribute(jsObject: jsObject, name: Strings.rowIndex) + _sectionRowIndex = ReadonlyAttribute(jsObject: jsObject, name: Strings.sectionRowIndex) + _cells = ReadonlyAttribute(jsObject: jsObject, name: Strings.cells) + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + _ch = ReadWriteAttribute(jsObject: jsObject, name: Strings.ch) + _chOff = ReadWriteAttribute(jsObject: jsObject, name: Strings.chOff) + _vAlign = ReadWriteAttribute(jsObject: jsObject, name: Strings.vAlign) + _bgColor = ReadWriteAttribute(jsObject: jsObject, name: Strings.bgColor) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadonlyAttribute + public var rowIndex: Int32 + + @ReadonlyAttribute + public var sectionRowIndex: Int32 + + @ReadonlyAttribute + public var cells: HTMLCollection + + @inlinable public func insertCell(index: Int32? = nil) -> HTMLTableCellElement { + let this = jsObject + return this[Strings.insertCell].function!(this: this, arguments: [index?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func deleteCell(index: Int32) { + let this = jsObject + _ = this[Strings.deleteCell].function!(this: this, arguments: [index.jsValue]) + } + + @ReadWriteAttribute + public var align: String + + @ReadWriteAttribute + public var ch: String + + @ReadWriteAttribute + public var chOff: String + + @ReadWriteAttribute + public var vAlign: String + + @ReadWriteAttribute + public var bgColor: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLTableSectionElement.swift b/Sources/DOMKit/WebIDL/HTMLTableSectionElement.swift new file mode 100644 index 00000000..4b820996 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLTableSectionElement.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLTableSectionElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLTableSectionElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _rows = ReadonlyAttribute(jsObject: jsObject, name: Strings.rows) + _align = ReadWriteAttribute(jsObject: jsObject, name: Strings.align) + _ch = ReadWriteAttribute(jsObject: jsObject, name: Strings.ch) + _chOff = ReadWriteAttribute(jsObject: jsObject, name: Strings.chOff) + _vAlign = ReadWriteAttribute(jsObject: jsObject, name: Strings.vAlign) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadonlyAttribute + public var rows: HTMLCollection + + @inlinable public func insertRow(index: Int32? = nil) -> HTMLTableRowElement { + let this = jsObject + return this[Strings.insertRow].function!(this: this, arguments: [index?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func deleteRow(index: Int32) { + let this = jsObject + _ = this[Strings.deleteRow].function!(this: this, arguments: [index.jsValue]) + } + + @ReadWriteAttribute + public var align: String + + @ReadWriteAttribute + public var ch: String + + @ReadWriteAttribute + public var chOff: String + + @ReadWriteAttribute + public var vAlign: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLTemplateElement.swift b/Sources/DOMKit/WebIDL/HTMLTemplateElement.swift new file mode 100644 index 00000000..0c417be9 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLTemplateElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLTemplateElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLTemplateElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _content = ReadonlyAttribute(jsObject: jsObject, name: Strings.content) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadonlyAttribute + public var content: DocumentFragment +} diff --git a/Sources/DOMKit/WebIDL/HTMLTextAreaElement.swift b/Sources/DOMKit/WebIDL/HTMLTextAreaElement.swift new file mode 100644 index 00000000..b9b973d6 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLTextAreaElement.swift @@ -0,0 +1,147 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLTextAreaElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLTextAreaElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _autocomplete = ReadWriteAttribute(jsObject: jsObject, name: Strings.autocomplete) + _cols = ReadWriteAttribute(jsObject: jsObject, name: Strings.cols) + _dirName = ReadWriteAttribute(jsObject: jsObject, name: Strings.dirName) + _disabled = ReadWriteAttribute(jsObject: jsObject, name: Strings.disabled) + _form = ReadonlyAttribute(jsObject: jsObject, name: Strings.form) + _maxLength = ReadWriteAttribute(jsObject: jsObject, name: Strings.maxLength) + _minLength = ReadWriteAttribute(jsObject: jsObject, name: Strings.minLength) + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _placeholder = ReadWriteAttribute(jsObject: jsObject, name: Strings.placeholder) + _readOnly = ReadWriteAttribute(jsObject: jsObject, name: Strings.readOnly) + _required = ReadWriteAttribute(jsObject: jsObject, name: Strings.required) + _rows = ReadWriteAttribute(jsObject: jsObject, name: Strings.rows) + _wrap = ReadWriteAttribute(jsObject: jsObject, name: Strings.wrap) + _type = ReadonlyAttribute(jsObject: jsObject, name: Strings.type) + _defaultValue = ReadWriteAttribute(jsObject: jsObject, name: Strings.defaultValue) + _value = ReadWriteAttribute(jsObject: jsObject, name: Strings.value) + _textLength = ReadonlyAttribute(jsObject: jsObject, name: Strings.textLength) + _willValidate = ReadonlyAttribute(jsObject: jsObject, name: Strings.willValidate) + _validity = ReadonlyAttribute(jsObject: jsObject, name: Strings.validity) + _validationMessage = ReadonlyAttribute(jsObject: jsObject, name: Strings.validationMessage) + _labels = ReadonlyAttribute(jsObject: jsObject, name: Strings.labels) + _selectionStart = ReadWriteAttribute(jsObject: jsObject, name: Strings.selectionStart) + _selectionEnd = ReadWriteAttribute(jsObject: jsObject, name: Strings.selectionEnd) + _selectionDirection = ReadWriteAttribute(jsObject: jsObject, name: Strings.selectionDirection) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var autocomplete: String + + @ReadWriteAttribute + public var cols: UInt32 + + @ReadWriteAttribute + public var dirName: String + + @ReadWriteAttribute + public var disabled: Bool + + @ReadonlyAttribute + public var form: HTMLFormElement? + + @ReadWriteAttribute + public var maxLength: Int32 + + @ReadWriteAttribute + public var minLength: Int32 + + @ReadWriteAttribute + public var name: String + + @ReadWriteAttribute + public var placeholder: String + + @ReadWriteAttribute + public var readOnly: Bool + + @ReadWriteAttribute + public var required: Bool + + @ReadWriteAttribute + public var rows: UInt32 + + @ReadWriteAttribute + public var wrap: String + + @ReadonlyAttribute + public var type: String + + @ReadWriteAttribute + public var defaultValue: String + + @ReadWriteAttribute + public var value: String + + @ReadonlyAttribute + public var textLength: UInt32 + + @ReadonlyAttribute + public var willValidate: Bool + + @ReadonlyAttribute + public var validity: ValidityState + + @ReadonlyAttribute + public var validationMessage: String + + @inlinable public func checkValidity() -> Bool { + let this = jsObject + return this[Strings.checkValidity].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func reportValidity() -> Bool { + let this = jsObject + return this[Strings.reportValidity].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func setCustomValidity(error: String) { + let this = jsObject + _ = this[Strings.setCustomValidity].function!(this: this, arguments: [error.jsValue]) + } + + @ReadonlyAttribute + public var labels: NodeList + + @inlinable public func select() { + let this = jsObject + _ = this[Strings.select].function!(this: this, arguments: []) + } + + @ReadWriteAttribute + public var selectionStart: UInt32 + + @ReadWriteAttribute + public var selectionEnd: UInt32 + + @ReadWriteAttribute + public var selectionDirection: String + + @inlinable public func setRangeText(replacement: String) { + let this = jsObject + _ = this[Strings.setRangeText].function!(this: this, arguments: [replacement.jsValue]) + } + + @inlinable public func setRangeText(replacement: String, start: UInt32, end: UInt32, selectionMode: SelectionMode? = nil) { + let this = jsObject + _ = this[Strings.setRangeText].function!(this: this, arguments: [replacement.jsValue, start.jsValue, end.jsValue, selectionMode?.jsValue ?? .undefined]) + } + + @inlinable public func setSelectionRange(start: UInt32, end: UInt32, direction: String? = nil) { + let this = jsObject + _ = this[Strings.setSelectionRange].function!(this: this, arguments: [start.jsValue, end.jsValue, direction?.jsValue ?? .undefined]) + } +} diff --git a/Sources/DOMKit/WebIDL/HTMLTimeElement.swift b/Sources/DOMKit/WebIDL/HTMLTimeElement.swift new file mode 100644 index 00000000..3c030c96 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLTimeElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLTimeElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLTimeElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _dateTime = ReadWriteAttribute(jsObject: jsObject, name: Strings.dateTime) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var dateTime: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLTitleElement.swift b/Sources/DOMKit/WebIDL/HTMLTitleElement.swift new file mode 100644 index 00000000..a3276414 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLTitleElement.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLTitleElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLTitleElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _text = ReadWriteAttribute(jsObject: jsObject, name: Strings.text) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var text: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLTrackElement.swift b/Sources/DOMKit/WebIDL/HTMLTrackElement.swift new file mode 100644 index 00000000..e40690bc --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLTrackElement.swift @@ -0,0 +1,52 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLTrackElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLTrackElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _kind = ReadWriteAttribute(jsObject: jsObject, name: Strings.kind) + _src = ReadWriteAttribute(jsObject: jsObject, name: Strings.src) + _srclang = ReadWriteAttribute(jsObject: jsObject, name: Strings.srclang) + _label = ReadWriteAttribute(jsObject: jsObject, name: Strings.label) + _default = ReadWriteAttribute(jsObject: jsObject, name: Strings.default) + _readyState = ReadonlyAttribute(jsObject: jsObject, name: Strings.readyState) + _track = ReadonlyAttribute(jsObject: jsObject, name: Strings.track) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var kind: String + + @ReadWriteAttribute + public var src: String + + @ReadWriteAttribute + public var srclang: String + + @ReadWriteAttribute + public var label: String + + @ReadWriteAttribute + public var `default`: Bool + + public static let NONE: UInt16 = 0 + + public static let LOADING: UInt16 = 1 + + public static let LOADED: UInt16 = 2 + + public static let ERROR: UInt16 = 3 + + @ReadonlyAttribute + public var readyState: UInt16 + + @ReadonlyAttribute + public var track: TextTrack +} diff --git a/Sources/DOMKit/WebIDL/HTMLUListElement.swift b/Sources/DOMKit/WebIDL/HTMLUListElement.swift new file mode 100644 index 00000000..58fc845f --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLUListElement.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLUListElement: HTMLElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLUListElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _compact = ReadWriteAttribute(jsObject: jsObject, name: Strings.compact) + _type = ReadWriteAttribute(jsObject: jsObject, name: Strings.type) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var compact: Bool + + @ReadWriteAttribute + public var type: String +} diff --git a/Sources/DOMKit/WebIDL/HTMLUnknownElement.swift b/Sources/DOMKit/WebIDL/HTMLUnknownElement.swift index 143b0bad..4fd853fa 100644 --- a/Sources/DOMKit/WebIDL/HTMLUnknownElement.swift +++ b/Sources/DOMKit/WebIDL/HTMLUnknownElement.swift @@ -1,12 +1,10 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class HTMLUnknownElement: HTMLElement { - override public class var constructor: JSFunction { JSObject.global.HTMLUnknownElement.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLUnknownElement].function! } public required init(unsafelyWrapping jsObject: JSObject) { super.init(unsafelyWrapping: jsObject) diff --git a/Sources/DOMKit/WebIDL/HTMLVideoElement.swift b/Sources/DOMKit/WebIDL/HTMLVideoElement.swift new file mode 100644 index 00000000..b194737d --- /dev/null +++ b/Sources/DOMKit/WebIDL/HTMLVideoElement.swift @@ -0,0 +1,40 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HTMLVideoElement: HTMLMediaElement { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HTMLVideoElement].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + _height = ReadWriteAttribute(jsObject: jsObject, name: Strings.height) + _videoWidth = ReadonlyAttribute(jsObject: jsObject, name: Strings.videoWidth) + _videoHeight = ReadonlyAttribute(jsObject: jsObject, name: Strings.videoHeight) + _poster = ReadWriteAttribute(jsObject: jsObject, name: Strings.poster) + _playsInline = ReadWriteAttribute(jsObject: jsObject, name: Strings.playsInline) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadWriteAttribute + public var width: UInt32 + + @ReadWriteAttribute + public var height: UInt32 + + @ReadonlyAttribute + public var videoWidth: UInt32 + + @ReadonlyAttribute + public var videoHeight: UInt32 + + @ReadWriteAttribute + public var poster: String + + @ReadWriteAttribute + public var playsInline: Bool +} diff --git a/Sources/DOMKit/WebIDL/HashChangeEvent.swift b/Sources/DOMKit/WebIDL/HashChangeEvent.swift new file mode 100644 index 00000000..47779d59 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HashChangeEvent.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HashChangeEvent: Event { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.HashChangeEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _oldURL = ReadonlyAttribute(jsObject: jsObject, name: Strings.oldURL) + _newURL = ReadonlyAttribute(jsObject: jsObject, name: Strings.newURL) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: HashChangeEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var oldURL: String + + @ReadonlyAttribute + public var newURL: String +} diff --git a/Sources/DOMKit/WebIDL/HashChangeEventInit.swift b/Sources/DOMKit/WebIDL/HashChangeEventInit.swift new file mode 100644 index 00000000..e9a91bc2 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HashChangeEventInit.swift @@ -0,0 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class HashChangeEventInit: BridgedDictionary { + public convenience init(oldURL: String, newURL: String) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.oldURL] = oldURL.jsValue + object[Strings.newURL] = newURL.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _oldURL = ReadWriteAttribute(jsObject: object, name: Strings.oldURL) + _newURL = ReadWriteAttribute(jsObject: object, name: Strings.newURL) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var oldURL: String + + @ReadWriteAttribute + public var newURL: String +} diff --git a/Sources/DOMKit/WebIDL/Headers.swift b/Sources/DOMKit/WebIDL/Headers.swift new file mode 100644 index 00000000..a34995c9 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Headers.swift @@ -0,0 +1,48 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class Headers: JSBridgedClass, Sequence { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.Headers].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + @inlinable public convenience init(init: HeadersInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [`init`?.jsValue ?? .undefined])) + } + + @inlinable public func append(name: String, value: String) { + let this = jsObject + _ = this[Strings.append].function!(this: this, arguments: [name.jsValue, value.jsValue]) + } + + @inlinable public func delete(name: String) { + let this = jsObject + _ = this[Strings.delete].function!(this: this, arguments: [name.jsValue]) + } + + @inlinable public func get(name: String) -> String? { + let this = jsObject + return this[Strings.get].function!(this: this, arguments: [name.jsValue]).fromJSValue()! + } + + @inlinable public func has(name: String) -> Bool { + let this = jsObject + return this[Strings.has].function!(this: this, arguments: [name.jsValue]).fromJSValue()! + } + + @inlinable public func set(name: String, value: String) { + let this = jsObject + _ = this[Strings.set].function!(this: this, arguments: [name.jsValue, value.jsValue]) + } + + public typealias Element = String + public func makeIterator() -> ValueIterableIterator { + ValueIterableIterator(sequence: self) + } +} diff --git a/Sources/DOMKit/WebIDL/HeadersInit.swift b/Sources/DOMKit/WebIDL/HeadersInit.swift new file mode 100644 index 00000000..ca6a8236 --- /dev/null +++ b/Sources/DOMKit/WebIDL/HeadersInit.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_HeadersInit: ConvertibleToJSValue {} +extension Dictionary: Any_HeadersInit where Key == String, Value == String {} +extension Array: Any_HeadersInit where Element == [String] {} + +public enum HeadersInit: JSValueCompatible, Any_HeadersInit { + case record_String_to_String([String: String]) + case seq_of_seq_of_String([[String]]) + + var record_String_to_String: [String: String]? { + switch self { + case let .record_String_to_String(record_String_to_String): return record_String_to_String + default: return nil + } + } + + var seq_of_seq_of_String: [[String]]? { + switch self { + case let .seq_of_seq_of_String(seq_of_seq_of_String): return seq_of_seq_of_String + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let record_String_to_String: [String: String] = value.fromJSValue() { + return .record_String_to_String(record_String_to_String) + } + if let seq_of_seq_of_String: [[String]] = value.fromJSValue() { + return .seq_of_seq_of_String(seq_of_seq_of_String) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .record_String_to_String(record_String_to_String): + return record_String_to_String.jsValue + case let .seq_of_seq_of_String(seq_of_seq_of_String): + return seq_of_seq_of_String.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/History.swift b/Sources/DOMKit/WebIDL/History.swift new file mode 100644 index 00000000..4295ed2d --- /dev/null +++ b/Sources/DOMKit/WebIDL/History.swift @@ -0,0 +1,51 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class History: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.History].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + _scrollRestoration = ReadWriteAttribute(jsObject: jsObject, name: Strings.scrollRestoration) + _state = ReadonlyAttribute(jsObject: jsObject, name: Strings.state) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var length: UInt32 + + @ReadWriteAttribute + public var scrollRestoration: ScrollRestoration + + @ReadonlyAttribute + public var state: JSValue + + @inlinable public func go(delta: Int32? = nil) { + let this = jsObject + _ = this[Strings.go].function!(this: this, arguments: [delta?.jsValue ?? .undefined]) + } + + @inlinable public func back() { + let this = jsObject + _ = this[Strings.back].function!(this: this, arguments: []) + } + + @inlinable public func forward() { + let this = jsObject + _ = this[Strings.forward].function!(this: this, arguments: []) + } + + @inlinable public func pushState(data: JSValue, unused: String, url: String? = nil) { + let this = jsObject + _ = this[Strings.pushState].function!(this: this, arguments: [data.jsValue, unused.jsValue, url?.jsValue ?? .undefined]) + } + + @inlinable public func replaceState(data: JSValue, unused: String, url: String? = nil) { + let this = jsObject + _ = this[Strings.replaceState].function!(this: this, arguments: [data.jsValue, unused.jsValue, url?.jsValue ?? .undefined]) + } +} diff --git a/Sources/DOMKit/WebIDL/ImageBitmap.swift b/Sources/DOMKit/WebIDL/ImageBitmap.swift new file mode 100644 index 00000000..bb780a8c --- /dev/null +++ b/Sources/DOMKit/WebIDL/ImageBitmap.swift @@ -0,0 +1,27 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ImageBitmap: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.ImageBitmap].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _width = ReadonlyAttribute(jsObject: jsObject, name: Strings.width) + _height = ReadonlyAttribute(jsObject: jsObject, name: Strings.height) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var width: UInt32 + + @ReadonlyAttribute + public var height: UInt32 + + @inlinable public func close() { + let this = jsObject + _ = this[Strings.close].function!(this: this, arguments: []) + } +} diff --git a/Sources/DOMKit/WebIDL/ImageBitmapOptions.swift b/Sources/DOMKit/WebIDL/ImageBitmapOptions.swift new file mode 100644 index 00000000..77156700 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ImageBitmapOptions.swift @@ -0,0 +1,45 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ImageBitmapOptions: BridgedDictionary { + public convenience init(imageOrientation: ImageOrientation, premultiplyAlpha: PremultiplyAlpha, colorSpaceConversion: ColorSpaceConversion, resizeWidth: UInt32, resizeHeight: UInt32, resizeQuality: ResizeQuality) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.imageOrientation] = imageOrientation.jsValue + object[Strings.premultiplyAlpha] = premultiplyAlpha.jsValue + object[Strings.colorSpaceConversion] = colorSpaceConversion.jsValue + object[Strings.resizeWidth] = resizeWidth.jsValue + object[Strings.resizeHeight] = resizeHeight.jsValue + object[Strings.resizeQuality] = resizeQuality.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _imageOrientation = ReadWriteAttribute(jsObject: object, name: Strings.imageOrientation) + _premultiplyAlpha = ReadWriteAttribute(jsObject: object, name: Strings.premultiplyAlpha) + _colorSpaceConversion = ReadWriteAttribute(jsObject: object, name: Strings.colorSpaceConversion) + _resizeWidth = ReadWriteAttribute(jsObject: object, name: Strings.resizeWidth) + _resizeHeight = ReadWriteAttribute(jsObject: object, name: Strings.resizeHeight) + _resizeQuality = ReadWriteAttribute(jsObject: object, name: Strings.resizeQuality) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var imageOrientation: ImageOrientation + + @ReadWriteAttribute + public var premultiplyAlpha: PremultiplyAlpha + + @ReadWriteAttribute + public var colorSpaceConversion: ColorSpaceConversion + + @ReadWriteAttribute + public var resizeWidth: UInt32 + + @ReadWriteAttribute + public var resizeHeight: UInt32 + + @ReadWriteAttribute + public var resizeQuality: ResizeQuality +} diff --git a/Sources/DOMKit/WebIDL/ImageBitmapRenderingContext.swift b/Sources/DOMKit/WebIDL/ImageBitmapRenderingContext.swift new file mode 100644 index 00000000..041cb8c7 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ImageBitmapRenderingContext.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ImageBitmapRenderingContext: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.ImageBitmapRenderingContext].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _canvas = ReadonlyAttribute(jsObject: jsObject, name: Strings.canvas) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var canvas: HTMLCanvasElement_or_OffscreenCanvas + + @inlinable public func transferFromImageBitmap(bitmap: ImageBitmap?) { + let this = jsObject + _ = this[Strings.transferFromImageBitmap].function!(this: this, arguments: [bitmap.jsValue]) + } +} diff --git a/Sources/DOMKit/WebIDL/ImageBitmapRenderingContextSettings.swift b/Sources/DOMKit/WebIDL/ImageBitmapRenderingContextSettings.swift new file mode 100644 index 00000000..129ab258 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ImageBitmapRenderingContextSettings.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ImageBitmapRenderingContextSettings: BridgedDictionary { + public convenience init(alpha: Bool) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.alpha] = alpha.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _alpha = ReadWriteAttribute(jsObject: object, name: Strings.alpha) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var alpha: Bool +} diff --git a/Sources/DOMKit/WebIDL/ImageBitmapSource.swift b/Sources/DOMKit/WebIDL/ImageBitmapSource.swift new file mode 100644 index 00000000..a6b7f91c --- /dev/null +++ b/Sources/DOMKit/WebIDL/ImageBitmapSource.swift @@ -0,0 +1,60 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_ImageBitmapSource: ConvertibleToJSValue {} +extension Blob: Any_ImageBitmapSource {} +extension CanvasImageSource: Any_ImageBitmapSource {} +extension ImageData: Any_ImageBitmapSource {} + +public enum ImageBitmapSource: JSValueCompatible, Any_ImageBitmapSource { + case blob(Blob) + case canvasImageSource(CanvasImageSource) + case imageData(ImageData) + + var blob: Blob? { + switch self { + case let .blob(blob): return blob + default: return nil + } + } + + var canvasImageSource: CanvasImageSource? { + switch self { + case let .canvasImageSource(canvasImageSource): return canvasImageSource + default: return nil + } + } + + var imageData: ImageData? { + switch self { + case let .imageData(imageData): return imageData + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let blob: Blob = value.fromJSValue() { + return .blob(blob) + } + if let canvasImageSource: CanvasImageSource = value.fromJSValue() { + return .canvasImageSource(canvasImageSource) + } + if let imageData: ImageData = value.fromJSValue() { + return .imageData(imageData) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .blob(blob): + return blob.jsValue + case let .canvasImageSource(canvasImageSource): + return canvasImageSource.jsValue + case let .imageData(imageData): + return imageData.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/ImageData.swift b/Sources/DOMKit/WebIDL/ImageData.swift new file mode 100644 index 00000000..2ad76a59 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ImageData.swift @@ -0,0 +1,38 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ImageData: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.ImageData].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _width = ReadonlyAttribute(jsObject: jsObject, name: Strings.width) + _height = ReadonlyAttribute(jsObject: jsObject, name: Strings.height) + _data = ReadonlyAttribute(jsObject: jsObject, name: Strings.data) + _colorSpace = ReadonlyAttribute(jsObject: jsObject, name: Strings.colorSpace) + self.jsObject = jsObject + } + + @inlinable public convenience init(sw: UInt32, sh: UInt32, settings: ImageDataSettings? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [sw.jsValue, sh.jsValue, settings?.jsValue ?? .undefined])) + } + + @inlinable public convenience init(data: Uint8ClampedArray, sw: UInt32, sh: UInt32? = nil, settings: ImageDataSettings? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [data.jsValue, sw.jsValue, sh?.jsValue ?? .undefined, settings?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var width: UInt32 + + @ReadonlyAttribute + public var height: UInt32 + + @ReadonlyAttribute + public var data: Uint8ClampedArray + + @ReadonlyAttribute + public var colorSpace: PredefinedColorSpace +} diff --git a/Sources/DOMKit/WebIDL/ImageDataSettings.swift b/Sources/DOMKit/WebIDL/ImageDataSettings.swift new file mode 100644 index 00000000..6e784521 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ImageDataSettings.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ImageDataSettings: BridgedDictionary { + public convenience init(colorSpace: PredefinedColorSpace) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.colorSpace] = colorSpace.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _colorSpace = ReadWriteAttribute(jsObject: object, name: Strings.colorSpace) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var colorSpace: PredefinedColorSpace +} diff --git a/Sources/DOMKit/WebIDL/ImageEncodeOptions.swift b/Sources/DOMKit/WebIDL/ImageEncodeOptions.swift new file mode 100644 index 00000000..f3263062 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ImageEncodeOptions.swift @@ -0,0 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ImageEncodeOptions: BridgedDictionary { + public convenience init(type: String, quality: Double) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.type] = type.jsValue + object[Strings.quality] = quality.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _type = ReadWriteAttribute(jsObject: object, name: Strings.type) + _quality = ReadWriteAttribute(jsObject: object, name: Strings.quality) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var type: String + + @ReadWriteAttribute + public var quality: Double +} diff --git a/Sources/DOMKit/WebIDL/ImageOrientation.swift b/Sources/DOMKit/WebIDL/ImageOrientation.swift new file mode 100644 index 00000000..f8a5f79d --- /dev/null +++ b/Sources/DOMKit/WebIDL/ImageOrientation.swift @@ -0,0 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum ImageOrientation: JSString, JSValueCompatible { + case none = "none" + case flipY = "flipY" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/ImageSmoothingQuality.swift b/Sources/DOMKit/WebIDL/ImageSmoothingQuality.swift new file mode 100644 index 00000000..16cce588 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ImageSmoothingQuality.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum ImageSmoothingQuality: JSString, JSValueCompatible { + case low = "low" + case medium = "medium" + case high = "high" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/InputEvent.swift b/Sources/DOMKit/WebIDL/InputEvent.swift new file mode 100644 index 00000000..9c528a5c --- /dev/null +++ b/Sources/DOMKit/WebIDL/InputEvent.swift @@ -0,0 +1,28 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class InputEvent: UIEvent { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.InputEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _data = ReadonlyAttribute(jsObject: jsObject, name: Strings.data) + _isComposing = ReadonlyAttribute(jsObject: jsObject, name: Strings.isComposing) + _inputType = ReadonlyAttribute(jsObject: jsObject, name: Strings.inputType) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: InputEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var data: String? + + @ReadonlyAttribute + public var isComposing: Bool + + @ReadonlyAttribute + public var inputType: String +} diff --git a/Sources/DOMKit/WebIDL/InputEventInit.swift b/Sources/DOMKit/WebIDL/InputEventInit.swift new file mode 100644 index 00000000..7f6f4ebd --- /dev/null +++ b/Sources/DOMKit/WebIDL/InputEventInit.swift @@ -0,0 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class InputEventInit: BridgedDictionary { + public convenience init(data: String?, isComposing: Bool, inputType: String) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.data] = data.jsValue + object[Strings.isComposing] = isComposing.jsValue + object[Strings.inputType] = inputType.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _data = ReadWriteAttribute(jsObject: object, name: Strings.data) + _isComposing = ReadWriteAttribute(jsObject: object, name: Strings.isComposing) + _inputType = ReadWriteAttribute(jsObject: object, name: Strings.inputType) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var data: String? + + @ReadWriteAttribute + public var isComposing: Bool + + @ReadWriteAttribute + public var inputType: String +} diff --git a/Sources/DOMKit/WebIDL/KeyboardEvent.swift b/Sources/DOMKit/WebIDL/KeyboardEvent.swift new file mode 100644 index 00000000..7f3b07a7 --- /dev/null +++ b/Sources/DOMKit/WebIDL/KeyboardEvent.swift @@ -0,0 +1,88 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class KeyboardEvent: UIEvent { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.KeyboardEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _key = ReadonlyAttribute(jsObject: jsObject, name: Strings.key) + _code = ReadonlyAttribute(jsObject: jsObject, name: Strings.code) + _location = ReadonlyAttribute(jsObject: jsObject, name: Strings.location) + _ctrlKey = ReadonlyAttribute(jsObject: jsObject, name: Strings.ctrlKey) + _shiftKey = ReadonlyAttribute(jsObject: jsObject, name: Strings.shiftKey) + _altKey = ReadonlyAttribute(jsObject: jsObject, name: Strings.altKey) + _metaKey = ReadonlyAttribute(jsObject: jsObject, name: Strings.metaKey) + _repeat = ReadonlyAttribute(jsObject: jsObject, name: Strings.repeat) + _isComposing = ReadonlyAttribute(jsObject: jsObject, name: Strings.isComposing) + _charCode = ReadonlyAttribute(jsObject: jsObject, name: Strings.charCode) + _keyCode = ReadonlyAttribute(jsObject: jsObject, name: Strings.keyCode) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: KeyboardEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + public static let DOM_KEY_LOCATION_STANDARD: UInt32 = 0x00 + + public static let DOM_KEY_LOCATION_LEFT: UInt32 = 0x01 + + public static let DOM_KEY_LOCATION_RIGHT: UInt32 = 0x02 + + public static let DOM_KEY_LOCATION_NUMPAD: UInt32 = 0x03 + + @ReadonlyAttribute + public var key: String + + @ReadonlyAttribute + public var code: String + + @ReadonlyAttribute + public var location: UInt32 + + @ReadonlyAttribute + public var ctrlKey: Bool + + @ReadonlyAttribute + public var shiftKey: Bool + + @ReadonlyAttribute + public var altKey: Bool + + @ReadonlyAttribute + public var metaKey: Bool + + @ReadonlyAttribute + public var `repeat`: Bool + + @ReadonlyAttribute + public var isComposing: Bool + + @inlinable public func getModifierState(keyArg: String) -> Bool { + let this = jsObject + return this[Strings.getModifierState].function!(this: this, arguments: [keyArg.jsValue]).fromJSValue()! + } + + @inlinable public func initKeyboardEvent(typeArg: String, bubblesArg: Bool? = nil, cancelableArg: Bool? = nil, viewArg: Window? = nil, keyArg: String? = nil, locationArg: UInt32? = nil, ctrlKey: Bool? = nil, altKey: Bool? = nil, shiftKey: Bool? = nil, metaKey: Bool? = nil) { + let _arg0 = typeArg.jsValue + let _arg1 = bubblesArg?.jsValue ?? .undefined + let _arg2 = cancelableArg?.jsValue ?? .undefined + let _arg3 = viewArg?.jsValue ?? .undefined + let _arg4 = keyArg?.jsValue ?? .undefined + let _arg5 = locationArg?.jsValue ?? .undefined + let _arg6 = ctrlKey?.jsValue ?? .undefined + let _arg7 = altKey?.jsValue ?? .undefined + let _arg8 = shiftKey?.jsValue ?? .undefined + let _arg9 = metaKey?.jsValue ?? .undefined + let this = jsObject + _ = this[Strings.initKeyboardEvent].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9]) + } + + @ReadonlyAttribute + public var charCode: UInt32 + + @ReadonlyAttribute + public var keyCode: UInt32 +} diff --git a/Sources/DOMKit/WebIDL/KeyboardEventInit.swift b/Sources/DOMKit/WebIDL/KeyboardEventInit.swift new file mode 100644 index 00000000..2dc21725 --- /dev/null +++ b/Sources/DOMKit/WebIDL/KeyboardEventInit.swift @@ -0,0 +1,50 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class KeyboardEventInit: BridgedDictionary { + public convenience init(key: String, code: String, location: UInt32, repeat: Bool, isComposing: Bool, charCode: UInt32, keyCode: UInt32) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.key] = key.jsValue + object[Strings.code] = code.jsValue + object[Strings.location] = location.jsValue + object[Strings.repeat] = `repeat`.jsValue + object[Strings.isComposing] = isComposing.jsValue + object[Strings.charCode] = charCode.jsValue + object[Strings.keyCode] = keyCode.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _key = ReadWriteAttribute(jsObject: object, name: Strings.key) + _code = ReadWriteAttribute(jsObject: object, name: Strings.code) + _location = ReadWriteAttribute(jsObject: object, name: Strings.location) + _repeat = ReadWriteAttribute(jsObject: object, name: Strings.repeat) + _isComposing = ReadWriteAttribute(jsObject: object, name: Strings.isComposing) + _charCode = ReadWriteAttribute(jsObject: object, name: Strings.charCode) + _keyCode = ReadWriteAttribute(jsObject: object, name: Strings.keyCode) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var key: String + + @ReadWriteAttribute + public var code: String + + @ReadWriteAttribute + public var location: UInt32 + + @ReadWriteAttribute + public var `repeat`: Bool + + @ReadWriteAttribute + public var isComposing: Bool + + @ReadWriteAttribute + public var charCode: UInt32 + + @ReadWriteAttribute + public var keyCode: UInt32 +} diff --git a/Sources/DOMKit/WebIDL/KeyframeAnimationOptions.swift b/Sources/DOMKit/WebIDL/KeyframeAnimationOptions.swift new file mode 100644 index 00000000..0568c226 --- /dev/null +++ b/Sources/DOMKit/WebIDL/KeyframeAnimationOptions.swift @@ -0,0 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class KeyframeAnimationOptions: BridgedDictionary { + public convenience init(id: String, timeline: AnimationTimeline?) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.id] = id.jsValue + object[Strings.timeline] = timeline.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _id = ReadWriteAttribute(jsObject: object, name: Strings.id) + _timeline = ReadWriteAttribute(jsObject: object, name: Strings.timeline) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var id: String + + @ReadWriteAttribute + public var timeline: AnimationTimeline? +} diff --git a/Sources/DOMKit/WebIDL/KeyframeEffect.swift b/Sources/DOMKit/WebIDL/KeyframeEffect.swift new file mode 100644 index 00000000..9569bb56 --- /dev/null +++ b/Sources/DOMKit/WebIDL/KeyframeEffect.swift @@ -0,0 +1,42 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class KeyframeEffect: AnimationEffect { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.KeyframeEffect].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _target = ReadWriteAttribute(jsObject: jsObject, name: Strings.target) + _pseudoElement = ReadWriteAttribute(jsObject: jsObject, name: Strings.pseudoElement) + _composite = ReadWriteAttribute(jsObject: jsObject, name: Strings.composite) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(target: Element?, keyframes: JSObject?, options: Double_or_KeyframeEffectOptions? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [target.jsValue, keyframes.jsValue, options?.jsValue ?? .undefined])) + } + + @inlinable public convenience init(source: KeyframeEffect) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [source.jsValue])) + } + + @ReadWriteAttribute + public var target: Element? + + @ReadWriteAttribute + public var pseudoElement: String? + + @ReadWriteAttribute + public var composite: CompositeOperation + + @inlinable public func getKeyframes() -> [JSObject] { + let this = jsObject + return this[Strings.getKeyframes].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func setKeyframes(keyframes: JSObject?) { + let this = jsObject + _ = this[Strings.setKeyframes].function!(this: this, arguments: [keyframes.jsValue]) + } +} diff --git a/Sources/DOMKit/WebIDL/KeyframeEffectOptions.swift b/Sources/DOMKit/WebIDL/KeyframeEffectOptions.swift new file mode 100644 index 00000000..d6be80df --- /dev/null +++ b/Sources/DOMKit/WebIDL/KeyframeEffectOptions.swift @@ -0,0 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class KeyframeEffectOptions: BridgedDictionary { + public convenience init(composite: CompositeOperation, pseudoElement: String?) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.composite] = composite.jsValue + object[Strings.pseudoElement] = pseudoElement.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _composite = ReadWriteAttribute(jsObject: object, name: Strings.composite) + _pseudoElement = ReadWriteAttribute(jsObject: object, name: Strings.pseudoElement) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var composite: CompositeOperation + + @ReadWriteAttribute + public var pseudoElement: String? +} diff --git a/Sources/DOMKit/WebIDL/Location.swift b/Sources/DOMKit/WebIDL/Location.swift new file mode 100644 index 00000000..525aa304 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Location.swift @@ -0,0 +1,69 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class Location: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.Location].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _href = ReadWriteAttribute(jsObject: jsObject, name: Strings.href) + _origin = ReadonlyAttribute(jsObject: jsObject, name: Strings.origin) + _protocol = ReadWriteAttribute(jsObject: jsObject, name: Strings.protocol) + _host = ReadWriteAttribute(jsObject: jsObject, name: Strings.host) + _hostname = ReadWriteAttribute(jsObject: jsObject, name: Strings.hostname) + _port = ReadWriteAttribute(jsObject: jsObject, name: Strings.port) + _pathname = ReadWriteAttribute(jsObject: jsObject, name: Strings.pathname) + _search = ReadWriteAttribute(jsObject: jsObject, name: Strings.search) + _hash = ReadWriteAttribute(jsObject: jsObject, name: Strings.hash) + _ancestorOrigins = ReadonlyAttribute(jsObject: jsObject, name: Strings.ancestorOrigins) + self.jsObject = jsObject + } + + @ReadWriteAttribute + public var href: String + + @ReadonlyAttribute + public var origin: String + + @ReadWriteAttribute + public var `protocol`: String + + @ReadWriteAttribute + public var host: String + + @ReadWriteAttribute + public var hostname: String + + @ReadWriteAttribute + public var port: String + + @ReadWriteAttribute + public var pathname: String + + @ReadWriteAttribute + public var search: String + + @ReadWriteAttribute + public var hash: String + + @inlinable public func assign(url: String) { + let this = jsObject + _ = this[Strings.assign].function!(this: this, arguments: [url.jsValue]) + } + + @inlinable public func replace(url: String) { + let this = jsObject + _ = this[Strings.replace].function!(this: this, arguments: [url.jsValue]) + } + + @inlinable public func reload() { + let this = jsObject + _ = this[Strings.reload].function!(this: this, arguments: []) + } + + @ReadonlyAttribute + public var ancestorOrigins: DOMStringList +} diff --git a/Sources/DOMKit/WebIDL/MediaError.swift b/Sources/DOMKit/WebIDL/MediaError.swift new file mode 100644 index 00000000..1c499ab5 --- /dev/null +++ b/Sources/DOMKit/WebIDL/MediaError.swift @@ -0,0 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class MediaError: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.MediaError].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _code = ReadonlyAttribute(jsObject: jsObject, name: Strings.code) + _message = ReadonlyAttribute(jsObject: jsObject, name: Strings.message) + self.jsObject = jsObject + } + + public static let MEDIA_ERR_ABORTED: UInt16 = 1 + + public static let MEDIA_ERR_NETWORK: UInt16 = 2 + + public static let MEDIA_ERR_DECODE: UInt16 = 3 + + public static let MEDIA_ERR_SRC_NOT_SUPPORTED: UInt16 = 4 + + @ReadonlyAttribute + public var code: UInt16 + + @ReadonlyAttribute + public var message: String +} diff --git a/Sources/DOMKit/WebIDL/MessageChannel.swift b/Sources/DOMKit/WebIDL/MessageChannel.swift new file mode 100644 index 00000000..e8ddfec1 --- /dev/null +++ b/Sources/DOMKit/WebIDL/MessageChannel.swift @@ -0,0 +1,26 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class MessageChannel: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.MessageChannel].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _port1 = ReadonlyAttribute(jsObject: jsObject, name: Strings.port1) + _port2 = ReadonlyAttribute(jsObject: jsObject, name: Strings.port2) + self.jsObject = jsObject + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ReadonlyAttribute + public var port1: MessagePort + + @ReadonlyAttribute + public var port2: MessagePort +} diff --git a/Sources/DOMKit/WebIDL/MessageEvent.swift b/Sources/DOMKit/WebIDL/MessageEvent.swift new file mode 100644 index 00000000..d2b8bebf --- /dev/null +++ b/Sources/DOMKit/WebIDL/MessageEvent.swift @@ -0,0 +1,49 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class MessageEvent: Event { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.MessageEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _data = ReadonlyAttribute(jsObject: jsObject, name: Strings.data) + _origin = ReadonlyAttribute(jsObject: jsObject, name: Strings.origin) + _lastEventId = ReadonlyAttribute(jsObject: jsObject, name: Strings.lastEventId) + _source = ReadonlyAttribute(jsObject: jsObject, name: Strings.source) + _ports = ReadonlyAttribute(jsObject: jsObject, name: Strings.ports) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: MessageEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var data: JSValue + + @ReadonlyAttribute + public var origin: String + + @ReadonlyAttribute + public var lastEventId: String + + @ReadonlyAttribute + public var source: MessageEventSource? + + @ReadonlyAttribute + public var ports: [MessagePort] + + @inlinable public func initMessageEvent(type: String, bubbles: Bool? = nil, cancelable: Bool? = nil, data: JSValue? = nil, origin: String? = nil, lastEventId: String? = nil, source: MessageEventSource? = nil, ports: [MessagePort]? = nil) { + let _arg0 = type.jsValue + let _arg1 = bubbles?.jsValue ?? .undefined + let _arg2 = cancelable?.jsValue ?? .undefined + let _arg3 = data?.jsValue ?? .undefined + let _arg4 = origin?.jsValue ?? .undefined + let _arg5 = lastEventId?.jsValue ?? .undefined + let _arg6 = source?.jsValue ?? .undefined + let _arg7 = ports?.jsValue ?? .undefined + let this = jsObject + _ = this[Strings.initMessageEvent].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7]) + } +} diff --git a/Sources/DOMKit/WebIDL/MessageEventInit.swift b/Sources/DOMKit/WebIDL/MessageEventInit.swift new file mode 100644 index 00000000..61761d89 --- /dev/null +++ b/Sources/DOMKit/WebIDL/MessageEventInit.swift @@ -0,0 +1,40 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class MessageEventInit: BridgedDictionary { + public convenience init(data: JSValue, origin: String, lastEventId: String, source: MessageEventSource?, ports: [MessagePort]) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.data] = data.jsValue + object[Strings.origin] = origin.jsValue + object[Strings.lastEventId] = lastEventId.jsValue + object[Strings.source] = source.jsValue + object[Strings.ports] = ports.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _data = ReadWriteAttribute(jsObject: object, name: Strings.data) + _origin = ReadWriteAttribute(jsObject: object, name: Strings.origin) + _lastEventId = ReadWriteAttribute(jsObject: object, name: Strings.lastEventId) + _source = ReadWriteAttribute(jsObject: object, name: Strings.source) + _ports = ReadWriteAttribute(jsObject: object, name: Strings.ports) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var data: JSValue + + @ReadWriteAttribute + public var origin: String + + @ReadWriteAttribute + public var lastEventId: String + + @ReadWriteAttribute + public var source: MessageEventSource? + + @ReadWriteAttribute + public var ports: [MessagePort] +} diff --git a/Sources/DOMKit/WebIDL/MessageEventSource.swift b/Sources/DOMKit/WebIDL/MessageEventSource.swift new file mode 100644 index 00000000..bbbe2129 --- /dev/null +++ b/Sources/DOMKit/WebIDL/MessageEventSource.swift @@ -0,0 +1,60 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_MessageEventSource: ConvertibleToJSValue {} +extension MessagePort: Any_MessageEventSource {} +extension ServiceWorker: Any_MessageEventSource {} +extension WindowProxy: Any_MessageEventSource {} + +public enum MessageEventSource: JSValueCompatible, Any_MessageEventSource { + case messagePort(MessagePort) + case serviceWorker(ServiceWorker) + case windowProxy(WindowProxy) + + var messagePort: MessagePort? { + switch self { + case let .messagePort(messagePort): return messagePort + default: return nil + } + } + + var serviceWorker: ServiceWorker? { + switch self { + case let .serviceWorker(serviceWorker): return serviceWorker + default: return nil + } + } + + var windowProxy: WindowProxy? { + switch self { + case let .windowProxy(windowProxy): return windowProxy + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let messagePort: MessagePort = value.fromJSValue() { + return .messagePort(messagePort) + } + if let serviceWorker: ServiceWorker = value.fromJSValue() { + return .serviceWorker(serviceWorker) + } + if let windowProxy: WindowProxy = value.fromJSValue() { + return .windowProxy(windowProxy) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .messagePort(messagePort): + return messagePort.jsValue + case let .serviceWorker(serviceWorker): + return serviceWorker.jsValue + case let .windowProxy(windowProxy): + return windowProxy.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/MessagePort.swift b/Sources/DOMKit/WebIDL/MessagePort.swift new file mode 100644 index 00000000..d569eccf --- /dev/null +++ b/Sources/DOMKit/WebIDL/MessagePort.swift @@ -0,0 +1,40 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class MessagePort: EventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.MessagePort].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _onmessage = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onmessage) + _onmessageerror = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onmessageerror) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public func postMessage(message: JSValue, transfer: [JSObject]) { + let this = jsObject + _ = this[Strings.postMessage].function!(this: this, arguments: [message.jsValue, transfer.jsValue]) + } + + @inlinable public func postMessage(message: JSValue, options: StructuredSerializeOptions? = nil) { + let this = jsObject + _ = this[Strings.postMessage].function!(this: this, arguments: [message.jsValue, options?.jsValue ?? .undefined]) + } + + @inlinable public func start() { + let this = jsObject + _ = this[Strings.start].function!(this: this, arguments: []) + } + + @inlinable public func close() { + let this = jsObject + _ = this[Strings.close].function!(this: this, arguments: []) + } + + @ClosureAttribute1Optional + public var onmessage: EventHandler + + @ClosureAttribute1Optional + public var onmessageerror: EventHandler +} diff --git a/Sources/DOMKit/WebIDL/MimeType.swift b/Sources/DOMKit/WebIDL/MimeType.swift new file mode 100644 index 00000000..33aa20e2 --- /dev/null +++ b/Sources/DOMKit/WebIDL/MimeType.swift @@ -0,0 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class MimeType: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.MimeType].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _type = ReadonlyAttribute(jsObject: jsObject, name: Strings.type) + _description = ReadonlyAttribute(jsObject: jsObject, name: Strings.description) + _suffixes = ReadonlyAttribute(jsObject: jsObject, name: Strings.suffixes) + _enabledPlugin = ReadonlyAttribute(jsObject: jsObject, name: Strings.enabledPlugin) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var type: String + + @ReadonlyAttribute + public var description: String + + @ReadonlyAttribute + public var suffixes: String + + @ReadonlyAttribute + public var enabledPlugin: Plugin +} diff --git a/Sources/DOMKit/WebIDL/MimeTypeArray.swift b/Sources/DOMKit/WebIDL/MimeTypeArray.swift new file mode 100644 index 00000000..8dc67b43 --- /dev/null +++ b/Sources/DOMKit/WebIDL/MimeTypeArray.swift @@ -0,0 +1,26 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class MimeTypeArray: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.MimeTypeArray].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var length: UInt32 + + @inlinable public subscript(key: Int) -> MimeType? { + jsObject[key].fromJSValue() + } + + @inlinable public subscript(key: String) -> MimeType? { + jsObject[key].fromJSValue() + } +} diff --git a/Sources/DOMKit/WebIDL/MouseEvent.swift b/Sources/DOMKit/WebIDL/MouseEvent.swift new file mode 100644 index 00000000..274f1d93 --- /dev/null +++ b/Sources/DOMKit/WebIDL/MouseEvent.swift @@ -0,0 +1,85 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class MouseEvent: UIEvent { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.MouseEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _screenX = ReadonlyAttribute(jsObject: jsObject, name: Strings.screenX) + _screenY = ReadonlyAttribute(jsObject: jsObject, name: Strings.screenY) + _clientX = ReadonlyAttribute(jsObject: jsObject, name: Strings.clientX) + _clientY = ReadonlyAttribute(jsObject: jsObject, name: Strings.clientY) + _ctrlKey = ReadonlyAttribute(jsObject: jsObject, name: Strings.ctrlKey) + _shiftKey = ReadonlyAttribute(jsObject: jsObject, name: Strings.shiftKey) + _altKey = ReadonlyAttribute(jsObject: jsObject, name: Strings.altKey) + _metaKey = ReadonlyAttribute(jsObject: jsObject, name: Strings.metaKey) + _button = ReadonlyAttribute(jsObject: jsObject, name: Strings.button) + _buttons = ReadonlyAttribute(jsObject: jsObject, name: Strings.buttons) + _relatedTarget = ReadonlyAttribute(jsObject: jsObject, name: Strings.relatedTarget) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: MouseEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var screenX: Int32 + + @ReadonlyAttribute + public var screenY: Int32 + + @ReadonlyAttribute + public var clientX: Int32 + + @ReadonlyAttribute + public var clientY: Int32 + + @ReadonlyAttribute + public var ctrlKey: Bool + + @ReadonlyAttribute + public var shiftKey: Bool + + @ReadonlyAttribute + public var altKey: Bool + + @ReadonlyAttribute + public var metaKey: Bool + + @ReadonlyAttribute + public var button: Int16 + + @ReadonlyAttribute + public var buttons: UInt16 + + @ReadonlyAttribute + public var relatedTarget: EventTarget? + + @inlinable public func getModifierState(keyArg: String) -> Bool { + let this = jsObject + return this[Strings.getModifierState].function!(this: this, arguments: [keyArg.jsValue]).fromJSValue()! + } + + @inlinable public func initMouseEvent(typeArg: String, bubblesArg: Bool? = nil, cancelableArg: Bool? = nil, viewArg: Window? = nil, detailArg: Int32? = nil, screenXArg: Int32? = nil, screenYArg: Int32? = nil, clientXArg: Int32? = nil, clientYArg: Int32? = nil, ctrlKeyArg: Bool? = nil, altKeyArg: Bool? = nil, shiftKeyArg: Bool? = nil, metaKeyArg: Bool? = nil, buttonArg: Int16? = nil, relatedTargetArg: EventTarget? = nil) { + let _arg0 = typeArg.jsValue + let _arg1 = bubblesArg?.jsValue ?? .undefined + let _arg2 = cancelableArg?.jsValue ?? .undefined + let _arg3 = viewArg?.jsValue ?? .undefined + let _arg4 = detailArg?.jsValue ?? .undefined + let _arg5 = screenXArg?.jsValue ?? .undefined + let _arg6 = screenYArg?.jsValue ?? .undefined + let _arg7 = clientXArg?.jsValue ?? .undefined + let _arg8 = clientYArg?.jsValue ?? .undefined + let _arg9 = ctrlKeyArg?.jsValue ?? .undefined + let _arg10 = altKeyArg?.jsValue ?? .undefined + let _arg11 = shiftKeyArg?.jsValue ?? .undefined + let _arg12 = metaKeyArg?.jsValue ?? .undefined + let _arg13 = buttonArg?.jsValue ?? .undefined + let _arg14 = relatedTargetArg?.jsValue ?? .undefined + let this = jsObject + _ = this[Strings.initMouseEvent].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10, _arg11, _arg12, _arg13, _arg14]) + } +} diff --git a/Sources/DOMKit/WebIDL/MouseEventInit.swift b/Sources/DOMKit/WebIDL/MouseEventInit.swift new file mode 100644 index 00000000..6878df64 --- /dev/null +++ b/Sources/DOMKit/WebIDL/MouseEventInit.swift @@ -0,0 +1,50 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class MouseEventInit: BridgedDictionary { + public convenience init(screenX: Int32, screenY: Int32, clientX: Int32, clientY: Int32, button: Int16, buttons: UInt16, relatedTarget: EventTarget?) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.screenX] = screenX.jsValue + object[Strings.screenY] = screenY.jsValue + object[Strings.clientX] = clientX.jsValue + object[Strings.clientY] = clientY.jsValue + object[Strings.button] = button.jsValue + object[Strings.buttons] = buttons.jsValue + object[Strings.relatedTarget] = relatedTarget.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _screenX = ReadWriteAttribute(jsObject: object, name: Strings.screenX) + _screenY = ReadWriteAttribute(jsObject: object, name: Strings.screenY) + _clientX = ReadWriteAttribute(jsObject: object, name: Strings.clientX) + _clientY = ReadWriteAttribute(jsObject: object, name: Strings.clientY) + _button = ReadWriteAttribute(jsObject: object, name: Strings.button) + _buttons = ReadWriteAttribute(jsObject: object, name: Strings.buttons) + _relatedTarget = ReadWriteAttribute(jsObject: object, name: Strings.relatedTarget) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var screenX: Int32 + + @ReadWriteAttribute + public var screenY: Int32 + + @ReadWriteAttribute + public var clientX: Int32 + + @ReadWriteAttribute + public var clientY: Int32 + + @ReadWriteAttribute + public var button: Int16 + + @ReadWriteAttribute + public var buttons: UInt16 + + @ReadWriteAttribute + public var relatedTarget: EventTarget? +} diff --git a/Sources/DOMKit/WebIDL/MultiCacheQueryOptions.swift b/Sources/DOMKit/WebIDL/MultiCacheQueryOptions.swift new file mode 100644 index 00000000..94a1f466 --- /dev/null +++ b/Sources/DOMKit/WebIDL/MultiCacheQueryOptions.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class MultiCacheQueryOptions: BridgedDictionary { + public convenience init(cacheName: String) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.cacheName] = cacheName.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _cacheName = ReadWriteAttribute(jsObject: object, name: Strings.cacheName) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var cacheName: String +} diff --git a/Sources/DOMKit/WebIDL/MutationCallback.swift b/Sources/DOMKit/WebIDL/MutationCallback.swift deleted file mode 100644 index 3223e519..00000000 --- a/Sources/DOMKit/WebIDL/MutationCallback.swift +++ /dev/null @@ -1,8 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public typealias MutationCallback = (([MutationRecord], MutationObserver) -> Void) diff --git a/Sources/DOMKit/WebIDL/MutationEvent.swift b/Sources/DOMKit/WebIDL/MutationEvent.swift new file mode 100644 index 00000000..d81e064e --- /dev/null +++ b/Sources/DOMKit/WebIDL/MutationEvent.swift @@ -0,0 +1,51 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class MutationEvent: Event { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.MutationEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _relatedNode = ReadonlyAttribute(jsObject: jsObject, name: Strings.relatedNode) + _prevValue = ReadonlyAttribute(jsObject: jsObject, name: Strings.prevValue) + _newValue = ReadonlyAttribute(jsObject: jsObject, name: Strings.newValue) + _attrName = ReadonlyAttribute(jsObject: jsObject, name: Strings.attrName) + _attrChange = ReadonlyAttribute(jsObject: jsObject, name: Strings.attrChange) + super.init(unsafelyWrapping: jsObject) + } + + public static let MODIFICATION: UInt16 = 1 + + public static let ADDITION: UInt16 = 2 + + public static let REMOVAL: UInt16 = 3 + + @ReadonlyAttribute + public var relatedNode: Node? + + @ReadonlyAttribute + public var prevValue: String + + @ReadonlyAttribute + public var newValue: String + + @ReadonlyAttribute + public var attrName: String + + @ReadonlyAttribute + public var attrChange: UInt16 + + @inlinable public func initMutationEvent(typeArg: String, bubblesArg: Bool? = nil, cancelableArg: Bool? = nil, relatedNodeArg: Node? = nil, prevValueArg: String? = nil, newValueArg: String? = nil, attrNameArg: String? = nil, attrChangeArg: UInt16? = nil) { + let _arg0 = typeArg.jsValue + let _arg1 = bubblesArg?.jsValue ?? .undefined + let _arg2 = cancelableArg?.jsValue ?? .undefined + let _arg3 = relatedNodeArg?.jsValue ?? .undefined + let _arg4 = prevValueArg?.jsValue ?? .undefined + let _arg5 = newValueArg?.jsValue ?? .undefined + let _arg6 = attrNameArg?.jsValue ?? .undefined + let _arg7 = attrChangeArg?.jsValue ?? .undefined + let this = jsObject + _ = this[Strings.initMutationEvent].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7]) + } +} diff --git a/Sources/DOMKit/WebIDL/MutationObserver.swift b/Sources/DOMKit/WebIDL/MutationObserver.swift index c3a7eb19..9dd93278 100644 --- a/Sources/DOMKit/WebIDL/MutationObserver.swift +++ b/Sources/DOMKit/WebIDL/MutationObserver.swift @@ -1,39 +1,31 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class MutationObserver: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.MutationObserver.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.MutationObserver].function! } public let jsObject: JSObject - var closure: JSClosure? public required init(unsafelyWrapping jsObject: JSObject) { self.jsObject = jsObject } - public convenience init(callback: @escaping MutationCallback) { - let closure = JSClosure { callback($0[0].fromJSValue()!, $0[1].fromJSValue()!) } - self.init(unsafelyWrapping: MutationObserver.constructor.new(closure)) - self.closure = closure - } - - deinit { - closure?.release() - } + // XXX: constructor is ignored - public func observe(target: Node, options: MutationObserverInit = [:]) { - _ = jsObject.observe!(target.jsValue(), options.jsValue()) + @inlinable public func observe(target: Node, options: MutationObserverInit? = nil) { + let this = jsObject + _ = this[Strings.observe].function!(this: this, arguments: [target.jsValue, options?.jsValue ?? .undefined]) } - public func disconnect() { - _ = jsObject.disconnect!() + @inlinable public func disconnect() { + let this = jsObject + _ = this[Strings.disconnect].function!(this: this, arguments: []) } - public func takeRecords() -> [MutationRecord] { - return jsObject.takeRecords!().fromJSValue()! + @inlinable public func takeRecords() -> [MutationRecord] { + let this = jsObject + return this[Strings.takeRecords].function!(this: this, arguments: []).fromJSValue()! } } diff --git a/Sources/DOMKit/WebIDL/MutationObserverInit.swift b/Sources/DOMKit/WebIDL/MutationObserverInit.swift index 81f50906..ae71401c 100644 --- a/Sources/DOMKit/WebIDL/MutationObserverInit.swift +++ b/Sources/DOMKit/WebIDL/MutationObserverInit.swift @@ -1,39 +1,50 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public struct MutationObserverInit: ExpressibleByDictionaryLiteral, JSBridgedType { - public enum Key: String, Hashable { - case childList, attributes, characterData, subtree, attributeOldValue, characterDataOldValue, attributeFilter +public class MutationObserverInit: BridgedDictionary { + public convenience init(childList: Bool, attributes: Bool, characterData: Bool, subtree: Bool, attributeOldValue: Bool, characterDataOldValue: Bool, attributeFilter: [String]) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.childList] = childList.jsValue + object[Strings.attributes] = attributes.jsValue + object[Strings.characterData] = characterData.jsValue + object[Strings.subtree] = subtree.jsValue + object[Strings.attributeOldValue] = attributeOldValue.jsValue + object[Strings.characterDataOldValue] = characterDataOldValue.jsValue + object[Strings.attributeFilter] = attributeFilter.jsValue + self.init(unsafelyWrapping: object) } - private let dictionary: [String: JSValue] - - public init(uniqueKeysWithValues elements: [(Key, ConvertibleToJSValue)]) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) + public required init(unsafelyWrapping object: JSObject) { + _childList = ReadWriteAttribute(jsObject: object, name: Strings.childList) + _attributes = ReadWriteAttribute(jsObject: object, name: Strings.attributes) + _characterData = ReadWriteAttribute(jsObject: object, name: Strings.characterData) + _subtree = ReadWriteAttribute(jsObject: object, name: Strings.subtree) + _attributeOldValue = ReadWriteAttribute(jsObject: object, name: Strings.attributeOldValue) + _characterDataOldValue = ReadWriteAttribute(jsObject: object, name: Strings.characterDataOldValue) + _attributeFilter = ReadWriteAttribute(jsObject: object, name: Strings.attributeFilter) + super.init(unsafelyWrapping: object) } - public init(dictionaryLiteral elements: (Key, ConvertibleToJSValue)...) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } + @ReadWriteAttribute + public var childList: Bool - subscript(_ key: Key) -> JSValue? { - dictionary[key.rawValue] - } + @ReadWriteAttribute + public var attributes: Bool - public init?(from value: JSValue) { - if let dictionary: [String: JSValue] = value.fromJSValue() { - self.dictionary = dictionary - } - return nil - } + @ReadWriteAttribute + public var characterData: Bool - public var value: JSValue { jsValue() } + @ReadWriteAttribute + public var subtree: Bool - public func jsValue() -> JSValue { - return dictionary.jsValue() - } + @ReadWriteAttribute + public var attributeOldValue: Bool + + @ReadWriteAttribute + public var characterDataOldValue: Bool + + @ReadWriteAttribute + public var attributeFilter: [String] } diff --git a/Sources/DOMKit/WebIDL/MutationRecord.swift b/Sources/DOMKit/WebIDL/MutationRecord.swift index 66b31816..2b7a6fa1 100644 --- a/Sources/DOMKit/WebIDL/MutationRecord.swift +++ b/Sources/DOMKit/WebIDL/MutationRecord.swift @@ -1,25 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class MutationRecord: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.MutationRecord.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.MutationRecord].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _type = ReadonlyAttribute(jsObject: jsObject, name: "type") - _target = ReadonlyAttribute(jsObject: jsObject, name: "target") - _addedNodes = ReadonlyAttribute(jsObject: jsObject, name: "addedNodes") - _removedNodes = ReadonlyAttribute(jsObject: jsObject, name: "removedNodes") - _previousSibling = ReadonlyAttribute(jsObject: jsObject, name: "previousSibling") - _nextSibling = ReadonlyAttribute(jsObject: jsObject, name: "nextSibling") - _attributeName = ReadonlyAttribute(jsObject: jsObject, name: "attributeName") - _attributeNamespace = ReadonlyAttribute(jsObject: jsObject, name: "attributeNamespace") - _oldValue = ReadonlyAttribute(jsObject: jsObject, name: "oldValue") + _type = ReadonlyAttribute(jsObject: jsObject, name: Strings.type) + _target = ReadonlyAttribute(jsObject: jsObject, name: Strings.target) + _addedNodes = ReadonlyAttribute(jsObject: jsObject, name: Strings.addedNodes) + _removedNodes = ReadonlyAttribute(jsObject: jsObject, name: Strings.removedNodes) + _previousSibling = ReadonlyAttribute(jsObject: jsObject, name: Strings.previousSibling) + _nextSibling = ReadonlyAttribute(jsObject: jsObject, name: Strings.nextSibling) + _attributeName = ReadonlyAttribute(jsObject: jsObject, name: Strings.attributeName) + _attributeNamespace = ReadonlyAttribute(jsObject: jsObject, name: Strings.attributeNamespace) + _oldValue = ReadonlyAttribute(jsObject: jsObject, name: Strings.oldValue) self.jsObject = jsObject } diff --git a/Sources/DOMKit/WebIDL/NamedNodeMap.swift b/Sources/DOMKit/WebIDL/NamedNodeMap.swift index f0f85c62..36468f52 100644 --- a/Sources/DOMKit/WebIDL/NamedNodeMap.swift +++ b/Sources/DOMKit/WebIDL/NamedNodeMap.swift @@ -1,44 +1,51 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class NamedNodeMap: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.NamedNodeMap.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.NamedNodeMap].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _length = ReadonlyAttribute(jsObject: jsObject, name: "length") + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) self.jsObject = jsObject } - public subscript(_: String) -> Attr?? { - return jsObject.qualifiedName.fromJSValue()! - } - @ReadonlyAttribute public var length: UInt32 - public func getNamedItemNS(namespace: String?, localName: String) -> Attr? { - return jsObject.getNamedItemNS!(namespace.jsValue(), localName.jsValue()).fromJSValue()! + @inlinable public subscript(key: Int) -> Attr? { + jsObject[key].fromJSValue() + } + + @inlinable public subscript(key: String) -> Attr? { + jsObject[key].fromJSValue() + } + + @inlinable public func getNamedItemNS(namespace: String?, localName: String) -> Attr? { + let this = jsObject + return this[Strings.getNamedItemNS].function!(this: this, arguments: [namespace.jsValue, localName.jsValue]).fromJSValue()! } - public func setNamedItem(attr: Attr) -> Attr? { - return jsObject.setNamedItem!(attr.jsValue()).fromJSValue()! + @inlinable public func setNamedItem(attr: Attr) -> Attr? { + let this = jsObject + return this[Strings.setNamedItem].function!(this: this, arguments: [attr.jsValue]).fromJSValue()! } - public func setNamedItemNS(attr: Attr) -> Attr? { - return jsObject.setNamedItemNS!(attr.jsValue()).fromJSValue()! + @inlinable public func setNamedItemNS(attr: Attr) -> Attr? { + let this = jsObject + return this[Strings.setNamedItemNS].function!(this: this, arguments: [attr.jsValue]).fromJSValue()! } - public func removeNamedItem(qualifiedName: String) -> Attr { - return jsObject.removeNamedItem!(qualifiedName.jsValue()).fromJSValue()! + @inlinable public func removeNamedItem(qualifiedName: String) -> Attr { + let this = jsObject + return this[Strings.removeNamedItem].function!(this: this, arguments: [qualifiedName.jsValue]).fromJSValue()! } - public func removeNamedItemNS(namespace: String?, localName: String) -> Attr { - return jsObject.removeNamedItemNS!(namespace.jsValue(), localName.jsValue()).fromJSValue()! + @inlinable public func removeNamedItemNS(namespace: String?, localName: String) -> Attr { + let this = jsObject + return this[Strings.removeNamedItemNS].function!(this: this, arguments: [namespace.jsValue, localName.jsValue]).fromJSValue()! } } diff --git a/Sources/DOMKit/WebIDL/NavigationPreloadManager.swift b/Sources/DOMKit/WebIDL/NavigationPreloadManager.swift new file mode 100644 index 00000000..3484feb7 --- /dev/null +++ b/Sources/DOMKit/WebIDL/NavigationPreloadManager.swift @@ -0,0 +1,62 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class NavigationPreloadManager: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.NavigationPreloadManager].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + @inlinable public func enable() -> JSPromise { + let this = jsObject + return this[Strings.enable].function!(this: this, arguments: []).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func enable() async throws { + let this = jsObject + let _promise: JSPromise = this[Strings.enable].function!(this: this, arguments: []).fromJSValue()! + _ = try await _promise.value + } + + @inlinable public func disable() -> JSPromise { + let this = jsObject + return this[Strings.disable].function!(this: this, arguments: []).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func disable() async throws { + let this = jsObject + let _promise: JSPromise = this[Strings.disable].function!(this: this, arguments: []).fromJSValue()! + _ = try await _promise.value + } + + @inlinable public func setHeaderValue(value: String) -> JSPromise { + let this = jsObject + return this[Strings.setHeaderValue].function!(this: this, arguments: [value.jsValue]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func setHeaderValue(value: String) async throws { + let this = jsObject + let _promise: JSPromise = this[Strings.setHeaderValue].function!(this: this, arguments: [value.jsValue]).fromJSValue()! + _ = try await _promise.value + } + + @inlinable public func getState() -> JSPromise { + let this = jsObject + return this[Strings.getState].function!(this: this, arguments: []).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func getState() async throws -> NavigationPreloadState { + let this = jsObject + let _promise: JSPromise = this[Strings.getState].function!(this: this, arguments: []).fromJSValue()! + return try await _promise.value.fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/NavigationPreloadState.swift b/Sources/DOMKit/WebIDL/NavigationPreloadState.swift new file mode 100644 index 00000000..4aea9988 --- /dev/null +++ b/Sources/DOMKit/WebIDL/NavigationPreloadState.swift @@ -0,0 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class NavigationPreloadState: BridgedDictionary { + public convenience init(enabled: Bool, headerValue: String) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.enabled] = enabled.jsValue + object[Strings.headerValue] = headerValue.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _enabled = ReadWriteAttribute(jsObject: object, name: Strings.enabled) + _headerValue = ReadWriteAttribute(jsObject: object, name: Strings.headerValue) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var enabled: Bool + + @ReadWriteAttribute + public var headerValue: String +} diff --git a/Sources/DOMKit/WebIDL/Navigator.swift b/Sources/DOMKit/WebIDL/Navigator.swift new file mode 100644 index 00000000..f697818a --- /dev/null +++ b/Sources/DOMKit/WebIDL/Navigator.swift @@ -0,0 +1,18 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class Navigator: JSBridgedClass, NavigatorID, NavigatorLanguage, NavigatorOnLine, NavigatorContentUtils, NavigatorCookies, NavigatorPlugins, NavigatorConcurrentHardware { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.Navigator].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _serviceWorker = ReadonlyAttribute(jsObject: jsObject, name: Strings.serviceWorker) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var serviceWorker: ServiceWorkerContainer +} diff --git a/Sources/DOMKit/WebIDL/NavigatorConcurrentHardware.swift b/Sources/DOMKit/WebIDL/NavigatorConcurrentHardware.swift new file mode 100644 index 00000000..17b759f4 --- /dev/null +++ b/Sources/DOMKit/WebIDL/NavigatorConcurrentHardware.swift @@ -0,0 +1,9 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol NavigatorConcurrentHardware: JSBridgedClass {} +public extension NavigatorConcurrentHardware { + @inlinable var hardwareConcurrency: UInt64 { ReadonlyAttribute[Strings.hardwareConcurrency, in: jsObject] } +} diff --git a/Sources/DOMKit/WebIDL/NavigatorContentUtils.swift b/Sources/DOMKit/WebIDL/NavigatorContentUtils.swift new file mode 100644 index 00000000..02a62820 --- /dev/null +++ b/Sources/DOMKit/WebIDL/NavigatorContentUtils.swift @@ -0,0 +1,17 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol NavigatorContentUtils: JSBridgedClass {} +public extension NavigatorContentUtils { + @inlinable func registerProtocolHandler(scheme: String, url: String) { + let this = jsObject + _ = this[Strings.registerProtocolHandler].function!(this: this, arguments: [scheme.jsValue, url.jsValue]) + } + + @inlinable func unregisterProtocolHandler(scheme: String, url: String) { + let this = jsObject + _ = this[Strings.unregisterProtocolHandler].function!(this: this, arguments: [scheme.jsValue, url.jsValue]) + } +} diff --git a/Sources/DOMKit/WebIDL/NavigatorCookies.swift b/Sources/DOMKit/WebIDL/NavigatorCookies.swift new file mode 100644 index 00000000..7a35664b --- /dev/null +++ b/Sources/DOMKit/WebIDL/NavigatorCookies.swift @@ -0,0 +1,9 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol NavigatorCookies: JSBridgedClass {} +public extension NavigatorCookies { + @inlinable var cookieEnabled: Bool { ReadonlyAttribute[Strings.cookieEnabled, in: jsObject] } +} diff --git a/Sources/DOMKit/WebIDL/NavigatorID.swift b/Sources/DOMKit/WebIDL/NavigatorID.swift new file mode 100644 index 00000000..e925577d --- /dev/null +++ b/Sources/DOMKit/WebIDL/NavigatorID.swift @@ -0,0 +1,32 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol NavigatorID: JSBridgedClass {} +public extension NavigatorID { + @inlinable var appCodeName: String { ReadonlyAttribute[Strings.appCodeName, in: jsObject] } + + @inlinable var appName: String { ReadonlyAttribute[Strings.appName, in: jsObject] } + + @inlinable var appVersion: String { ReadonlyAttribute[Strings.appVersion, in: jsObject] } + + @inlinable var platform: String { ReadonlyAttribute[Strings.platform, in: jsObject] } + + @inlinable var product: String { ReadonlyAttribute[Strings.product, in: jsObject] } + + @inlinable var productSub: String { ReadonlyAttribute[Strings.productSub, in: jsObject] } + + @inlinable var userAgent: String { ReadonlyAttribute[Strings.userAgent, in: jsObject] } + + @inlinable var vendor: String { ReadonlyAttribute[Strings.vendor, in: jsObject] } + + @inlinable var vendorSub: String { ReadonlyAttribute[Strings.vendorSub, in: jsObject] } + + @inlinable func taintEnabled() -> Bool { + let this = jsObject + return this[Strings.taintEnabled].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable var oscpu: String { ReadonlyAttribute[Strings.oscpu, in: jsObject] } +} diff --git a/Sources/DOMKit/WebIDL/NavigatorLanguage.swift b/Sources/DOMKit/WebIDL/NavigatorLanguage.swift new file mode 100644 index 00000000..a692466a --- /dev/null +++ b/Sources/DOMKit/WebIDL/NavigatorLanguage.swift @@ -0,0 +1,11 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol NavigatorLanguage: JSBridgedClass {} +public extension NavigatorLanguage { + @inlinable var language: String { ReadonlyAttribute[Strings.language, in: jsObject] } + + @inlinable var languages: [String] { ReadonlyAttribute[Strings.languages, in: jsObject] } +} diff --git a/Sources/DOMKit/WebIDL/NavigatorOnLine.swift b/Sources/DOMKit/WebIDL/NavigatorOnLine.swift new file mode 100644 index 00000000..56f5b291 --- /dev/null +++ b/Sources/DOMKit/WebIDL/NavigatorOnLine.swift @@ -0,0 +1,9 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol NavigatorOnLine: JSBridgedClass {} +public extension NavigatorOnLine { + @inlinable var onLine: Bool { ReadonlyAttribute[Strings.onLine, in: jsObject] } +} diff --git a/Sources/DOMKit/WebIDL/NavigatorPlugins.swift b/Sources/DOMKit/WebIDL/NavigatorPlugins.swift new file mode 100644 index 00000000..69a000c0 --- /dev/null +++ b/Sources/DOMKit/WebIDL/NavigatorPlugins.swift @@ -0,0 +1,18 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol NavigatorPlugins: JSBridgedClass {} +public extension NavigatorPlugins { + @inlinable var plugins: PluginArray { ReadonlyAttribute[Strings.plugins, in: jsObject] } + + @inlinable var mimeTypes: MimeTypeArray { ReadonlyAttribute[Strings.mimeTypes, in: jsObject] } + + @inlinable func javaEnabled() -> Bool { + let this = jsObject + return this[Strings.javaEnabled].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable var pdfViewerEnabled: Bool { ReadonlyAttribute[Strings.pdfViewerEnabled, in: jsObject] } +} diff --git a/Sources/DOMKit/WebIDL/Node.swift b/Sources/DOMKit/WebIDL/Node.swift index 8a965825..870ce77c 100644 --- a/Sources/DOMKit/WebIDL/Node.swift +++ b/Sources/DOMKit/WebIDL/Node.swift @@ -1,54 +1,52 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class Node: EventTarget { - override public class var constructor: JSFunction { JSObject.global.Node.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.Node].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _nodeType = ReadonlyAttribute(jsObject: jsObject, name: "nodeType") - _nodeName = ReadonlyAttribute(jsObject: jsObject, name: "nodeName") - _baseURI = ReadonlyAttribute(jsObject: jsObject, name: "baseURI") - _isConnected = ReadonlyAttribute(jsObject: jsObject, name: "isConnected") - _ownerDocument = ReadonlyAttribute(jsObject: jsObject, name: "ownerDocument") - _parentNode = ReadonlyAttribute(jsObject: jsObject, name: "parentNode") - _parentElement = ReadonlyAttribute(jsObject: jsObject, name: "parentElement") - _childNodes = ReadonlyAttribute(jsObject: jsObject, name: "childNodes") - _firstChild = ReadonlyAttribute(jsObject: jsObject, name: "firstChild") - _lastChild = ReadonlyAttribute(jsObject: jsObject, name: "lastChild") - _previousSibling = ReadonlyAttribute(jsObject: jsObject, name: "previousSibling") - _nextSibling = ReadonlyAttribute(jsObject: jsObject, name: "nextSibling") - _nodeValue = ReadWriteAttribute(jsObject: jsObject, name: "nodeValue") - _textContent = ReadWriteAttribute(jsObject: jsObject, name: "textContent") + _nodeType = ReadonlyAttribute(jsObject: jsObject, name: Strings.nodeType) + _nodeName = ReadonlyAttribute(jsObject: jsObject, name: Strings.nodeName) + _baseURI = ReadonlyAttribute(jsObject: jsObject, name: Strings.baseURI) + _isConnected = ReadonlyAttribute(jsObject: jsObject, name: Strings.isConnected) + _ownerDocument = ReadonlyAttribute(jsObject: jsObject, name: Strings.ownerDocument) + _parentNode = ReadonlyAttribute(jsObject: jsObject, name: Strings.parentNode) + _parentElement = ReadonlyAttribute(jsObject: jsObject, name: Strings.parentElement) + _childNodes = ReadonlyAttribute(jsObject: jsObject, name: Strings.childNodes) + _firstChild = ReadonlyAttribute(jsObject: jsObject, name: Strings.firstChild) + _lastChild = ReadonlyAttribute(jsObject: jsObject, name: Strings.lastChild) + _previousSibling = ReadonlyAttribute(jsObject: jsObject, name: Strings.previousSibling) + _nextSibling = ReadonlyAttribute(jsObject: jsObject, name: Strings.nextSibling) + _nodeValue = ReadWriteAttribute(jsObject: jsObject, name: Strings.nodeValue) + _textContent = ReadWriteAttribute(jsObject: jsObject, name: Strings.textContent) super.init(unsafelyWrapping: jsObject) } - public let ELEMENT_NODE: UInt16 = 1 + public static let ELEMENT_NODE: UInt16 = 1 - public let ATTRIBUTE_NODE: UInt16 = 2 + public static let ATTRIBUTE_NODE: UInt16 = 2 - public let TEXT_NODE: UInt16 = 3 + public static let TEXT_NODE: UInt16 = 3 - public let CDATA_SECTION_NODE: UInt16 = 4 + public static let CDATA_SECTION_NODE: UInt16 = 4 - public let ENTITY_REFERENCE_NODE: UInt16 = 5 + public static let ENTITY_REFERENCE_NODE: UInt16 = 5 - public let ENTITY_NODE: UInt16 = 6 + public static let ENTITY_NODE: UInt16 = 6 - public let PROCESSING_INSTRUCTION_NODE: UInt16 = 7 + public static let PROCESSING_INSTRUCTION_NODE: UInt16 = 7 - public let COMMENT_NODE: UInt16 = 8 + public static let COMMENT_NODE: UInt16 = 8 - public let DOCUMENT_NODE: UInt16 = 9 + public static let DOCUMENT_NODE: UInt16 = 9 - public let DOCUMENT_TYPE_NODE: UInt16 = 10 + public static let DOCUMENT_TYPE_NODE: UInt16 = 10 - public let DOCUMENT_FRAGMENT_NODE: UInt16 = 11 + public static let DOCUMENT_FRAGMENT_NODE: UInt16 = 11 - public let NOTATION_NODE: UInt16 = 12 + public static let NOTATION_NODE: UInt16 = 12 @ReadonlyAttribute public var nodeType: UInt16 @@ -65,8 +63,9 @@ public class Node: EventTarget { @ReadonlyAttribute public var ownerDocument: Document? - public func getRootNode(options: GetRootNodeOptions = [:]) -> Node { - return jsObject.getRootNode!(options.jsValue()).fromJSValue()! + @inlinable public func getRootNode(options: GetRootNodeOptions? = nil) -> Self { + let this = jsObject + return this[Strings.getRootNode].function!(this: this, arguments: [options?.jsValue ?? .undefined]).fromJSValue()! } @ReadonlyAttribute @@ -75,8 +74,9 @@ public class Node: EventTarget { @ReadonlyAttribute public var parentElement: Element? - public func hasChildNodes() -> Bool { - return jsObject.hasChildNodes!().fromJSValue()! + @inlinable public func hasChildNodes() -> Bool { + let this = jsObject + return this[Strings.hasChildNodes].function!(this: this, arguments: []).fromJSValue()! } @ReadonlyAttribute @@ -100,67 +100,80 @@ public class Node: EventTarget { @ReadWriteAttribute public var textContent: String? - public func normalize() { - _ = jsObject.normalize!() + @inlinable public func normalize() { + let this = jsObject + _ = this[Strings.normalize].function!(this: this, arguments: []) } - public func cloneNode(deep: Bool = false) -> Node { - return jsObject.cloneNode!(deep.jsValue()).fromJSValue()! + @inlinable public func cloneNode(deep: Bool? = nil) -> Self { + let this = jsObject + return this[Strings.cloneNode].function!(this: this, arguments: [deep?.jsValue ?? .undefined]).fromJSValue()! } - public func isEqualNode(otherNode: Node?) -> Bool { - return jsObject.isEqualNode!(otherNode.jsValue()).fromJSValue()! + @inlinable public func isEqualNode(otherNode: Node?) -> Bool { + let this = jsObject + return this[Strings.isEqualNode].function!(this: this, arguments: [otherNode.jsValue]).fromJSValue()! } - public func isSameNode(otherNode: Node?) -> Bool { - return jsObject.isSameNode!(otherNode.jsValue()).fromJSValue()! + @inlinable public func isSameNode(otherNode: Node?) -> Bool { + let this = jsObject + return this[Strings.isSameNode].function!(this: this, arguments: [otherNode.jsValue]).fromJSValue()! } - public let DOCUMENT_POSITION_DISCONNECTED: UInt16 = 1 + public static let DOCUMENT_POSITION_DISCONNECTED: UInt16 = 0x01 - public let DOCUMENT_POSITION_PRECEDING: UInt16 = 2 + public static let DOCUMENT_POSITION_PRECEDING: UInt16 = 0x02 - public let DOCUMENT_POSITION_FOLLOWING: UInt16 = 4 + public static let DOCUMENT_POSITION_FOLLOWING: UInt16 = 0x04 - public let DOCUMENT_POSITION_CONTAINS: UInt16 = 8 + public static let DOCUMENT_POSITION_CONTAINS: UInt16 = 0x08 - public let DOCUMENT_POSITION_CONTAINED_BY: UInt16 = 16 + public static let DOCUMENT_POSITION_CONTAINED_BY: UInt16 = 0x10 - public let DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: UInt16 = 32 + public static let DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: UInt16 = 0x20 - public func compareDocumentPosition(other: Node) -> UInt16 { - return jsObject.compareDocumentPosition!(other.jsValue()).fromJSValue()! + @inlinable public func compareDocumentPosition(other: Node) -> UInt16 { + let this = jsObject + return this[Strings.compareDocumentPosition].function!(this: this, arguments: [other.jsValue]).fromJSValue()! } - public func contains(other: Node?) -> Bool { - return jsObject.contains!(other.jsValue()).fromJSValue()! + @inlinable public func contains(other: Node?) -> Bool { + let this = jsObject + return this[Strings.contains].function!(this: this, arguments: [other.jsValue]).fromJSValue()! } - public func lookupPrefix(namespace: String?) -> String? { - return jsObject.lookupPrefix!(namespace.jsValue()).fromJSValue()! + @inlinable public func lookupPrefix(namespace: String?) -> String? { + let this = jsObject + return this[Strings.lookupPrefix].function!(this: this, arguments: [namespace.jsValue]).fromJSValue()! } - public func lookupNamespaceURI(prefix: String?) -> String? { - return jsObject.lookupNamespaceURI!(prefix.jsValue()).fromJSValue()! + @inlinable public func lookupNamespaceURI(prefix: String?) -> String? { + let this = jsObject + return this[Strings.lookupNamespaceURI].function!(this: this, arguments: [prefix.jsValue]).fromJSValue()! } - public func isDefaultNamespace(namespace: String?) -> Bool { - return jsObject.isDefaultNamespace!(namespace.jsValue()).fromJSValue()! + @inlinable public func isDefaultNamespace(namespace: String?) -> Bool { + let this = jsObject + return this[Strings.isDefaultNamespace].function!(this: this, arguments: [namespace.jsValue]).fromJSValue()! } - public func insertBefore(node: Node, child: Node?) -> Node { - return jsObject.insertBefore!(node.jsValue(), child.jsValue()).fromJSValue()! + @inlinable public func insertBefore(node: Node, child: Node?) -> Self { + let this = jsObject + return this[Strings.insertBefore].function!(this: this, arguments: [node.jsValue, child.jsValue]).fromJSValue()! } - public func appendChild(node: Node) -> Node { - return jsObject.appendChild!(node.jsValue()).fromJSValue()! + @inlinable public func appendChild(node: Node) -> Self { + let this = jsObject + return this[Strings.appendChild].function!(this: this, arguments: [node.jsValue]).fromJSValue()! } - public func replaceChild(node: Node, child: Node) -> Node { - return jsObject.replaceChild!(node.jsValue(), child.jsValue()).fromJSValue()! + @inlinable public func replaceChild(node: Node, child: Node) -> Self { + let this = jsObject + return this[Strings.replaceChild].function!(this: this, arguments: [node.jsValue, child.jsValue]).fromJSValue()! } - public func removeChild(child: Node) -> Node { - return jsObject.removeChild!(child.jsValue()).fromJSValue()! + @inlinable public func removeChild(child: Node) -> Self { + let this = jsObject + return this[Strings.removeChild].function!(this: this, arguments: [child.jsValue]).fromJSValue()! } } diff --git a/Sources/DOMKit/WebIDL/NodeFilter.swift b/Sources/DOMKit/WebIDL/NodeFilter.swift deleted file mode 100644 index 5a048aa0..00000000 --- a/Sources/DOMKit/WebIDL/NodeFilter.swift +++ /dev/null @@ -1,76 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public protocol NodeFilter: JSBridgedType { - func acceptNode(node: Node) -> UInt16 -} - -public extension NodeFilter { - var FILTER_ACCEPT: UInt16 { - return 1 - } - - var FILTER_REJECT: UInt16 { - return 2 - } - - var FILTER_SKIP: UInt16 { - return 3 - } - - var SHOW_ALL: UInt32 { - return 4_294_967_295 - } - - var SHOW_ELEMENT: UInt32 { - return 1 - } - - var SHOW_ATTRIBUTE: UInt32 { - return 2 - } - - var SHOW_TEXT: UInt32 { - return 4 - } - - var SHOW_CDATA_SECTION: UInt32 { - return 8 - } - - var SHOW_ENTITY_REFERENCE: UInt32 { - return 16 - } - - var SHOW_ENTITY: UInt32 { - return 32 - } - - var SHOW_PROCESSING_INSTRUCTION: UInt32 { - return 64 - } - - var SHOW_COMMENT: UInt32 { - return 128 - } - - var SHOW_DOCUMENT: UInt32 { - return 256 - } - - var SHOW_DOCUMENT_TYPE: UInt32 { - return 512 - } - - var SHOW_DOCUMENT_FRAGMENT: UInt32 { - return 1024 - } - - var SHOW_NOTATION: UInt32 { - return 2048 - } -} diff --git a/Sources/DOMKit/WebIDL/NodeIterator.swift b/Sources/DOMKit/WebIDL/NodeIterator.swift index f4615b30..b3ae30eb 100644 --- a/Sources/DOMKit/WebIDL/NodeIterator.swift +++ b/Sources/DOMKit/WebIDL/NodeIterator.swift @@ -1,20 +1,18 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class NodeIterator: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.NodeIterator.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.NodeIterator].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _root = ReadonlyAttribute(jsObject: jsObject, name: "root") - _referenceNode = ReadonlyAttribute(jsObject: jsObject, name: "referenceNode") - _pointerBeforeReferenceNode = ReadonlyAttribute(jsObject: jsObject, name: "pointerBeforeReferenceNode") - _whatToShow = ReadonlyAttribute(jsObject: jsObject, name: "whatToShow") + _root = ReadonlyAttribute(jsObject: jsObject, name: Strings.root) + _referenceNode = ReadonlyAttribute(jsObject: jsObject, name: Strings.referenceNode) + _pointerBeforeReferenceNode = ReadonlyAttribute(jsObject: jsObject, name: Strings.pointerBeforeReferenceNode) + _whatToShow = ReadonlyAttribute(jsObject: jsObject, name: Strings.whatToShow) self.jsObject = jsObject } @@ -30,19 +28,20 @@ public class NodeIterator: JSBridgedClass { @ReadonlyAttribute public var whatToShow: UInt32 - public var filter: NodeFilter? { - return jsObject.filter.fromJSValue()! as AnyNodeFilter? - } + // XXX: member 'filter' is ignored - public func nextNode() -> Node? { - return jsObject.nextNode!().fromJSValue()! + @inlinable public func nextNode() -> Node? { + let this = jsObject + return this[Strings.nextNode].function!(this: this, arguments: []).fromJSValue()! } - public func previousNode() -> Node? { - return jsObject.previousNode!().fromJSValue()! + @inlinable public func previousNode() -> Node? { + let this = jsObject + return this[Strings.previousNode].function!(this: this, arguments: []).fromJSValue()! } - public func detach() { - _ = jsObject.detach!() + @inlinable public func detach() { + let this = jsObject + _ = this[Strings.detach].function!(this: this, arguments: []) } } diff --git a/Sources/DOMKit/WebIDL/NodeList.swift b/Sources/DOMKit/WebIDL/NodeList.swift index c3746e46..4e3a16f4 100644 --- a/Sources/DOMKit/WebIDL/NodeList.swift +++ b/Sources/DOMKit/WebIDL/NodeList.swift @@ -1,24 +1,27 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class NodeList: JSBridgedClass, Sequence { - public class var constructor: JSFunction { JSObject.global.NodeList.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.NodeList].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _length = ReadonlyAttribute(jsObject: jsObject, name: "length") + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) self.jsObject = jsObject } - public typealias Element = Node + @inlinable public subscript(key: Int) -> Node? { + jsObject[key].fromJSValue() + } @ReadonlyAttribute public var length: UInt32 - public func makeIterator() -> ValueIterableIterator { return ValueIterableIterator(sequence: self) } + public typealias Element = Node + public func makeIterator() -> ValueIterableIterator { + ValueIterableIterator(sequence: self) + } } diff --git a/Sources/DOMKit/WebIDL/NodeOrString.swift b/Sources/DOMKit/WebIDL/NodeOrString.swift deleted file mode 100644 index 76e353ee..00000000 --- a/Sources/DOMKit/WebIDL/NodeOrString.swift +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public enum NodeOrString: JSBridgedType, ExpressibleByStringLiteral { - case node(Node) - case string(String) - - public init?(from value: JSValue) { - if let decoded: Node = value.fromJSValue() { - self = .node(decoded) - } else if let decoded: String = value.fromJSValue() { - self = .string(decoded) - } else { - return nil - } - } - - public init(stringLiteral value: String) { - self = .string(value) - } - - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - switch self { - case let .node(v): return v.jsValue() - case let .string(v): return v.jsValue() - } - } -} diff --git a/Sources/DOMKit/WebIDL/Node_or_String.swift b/Sources/DOMKit/WebIDL/Node_or_String.swift new file mode 100644 index 00000000..9efca3bf --- /dev/null +++ b/Sources/DOMKit/WebIDL/Node_or_String.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_Node_or_String: ConvertibleToJSValue {} +extension Node: Any_Node_or_String {} +extension String: Any_Node_or_String {} + +public enum Node_or_String: JSValueCompatible, Any_Node_or_String { + case node(Node) + case string(String) + + var node: Node? { + switch self { + case let .node(node): return node + default: return nil + } + } + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let node: Node = value.fromJSValue() { + return .node(node) + } + if let string: String = value.fromJSValue() { + return .string(string) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .node(node): + return node.jsValue + case let .string(string): + return string.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/NonDocumentTypeChildNode.swift b/Sources/DOMKit/WebIDL/NonDocumentTypeChildNode.swift index 5e9e0325..211c96f3 100644 --- a/Sources/DOMKit/WebIDL/NonDocumentTypeChildNode.swift +++ b/Sources/DOMKit/WebIDL/NonDocumentTypeChildNode.swift @@ -1,18 +1,11 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public protocol NonDocumentTypeChildNode: JSBridgedClass {} - public extension NonDocumentTypeChildNode { - var previousElementSibling: Element? { - return jsObject.previousElementSibling.fromJSValue()! - } + @inlinable var previousElementSibling: Element? { ReadonlyAttribute[Strings.previousElementSibling, in: jsObject] } - var nextElementSibling: Element? { - return jsObject.nextElementSibling.fromJSValue()! - } + @inlinable var nextElementSibling: Element? { ReadonlyAttribute[Strings.nextElementSibling, in: jsObject] } } diff --git a/Sources/DOMKit/WebIDL/NonElementParentNode.swift b/Sources/DOMKit/WebIDL/NonElementParentNode.swift index 2ed2edc3..ebbbf429 100644 --- a/Sources/DOMKit/WebIDL/NonElementParentNode.swift +++ b/Sources/DOMKit/WebIDL/NonElementParentNode.swift @@ -1,14 +1,12 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public protocol NonElementParentNode: JSBridgedClass {} - public extension NonElementParentNode { - func getElementById(elementId: String) -> Element? { - return jsObject.getElementById!(elementId.jsValue()).fromJSValue()! + @inlinable func getElementById(elementId: String) -> Element? { + let this = jsObject + return this[Strings.getElementById].function!(this: this, arguments: [elementId.jsValue]).fromJSValue()! } } diff --git a/Sources/DOMKit/WebIDL/OffscreenCanvas.swift b/Sources/DOMKit/WebIDL/OffscreenCanvas.swift new file mode 100644 index 00000000..5f03a997 --- /dev/null +++ b/Sources/DOMKit/WebIDL/OffscreenCanvas.swift @@ -0,0 +1,54 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class OffscreenCanvas: EventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.OffscreenCanvas].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _width = ReadWriteAttribute(jsObject: jsObject, name: Strings.width) + _height = ReadWriteAttribute(jsObject: jsObject, name: Strings.height) + _oncontextlost = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.oncontextlost) + _oncontextrestored = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.oncontextrestored) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(width: UInt64, height: UInt64) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [width.jsValue, height.jsValue])) + } + + @ReadWriteAttribute + public var width: UInt64 + + @ReadWriteAttribute + public var height: UInt64 + + @inlinable public func getContext(contextId: OffscreenRenderingContextId, options: JSValue? = nil) -> OffscreenRenderingContext? { + let this = jsObject + return this[Strings.getContext].function!(this: this, arguments: [contextId.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func transferToImageBitmap() -> ImageBitmap { + let this = jsObject + return this[Strings.transferToImageBitmap].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func convertToBlob(options: ImageEncodeOptions? = nil) -> JSPromise { + let this = jsObject + return this[Strings.convertToBlob].function!(this: this, arguments: [options?.jsValue ?? .undefined]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func convertToBlob(options: ImageEncodeOptions? = nil) async throws -> Blob { + let this = jsObject + let _promise: JSPromise = this[Strings.convertToBlob].function!(this: this, arguments: [options?.jsValue ?? .undefined]).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @ClosureAttribute1Optional + public var oncontextlost: EventHandler + + @ClosureAttribute1Optional + public var oncontextrestored: EventHandler +} diff --git a/Sources/DOMKit/WebIDL/OffscreenCanvasRenderingContext2D.swift b/Sources/DOMKit/WebIDL/OffscreenCanvasRenderingContext2D.swift new file mode 100644 index 00000000..b37fb1fb --- /dev/null +++ b/Sources/DOMKit/WebIDL/OffscreenCanvasRenderingContext2D.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class OffscreenCanvasRenderingContext2D: JSBridgedClass, CanvasState, CanvasTransform, CanvasCompositing, CanvasImageSmoothing, CanvasFillStrokeStyles, CanvasShadowStyles, CanvasFilters, CanvasRect, CanvasDrawPath, CanvasText, CanvasDrawImage, CanvasImageData, CanvasPathDrawingStyles, CanvasTextDrawingStyles, CanvasPath { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.OffscreenCanvasRenderingContext2D].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _canvas = ReadonlyAttribute(jsObject: jsObject, name: Strings.canvas) + self.jsObject = jsObject + } + + @inlinable public func commit() { + let this = jsObject + _ = this[Strings.commit].function!(this: this, arguments: []) + } + + @ReadonlyAttribute + public var canvas: OffscreenCanvas +} diff --git a/Sources/DOMKit/WebIDL/OffscreenRenderingContextId.swift b/Sources/DOMKit/WebIDL/OffscreenRenderingContextId.swift new file mode 100644 index 00000000..a2269db5 --- /dev/null +++ b/Sources/DOMKit/WebIDL/OffscreenRenderingContextId.swift @@ -0,0 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum OffscreenRenderingContextId: JSString, JSValueCompatible { + case _2d = "2d" + case bitmaprenderer = "bitmaprenderer" + case webgl = "webgl" + case webgl2 = "webgl2" + case webgpu = "webgpu" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/OnBeforeUnloadEventHandler.swift b/Sources/DOMKit/WebIDL/OnBeforeUnloadEventHandler.swift deleted file mode 100644 index d85485ba..00000000 --- a/Sources/DOMKit/WebIDL/OnBeforeUnloadEventHandler.swift +++ /dev/null @@ -1,8 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public typealias OnBeforeUnloadEventHandler = OnBeforeUnloadEventHandlerNonNull? diff --git a/Sources/DOMKit/WebIDL/OnBeforeUnloadEventHandlerNonNull.swift b/Sources/DOMKit/WebIDL/OnBeforeUnloadEventHandlerNonNull.swift deleted file mode 100644 index 94daafd6..00000000 --- a/Sources/DOMKit/WebIDL/OnBeforeUnloadEventHandlerNonNull.swift +++ /dev/null @@ -1,8 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public typealias OnBeforeUnloadEventHandlerNonNull = ((Event) -> String?) diff --git a/Sources/DOMKit/WebIDL/OnErrorEventHandler.swift b/Sources/DOMKit/WebIDL/OnErrorEventHandler.swift deleted file mode 100644 index d9227e1c..00000000 --- a/Sources/DOMKit/WebIDL/OnErrorEventHandler.swift +++ /dev/null @@ -1,8 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public typealias OnErrorEventHandler = OnErrorEventHandlerNonNull? diff --git a/Sources/DOMKit/WebIDL/OnErrorEventHandlerNonNull.swift b/Sources/DOMKit/WebIDL/OnErrorEventHandlerNonNull.swift deleted file mode 100644 index 3bfaffe1..00000000 --- a/Sources/DOMKit/WebIDL/OnErrorEventHandlerNonNull.swift +++ /dev/null @@ -1,8 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public typealias OnErrorEventHandlerNonNull = ((EventOrString, String, UInt32, UInt32, JSValue) -> JSValue) diff --git a/Sources/DOMKit/WebIDL/OptionalEffectTiming.swift b/Sources/DOMKit/WebIDL/OptionalEffectTiming.swift new file mode 100644 index 00000000..e23c1217 --- /dev/null +++ b/Sources/DOMKit/WebIDL/OptionalEffectTiming.swift @@ -0,0 +1,55 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class OptionalEffectTiming: BridgedDictionary { + public convenience init(delay: Double, endDelay: Double, fill: FillMode, iterationStart: Double, iterations: Double, duration: Double_or_String, direction: PlaybackDirection, easing: String) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.delay] = delay.jsValue + object[Strings.endDelay] = endDelay.jsValue + object[Strings.fill] = fill.jsValue + object[Strings.iterationStart] = iterationStart.jsValue + object[Strings.iterations] = iterations.jsValue + object[Strings.duration] = duration.jsValue + object[Strings.direction] = direction.jsValue + object[Strings.easing] = easing.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _delay = ReadWriteAttribute(jsObject: object, name: Strings.delay) + _endDelay = ReadWriteAttribute(jsObject: object, name: Strings.endDelay) + _fill = ReadWriteAttribute(jsObject: object, name: Strings.fill) + _iterationStart = ReadWriteAttribute(jsObject: object, name: Strings.iterationStart) + _iterations = ReadWriteAttribute(jsObject: object, name: Strings.iterations) + _duration = ReadWriteAttribute(jsObject: object, name: Strings.duration) + _direction = ReadWriteAttribute(jsObject: object, name: Strings.direction) + _easing = ReadWriteAttribute(jsObject: object, name: Strings.easing) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var delay: Double + + @ReadWriteAttribute + public var endDelay: Double + + @ReadWriteAttribute + public var fill: FillMode + + @ReadWriteAttribute + public var iterationStart: Double + + @ReadWriteAttribute + public var iterations: Double + + @ReadWriteAttribute + public var duration: Double_or_String + + @ReadWriteAttribute + public var direction: PlaybackDirection + + @ReadWriteAttribute + public var easing: String +} diff --git a/Sources/DOMKit/WebIDL/PageTransitionEvent.swift b/Sources/DOMKit/WebIDL/PageTransitionEvent.swift new file mode 100644 index 00000000..9a451d49 --- /dev/null +++ b/Sources/DOMKit/WebIDL/PageTransitionEvent.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class PageTransitionEvent: Event { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.PageTransitionEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _persisted = ReadonlyAttribute(jsObject: jsObject, name: Strings.persisted) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: PageTransitionEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var persisted: Bool +} diff --git a/Sources/DOMKit/WebIDL/PageTransitionEventInit.swift b/Sources/DOMKit/WebIDL/PageTransitionEventInit.swift new file mode 100644 index 00000000..685734a7 --- /dev/null +++ b/Sources/DOMKit/WebIDL/PageTransitionEventInit.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class PageTransitionEventInit: BridgedDictionary { + public convenience init(persisted: Bool) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.persisted] = persisted.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _persisted = ReadWriteAttribute(jsObject: object, name: Strings.persisted) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var persisted: Bool +} diff --git a/Sources/DOMKit/WebIDL/ParentNode.swift b/Sources/DOMKit/WebIDL/ParentNode.swift index 4a8d817b..a3d4f0ac 100644 --- a/Sources/DOMKit/WebIDL/ParentNode.swift +++ b/Sources/DOMKit/WebIDL/ParentNode.swift @@ -1,50 +1,40 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public protocol ParentNode: JSBridgedClass {} - public extension ParentNode { - var children: HTMLCollection { - return jsObject.children.fromJSValue()! - } - - var firstElementChild: Element? { - return jsObject.firstElementChild.fromJSValue()! - } + @inlinable var children: HTMLCollection { ReadonlyAttribute[Strings.children, in: jsObject] } - var lastElementChild: Element? { - return jsObject.lastElementChild.fromJSValue()! - } + @inlinable var firstElementChild: Element? { ReadonlyAttribute[Strings.firstElementChild, in: jsObject] } - var childElementCount: UInt32 { - return jsObject.childElementCount.fromJSValue()! - } + @inlinable var lastElementChild: Element? { ReadonlyAttribute[Strings.lastElementChild, in: jsObject] } - func prepend(nodes: NodeOrString...) { - _ = jsObject.prepend!(nodes.jsValue()) - } + @inlinable var childElementCount: UInt32 { ReadonlyAttribute[Strings.childElementCount, in: jsObject] } - func prepend() { - _ = jsObject.prepend!() + @inlinable func prepend(nodes: Node_or_String...) { + let this = jsObject + _ = this[Strings.prepend].function!(this: this, arguments: nodes.map(\.jsValue)) } - func append(nodes: NodeOrString...) { - _ = jsObject.append!(nodes.jsValue()) + @inlinable func append(nodes: Node_or_String...) { + let this = jsObject + _ = this[Strings.append].function!(this: this, arguments: nodes.map(\.jsValue)) } - func append() { - _ = jsObject.append!() + @inlinable func replaceChildren(nodes: Node_or_String...) { + let this = jsObject + _ = this[Strings.replaceChildren].function!(this: this, arguments: nodes.map(\.jsValue)) } - func querySelector(selectors: String) -> Element? { - return jsObject.querySelector!(selectors.jsValue()).fromJSValue()! + @inlinable func querySelector(selectors: String) -> Element? { + let this = jsObject + return this[Strings.querySelector].function!(this: this, arguments: [selectors.jsValue]).fromJSValue()! } - func querySelectorAll(selectors: String) -> NodeList { - return jsObject.querySelectorAll!(selectors.jsValue()).fromJSValue()! + @inlinable func querySelectorAll(selectors: String) -> NodeList { + let this = jsObject + return this[Strings.querySelectorAll].function!(this: this, arguments: [selectors.jsValue]).fromJSValue()! } } diff --git a/Sources/DOMKit/WebIDL/Path2D.swift b/Sources/DOMKit/WebIDL/Path2D.swift new file mode 100644 index 00000000..5275df19 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Path2D.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class Path2D: JSBridgedClass, CanvasPath { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.Path2D].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + @inlinable public convenience init(path: Path2D_or_String? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [path?.jsValue ?? .undefined])) + } + + @inlinable public func addPath(path: Path2D, transform: DOMMatrix2DInit? = nil) { + let this = jsObject + _ = this[Strings.addPath].function!(this: this, arguments: [path.jsValue, transform?.jsValue ?? .undefined]) + } +} diff --git a/Sources/DOMKit/WebIDL/Path2D_or_String.swift b/Sources/DOMKit/WebIDL/Path2D_or_String.swift new file mode 100644 index 00000000..f0b175c5 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Path2D_or_String.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_Path2D_or_String: ConvertibleToJSValue {} +extension Path2D: Any_Path2D_or_String {} +extension String: Any_Path2D_or_String {} + +public enum Path2D_or_String: JSValueCompatible, Any_Path2D_or_String { + case path2D(Path2D) + case string(String) + + var path2D: Path2D? { + switch self { + case let .path2D(path2D): return path2D + default: return nil + } + } + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let path2D: Path2D = value.fromJSValue() { + return .path2D(path2D) + } + if let string: String = value.fromJSValue() { + return .string(string) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .path2D(path2D): + return path2D.jsValue + case let .string(string): + return string.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/Performance.swift b/Sources/DOMKit/WebIDL/Performance.swift new file mode 100644 index 00000000..37f8c687 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Performance.swift @@ -0,0 +1,26 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class Performance: EventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.Performance].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _timeOrigin = ReadonlyAttribute(jsObject: jsObject, name: Strings.timeOrigin) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public func now() -> DOMHighResTimeStamp { + let this = jsObject + return this[Strings.now].function!(this: this, arguments: []).fromJSValue()! + } + + @ReadonlyAttribute + public var timeOrigin: DOMHighResTimeStamp + + @inlinable public func toJSON() -> JSObject { + let this = jsObject + return this[Strings.toJSON].function!(this: this, arguments: []).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/PlaybackDirection.swift b/Sources/DOMKit/WebIDL/PlaybackDirection.swift new file mode 100644 index 00000000..ca639aea --- /dev/null +++ b/Sources/DOMKit/WebIDL/PlaybackDirection.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum PlaybackDirection: JSString, JSValueCompatible { + case normal = "normal" + case reverse = "reverse" + case alternate = "alternate" + case alternateReverse = "alternate-reverse" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/Plugin.swift b/Sources/DOMKit/WebIDL/Plugin.swift new file mode 100644 index 00000000..920bb6e0 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Plugin.swift @@ -0,0 +1,38 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class Plugin: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.Plugin].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _name = ReadonlyAttribute(jsObject: jsObject, name: Strings.name) + _description = ReadonlyAttribute(jsObject: jsObject, name: Strings.description) + _filename = ReadonlyAttribute(jsObject: jsObject, name: Strings.filename) + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var name: String + + @ReadonlyAttribute + public var description: String + + @ReadonlyAttribute + public var filename: String + + @ReadonlyAttribute + public var length: UInt32 + + @inlinable public subscript(key: Int) -> MimeType? { + jsObject[key].fromJSValue() + } + + @inlinable public subscript(key: String) -> MimeType? { + jsObject[key].fromJSValue() + } +} diff --git a/Sources/DOMKit/WebIDL/PluginArray.swift b/Sources/DOMKit/WebIDL/PluginArray.swift new file mode 100644 index 00000000..0a21853a --- /dev/null +++ b/Sources/DOMKit/WebIDL/PluginArray.swift @@ -0,0 +1,31 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class PluginArray: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.PluginArray].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + self.jsObject = jsObject + } + + @inlinable public func refresh() { + let this = jsObject + _ = this[Strings.refresh].function!(this: this, arguments: []) + } + + @ReadonlyAttribute + public var length: UInt32 + + @inlinable public subscript(key: Int) -> Plugin? { + jsObject[key].fromJSValue() + } + + @inlinable public subscript(key: String) -> Plugin? { + jsObject[key].fromJSValue() + } +} diff --git a/Sources/DOMKit/WebIDL/PopStateEvent.swift b/Sources/DOMKit/WebIDL/PopStateEvent.swift new file mode 100644 index 00000000..cbfd0e55 --- /dev/null +++ b/Sources/DOMKit/WebIDL/PopStateEvent.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class PopStateEvent: Event { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.PopStateEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _state = ReadonlyAttribute(jsObject: jsObject, name: Strings.state) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: PopStateEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var state: JSValue +} diff --git a/Sources/DOMKit/WebIDL/PopStateEventInit.swift b/Sources/DOMKit/WebIDL/PopStateEventInit.swift new file mode 100644 index 00000000..f0814184 --- /dev/null +++ b/Sources/DOMKit/WebIDL/PopStateEventInit.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class PopStateEventInit: BridgedDictionary { + public convenience init(state: JSValue) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.state] = state.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _state = ReadWriteAttribute(jsObject: object, name: Strings.state) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var state: JSValue +} diff --git a/Sources/DOMKit/WebIDL/PredefinedColorSpace.swift b/Sources/DOMKit/WebIDL/PredefinedColorSpace.swift new file mode 100644 index 00000000..67727b3f --- /dev/null +++ b/Sources/DOMKit/WebIDL/PredefinedColorSpace.swift @@ -0,0 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum PredefinedColorSpace: JSString, JSValueCompatible { + case srgb = "srgb" + case displayP3 = "display-p3" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/PremultiplyAlpha.swift b/Sources/DOMKit/WebIDL/PremultiplyAlpha.swift new file mode 100644 index 00000000..92f71592 --- /dev/null +++ b/Sources/DOMKit/WebIDL/PremultiplyAlpha.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum PremultiplyAlpha: JSString, JSValueCompatible { + case none = "none" + case premultiply = "premultiply" + case `default` = "default" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/ProcessingInstruction.swift b/Sources/DOMKit/WebIDL/ProcessingInstruction.swift index 8db31501..15913be1 100644 --- a/Sources/DOMKit/WebIDL/ProcessingInstruction.swift +++ b/Sources/DOMKit/WebIDL/ProcessingInstruction.swift @@ -1,15 +1,13 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class ProcessingInstruction: CharacterData { - override public class var constructor: JSFunction { JSObject.global.ProcessingInstruction.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.ProcessingInstruction].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _target = ReadonlyAttribute(jsObject: jsObject, name: "target") + _target = ReadonlyAttribute(jsObject: jsObject, name: Strings.target) super.init(unsafelyWrapping: jsObject) } diff --git a/Sources/DOMKit/WebIDL/ProgressEvent.swift b/Sources/DOMKit/WebIDL/ProgressEvent.swift new file mode 100644 index 00000000..2bc0d2a2 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ProgressEvent.swift @@ -0,0 +1,28 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ProgressEvent: Event { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.ProgressEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _lengthComputable = ReadonlyAttribute(jsObject: jsObject, name: Strings.lengthComputable) + _loaded = ReadonlyAttribute(jsObject: jsObject, name: Strings.loaded) + _total = ReadonlyAttribute(jsObject: jsObject, name: Strings.total) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: ProgressEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var lengthComputable: Bool + + @ReadonlyAttribute + public var loaded: UInt64 + + @ReadonlyAttribute + public var total: UInt64 +} diff --git a/Sources/DOMKit/WebIDL/ProgressEventInit.swift b/Sources/DOMKit/WebIDL/ProgressEventInit.swift new file mode 100644 index 00000000..cefb4961 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ProgressEventInit.swift @@ -0,0 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ProgressEventInit: BridgedDictionary { + public convenience init(lengthComputable: Bool, loaded: UInt64, total: UInt64) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.lengthComputable] = lengthComputable.jsValue + object[Strings.loaded] = loaded.jsValue + object[Strings.total] = total.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _lengthComputable = ReadWriteAttribute(jsObject: object, name: Strings.lengthComputable) + _loaded = ReadWriteAttribute(jsObject: object, name: Strings.loaded) + _total = ReadWriteAttribute(jsObject: object, name: Strings.total) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var lengthComputable: Bool + + @ReadWriteAttribute + public var loaded: UInt64 + + @ReadWriteAttribute + public var total: UInt64 +} diff --git a/Sources/DOMKit/WebIDL/PromiseRejectionEvent.swift b/Sources/DOMKit/WebIDL/PromiseRejectionEvent.swift new file mode 100644 index 00000000..1be7f2e4 --- /dev/null +++ b/Sources/DOMKit/WebIDL/PromiseRejectionEvent.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class PromiseRejectionEvent: Event { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.PromiseRejectionEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _promise = ReadonlyAttribute(jsObject: jsObject, name: Strings.promise) + _reason = ReadonlyAttribute(jsObject: jsObject, name: Strings.reason) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: PromiseRejectionEventInit) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict.jsValue])) + } + + @ReadonlyAttribute + public var promise: JSPromise + + @ReadonlyAttribute + public var reason: JSValue +} diff --git a/Sources/DOMKit/WebIDL/PromiseRejectionEventInit.swift b/Sources/DOMKit/WebIDL/PromiseRejectionEventInit.swift new file mode 100644 index 00000000..5ee0fc8d --- /dev/null +++ b/Sources/DOMKit/WebIDL/PromiseRejectionEventInit.swift @@ -0,0 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class PromiseRejectionEventInit: BridgedDictionary { + public convenience init(promise: JSPromise, reason: JSValue) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.promise] = promise.jsValue + object[Strings.reason] = reason.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _promise = ReadWriteAttribute(jsObject: object, name: Strings.promise) + _reason = ReadWriteAttribute(jsObject: object, name: Strings.reason) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var promise: JSPromise + + @ReadWriteAttribute + public var reason: JSValue +} diff --git a/Sources/DOMKit/WebIDL/RadioNodeList.swift b/Sources/DOMKit/WebIDL/RadioNodeList.swift index e8f8c3d0..60a188a6 100644 --- a/Sources/DOMKit/WebIDL/RadioNodeList.swift +++ b/Sources/DOMKit/WebIDL/RadioNodeList.swift @@ -1,15 +1,13 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class RadioNodeList: NodeList { - override public class var constructor: JSFunction { JSObject.global.RadioNodeList.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.RadioNodeList].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _value = ReadWriteAttribute(jsObject: jsObject, name: "value") + _value = ReadWriteAttribute(jsObject: jsObject, name: Strings.value) super.init(unsafelyWrapping: jsObject) } diff --git a/Sources/DOMKit/WebIDL/RadioNodeListOrElement.swift b/Sources/DOMKit/WebIDL/RadioNodeListOrElement.swift deleted file mode 100644 index 53644ae3..00000000 --- a/Sources/DOMKit/WebIDL/RadioNodeListOrElement.swift +++ /dev/null @@ -1,30 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public enum RadioNodeListOrElement: JSBridgedType { - case radioNodeList(RadioNodeList) - case element(Element) - - public init?(from value: JSValue) { - if let decoded: RadioNodeList = value.fromJSValue() { - self = .radioNodeList(decoded) - } else if let decoded: Element = value.fromJSValue() { - self = .element(decoded) - } else { - return nil - } - } - - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - switch self { - case let .radioNodeList(v): return v.jsValue() - case let .element(v): return v.jsValue() - } - } -} diff --git a/Sources/DOMKit/WebIDL/Range.swift b/Sources/DOMKit/WebIDL/Range.swift index 4d72be56..aefbda5f 100644 --- a/Sources/DOMKit/WebIDL/Range.swift +++ b/Sources/DOMKit/WebIDL/Range.swift @@ -1,110 +1,132 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class Range: AbstractRange { - override public class var constructor: JSFunction { JSObject.global.Range.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.Range].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _commonAncestorContainer = ReadonlyAttribute(jsObject: jsObject, name: "commonAncestorContainer") + _commonAncestorContainer = ReadonlyAttribute(jsObject: jsObject, name: Strings.commonAncestorContainer) super.init(unsafelyWrapping: jsObject) } - public convenience init() { - self.init(unsafelyWrapping: Range.constructor.new()) + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) } @ReadonlyAttribute public var commonAncestorContainer: Node - public func setStart(node: Node, offset: UInt32) { - _ = jsObject.setStart!(node.jsValue(), offset.jsValue()) + @inlinable public func setStart(node: Node, offset: UInt32) { + let this = jsObject + _ = this[Strings.setStart].function!(this: this, arguments: [node.jsValue, offset.jsValue]) } - public func setEnd(node: Node, offset: UInt32) { - _ = jsObject.setEnd!(node.jsValue(), offset.jsValue()) + @inlinable public func setEnd(node: Node, offset: UInt32) { + let this = jsObject + _ = this[Strings.setEnd].function!(this: this, arguments: [node.jsValue, offset.jsValue]) } - public func setStartBefore(node: Node) { - _ = jsObject.setStartBefore!(node.jsValue()) + @inlinable public func setStartBefore(node: Node) { + let this = jsObject + _ = this[Strings.setStartBefore].function!(this: this, arguments: [node.jsValue]) } - public func setStartAfter(node: Node) { - _ = jsObject.setStartAfter!(node.jsValue()) + @inlinable public func setStartAfter(node: Node) { + let this = jsObject + _ = this[Strings.setStartAfter].function!(this: this, arguments: [node.jsValue]) } - public func setEndBefore(node: Node) { - _ = jsObject.setEndBefore!(node.jsValue()) + @inlinable public func setEndBefore(node: Node) { + let this = jsObject + _ = this[Strings.setEndBefore].function!(this: this, arguments: [node.jsValue]) } - public func setEndAfter(node: Node) { - _ = jsObject.setEndAfter!(node.jsValue()) + @inlinable public func setEndAfter(node: Node) { + let this = jsObject + _ = this[Strings.setEndAfter].function!(this: this, arguments: [node.jsValue]) } - public func collapse(toStart: Bool = false) { - _ = jsObject.collapse!(toStart.jsValue()) + @inlinable public func collapse(toStart: Bool? = nil) { + let this = jsObject + _ = this[Strings.collapse].function!(this: this, arguments: [toStart?.jsValue ?? .undefined]) } - public func selectNode(node: Node) { - _ = jsObject.selectNode!(node.jsValue()) + @inlinable public func selectNode(node: Node) { + let this = jsObject + _ = this[Strings.selectNode].function!(this: this, arguments: [node.jsValue]) } - public func selectNodeContents(node: Node) { - _ = jsObject.selectNodeContents!(node.jsValue()) + @inlinable public func selectNodeContents(node: Node) { + let this = jsObject + _ = this[Strings.selectNodeContents].function!(this: this, arguments: [node.jsValue]) } - public let START_TO_START: UInt16 = 0 + public static let START_TO_START: UInt16 = 0 + + public static let START_TO_END: UInt16 = 1 - public let START_TO_END: UInt16 = 1 + public static let END_TO_END: UInt16 = 2 - public let END_TO_END: UInt16 = 2 + public static let END_TO_START: UInt16 = 3 - public let END_TO_START: UInt16 = 3 + @inlinable public func compareBoundaryPoints(how: UInt16, sourceRange: Range) -> Int16 { + let this = jsObject + return this[Strings.compareBoundaryPoints].function!(this: this, arguments: [how.jsValue, sourceRange.jsValue]).fromJSValue()! + } - public func compareBoundaryPoints(how: UInt16, sourceRange: Range) -> Int16 { - return jsObject.compareBoundaryPoints!(how.jsValue(), sourceRange.jsValue()).fromJSValue()! + @inlinable public func deleteContents() { + let this = jsObject + _ = this[Strings.deleteContents].function!(this: this, arguments: []) } - public func deleteContents() { - _ = jsObject.deleteContents!() + @inlinable public func extractContents() -> DocumentFragment { + let this = jsObject + return this[Strings.extractContents].function!(this: this, arguments: []).fromJSValue()! } - public func extractContents() -> DocumentFragment { - return jsObject.extractContents!().fromJSValue()! + @inlinable public func cloneContents() -> DocumentFragment { + let this = jsObject + return this[Strings.cloneContents].function!(this: this, arguments: []).fromJSValue()! } - public func cloneContents() -> DocumentFragment { - return jsObject.cloneContents!().fromJSValue()! + @inlinable public func insertNode(node: Node) { + let this = jsObject + _ = this[Strings.insertNode].function!(this: this, arguments: [node.jsValue]) } - public func insertNode(node: Node) { - _ = jsObject.insertNode!(node.jsValue()) + @inlinable public func surroundContents(newParent: Node) { + let this = jsObject + _ = this[Strings.surroundContents].function!(this: this, arguments: [newParent.jsValue]) } - public func surroundContents(newParent: Node) { - _ = jsObject.surroundContents!(newParent.jsValue()) + @inlinable public func cloneRange() -> Self { + let this = jsObject + return this[Strings.cloneRange].function!(this: this, arguments: []).fromJSValue()! } - public func cloneRange() -> Range { - return jsObject.cloneRange!().fromJSValue()! + @inlinable public func detach() { + let this = jsObject + _ = this[Strings.detach].function!(this: this, arguments: []) } - public func detach() { - _ = jsObject.detach!() + @inlinable public func isPointInRange(node: Node, offset: UInt32) -> Bool { + let this = jsObject + return this[Strings.isPointInRange].function!(this: this, arguments: [node.jsValue, offset.jsValue]).fromJSValue()! } - public func isPointInRange(node: Node, offset: UInt32) -> Bool { - return jsObject.isPointInRange!(node.jsValue(), offset.jsValue()).fromJSValue()! + @inlinable public func comparePoint(node: Node, offset: UInt32) -> Int16 { + let this = jsObject + return this[Strings.comparePoint].function!(this: this, arguments: [node.jsValue, offset.jsValue]).fromJSValue()! } - public func comparePoint(node: Node, offset: UInt32) -> Int16 { - return jsObject.comparePoint!(node.jsValue(), offset.jsValue()).fromJSValue()! + @inlinable public func intersectsNode(node: Node) -> Bool { + let this = jsObject + return this[Strings.intersectsNode].function!(this: this, arguments: [node.jsValue]).fromJSValue()! } - public func intersectsNode(node: Node) -> Bool { - return jsObject.intersectsNode!(node.jsValue()).fromJSValue()! + @inlinable public var description: String { + jsObject[Strings.toString]!().fromJSValue()! } } diff --git a/Sources/DOMKit/WebIDL/ReferrerPolicy.swift b/Sources/DOMKit/WebIDL/ReferrerPolicy.swift new file mode 100644 index 00000000..c1e36114 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ReferrerPolicy.swift @@ -0,0 +1,29 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum ReferrerPolicy: JSString, JSValueCompatible { + case _empty = "" + case noReferrer = "no-referrer" + case noReferrerWhenDowngrade = "no-referrer-when-downgrade" + case sameOrigin = "same-origin" + case origin = "origin" + case strictOrigin = "strict-origin" + case originWhenCrossOrigin = "origin-when-cross-origin" + case strictOriginWhenCrossOrigin = "strict-origin-when-cross-origin" + case unsafeUrl = "unsafe-url" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/RegistrationOptions.swift b/Sources/DOMKit/WebIDL/RegistrationOptions.swift new file mode 100644 index 00000000..97cfe75b --- /dev/null +++ b/Sources/DOMKit/WebIDL/RegistrationOptions.swift @@ -0,0 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class RegistrationOptions: BridgedDictionary { + public convenience init(scope: String, type: WorkerType, updateViaCache: ServiceWorkerUpdateViaCache) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.scope] = scope.jsValue + object[Strings.type] = type.jsValue + object[Strings.updateViaCache] = updateViaCache.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _scope = ReadWriteAttribute(jsObject: object, name: Strings.scope) + _type = ReadWriteAttribute(jsObject: object, name: Strings.type) + _updateViaCache = ReadWriteAttribute(jsObject: object, name: Strings.updateViaCache) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var scope: String + + @ReadWriteAttribute + public var type: WorkerType + + @ReadWriteAttribute + public var updateViaCache: ServiceWorkerUpdateViaCache +} diff --git a/Sources/DOMKit/WebIDL/Request.swift b/Sources/DOMKit/WebIDL/Request.swift new file mode 100644 index 00000000..39f25ce8 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Request.swift @@ -0,0 +1,83 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class Request: JSBridgedClass, Body { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.Request].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _method = ReadonlyAttribute(jsObject: jsObject, name: Strings.method) + _url = ReadonlyAttribute(jsObject: jsObject, name: Strings.url) + _headers = ReadonlyAttribute(jsObject: jsObject, name: Strings.headers) + _destination = ReadonlyAttribute(jsObject: jsObject, name: Strings.destination) + _referrer = ReadonlyAttribute(jsObject: jsObject, name: Strings.referrer) + _referrerPolicy = ReadonlyAttribute(jsObject: jsObject, name: Strings.referrerPolicy) + _mode = ReadonlyAttribute(jsObject: jsObject, name: Strings.mode) + _credentials = ReadonlyAttribute(jsObject: jsObject, name: Strings.credentials) + _cache = ReadonlyAttribute(jsObject: jsObject, name: Strings.cache) + _redirect = ReadonlyAttribute(jsObject: jsObject, name: Strings.redirect) + _integrity = ReadonlyAttribute(jsObject: jsObject, name: Strings.integrity) + _keepalive = ReadonlyAttribute(jsObject: jsObject, name: Strings.keepalive) + _isReloadNavigation = ReadonlyAttribute(jsObject: jsObject, name: Strings.isReloadNavigation) + _isHistoryNavigation = ReadonlyAttribute(jsObject: jsObject, name: Strings.isHistoryNavigation) + _signal = ReadonlyAttribute(jsObject: jsObject, name: Strings.signal) + self.jsObject = jsObject + } + + @inlinable public convenience init(input: RequestInfo, init: RequestInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [input.jsValue, `init`?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var method: String + + @ReadonlyAttribute + public var url: String + + @ReadonlyAttribute + public var headers: Headers + + @ReadonlyAttribute + public var destination: RequestDestination + + @ReadonlyAttribute + public var referrer: String + + @ReadonlyAttribute + public var referrerPolicy: ReferrerPolicy + + @ReadonlyAttribute + public var mode: RequestMode + + @ReadonlyAttribute + public var credentials: RequestCredentials + + @ReadonlyAttribute + public var cache: RequestCache + + @ReadonlyAttribute + public var redirect: RequestRedirect + + @ReadonlyAttribute + public var integrity: String + + @ReadonlyAttribute + public var keepalive: Bool + + @ReadonlyAttribute + public var isReloadNavigation: Bool + + @ReadonlyAttribute + public var isHistoryNavigation: Bool + + @ReadonlyAttribute + public var signal: AbortSignal + + @inlinable public func clone() -> Self { + let this = jsObject + return this[Strings.clone].function!(this: this, arguments: []).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/RequestCache.swift b/Sources/DOMKit/WebIDL/RequestCache.swift new file mode 100644 index 00000000..72c158ac --- /dev/null +++ b/Sources/DOMKit/WebIDL/RequestCache.swift @@ -0,0 +1,26 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum RequestCache: JSString, JSValueCompatible { + case `default` = "default" + case noStore = "no-store" + case reload = "reload" + case noCache = "no-cache" + case forceCache = "force-cache" + case onlyIfCached = "only-if-cached" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/RequestCredentials.swift b/Sources/DOMKit/WebIDL/RequestCredentials.swift new file mode 100644 index 00000000..9af56520 --- /dev/null +++ b/Sources/DOMKit/WebIDL/RequestCredentials.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum RequestCredentials: JSString, JSValueCompatible { + case omit = "omit" + case sameOrigin = "same-origin" + case include = "include" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/RequestDestination.swift b/Sources/DOMKit/WebIDL/RequestDestination.swift new file mode 100644 index 00000000..85676c49 --- /dev/null +++ b/Sources/DOMKit/WebIDL/RequestDestination.swift @@ -0,0 +1,40 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum RequestDestination: JSString, JSValueCompatible { + case _empty = "" + case audio = "audio" + case audioworklet = "audioworklet" + case document = "document" + case embed = "embed" + case font = "font" + case frame = "frame" + case iframe = "iframe" + case image = "image" + case manifest = "manifest" + case object = "object" + case paintworklet = "paintworklet" + case report = "report" + case script = "script" + case sharedworker = "sharedworker" + case style = "style" + case track = "track" + case video = "video" + case worker = "worker" + case xslt = "xslt" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/RequestInfo.swift b/Sources/DOMKit/WebIDL/RequestInfo.swift new file mode 100644 index 00000000..2019247c --- /dev/null +++ b/Sources/DOMKit/WebIDL/RequestInfo.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_RequestInfo: ConvertibleToJSValue {} +extension Request: Any_RequestInfo {} +extension String: Any_RequestInfo {} + +public enum RequestInfo: JSValueCompatible, Any_RequestInfo { + case request(Request) + case string(String) + + var request: Request? { + switch self { + case let .request(request): return request + default: return nil + } + } + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let request: Request = value.fromJSValue() { + return .request(request) + } + if let string: String = value.fromJSValue() { + return .string(string) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .request(request): + return request.jsValue + case let .string(string): + return string.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/RequestInit.swift b/Sources/DOMKit/WebIDL/RequestInit.swift new file mode 100644 index 00000000..edeebffe --- /dev/null +++ b/Sources/DOMKit/WebIDL/RequestInit.swift @@ -0,0 +1,80 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class RequestInit: BridgedDictionary { + public convenience init(method: String, headers: HeadersInit, body: BodyInit?, referrer: String, referrerPolicy: ReferrerPolicy, mode: RequestMode, credentials: RequestCredentials, cache: RequestCache, redirect: RequestRedirect, integrity: String, keepalive: Bool, signal: AbortSignal?, window: JSValue) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.method] = method.jsValue + object[Strings.headers] = headers.jsValue + object[Strings.body] = body.jsValue + object[Strings.referrer] = referrer.jsValue + object[Strings.referrerPolicy] = referrerPolicy.jsValue + object[Strings.mode] = mode.jsValue + object[Strings.credentials] = credentials.jsValue + object[Strings.cache] = cache.jsValue + object[Strings.redirect] = redirect.jsValue + object[Strings.integrity] = integrity.jsValue + object[Strings.keepalive] = keepalive.jsValue + object[Strings.signal] = signal.jsValue + object[Strings.window] = window.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _method = ReadWriteAttribute(jsObject: object, name: Strings.method) + _headers = ReadWriteAttribute(jsObject: object, name: Strings.headers) + _body = ReadWriteAttribute(jsObject: object, name: Strings.body) + _referrer = ReadWriteAttribute(jsObject: object, name: Strings.referrer) + _referrerPolicy = ReadWriteAttribute(jsObject: object, name: Strings.referrerPolicy) + _mode = ReadWriteAttribute(jsObject: object, name: Strings.mode) + _credentials = ReadWriteAttribute(jsObject: object, name: Strings.credentials) + _cache = ReadWriteAttribute(jsObject: object, name: Strings.cache) + _redirect = ReadWriteAttribute(jsObject: object, name: Strings.redirect) + _integrity = ReadWriteAttribute(jsObject: object, name: Strings.integrity) + _keepalive = ReadWriteAttribute(jsObject: object, name: Strings.keepalive) + _signal = ReadWriteAttribute(jsObject: object, name: Strings.signal) + _window = ReadWriteAttribute(jsObject: object, name: Strings.window) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var method: String + + @ReadWriteAttribute + public var headers: HeadersInit + + @ReadWriteAttribute + public var body: BodyInit? + + @ReadWriteAttribute + public var referrer: String + + @ReadWriteAttribute + public var referrerPolicy: ReferrerPolicy + + @ReadWriteAttribute + public var mode: RequestMode + + @ReadWriteAttribute + public var credentials: RequestCredentials + + @ReadWriteAttribute + public var cache: RequestCache + + @ReadWriteAttribute + public var redirect: RequestRedirect + + @ReadWriteAttribute + public var integrity: String + + @ReadWriteAttribute + public var keepalive: Bool + + @ReadWriteAttribute + public var signal: AbortSignal? + + @ReadWriteAttribute + public var window: JSValue +} diff --git a/Sources/DOMKit/WebIDL/RequestMode.swift b/Sources/DOMKit/WebIDL/RequestMode.swift new file mode 100644 index 00000000..cea0dc8b --- /dev/null +++ b/Sources/DOMKit/WebIDL/RequestMode.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum RequestMode: JSString, JSValueCompatible { + case navigate = "navigate" + case sameOrigin = "same-origin" + case noCors = "no-cors" + case cors = "cors" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/RequestRedirect.swift b/Sources/DOMKit/WebIDL/RequestRedirect.swift new file mode 100644 index 00000000..999e4065 --- /dev/null +++ b/Sources/DOMKit/WebIDL/RequestRedirect.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum RequestRedirect: JSString, JSValueCompatible { + case follow = "follow" + case error = "error" + case manual = "manual" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/ResizeQuality.swift b/Sources/DOMKit/WebIDL/ResizeQuality.swift new file mode 100644 index 00000000..2885fb64 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ResizeQuality.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum ResizeQuality: JSString, JSValueCompatible { + case pixelated = "pixelated" + case low = "low" + case medium = "medium" + case high = "high" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/Response.swift b/Sources/DOMKit/WebIDL/Response.swift new file mode 100644 index 00000000..758d1166 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Response.swift @@ -0,0 +1,61 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class Response: JSBridgedClass, Body { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.Response].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _type = ReadonlyAttribute(jsObject: jsObject, name: Strings.type) + _url = ReadonlyAttribute(jsObject: jsObject, name: Strings.url) + _redirected = ReadonlyAttribute(jsObject: jsObject, name: Strings.redirected) + _status = ReadonlyAttribute(jsObject: jsObject, name: Strings.status) + _ok = ReadonlyAttribute(jsObject: jsObject, name: Strings.ok) + _statusText = ReadonlyAttribute(jsObject: jsObject, name: Strings.statusText) + _headers = ReadonlyAttribute(jsObject: jsObject, name: Strings.headers) + self.jsObject = jsObject + } + + @inlinable public convenience init(body: BodyInit? = nil, init: ResponseInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [body?.jsValue ?? .undefined, `init`?.jsValue ?? .undefined])) + } + + @inlinable public static func error() -> Self { + let this = constructor + return this[Strings.error].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public static func redirect(url: String, status: UInt16? = nil) -> Self { + let this = constructor + return this[Strings.redirect].function!(this: this, arguments: [url.jsValue, status?.jsValue ?? .undefined]).fromJSValue()! + } + + @ReadonlyAttribute + public var type: ResponseType + + @ReadonlyAttribute + public var url: String + + @ReadonlyAttribute + public var redirected: Bool + + @ReadonlyAttribute + public var status: UInt16 + + @ReadonlyAttribute + public var ok: Bool + + @ReadonlyAttribute + public var statusText: String + + @ReadonlyAttribute + public var headers: Headers + + @inlinable public func clone() -> Self { + let this = jsObject + return this[Strings.clone].function!(this: this, arguments: []).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/ResponseInit.swift b/Sources/DOMKit/WebIDL/ResponseInit.swift new file mode 100644 index 00000000..d2da62c2 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ResponseInit.swift @@ -0,0 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ResponseInit: BridgedDictionary { + public convenience init(status: UInt16, statusText: String, headers: HeadersInit) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.status] = status.jsValue + object[Strings.statusText] = statusText.jsValue + object[Strings.headers] = headers.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _status = ReadWriteAttribute(jsObject: object, name: Strings.status) + _statusText = ReadWriteAttribute(jsObject: object, name: Strings.statusText) + _headers = ReadWriteAttribute(jsObject: object, name: Strings.headers) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var status: UInt16 + + @ReadWriteAttribute + public var statusText: String + + @ReadWriteAttribute + public var headers: HeadersInit +} diff --git a/Sources/DOMKit/WebIDL/ResponseType.swift b/Sources/DOMKit/WebIDL/ResponseType.swift new file mode 100644 index 00000000..912d993a --- /dev/null +++ b/Sources/DOMKit/WebIDL/ResponseType.swift @@ -0,0 +1,26 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum ResponseType: JSString, JSValueCompatible { + case basic = "basic" + case cors = "cors" + case `default` = "default" + case error = "error" + case opaque = "opaque" + case opaqueredirect = "opaqueredirect" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/ScrollRestoration.swift b/Sources/DOMKit/WebIDL/ScrollRestoration.swift new file mode 100644 index 00000000..4c2ba486 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ScrollRestoration.swift @@ -0,0 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum ScrollRestoration: JSString, JSValueCompatible { + case auto = "auto" + case manual = "manual" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/SelectionMode.swift b/Sources/DOMKit/WebIDL/SelectionMode.swift new file mode 100644 index 00000000..c5434877 --- /dev/null +++ b/Sources/DOMKit/WebIDL/SelectionMode.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum SelectionMode: JSString, JSValueCompatible { + case select = "select" + case start = "start" + case end = "end" + case preserve = "preserve" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/ServiceWorker.swift b/Sources/DOMKit/WebIDL/ServiceWorker.swift new file mode 100644 index 00000000..0ab5f4cd --- /dev/null +++ b/Sources/DOMKit/WebIDL/ServiceWorker.swift @@ -0,0 +1,34 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ServiceWorker: EventTarget, AbstractWorker { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.ServiceWorker].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _scriptURL = ReadonlyAttribute(jsObject: jsObject, name: Strings.scriptURL) + _state = ReadonlyAttribute(jsObject: jsObject, name: Strings.state) + _onstatechange = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onstatechange) + super.init(unsafelyWrapping: jsObject) + } + + @ReadonlyAttribute + public var scriptURL: String + + @ReadonlyAttribute + public var state: ServiceWorkerState + + @inlinable public func postMessage(message: JSValue, transfer: [JSObject]) { + let this = jsObject + _ = this[Strings.postMessage].function!(this: this, arguments: [message.jsValue, transfer.jsValue]) + } + + @inlinable public func postMessage(message: JSValue, options: StructuredSerializeOptions? = nil) { + let this = jsObject + _ = this[Strings.postMessage].function!(this: this, arguments: [message.jsValue, options?.jsValue ?? .undefined]) + } + + @ClosureAttribute1Optional + public var onstatechange: EventHandler +} diff --git a/Sources/DOMKit/WebIDL/ServiceWorkerContainer.swift b/Sources/DOMKit/WebIDL/ServiceWorkerContainer.swift new file mode 100644 index 00000000..63fe6273 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ServiceWorkerContainer.swift @@ -0,0 +1,73 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ServiceWorkerContainer: EventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.ServiceWorkerContainer].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _controller = ReadonlyAttribute(jsObject: jsObject, name: Strings.controller) + _ready = ReadonlyAttribute(jsObject: jsObject, name: Strings.ready) + _oncontrollerchange = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.oncontrollerchange) + _onmessage = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onmessage) + _onmessageerror = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onmessageerror) + super.init(unsafelyWrapping: jsObject) + } + + @ReadonlyAttribute + public var controller: ServiceWorker? + + @ReadonlyAttribute + public var ready: JSPromise + + @inlinable public func register(scriptURL: String, options: RegistrationOptions? = nil) -> JSPromise { + let this = jsObject + return this[Strings.register].function!(this: this, arguments: [scriptURL.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func register(scriptURL: String, options: RegistrationOptions? = nil) async throws -> ServiceWorkerRegistration { + let this = jsObject + let _promise: JSPromise = this[Strings.register].function!(this: this, arguments: [scriptURL.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable public func getRegistration(clientURL: String? = nil) -> JSPromise { + let this = jsObject + return this[Strings.getRegistration].function!(this: this, arguments: [clientURL?.jsValue ?? .undefined]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func getRegistration(clientURL: String? = nil) async throws -> ServiceWorkerRegistration? { + let this = jsObject + let _promise: JSPromise = this[Strings.getRegistration].function!(this: this, arguments: [clientURL?.jsValue ?? .undefined]).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable public func getRegistrations() -> JSPromise { + let this = jsObject + return this[Strings.getRegistrations].function!(this: this, arguments: []).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func getRegistrations() async throws -> [ServiceWorkerRegistration] { + let this = jsObject + let _promise: JSPromise = this[Strings.getRegistrations].function!(this: this, arguments: []).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable public func startMessages() { + let this = jsObject + _ = this[Strings.startMessages].function!(this: this, arguments: []) + } + + @ClosureAttribute1Optional + public var oncontrollerchange: EventHandler + + @ClosureAttribute1Optional + public var onmessage: EventHandler + + @ClosureAttribute1Optional + public var onmessageerror: EventHandler +} diff --git a/Sources/DOMKit/WebIDL/ServiceWorkerRegistration.swift b/Sources/DOMKit/WebIDL/ServiceWorkerRegistration.swift new file mode 100644 index 00000000..67ea90db --- /dev/null +++ b/Sources/DOMKit/WebIDL/ServiceWorkerRegistration.swift @@ -0,0 +1,64 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class ServiceWorkerRegistration: EventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.ServiceWorkerRegistration].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _installing = ReadonlyAttribute(jsObject: jsObject, name: Strings.installing) + _waiting = ReadonlyAttribute(jsObject: jsObject, name: Strings.waiting) + _active = ReadonlyAttribute(jsObject: jsObject, name: Strings.active) + _navigationPreload = ReadonlyAttribute(jsObject: jsObject, name: Strings.navigationPreload) + _scope = ReadonlyAttribute(jsObject: jsObject, name: Strings.scope) + _updateViaCache = ReadonlyAttribute(jsObject: jsObject, name: Strings.updateViaCache) + _onupdatefound = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onupdatefound) + super.init(unsafelyWrapping: jsObject) + } + + @ReadonlyAttribute + public var installing: ServiceWorker? + + @ReadonlyAttribute + public var waiting: ServiceWorker? + + @ReadonlyAttribute + public var active: ServiceWorker? + + @ReadonlyAttribute + public var navigationPreload: NavigationPreloadManager + + @ReadonlyAttribute + public var scope: String + + @ReadonlyAttribute + public var updateViaCache: ServiceWorkerUpdateViaCache + + @inlinable public func update() -> JSPromise { + let this = jsObject + return this[Strings.update].function!(this: this, arguments: []).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func update() async throws { + let this = jsObject + let _promise: JSPromise = this[Strings.update].function!(this: this, arguments: []).fromJSValue()! + _ = try await _promise.value + } + + @inlinable public func unregister() -> JSPromise { + let this = jsObject + return this[Strings.unregister].function!(this: this, arguments: []).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func unregister() async throws -> Bool { + let this = jsObject + let _promise: JSPromise = this[Strings.unregister].function!(this: this, arguments: []).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @ClosureAttribute1Optional + public var onupdatefound: EventHandler +} diff --git a/Sources/DOMKit/WebIDL/ServiceWorkerState.swift b/Sources/DOMKit/WebIDL/ServiceWorkerState.swift new file mode 100644 index 00000000..e5bfac3b --- /dev/null +++ b/Sources/DOMKit/WebIDL/ServiceWorkerState.swift @@ -0,0 +1,26 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum ServiceWorkerState: JSString, JSValueCompatible { + case parsed = "parsed" + case installing = "installing" + case installed = "installed" + case activating = "activating" + case activated = "activated" + case redundant = "redundant" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/ServiceWorkerUpdateViaCache.swift b/Sources/DOMKit/WebIDL/ServiceWorkerUpdateViaCache.swift new file mode 100644 index 00000000..032f59f3 --- /dev/null +++ b/Sources/DOMKit/WebIDL/ServiceWorkerUpdateViaCache.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum ServiceWorkerUpdateViaCache: JSString, JSValueCompatible { + case imports = "imports" + case all = "all" + case none = "none" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/ShadowRoot.swift b/Sources/DOMKit/WebIDL/ShadowRoot.swift index 97d45ea3..524a002f 100644 --- a/Sources/DOMKit/WebIDL/ShadowRoot.swift +++ b/Sources/DOMKit/WebIDL/ShadowRoot.swift @@ -1,26 +1,32 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class ShadowRoot: DocumentFragment, DocumentOrShadowRoot { - override public class var constructor: JSFunction { JSObject.global.ShadowRoot.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.ShadowRoot].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _mode = ReadonlyAttribute(jsObject: jsObject, name: "mode") - _host = ReadonlyAttribute(jsObject: jsObject, name: "host") - _onslotchange = OptionalClosureHandler(jsObject: jsObject, name: "onslotchange") + _mode = ReadonlyAttribute(jsObject: jsObject, name: Strings.mode) + _delegatesFocus = ReadonlyAttribute(jsObject: jsObject, name: Strings.delegatesFocus) + _slotAssignment = ReadonlyAttribute(jsObject: jsObject, name: Strings.slotAssignment) + _host = ReadonlyAttribute(jsObject: jsObject, name: Strings.host) + _onslotchange = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onslotchange) super.init(unsafelyWrapping: jsObject) } @ReadonlyAttribute public var mode: ShadowRootMode + @ReadonlyAttribute + public var delegatesFocus: Bool + + @ReadonlyAttribute + public var slotAssignment: SlotAssignmentMode + @ReadonlyAttribute public var host: Element - @OptionalClosureHandler + @ClosureAttribute1Optional public var onslotchange: EventHandler } diff --git a/Sources/DOMKit/WebIDL/ShadowRootInit.swift b/Sources/DOMKit/WebIDL/ShadowRootInit.swift index 86cd543f..24f7913a 100644 --- a/Sources/DOMKit/WebIDL/ShadowRootInit.swift +++ b/Sources/DOMKit/WebIDL/ShadowRootInit.swift @@ -1,39 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public struct ShadowRootInit: ExpressibleByDictionaryLiteral, JSBridgedType { - public enum Key: String, Hashable { - case mode, delegatesFocus - } - - private let dictionary: [String: JSValue] - - public init(uniqueKeysWithValues elements: [(Key, ConvertibleToJSValue)]) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) +public class ShadowRootInit: BridgedDictionary { + public convenience init(mode: ShadowRootMode, delegatesFocus: Bool, slotAssignment: SlotAssignmentMode) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.mode] = mode.jsValue + object[Strings.delegatesFocus] = delegatesFocus.jsValue + object[Strings.slotAssignment] = slotAssignment.jsValue + self.init(unsafelyWrapping: object) } - public init(dictionaryLiteral elements: (Key, ConvertibleToJSValue)...) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) + public required init(unsafelyWrapping object: JSObject) { + _mode = ReadWriteAttribute(jsObject: object, name: Strings.mode) + _delegatesFocus = ReadWriteAttribute(jsObject: object, name: Strings.delegatesFocus) + _slotAssignment = ReadWriteAttribute(jsObject: object, name: Strings.slotAssignment) + super.init(unsafelyWrapping: object) } - subscript(_ key: Key) -> JSValue? { - dictionary[key.rawValue] - } - - public init?(from value: JSValue) { - if let dictionary: [String: JSValue] = value.fromJSValue() { - self.dictionary = dictionary - } - return nil - } + @ReadWriteAttribute + public var mode: ShadowRootMode - public var value: JSValue { jsValue() } + @ReadWriteAttribute + public var delegatesFocus: Bool - public func jsValue() -> JSValue { - return dictionary.jsValue() - } + @ReadWriteAttribute + public var slotAssignment: SlotAssignmentMode } diff --git a/Sources/DOMKit/WebIDL/ShadowRootMode.swift b/Sources/DOMKit/WebIDL/ShadowRootMode.swift index 4768453a..7749aa7a 100644 --- a/Sources/DOMKit/WebIDL/ShadowRootMode.swift +++ b/Sources/DOMKit/WebIDL/ShadowRootMode.swift @@ -1,23 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public enum ShadowRootMode: String, JSValueCompatible { - public static func construct(from jsValue: JSValue) -> ShadowRootMode? { - if let string = jsValue.string, - let value = ShadowRootMode(rawValue: string) - { - return value +public enum ShadowRootMode: JSString, JSValueCompatible { + case open = "open" + case closed = "closed" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) } return nil } - case open - case closed - public func jsValue() -> JSValue { - return rawValue.jsValue() + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } } diff --git a/Sources/DOMKit/WebIDL/SharedWorker.swift b/Sources/DOMKit/WebIDL/SharedWorker.swift new file mode 100644 index 00000000..152a1717 --- /dev/null +++ b/Sources/DOMKit/WebIDL/SharedWorker.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class SharedWorker: EventTarget, AbstractWorker { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.SharedWorker].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _port = ReadonlyAttribute(jsObject: jsObject, name: Strings.port) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(scriptURL: String, options: String_or_WorkerOptions? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [scriptURL.jsValue, options?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var port: MessagePort +} diff --git a/Sources/DOMKit/WebIDL/SlotAssignmentMode.swift b/Sources/DOMKit/WebIDL/SlotAssignmentMode.swift new file mode 100644 index 00000000..9a4f11b1 --- /dev/null +++ b/Sources/DOMKit/WebIDL/SlotAssignmentMode.swift @@ -0,0 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum SlotAssignmentMode: JSString, JSValueCompatible { + case manual = "manual" + case named = "named" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/Slotable.swift b/Sources/DOMKit/WebIDL/Slotable.swift deleted file mode 100644 index bc041feb..00000000 --- a/Sources/DOMKit/WebIDL/Slotable.swift +++ /dev/null @@ -1,14 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public protocol Slotable: JSBridgedClass {} - -public extension Slotable { - var assignedSlot: HTMLSlotElement? { - return jsObject.assignedSlot.fromJSValue()! - } -} diff --git a/Sources/DOMKit/WebIDL/Slottable.swift b/Sources/DOMKit/WebIDL/Slottable.swift new file mode 100644 index 00000000..64c060ee --- /dev/null +++ b/Sources/DOMKit/WebIDL/Slottable.swift @@ -0,0 +1,9 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Slottable: JSBridgedClass {} +public extension Slottable { + @inlinable var assignedSlot: HTMLSlotElement? { ReadonlyAttribute[Strings.assignedSlot, in: jsObject] } +} diff --git a/Sources/DOMKit/WebIDL/StaticRange.swift b/Sources/DOMKit/WebIDL/StaticRange.swift index 4e2f2218..f8f95fe6 100644 --- a/Sources/DOMKit/WebIDL/StaticRange.swift +++ b/Sources/DOMKit/WebIDL/StaticRange.swift @@ -1,18 +1,16 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class StaticRange: AbstractRange { - override public class var constructor: JSFunction { JSObject.global.StaticRange.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.StaticRange].function! } public required init(unsafelyWrapping jsObject: JSObject) { super.init(unsafelyWrapping: jsObject) } - public convenience init(init: StaticRangeInit) { - self.init(unsafelyWrapping: StaticRange.constructor.new(`init`.jsValue())) + @inlinable public convenience init(init: StaticRangeInit) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [`init`.jsValue])) } } diff --git a/Sources/DOMKit/WebIDL/StaticRangeInit.swift b/Sources/DOMKit/WebIDL/StaticRangeInit.swift index 90e7a402..45ca5d3e 100644 --- a/Sources/DOMKit/WebIDL/StaticRangeInit.swift +++ b/Sources/DOMKit/WebIDL/StaticRangeInit.swift @@ -1,39 +1,35 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public struct StaticRangeInit: ExpressibleByDictionaryLiteral, JSBridgedType { - public enum Key: String, Hashable { - case startContainer, startOffset, endContainer, endOffset +public class StaticRangeInit: BridgedDictionary { + public convenience init(startContainer: Node, startOffset: UInt32, endContainer: Node, endOffset: UInt32) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.startContainer] = startContainer.jsValue + object[Strings.startOffset] = startOffset.jsValue + object[Strings.endContainer] = endContainer.jsValue + object[Strings.endOffset] = endOffset.jsValue + self.init(unsafelyWrapping: object) } - private let dictionary: [String: JSValue] - - public init(uniqueKeysWithValues elements: [(Key, ConvertibleToJSValue)]) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) + public required init(unsafelyWrapping object: JSObject) { + _startContainer = ReadWriteAttribute(jsObject: object, name: Strings.startContainer) + _startOffset = ReadWriteAttribute(jsObject: object, name: Strings.startOffset) + _endContainer = ReadWriteAttribute(jsObject: object, name: Strings.endContainer) + _endOffset = ReadWriteAttribute(jsObject: object, name: Strings.endOffset) + super.init(unsafelyWrapping: object) } - public init(dictionaryLiteral elements: (Key, ConvertibleToJSValue)...) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } + @ReadWriteAttribute + public var startContainer: Node - subscript(_ key: Key) -> JSValue? { - dictionary[key.rawValue] - } + @ReadWriteAttribute + public var startOffset: UInt32 - public init?(from value: JSValue) { - if let dictionary: [String: JSValue] = value.fromJSValue() { - self.dictionary = dictionary - } - return nil - } - - public var value: JSValue { jsValue() } + @ReadWriteAttribute + public var endContainer: Node - public func jsValue() -> JSValue { - return dictionary.jsValue() - } + @ReadWriteAttribute + public var endOffset: UInt32 } diff --git a/Sources/DOMKit/WebIDL/Storage.swift b/Sources/DOMKit/WebIDL/Storage.swift new file mode 100644 index 00000000..b89232c9 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Storage.swift @@ -0,0 +1,36 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class Storage: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.Storage].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var length: UInt32 + + @inlinable public func key(index: UInt32) -> String? { + let this = jsObject + return this[Strings.key].function!(this: this, arguments: [index.jsValue]).fromJSValue()! + } + + @inlinable public subscript(key: String) -> String? { + jsObject[key].fromJSValue() + } + + // XXX: unsupported setter for keys of type String + + // XXX: unsupported deleter for keys of type String + + @inlinable public func clear() { + let this = jsObject + _ = this[Strings.clear].function!(this: this, arguments: []) + } +} diff --git a/Sources/DOMKit/WebIDL/StorageEvent.swift b/Sources/DOMKit/WebIDL/StorageEvent.swift new file mode 100644 index 00000000..ff3503b2 --- /dev/null +++ b/Sources/DOMKit/WebIDL/StorageEvent.swift @@ -0,0 +1,49 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class StorageEvent: Event { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.StorageEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _key = ReadonlyAttribute(jsObject: jsObject, name: Strings.key) + _oldValue = ReadonlyAttribute(jsObject: jsObject, name: Strings.oldValue) + _newValue = ReadonlyAttribute(jsObject: jsObject, name: Strings.newValue) + _url = ReadonlyAttribute(jsObject: jsObject, name: Strings.url) + _storageArea = ReadonlyAttribute(jsObject: jsObject, name: Strings.storageArea) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: StorageEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var key: String? + + @ReadonlyAttribute + public var oldValue: String? + + @ReadonlyAttribute + public var newValue: String? + + @ReadonlyAttribute + public var url: String + + @ReadonlyAttribute + public var storageArea: Storage? + + @inlinable public func initStorageEvent(type: String, bubbles: Bool? = nil, cancelable: Bool? = nil, key: String? = nil, oldValue: String? = nil, newValue: String? = nil, url: String? = nil, storageArea: Storage? = nil) { + let _arg0 = type.jsValue + let _arg1 = bubbles?.jsValue ?? .undefined + let _arg2 = cancelable?.jsValue ?? .undefined + let _arg3 = key?.jsValue ?? .undefined + let _arg4 = oldValue?.jsValue ?? .undefined + let _arg5 = newValue?.jsValue ?? .undefined + let _arg6 = url?.jsValue ?? .undefined + let _arg7 = storageArea?.jsValue ?? .undefined + let this = jsObject + _ = this[Strings.initStorageEvent].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7]) + } +} diff --git a/Sources/DOMKit/WebIDL/StorageEventInit.swift b/Sources/DOMKit/WebIDL/StorageEventInit.swift new file mode 100644 index 00000000..00d17ee3 --- /dev/null +++ b/Sources/DOMKit/WebIDL/StorageEventInit.swift @@ -0,0 +1,40 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class StorageEventInit: BridgedDictionary { + public convenience init(key: String?, oldValue: String?, newValue: String?, url: String, storageArea: Storage?) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.key] = key.jsValue + object[Strings.oldValue] = oldValue.jsValue + object[Strings.newValue] = newValue.jsValue + object[Strings.url] = url.jsValue + object[Strings.storageArea] = storageArea.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _key = ReadWriteAttribute(jsObject: object, name: Strings.key) + _oldValue = ReadWriteAttribute(jsObject: object, name: Strings.oldValue) + _newValue = ReadWriteAttribute(jsObject: object, name: Strings.newValue) + _url = ReadWriteAttribute(jsObject: object, name: Strings.url) + _storageArea = ReadWriteAttribute(jsObject: object, name: Strings.storageArea) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var key: String? + + @ReadWriteAttribute + public var oldValue: String? + + @ReadWriteAttribute + public var newValue: String? + + @ReadWriteAttribute + public var url: String + + @ReadWriteAttribute + public var storageArea: Storage? +} diff --git a/Sources/DOMKit/WebIDL/StringOrArrayBuffer.swift b/Sources/DOMKit/WebIDL/StringOrArrayBuffer.swift deleted file mode 100644 index 675c5a8f..00000000 --- a/Sources/DOMKit/WebIDL/StringOrArrayBuffer.swift +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public enum StringOrArrayBuffer: JSBridgedType, ExpressibleByStringLiteral { - case string(String) - case arrayBuffer(ArrayBuffer) - - public init?(from value: JSValue) { - if let decoded: String = value.fromJSValue() { - self = .string(decoded) - } else if let decoded: ArrayBuffer = value.fromJSValue() { - self = .arrayBuffer(decoded) - } else { - return nil - } - } - - public init(stringLiteral value: String) { - self = .string(value) - } - - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - switch self { - case let .string(v): return v.jsValue() - case let .arrayBuffer(v): return v.jsValue() - } - } -} diff --git a/Sources/DOMKit/WebIDL/StringOrElementCreationOptions.swift b/Sources/DOMKit/WebIDL/StringOrElementCreationOptions.swift deleted file mode 100644 index ba6cc8c1..00000000 --- a/Sources/DOMKit/WebIDL/StringOrElementCreationOptions.swift +++ /dev/null @@ -1,38 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public enum StringOrElementCreationOptions: JSBridgedType, ExpressibleByDictionaryLiteral, ExpressibleByStringLiteral { - case string(String) - case elementCreationOptions(ElementCreationOptions) - - public init?(from value: JSValue) { - if let decoded: String = value.fromJSValue() { - self = .string(decoded) - } else if let decoded: ElementCreationOptions = value.fromJSValue() { - self = .elementCreationOptions(decoded) - } else { - return nil - } - } - - public init(stringLiteral value: String) { - self = .string(value) - } - - public init(dictionaryLiteral elements: (ElementCreationOptions.Key, ElementCreationOptions.Value)...) { - self = .elementCreationOptions(.init(uniqueKeysWithValues: elements)) - } - - public var value: JSValue { jsValue() } - - public func jsValue() -> JSValue { - switch self { - case let .string(v): return v.jsValue() - case let .elementCreationOptions(v): return v.jsValue() - } - } -} diff --git a/Sources/DOMKit/WebIDL/String_or_WorkerOptions.swift b/Sources/DOMKit/WebIDL/String_or_WorkerOptions.swift new file mode 100644 index 00000000..e17ceccb --- /dev/null +++ b/Sources/DOMKit/WebIDL/String_or_WorkerOptions.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_String_or_WorkerOptions: ConvertibleToJSValue {} +extension String: Any_String_or_WorkerOptions {} +extension WorkerOptions: Any_String_or_WorkerOptions {} + +public enum String_or_WorkerOptions: JSValueCompatible, Any_String_or_WorkerOptions { + case string(String) + case workerOptions(WorkerOptions) + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + var workerOptions: WorkerOptions? { + switch self { + case let .workerOptions(workerOptions): return workerOptions + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let string: String = value.fromJSValue() { + return .string(string) + } + if let workerOptions: WorkerOptions = value.fromJSValue() { + return .workerOptions(workerOptions) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .string(string): + return string.jsValue + case let .workerOptions(workerOptions): + return workerOptions.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/String_or_record_String_to_String_or_seq_of_seq_of_String.swift b/Sources/DOMKit/WebIDL/String_or_record_String_to_String_or_seq_of_seq_of_String.swift new file mode 100644 index 00000000..fd8a1617 --- /dev/null +++ b/Sources/DOMKit/WebIDL/String_or_record_String_to_String_or_seq_of_seq_of_String.swift @@ -0,0 +1,60 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_String_or_record_String_to_String_or_seq_of_seq_of_String: ConvertibleToJSValue {} +extension String: Any_String_or_record_String_to_String_or_seq_of_seq_of_String {} +extension Dictionary: Any_String_or_record_String_to_String_or_seq_of_seq_of_String where Key == String, Value == String {} +extension Array: Any_String_or_record_String_to_String_or_seq_of_seq_of_String where Element == [String] {} + +public enum String_or_record_String_to_String_or_seq_of_seq_of_String: JSValueCompatible, Any_String_or_record_String_to_String_or_seq_of_seq_of_String { + case string(String) + case record_String_to_String([String: String]) + case seq_of_seq_of_String([[String]]) + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + var record_String_to_String: [String: String]? { + switch self { + case let .record_String_to_String(record_String_to_String): return record_String_to_String + default: return nil + } + } + + var seq_of_seq_of_String: [[String]]? { + switch self { + case let .seq_of_seq_of_String(seq_of_seq_of_String): return seq_of_seq_of_String + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let string: String = value.fromJSValue() { + return .string(string) + } + if let record_String_to_String: [String: String] = value.fromJSValue() { + return .record_String_to_String(record_String_to_String) + } + if let seq_of_seq_of_String: [[String]] = value.fromJSValue() { + return .seq_of_seq_of_String(seq_of_seq_of_String) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .string(string): + return string.jsValue + case let .record_String_to_String(record_String_to_String): + return record_String_to_String.jsValue + case let .seq_of_seq_of_String(seq_of_seq_of_String): + return seq_of_seq_of_String.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/String_or_seq_of_Double.swift b/Sources/DOMKit/WebIDL/String_or_seq_of_Double.swift new file mode 100644 index 00000000..88d5c5c3 --- /dev/null +++ b/Sources/DOMKit/WebIDL/String_or_seq_of_Double.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_String_or_seq_of_Double: ConvertibleToJSValue {} +extension String: Any_String_or_seq_of_Double {} +extension Array: Any_String_or_seq_of_Double where Element == Double {} + +public enum String_or_seq_of_Double: JSValueCompatible, Any_String_or_seq_of_Double { + case string(String) + case seq_of_Double([Double]) + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + var seq_of_Double: [Double]? { + switch self { + case let .seq_of_Double(seq_of_Double): return seq_of_Double + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let string: String = value.fromJSValue() { + return .string(string) + } + if let seq_of_Double: [Double] = value.fromJSValue() { + return .seq_of_Double(seq_of_Double) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .string(string): + return string.jsValue + case let .seq_of_Double(seq_of_Double): + return seq_of_Double.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/String_or_seq_of_String.swift b/Sources/DOMKit/WebIDL/String_or_seq_of_String.swift new file mode 100644 index 00000000..76ffbade --- /dev/null +++ b/Sources/DOMKit/WebIDL/String_or_seq_of_String.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_String_or_seq_of_String: ConvertibleToJSValue {} +extension String: Any_String_or_seq_of_String {} +extension Array: Any_String_or_seq_of_String where Element == String {} + +public enum String_or_seq_of_String: JSValueCompatible, Any_String_or_seq_of_String { + case string(String) + case seq_of_String([String]) + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + var seq_of_String: [String]? { + switch self { + case let .seq_of_String(seq_of_String): return seq_of_String + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let string: String = value.fromJSValue() { + return .string(string) + } + if let seq_of_String: [String] = value.fromJSValue() { + return .seq_of_String(seq_of_String) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .string(string): + return string.jsValue + case let .seq_of_String(seq_of_String): + return seq_of_String.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/Strings.swift b/Sources/DOMKit/WebIDL/Strings.swift new file mode 100644 index 00000000..0318a71e --- /dev/null +++ b/Sources/DOMKit/WebIDL/Strings.swift @@ -0,0 +1,1382 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +@usableFromInline enum Strings { + static let _self: JSString = "self" + @usableFromInline static let AbortController: JSString = "AbortController" + @usableFromInline static let AbortSignal: JSString = "AbortSignal" + @usableFromInline static let AbstractRange: JSString = "AbstractRange" + @usableFromInline static let AddSearchProvider: JSString = "AddSearchProvider" + @usableFromInline static let Animation: JSString = "Animation" + @usableFromInline static let AnimationEffect: JSString = "AnimationEffect" + @usableFromInline static let AnimationTimeline: JSString = "AnimationTimeline" + @usableFromInline static let Attr: JSString = "Attr" + @usableFromInline static let AudioTrack: JSString = "AudioTrack" + @usableFromInline static let AudioTrackList: JSString = "AudioTrackList" + @usableFromInline static let BarProp: JSString = "BarProp" + @usableFromInline static let BeforeUnloadEvent: JSString = "BeforeUnloadEvent" + @usableFromInline static let Blob: JSString = "Blob" + @usableFromInline static let BroadcastChannel: JSString = "BroadcastChannel" + @usableFromInline static let CDATASection: JSString = "CDATASection" + @usableFromInline static let Cache: JSString = "Cache" + @usableFromInline static let CacheStorage: JSString = "CacheStorage" + @usableFromInline static let CanvasFilter: JSString = "CanvasFilter" + @usableFromInline static let CanvasGradient: JSString = "CanvasGradient" + @usableFromInline static let CanvasPattern: JSString = "CanvasPattern" + @usableFromInline static let CanvasRenderingContext2D: JSString = "CanvasRenderingContext2D" + @usableFromInline static let CharacterData: JSString = "CharacterData" + @usableFromInline static let Comment: JSString = "Comment" + @usableFromInline static let CompositionEvent: JSString = "CompositionEvent" + @usableFromInline static let CustomElementRegistry: JSString = "CustomElementRegistry" + @usableFromInline static let CustomEvent: JSString = "CustomEvent" + @usableFromInline static let DOMException: JSString = "DOMException" + @usableFromInline static let DOMImplementation: JSString = "DOMImplementation" + @usableFromInline static let DOMMatrix: JSString = "DOMMatrix" + @usableFromInline static let DOMMatrixReadOnly: JSString = "DOMMatrixReadOnly" + @usableFromInline static let DOMParser: JSString = "DOMParser" + @usableFromInline static let DOMPoint: JSString = "DOMPoint" + @usableFromInline static let DOMPointReadOnly: JSString = "DOMPointReadOnly" + @usableFromInline static let DOMQuad: JSString = "DOMQuad" + @usableFromInline static let DOMRect: JSString = "DOMRect" + @usableFromInline static let DOMRectList: JSString = "DOMRectList" + @usableFromInline static let DOMRectReadOnly: JSString = "DOMRectReadOnly" + @usableFromInline static let DOMStringList: JSString = "DOMStringList" + @usableFromInline static let DOMStringMap: JSString = "DOMStringMap" + @usableFromInline static let DOMTokenList: JSString = "DOMTokenList" + @usableFromInline static let DataTransfer: JSString = "DataTransfer" + @usableFromInline static let DataTransferItem: JSString = "DataTransferItem" + @usableFromInline static let DataTransferItemList: JSString = "DataTransferItemList" + @usableFromInline static let Document: JSString = "Document" + @usableFromInline static let DocumentFragment: JSString = "DocumentFragment" + @usableFromInline static let DocumentTimeline: JSString = "DocumentTimeline" + @usableFromInline static let DocumentType: JSString = "DocumentType" + @usableFromInline static let DragEvent: JSString = "DragEvent" + @usableFromInline static let Element: JSString = "Element" + @usableFromInline static let ElementInternals: JSString = "ElementInternals" + @usableFromInline static let ErrorEvent: JSString = "ErrorEvent" + @usableFromInline static let Event: JSString = "Event" + @usableFromInline static let EventSource: JSString = "EventSource" + @usableFromInline static let EventTarget: JSString = "EventTarget" + @usableFromInline static let External: JSString = "External" + @usableFromInline static let File: JSString = "File" + @usableFromInline static let FileList: JSString = "FileList" + @usableFromInline static let FileReader: JSString = "FileReader" + @usableFromInline static let FocusEvent: JSString = "FocusEvent" + @usableFromInline static let FormData: JSString = "FormData" + @usableFromInline static let FormDataEvent: JSString = "FormDataEvent" + @usableFromInline static let HTMLAllCollection: JSString = "HTMLAllCollection" + @usableFromInline static let HTMLAnchorElement: JSString = "HTMLAnchorElement" + @usableFromInline static let HTMLAreaElement: JSString = "HTMLAreaElement" + @usableFromInline static let HTMLAudioElement: JSString = "HTMLAudioElement" + @usableFromInline static let HTMLBRElement: JSString = "HTMLBRElement" + @usableFromInline static let HTMLBaseElement: JSString = "HTMLBaseElement" + @usableFromInline static let HTMLBodyElement: JSString = "HTMLBodyElement" + @usableFromInline static let HTMLButtonElement: JSString = "HTMLButtonElement" + @usableFromInline static let HTMLCanvasElement: JSString = "HTMLCanvasElement" + @usableFromInline static let HTMLCollection: JSString = "HTMLCollection" + @usableFromInline static let HTMLDListElement: JSString = "HTMLDListElement" + @usableFromInline static let HTMLDataElement: JSString = "HTMLDataElement" + @usableFromInline static let HTMLDataListElement: JSString = "HTMLDataListElement" + @usableFromInline static let HTMLDetailsElement: JSString = "HTMLDetailsElement" + @usableFromInline static let HTMLDialogElement: JSString = "HTMLDialogElement" + @usableFromInline static let HTMLDirectoryElement: JSString = "HTMLDirectoryElement" + @usableFromInline static let HTMLDivElement: JSString = "HTMLDivElement" + @usableFromInline static let HTMLElement: JSString = "HTMLElement" + @usableFromInline static let HTMLEmbedElement: JSString = "HTMLEmbedElement" + @usableFromInline static let HTMLFieldSetElement: JSString = "HTMLFieldSetElement" + @usableFromInline static let HTMLFontElement: JSString = "HTMLFontElement" + @usableFromInline static let HTMLFormControlsCollection: JSString = "HTMLFormControlsCollection" + @usableFromInline static let HTMLFormElement: JSString = "HTMLFormElement" + @usableFromInline static let HTMLFrameElement: JSString = "HTMLFrameElement" + @usableFromInline static let HTMLFrameSetElement: JSString = "HTMLFrameSetElement" + @usableFromInline static let HTMLHRElement: JSString = "HTMLHRElement" + @usableFromInline static let HTMLHeadElement: JSString = "HTMLHeadElement" + @usableFromInline static let HTMLHeadingElement: JSString = "HTMLHeadingElement" + @usableFromInline static let HTMLHtmlElement: JSString = "HTMLHtmlElement" + @usableFromInline static let HTMLIFrameElement: JSString = "HTMLIFrameElement" + @usableFromInline static let HTMLImageElement: JSString = "HTMLImageElement" + @usableFromInline static let HTMLInputElement: JSString = "HTMLInputElement" + @usableFromInline static let HTMLLIElement: JSString = "HTMLLIElement" + @usableFromInline static let HTMLLabelElement: JSString = "HTMLLabelElement" + @usableFromInline static let HTMLLegendElement: JSString = "HTMLLegendElement" + @usableFromInline static let HTMLLinkElement: JSString = "HTMLLinkElement" + @usableFromInline static let HTMLMapElement: JSString = "HTMLMapElement" + @usableFromInline static let HTMLMarqueeElement: JSString = "HTMLMarqueeElement" + @usableFromInline static let HTMLMediaElement: JSString = "HTMLMediaElement" + @usableFromInline static let HTMLMenuElement: JSString = "HTMLMenuElement" + @usableFromInline static let HTMLMetaElement: JSString = "HTMLMetaElement" + @usableFromInline static let HTMLMeterElement: JSString = "HTMLMeterElement" + @usableFromInline static let HTMLModElement: JSString = "HTMLModElement" + @usableFromInline static let HTMLOListElement: JSString = "HTMLOListElement" + @usableFromInline static let HTMLObjectElement: JSString = "HTMLObjectElement" + @usableFromInline static let HTMLOptGroupElement: JSString = "HTMLOptGroupElement" + @usableFromInline static let HTMLOptionElement: JSString = "HTMLOptionElement" + @usableFromInline static let HTMLOptionsCollection: JSString = "HTMLOptionsCollection" + @usableFromInline static let HTMLOutputElement: JSString = "HTMLOutputElement" + @usableFromInline static let HTMLParagraphElement: JSString = "HTMLParagraphElement" + @usableFromInline static let HTMLParamElement: JSString = "HTMLParamElement" + @usableFromInline static let HTMLPictureElement: JSString = "HTMLPictureElement" + @usableFromInline static let HTMLPreElement: JSString = "HTMLPreElement" + @usableFromInline static let HTMLProgressElement: JSString = "HTMLProgressElement" + @usableFromInline static let HTMLQuoteElement: JSString = "HTMLQuoteElement" + @usableFromInline static let HTMLScriptElement: JSString = "HTMLScriptElement" + @usableFromInline static let HTMLSelectElement: JSString = "HTMLSelectElement" + @usableFromInline static let HTMLSlotElement: JSString = "HTMLSlotElement" + @usableFromInline static let HTMLSourceElement: JSString = "HTMLSourceElement" + @usableFromInline static let HTMLSpanElement: JSString = "HTMLSpanElement" + @usableFromInline static let HTMLStyleElement: JSString = "HTMLStyleElement" + @usableFromInline static let HTMLTableCaptionElement: JSString = "HTMLTableCaptionElement" + @usableFromInline static let HTMLTableCellElement: JSString = "HTMLTableCellElement" + @usableFromInline static let HTMLTableColElement: JSString = "HTMLTableColElement" + @usableFromInline static let HTMLTableElement: JSString = "HTMLTableElement" + @usableFromInline static let HTMLTableRowElement: JSString = "HTMLTableRowElement" + @usableFromInline static let HTMLTableSectionElement: JSString = "HTMLTableSectionElement" + @usableFromInline static let HTMLTemplateElement: JSString = "HTMLTemplateElement" + @usableFromInline static let HTMLTextAreaElement: JSString = "HTMLTextAreaElement" + @usableFromInline static let HTMLTimeElement: JSString = "HTMLTimeElement" + @usableFromInline static let HTMLTitleElement: JSString = "HTMLTitleElement" + @usableFromInline static let HTMLTrackElement: JSString = "HTMLTrackElement" + @usableFromInline static let HTMLUListElement: JSString = "HTMLUListElement" + @usableFromInline static let HTMLUnknownElement: JSString = "HTMLUnknownElement" + @usableFromInline static let HTMLVideoElement: JSString = "HTMLVideoElement" + @usableFromInline static let HashChangeEvent: JSString = "HashChangeEvent" + @usableFromInline static let Headers: JSString = "Headers" + @usableFromInline static let History: JSString = "History" + @usableFromInline static let ImageBitmap: JSString = "ImageBitmap" + @usableFromInline static let ImageBitmapRenderingContext: JSString = "ImageBitmapRenderingContext" + @usableFromInline static let ImageData: JSString = "ImageData" + @usableFromInline static let InputEvent: JSString = "InputEvent" + @usableFromInline static let IsSearchProviderInstalled: JSString = "IsSearchProviderInstalled" + @usableFromInline static let KeyboardEvent: JSString = "KeyboardEvent" + @usableFromInline static let KeyframeEffect: JSString = "KeyframeEffect" + @usableFromInline static let Location: JSString = "Location" + @usableFromInline static let MediaError: JSString = "MediaError" + @usableFromInline static let MessageChannel: JSString = "MessageChannel" + @usableFromInline static let MessageEvent: JSString = "MessageEvent" + @usableFromInline static let MessagePort: JSString = "MessagePort" + @usableFromInline static let MimeType: JSString = "MimeType" + @usableFromInline static let MimeTypeArray: JSString = "MimeTypeArray" + @usableFromInline static let MouseEvent: JSString = "MouseEvent" + @usableFromInline static let MutationEvent: JSString = "MutationEvent" + @usableFromInline static let MutationObserver: JSString = "MutationObserver" + @usableFromInline static let MutationRecord: JSString = "MutationRecord" + @usableFromInline static let NamedNodeMap: JSString = "NamedNodeMap" + @usableFromInline static let NavigationPreloadManager: JSString = "NavigationPreloadManager" + @usableFromInline static let Navigator: JSString = "Navigator" + @usableFromInline static let Node: JSString = "Node" + @usableFromInline static let NodeIterator: JSString = "NodeIterator" + @usableFromInline static let NodeList: JSString = "NodeList" + @usableFromInline static let Object: JSString = "Object" + @usableFromInline static let OffscreenCanvas: JSString = "OffscreenCanvas" + @usableFromInline static let OffscreenCanvasRenderingContext2D: JSString = "OffscreenCanvasRenderingContext2D" + @usableFromInline static let PageTransitionEvent: JSString = "PageTransitionEvent" + @usableFromInline static let Path2D: JSString = "Path2D" + @usableFromInline static let Performance: JSString = "Performance" + @usableFromInline static let Plugin: JSString = "Plugin" + @usableFromInline static let PluginArray: JSString = "PluginArray" + @usableFromInline static let PopStateEvent: JSString = "PopStateEvent" + @usableFromInline static let ProcessingInstruction: JSString = "ProcessingInstruction" + @usableFromInline static let ProgressEvent: JSString = "ProgressEvent" + @usableFromInline static let PromiseRejectionEvent: JSString = "PromiseRejectionEvent" + @usableFromInline static let RadioNodeList: JSString = "RadioNodeList" + @usableFromInline static let Range: JSString = "Range" + @usableFromInline static let Request: JSString = "Request" + @usableFromInline static let Response: JSString = "Response" + @usableFromInline static let ServiceWorker: JSString = "ServiceWorker" + @usableFromInline static let ServiceWorkerContainer: JSString = "ServiceWorkerContainer" + @usableFromInline static let ServiceWorkerRegistration: JSString = "ServiceWorkerRegistration" + @usableFromInline static let ShadowRoot: JSString = "ShadowRoot" + @usableFromInline static let SharedWorker: JSString = "SharedWorker" + @usableFromInline static let StaticRange: JSString = "StaticRange" + @usableFromInline static let Storage: JSString = "Storage" + @usableFromInline static let StorageEvent: JSString = "StorageEvent" + @usableFromInline static let SubmitEvent: JSString = "SubmitEvent" + @usableFromInline static let Text: JSString = "Text" + @usableFromInline static let TextMetrics: JSString = "TextMetrics" + @usableFromInline static let TextTrack: JSString = "TextTrack" + @usableFromInline static let TextTrackCue: JSString = "TextTrackCue" + @usableFromInline static let TextTrackCueList: JSString = "TextTrackCueList" + @usableFromInline static let TextTrackList: JSString = "TextTrackList" + @usableFromInline static let TimeRanges: JSString = "TimeRanges" + @usableFromInline static let TrackEvent: JSString = "TrackEvent" + @usableFromInline static let TreeWalker: JSString = "TreeWalker" + @usableFromInline static let UIEvent: JSString = "UIEvent" + @usableFromInline static let URL: JSString = "URL" + @usableFromInline static let URLSearchParams: JSString = "URLSearchParams" + @usableFromInline static let ValidityState: JSString = "ValidityState" + @usableFromInline static let VideoTrack: JSString = "VideoTrack" + @usableFromInline static let VideoTrackList: JSString = "VideoTrackList" + @usableFromInline static let WheelEvent: JSString = "WheelEvent" + @usableFromInline static let Window: JSString = "Window" + @usableFromInline static let Worker: JSString = "Worker" + @usableFromInline static let Worklet: JSString = "Worklet" + @usableFromInline static let XMLDocument: JSString = "XMLDocument" + @usableFromInline static let XMLHttpRequest: JSString = "XMLHttpRequest" + @usableFromInline static let XMLHttpRequestEventTarget: JSString = "XMLHttpRequestEventTarget" + @usableFromInline static let XMLHttpRequestUpload: JSString = "XMLHttpRequestUpload" + @usableFromInline static let XPathEvaluator: JSString = "XPathEvaluator" + @usableFromInline static let XPathExpression: JSString = "XPathExpression" + @usableFromInline static let XPathResult: JSString = "XPathResult" + @usableFromInline static let XSLTProcessor: JSString = "XSLTProcessor" + @usableFromInline static let a: JSString = "a" + @usableFromInline static let aLink: JSString = "aLink" + @usableFromInline static let abbr: JSString = "abbr" + @usableFromInline static let abort: JSString = "abort" + @usableFromInline static let aborted: JSString = "aborted" + @usableFromInline static let accept: JSString = "accept" + @usableFromInline static let acceptCharset: JSString = "acceptCharset" + @usableFromInline static let accessKey: JSString = "accessKey" + @usableFromInline static let accessKeyLabel: JSString = "accessKeyLabel" + @usableFromInline static let action: JSString = "action" + @usableFromInline static let active: JSString = "active" + @usableFromInline static let activeCues: JSString = "activeCues" + @usableFromInline static let activeElement: JSString = "activeElement" + @usableFromInline static let actualBoundingBoxAscent: JSString = "actualBoundingBoxAscent" + @usableFromInline static let actualBoundingBoxDescent: JSString = "actualBoundingBoxDescent" + @usableFromInline static let actualBoundingBoxLeft: JSString = "actualBoundingBoxLeft" + @usableFromInline static let actualBoundingBoxRight: JSString = "actualBoundingBoxRight" + @usableFromInline static let add: JSString = "add" + @usableFromInline static let addAll: JSString = "addAll" + @usableFromInline static let addColorStop: JSString = "addColorStop" + @usableFromInline static let addCue: JSString = "addCue" + @usableFromInline static let addModule: JSString = "addModule" + @usableFromInline static let addPath: JSString = "addPath" + @usableFromInline static let addTextTrack: JSString = "addTextTrack" + @usableFromInline static let addedNodes: JSString = "addedNodes" + @usableFromInline static let adoptNode: JSString = "adoptNode" + @usableFromInline static let after: JSString = "after" + @usableFromInline static let alert: JSString = "alert" + @usableFromInline static let align: JSString = "align" + @usableFromInline static let alinkColor: JSString = "alinkColor" + @usableFromInline static let all: JSString = "all" + @usableFromInline static let allow: JSString = "allow" + @usableFromInline static let allowFullscreen: JSString = "allowFullscreen" + @usableFromInline static let alpha: JSString = "alpha" + @usableFromInline static let alphabeticBaseline: JSString = "alphabeticBaseline" + @usableFromInline static let alt: JSString = "alt" + @usableFromInline static let altKey: JSString = "altKey" + @usableFromInline static let ancestorOrigins: JSString = "ancestorOrigins" + @usableFromInline static let anchors: JSString = "anchors" + @usableFromInline static let animate: JSString = "animate" + @usableFromInline static let appCodeName: JSString = "appCodeName" + @usableFromInline static let appName: JSString = "appName" + @usableFromInline static let appVersion: JSString = "appVersion" + @usableFromInline static let append: JSString = "append" + @usableFromInline static let appendChild: JSString = "appendChild" + @usableFromInline static let appendData: JSString = "appendData" + @usableFromInline static let applets: JSString = "applets" + @usableFromInline static let arc: JSString = "arc" + @usableFromInline static let arcTo: JSString = "arcTo" + @usableFromInline static let archive: JSString = "archive" + @usableFromInline static let areas: JSString = "areas" + @usableFromInline static let ariaAtomic: JSString = "ariaAtomic" + @usableFromInline static let ariaAutoComplete: JSString = "ariaAutoComplete" + @usableFromInline static let ariaBusy: JSString = "ariaBusy" + @usableFromInline static let ariaChecked: JSString = "ariaChecked" + @usableFromInline static let ariaColCount: JSString = "ariaColCount" + @usableFromInline static let ariaColIndex: JSString = "ariaColIndex" + @usableFromInline static let ariaColIndexText: JSString = "ariaColIndexText" + @usableFromInline static let ariaColSpan: JSString = "ariaColSpan" + @usableFromInline static let ariaCurrent: JSString = "ariaCurrent" + @usableFromInline static let ariaDescription: JSString = "ariaDescription" + @usableFromInline static let ariaDisabled: JSString = "ariaDisabled" + @usableFromInline static let ariaExpanded: JSString = "ariaExpanded" + @usableFromInline static let ariaHasPopup: JSString = "ariaHasPopup" + @usableFromInline static let ariaHidden: JSString = "ariaHidden" + @usableFromInline static let ariaInvalid: JSString = "ariaInvalid" + @usableFromInline static let ariaKeyShortcuts: JSString = "ariaKeyShortcuts" + @usableFromInline static let ariaLabel: JSString = "ariaLabel" + @usableFromInline static let ariaLevel: JSString = "ariaLevel" + @usableFromInline static let ariaLive: JSString = "ariaLive" + @usableFromInline static let ariaModal: JSString = "ariaModal" + @usableFromInline static let ariaMultiLine: JSString = "ariaMultiLine" + @usableFromInline static let ariaMultiSelectable: JSString = "ariaMultiSelectable" + @usableFromInline static let ariaOrientation: JSString = "ariaOrientation" + @usableFromInline static let ariaPlaceholder: JSString = "ariaPlaceholder" + @usableFromInline static let ariaPosInSet: JSString = "ariaPosInSet" + @usableFromInline static let ariaPressed: JSString = "ariaPressed" + @usableFromInline static let ariaReadOnly: JSString = "ariaReadOnly" + @usableFromInline static let ariaRequired: JSString = "ariaRequired" + @usableFromInline static let ariaRoleDescription: JSString = "ariaRoleDescription" + @usableFromInline static let ariaRowCount: JSString = "ariaRowCount" + @usableFromInline static let ariaRowIndex: JSString = "ariaRowIndex" + @usableFromInline static let ariaRowIndexText: JSString = "ariaRowIndexText" + @usableFromInline static let ariaRowSpan: JSString = "ariaRowSpan" + @usableFromInline static let ariaSelected: JSString = "ariaSelected" + @usableFromInline static let ariaSetSize: JSString = "ariaSetSize" + @usableFromInline static let ariaSort: JSString = "ariaSort" + @usableFromInline static let ariaValueMax: JSString = "ariaValueMax" + @usableFromInline static let ariaValueMin: JSString = "ariaValueMin" + @usableFromInline static let ariaValueNow: JSString = "ariaValueNow" + @usableFromInline static let ariaValueText: JSString = "ariaValueText" + @usableFromInline static let arrayBuffer: JSString = "arrayBuffer" + @usableFromInline static let `as`: JSString = "as" + @usableFromInline static let assign: JSString = "assign" + @usableFromInline static let assignedElements: JSString = "assignedElements" + @usableFromInline static let assignedNodes: JSString = "assignedNodes" + @usableFromInline static let assignedSlot: JSString = "assignedSlot" + @usableFromInline static let async: JSString = "async" + @usableFromInline static let atob: JSString = "atob" + @usableFromInline static let attachInternals: JSString = "attachInternals" + @usableFromInline static let attachShadow: JSString = "attachShadow" + @usableFromInline static let attrChange: JSString = "attrChange" + @usableFromInline static let attrName: JSString = "attrName" + @usableFromInline static let attributeFilter: JSString = "attributeFilter" + @usableFromInline static let attributeName: JSString = "attributeName" + @usableFromInline static let attributeNamespace: JSString = "attributeNamespace" + @usableFromInline static let attributeOldValue: JSString = "attributeOldValue" + @usableFromInline static let attributes: JSString = "attributes" + @usableFromInline static let audioTracks: JSString = "audioTracks" + @usableFromInline static let autocapitalize: JSString = "autocapitalize" + @usableFromInline static let autocomplete: JSString = "autocomplete" + @usableFromInline static let autofocus: JSString = "autofocus" + @usableFromInline static let autoplay: JSString = "autoplay" + @usableFromInline static let axis: JSString = "axis" + @usableFromInline static let b: JSString = "b" + @usableFromInline static let back: JSString = "back" + @usableFromInline static let background: JSString = "background" + @usableFromInline static let badInput: JSString = "badInput" + @usableFromInline static let baseURI: JSString = "baseURI" + @usableFromInline static let before: JSString = "before" + @usableFromInline static let beginPath: JSString = "beginPath" + @usableFromInline static let behavior: JSString = "behavior" + @usableFromInline static let bezierCurveTo: JSString = "bezierCurveTo" + @usableFromInline static let bgColor: JSString = "bgColor" + @usableFromInline static let blob: JSString = "blob" + @usableFromInline static let blocking: JSString = "blocking" + @usableFromInline static let blur: JSString = "blur" + @usableFromInline static let body: JSString = "body" + @usableFromInline static let bodyUsed: JSString = "bodyUsed" + @usableFromInline static let booleanValue: JSString = "booleanValue" + @usableFromInline static let border: JSString = "border" + @usableFromInline static let bottom: JSString = "bottom" + @usableFromInline static let btoa: JSString = "btoa" + @usableFromInline static let bubbles: JSString = "bubbles" + @usableFromInline static let buffered: JSString = "buffered" + @usableFromInline static let button: JSString = "button" + @usableFromInline static let buttons: JSString = "buttons" + @usableFromInline static let c: JSString = "c" + @usableFromInline static let cache: JSString = "cache" + @usableFromInline static let cacheName: JSString = "cacheName" + @usableFromInline static let caches: JSString = "caches" + @usableFromInline static let canPlayType: JSString = "canPlayType" + @usableFromInline static let cancel: JSString = "cancel" + @usableFromInline static let cancelAnimationFrame: JSString = "cancelAnimationFrame" + @usableFromInline static let cancelBubble: JSString = "cancelBubble" + @usableFromInline static let cancelable: JSString = "cancelable" + @usableFromInline static let canvas: JSString = "canvas" + @usableFromInline static let caption: JSString = "caption" + @usableFromInline static let capture: JSString = "capture" + @usableFromInline static let captureEvents: JSString = "captureEvents" + @usableFromInline static let cellIndex: JSString = "cellIndex" + @usableFromInline static let cellPadding: JSString = "cellPadding" + @usableFromInline static let cellSpacing: JSString = "cellSpacing" + @usableFromInline static let cells: JSString = "cells" + @usableFromInline static let ch: JSString = "ch" + @usableFromInline static let chOff: JSString = "chOff" + @usableFromInline static let charCode: JSString = "charCode" + @usableFromInline static let characterData: JSString = "characterData" + @usableFromInline static let characterDataOldValue: JSString = "characterDataOldValue" + @usableFromInline static let characterSet: JSString = "characterSet" + @usableFromInline static let charset: JSString = "charset" + @usableFromInline static let checkValidity: JSString = "checkValidity" + @usableFromInline static let checked: JSString = "checked" + @usableFromInline static let childElementCount: JSString = "childElementCount" + @usableFromInline static let childList: JSString = "childList" + @usableFromInline static let childNodes: JSString = "childNodes" + @usableFromInline static let children: JSString = "children" + @usableFromInline static let cite: JSString = "cite" + @usableFromInline static let classList: JSString = "classList" + @usableFromInline static let className: JSString = "className" + @usableFromInline static let clear: JSString = "clear" + @usableFromInline static let clearData: JSString = "clearData" + @usableFromInline static let clearInterval: JSString = "clearInterval" + @usableFromInline static let clearParameters: JSString = "clearParameters" + @usableFromInline static let clearRect: JSString = "clearRect" + @usableFromInline static let clearTimeout: JSString = "clearTimeout" + @usableFromInline static let click: JSString = "click" + @usableFromInline static let clientId: JSString = "clientId" + @usableFromInline static let clientInformation: JSString = "clientInformation" + @usableFromInline static let clientX: JSString = "clientX" + @usableFromInline static let clientY: JSString = "clientY" + @usableFromInline static let clip: JSString = "clip" + @usableFromInline static let clone: JSString = "clone" + @usableFromInline static let cloneContents: JSString = "cloneContents" + @usableFromInline static let cloneNode: JSString = "cloneNode" + @usableFromInline static let cloneRange: JSString = "cloneRange" + @usableFromInline static let close: JSString = "close" + @usableFromInline static let closePath: JSString = "closePath" + @usableFromInline static let closed: JSString = "closed" + @usableFromInline static let closest: JSString = "closest" + @usableFromInline static let code: JSString = "code" + @usableFromInline static let codeBase: JSString = "codeBase" + @usableFromInline static let codeType: JSString = "codeType" + @usableFromInline static let colSpan: JSString = "colSpan" + @usableFromInline static let collapse: JSString = "collapse" + @usableFromInline static let collapsed: JSString = "collapsed" + @usableFromInline static let colno: JSString = "colno" + @usableFromInline static let color: JSString = "color" + @usableFromInline static let colorSpace: JSString = "colorSpace" + @usableFromInline static let colorSpaceConversion: JSString = "colorSpaceConversion" + @usableFromInline static let cols: JSString = "cols" + @usableFromInline static let commit: JSString = "commit" + @usableFromInline static let commitStyles: JSString = "commitStyles" + @usableFromInline static let commonAncestorContainer: JSString = "commonAncestorContainer" + @usableFromInline static let compact: JSString = "compact" + @usableFromInline static let compareBoundaryPoints: JSString = "compareBoundaryPoints" + @usableFromInline static let compareDocumentPosition: JSString = "compareDocumentPosition" + @usableFromInline static let comparePoint: JSString = "comparePoint" + @usableFromInline static let compatMode: JSString = "compatMode" + @usableFromInline static let complete: JSString = "complete" + @usableFromInline static let composed: JSString = "composed" + @usableFromInline static let composedPath: JSString = "composedPath" + @usableFromInline static let composite: JSString = "composite" + @usableFromInline static let computedOffset: JSString = "computedOffset" + @usableFromInline static let confirm: JSString = "confirm" + @usableFromInline static let contains: JSString = "contains" + @usableFromInline static let content: JSString = "content" + @usableFromInline static let contentDocument: JSString = "contentDocument" + @usableFromInline static let contentEditable: JSString = "contentEditable" + @usableFromInline static let contentType: JSString = "contentType" + @usableFromInline static let contentWindow: JSString = "contentWindow" + @usableFromInline static let control: JSString = "control" + @usableFromInline static let controller: JSString = "controller" + @usableFromInline static let controls: JSString = "controls" + @usableFromInline static let convertToBlob: JSString = "convertToBlob" + @usableFromInline static let cookie: JSString = "cookie" + @usableFromInline static let cookieEnabled: JSString = "cookieEnabled" + @usableFromInline static let coords: JSString = "coords" + @usableFromInline static let createAttribute: JSString = "createAttribute" + @usableFromInline static let createAttributeNS: JSString = "createAttributeNS" + @usableFromInline static let createCDATASection: JSString = "createCDATASection" + @usableFromInline static let createCaption: JSString = "createCaption" + @usableFromInline static let createComment: JSString = "createComment" + @usableFromInline static let createConicGradient: JSString = "createConicGradient" + @usableFromInline static let createDocument: JSString = "createDocument" + @usableFromInline static let createDocumentFragment: JSString = "createDocumentFragment" + @usableFromInline static let createDocumentType: JSString = "createDocumentType" + @usableFromInline static let createElement: JSString = "createElement" + @usableFromInline static let createElementNS: JSString = "createElementNS" + @usableFromInline static let createEvent: JSString = "createEvent" + @usableFromInline static let createHTMLDocument: JSString = "createHTMLDocument" + @usableFromInline static let createImageBitmap: JSString = "createImageBitmap" + @usableFromInline static let createImageData: JSString = "createImageData" + @usableFromInline static let createLinearGradient: JSString = "createLinearGradient" + @usableFromInline static let createObjectURL: JSString = "createObjectURL" + @usableFromInline static let createPattern: JSString = "createPattern" + @usableFromInline static let createProcessingInstruction: JSString = "createProcessingInstruction" + @usableFromInline static let createRadialGradient: JSString = "createRadialGradient" + @usableFromInline static let createRange: JSString = "createRange" + @usableFromInline static let createTBody: JSString = "createTBody" + @usableFromInline static let createTFoot: JSString = "createTFoot" + @usableFromInline static let createTHead: JSString = "createTHead" + @usableFromInline static let createTextNode: JSString = "createTextNode" + @usableFromInline static let credentials: JSString = "credentials" + @usableFromInline static let crossOrigin: JSString = "crossOrigin" + @usableFromInline static let crossOriginIsolated: JSString = "crossOriginIsolated" + @usableFromInline static let ctrlKey: JSString = "ctrlKey" + @usableFromInline static let cues: JSString = "cues" + @usableFromInline static let currentIteration: JSString = "currentIteration" + @usableFromInline static let currentNode: JSString = "currentNode" + @usableFromInline static let currentScript: JSString = "currentScript" + @usableFromInline static let currentSrc: JSString = "currentSrc" + @usableFromInline static let currentTarget: JSString = "currentTarget" + @usableFromInline static let currentTime: JSString = "currentTime" + @usableFromInline static let customElements: JSString = "customElements" + @usableFromInline static let customError: JSString = "customError" + @usableFromInline static let d: JSString = "d" + @usableFromInline static let data: JSString = "data" + @usableFromInline static let dataTransfer: JSString = "dataTransfer" + @usableFromInline static let dataset: JSString = "dataset" + @usableFromInline static let dateTime: JSString = "dateTime" + @usableFromInline static let declare: JSString = "declare" + @usableFromInline static let decode: JSString = "decode" + @usableFromInline static let decoding: JSString = "decoding" + @usableFromInline static let `default`: JSString = "default" + @usableFromInline static let defaultChecked: JSString = "defaultChecked" + @usableFromInline static let defaultMuted: JSString = "defaultMuted" + @usableFromInline static let defaultPlaybackRate: JSString = "defaultPlaybackRate" + @usableFromInline static let defaultPrevented: JSString = "defaultPrevented" + @usableFromInline static let defaultSelected: JSString = "defaultSelected" + @usableFromInline static let defaultValue: JSString = "defaultValue" + @usableFromInline static let defaultView: JSString = "defaultView" + @usableFromInline static let `defer`: JSString = "defer" + @usableFromInline static let define: JSString = "define" + @usableFromInline static let delay: JSString = "delay" + @usableFromInline static let delegatesFocus: JSString = "delegatesFocus" + @usableFromInline static let delete: JSString = "delete" + @usableFromInline static let deleteCaption: JSString = "deleteCaption" + @usableFromInline static let deleteCell: JSString = "deleteCell" + @usableFromInline static let deleteContents: JSString = "deleteContents" + @usableFromInline static let deleteData: JSString = "deleteData" + @usableFromInline static let deleteRow: JSString = "deleteRow" + @usableFromInline static let deleteTFoot: JSString = "deleteTFoot" + @usableFromInline static let deleteTHead: JSString = "deleteTHead" + @usableFromInline static let deltaMode: JSString = "deltaMode" + @usableFromInline static let deltaX: JSString = "deltaX" + @usableFromInline static let deltaY: JSString = "deltaY" + @usableFromInline static let deltaZ: JSString = "deltaZ" + @usableFromInline static let description: JSString = "description" + @usableFromInline static let designMode: JSString = "designMode" + @usableFromInline static let destination: JSString = "destination" + @usableFromInline static let desynchronized: JSString = "desynchronized" + @usableFromInline static let detach: JSString = "detach" + @usableFromInline static let detail: JSString = "detail" + @usableFromInline static let dir: JSString = "dir" + @usableFromInline static let dirName: JSString = "dirName" + @usableFromInline static let direction: JSString = "direction" + @usableFromInline static let disable: JSString = "disable" + @usableFromInline static let disabled: JSString = "disabled" + @usableFromInline static let disconnect: JSString = "disconnect" + @usableFromInline static let dispatchEvent: JSString = "dispatchEvent" + @usableFromInline static let doctype: JSString = "doctype" + @usableFromInline static let document: JSString = "document" + @usableFromInline static let documentElement: JSString = "documentElement" + @usableFromInline static let documentURI: JSString = "documentURI" + @usableFromInline static let domain: JSString = "domain" + @usableFromInline static let download: JSString = "download" + @usableFromInline static let draggable: JSString = "draggable" + @usableFromInline static let drawFocusIfNeeded: JSString = "drawFocusIfNeeded" + @usableFromInline static let drawImage: JSString = "drawImage" + @usableFromInline static let dropEffect: JSString = "dropEffect" + @usableFromInline static let duration: JSString = "duration" + @usableFromInline static let e: JSString = "e" + @usableFromInline static let easing: JSString = "easing" + @usableFromInline static let effect: JSString = "effect" + @usableFromInline static let effectAllowed: JSString = "effectAllowed" + @usableFromInline static let elements: JSString = "elements" + @usableFromInline static let ellipse: JSString = "ellipse" + @usableFromInline static let emHeightAscent: JSString = "emHeightAscent" + @usableFromInline static let emHeightDescent: JSString = "emHeightDescent" + @usableFromInline static let embeds: JSString = "embeds" + @usableFromInline static let enable: JSString = "enable" + @usableFromInline static let enabled: JSString = "enabled" + @usableFromInline static let enabledPlugin: JSString = "enabledPlugin" + @usableFromInline static let encoding: JSString = "encoding" + @usableFromInline static let enctype: JSString = "enctype" + @usableFromInline static let end: JSString = "end" + @usableFromInline static let endContainer: JSString = "endContainer" + @usableFromInline static let endDelay: JSString = "endDelay" + @usableFromInline static let endOffset: JSString = "endOffset" + @usableFromInline static let endTime: JSString = "endTime" + @usableFromInline static let ended: JSString = "ended" + @usableFromInline static let endings: JSString = "endings" + @usableFromInline static let enterKeyHint: JSString = "enterKeyHint" + @usableFromInline static let error: JSString = "error" + @usableFromInline static let evaluate: JSString = "evaluate" + @usableFromInline static let event: JSString = "event" + @usableFromInline static let eventPhase: JSString = "eventPhase" + @usableFromInline static let execCommand: JSString = "execCommand" + @usableFromInline static let extends: JSString = "extends" + @usableFromInline static let external: JSString = "external" + @usableFromInline static let extractContents: JSString = "extractContents" + @usableFromInline static let f: JSString = "f" + @usableFromInline static let face: JSString = "face" + @usableFromInline static let fastSeek: JSString = "fastSeek" + @usableFromInline static let fetch: JSString = "fetch" + @usableFromInline static let fgColor: JSString = "fgColor" + @usableFromInline static let filename: JSString = "filename" + @usableFromInline static let files: JSString = "files" + @usableFromInline static let fill: JSString = "fill" + @usableFromInline static let fillRect: JSString = "fillRect" + @usableFromInline static let fillStyle: JSString = "fillStyle" + @usableFromInline static let fillText: JSString = "fillText" + @usableFromInline static let filter: JSString = "filter" + @usableFromInline static let finish: JSString = "finish" + @usableFromInline static let finished: JSString = "finished" + @usableFromInline static let firstChild: JSString = "firstChild" + @usableFromInline static let firstElementChild: JSString = "firstElementChild" + @usableFromInline static let flatten: JSString = "flatten" + @usableFromInline static let flipX: JSString = "flipX" + @usableFromInline static let flipY: JSString = "flipY" + @usableFromInline static let focus: JSString = "focus" + @usableFromInline static let font: JSString = "font" + @usableFromInline static let fontBoundingBoxAscent: JSString = "fontBoundingBoxAscent" + @usableFromInline static let fontBoundingBoxDescent: JSString = "fontBoundingBoxDescent" + @usableFromInline static let fontKerning: JSString = "fontKerning" + @usableFromInline static let fontStretch: JSString = "fontStretch" + @usableFromInline static let fontVariantCaps: JSString = "fontVariantCaps" + @usableFromInline static let form: JSString = "form" + @usableFromInline static let formAction: JSString = "formAction" + @usableFromInline static let formData: JSString = "formData" + @usableFromInline static let formEnctype: JSString = "formEnctype" + @usableFromInline static let formMethod: JSString = "formMethod" + @usableFromInline static let formNoValidate: JSString = "formNoValidate" + @usableFromInline static let formTarget: JSString = "formTarget" + @usableFromInline static let forms: JSString = "forms" + @usableFromInline static let forward: JSString = "forward" + @usableFromInline static let frame: JSString = "frame" + @usableFromInline static let frameBorder: JSString = "frameBorder" + @usableFromInline static let frameElement: JSString = "frameElement" + @usableFromInline static let frames: JSString = "frames" + @usableFromInline static let fromFloat32Array: JSString = "fromFloat32Array" + @usableFromInline static let fromFloat64Array: JSString = "fromFloat64Array" + @usableFromInline static let fromMatrix: JSString = "fromMatrix" + @usableFromInline static let fromPoint: JSString = "fromPoint" + @usableFromInline static let fromQuad: JSString = "fromQuad" + @usableFromInline static let fromRect: JSString = "fromRect" + @usableFromInline static let get: JSString = "get" + @usableFromInline static let getAll: JSString = "getAll" + @usableFromInline static let getAllResponseHeaders: JSString = "getAllResponseHeaders" + @usableFromInline static let getAnimations: JSString = "getAnimations" + @usableFromInline static let getAsFile: JSString = "getAsFile" + @usableFromInline static let getAttribute: JSString = "getAttribute" + @usableFromInline static let getAttributeNS: JSString = "getAttributeNS" + @usableFromInline static let getAttributeNames: JSString = "getAttributeNames" + @usableFromInline static let getAttributeNode: JSString = "getAttributeNode" + @usableFromInline static let getAttributeNodeNS: JSString = "getAttributeNodeNS" + @usableFromInline static let getBounds: JSString = "getBounds" + @usableFromInline static let getComputedTiming: JSString = "getComputedTiming" + @usableFromInline static let getContext: JSString = "getContext" + @usableFromInline static let getContextAttributes: JSString = "getContextAttributes" + @usableFromInline static let getCueById: JSString = "getCueById" + @usableFromInline static let getData: JSString = "getData" + @usableFromInline static let getElementById: JSString = "getElementById" + @usableFromInline static let getElementsByClassName: JSString = "getElementsByClassName" + @usableFromInline static let getElementsByName: JSString = "getElementsByName" + @usableFromInline static let getElementsByTagName: JSString = "getElementsByTagName" + @usableFromInline static let getElementsByTagNameNS: JSString = "getElementsByTagNameNS" + @usableFromInline static let getImageData: JSString = "getImageData" + @usableFromInline static let getKeyframes: JSString = "getKeyframes" + @usableFromInline static let getLineDash: JSString = "getLineDash" + @usableFromInline static let getModifierState: JSString = "getModifierState" + @usableFromInline static let getNamedItemNS: JSString = "getNamedItemNS" + @usableFromInline static let getParameter: JSString = "getParameter" + @usableFromInline static let getRegistration: JSString = "getRegistration" + @usableFromInline static let getRegistrations: JSString = "getRegistrations" + @usableFromInline static let getResponseHeader: JSString = "getResponseHeader" + @usableFromInline static let getRootNode: JSString = "getRootNode" + @usableFromInline static let getSVGDocument: JSString = "getSVGDocument" + @usableFromInline static let getStartDate: JSString = "getStartDate" + @usableFromInline static let getState: JSString = "getState" + @usableFromInline static let getTiming: JSString = "getTiming" + @usableFromInline static let getTrackById: JSString = "getTrackById" + @usableFromInline static let getTransform: JSString = "getTransform" + @usableFromInline static let globalAlpha: JSString = "globalAlpha" + @usableFromInline static let globalCompositeOperation: JSString = "globalCompositeOperation" + @usableFromInline static let go: JSString = "go" + @usableFromInline static let handled: JSString = "handled" + @usableFromInline static let hangingBaseline: JSString = "hangingBaseline" + @usableFromInline static let hardwareConcurrency: JSString = "hardwareConcurrency" + @usableFromInline static let has: JSString = "has" + @usableFromInline static let hasAttribute: JSString = "hasAttribute" + @usableFromInline static let hasAttributeNS: JSString = "hasAttributeNS" + @usableFromInline static let hasAttributes: JSString = "hasAttributes" + @usableFromInline static let hasChildNodes: JSString = "hasChildNodes" + @usableFromInline static let hasFeature: JSString = "hasFeature" + @usableFromInline static let hasFocus: JSString = "hasFocus" + @usableFromInline static let hash: JSString = "hash" + @usableFromInline static let head: JSString = "head" + @usableFromInline static let headerValue: JSString = "headerValue" + @usableFromInline static let headers: JSString = "headers" + @usableFromInline static let height: JSString = "height" + @usableFromInline static let hidden: JSString = "hidden" + @usableFromInline static let high: JSString = "high" + @usableFromInline static let history: JSString = "history" + @usableFromInline static let host: JSString = "host" + @usableFromInline static let hostname: JSString = "hostname" + @usableFromInline static let href: JSString = "href" + @usableFromInline static let hreflang: JSString = "hreflang" + @usableFromInline static let hspace: JSString = "hspace" + @usableFromInline static let htmlFor: JSString = "htmlFor" + @usableFromInline static let httpEquiv: JSString = "httpEquiv" + @usableFromInline static let id: JSString = "id" + @usableFromInline static let ideographicBaseline: JSString = "ideographicBaseline" + @usableFromInline static let ignoreMethod: JSString = "ignoreMethod" + @usableFromInline static let ignoreSearch: JSString = "ignoreSearch" + @usableFromInline static let ignoreVary: JSString = "ignoreVary" + @usableFromInline static let imageOrientation: JSString = "imageOrientation" + @usableFromInline static let imageSizes: JSString = "imageSizes" + @usableFromInline static let imageSmoothingEnabled: JSString = "imageSmoothingEnabled" + @usableFromInline static let imageSmoothingQuality: JSString = "imageSmoothingQuality" + @usableFromInline static let imageSrcset: JSString = "imageSrcset" + @usableFromInline static let images: JSString = "images" + @usableFromInline static let implementation: JSString = "implementation" + @usableFromInline static let importNode: JSString = "importNode" + @usableFromInline static let importStylesheet: JSString = "importStylesheet" + @usableFromInline static let inBandMetadataTrackDispatchType: JSString = "inBandMetadataTrackDispatchType" + @usableFromInline static let includeUncontrolled: JSString = "includeUncontrolled" + @usableFromInline static let indeterminate: JSString = "indeterminate" + @usableFromInline static let index: JSString = "index" + @usableFromInline static let inert: JSString = "inert" + @usableFromInline static let initCompositionEvent: JSString = "initCompositionEvent" + @usableFromInline static let initCustomEvent: JSString = "initCustomEvent" + @usableFromInline static let initEvent: JSString = "initEvent" + @usableFromInline static let initKeyboardEvent: JSString = "initKeyboardEvent" + @usableFromInline static let initMessageEvent: JSString = "initMessageEvent" + @usableFromInline static let initMouseEvent: JSString = "initMouseEvent" + @usableFromInline static let initMutationEvent: JSString = "initMutationEvent" + @usableFromInline static let initStorageEvent: JSString = "initStorageEvent" + @usableFromInline static let initUIEvent: JSString = "initUIEvent" + @usableFromInline static let innerText: JSString = "innerText" + @usableFromInline static let inputEncoding: JSString = "inputEncoding" + @usableFromInline static let inputMode: JSString = "inputMode" + @usableFromInline static let inputType: JSString = "inputType" + @usableFromInline static let insertAdjacentElement: JSString = "insertAdjacentElement" + @usableFromInline static let insertAdjacentText: JSString = "insertAdjacentText" + @usableFromInline static let insertBefore: JSString = "insertBefore" + @usableFromInline static let insertCell: JSString = "insertCell" + @usableFromInline static let insertData: JSString = "insertData" + @usableFromInline static let insertNode: JSString = "insertNode" + @usableFromInline static let insertRow: JSString = "insertRow" + @usableFromInline static let installing: JSString = "installing" + @usableFromInline static let integrity: JSString = "integrity" + @usableFromInline static let intersectsNode: JSString = "intersectsNode" + @usableFromInline static let invalidIteratorState: JSString = "invalidIteratorState" + @usableFromInline static let inverse: JSString = "inverse" + @usableFromInline static let invertSelf: JSString = "invertSelf" + @usableFromInline static let `is`: JSString = "is" + @usableFromInline static let is2D: JSString = "is2D" + @usableFromInline static let isComposing: JSString = "isComposing" + @usableFromInline static let isConnected: JSString = "isConnected" + @usableFromInline static let isContentEditable: JSString = "isContentEditable" + @usableFromInline static let isContextLost: JSString = "isContextLost" + @usableFromInline static let isDefaultNamespace: JSString = "isDefaultNamespace" + @usableFromInline static let isEqualNode: JSString = "isEqualNode" + @usableFromInline static let isHistoryNavigation: JSString = "isHistoryNavigation" + @usableFromInline static let isIdentity: JSString = "isIdentity" + @usableFromInline static let isMap: JSString = "isMap" + @usableFromInline static let isPointInPath: JSString = "isPointInPath" + @usableFromInline static let isPointInRange: JSString = "isPointInRange" + @usableFromInline static let isPointInStroke: JSString = "isPointInStroke" + @usableFromInline static let isReloadNavigation: JSString = "isReloadNavigation" + @usableFromInline static let isSameNode: JSString = "isSameNode" + @usableFromInline static let isSecureContext: JSString = "isSecureContext" + @usableFromInline static let isTrusted: JSString = "isTrusted" + @usableFromInline static let item: JSString = "item" + @usableFromInline static let items: JSString = "items" + @usableFromInline static let iterateNext: JSString = "iterateNext" + @usableFromInline static let iterationStart: JSString = "iterationStart" + @usableFromInline static let iterations: JSString = "iterations" + @usableFromInline static let javaEnabled: JSString = "javaEnabled" + @usableFromInline static let json: JSString = "json" + @usableFromInline static let keepalive: JSString = "keepalive" + @usableFromInline static let key: JSString = "key" + @usableFromInline static let keyCode: JSString = "keyCode" + @usableFromInline static let keys: JSString = "keys" + @usableFromInline static let kind: JSString = "kind" + @usableFromInline static let label: JSString = "label" + @usableFromInline static let labels: JSString = "labels" + @usableFromInline static let lang: JSString = "lang" + @usableFromInline static let language: JSString = "language" + @usableFromInline static let languages: JSString = "languages" + @usableFromInline static let lastChild: JSString = "lastChild" + @usableFromInline static let lastElementChild: JSString = "lastElementChild" + @usableFromInline static let lastEventId: JSString = "lastEventId" + @usableFromInline static let lastModified: JSString = "lastModified" + @usableFromInline static let left: JSString = "left" + @usableFromInline static let length: JSString = "length" + @usableFromInline static let lengthComputable: JSString = "lengthComputable" + @usableFromInline static let letterSpacing: JSString = "letterSpacing" + @usableFromInline static let lineCap: JSString = "lineCap" + @usableFromInline static let lineDashOffset: JSString = "lineDashOffset" + @usableFromInline static let lineJoin: JSString = "lineJoin" + @usableFromInline static let lineTo: JSString = "lineTo" + @usableFromInline static let lineWidth: JSString = "lineWidth" + @usableFromInline static let lineno: JSString = "lineno" + @usableFromInline static let link: JSString = "link" + @usableFromInline static let linkColor: JSString = "linkColor" + @usableFromInline static let links: JSString = "links" + @usableFromInline static let list: JSString = "list" + @usableFromInline static let load: JSString = "load" + @usableFromInline static let loaded: JSString = "loaded" + @usableFromInline static let loading: JSString = "loading" + @usableFromInline static let localName: JSString = "localName" + @usableFromInline static let localStorage: JSString = "localStorage" + @usableFromInline static let location: JSString = "location" + @usableFromInline static let locationbar: JSString = "locationbar" + @usableFromInline static let longDesc: JSString = "longDesc" + @usableFromInline static let lookupNamespaceURI: JSString = "lookupNamespaceURI" + @usableFromInline static let lookupPrefix: JSString = "lookupPrefix" + @usableFromInline static let loop: JSString = "loop" + @usableFromInline static let low: JSString = "low" + @usableFromInline static let lowsrc: JSString = "lowsrc" + @usableFromInline static let m11: JSString = "m11" + @usableFromInline static let m12: JSString = "m12" + @usableFromInline static let m13: JSString = "m13" + @usableFromInline static let m14: JSString = "m14" + @usableFromInline static let m21: JSString = "m21" + @usableFromInline static let m22: JSString = "m22" + @usableFromInline static let m23: JSString = "m23" + @usableFromInline static let m24: JSString = "m24" + @usableFromInline static let m31: JSString = "m31" + @usableFromInline static let m32: JSString = "m32" + @usableFromInline static let m33: JSString = "m33" + @usableFromInline static let m34: JSString = "m34" + @usableFromInline static let m41: JSString = "m41" + @usableFromInline static let m42: JSString = "m42" + @usableFromInline static let m43: JSString = "m43" + @usableFromInline static let m44: JSString = "m44" + @usableFromInline static let marginHeight: JSString = "marginHeight" + @usableFromInline static let marginWidth: JSString = "marginWidth" + @usableFromInline static let match: JSString = "match" + @usableFromInline static let matchAll: JSString = "matchAll" + @usableFromInline static let matches: JSString = "matches" + @usableFromInline static let matrixTransform: JSString = "matrixTransform" + @usableFromInline static let max: JSString = "max" + @usableFromInline static let maxLength: JSString = "maxLength" + @usableFromInline static let measureText: JSString = "measureText" + @usableFromInline static let media: JSString = "media" + @usableFromInline static let menubar: JSString = "menubar" + @usableFromInline static let message: JSString = "message" + @usableFromInline static let metaKey: JSString = "metaKey" + @usableFromInline static let method: JSString = "method" + @usableFromInline static let mimeTypes: JSString = "mimeTypes" + @usableFromInline static let min: JSString = "min" + @usableFromInline static let minLength: JSString = "minLength" + @usableFromInline static let miterLimit: JSString = "miterLimit" + @usableFromInline static let mode: JSString = "mode" + @usableFromInline static let modifierAltGraph: JSString = "modifierAltGraph" + @usableFromInline static let modifierCapsLock: JSString = "modifierCapsLock" + @usableFromInline static let modifierFn: JSString = "modifierFn" + @usableFromInline static let modifierFnLock: JSString = "modifierFnLock" + @usableFromInline static let modifierHyper: JSString = "modifierHyper" + @usableFromInline static let modifierNumLock: JSString = "modifierNumLock" + @usableFromInline static let modifierScrollLock: JSString = "modifierScrollLock" + @usableFromInline static let modifierSuper: JSString = "modifierSuper" + @usableFromInline static let modifierSymbol: JSString = "modifierSymbol" + @usableFromInline static let modifierSymbolLock: JSString = "modifierSymbolLock" + @usableFromInline static let moveTo: JSString = "moveTo" + @usableFromInline static let multiple: JSString = "multiple" + @usableFromInline static let multiply: JSString = "multiply" + @usableFromInline static let multiplySelf: JSString = "multiplySelf" + @usableFromInline static let muted: JSString = "muted" + @usableFromInline static let name: JSString = "name" + @usableFromInline static let namedItem: JSString = "namedItem" + @usableFromInline static let namespaceURI: JSString = "namespaceURI" + @usableFromInline static let naturalHeight: JSString = "naturalHeight" + @usableFromInline static let naturalWidth: JSString = "naturalWidth" + @usableFromInline static let navigationPreload: JSString = "navigationPreload" + @usableFromInline static let navigator: JSString = "navigator" + @usableFromInline static let networkState: JSString = "networkState" + @usableFromInline static let newURL: JSString = "newURL" + @usableFromInline static let newValue: JSString = "newValue" + @usableFromInline static let nextElementSibling: JSString = "nextElementSibling" + @usableFromInline static let nextNode: JSString = "nextNode" + @usableFromInline static let nextSibling: JSString = "nextSibling" + @usableFromInline static let noHref: JSString = "noHref" + @usableFromInline static let noModule: JSString = "noModule" + @usableFromInline static let noResize: JSString = "noResize" + @usableFromInline static let noShade: JSString = "noShade" + @usableFromInline static let noValidate: JSString = "noValidate" + @usableFromInline static let noWrap: JSString = "noWrap" + @usableFromInline static let nodeName: JSString = "nodeName" + @usableFromInline static let nodeType: JSString = "nodeType" + @usableFromInline static let nodeValue: JSString = "nodeValue" + @usableFromInline static let nonce: JSString = "nonce" + @usableFromInline static let normalize: JSString = "normalize" + @usableFromInline static let now: JSString = "now" + @usableFromInline static let numberValue: JSString = "numberValue" + @usableFromInline static let observe: JSString = "observe" + @usableFromInline static let offset: JSString = "offset" + @usableFromInline static let ok: JSString = "ok" + @usableFromInline static let oldURL: JSString = "oldURL" + @usableFromInline static let oldValue: JSString = "oldValue" + @usableFromInline static let onLine: JSString = "onLine" + @usableFromInline static let onabort: JSString = "onabort" + @usableFromInline static let onaddtrack: JSString = "onaddtrack" + @usableFromInline static let onafterprint: JSString = "onafterprint" + @usableFromInline static let onauxclick: JSString = "onauxclick" + @usableFromInline static let onbeforeprint: JSString = "onbeforeprint" + @usableFromInline static let onbeforeunload: JSString = "onbeforeunload" + @usableFromInline static let onblur: JSString = "onblur" + @usableFromInline static let oncancel: JSString = "oncancel" + @usableFromInline static let oncanplay: JSString = "oncanplay" + @usableFromInline static let oncanplaythrough: JSString = "oncanplaythrough" + @usableFromInline static let once: JSString = "once" + @usableFromInline static let onchange: JSString = "onchange" + @usableFromInline static let onclick: JSString = "onclick" + @usableFromInline static let onclose: JSString = "onclose" + @usableFromInline static let oncontextlost: JSString = "oncontextlost" + @usableFromInline static let oncontextmenu: JSString = "oncontextmenu" + @usableFromInline static let oncontextrestored: JSString = "oncontextrestored" + @usableFromInline static let oncontrollerchange: JSString = "oncontrollerchange" + @usableFromInline static let oncopy: JSString = "oncopy" + @usableFromInline static let oncuechange: JSString = "oncuechange" + @usableFromInline static let oncut: JSString = "oncut" + @usableFromInline static let ondblclick: JSString = "ondblclick" + @usableFromInline static let ondrag: JSString = "ondrag" + @usableFromInline static let ondragend: JSString = "ondragend" + @usableFromInline static let ondragenter: JSString = "ondragenter" + @usableFromInline static let ondragleave: JSString = "ondragleave" + @usableFromInline static let ondragover: JSString = "ondragover" + @usableFromInline static let ondragstart: JSString = "ondragstart" + @usableFromInline static let ondrop: JSString = "ondrop" + @usableFromInline static let ondurationchange: JSString = "ondurationchange" + @usableFromInline static let onemptied: JSString = "onemptied" + @usableFromInline static let onended: JSString = "onended" + @usableFromInline static let onenter: JSString = "onenter" + @usableFromInline static let onerror: JSString = "onerror" + @usableFromInline static let onexit: JSString = "onexit" + @usableFromInline static let onfinish: JSString = "onfinish" + @usableFromInline static let onfocus: JSString = "onfocus" + @usableFromInline static let onformdata: JSString = "onformdata" + @usableFromInline static let onhashchange: JSString = "onhashchange" + @usableFromInline static let oninput: JSString = "oninput" + @usableFromInline static let oninvalid: JSString = "oninvalid" + @usableFromInline static let onkeydown: JSString = "onkeydown" + @usableFromInline static let onkeypress: JSString = "onkeypress" + @usableFromInline static let onkeyup: JSString = "onkeyup" + @usableFromInline static let onlanguagechange: JSString = "onlanguagechange" + @usableFromInline static let onload: JSString = "onload" + @usableFromInline static let onloadeddata: JSString = "onloadeddata" + @usableFromInline static let onloadedmetadata: JSString = "onloadedmetadata" + @usableFromInline static let onloadend: JSString = "onloadend" + @usableFromInline static let onloadstart: JSString = "onloadstart" + @usableFromInline static let onmessage: JSString = "onmessage" + @usableFromInline static let onmessageerror: JSString = "onmessageerror" + @usableFromInline static let onmousedown: JSString = "onmousedown" + @usableFromInline static let onmouseenter: JSString = "onmouseenter" + @usableFromInline static let onmouseleave: JSString = "onmouseleave" + @usableFromInline static let onmousemove: JSString = "onmousemove" + @usableFromInline static let onmouseout: JSString = "onmouseout" + @usableFromInline static let onmouseover: JSString = "onmouseover" + @usableFromInline static let onmouseup: JSString = "onmouseup" + @usableFromInline static let onoffline: JSString = "onoffline" + @usableFromInline static let ononline: JSString = "ononline" + @usableFromInline static let onopen: JSString = "onopen" + @usableFromInline static let onpagehide: JSString = "onpagehide" + @usableFromInline static let onpageshow: JSString = "onpageshow" + @usableFromInline static let onpaste: JSString = "onpaste" + @usableFromInline static let onpause: JSString = "onpause" + @usableFromInline static let onplay: JSString = "onplay" + @usableFromInline static let onplaying: JSString = "onplaying" + @usableFromInline static let onpopstate: JSString = "onpopstate" + @usableFromInline static let onprogress: JSString = "onprogress" + @usableFromInline static let onratechange: JSString = "onratechange" + @usableFromInline static let onreadystatechange: JSString = "onreadystatechange" + @usableFromInline static let onrejectionhandled: JSString = "onrejectionhandled" + @usableFromInline static let onremove: JSString = "onremove" + @usableFromInline static let onremovetrack: JSString = "onremovetrack" + @usableFromInline static let onreset: JSString = "onreset" + @usableFromInline static let onresize: JSString = "onresize" + @usableFromInline static let onscroll: JSString = "onscroll" + @usableFromInline static let onsecuritypolicyviolation: JSString = "onsecuritypolicyviolation" + @usableFromInline static let onseeked: JSString = "onseeked" + @usableFromInline static let onseeking: JSString = "onseeking" + @usableFromInline static let onselect: JSString = "onselect" + @usableFromInline static let onslotchange: JSString = "onslotchange" + @usableFromInline static let onstalled: JSString = "onstalled" + @usableFromInline static let onstatechange: JSString = "onstatechange" + @usableFromInline static let onstorage: JSString = "onstorage" + @usableFromInline static let onsubmit: JSString = "onsubmit" + @usableFromInline static let onsuspend: JSString = "onsuspend" + @usableFromInline static let ontimeout: JSString = "ontimeout" + @usableFromInline static let ontimeupdate: JSString = "ontimeupdate" + @usableFromInline static let ontoggle: JSString = "ontoggle" + @usableFromInline static let onunhandledrejection: JSString = "onunhandledrejection" + @usableFromInline static let onunload: JSString = "onunload" + @usableFromInline static let onupdatefound: JSString = "onupdatefound" + @usableFromInline static let onvisibilitychange: JSString = "onvisibilitychange" + @usableFromInline static let onvolumechange: JSString = "onvolumechange" + @usableFromInline static let onwaiting: JSString = "onwaiting" + @usableFromInline static let onwebkitanimationend: JSString = "onwebkitanimationend" + @usableFromInline static let onwebkitanimationiteration: JSString = "onwebkitanimationiteration" + @usableFromInline static let onwebkitanimationstart: JSString = "onwebkitanimationstart" + @usableFromInline static let onwebkittransitionend: JSString = "onwebkittransitionend" + @usableFromInline static let onwheel: JSString = "onwheel" + @usableFromInline static let open: JSString = "open" + @usableFromInline static let opener: JSString = "opener" + @usableFromInline static let optimum: JSString = "optimum" + @usableFromInline static let options: JSString = "options" + @usableFromInline static let origin: JSString = "origin" + @usableFromInline static let originAgentCluster: JSString = "originAgentCluster" + @usableFromInline static let originTime: JSString = "originTime" + @usableFromInline static let oscpu: JSString = "oscpu" + @usableFromInline static let outerText: JSString = "outerText" + @usableFromInline static let overrideMimeType: JSString = "overrideMimeType" + @usableFromInline static let ownerDocument: JSString = "ownerDocument" + @usableFromInline static let ownerElement: JSString = "ownerElement" + @usableFromInline static let p1: JSString = "p1" + @usableFromInline static let p2: JSString = "p2" + @usableFromInline static let p3: JSString = "p3" + @usableFromInline static let p4: JSString = "p4" + @usableFromInline static let parent: JSString = "parent" + @usableFromInline static let parentElement: JSString = "parentElement" + @usableFromInline static let parentNode: JSString = "parentNode" + @usableFromInline static let parseFromString: JSString = "parseFromString" + @usableFromInline static let passive: JSString = "passive" + @usableFromInline static let password: JSString = "password" + @usableFromInline static let pathname: JSString = "pathname" + @usableFromInline static let pattern: JSString = "pattern" + @usableFromInline static let patternMismatch: JSString = "patternMismatch" + @usableFromInline static let pause: JSString = "pause" + @usableFromInline static let pauseOnExit: JSString = "pauseOnExit" + @usableFromInline static let paused: JSString = "paused" + @usableFromInline static let pdfViewerEnabled: JSString = "pdfViewerEnabled" + @usableFromInline static let pending: JSString = "pending" + @usableFromInline static let performance: JSString = "performance" + @usableFromInline static let persist: JSString = "persist" + @usableFromInline static let persisted: JSString = "persisted" + @usableFromInline static let personalbar: JSString = "personalbar" + @usableFromInline static let phase: JSString = "phase" + @usableFromInline static let ping: JSString = "ping" + @usableFromInline static let placeholder: JSString = "placeholder" + @usableFromInline static let platform: JSString = "platform" + @usableFromInline static let play: JSString = "play" + @usableFromInline static let playState: JSString = "playState" + @usableFromInline static let playbackRate: JSString = "playbackRate" + @usableFromInline static let played: JSString = "played" + @usableFromInline static let playsInline: JSString = "playsInline" + @usableFromInline static let plugins: JSString = "plugins" + @usableFromInline static let pointerBeforeReferenceNode: JSString = "pointerBeforeReferenceNode" + @usableFromInline static let port: JSString = "port" + @usableFromInline static let port1: JSString = "port1" + @usableFromInline static let port2: JSString = "port2" + @usableFromInline static let ports: JSString = "ports" + @usableFromInline static let position: JSString = "position" + @usableFromInline static let postMessage: JSString = "postMessage" + @usableFromInline static let poster: JSString = "poster" + @usableFromInline static let preMultiplySelf: JSString = "preMultiplySelf" + @usableFromInline static let prefix: JSString = "prefix" + @usableFromInline static let preload: JSString = "preload" + @usableFromInline static let preloadResponse: JSString = "preloadResponse" + @usableFromInline static let premultiplyAlpha: JSString = "premultiplyAlpha" + @usableFromInline static let prepend: JSString = "prepend" + @usableFromInline static let preservesPitch: JSString = "preservesPitch" + @usableFromInline static let prevValue: JSString = "prevValue" + @usableFromInline static let preventDefault: JSString = "preventDefault" + @usableFromInline static let preventScroll: JSString = "preventScroll" + @usableFromInline static let previousElementSibling: JSString = "previousElementSibling" + @usableFromInline static let previousNode: JSString = "previousNode" + @usableFromInline static let previousSibling: JSString = "previousSibling" + @usableFromInline static let print: JSString = "print" + @usableFromInline static let product: JSString = "product" + @usableFromInline static let productSub: JSString = "productSub" + @usableFromInline static let progress: JSString = "progress" + @usableFromInline static let promise: JSString = "promise" + @usableFromInline static let prompt: JSString = "prompt" + @usableFromInline static let `protocol`: JSString = "protocol" + @usableFromInline static let pseudoElement: JSString = "pseudoElement" + @usableFromInline static let publicId: JSString = "publicId" + @usableFromInline static let pushState: JSString = "pushState" + @usableFromInline static let put: JSString = "put" + @usableFromInline static let putImageData: JSString = "putImageData" + @usableFromInline static let quadraticCurveTo: JSString = "quadraticCurveTo" + @usableFromInline static let quality: JSString = "quality" + @usableFromInline static let queryCommandEnabled: JSString = "queryCommandEnabled" + @usableFromInline static let queryCommandIndeterm: JSString = "queryCommandIndeterm" + @usableFromInline static let queryCommandState: JSString = "queryCommandState" + @usableFromInline static let queryCommandSupported: JSString = "queryCommandSupported" + @usableFromInline static let queryCommandValue: JSString = "queryCommandValue" + @usableFromInline static let querySelector: JSString = "querySelector" + @usableFromInline static let querySelectorAll: JSString = "querySelectorAll" + @usableFromInline static let rangeOverflow: JSString = "rangeOverflow" + @usableFromInline static let rangeUnderflow: JSString = "rangeUnderflow" + @usableFromInline static let readAsArrayBuffer: JSString = "readAsArrayBuffer" + @usableFromInline static let readAsBinaryString: JSString = "readAsBinaryString" + @usableFromInline static let readAsDataURL: JSString = "readAsDataURL" + @usableFromInline static let readAsText: JSString = "readAsText" + @usableFromInline static let readOnly: JSString = "readOnly" + @usableFromInline static let ready: JSString = "ready" + @usableFromInline static let readyState: JSString = "readyState" + @usableFromInline static let reason: JSString = "reason" + @usableFromInline static let rect: JSString = "rect" + @usableFromInline static let redirect: JSString = "redirect" + @usableFromInline static let redirected: JSString = "redirected" + @usableFromInline static let referenceNode: JSString = "referenceNode" + @usableFromInline static let referrer: JSString = "referrer" + @usableFromInline static let referrerPolicy: JSString = "referrerPolicy" + @usableFromInline static let refresh: JSString = "refresh" + @usableFromInline static let register: JSString = "register" + @usableFromInline static let registerProtocolHandler: JSString = "registerProtocolHandler" + @usableFromInline static let rel: JSString = "rel" + @usableFromInline static let relList: JSString = "relList" + @usableFromInline static let relatedNode: JSString = "relatedNode" + @usableFromInline static let relatedTarget: JSString = "relatedTarget" + @usableFromInline static let releaseEvents: JSString = "releaseEvents" + @usableFromInline static let reload: JSString = "reload" + @usableFromInline static let remove: JSString = "remove" + @usableFromInline static let removeAttribute: JSString = "removeAttribute" + @usableFromInline static let removeAttributeNS: JSString = "removeAttributeNS" + @usableFromInline static let removeAttributeNode: JSString = "removeAttributeNode" + @usableFromInline static let removeChild: JSString = "removeChild" + @usableFromInline static let removeCue: JSString = "removeCue" + @usableFromInline static let removeNamedItem: JSString = "removeNamedItem" + @usableFromInline static let removeNamedItemNS: JSString = "removeNamedItemNS" + @usableFromInline static let removeParameter: JSString = "removeParameter" + @usableFromInline static let removedNodes: JSString = "removedNodes" + @usableFromInline static let `repeat`: JSString = "repeat" + @usableFromInline static let replace: JSString = "replace" + @usableFromInline static let replaceChild: JSString = "replaceChild" + @usableFromInline static let replaceChildren: JSString = "replaceChildren" + @usableFromInline static let replaceData: JSString = "replaceData" + @usableFromInline static let replaceState: JSString = "replaceState" + @usableFromInline static let replaceWith: JSString = "replaceWith" + @usableFromInline static let replacesClientId: JSString = "replacesClientId" + @usableFromInline static let reportError: JSString = "reportError" + @usableFromInline static let reportValidity: JSString = "reportValidity" + @usableFromInline static let request: JSString = "request" + @usableFromInline static let requestSubmit: JSString = "requestSubmit" + @usableFromInline static let required: JSString = "required" + @usableFromInline static let reset: JSString = "reset" + @usableFromInline static let resetTransform: JSString = "resetTransform" + @usableFromInline static let resizeHeight: JSString = "resizeHeight" + @usableFromInline static let resizeQuality: JSString = "resizeQuality" + @usableFromInline static let resizeWidth: JSString = "resizeWidth" + @usableFromInline static let response: JSString = "response" + @usableFromInline static let responseText: JSString = "responseText" + @usableFromInline static let responseType: JSString = "responseType" + @usableFromInline static let responseURL: JSString = "responseURL" + @usableFromInline static let responseXML: JSString = "responseXML" + @usableFromInline static let restore: JSString = "restore" + @usableFromInline static let result: JSString = "result" + @usableFromInline static let resultType: JSString = "resultType" + @usableFromInline static let resultingClientId: JSString = "resultingClientId" + @usableFromInline static let returnValue: JSString = "returnValue" + @usableFromInline static let rev: JSString = "rev" + @usableFromInline static let reverse: JSString = "reverse" + @usableFromInline static let reversed: JSString = "reversed" + @usableFromInline static let revokeObjectURL: JSString = "revokeObjectURL" + @usableFromInline static let right: JSString = "right" + @usableFromInline static let role: JSString = "role" + @usableFromInline static let root: JSString = "root" + @usableFromInline static let rotate: JSString = "rotate" + @usableFromInline static let rotateAxisAngle: JSString = "rotateAxisAngle" + @usableFromInline static let rotateAxisAngleSelf: JSString = "rotateAxisAngleSelf" + @usableFromInline static let rotateFromVector: JSString = "rotateFromVector" + @usableFromInline static let rotateFromVectorSelf: JSString = "rotateFromVectorSelf" + @usableFromInline static let rotateSelf: JSString = "rotateSelf" + @usableFromInline static let roundRect: JSString = "roundRect" + @usableFromInline static let rowIndex: JSString = "rowIndex" + @usableFromInline static let rowSpan: JSString = "rowSpan" + @usableFromInline static let rows: JSString = "rows" + @usableFromInline static let rules: JSString = "rules" + @usableFromInline static let sandbox: JSString = "sandbox" + @usableFromInline static let save: JSString = "save" + @usableFromInline static let scale: JSString = "scale" + @usableFromInline static let scale3d: JSString = "scale3d" + @usableFromInline static let scale3dSelf: JSString = "scale3dSelf" + @usableFromInline static let scaleNonUniform: JSString = "scaleNonUniform" + @usableFromInline static let scaleSelf: JSString = "scaleSelf" + @usableFromInline static let scheme: JSString = "scheme" + @usableFromInline static let scope: JSString = "scope" + @usableFromInline static let screenX: JSString = "screenX" + @usableFromInline static let screenY: JSString = "screenY" + @usableFromInline static let scriptURL: JSString = "scriptURL" + @usableFromInline static let scripts: JSString = "scripts" + @usableFromInline static let scrollAmount: JSString = "scrollAmount" + @usableFromInline static let scrollDelay: JSString = "scrollDelay" + @usableFromInline static let scrollPathIntoView: JSString = "scrollPathIntoView" + @usableFromInline static let scrollRestoration: JSString = "scrollRestoration" + @usableFromInline static let scrollbars: JSString = "scrollbars" + @usableFromInline static let scrolling: JSString = "scrolling" + @usableFromInline static let search: JSString = "search" + @usableFromInline static let searchParams: JSString = "searchParams" + @usableFromInline static let sectionRowIndex: JSString = "sectionRowIndex" + @usableFromInline static let seekable: JSString = "seekable" + @usableFromInline static let seeking: JSString = "seeking" + @usableFromInline static let select: JSString = "select" + @usableFromInline static let selectNode: JSString = "selectNode" + @usableFromInline static let selectNodeContents: JSString = "selectNodeContents" + @usableFromInline static let selected: JSString = "selected" + @usableFromInline static let selectedIndex: JSString = "selectedIndex" + @usableFromInline static let selectedOptions: JSString = "selectedOptions" + @usableFromInline static let selectionDirection: JSString = "selectionDirection" + @usableFromInline static let selectionEnd: JSString = "selectionEnd" + @usableFromInline static let selectionStart: JSString = "selectionStart" + @usableFromInline static let send: JSString = "send" + @usableFromInline static let serviceWorker: JSString = "serviceWorker" + @usableFromInline static let sessionStorage: JSString = "sessionStorage" + @usableFromInline static let set: JSString = "set" + @usableFromInline static let setAttribute: JSString = "setAttribute" + @usableFromInline static let setAttributeNS: JSString = "setAttributeNS" + @usableFromInline static let setAttributeNode: JSString = "setAttributeNode" + @usableFromInline static let setAttributeNodeNS: JSString = "setAttributeNodeNS" + @usableFromInline static let setCustomValidity: JSString = "setCustomValidity" + @usableFromInline static let setData: JSString = "setData" + @usableFromInline static let setDragImage: JSString = "setDragImage" + @usableFromInline static let setEnd: JSString = "setEnd" + @usableFromInline static let setEndAfter: JSString = "setEndAfter" + @usableFromInline static let setEndBefore: JSString = "setEndBefore" + @usableFromInline static let setFormValue: JSString = "setFormValue" + @usableFromInline static let setHeaderValue: JSString = "setHeaderValue" + @usableFromInline static let setInterval: JSString = "setInterval" + @usableFromInline static let setKeyframes: JSString = "setKeyframes" + @usableFromInline static let setLineDash: JSString = "setLineDash" + @usableFromInline static let setMatrixValue: JSString = "setMatrixValue" + @usableFromInline static let setNamedItem: JSString = "setNamedItem" + @usableFromInline static let setNamedItemNS: JSString = "setNamedItemNS" + @usableFromInline static let setParameter: JSString = "setParameter" + @usableFromInline static let setRangeText: JSString = "setRangeText" + @usableFromInline static let setRequestHeader: JSString = "setRequestHeader" + @usableFromInline static let setSelectionRange: JSString = "setSelectionRange" + @usableFromInline static let setStart: JSString = "setStart" + @usableFromInline static let setStartAfter: JSString = "setStartAfter" + @usableFromInline static let setStartBefore: JSString = "setStartBefore" + @usableFromInline static let setTimeout: JSString = "setTimeout" + @usableFromInline static let setTransform: JSString = "setTransform" + @usableFromInline static let setValidity: JSString = "setValidity" + @usableFromInline static let shadowBlur: JSString = "shadowBlur" + @usableFromInline static let shadowColor: JSString = "shadowColor" + @usableFromInline static let shadowOffsetX: JSString = "shadowOffsetX" + @usableFromInline static let shadowOffsetY: JSString = "shadowOffsetY" + @usableFromInline static let shadowRoot: JSString = "shadowRoot" + @usableFromInline static let shape: JSString = "shape" + @usableFromInline static let shiftKey: JSString = "shiftKey" + @usableFromInline static let show: JSString = "show" + @usableFromInline static let showModal: JSString = "showModal" + @usableFromInline static let showPicker: JSString = "showPicker" + @usableFromInline static let signal: JSString = "signal" + @usableFromInline static let singleNodeValue: JSString = "singleNodeValue" + @usableFromInline static let size: JSString = "size" + @usableFromInline static let sizes: JSString = "sizes" + @usableFromInline static let skewX: JSString = "skewX" + @usableFromInline static let skewXSelf: JSString = "skewXSelf" + @usableFromInline static let skewY: JSString = "skewY" + @usableFromInline static let skewYSelf: JSString = "skewYSelf" + @usableFromInline static let slice: JSString = "slice" + @usableFromInline static let slot: JSString = "slot" + @usableFromInline static let slotAssignment: JSString = "slotAssignment" + @usableFromInline static let snapshotItem: JSString = "snapshotItem" + @usableFromInline static let snapshotLength: JSString = "snapshotLength" + @usableFromInline static let sort: JSString = "sort" + @usableFromInline static let source: JSString = "source" + @usableFromInline static let span: JSString = "span" + @usableFromInline static let specified: JSString = "specified" + @usableFromInline static let spellcheck: JSString = "spellcheck" + @usableFromInline static let splitText: JSString = "splitText" + @usableFromInline static let src: JSString = "src" + @usableFromInline static let srcElement: JSString = "srcElement" + @usableFromInline static let srcdoc: JSString = "srcdoc" + @usableFromInline static let srclang: JSString = "srclang" + @usableFromInline static let srcset: JSString = "srcset" + @usableFromInline static let standby: JSString = "standby" + @usableFromInline static let start: JSString = "start" + @usableFromInline static let startContainer: JSString = "startContainer" + @usableFromInline static let startMessages: JSString = "startMessages" + @usableFromInline static let startOffset: JSString = "startOffset" + @usableFromInline static let startTime: JSString = "startTime" + @usableFromInline static let state: JSString = "state" + @usableFromInline static let status: JSString = "status" + @usableFromInline static let statusText: JSString = "statusText" + @usableFromInline static let statusbar: JSString = "statusbar" + @usableFromInline static let step: JSString = "step" + @usableFromInline static let stepDown: JSString = "stepDown" + @usableFromInline static let stepMismatch: JSString = "stepMismatch" + @usableFromInline static let stepUp: JSString = "stepUp" + @usableFromInline static let stop: JSString = "stop" + @usableFromInline static let stopImmediatePropagation: JSString = "stopImmediatePropagation" + @usableFromInline static let stopPropagation: JSString = "stopPropagation" + @usableFromInline static let storageArea: JSString = "storageArea" + @usableFromInline static let stringValue: JSString = "stringValue" + @usableFromInline static let stroke: JSString = "stroke" + @usableFromInline static let strokeRect: JSString = "strokeRect" + @usableFromInline static let strokeStyle: JSString = "strokeStyle" + @usableFromInline static let strokeText: JSString = "strokeText" + @usableFromInline static let structuredClone: JSString = "structuredClone" + @usableFromInline static let submit: JSString = "submit" + @usableFromInline static let submitter: JSString = "submitter" + @usableFromInline static let substringData: JSString = "substringData" + @usableFromInline static let subtree: JSString = "subtree" + @usableFromInline static let suffixes: JSString = "suffixes" + @usableFromInline static let summary: JSString = "summary" + @usableFromInline static let supports: JSString = "supports" + @usableFromInline static let surroundContents: JSString = "surroundContents" + @usableFromInline static let systemId: JSString = "systemId" + @usableFromInline static let tBodies: JSString = "tBodies" + @usableFromInline static let tFoot: JSString = "tFoot" + @usableFromInline static let tHead: JSString = "tHead" + @usableFromInline static let tabIndex: JSString = "tabIndex" + @usableFromInline static let tagName: JSString = "tagName" + @usableFromInline static let taintEnabled: JSString = "taintEnabled" + @usableFromInline static let takeRecords: JSString = "takeRecords" + @usableFromInline static let target: JSString = "target" + @usableFromInline static let targetOrigin: JSString = "targetOrigin" + @usableFromInline static let terminate: JSString = "terminate" + @usableFromInline static let text: JSString = "text" + @usableFromInline static let textAlign: JSString = "textAlign" + @usableFromInline static let textBaseline: JSString = "textBaseline" + @usableFromInline static let textContent: JSString = "textContent" + @usableFromInline static let textLength: JSString = "textLength" + @usableFromInline static let textRendering: JSString = "textRendering" + @usableFromInline static let textTracks: JSString = "textTracks" + @usableFromInline static let throwIfAborted: JSString = "throwIfAborted" + @usableFromInline static let timeOrigin: JSString = "timeOrigin" + @usableFromInline static let timeStamp: JSString = "timeStamp" + @usableFromInline static let timeline: JSString = "timeline" + @usableFromInline static let timeout: JSString = "timeout" + @usableFromInline static let title: JSString = "title" + @usableFromInline static let toDataURL: JSString = "toDataURL" + @usableFromInline static let toFloat32Array: JSString = "toFloat32Array" + @usableFromInline static let toFloat64Array: JSString = "toFloat64Array" + @usableFromInline static let toJSON: JSString = "toJSON" + @usableFromInline static let toString: JSString = "toString" + @usableFromInline static let toggle: JSString = "toggle" + @usableFromInline static let toggleAttribute: JSString = "toggleAttribute" + @usableFromInline static let tooLong: JSString = "tooLong" + @usableFromInline static let tooShort: JSString = "tooShort" + @usableFromInline static let toolbar: JSString = "toolbar" + @usableFromInline static let top: JSString = "top" + @usableFromInline static let total: JSString = "total" + @usableFromInline static let track: JSString = "track" + @usableFromInline static let transfer: JSString = "transfer" + @usableFromInline static let transferControlToOffscreen: JSString = "transferControlToOffscreen" + @usableFromInline static let transferFromImageBitmap: JSString = "transferFromImageBitmap" + @usableFromInline static let transferToImageBitmap: JSString = "transferToImageBitmap" + @usableFromInline static let transform: JSString = "transform" + @usableFromInline static let transformPoint: JSString = "transformPoint" + @usableFromInline static let transformToDocument: JSString = "transformToDocument" + @usableFromInline static let transformToFragment: JSString = "transformToFragment" + @usableFromInline static let translate: JSString = "translate" + @usableFromInline static let translateSelf: JSString = "translateSelf" + @usableFromInline static let trueSpeed: JSString = "trueSpeed" + @usableFromInline static let type: JSString = "type" + @usableFromInline static let typeMismatch: JSString = "typeMismatch" + @usableFromInline static let types: JSString = "types" + @usableFromInline static let unregister: JSString = "unregister" + @usableFromInline static let unregisterProtocolHandler: JSString = "unregisterProtocolHandler" + @usableFromInline static let update: JSString = "update" + @usableFromInline static let updatePlaybackRate: JSString = "updatePlaybackRate" + @usableFromInline static let updateTiming: JSString = "updateTiming" + @usableFromInline static let updateViaCache: JSString = "updateViaCache" + @usableFromInline static let upgrade: JSString = "upgrade" + @usableFromInline static let upload: JSString = "upload" + @usableFromInline static let url: JSString = "url" + @usableFromInline static let useMap: JSString = "useMap" + @usableFromInline static let userAgent: JSString = "userAgent" + @usableFromInline static let username: JSString = "username" + @usableFromInline static let vAlign: JSString = "vAlign" + @usableFromInline static let vLink: JSString = "vLink" + @usableFromInline static let valid: JSString = "valid" + @usableFromInline static let validationMessage: JSString = "validationMessage" + @usableFromInline static let validity: JSString = "validity" + @usableFromInline static let value: JSString = "value" + @usableFromInline static let valueAsDate: JSString = "valueAsDate" + @usableFromInline static let valueAsNumber: JSString = "valueAsNumber" + @usableFromInline static let valueMissing: JSString = "valueMissing" + @usableFromInline static let valueType: JSString = "valueType" + @usableFromInline static let vendor: JSString = "vendor" + @usableFromInline static let vendorSub: JSString = "vendorSub" + @usableFromInline static let version: JSString = "version" + @usableFromInline static let videoHeight: JSString = "videoHeight" + @usableFromInline static let videoTracks: JSString = "videoTracks" + @usableFromInline static let videoWidth: JSString = "videoWidth" + @usableFromInline static let view: JSString = "view" + @usableFromInline static let visibilityState: JSString = "visibilityState" + @usableFromInline static let visible: JSString = "visible" + @usableFromInline static let vlinkColor: JSString = "vlinkColor" + @usableFromInline static let volume: JSString = "volume" + @usableFromInline static let vspace: JSString = "vspace" + @usableFromInline static let w: JSString = "w" + @usableFromInline static let waiting: JSString = "waiting" + @usableFromInline static let webkitMatchesSelector: JSString = "webkitMatchesSelector" + @usableFromInline static let whatToShow: JSString = "whatToShow" + @usableFromInline static let whenDefined: JSString = "whenDefined" + @usableFromInline static let which: JSString = "which" + @usableFromInline static let wholeText: JSString = "wholeText" + @usableFromInline static let width: JSString = "width" + @usableFromInline static let willReadFrequently: JSString = "willReadFrequently" + @usableFromInline static let willValidate: JSString = "willValidate" + @usableFromInline static let window: JSString = "window" + @usableFromInline static let withCredentials: JSString = "withCredentials" + @usableFromInline static let wordSpacing: JSString = "wordSpacing" + @usableFromInline static let wrap: JSString = "wrap" + @usableFromInline static let write: JSString = "write" + @usableFromInline static let writeln: JSString = "writeln" + @usableFromInline static let x: JSString = "x" + @usableFromInline static let y: JSString = "y" + @usableFromInline static let z: JSString = "z" +} diff --git a/Sources/DOMKit/WebIDL/StructuredSerializeOptions.swift b/Sources/DOMKit/WebIDL/StructuredSerializeOptions.swift new file mode 100644 index 00000000..67639f2d --- /dev/null +++ b/Sources/DOMKit/WebIDL/StructuredSerializeOptions.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class StructuredSerializeOptions: BridgedDictionary { + public convenience init(transfer: [JSObject]) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.transfer] = transfer.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _transfer = ReadWriteAttribute(jsObject: object, name: Strings.transfer) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var transfer: [JSObject] +} diff --git a/Sources/DOMKit/WebIDL/SubmitEvent.swift b/Sources/DOMKit/WebIDL/SubmitEvent.swift new file mode 100644 index 00000000..7af0c6ef --- /dev/null +++ b/Sources/DOMKit/WebIDL/SubmitEvent.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class SubmitEvent: Event { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.SubmitEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _submitter = ReadonlyAttribute(jsObject: jsObject, name: Strings.submitter) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: SubmitEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var submitter: HTMLElement? +} diff --git a/Sources/DOMKit/WebIDL/SubmitEventInit.swift b/Sources/DOMKit/WebIDL/SubmitEventInit.swift new file mode 100644 index 00000000..7913a9c4 --- /dev/null +++ b/Sources/DOMKit/WebIDL/SubmitEventInit.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class SubmitEventInit: BridgedDictionary { + public convenience init(submitter: HTMLElement?) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.submitter] = submitter.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _submitter = ReadWriteAttribute(jsObject: object, name: Strings.submitter) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var submitter: HTMLElement? +} diff --git a/Sources/DOMKit/WebIDL/Text.swift b/Sources/DOMKit/WebIDL/Text.swift index 4138c2f1..63922264 100644 --- a/Sources/DOMKit/WebIDL/Text.swift +++ b/Sources/DOMKit/WebIDL/Text.swift @@ -1,24 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public class Text: CharacterData, Slotable { - override public class var constructor: JSFunction { JSObject.global.Text.function! } +public class Text: CharacterData, Slottable { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.Text].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _wholeText = ReadonlyAttribute(jsObject: jsObject, name: "wholeText") + _wholeText = ReadonlyAttribute(jsObject: jsObject, name: Strings.wholeText) super.init(unsafelyWrapping: jsObject) } - public convenience init(data: String = "") { - self.init(unsafelyWrapping: Text.constructor.new(data.jsValue())) + @inlinable public convenience init(data: String? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [data?.jsValue ?? .undefined])) } - public func splitText(offset: UInt32) -> Text { - return jsObject.splitText!(offset.jsValue()).fromJSValue()! + @inlinable public func splitText(offset: UInt32) -> Self { + let this = jsObject + return this[Strings.splitText].function!(this: this, arguments: [offset.jsValue]).fromJSValue()! } @ReadonlyAttribute diff --git a/Sources/DOMKit/WebIDL/TextMetrics.swift b/Sources/DOMKit/WebIDL/TextMetrics.swift new file mode 100644 index 00000000..8d61be6e --- /dev/null +++ b/Sources/DOMKit/WebIDL/TextMetrics.swift @@ -0,0 +1,62 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class TextMetrics: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.TextMetrics].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _width = ReadonlyAttribute(jsObject: jsObject, name: Strings.width) + _actualBoundingBoxLeft = ReadonlyAttribute(jsObject: jsObject, name: Strings.actualBoundingBoxLeft) + _actualBoundingBoxRight = ReadonlyAttribute(jsObject: jsObject, name: Strings.actualBoundingBoxRight) + _fontBoundingBoxAscent = ReadonlyAttribute(jsObject: jsObject, name: Strings.fontBoundingBoxAscent) + _fontBoundingBoxDescent = ReadonlyAttribute(jsObject: jsObject, name: Strings.fontBoundingBoxDescent) + _actualBoundingBoxAscent = ReadonlyAttribute(jsObject: jsObject, name: Strings.actualBoundingBoxAscent) + _actualBoundingBoxDescent = ReadonlyAttribute(jsObject: jsObject, name: Strings.actualBoundingBoxDescent) + _emHeightAscent = ReadonlyAttribute(jsObject: jsObject, name: Strings.emHeightAscent) + _emHeightDescent = ReadonlyAttribute(jsObject: jsObject, name: Strings.emHeightDescent) + _hangingBaseline = ReadonlyAttribute(jsObject: jsObject, name: Strings.hangingBaseline) + _alphabeticBaseline = ReadonlyAttribute(jsObject: jsObject, name: Strings.alphabeticBaseline) + _ideographicBaseline = ReadonlyAttribute(jsObject: jsObject, name: Strings.ideographicBaseline) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var width: Double + + @ReadonlyAttribute + public var actualBoundingBoxLeft: Double + + @ReadonlyAttribute + public var actualBoundingBoxRight: Double + + @ReadonlyAttribute + public var fontBoundingBoxAscent: Double + + @ReadonlyAttribute + public var fontBoundingBoxDescent: Double + + @ReadonlyAttribute + public var actualBoundingBoxAscent: Double + + @ReadonlyAttribute + public var actualBoundingBoxDescent: Double + + @ReadonlyAttribute + public var emHeightAscent: Double + + @ReadonlyAttribute + public var emHeightDescent: Double + + @ReadonlyAttribute + public var hangingBaseline: Double + + @ReadonlyAttribute + public var alphabeticBaseline: Double + + @ReadonlyAttribute + public var ideographicBaseline: Double +} diff --git a/Sources/DOMKit/WebIDL/TextTrack.swift b/Sources/DOMKit/WebIDL/TextTrack.swift new file mode 100644 index 00000000..4de86043 --- /dev/null +++ b/Sources/DOMKit/WebIDL/TextTrack.swift @@ -0,0 +1,58 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class TextTrack: EventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.TextTrack].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _kind = ReadonlyAttribute(jsObject: jsObject, name: Strings.kind) + _label = ReadonlyAttribute(jsObject: jsObject, name: Strings.label) + _language = ReadonlyAttribute(jsObject: jsObject, name: Strings.language) + _id = ReadonlyAttribute(jsObject: jsObject, name: Strings.id) + _inBandMetadataTrackDispatchType = ReadonlyAttribute(jsObject: jsObject, name: Strings.inBandMetadataTrackDispatchType) + _mode = ReadWriteAttribute(jsObject: jsObject, name: Strings.mode) + _cues = ReadonlyAttribute(jsObject: jsObject, name: Strings.cues) + _activeCues = ReadonlyAttribute(jsObject: jsObject, name: Strings.activeCues) + _oncuechange = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.oncuechange) + super.init(unsafelyWrapping: jsObject) + } + + @ReadonlyAttribute + public var kind: TextTrackKind + + @ReadonlyAttribute + public var label: String + + @ReadonlyAttribute + public var language: String + + @ReadonlyAttribute + public var id: String + + @ReadonlyAttribute + public var inBandMetadataTrackDispatchType: String + + @ReadWriteAttribute + public var mode: TextTrackMode + + @ReadonlyAttribute + public var cues: TextTrackCueList? + + @ReadonlyAttribute + public var activeCues: TextTrackCueList? + + @inlinable public func addCue(cue: TextTrackCue) { + let this = jsObject + _ = this[Strings.addCue].function!(this: this, arguments: [cue.jsValue]) + } + + @inlinable public func removeCue(cue: TextTrackCue) { + let this = jsObject + _ = this[Strings.removeCue].function!(this: this, arguments: [cue.jsValue]) + } + + @ClosureAttribute1Optional + public var oncuechange: EventHandler +} diff --git a/Sources/DOMKit/WebIDL/TextTrackCue.swift b/Sources/DOMKit/WebIDL/TextTrackCue.swift new file mode 100644 index 00000000..583035f1 --- /dev/null +++ b/Sources/DOMKit/WebIDL/TextTrackCue.swift @@ -0,0 +1,40 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class TextTrackCue: EventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.TextTrackCue].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _track = ReadonlyAttribute(jsObject: jsObject, name: Strings.track) + _id = ReadWriteAttribute(jsObject: jsObject, name: Strings.id) + _startTime = ReadWriteAttribute(jsObject: jsObject, name: Strings.startTime) + _endTime = ReadWriteAttribute(jsObject: jsObject, name: Strings.endTime) + _pauseOnExit = ReadWriteAttribute(jsObject: jsObject, name: Strings.pauseOnExit) + _onenter = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onenter) + _onexit = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onexit) + super.init(unsafelyWrapping: jsObject) + } + + @ReadonlyAttribute + public var track: TextTrack? + + @ReadWriteAttribute + public var id: String + + @ReadWriteAttribute + public var startTime: Double + + @ReadWriteAttribute + public var endTime: Double + + @ReadWriteAttribute + public var pauseOnExit: Bool + + @ClosureAttribute1Optional + public var onenter: EventHandler + + @ClosureAttribute1Optional + public var onexit: EventHandler +} diff --git a/Sources/DOMKit/WebIDL/TextTrackCueList.swift b/Sources/DOMKit/WebIDL/TextTrackCueList.swift new file mode 100644 index 00000000..0c73392e --- /dev/null +++ b/Sources/DOMKit/WebIDL/TextTrackCueList.swift @@ -0,0 +1,27 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class TextTrackCueList: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.TextTrackCueList].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var length: UInt32 + + @inlinable public subscript(key: Int) -> TextTrackCue { + jsObject[key].fromJSValue()! + } + + @inlinable public func getCueById(id: String) -> TextTrackCue? { + let this = jsObject + return this[Strings.getCueById].function!(this: this, arguments: [id.jsValue]).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/TextTrackKind.swift b/Sources/DOMKit/WebIDL/TextTrackKind.swift new file mode 100644 index 00000000..ac618d36 --- /dev/null +++ b/Sources/DOMKit/WebIDL/TextTrackKind.swift @@ -0,0 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum TextTrackKind: JSString, JSValueCompatible { + case subtitles = "subtitles" + case captions = "captions" + case descriptions = "descriptions" + case chapters = "chapters" + case metadata = "metadata" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/TextTrackList.swift b/Sources/DOMKit/WebIDL/TextTrackList.swift new file mode 100644 index 00000000..fed8608c --- /dev/null +++ b/Sources/DOMKit/WebIDL/TextTrackList.swift @@ -0,0 +1,37 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class TextTrackList: EventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.TextTrackList].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + _onchange = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onchange) + _onaddtrack = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onaddtrack) + _onremovetrack = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onremovetrack) + super.init(unsafelyWrapping: jsObject) + } + + @ReadonlyAttribute + public var length: UInt32 + + @inlinable public subscript(key: Int) -> TextTrack { + jsObject[key].fromJSValue()! + } + + @inlinable public func getTrackById(id: String) -> TextTrack? { + let this = jsObject + return this[Strings.getTrackById].function!(this: this, arguments: [id.jsValue]).fromJSValue()! + } + + @ClosureAttribute1Optional + public var onchange: EventHandler + + @ClosureAttribute1Optional + public var onaddtrack: EventHandler + + @ClosureAttribute1Optional + public var onremovetrack: EventHandler +} diff --git a/Sources/DOMKit/WebIDL/TextTrackMode.swift b/Sources/DOMKit/WebIDL/TextTrackMode.swift new file mode 100644 index 00000000..e4ae982f --- /dev/null +++ b/Sources/DOMKit/WebIDL/TextTrackMode.swift @@ -0,0 +1,23 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum TextTrackMode: JSString, JSValueCompatible { + case disabled = "disabled" + case hidden = "hidden" + case showing = "showing" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/TimeRanges.swift b/Sources/DOMKit/WebIDL/TimeRanges.swift new file mode 100644 index 00000000..08e6948f --- /dev/null +++ b/Sources/DOMKit/WebIDL/TimeRanges.swift @@ -0,0 +1,28 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class TimeRanges: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.TimeRanges].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var length: UInt32 + + @inlinable public func start(index: UInt32) -> Double { + let this = jsObject + return this[Strings.start].function!(this: this, arguments: [index.jsValue]).fromJSValue()! + } + + @inlinable public func end(index: UInt32) -> Double { + let this = jsObject + return this[Strings.end].function!(this: this, arguments: [index.jsValue]).fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/TimelinePhase.swift b/Sources/DOMKit/WebIDL/TimelinePhase.swift new file mode 100644 index 00000000..6c79111d --- /dev/null +++ b/Sources/DOMKit/WebIDL/TimelinePhase.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum TimelinePhase: JSString, JSValueCompatible { + case inactive = "inactive" + case before = "before" + case active = "active" + case after = "after" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/TimerHandler.swift b/Sources/DOMKit/WebIDL/TimerHandler.swift new file mode 100644 index 00000000..c4a63ae6 --- /dev/null +++ b/Sources/DOMKit/WebIDL/TimerHandler.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_TimerHandler: ConvertibleToJSValue {} +extension JSFunction: Any_TimerHandler {} +extension String: Any_TimerHandler {} + +public enum TimerHandler: JSValueCompatible, Any_TimerHandler { + case jsFunction(JSFunction) + case string(String) + + var jsFunction: JSFunction? { + switch self { + case let .jsFunction(jsFunction): return jsFunction + default: return nil + } + } + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let jsFunction: JSFunction = value.fromJSValue() { + return .jsFunction(jsFunction) + } + if let string: String = value.fromJSValue() { + return .string(string) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .jsFunction(jsFunction): + return jsFunction.jsValue + case let .string(string): + return string.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/TrackEvent.swift b/Sources/DOMKit/WebIDL/TrackEvent.swift new file mode 100644 index 00000000..9312c8ab --- /dev/null +++ b/Sources/DOMKit/WebIDL/TrackEvent.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class TrackEvent: Event { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.TrackEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _track = ReadonlyAttribute(jsObject: jsObject, name: Strings.track) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: TrackEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var track: AudioTrack_or_TextTrack_or_VideoTrack? +} diff --git a/Sources/DOMKit/WebIDL/TrackEventInit.swift b/Sources/DOMKit/WebIDL/TrackEventInit.swift new file mode 100644 index 00000000..a9485dd4 --- /dev/null +++ b/Sources/DOMKit/WebIDL/TrackEventInit.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class TrackEventInit: BridgedDictionary { + public convenience init(track: AudioTrack_or_TextTrack_or_VideoTrack?) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.track] = track.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _track = ReadWriteAttribute(jsObject: object, name: Strings.track) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var track: AudioTrack_or_TextTrack_or_VideoTrack? +} diff --git a/Sources/DOMKit/WebIDL/TreeWalker.swift b/Sources/DOMKit/WebIDL/TreeWalker.swift index 6d0fd816..541e1477 100644 --- a/Sources/DOMKit/WebIDL/TreeWalker.swift +++ b/Sources/DOMKit/WebIDL/TreeWalker.swift @@ -1,19 +1,17 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class TreeWalker: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.TreeWalker.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.TreeWalker].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _root = ReadonlyAttribute(jsObject: jsObject, name: "root") - _whatToShow = ReadonlyAttribute(jsObject: jsObject, name: "whatToShow") - _currentNode = ReadWriteAttribute(jsObject: jsObject, name: "currentNode") + _root = ReadonlyAttribute(jsObject: jsObject, name: Strings.root) + _whatToShow = ReadonlyAttribute(jsObject: jsObject, name: Strings.whatToShow) + _currentNode = ReadWriteAttribute(jsObject: jsObject, name: Strings.currentNode) self.jsObject = jsObject } @@ -23,38 +21,43 @@ public class TreeWalker: JSBridgedClass { @ReadonlyAttribute public var whatToShow: UInt32 - public var filter: NodeFilter? { - return jsObject.filter.fromJSValue()! as AnyNodeFilter? - } + // XXX: member 'filter' is ignored @ReadWriteAttribute public var currentNode: Node - public func parentNode() -> Node? { - return jsObject.parentNode!().fromJSValue()! + @inlinable public func parentNode() -> Node? { + let this = jsObject + return this[Strings.parentNode].function!(this: this, arguments: []).fromJSValue()! } - public func firstChild() -> Node? { - return jsObject.firstChild!().fromJSValue()! + @inlinable public func firstChild() -> Node? { + let this = jsObject + return this[Strings.firstChild].function!(this: this, arguments: []).fromJSValue()! } - public func lastChild() -> Node? { - return jsObject.lastChild!().fromJSValue()! + @inlinable public func lastChild() -> Node? { + let this = jsObject + return this[Strings.lastChild].function!(this: this, arguments: []).fromJSValue()! } - public func previousSibling() -> Node? { - return jsObject.previousSibling!().fromJSValue()! + @inlinable public func previousSibling() -> Node? { + let this = jsObject + return this[Strings.previousSibling].function!(this: this, arguments: []).fromJSValue()! } - public func nextSibling() -> Node? { - return jsObject.nextSibling!().fromJSValue()! + @inlinable public func nextSibling() -> Node? { + let this = jsObject + return this[Strings.nextSibling].function!(this: this, arguments: []).fromJSValue()! } - public func previousNode() -> Node? { - return jsObject.previousNode!().fromJSValue()! + @inlinable public func previousNode() -> Node? { + let this = jsObject + return this[Strings.previousNode].function!(this: this, arguments: []).fromJSValue()! } - public func nextNode() -> Node? { - return jsObject.nextNode!().fromJSValue()! + @inlinable public func nextNode() -> Node? { + let this = jsObject + return this[Strings.nextNode].function!(this: this, arguments: []).fromJSValue()! } } diff --git a/Sources/DOMKit/WebIDL/Typedefs.swift b/Sources/DOMKit/WebIDL/Typedefs.swift new file mode 100644 index 00000000..a44e06f7 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Typedefs.swift @@ -0,0 +1,24 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public typealias CanvasFilterInput = [String: JSValue] + +public typealias EventHandler = EventHandlerNonNull? +public typealias OnErrorEventHandler = OnErrorEventHandlerNonNull? +public typealias OnBeforeUnloadEventHandler = OnBeforeUnloadEventHandlerNonNull? + +public typealias DOMHighResTimeStamp = Double +public typealias EpochTimeStamp = UInt64 + +public typealias DOMTimeStamp = UInt64 + +public typealias MutationCallback = ([MutationRecord], MutationObserver) -> Void +public typealias BlobCallback = (Blob?) -> Void +public typealias FunctionStringCallback = (String) -> Void +public typealias EventHandlerNonNull = (Event) -> JSValue +public typealias OnErrorEventHandlerNonNull = (Event_or_String, String, UInt32, UInt32, JSValue) -> JSValue +public typealias OnBeforeUnloadEventHandlerNonNull = (Event) -> String? +public typealias FrameRequestCallback = (DOMHighResTimeStamp) -> Void +public typealias VoidFunction = () -> Void diff --git a/Sources/DOMKit/WebIDL/UIEvent.swift b/Sources/DOMKit/WebIDL/UIEvent.swift new file mode 100644 index 00000000..7cc090b2 --- /dev/null +++ b/Sources/DOMKit/WebIDL/UIEvent.swift @@ -0,0 +1,33 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class UIEvent: Event { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.UIEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _view = ReadonlyAttribute(jsObject: jsObject, name: Strings.view) + _detail = ReadonlyAttribute(jsObject: jsObject, name: Strings.detail) + _which = ReadonlyAttribute(jsObject: jsObject, name: Strings.which) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: UIEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + @ReadonlyAttribute + public var view: Window? + + @ReadonlyAttribute + public var detail: Int32 + + @inlinable public func initUIEvent(typeArg: String, bubblesArg: Bool? = nil, cancelableArg: Bool? = nil, viewArg: Window? = nil, detailArg: Int32? = nil) { + let this = jsObject + _ = this[Strings.initUIEvent].function!(this: this, arguments: [typeArg.jsValue, bubblesArg?.jsValue ?? .undefined, cancelableArg?.jsValue ?? .undefined, viewArg?.jsValue ?? .undefined, detailArg?.jsValue ?? .undefined]) + } + + @ReadonlyAttribute + public var which: UInt32 +} diff --git a/Sources/DOMKit/WebIDL/UIEventInit.swift b/Sources/DOMKit/WebIDL/UIEventInit.swift new file mode 100644 index 00000000..f9b8d8fb --- /dev/null +++ b/Sources/DOMKit/WebIDL/UIEventInit.swift @@ -0,0 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class UIEventInit: BridgedDictionary { + public convenience init(view: Window?, detail: Int32, which: UInt32) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.view] = view.jsValue + object[Strings.detail] = detail.jsValue + object[Strings.which] = which.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _view = ReadWriteAttribute(jsObject: object, name: Strings.view) + _detail = ReadWriteAttribute(jsObject: object, name: Strings.detail) + _which = ReadWriteAttribute(jsObject: object, name: Strings.which) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var view: Window? + + @ReadWriteAttribute + public var detail: Int32 + + @ReadWriteAttribute + public var which: UInt32 +} diff --git a/Sources/DOMKit/WebIDL/URL.swift b/Sources/DOMKit/WebIDL/URL.swift index c47a8ac8..989d2811 100644 --- a/Sources/DOMKit/WebIDL/URL.swift +++ b/Sources/DOMKit/WebIDL/URL.swift @@ -1,16 +1,81 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class URL: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.URL.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.URL].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { + _href = ReadWriteAttribute(jsObject: jsObject, name: Strings.href) + _origin = ReadonlyAttribute(jsObject: jsObject, name: Strings.origin) + _protocol = ReadWriteAttribute(jsObject: jsObject, name: Strings.protocol) + _username = ReadWriteAttribute(jsObject: jsObject, name: Strings.username) + _password = ReadWriteAttribute(jsObject: jsObject, name: Strings.password) + _host = ReadWriteAttribute(jsObject: jsObject, name: Strings.host) + _hostname = ReadWriteAttribute(jsObject: jsObject, name: Strings.hostname) + _port = ReadWriteAttribute(jsObject: jsObject, name: Strings.port) + _pathname = ReadWriteAttribute(jsObject: jsObject, name: Strings.pathname) + _search = ReadWriteAttribute(jsObject: jsObject, name: Strings.search) + _searchParams = ReadonlyAttribute(jsObject: jsObject, name: Strings.searchParams) + _hash = ReadWriteAttribute(jsObject: jsObject, name: Strings.hash) self.jsObject = jsObject } + + @inlinable public static func createObjectURL(obj: Blob_or_MediaSource) -> String { + let this = constructor + return this[Strings.createObjectURL].function!(this: this, arguments: [obj.jsValue]).fromJSValue()! + } + + @inlinable public static func revokeObjectURL(url: String) { + let this = constructor + _ = this[Strings.revokeObjectURL].function!(this: this, arguments: [url.jsValue]) + } + + @inlinable public convenience init(url: String, base: String? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [url.jsValue, base?.jsValue ?? .undefined])) + } + + @ReadWriteAttribute + public var href: String + + @ReadonlyAttribute + public var origin: String + + @ReadWriteAttribute + public var `protocol`: String + + @ReadWriteAttribute + public var username: String + + @ReadWriteAttribute + public var password: String + + @ReadWriteAttribute + public var host: String + + @ReadWriteAttribute + public var hostname: String + + @ReadWriteAttribute + public var port: String + + @ReadWriteAttribute + public var pathname: String + + @ReadWriteAttribute + public var search: String + + @ReadonlyAttribute + public var searchParams: URLSearchParams + + @ReadWriteAttribute + public var hash: String + + @inlinable public func toJSON() -> String { + let this = jsObject + return this[Strings.toJSON].function!(this: this, arguments: []).fromJSValue()! + } } diff --git a/Sources/DOMKit/WebIDL/URLSearchParams.swift b/Sources/DOMKit/WebIDL/URLSearchParams.swift new file mode 100644 index 00000000..7d151f74 --- /dev/null +++ b/Sources/DOMKit/WebIDL/URLSearchParams.swift @@ -0,0 +1,62 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class URLSearchParams: JSBridgedClass, Sequence { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.URLSearchParams].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + @inlinable public convenience init(init: String_or_record_String_to_String_or_seq_of_seq_of_String? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [`init`?.jsValue ?? .undefined])) + } + + @inlinable public func append(name: String, value: String) { + let this = jsObject + _ = this[Strings.append].function!(this: this, arguments: [name.jsValue, value.jsValue]) + } + + @inlinable public func delete(name: String) { + let this = jsObject + _ = this[Strings.delete].function!(this: this, arguments: [name.jsValue]) + } + + @inlinable public func get(name: String) -> String? { + let this = jsObject + return this[Strings.get].function!(this: this, arguments: [name.jsValue]).fromJSValue()! + } + + @inlinable public func getAll(name: String) -> [String] { + let this = jsObject + return this[Strings.getAll].function!(this: this, arguments: [name.jsValue]).fromJSValue()! + } + + @inlinable public func has(name: String) -> Bool { + let this = jsObject + return this[Strings.has].function!(this: this, arguments: [name.jsValue]).fromJSValue()! + } + + @inlinable public func set(name: String, value: String) { + let this = jsObject + _ = this[Strings.set].function!(this: this, arguments: [name.jsValue, value.jsValue]) + } + + @inlinable public func sort() { + let this = jsObject + _ = this[Strings.sort].function!(this: this, arguments: []) + } + + public typealias Element = String + public func makeIterator() -> ValueIterableIterator { + ValueIterableIterator(sequence: self) + } + + @inlinable public var description: String { + jsObject[Strings.toString]!().fromJSValue()! + } +} diff --git a/Sources/DOMKit/WebIDL/ValidityState.swift b/Sources/DOMKit/WebIDL/ValidityState.swift index 33d98c2c..5b403383 100644 --- a/Sources/DOMKit/WebIDL/ValidityState.swift +++ b/Sources/DOMKit/WebIDL/ValidityState.swift @@ -1,27 +1,25 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class ValidityState: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.ValidityState.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.ValidityState].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _valueMissing = ReadonlyAttribute(jsObject: jsObject, name: "valueMissing") - _typeMismatch = ReadonlyAttribute(jsObject: jsObject, name: "typeMismatch") - _patternMismatch = ReadonlyAttribute(jsObject: jsObject, name: "patternMismatch") - _tooLong = ReadonlyAttribute(jsObject: jsObject, name: "tooLong") - _tooShort = ReadonlyAttribute(jsObject: jsObject, name: "tooShort") - _rangeUnderflow = ReadonlyAttribute(jsObject: jsObject, name: "rangeUnderflow") - _rangeOverflow = ReadonlyAttribute(jsObject: jsObject, name: "rangeOverflow") - _stepMismatch = ReadonlyAttribute(jsObject: jsObject, name: "stepMismatch") - _badInput = ReadonlyAttribute(jsObject: jsObject, name: "badInput") - _customError = ReadonlyAttribute(jsObject: jsObject, name: "customError") - _valid = ReadonlyAttribute(jsObject: jsObject, name: "valid") + _valueMissing = ReadonlyAttribute(jsObject: jsObject, name: Strings.valueMissing) + _typeMismatch = ReadonlyAttribute(jsObject: jsObject, name: Strings.typeMismatch) + _patternMismatch = ReadonlyAttribute(jsObject: jsObject, name: Strings.patternMismatch) + _tooLong = ReadonlyAttribute(jsObject: jsObject, name: Strings.tooLong) + _tooShort = ReadonlyAttribute(jsObject: jsObject, name: Strings.tooShort) + _rangeUnderflow = ReadonlyAttribute(jsObject: jsObject, name: Strings.rangeUnderflow) + _rangeOverflow = ReadonlyAttribute(jsObject: jsObject, name: Strings.rangeOverflow) + _stepMismatch = ReadonlyAttribute(jsObject: jsObject, name: Strings.stepMismatch) + _badInput = ReadonlyAttribute(jsObject: jsObject, name: Strings.badInput) + _customError = ReadonlyAttribute(jsObject: jsObject, name: Strings.customError) + _valid = ReadonlyAttribute(jsObject: jsObject, name: Strings.valid) self.jsObject = jsObject } diff --git a/Sources/DOMKit/WebIDL/ValidityStateFlags.swift b/Sources/DOMKit/WebIDL/ValidityStateFlags.swift index 8b507bc0..4686cec3 100644 --- a/Sources/DOMKit/WebIDL/ValidityStateFlags.swift +++ b/Sources/DOMKit/WebIDL/ValidityStateFlags.swift @@ -1,39 +1,65 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public struct ValidityStateFlags: ExpressibleByDictionaryLiteral, JSBridgedType { - public enum Key: String, Hashable { - case valueMissing, typeMismatch, patternMismatch, tooLong, tooShort, rangeUnderflow, rangeOverflow, stepMismatch, badInput, customError +public class ValidityStateFlags: BridgedDictionary { + public convenience init(valueMissing: Bool, typeMismatch: Bool, patternMismatch: Bool, tooLong: Bool, tooShort: Bool, rangeUnderflow: Bool, rangeOverflow: Bool, stepMismatch: Bool, badInput: Bool, customError: Bool) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.valueMissing] = valueMissing.jsValue + object[Strings.typeMismatch] = typeMismatch.jsValue + object[Strings.patternMismatch] = patternMismatch.jsValue + object[Strings.tooLong] = tooLong.jsValue + object[Strings.tooShort] = tooShort.jsValue + object[Strings.rangeUnderflow] = rangeUnderflow.jsValue + object[Strings.rangeOverflow] = rangeOverflow.jsValue + object[Strings.stepMismatch] = stepMismatch.jsValue + object[Strings.badInput] = badInput.jsValue + object[Strings.customError] = customError.jsValue + self.init(unsafelyWrapping: object) } - private let dictionary: [String: JSValue] - - public init(uniqueKeysWithValues elements: [(Key, ConvertibleToJSValue)]) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) + public required init(unsafelyWrapping object: JSObject) { + _valueMissing = ReadWriteAttribute(jsObject: object, name: Strings.valueMissing) + _typeMismatch = ReadWriteAttribute(jsObject: object, name: Strings.typeMismatch) + _patternMismatch = ReadWriteAttribute(jsObject: object, name: Strings.patternMismatch) + _tooLong = ReadWriteAttribute(jsObject: object, name: Strings.tooLong) + _tooShort = ReadWriteAttribute(jsObject: object, name: Strings.tooShort) + _rangeUnderflow = ReadWriteAttribute(jsObject: object, name: Strings.rangeUnderflow) + _rangeOverflow = ReadWriteAttribute(jsObject: object, name: Strings.rangeOverflow) + _stepMismatch = ReadWriteAttribute(jsObject: object, name: Strings.stepMismatch) + _badInput = ReadWriteAttribute(jsObject: object, name: Strings.badInput) + _customError = ReadWriteAttribute(jsObject: object, name: Strings.customError) + super.init(unsafelyWrapping: object) } - public init(dictionaryLiteral elements: (Key, ConvertibleToJSValue)...) { - dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1.jsValue()) }) - } + @ReadWriteAttribute + public var valueMissing: Bool - subscript(_ key: Key) -> JSValue? { - dictionary[key.rawValue] - } + @ReadWriteAttribute + public var typeMismatch: Bool - public init?(from value: JSValue) { - if let dictionary: [String: JSValue] = value.fromJSValue() { - self.dictionary = dictionary - } - return nil - } + @ReadWriteAttribute + public var patternMismatch: Bool - public var value: JSValue { jsValue() } + @ReadWriteAttribute + public var tooLong: Bool - public func jsValue() -> JSValue { - return dictionary.jsValue() - } + @ReadWriteAttribute + public var tooShort: Bool + + @ReadWriteAttribute + public var rangeUnderflow: Bool + + @ReadWriteAttribute + public var rangeOverflow: Bool + + @ReadWriteAttribute + public var stepMismatch: Bool + + @ReadWriteAttribute + public var badInput: Bool + + @ReadWriteAttribute + public var customError: Bool } diff --git a/Sources/DOMKit/WebIDL/VideoTrack.swift b/Sources/DOMKit/WebIDL/VideoTrack.swift new file mode 100644 index 00000000..5177c9b5 --- /dev/null +++ b/Sources/DOMKit/WebIDL/VideoTrack.swift @@ -0,0 +1,34 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class VideoTrack: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.VideoTrack].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + _id = ReadonlyAttribute(jsObject: jsObject, name: Strings.id) + _kind = ReadonlyAttribute(jsObject: jsObject, name: Strings.kind) + _label = ReadonlyAttribute(jsObject: jsObject, name: Strings.label) + _language = ReadonlyAttribute(jsObject: jsObject, name: Strings.language) + _selected = ReadWriteAttribute(jsObject: jsObject, name: Strings.selected) + self.jsObject = jsObject + } + + @ReadonlyAttribute + public var id: String + + @ReadonlyAttribute + public var kind: String + + @ReadonlyAttribute + public var label: String + + @ReadonlyAttribute + public var language: String + + @ReadWriteAttribute + public var selected: Bool +} diff --git a/Sources/DOMKit/WebIDL/VideoTrackList.swift b/Sources/DOMKit/WebIDL/VideoTrackList.swift new file mode 100644 index 00000000..99ca81ae --- /dev/null +++ b/Sources/DOMKit/WebIDL/VideoTrackList.swift @@ -0,0 +1,41 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class VideoTrackList: EventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.VideoTrackList].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + _selectedIndex = ReadonlyAttribute(jsObject: jsObject, name: Strings.selectedIndex) + _onchange = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onchange) + _onaddtrack = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onaddtrack) + _onremovetrack = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onremovetrack) + super.init(unsafelyWrapping: jsObject) + } + + @ReadonlyAttribute + public var length: UInt32 + + @inlinable public subscript(key: Int) -> VideoTrack { + jsObject[key].fromJSValue()! + } + + @inlinable public func getTrackById(id: String) -> VideoTrack? { + let this = jsObject + return this[Strings.getTrackById].function!(this: this, arguments: [id.jsValue]).fromJSValue()! + } + + @ReadonlyAttribute + public var selectedIndex: Int32 + + @ClosureAttribute1Optional + public var onchange: EventHandler + + @ClosureAttribute1Optional + public var onaddtrack: EventHandler + + @ClosureAttribute1Optional + public var onremovetrack: EventHandler +} diff --git a/Sources/DOMKit/WebIDL/WheelEvent.swift b/Sources/DOMKit/WebIDL/WheelEvent.swift new file mode 100644 index 00000000..c43417b3 --- /dev/null +++ b/Sources/DOMKit/WebIDL/WheelEvent.swift @@ -0,0 +1,38 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class WheelEvent: MouseEvent { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.WheelEvent].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _deltaX = ReadonlyAttribute(jsObject: jsObject, name: Strings.deltaX) + _deltaY = ReadonlyAttribute(jsObject: jsObject, name: Strings.deltaY) + _deltaZ = ReadonlyAttribute(jsObject: jsObject, name: Strings.deltaZ) + _deltaMode = ReadonlyAttribute(jsObject: jsObject, name: Strings.deltaMode) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(type: String, eventInitDict: WheelEventInit? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [type.jsValue, eventInitDict?.jsValue ?? .undefined])) + } + + public static let DOM_DELTA_PIXEL: UInt32 = 0x00 + + public static let DOM_DELTA_LINE: UInt32 = 0x01 + + public static let DOM_DELTA_PAGE: UInt32 = 0x02 + + @ReadonlyAttribute + public var deltaX: Double + + @ReadonlyAttribute + public var deltaY: Double + + @ReadonlyAttribute + public var deltaZ: Double + + @ReadonlyAttribute + public var deltaMode: UInt32 +} diff --git a/Sources/DOMKit/WebIDL/WheelEventInit.swift b/Sources/DOMKit/WebIDL/WheelEventInit.swift new file mode 100644 index 00000000..04433e65 --- /dev/null +++ b/Sources/DOMKit/WebIDL/WheelEventInit.swift @@ -0,0 +1,35 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class WheelEventInit: BridgedDictionary { + public convenience init(deltaX: Double, deltaY: Double, deltaZ: Double, deltaMode: UInt32) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.deltaX] = deltaX.jsValue + object[Strings.deltaY] = deltaY.jsValue + object[Strings.deltaZ] = deltaZ.jsValue + object[Strings.deltaMode] = deltaMode.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _deltaX = ReadWriteAttribute(jsObject: object, name: Strings.deltaX) + _deltaY = ReadWriteAttribute(jsObject: object, name: Strings.deltaY) + _deltaZ = ReadWriteAttribute(jsObject: object, name: Strings.deltaZ) + _deltaMode = ReadWriteAttribute(jsObject: object, name: Strings.deltaMode) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var deltaX: Double + + @ReadWriteAttribute + public var deltaY: Double + + @ReadWriteAttribute + public var deltaZ: Double + + @ReadWriteAttribute + public var deltaMode: UInt32 +} diff --git a/Sources/DOMKit/WebIDL/Window.swift b/Sources/DOMKit/WebIDL/Window.swift index dc32ce32..1588fbb8 100644 --- a/Sources/DOMKit/WebIDL/Window.swift +++ b/Sources/DOMKit/WebIDL/Window.swift @@ -1,20 +1,190 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit -public class Window: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.Window.function! } - - public let jsObject: JSObject +public class Window: EventTarget, GlobalEventHandlers, WindowEventHandlers, WindowOrWorkerGlobalScope, AnimationFrameProvider, WindowSessionStorage, WindowLocalStorage { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.Window].function! } public required init(unsafelyWrapping jsObject: JSObject) { - _event = ReadonlyAttribute(jsObject: jsObject, name: "event") - self.jsObject = jsObject + _event = ReadonlyAttribute(jsObject: jsObject, name: Strings.event) + _window = ReadonlyAttribute(jsObject: jsObject, name: Strings.window) + _self = ReadonlyAttribute(jsObject: jsObject, name: Strings._self) + _document = ReadonlyAttribute(jsObject: jsObject, name: Strings.document) + _name = ReadWriteAttribute(jsObject: jsObject, name: Strings.name) + _location = ReadonlyAttribute(jsObject: jsObject, name: Strings.location) + _history = ReadonlyAttribute(jsObject: jsObject, name: Strings.history) + _customElements = ReadonlyAttribute(jsObject: jsObject, name: Strings.customElements) + _locationbar = ReadonlyAttribute(jsObject: jsObject, name: Strings.locationbar) + _menubar = ReadonlyAttribute(jsObject: jsObject, name: Strings.menubar) + _personalbar = ReadonlyAttribute(jsObject: jsObject, name: Strings.personalbar) + _scrollbars = ReadonlyAttribute(jsObject: jsObject, name: Strings.scrollbars) + _statusbar = ReadonlyAttribute(jsObject: jsObject, name: Strings.statusbar) + _toolbar = ReadonlyAttribute(jsObject: jsObject, name: Strings.toolbar) + _status = ReadWriteAttribute(jsObject: jsObject, name: Strings.status) + _closed = ReadonlyAttribute(jsObject: jsObject, name: Strings.closed) + _frames = ReadonlyAttribute(jsObject: jsObject, name: Strings.frames) + _length = ReadonlyAttribute(jsObject: jsObject, name: Strings.length) + _top = ReadonlyAttribute(jsObject: jsObject, name: Strings.top) + _opener = ReadWriteAttribute(jsObject: jsObject, name: Strings.opener) + _parent = ReadonlyAttribute(jsObject: jsObject, name: Strings.parent) + _frameElement = ReadonlyAttribute(jsObject: jsObject, name: Strings.frameElement) + _navigator = ReadonlyAttribute(jsObject: jsObject, name: Strings.navigator) + _clientInformation = ReadonlyAttribute(jsObject: jsObject, name: Strings.clientInformation) + _originAgentCluster = ReadonlyAttribute(jsObject: jsObject, name: Strings.originAgentCluster) + _external = ReadonlyAttribute(jsObject: jsObject, name: Strings.external) + super.init(unsafelyWrapping: jsObject) + } + + @ReadonlyAttribute + public var event: Event? + + @ReadonlyAttribute + public var window: WindowProxy + + @ReadonlyAttribute + public var `self`: WindowProxy + + @ReadonlyAttribute + public var document: Document + + @ReadWriteAttribute + public var name: String + + @ReadonlyAttribute + public var location: Location + + @ReadonlyAttribute + public var history: History + + @ReadonlyAttribute + public var customElements: CustomElementRegistry + + @ReadonlyAttribute + public var locationbar: BarProp + + @ReadonlyAttribute + public var menubar: BarProp + + @ReadonlyAttribute + public var personalbar: BarProp + + @ReadonlyAttribute + public var scrollbars: BarProp + + @ReadonlyAttribute + public var statusbar: BarProp + + @ReadonlyAttribute + public var toolbar: BarProp + + @ReadWriteAttribute + public var status: String + + @inlinable public func close() { + let this = jsObject + _ = this[Strings.close].function!(this: this, arguments: []) + } + + @ReadonlyAttribute + public var closed: Bool + + @inlinable public func stop() { + let this = jsObject + _ = this[Strings.stop].function!(this: this, arguments: []) + } + + @inlinable public func focus() { + let this = jsObject + _ = this[Strings.focus].function!(this: this, arguments: []) + } + + @inlinable public func blur() { + let this = jsObject + _ = this[Strings.blur].function!(this: this, arguments: []) + } + + @ReadonlyAttribute + public var frames: WindowProxy + + @ReadonlyAttribute + public var length: UInt32 + + @ReadonlyAttribute + public var top: WindowProxy? + + @ReadWriteAttribute + public var opener: JSValue + + @ReadonlyAttribute + public var parent: WindowProxy? + + @ReadonlyAttribute + public var frameElement: Element? + + @inlinable public func open(url: String? = nil, target: String? = nil, features: String? = nil) -> WindowProxy? { + let this = jsObject + return this[Strings.open].function!(this: this, arguments: [url?.jsValue ?? .undefined, target?.jsValue ?? .undefined, features?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public subscript(key: String) -> JSObject { + jsObject[key].fromJSValue()! + } + + @ReadonlyAttribute + public var navigator: Navigator + + @ReadonlyAttribute + public var clientInformation: Navigator + + @ReadonlyAttribute + public var originAgentCluster: Bool + + @inlinable public func alert() { + let this = jsObject + _ = this[Strings.alert].function!(this: this, arguments: []) + } + + @inlinable public func alert(message: String) { + let this = jsObject + _ = this[Strings.alert].function!(this: this, arguments: [message.jsValue]) + } + + @inlinable public func confirm(message: String? = nil) -> Bool { + let this = jsObject + return this[Strings.confirm].function!(this: this, arguments: [message?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func prompt(message: String? = nil, default: String? = nil) -> String? { + let this = jsObject + return this[Strings.prompt].function!(this: this, arguments: [message?.jsValue ?? .undefined, `default`?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable public func print() { + let this = jsObject + _ = this[Strings.print].function!(this: this, arguments: []) + } + + @inlinable public func postMessage(message: JSValue, targetOrigin: String, transfer: [JSObject]? = nil) { + let this = jsObject + _ = this[Strings.postMessage].function!(this: this, arguments: [message.jsValue, targetOrigin.jsValue, transfer?.jsValue ?? .undefined]) + } + + @inlinable public func postMessage(message: JSValue, options: WindowPostMessageOptions? = nil) { + let this = jsObject + _ = this[Strings.postMessage].function!(this: this, arguments: [message.jsValue, options?.jsValue ?? .undefined]) + } + + @inlinable public func captureEvents() { + let this = jsObject + _ = this[Strings.captureEvents].function!(this: this, arguments: []) + } + + @inlinable public func releaseEvents() { + let this = jsObject + _ = this[Strings.releaseEvents].function!(this: this, arguments: []) } @ReadonlyAttribute - public var event: JSValue + public var external: External } diff --git a/Sources/DOMKit/WebIDL/WindowEventHandlers.swift b/Sources/DOMKit/WebIDL/WindowEventHandlers.swift index 3bc1c6ed..53bf2dc3 100644 --- a/Sources/DOMKit/WebIDL/WindowEventHandlers.swift +++ b/Sources/DOMKit/WebIDL/WindowEventHandlers.swift @@ -1,298 +1,87 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public protocol WindowEventHandlers: JSBridgedClass {} - public extension WindowEventHandlers { - var onafterprint: EventHandler { - get { - guard let function = jsObject.onafterprint.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onafterprint = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onafterprint = .null - } - } + @inlinable var onafterprint: EventHandler { + get { ClosureAttribute1Optional[Strings.onafterprint, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onafterprint, in: jsObject] = newValue } } - var onbeforeprint: EventHandler { - get { - guard let function = jsObject.onbeforeprint.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onbeforeprint = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onbeforeprint = .null - } - } + @inlinable var onbeforeprint: EventHandler { + get { ClosureAttribute1Optional[Strings.onbeforeprint, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onbeforeprint, in: jsObject] = newValue } } - var onbeforeunload: OnBeforeUnloadEventHandler { - get { - guard let function = jsObject.onbeforeunload.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onbeforeunload = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onbeforeunload = .null - } - } + @inlinable var onbeforeunload: OnBeforeUnloadEventHandler { + get { ClosureAttribute1Optional[Strings.onbeforeunload, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onbeforeunload, in: jsObject] = newValue } } - var onhashchange: EventHandler { - get { - guard let function = jsObject.onhashchange.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onhashchange = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onhashchange = .null - } - } + @inlinable var onhashchange: EventHandler { + get { ClosureAttribute1Optional[Strings.onhashchange, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onhashchange, in: jsObject] = newValue } } - var onlanguagechange: EventHandler { - get { - guard let function = jsObject.onlanguagechange.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onlanguagechange = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onlanguagechange = .null - } - } + @inlinable var onlanguagechange: EventHandler { + get { ClosureAttribute1Optional[Strings.onlanguagechange, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onlanguagechange, in: jsObject] = newValue } } - var onmessage: EventHandler { - get { - guard let function = jsObject.onmessage.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onmessage = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onmessage = .null - } - } + @inlinable var onmessage: EventHandler { + get { ClosureAttribute1Optional[Strings.onmessage, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onmessage, in: jsObject] = newValue } } - var onmessageerror: EventHandler { - get { - guard let function = jsObject.onmessageerror.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onmessageerror = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onmessageerror = .null - } - } + @inlinable var onmessageerror: EventHandler { + get { ClosureAttribute1Optional[Strings.onmessageerror, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onmessageerror, in: jsObject] = newValue } } - var onoffline: EventHandler { - get { - guard let function = jsObject.onoffline.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onoffline = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onoffline = .null - } - } + @inlinable var onoffline: EventHandler { + get { ClosureAttribute1Optional[Strings.onoffline, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onoffline, in: jsObject] = newValue } } - var ononline: EventHandler { - get { - guard let function = jsObject.ononline.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.ononline = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.ononline = .null - } - } + @inlinable var ononline: EventHandler { + get { ClosureAttribute1Optional[Strings.ononline, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.ononline, in: jsObject] = newValue } } - var onpagehide: EventHandler { - get { - guard let function = jsObject.onpagehide.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onpagehide = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onpagehide = .null - } - } + @inlinable var onpagehide: EventHandler { + get { ClosureAttribute1Optional[Strings.onpagehide, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onpagehide, in: jsObject] = newValue } } - var onpageshow: EventHandler { - get { - guard let function = jsObject.onpageshow.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onpageshow = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onpageshow = .null - } - } + @inlinable var onpageshow: EventHandler { + get { ClosureAttribute1Optional[Strings.onpageshow, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onpageshow, in: jsObject] = newValue } } - var onpopstate: EventHandler { - get { - guard let function = jsObject.onpopstate.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onpopstate = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onpopstate = .null - } - } + @inlinable var onpopstate: EventHandler { + get { ClosureAttribute1Optional[Strings.onpopstate, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onpopstate, in: jsObject] = newValue } } - var onrejectionhandled: EventHandler { - get { - guard let function = jsObject.onrejectionhandled.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onrejectionhandled = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onrejectionhandled = .null - } - } + @inlinable var onrejectionhandled: EventHandler { + get { ClosureAttribute1Optional[Strings.onrejectionhandled, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onrejectionhandled, in: jsObject] = newValue } } - var onstorage: EventHandler { - get { - guard let function = jsObject.onstorage.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onstorage = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onstorage = .null - } - } + @inlinable var onstorage: EventHandler { + get { ClosureAttribute1Optional[Strings.onstorage, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onstorage, in: jsObject] = newValue } } - var onunhandledrejection: EventHandler { - get { - guard let function = jsObject.onunhandledrejection.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onunhandledrejection = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onunhandledrejection = .null - } - } + @inlinable var onunhandledrejection: EventHandler { + get { ClosureAttribute1Optional[Strings.onunhandledrejection, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onunhandledrejection, in: jsObject] = newValue } } - var onunload: EventHandler { - get { - guard let function = jsObject.onunload.function else { - return nil - } - return { arg0 in function(arg0).fromJSValue()! } - } - set { - if let newValue = newValue { - jsObject.onunload = JSClosure { arguments in - newValue(arguments[0].fromJSValue()!).jsValue() - }.jsValue() - } else { - jsObject.onunload = .null - } - } + @inlinable var onunload: EventHandler { + get { ClosureAttribute1Optional[Strings.onunload, in: jsObject] } + nonmutating set { ClosureAttribute1Optional[Strings.onunload, in: jsObject] = newValue } } } diff --git a/Sources/DOMKit/WebIDL/WindowLocalStorage.swift b/Sources/DOMKit/WebIDL/WindowLocalStorage.swift new file mode 100644 index 00000000..c46d62fe --- /dev/null +++ b/Sources/DOMKit/WebIDL/WindowLocalStorage.swift @@ -0,0 +1,9 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol WindowLocalStorage: JSBridgedClass {} +public extension WindowLocalStorage { + @inlinable var localStorage: Storage { ReadonlyAttribute[Strings.localStorage, in: jsObject] } +} diff --git a/Sources/DOMKit/WebIDL/WindowOrWorkerGlobalScope.swift b/Sources/DOMKit/WebIDL/WindowOrWorkerGlobalScope.swift new file mode 100644 index 00000000..d94fd8fa --- /dev/null +++ b/Sources/DOMKit/WebIDL/WindowOrWorkerGlobalScope.swift @@ -0,0 +1,107 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol WindowOrWorkerGlobalScope: JSBridgedClass {} +public extension WindowOrWorkerGlobalScope { + @inlinable func fetch(input: RequestInfo, init: RequestInit? = nil) -> JSPromise { + let this = jsObject + return this[Strings.fetch].function!(this: this, arguments: [input.jsValue, `init`?.jsValue ?? .undefined]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable func fetch(input: RequestInfo, init: RequestInit? = nil) async throws -> Response { + let this = jsObject + let _promise: JSPromise = this[Strings.fetch].function!(this: this, arguments: [input.jsValue, `init`?.jsValue ?? .undefined]).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable var origin: String { ReadonlyAttribute[Strings.origin, in: jsObject] } + + @inlinable var isSecureContext: Bool { ReadonlyAttribute[Strings.isSecureContext, in: jsObject] } + + @inlinable var crossOriginIsolated: Bool { ReadonlyAttribute[Strings.crossOriginIsolated, in: jsObject] } + + @inlinable func reportError(e: JSValue) { + let this = jsObject + _ = this[Strings.reportError].function!(this: this, arguments: [e.jsValue]) + } + + @inlinable func btoa(data: String) -> String { + let this = jsObject + return this[Strings.btoa].function!(this: this, arguments: [data.jsValue]).fromJSValue()! + } + + @inlinable func atob(data: String) -> String { + let this = jsObject + return this[Strings.atob].function!(this: this, arguments: [data.jsValue]).fromJSValue()! + } + + @inlinable func setTimeout(handler: TimerHandler, timeout: Int32? = nil, arguments: JSValue...) -> Int32 { + let this = jsObject + return this[Strings.setTimeout].function!(this: this, arguments: [handler.jsValue, timeout?.jsValue ?? .undefined] + arguments.map(\.jsValue)).fromJSValue()! + } + + @inlinable func clearTimeout(id: Int32? = nil) { + let this = jsObject + _ = this[Strings.clearTimeout].function!(this: this, arguments: [id?.jsValue ?? .undefined]) + } + + @inlinable func setInterval(handler: TimerHandler, timeout: Int32? = nil, arguments: JSValue...) -> Int32 { + let this = jsObject + return this[Strings.setInterval].function!(this: this, arguments: [handler.jsValue, timeout?.jsValue ?? .undefined] + arguments.map(\.jsValue)).fromJSValue()! + } + + @inlinable func clearInterval(id: Int32? = nil) { + let this = jsObject + _ = this[Strings.clearInterval].function!(this: this, arguments: [id?.jsValue ?? .undefined]) + } + + // XXX: method 'queueMicrotask' is ignored + + @inlinable func createImageBitmap(image: ImageBitmapSource, options: ImageBitmapOptions? = nil) -> JSPromise { + let this = jsObject + return this[Strings.createImageBitmap].function!(this: this, arguments: [image.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable func createImageBitmap(image: ImageBitmapSource, options: ImageBitmapOptions? = nil) async throws -> ImageBitmap { + let this = jsObject + let _promise: JSPromise = this[Strings.createImageBitmap].function!(this: this, arguments: [image.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable func createImageBitmap(image: ImageBitmapSource, sx: Int32, sy: Int32, sw: Int32, sh: Int32, options: ImageBitmapOptions? = nil) -> JSPromise { + let _arg0 = image.jsValue + let _arg1 = sx.jsValue + let _arg2 = sy.jsValue + let _arg3 = sw.jsValue + let _arg4 = sh.jsValue + let _arg5 = options?.jsValue ?? .undefined + let this = jsObject + return this[Strings.createImageBitmap].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable func createImageBitmap(image: ImageBitmapSource, sx: Int32, sy: Int32, sw: Int32, sh: Int32, options: ImageBitmapOptions? = nil) async throws -> ImageBitmap { + let _arg0 = image.jsValue + let _arg1 = sx.jsValue + let _arg2 = sy.jsValue + let _arg3 = sw.jsValue + let _arg4 = sh.jsValue + let _arg5 = options?.jsValue ?? .undefined + let this = jsObject + let _promise: JSPromise = this[Strings.createImageBitmap].function!(this: this, arguments: [_arg0, _arg1, _arg2, _arg3, _arg4, _arg5]).fromJSValue()! + return try await _promise.value.fromJSValue()! + } + + @inlinable func structuredClone(value: JSValue, options: StructuredSerializeOptions? = nil) -> JSValue { + let this = jsObject + return this[Strings.structuredClone].function!(this: this, arguments: [value.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + } + + @inlinable var performance: Performance { ReadonlyAttribute[Strings.performance, in: jsObject] } + + @inlinable var caches: CacheStorage { ReadonlyAttribute[Strings.caches, in: jsObject] } +} diff --git a/Sources/DOMKit/WebIDL/WindowPostMessageOptions.swift b/Sources/DOMKit/WebIDL/WindowPostMessageOptions.swift new file mode 100644 index 00000000..34eff6f7 --- /dev/null +++ b/Sources/DOMKit/WebIDL/WindowPostMessageOptions.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class WindowPostMessageOptions: BridgedDictionary { + public convenience init(targetOrigin: String) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.targetOrigin] = targetOrigin.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _targetOrigin = ReadWriteAttribute(jsObject: object, name: Strings.targetOrigin) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var targetOrigin: String +} diff --git a/Sources/DOMKit/WebIDL/WindowSessionStorage.swift b/Sources/DOMKit/WebIDL/WindowSessionStorage.swift new file mode 100644 index 00000000..0e299f3f --- /dev/null +++ b/Sources/DOMKit/WebIDL/WindowSessionStorage.swift @@ -0,0 +1,9 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol WindowSessionStorage: JSBridgedClass {} +public extension WindowSessionStorage { + @inlinable var sessionStorage: Storage { ReadonlyAttribute[Strings.sessionStorage, in: jsObject] } +} diff --git a/Sources/DOMKit/WebIDL/Worker.swift b/Sources/DOMKit/WebIDL/Worker.swift new file mode 100644 index 00000000..29375925 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Worker.swift @@ -0,0 +1,39 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class Worker: EventTarget, AbstractWorker { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.Worker].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _onmessage = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onmessage) + _onmessageerror = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onmessageerror) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init(scriptURL: String, options: WorkerOptions? = nil) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [scriptURL.jsValue, options?.jsValue ?? .undefined])) + } + + @inlinable public func terminate() { + let this = jsObject + _ = this[Strings.terminate].function!(this: this, arguments: []) + } + + @inlinable public func postMessage(message: JSValue, transfer: [JSObject]) { + let this = jsObject + _ = this[Strings.postMessage].function!(this: this, arguments: [message.jsValue, transfer.jsValue]) + } + + @inlinable public func postMessage(message: JSValue, options: StructuredSerializeOptions? = nil) { + let this = jsObject + _ = this[Strings.postMessage].function!(this: this, arguments: [message.jsValue, options?.jsValue ?? .undefined]) + } + + @ClosureAttribute1Optional + public var onmessage: EventHandler + + @ClosureAttribute1Optional + public var onmessageerror: EventHandler +} diff --git a/Sources/DOMKit/WebIDL/WorkerOptions.swift b/Sources/DOMKit/WebIDL/WorkerOptions.swift new file mode 100644 index 00000000..41e473f4 --- /dev/null +++ b/Sources/DOMKit/WebIDL/WorkerOptions.swift @@ -0,0 +1,30 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class WorkerOptions: BridgedDictionary { + public convenience init(type: WorkerType, credentials: RequestCredentials, name: String) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.type] = type.jsValue + object[Strings.credentials] = credentials.jsValue + object[Strings.name] = name.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _type = ReadWriteAttribute(jsObject: object, name: Strings.type) + _credentials = ReadWriteAttribute(jsObject: object, name: Strings.credentials) + _name = ReadWriteAttribute(jsObject: object, name: Strings.name) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var type: WorkerType + + @ReadWriteAttribute + public var credentials: RequestCredentials + + @ReadWriteAttribute + public var name: String +} diff --git a/Sources/DOMKit/WebIDL/WorkerType.swift b/Sources/DOMKit/WebIDL/WorkerType.swift new file mode 100644 index 00000000..c52ed4c4 --- /dev/null +++ b/Sources/DOMKit/WebIDL/WorkerType.swift @@ -0,0 +1,22 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum WorkerType: JSString, JSValueCompatible { + case classic = "classic" + case module = "module" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/Worklet.swift b/Sources/DOMKit/WebIDL/Worklet.swift new file mode 100644 index 00000000..6d776066 --- /dev/null +++ b/Sources/DOMKit/WebIDL/Worklet.swift @@ -0,0 +1,26 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class Worklet: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.Worklet].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + @inlinable public func addModule(moduleURL: String, options: WorkletOptions? = nil) -> JSPromise { + let this = jsObject + return this[Strings.addModule].function!(this: this, arguments: [moduleURL.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + } + + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable public func addModule(moduleURL: String, options: WorkletOptions? = nil) async throws { + let this = jsObject + let _promise: JSPromise = this[Strings.addModule].function!(this: this, arguments: [moduleURL.jsValue, options?.jsValue ?? .undefined]).fromJSValue()! + _ = try await _promise.value + } +} diff --git a/Sources/DOMKit/WebIDL/WorkletOptions.swift b/Sources/DOMKit/WebIDL/WorkletOptions.swift new file mode 100644 index 00000000..153d4b62 --- /dev/null +++ b/Sources/DOMKit/WebIDL/WorkletOptions.swift @@ -0,0 +1,20 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class WorkletOptions: BridgedDictionary { + public convenience init(credentials: RequestCredentials) { + let object = JSObject.global[Strings.Object].function!.new() + object[Strings.credentials] = credentials.jsValue + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + _credentials = ReadWriteAttribute(jsObject: object, name: Strings.credentials) + super.init(unsafelyWrapping: object) + } + + @ReadWriteAttribute + public var credentials: RequestCredentials +} diff --git a/Sources/DOMKit/WebIDL/XMLDocument.swift b/Sources/DOMKit/WebIDL/XMLDocument.swift index 0fe2c9ba..7debba4e 100644 --- a/Sources/DOMKit/WebIDL/XMLDocument.swift +++ b/Sources/DOMKit/WebIDL/XMLDocument.swift @@ -1,12 +1,10 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class XMLDocument: Document { - override public class var constructor: JSFunction { JSObject.global.XMLDocument.function! } + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.XMLDocument].function! } public required init(unsafelyWrapping jsObject: JSObject) { super.init(unsafelyWrapping: jsObject) diff --git a/Sources/DOMKit/WebIDL/XMLHttpRequest.swift b/Sources/DOMKit/WebIDL/XMLHttpRequest.swift new file mode 100644 index 00000000..1be78b7a --- /dev/null +++ b/Sources/DOMKit/WebIDL/XMLHttpRequest.swift @@ -0,0 +1,114 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class XMLHttpRequest: XMLHttpRequestEventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.XMLHttpRequest].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _onreadystatechange = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onreadystatechange) + _readyState = ReadonlyAttribute(jsObject: jsObject, name: Strings.readyState) + _timeout = ReadWriteAttribute(jsObject: jsObject, name: Strings.timeout) + _withCredentials = ReadWriteAttribute(jsObject: jsObject, name: Strings.withCredentials) + _upload = ReadonlyAttribute(jsObject: jsObject, name: Strings.upload) + _responseURL = ReadonlyAttribute(jsObject: jsObject, name: Strings.responseURL) + _status = ReadonlyAttribute(jsObject: jsObject, name: Strings.status) + _statusText = ReadonlyAttribute(jsObject: jsObject, name: Strings.statusText) + _responseType = ReadWriteAttribute(jsObject: jsObject, name: Strings.responseType) + _response = ReadonlyAttribute(jsObject: jsObject, name: Strings.response) + _responseText = ReadonlyAttribute(jsObject: jsObject, name: Strings.responseText) + _responseXML = ReadonlyAttribute(jsObject: jsObject, name: Strings.responseXML) + super.init(unsafelyWrapping: jsObject) + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @ClosureAttribute1Optional + public var onreadystatechange: EventHandler + + public static let UNSENT: UInt16 = 0 + + public static let OPENED: UInt16 = 1 + + public static let HEADERS_RECEIVED: UInt16 = 2 + + public static let LOADING: UInt16 = 3 + + public static let DONE: UInt16 = 4 + + @ReadonlyAttribute + public var readyState: UInt16 + + @inlinable public func open(method: String, url: String) { + let this = jsObject + _ = this[Strings.open].function!(this: this, arguments: [method.jsValue, url.jsValue]) + } + + @inlinable public func open(method: String, url: String, async: Bool, username: String? = nil, password: String? = nil) { + let this = jsObject + _ = this[Strings.open].function!(this: this, arguments: [method.jsValue, url.jsValue, async.jsValue, username?.jsValue ?? .undefined, password?.jsValue ?? .undefined]) + } + + @inlinable public func setRequestHeader(name: String, value: String) { + let this = jsObject + _ = this[Strings.setRequestHeader].function!(this: this, arguments: [name.jsValue, value.jsValue]) + } + + @ReadWriteAttribute + public var timeout: UInt32 + + @ReadWriteAttribute + public var withCredentials: Bool + + @ReadonlyAttribute + public var upload: XMLHttpRequestUpload + + @inlinable public func send(body: Document_or_XMLHttpRequestBodyInit? = nil) { + let this = jsObject + _ = this[Strings.send].function!(this: this, arguments: [body?.jsValue ?? .undefined]) + } + + @inlinable public func abort() { + let this = jsObject + _ = this[Strings.abort].function!(this: this, arguments: []) + } + + @ReadonlyAttribute + public var responseURL: String + + @ReadonlyAttribute + public var status: UInt16 + + @ReadonlyAttribute + public var statusText: String + + @inlinable public func getResponseHeader(name: String) -> String? { + let this = jsObject + return this[Strings.getResponseHeader].function!(this: this, arguments: [name.jsValue]).fromJSValue()! + } + + @inlinable public func getAllResponseHeaders() -> String { + let this = jsObject + return this[Strings.getAllResponseHeaders].function!(this: this, arguments: []).fromJSValue()! + } + + @inlinable public func overrideMimeType(mime: String) { + let this = jsObject + _ = this[Strings.overrideMimeType].function!(this: this, arguments: [mime.jsValue]) + } + + @ReadWriteAttribute + public var responseType: XMLHttpRequestResponseType + + @ReadonlyAttribute + public var response: JSValue + + @ReadonlyAttribute + public var responseText: String + + @ReadonlyAttribute + public var responseXML: Document? +} diff --git a/Sources/DOMKit/WebIDL/XMLHttpRequestBodyInit.swift b/Sources/DOMKit/WebIDL/XMLHttpRequestBodyInit.swift new file mode 100644 index 00000000..fc361f42 --- /dev/null +++ b/Sources/DOMKit/WebIDL/XMLHttpRequestBodyInit.swift @@ -0,0 +1,88 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_XMLHttpRequestBodyInit: ConvertibleToJSValue {} +extension Blob: Any_XMLHttpRequestBodyInit {} +extension BufferSource: Any_XMLHttpRequestBodyInit {} +extension FormData: Any_XMLHttpRequestBodyInit {} +extension String: Any_XMLHttpRequestBodyInit {} +extension URLSearchParams: Any_XMLHttpRequestBodyInit {} + +public enum XMLHttpRequestBodyInit: JSValueCompatible, Any_XMLHttpRequestBodyInit { + case blob(Blob) + case bufferSource(BufferSource) + case formData(FormData) + case string(String) + case urlSearchParams(URLSearchParams) + + var blob: Blob? { + switch self { + case let .blob(blob): return blob + default: return nil + } + } + + var bufferSource: BufferSource? { + switch self { + case let .bufferSource(bufferSource): return bufferSource + default: return nil + } + } + + var formData: FormData? { + switch self { + case let .formData(formData): return formData + default: return nil + } + } + + var string: String? { + switch self { + case let .string(string): return string + default: return nil + } + } + + var urlSearchParams: URLSearchParams? { + switch self { + case let .urlSearchParams(urlSearchParams): return urlSearchParams + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let blob: Blob = value.fromJSValue() { + return .blob(blob) + } + if let bufferSource: BufferSource = value.fromJSValue() { + return .bufferSource(bufferSource) + } + if let formData: FormData = value.fromJSValue() { + return .formData(formData) + } + if let string: String = value.fromJSValue() { + return .string(string) + } + if let urlSearchParams: URLSearchParams = value.fromJSValue() { + return .urlSearchParams(urlSearchParams) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .blob(blob): + return blob.jsValue + case let .bufferSource(bufferSource): + return bufferSource.jsValue + case let .formData(formData): + return formData.jsValue + case let .string(string): + return string.jsValue + case let .urlSearchParams(urlSearchParams): + return urlSearchParams.jsValue + } + } +} diff --git a/Sources/DOMKit/WebIDL/XMLHttpRequestEventTarget.swift b/Sources/DOMKit/WebIDL/XMLHttpRequestEventTarget.swift new file mode 100644 index 00000000..6ca9430c --- /dev/null +++ b/Sources/DOMKit/WebIDL/XMLHttpRequestEventTarget.swift @@ -0,0 +1,40 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class XMLHttpRequestEventTarget: EventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.XMLHttpRequestEventTarget].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + _onloadstart = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onloadstart) + _onprogress = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onprogress) + _onabort = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onabort) + _onerror = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onerror) + _onload = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onload) + _ontimeout = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.ontimeout) + _onloadend = ClosureAttribute1Optional(jsObject: jsObject, name: Strings.onloadend) + super.init(unsafelyWrapping: jsObject) + } + + @ClosureAttribute1Optional + public var onloadstart: EventHandler + + @ClosureAttribute1Optional + public var onprogress: EventHandler + + @ClosureAttribute1Optional + public var onabort: EventHandler + + @ClosureAttribute1Optional + public var onerror: EventHandler + + @ClosureAttribute1Optional + public var onload: EventHandler + + @ClosureAttribute1Optional + public var ontimeout: EventHandler + + @ClosureAttribute1Optional + public var onloadend: EventHandler +} diff --git a/Sources/DOMKit/WebIDL/XMLHttpRequestResponseType.swift b/Sources/DOMKit/WebIDL/XMLHttpRequestResponseType.swift new file mode 100644 index 00000000..3fa4b45e --- /dev/null +++ b/Sources/DOMKit/WebIDL/XMLHttpRequestResponseType.swift @@ -0,0 +1,26 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum XMLHttpRequestResponseType: JSString, JSValueCompatible { + case _empty = "" + case arraybuffer = "arraybuffer" + case blob = "blob" + case document = "document" + case json = "json" + case text = "text" + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } +} diff --git a/Sources/DOMKit/WebIDL/XMLHttpRequestUpload.swift b/Sources/DOMKit/WebIDL/XMLHttpRequestUpload.swift new file mode 100644 index 00000000..68459258 --- /dev/null +++ b/Sources/DOMKit/WebIDL/XMLHttpRequestUpload.swift @@ -0,0 +1,12 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class XMLHttpRequestUpload: XMLHttpRequestEventTarget { + @inlinable override public class var constructor: JSFunction { JSObject.global[Strings.XMLHttpRequestUpload].function! } + + public required init(unsafelyWrapping jsObject: JSObject) { + super.init(unsafelyWrapping: jsObject) + } +} diff --git a/Sources/DOMKit/WebIDL/XPathEvaluator.swift b/Sources/DOMKit/WebIDL/XPathEvaluator.swift index 30e8da4a..546d5ce5 100644 --- a/Sources/DOMKit/WebIDL/XPathEvaluator.swift +++ b/Sources/DOMKit/WebIDL/XPathEvaluator.swift @@ -1,12 +1,10 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class XPathEvaluator: JSBridgedClass, XPathEvaluatorBase { - public class var constructor: JSFunction { JSObject.global.XPathEvaluator.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.XPathEvaluator].function! } public let jsObject: JSObject @@ -14,7 +12,7 @@ public class XPathEvaluator: JSBridgedClass, XPathEvaluatorBase { self.jsObject = jsObject } - public convenience init() { - self.init(unsafelyWrapping: XPathEvaluator.constructor.new()) + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) } } diff --git a/Sources/DOMKit/WebIDL/XPathEvaluatorBase.swift b/Sources/DOMKit/WebIDL/XPathEvaluatorBase.swift index 9ec9e315..34302ee2 100644 --- a/Sources/DOMKit/WebIDL/XPathEvaluatorBase.swift +++ b/Sources/DOMKit/WebIDL/XPathEvaluatorBase.swift @@ -1,30 +1,13 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public protocol XPathEvaluatorBase: JSBridgedClass {} - public extension XPathEvaluatorBase { - func createExpression(expression: String, resolver: XPathNSResolverType? = nil) -> XPathExpression { - return jsObject.createExpression!(expression.jsValue(), resolver.jsValue()).fromJSValue()! - } - - func createExpression(expression: String, resolver: ((String?) -> String?)? = nil) -> XPathExpression { - return jsObject.createExpression!(expression.jsValue(), resolver == nil ? nil : JSClosure { resolver!($0[0].fromJSValue()!).jsValue() }).fromJSValue()! - } - - func createNSResolver(nodeResolver: Node) -> XPathNSResolver { - return jsObject.createNSResolver!(nodeResolver.jsValue()).fromJSValue()! as AnyXPathNSResolver - } + // XXX: method 'createExpression' is ignored - func evaluate(expression: String, contextNode: Node, resolver: XPathNSResolverType? = nil, type: UInt16 = 0, result: XPathResult? = nil) -> XPathResult { - return jsObject.evaluate!(expression.jsValue(), contextNode.jsValue(), resolver.jsValue(), type.jsValue(), result.jsValue()).fromJSValue()! - } + // XXX: method 'createNSResolver' is ignored - func evaluate(expression: String, contextNode: Node, resolver: ((String?) -> String?)? = nil, type: UInt16 = 0, result: XPathResult? = nil) -> XPathResult { - return jsObject.evaluate!(expression.jsValue(), contextNode.jsValue(), resolver == nil ? nil : JSClosure { resolver!($0[0].fromJSValue()!).jsValue() }, type.jsValue(), result.jsValue()).fromJSValue()! - } + // XXX: method 'evaluate' is ignored } diff --git a/Sources/DOMKit/WebIDL/XPathExpression.swift b/Sources/DOMKit/WebIDL/XPathExpression.swift index e52919ee..6716ae55 100644 --- a/Sources/DOMKit/WebIDL/XPathExpression.swift +++ b/Sources/DOMKit/WebIDL/XPathExpression.swift @@ -1,12 +1,10 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class XPathExpression: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.XPathExpression.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.XPathExpression].function! } public let jsObject: JSObject @@ -14,7 +12,8 @@ public class XPathExpression: JSBridgedClass { self.jsObject = jsObject } - public func evaluate(contextNode: Node, type: UInt16 = 0, result: XPathResult? = nil) -> XPathResult { - return jsObject.evaluate!(contextNode.jsValue(), type.jsValue(), result.jsValue()).fromJSValue()! + @inlinable public func evaluate(contextNode: Node, type: UInt16? = nil, result: XPathResult? = nil) -> XPathResult { + let this = jsObject + return this[Strings.evaluate].function!(this: this, arguments: [contextNode.jsValue, type?.jsValue ?? .undefined, result?.jsValue ?? .undefined]).fromJSValue()! } } diff --git a/Sources/DOMKit/WebIDL/XPathNSResolver.swift b/Sources/DOMKit/WebIDL/XPathNSResolver.swift deleted file mode 100644 index 1d9cfe0d..00000000 --- a/Sources/DOMKit/WebIDL/XPathNSResolver.swift +++ /dev/null @@ -1,10 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public protocol XPathNSResolver: JSBridgedType { - func lookupNamespaceURI(prefix: String?) -> String? -} diff --git a/Sources/DOMKit/WebIDL/XPathResult.swift b/Sources/DOMKit/WebIDL/XPathResult.swift index 6395dd49..1c4458c5 100644 --- a/Sources/DOMKit/WebIDL/XPathResult.swift +++ b/Sources/DOMKit/WebIDL/XPathResult.swift @@ -1,45 +1,43 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! -/* - * The following code is auto generated using webidl2swift - */ - +import JavaScriptEventLoop import JavaScriptKit public class XPathResult: JSBridgedClass { - public class var constructor: JSFunction { JSObject.global.XPathResult.function! } + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.XPathResult].function! } public let jsObject: JSObject public required init(unsafelyWrapping jsObject: JSObject) { - _resultType = ReadonlyAttribute(jsObject: jsObject, name: "resultType") - _numberValue = ReadonlyAttribute(jsObject: jsObject, name: "numberValue") - _stringValue = ReadonlyAttribute(jsObject: jsObject, name: "stringValue") - _booleanValue = ReadonlyAttribute(jsObject: jsObject, name: "booleanValue") - _singleNodeValue = ReadonlyAttribute(jsObject: jsObject, name: "singleNodeValue") - _invalidIteratorState = ReadonlyAttribute(jsObject: jsObject, name: "invalidIteratorState") - _snapshotLength = ReadonlyAttribute(jsObject: jsObject, name: "snapshotLength") + _resultType = ReadonlyAttribute(jsObject: jsObject, name: Strings.resultType) + _numberValue = ReadonlyAttribute(jsObject: jsObject, name: Strings.numberValue) + _stringValue = ReadonlyAttribute(jsObject: jsObject, name: Strings.stringValue) + _booleanValue = ReadonlyAttribute(jsObject: jsObject, name: Strings.booleanValue) + _singleNodeValue = ReadonlyAttribute(jsObject: jsObject, name: Strings.singleNodeValue) + _invalidIteratorState = ReadonlyAttribute(jsObject: jsObject, name: Strings.invalidIteratorState) + _snapshotLength = ReadonlyAttribute(jsObject: jsObject, name: Strings.snapshotLength) self.jsObject = jsObject } - public let ANY_TYPE: UInt16 = 0 + public static let ANY_TYPE: UInt16 = 0 - public let NUMBER_TYPE: UInt16 = 1 + public static let NUMBER_TYPE: UInt16 = 1 - public let STRING_TYPE: UInt16 = 2 + public static let STRING_TYPE: UInt16 = 2 - public let BOOLEAN_TYPE: UInt16 = 3 + public static let BOOLEAN_TYPE: UInt16 = 3 - public let UNORDERED_NODE_ITERATOR_TYPE: UInt16 = 4 + public static let UNORDERED_NODE_ITERATOR_TYPE: UInt16 = 4 - public let ORDERED_NODE_ITERATOR_TYPE: UInt16 = 5 + public static let ORDERED_NODE_ITERATOR_TYPE: UInt16 = 5 - public let UNORDERED_NODE_SNAPSHOT_TYPE: UInt16 = 6 + public static let UNORDERED_NODE_SNAPSHOT_TYPE: UInt16 = 6 - public let ORDERED_NODE_SNAPSHOT_TYPE: UInt16 = 7 + public static let ORDERED_NODE_SNAPSHOT_TYPE: UInt16 = 7 - public let ANY_UNORDERED_NODE_TYPE: UInt16 = 8 + public static let ANY_UNORDERED_NODE_TYPE: UInt16 = 8 - public let FIRST_ORDERED_NODE_TYPE: UInt16 = 9 + public static let FIRST_ORDERED_NODE_TYPE: UInt16 = 9 @ReadonlyAttribute public var resultType: UInt16 @@ -62,11 +60,13 @@ public class XPathResult: JSBridgedClass { @ReadonlyAttribute public var snapshotLength: UInt32 - public func iterateNext() -> Node? { - return jsObject.iterateNext!().fromJSValue()! + @inlinable public func iterateNext() -> Node? { + let this = jsObject + return this[Strings.iterateNext].function!(this: this, arguments: []).fromJSValue()! } - public func snapshotItem(index: UInt32) -> Node? { - return jsObject.snapshotItem!(index.jsValue()).fromJSValue()! + @inlinable public func snapshotItem(index: UInt32) -> Node? { + let this = jsObject + return this[Strings.snapshotItem].function!(this: this, arguments: [index.jsValue]).fromJSValue()! } } diff --git a/Sources/DOMKit/WebIDL/XSLTProcessor.swift b/Sources/DOMKit/WebIDL/XSLTProcessor.swift new file mode 100644 index 00000000..271b3589 --- /dev/null +++ b/Sources/DOMKit/WebIDL/XSLTProcessor.swift @@ -0,0 +1,58 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public class XSLTProcessor: JSBridgedClass { + @inlinable public class var constructor: JSFunction { JSObject.global[Strings.XSLTProcessor].function! } + + public let jsObject: JSObject + + public required init(unsafelyWrapping jsObject: JSObject) { + self.jsObject = jsObject + } + + @inlinable public convenience init() { + self.init(unsafelyWrapping: Self.constructor.new(arguments: [])) + } + + @inlinable public func importStylesheet(style: Node) { + let this = jsObject + _ = this[Strings.importStylesheet].function!(this: this, arguments: [style.jsValue]) + } + + @inlinable public func transformToFragment(source: Node, output: Document) -> DocumentFragment { + let this = jsObject + return this[Strings.transformToFragment].function!(this: this, arguments: [source.jsValue, output.jsValue]).fromJSValue()! + } + + @inlinable public func transformToDocument(source: Node) -> Document { + let this = jsObject + return this[Strings.transformToDocument].function!(this: this, arguments: [source.jsValue]).fromJSValue()! + } + + @inlinable public func setParameter(namespaceURI: String, localName: String, value: JSValue) { + let this = jsObject + _ = this[Strings.setParameter].function!(this: this, arguments: [namespaceURI.jsValue, localName.jsValue, value.jsValue]) + } + + @inlinable public func getParameter(namespaceURI: String, localName: String) -> JSValue { + let this = jsObject + return this[Strings.getParameter].function!(this: this, arguments: [namespaceURI.jsValue, localName.jsValue]).fromJSValue()! + } + + @inlinable public func removeParameter(namespaceURI: String, localName: String) { + let this = jsObject + _ = this[Strings.removeParameter].function!(this: this, arguments: [namespaceURI.jsValue, localName.jsValue]) + } + + @inlinable public func clearParameters() { + let this = jsObject + _ = this[Strings.clearParameters].function!(this: this, arguments: []) + } + + @inlinable public func reset() { + let this = jsObject + _ = this[Strings.reset].function!(this: this, arguments: []) + } +} diff --git a/Sources/DOMKit/WebIDL/console.swift b/Sources/DOMKit/WebIDL/console.swift deleted file mode 100644 index a3e772d3..00000000 --- a/Sources/DOMKit/WebIDL/console.swift +++ /dev/null @@ -1,148 +0,0 @@ - -/* - * The following code is auto generated using webidl2swift - */ - -import JavaScriptKit - -public enum console { - public static var jsObject: JSObject { - return JSObject.global.console.object! - } - - public static func assert(condition: Bool = false, data: JSValue...) { - _ = jsObject.assert!(condition.jsValue(), data.jsValue()) - } - - public static func assert(condition: Bool = false) { - _ = jsObject.assert!(condition.jsValue()) - } - - public static func clear() { - _ = jsObject.clear!() - } - - public static func debug(data: JSValue...) { - _ = jsObject.debug!(data.jsValue()) - } - - public static func debug() { - _ = jsObject.debug!() - } - - public static func error(data: JSValue...) { - _ = jsObject.error!(data.jsValue()) - } - - public static func error() { - _ = jsObject.error!() - } - - public static func info(data: JSValue...) { - _ = jsObject.info!(data.jsValue()) - } - - public static func info() { - _ = jsObject.info!() - } - - public static func log(data: JSValue...) { - _ = jsObject.log!(data.jsValue()) - } - - public static func log() { - _ = jsObject.log!() - } - - public static func table(tabularData: JSValue, properties: [String]) { - _ = jsObject.table!(tabularData.jsValue(), properties.jsValue()) - } - - public static func table(tabularData: JSValue) { - _ = jsObject.table!(tabularData.jsValue()) - } - - public static func table() { - _ = jsObject.table!() - } - - public static func trace(data: JSValue...) { - _ = jsObject.trace!(data.jsValue()) - } - - public static func trace() { - _ = jsObject.trace!() - } - - public static func warn(data: JSValue...) { - _ = jsObject.warn!(data.jsValue()) - } - - public static func warn() { - _ = jsObject.warn!() - } - - public static func dir(item: JSValue, options: JSValue?) { - _ = jsObject.dir!(item.jsValue(), options.jsValue()) - } - - public static func dir(item: JSValue) { - _ = jsObject.dir!(item.jsValue()) - } - - public static func dir() { - _ = jsObject.dir!() - } - - public static func dirxml(data: JSValue...) { - _ = jsObject.dirxml!(data.jsValue()) - } - - public static func dirxml() { - _ = jsObject.dirxml!() - } - - public static func count(label: String = "default") { - _ = jsObject.count!(label.jsValue()) - } - - public static func countReset(label: String = "default") { - _ = jsObject.countReset!(label.jsValue()) - } - - public static func group(data: JSValue...) { - _ = jsObject.group!(data.jsValue()) - } - - public static func group() { - _ = jsObject.group!() - } - - public static func groupCollapsed(data: JSValue...) { - _ = jsObject.groupCollapsed!(data.jsValue()) - } - - public static func groupCollapsed() { - _ = jsObject.groupCollapsed!() - } - - public static func groupEnd() { - _ = jsObject.groupEnd!() - } - - public static func time(label: String = "default") { - _ = jsObject.time!(label.jsValue()) - } - - public static func timeLog(label: String = "default", data: JSValue...) { - _ = jsObject.timeLog!(label.jsValue(), data.jsValue()) - } - - public static func timeLog(label: String = "default") { - _ = jsObject.timeLog!(label.jsValue()) - } - - public static func timeEnd(label: String = "default") { - _ = jsObject.timeEnd!(label.jsValue()) - } -} diff --git a/Sources/DOMKit/WebIDL/nullable_Double_or_seq_of_nullable_Double.swift b/Sources/DOMKit/WebIDL/nullable_Double_or_seq_of_nullable_Double.swift new file mode 100644 index 00000000..bd62b198 --- /dev/null +++ b/Sources/DOMKit/WebIDL/nullable_Double_or_seq_of_nullable_Double.swift @@ -0,0 +1,46 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public protocol Any_nullable_Double_or_seq_of_nullable_Double: ConvertibleToJSValue {} +extension Optional: Any_nullable_Double_or_seq_of_nullable_Double where Wrapped == Double {} +extension Array: Any_nullable_Double_or_seq_of_nullable_Double where Element == Double? {} + +public enum nullable_Double_or_seq_of_nullable_Double: JSValueCompatible, Any_nullable_Double_or_seq_of_nullable_Double { + case nullable_Double(Double?) + case seq_of_nullable_Double([Double?]) + + var nullable_Double: Double?? { + switch self { + case let .nullable_Double(nullable_Double): return nullable_Double + default: return nil + } + } + + var seq_of_nullable_Double: [Double?]? { + switch self { + case let .seq_of_nullable_Double(seq_of_nullable_Double): return seq_of_nullable_Double + default: return nil + } + } + + public static func construct(from value: JSValue) -> Self? { + if let nullable_Double: Double? = value.fromJSValue() { + return .nullable_Double(nullable_Double) + } + if let seq_of_nullable_Double: [Double?] = value.fromJSValue() { + return .seq_of_nullable_Double(seq_of_nullable_Double) + } + return nil + } + + public var jsValue: JSValue { + switch self { + case let .nullable_Double(nullable_Double): + return nullable_Double.jsValue + case let .seq_of_nullable_Double(seq_of_nullable_Double): + return seq_of_nullable_Double.jsValue + } + } +} diff --git a/Sources/WebIDL/Argument.swift b/Sources/WebIDL/Argument.swift new file mode 100644 index 00000000..b6c4e8db --- /dev/null +++ b/Sources/WebIDL/Argument.swift @@ -0,0 +1,10 @@ +/// https://github.com/w3c/webidl2.js/#arguments +public struct IDLArgument: Hashable, IDLNode, IDLNamed { + public static let type = "argument" + public let `default`: IDLValue? + public let optional: Bool + public let variadic: Bool + public let idlType: IDLType + public let name: String + public let extAttrs: [IDLExtendedAttribute] +} diff --git a/Sources/WebIDL/Attribute.swift b/Sources/WebIDL/Attribute.swift new file mode 100644 index 00000000..29f10b84 --- /dev/null +++ b/Sources/WebIDL/Attribute.swift @@ -0,0 +1,8 @@ +public struct IDLAttribute: IDLNode, IDLNamed { + public static let type = "attribute" + public let name: String + public let special: String + public let readonly: Bool + public let idlType: IDLType + public let extAttrs: [IDLExtendedAttribute] +} diff --git a/Sources/WebIDL/Callback.swift b/Sources/WebIDL/Callback.swift new file mode 100644 index 00000000..db48a232 --- /dev/null +++ b/Sources/WebIDL/Callback.swift @@ -0,0 +1,8 @@ +/// https://github.com/w3c/webidl2.js#callback +public struct IDLCallback: IDLNode, IDLNamed { + public static let type = "callback" + public let name: String + public let idlType: IDLType + public let arguments: [IDLArgument] + public let extAttrs: [IDLExtendedAttribute] +} diff --git a/Sources/WebIDL/Constant.swift b/Sources/WebIDL/Constant.swift new file mode 100644 index 00000000..900e3af3 --- /dev/null +++ b/Sources/WebIDL/Constant.swift @@ -0,0 +1,7 @@ +public struct IDLConstant: IDLNode, IDLNamed { + public static let type = "const" + public let name: String + public let idlType: IDLType + public let value: IDLValue + public let extAttrs: [IDLExtendedAttribute] +} diff --git a/Sources/WebIDL/Constructor.swift b/Sources/WebIDL/Constructor.swift new file mode 100644 index 00000000..3dbb7386 --- /dev/null +++ b/Sources/WebIDL/Constructor.swift @@ -0,0 +1,5 @@ +public struct IDLConstructor: IDLNode { + public static let type = "constructor" + public let arguments: [IDLArgument] + public let extAttrs: [IDLExtendedAttribute] +} diff --git a/Sources/WebIDL/Declaration.swift b/Sources/WebIDL/Declaration.swift new file mode 100644 index 00000000..7b7ced1a --- /dev/null +++ b/Sources/WebIDL/Declaration.swift @@ -0,0 +1,29 @@ +/// https://github.com/w3c/webidl2.js#iterable-async-iterable-maplike-and-setlike-declarations +public protocol IDLDeclaration: IDLNode, IDLInterfaceMember { + var idlType: [IDLType] { get } + var arguments: [IDLArgument] { get } +} + +public struct IDLMapLikeDeclaration: IDLDeclaration { + public static let type = "maplike" + public let idlType: [IDLType] + public let readonly: Bool + public let arguments: [IDLArgument] + public let extAttrs: [IDLExtendedAttribute] +} + +public struct IDLSetLikeDeclaration: IDLDeclaration { + public static let type = "setlike" + public let idlType: [IDLType] + public let readonly: Bool + public let arguments: [IDLArgument] + public let extAttrs: [IDLExtendedAttribute] +} + +public struct IDLIterableDeclaration: IDLDeclaration { + public static let type = "iterable" + public let idlType: [IDLType] + public let async: Bool + public let arguments: [IDLArgument] + public let extAttrs: [IDLExtendedAttribute] +} diff --git a/Sources/WebIDL/Dictionary.swift b/Sources/WebIDL/Dictionary.swift new file mode 100644 index 00000000..9c74a1d1 --- /dev/null +++ b/Sources/WebIDL/Dictionary.swift @@ -0,0 +1,18 @@ +/// https://github.com/w3c/webidl2.js/#dictionary +public struct IDLDictionary: IDLNode, IDLNamed { + public static let type = "dictionary" + public let name: String + public let partial: Bool + public let members: [Member] + public let inheritance: String? + public let extAttrs: [IDLExtendedAttribute] + + public struct Member: IDLNode, IDLNamed { + public static let type = "field" + public let name: String + public let required: Bool + public let idlType: IDLType + public let extAttrs: [IDLExtendedAttribute] + public let `default`: IDLValue? + } +} diff --git a/Sources/WebIDL/Enum.swift b/Sources/WebIDL/Enum.swift new file mode 100644 index 00000000..e4e7dfad --- /dev/null +++ b/Sources/WebIDL/Enum.swift @@ -0,0 +1,11 @@ +public struct IDLEnum: IDLNode, IDLNamed { + public static let type = "enum" + public let name: String + private let values: [Value] + public var cases: [String] { values.map(\.value) } + public let extAttrs: [IDLExtendedAttribute] + + private struct Value: Decodable { + let value: String + } +} diff --git a/Sources/WebIDL/ExtendedAttribute.swift b/Sources/WebIDL/ExtendedAttribute.swift new file mode 100644 index 00000000..acbd43ba --- /dev/null +++ b/Sources/WebIDL/ExtendedAttribute.swift @@ -0,0 +1,69 @@ +/// https://github.com/w3c/webidl2.js/#extended-attributes +public struct IDLExtendedAttribute: Hashable, Decodable, IDLNamed { + public let name: String + public let arguments: [IDLArgument] + public let rhs: RHS? + + public enum RHS: Decodable, Equatable, Hashable { + case identifier(String) + case identifierList([String]) + case string(String) + case stringList([String]) + case decimal(String) + case decimalList([String]) + case integer(String) + case integerList([String]) + case wildcard + + private enum CodingKeys: String, CodingKey { + case type + case value + } + + private struct ValueContainer: Decodable { + let value: String + } + + public var identifiers: [String]? { + switch self { + case let .identifier(identifier): + return [identifier] + case let .identifierList(identifiers): + return identifiers + default: + return nil + } + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + let type = try container.decode(String.self, forKey: .type) + switch type { + case "identifier": + self = .identifier(try container.decode(String.self, forKey: .value)) + case "identifier-list": + self = .identifierList(try container.decode([ValueContainer].self, forKey: .value).map(\.value)) + case "string": + self = .string(try container.decode(String.self, forKey: .value)) + case "string-list": + self = .stringList(try container.decode([ValueContainer].self, forKey: .value).map(\.value)) + case "decimal": + self = .decimal(try container.decode(String.self, forKey: .value)) + case "decimal-list": + self = .decimalList(try container.decode([ValueContainer].self, forKey: .value).map(\.value)) + case "integer": + self = .integer(try container.decode(String.self, forKey: .value)) + case "integer-list": + self = .integerList(try container.decode([ValueContainer].self, forKey: .value).map(\.value)) + case "*": + self = .wildcard + default: + throw DecodingError.dataCorruptedError( + forKey: .type, + in: container, + debugDescription: "Unknown extended attribute type: \(type)" + ) + } + } + } +} diff --git a/Sources/WebIDL/GenericCollection.swift b/Sources/WebIDL/GenericCollection.swift new file mode 100644 index 00000000..867d1044 --- /dev/null +++ b/Sources/WebIDL/GenericCollection.swift @@ -0,0 +1,14 @@ +/// Necessary because it isn't possible to automatically decode an array +/// of different objects conforming to a protocol that is `Decodable`. +public struct GenericCollection: Collection, Decodable { + public let array: [IDLNode] + public var startIndex: Array.Index { array.startIndex } + public var endIndex: Array.Index { array.endIndex } + public subscript(index: Array.Index) -> Element { array[index] as! Element } + public func index(after index: Array.Index) -> Array.Index { array.index(after: index) } + + public init(from decoder: Decoder) throws { + let wrappers = try decoder.singleValueContainer().decode([IDLNodeDecoder].self) + array = wrappers.map(\.node) + } +} diff --git a/Sources/WebIDL/Includes.swift b/Sources/WebIDL/Includes.swift new file mode 100644 index 00000000..7f036ebe --- /dev/null +++ b/Sources/WebIDL/Includes.swift @@ -0,0 +1,6 @@ +public struct IDLIncludes: IDLNode { + public static let type = "includes" + public let target: String + public let includes: String + public let extAttrs: [IDLExtendedAttribute] +} diff --git a/Sources/WebIDL/Interface.swift b/Sources/WebIDL/Interface.swift new file mode 100644 index 00000000..9e1875be --- /dev/null +++ b/Sources/WebIDL/Interface.swift @@ -0,0 +1,28 @@ +/// https://github.com/w3c/webidl2.js#interface +public struct IDLInterface: IDLNode, IDLNamed { + public static let type = "interface" + public let name: String + public let partial: Bool + public let members: GenericCollection + public let inheritance: String? + public let extAttrs: [IDLExtendedAttribute] +} + +/// https://github.com/w3c/webidl2.js#callback-interfaces +public struct IDLCallbackInterface: IDLNode { + public static let type = "callback interface" + public let name: String + public let partial: Bool + public let members: GenericCollection + public let inheritance: String? + public let extAttrs: [IDLExtendedAttribute] +} + +public protocol IDLInterfaceMember: IDLNode {} + +extension IDLAttribute: IDLInterfaceMember {} +extension IDLConstant: IDLInterfaceMember {} +extension IDLConstructor: IDLInterfaceMember {} +// added on definition because of Swift limitation +// extension IDLDeclaration: IDLInterfaceMember {} +extension IDLOperation: IDLInterfaceMember {} diff --git a/Sources/WebIDL/InterfaceMixin.swift b/Sources/WebIDL/InterfaceMixin.swift new file mode 100644 index 00000000..7bf257a6 --- /dev/null +++ b/Sources/WebIDL/InterfaceMixin.swift @@ -0,0 +1,12 @@ +public struct IDLInterfaceMixin: IDLNode, IDLNamed { + public static let type = "interface mixin" + public let name: String + public let partial: Bool + public let members: GenericCollection + public let extAttrs: [IDLExtendedAttribute] +} + +public protocol IDLInterfaceMixinMember: IDLNode, IDLNamed {} +extension IDLAttribute: IDLInterfaceMixinMember {} +extension IDLConstant: IDLInterfaceMixinMember {} +extension IDLOperation: IDLInterfaceMixinMember {} diff --git a/Sources/WebIDL/Namespace.swift b/Sources/WebIDL/Namespace.swift new file mode 100644 index 00000000..763186b6 --- /dev/null +++ b/Sources/WebIDL/Namespace.swift @@ -0,0 +1,13 @@ +/// https://github.com/w3c/webidl2.js#namespace +public struct IDLNamespace: IDLNode, IDLNamed { + public static let type = "namespace" + public let name: String + public let partial: Bool + public let members: GenericCollection + public let extAttrs: [IDLExtendedAttribute] +} + +public protocol IDLNamespaceMember: IDLNode {} +extension IDLAttribute: IDLNamespaceMember {} +extension IDLConstant: IDLNamespaceMember {} +extension IDLOperation: IDLNamespaceMember {} diff --git a/Sources/WebIDL/Node.swift b/Sources/WebIDL/Node.swift new file mode 100644 index 00000000..614cb7fd --- /dev/null +++ b/Sources/WebIDL/Node.swift @@ -0,0 +1,50 @@ +public protocol IDLNode: Decodable { + static var type: String { get } + var extAttrs: [IDLExtendedAttribute] { get } +} + +public protocol IDLNamed { + var name: String { get } +} + +var idlTypes: [String: IDLNode.Type] = [ + "argument": IDLArgument.self, + "attribute": IDLAttribute.self, + "callback": IDLCallback.self, + "callback interface": IDLCallbackInterface.self, + "const": IDLConstant.self, + "constructor": IDLConstructor.self, + "maplike": IDLMapLikeDeclaration.self, + "setlike": IDLSetLikeDeclaration.self, + "iterable": IDLIterableDeclaration.self, + "dictionary": IDLDictionary.self, + "enum": IDLEnum.self, + "includes": IDLIncludes.self, + "interface": IDLInterface.self, + "interface mixin": IDLInterfaceMixin.self, + "namespace": IDLNamespace.self, + "operation": IDLOperation.self, + "typedef": IDLTypedef.self, +] + +private enum TypeKey: String, CodingKey { + case type +} + +struct IDLNodeDecoder: Decodable { + let node: IDLNode + init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: TypeKey.self) + let type = try container.decode(String.self, forKey: .type) + guard let idlType = idlTypes[type] else { + throw DecodingError.dataCorrupted( + DecodingError.Context( + codingPath: container.codingPath, + debugDescription: "Unknown type: \(type)" + ) + ) + } + + node = try idlType.init(from: decoder) + } +} diff --git a/Sources/WebIDL/Operation.swift b/Sources/WebIDL/Operation.swift new file mode 100644 index 00000000..57201f40 --- /dev/null +++ b/Sources/WebIDL/Operation.swift @@ -0,0 +1,8 @@ +public struct IDLOperation: IDLNode, IDLNamed { + public static let type = "operation" + public let special: String + public let idlType: IDLType? + public let name: String + public let arguments: [IDLArgument] + public let extAttrs: [IDLExtendedAttribute] +} diff --git a/Sources/WebIDL/Type.swift b/Sources/WebIDL/Type.swift new file mode 100644 index 00000000..66406b2d --- /dev/null +++ b/Sources/WebIDL/Type.swift @@ -0,0 +1,48 @@ +public struct IDLType: Decodable, Hashable { + public let type: String? + public let value: TypeValue + public let nullable: Bool + public let extAttrs: [IDLExtendedAttribute] + + private enum CodingKeys: String, CodingKey { + case type + case generic + case idlType + case nullable + case union + case extAttrs + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + type = try container.decodeIfPresent(String?.self, forKey: .type) ?? nil + nullable = try container.decode(Bool.self, forKey: .nullable) + extAttrs = try container.decode([IDLExtendedAttribute].self, forKey: .extAttrs) + value = try TypeValue(from: decoder) + } + + public enum TypeValue: Decodable, Hashable { + case generic(String, args: [IDLType]) + case single(String) + case union([IDLType]) + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + let generic = try container.decode(String.self, forKey: .generic) + if try container.decode(Bool.self, forKey: .union) { + self = .union(try container.decode([IDLType].self, forKey: .idlType)) + } else if !generic.isEmpty { + self = .generic(generic, args: try container.decode([IDLType].self, forKey: .idlType)) + } else if let name = try? container.decode(String.self, forKey: .idlType) { + self = .single(name) + } else { + throw DecodingError.dataCorrupted( + DecodingError.Context( + codingPath: container.codingPath, + debugDescription: "Expected generic, single, or union type" + ) + ) + } + } + } +} diff --git a/Sources/WebIDL/Typedef.swift b/Sources/WebIDL/Typedef.swift new file mode 100644 index 00000000..b0e34288 --- /dev/null +++ b/Sources/WebIDL/Typedef.swift @@ -0,0 +1,6 @@ +public struct IDLTypedef: IDLNode, IDLNamed { + public static let type = "typedef" + public let name: String + public let idlType: IDLType + public let extAttrs: [IDLExtendedAttribute] +} diff --git a/Sources/WebIDL/Value.swift b/Sources/WebIDL/Value.swift new file mode 100644 index 00000000..f69c9ffd --- /dev/null +++ b/Sources/WebIDL/Value.swift @@ -0,0 +1,47 @@ +/// Default and Const Values +public enum IDLValue: Hashable, Decodable { + case string(String) + case number(String) + case boolean(Bool) + case null + case infinity(negative: Bool) + case nan + case sequence + case dictionary + + private enum CodingKeys: String, CodingKey { + case type + case value + case negative + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + let type = try container.decode(String.self, forKey: .type) + switch type { + case "string": + self = .string(try container.decode(String.self, forKey: .value)) + case "number": + self = .number(try container.decode(String.self, forKey: .value)) + case "boolean": + self = .boolean(try container.decode(Bool.self, forKey: .value)) + case "null": + self = .null + case "infinity": + self = .infinity(negative: try container.decode(Bool.self, forKey: .negative)) + case "nan": + self = .nan + case "sequence": + self = .sequence + case "dictionary": + self = .dictionary + default: + throw DecodingError.dataCorrupted( + DecodingError.Context( + codingPath: container.codingPath, + debugDescription: "Unknown value type: \(type)" + ) + ) + } + } +} diff --git a/Sources/WebIDLToSwift/ClosurePattern.swift b/Sources/WebIDLToSwift/ClosurePattern.swift new file mode 100644 index 00000000..15b78d90 --- /dev/null +++ b/Sources/WebIDLToSwift/ClosurePattern.swift @@ -0,0 +1,115 @@ +struct ClosurePattern: SwiftRepresentable, Equatable, Hashable, Comparable { + static func < (lhs: ClosurePattern, rhs: ClosurePattern) -> Bool { + lhs.name.source < rhs.name.source + } + + let nullable: Bool + let void: Bool + let argCount: Int + + var name: SwiftSource { + "ClosureAttribute\(String(argCount))\(nullable ? "Optional" : "")\(void ? "Void" : "")" + } + + var indexes: [String] { (0 ..< argCount).map(String.init) } + + private var typeNames: [SwiftSource] { + indexes.map { "A\($0)" } + (void ? [] : ["ReturnType"]) + } + + private var closureType: SwiftSource { + let closure: SwiftSource = "(\(sequence: Array(typeNames.prefix(argCount)))) -> \(void ? "Void" : "ReturnType")" + return nullable ? "(\(closure))?" : closure + } + + private var getter: SwiftSource { + let getFunction: SwiftSource + if nullable { + getFunction = """ + guard let function = jsObject[name].function else { + return nil + } + """ + } else { + getFunction = "let function = jsObject[name].function!" + } + let call: SwiftSource = "function(\(sequence: indexes.map { "$\($0).jsValue" }))" + let closureBody: SwiftSource + if void { + closureBody = call + } else { + closureBody = "\(call).fromJSValue()!" + } + return """ + \(getFunction) + return { \(closureBody) } + """ + } + + private var setter: SwiftSource { + let call: SwiftSource = "newValue(\(sequence: indexes.map { "$0[\($0)].fromJSValue()!" }))" + let body: SwiftSource + if void { + body = """ + \(call) + return .undefined + """ + } else { + body = "\(call).jsValue" + } + let setClosure: SwiftSource = """ + jsObject[name] = JSClosure { \(argCount == 0 ? "_ in" : "") + \(body) + }.jsValue + """ + + if nullable { + return """ + if let newValue = newValue { + \(setClosure) + } else { + jsObject[name] = .null + } + """ + } else { + return setClosure + } + } + + var typeParams: SwiftSource { + if typeNames.isEmpty { return "" } + return """ + <\(sequence: typeNames)> + where \(sequence: typeNames.map { "\($0): JSValueCompatible" }) + """ + } + + var swiftRepresentation: SwiftSource { + """ + @propertyWrapper public final class \(name)\(typeParams) { + + @usableFromInline let jsObject: JSObject + @usableFromInline let name: JSString + + public init(jsObject: JSObject, name: JSString) { + self.jsObject = jsObject + self.name = name + } + + @inlinable public var wrappedValue: \(closureType) { + get { \(name)[name, in: jsObject] } + set { \(name)[name, in: jsObject] = newValue } + } + + @inlinable public static subscript(name: JSString, in jsObject: JSObject) -> \(closureType) { + get { + \(getter) + } + set { + \(setter) + } + } + } + """ + } +} diff --git a/Sources/WebIDLToSwift/Context.swift b/Sources/WebIDLToSwift/Context.swift new file mode 100644 index 00000000..495eb878 --- /dev/null +++ b/Sources/WebIDLToSwift/Context.swift @@ -0,0 +1,90 @@ +import WebIDL + +@dynamicMemberLookup +enum Context { + private(set) static var current = State() + + static var closurePatterns: Set = [] + private(set) static var strings: Set = ["toString"] + static var unions: Set = [] + + static func source(for name: String) -> SwiftSource { + assert(!name.isEmpty) + if name == "self" { + return "Strings._self" + } + strings.insert(name) + return "Strings.\(name)" + } + + private static var stack: [State] = [] + static func withState(_ new: State, body: () throws -> T) rethrows -> T { + stack.append(current) + current = new + defer { current = stack.removeLast() } + return try body() + } + + static subscript(dynamicMember member: KeyPath) -> T { + current[keyPath: member]! + } + + static subscript(dynamicMember member: KeyPath) -> T { + current[keyPath: member] + } + + struct State { + private(set) var `static` = false + private(set) var inClass = false + private(set) var constructor: SwiftSource? + private(set) var this: SwiftSource! + private(set) var className: SwiftSource! + private(set) var interfaces: [String: MergedInterface]! + private(set) var ignored: [String: Set]! + private(set) var types: [String: IDLTypealias]! + private(set) var override = false + private(set) var inProtocol = false + + static func `static`(this: SwiftSource, inClass: Bool = Context.inClass, className: SwiftSource) -> Self { + var newState = Context.current + newState.static = true + newState.this = this + newState.inClass = inClass + newState.className = className + return newState + } + + static func instance( + constructor: SwiftSource?, + this: SwiftSource, + className: SwiftSource, + inProtocol: Bool = Context.inProtocol + ) -> Self { + var newState = Context.current + newState.static = false + newState.constructor = constructor + newState.this = this + newState.inProtocol = inProtocol + newState.className = className + return newState + } + + static func override(_ isOverride: Bool) -> Self { + var newState = Context.current + newState.override = isOverride + return newState + } + + static func root( + interfaces: [String: MergedInterface], + ignored: [String: Set], + types: [String: IDLTypealias] + ) -> Self { + var newState = Context.current + newState.interfaces = interfaces + newState.ignored = ignored + newState.types = types + return newState + } + } +} diff --git a/Sources/WebIDLToSwift/FormatOutputFiles.swift b/Sources/WebIDLToSwift/FormatOutputFiles.swift new file mode 100644 index 00000000..c1f5be40 --- /dev/null +++ b/Sources/WebIDLToSwift/FormatOutputFiles.swift @@ -0,0 +1,14 @@ +import Foundation + +enum SwiftFormatter { + static func run() { + print("Formatting generated Swift files...") + let task = Process() + task.standardOutput = FileHandle.standardOutput + task.standardError = FileHandle.standardError + task.arguments = ["-c", "swiftformat Sources/DOMKit/WebIDL"] + task.launchPath = "/bin/zsh" + task.launch() + task.waitUntilExit() + } +} diff --git a/Sources/WebIDLToSwift/IDLBuilder.swift b/Sources/WebIDLToSwift/IDLBuilder.swift new file mode 100644 index 00000000..cfbf229a --- /dev/null +++ b/Sources/WebIDLToSwift/IDLBuilder.swift @@ -0,0 +1,148 @@ +import Foundation +import WebIDL + +enum IDLBuilder { + static let preamble = """ + // This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + + import JavaScriptKit + import JavaScriptEventLoop + \n + """ + + static let ignoredNames: Set = [ + // dictionaries that depend on types not exposed to Window environments + "BreakTokenOptions", "TrustedTypePolicyOptions", "FragmentResultOptions", + "Client_or_MessagePort_or_ServiceWorker", "ExtendableMessageEventInit", + // redundant unions + "CSSColorValue_or_CSSStyleValue", + // need types from specs not yet included + "ShadowAnimation", "MediaProvider", "Blob_or_MediaSource", + "OffscreenRenderingContext", "RenderingContext", "CanvasImageSource", + "HTMLOrSVGImageElement", "HTMLOrSVGScriptElement", "BodyInit", + // implemented manually + // ArrayBufferView + "BigInt64Array_or_BigUint64Array_or_DataView_or_Float32Array_or_Float64Array_or_Int16Array_or_Int32Array_or_Int8Array_or_Uint16Array_or_Uint32Array_or_Uint8Array_or_Uint8ClampedArray", + // RotationMatrixType + "DOMMatrix_or_Float32Array_or_Float64Array", + ] + + static let outDir = "Sources/DOMKit/WebIDL/" + static func writeFile(named name: String, content: String) throws { + let path = outDir + name + ".swift" + if FileManager.default.fileExists(atPath: path) { + fatalError("file already exists for \(name)") + } else { + try (preamble + content).write(toFile: path, atomically: true, encoding: .utf8) + } + } + + static func cleanOutputFolder() throws { + for file in try FileManager.default.contentsOfDirectory(atPath: outDir) { + try FileManager.default.removeItem(atPath: outDir + file) + } + } + + static func generateIDLBindings(idl: [GenericCollection]) throws { + let declarations = idl.flatMap(\.array) + let merged = DeclarationMerger.merge(declarations: declarations) + for (i, node) in merged.declarations.enumerated() { + guard let nameNode = Mirror(reflecting: node).children.first(where: { $0.label == "name" }), + let name = nameNode.value as? String + else { + fatalError("Cannot find name for \(node)") + } + if ignoredNames.contains(name) { + continue + } + let content = Context.withState(.root( + interfaces: merged.interfaces, + ignored: [ + // functions as parameters are unsupported + "AnimationFrameProvider": ["requestAnimationFrame"], + "AnimationWorkletGlobalScope": ["registerAnimator"], + "AudioWorkletGlobalScope": ["registerProcessor"], + "BaseAudioContext": ["decodeAudioData"], + "ComputePressureObserver": [""], + "DataTransferItem": ["getAsString"], + "FileSystemDirectoryEntry": ["getFile", "getDirectory"], + "FileSystemDirectoryReader": ["readEntries"], + "FileSystemEntry": ["getParent"], + "FileSystemFileEntry": ["file"], + "Geolocation": ["getCurrentPosition", "watchPosition"], + "HTMLCanvasElement": ["toBlob"], + "HTMLVideoElement": ["requestVideoFrameCallback"], + "IntersectionObserver": [""], + "LayoutWorkletGlobalScope": ["registerLayout"], + "LockManager": ["request"], + "MediaSession": ["setActionHandler"], + "MutationObserver": [""], + "Navigator": ["getUserMedia"], + "Notification": ["requestPermission"], + "PaintWorkletGlobalScope": ["registerPaint"], + "PerformanceObserver": [""], + "RemotePlayback": ["watchAvailability"], + "ReportingObserver": [""], + "ResizeObserver": [""], + "RTCPeerConnection": ["createOffer", "setLocalDescription", "createAnswer", "setRemoteDescription", "addIceCandidate"], + "Scheduler": ["postTask"], + "Window": ["requestIdleCallback"], + "WindowOrWorkerGlobalScope": ["queueMicrotask"], + "XRSession": ["requestAnimationFrame"], + // variadic callbacks are unsupported + "TrustedTypePolicyFactory": ["createPolicy"], + // NodeFilter + "Document": ["createNodeIterator", "createTreeWalker"], + "NodeIterator": ["filter"], + "TreeWalker": ["filter"], + // EventListener + "EventTarget": ["addEventListener", "removeEventListener"], + "MediaQueryList": ["addListener", "removeListener"], + // invalid override in Swift + "BeforeUnloadEvent": ["returnValue"], + "CSSColor": ["colorSpace"], + "SVGElement": ["className"], + "AudioBufferSourceNode": ["start"], + // XPathNSResolver + "XPathEvaluatorBase": ["createExpression", "createNSResolver", "evaluate"], + // disabled pending addition of more specs + "HTMLMediaElement": ["srcObject"], + "Blob": ["stream"], + "Body": ["body"], + ], + types: merged.types + )) { + toSwift(node).source + } + try writeFile(named: name, content: content) + } + } + + static func generateClosureTypes() throws { + let closureTypesContent: SwiftSource = """ + /* variadic generics please */ + \(lines: Context.closurePatterns.sorted().map(\.swiftRepresentation)) + """ + + try writeFile(named: "ClosureAttribute", content: closureTypesContent.source) + } + + static func generateStrings() throws { + let strings = Context.strings.sorted() + let stringsContent: SwiftSource = """ + @usableFromInline enum Strings { + static let _self: JSString = "self" + \(lines: strings.map { "@usableFromInline static let `\(raw: $0)`: JSString = \(quoted: $0)" }) + } + """ + + try writeFile(named: "Strings", content: stringsContent.source) + } + + static func generateUnions() throws { + for union in Context.unions { + guard !ignoredNames.contains(union.name) else { continue } + try writeFile(named: union.name, content: union.swiftRepresentation.source) + } + } +} diff --git a/Sources/WebIDLToSwift/IDLParser.swift b/Sources/WebIDLToSwift/IDLParser.swift new file mode 100644 index 00000000..aa409c7d --- /dev/null +++ b/Sources/WebIDLToSwift/IDLParser.swift @@ -0,0 +1,24 @@ +import Foundation +import WebIDL + +enum IDLParser { + private static func getJSONData() -> Data { + print("Fetching parsed IDL files...") + let task = Process() + let pipe = Pipe() + task.standardOutput = pipe + task.standardError = FileHandle.standardError + task.arguments = ["-c", "npm start --silent"] + task.launchPath = "/bin/zsh" + task.currentDirectoryPath = FileManager.default.currentDirectoryPath + "/parse-idl" + task.launch() + + return pipe.fileHandleForReading.readDataToEndOfFile() + } + + static func parseIDL() throws -> [GenericCollection] { + let data = getJSONData() + print("Building IDL struct tree...") + return try JSONDecoder().decode([GenericCollection].self, from: data) + } +} diff --git a/Sources/WebIDLToSwift/MergeDeclarations.swift b/Sources/WebIDLToSwift/MergeDeclarations.swift new file mode 100644 index 00000000..a58e249b --- /dev/null +++ b/Sources/WebIDLToSwift/MergeDeclarations.swift @@ -0,0 +1,242 @@ +import WebIDL + +enum DeclarationMerger { + static let ignoredTypedefs: Set = [ + "Function", + "AudioWorkletProcessorConstructor", + "CustomElementConstructor", + "ArrayBufferView", + "RotationMatrixType", + ] + static let validExposures: Set = ["Window"] + + static let ignoredParents: Set = ["LinkStyle"] + + private static func addAsync(_ members: [IDLNode]) -> [IDLNode] { + members.flatMap { member -> [IDLNode] in + if let operation = member as? IDLOperation, + case .generic("Promise", _) = operation.idlType?.value + { + return [member, AsyncOperation(operation: operation)] + } else { + return [member] + } + } + } + + static func merge(declarations: [IDLNode]) -> MergeResult { + let byType: [String: [IDLNode]] = declarations.reduce(into: [:]) { partialResult, node in + partialResult[type(of: node).type, default: []].append(node) + } + + let missedTypes = Set(declarations.map { type(of: $0).type }) + .symmetricDifference([ + IDLInterfaceMixin.type, + IDLInterface.type, + IDLDictionary.type, + IDLCallbackInterface.type, + IDLIncludes.type, + IDLEnum.type, IDLNamespace.type, + IDLTypedef.type, IDLCallback.type, + ]) + if !missedTypes.isEmpty { + print("missed types!", missedTypes) + } + // let byName: [String?: [IDLNode]] = declarations.reduce(into: [:]) { partialResult, node in + // let name = Mirror(reflecting: node).children.first { $0.label == "name" }?.value as? String + // partialResult[name, default: []].append(node) + // } + // print(byName.filter { $0.value.count > 1 }.map { "\($0.key ?? ""): \($0.value.map { type(of: $0).type }))" }.joined(separator: "\n")) + + func all(_: T.Type) -> [T] { + byType[T.type]?.map { $0 as! T } ?? [] + } + + let mixins = Dictionary( + grouping: all(IDLInterfaceMixin.self).map { + MergedMixin( + name: $0.name, + members: addAsync($0.members.array) as! [IDLInterfaceMixinMember] + ) + }, + by: \.name + ).mapValues { + $0.dropFirst().reduce(into: $0.first!) { partialResult, mixin in + partialResult.members += mixin.members + } + } + + let includes = Dictionary(grouping: all(IDLIncludes.self)) { $0.target } + .mapValues { $0.map(\.includes).filter { !Self.ignoredParents.contains($0) } } + + let mergedInterfaces = Dictionary( + grouping: all(IDLInterface.self).map { + MergedInterface( + name: $0.name, + parentClasses: [$0.inheritance] + .compactMap { $0 } + .filter { !Self.ignoredParents.contains($0) }, + members: addAsync($0.members.array) as! [IDLInterfaceMember], + exposed: Set( + $0.extAttrs + .filter { $0.name == "Exposed" } + .flatMap { $0.rhs?.identifiers ?? [] } + ), + exposedToAll: $0.extAttrs.contains { $0.name == "Exposed" && $0.rhs == .wildcard } + ) + }, + by: \.name + ).mapValues { toMerge -> MergedInterface in + var interface = toMerge.dropFirst().reduce(into: toMerge.first!) { partialResult, interface in + partialResult.parentClasses += interface.parentClasses + partialResult.members += interface.members + partialResult.exposed.formUnion(interface.exposed) + partialResult.exposedToAll = partialResult.exposedToAll || interface.exposedToAll + } + interface.mixins = includes[interface.name, default: []] + if let decl = interface.members.first(where: { $0 is IDLIterableDeclaration }) as? IDLIterableDeclaration { + interface.mixins.append(decl.async ? "AsyncSequence" : "Sequence") + } + return interface + }.filter { $0.value.exposedToAll || $0.value.exposed.contains(where: validExposures.contains) } + + let mergedDictionaries = Dictionary( + grouping: all(IDLDictionary.self).map { + MergedDictionary( + name: $0.name, + inheritance: [$0.inheritance] + .compactMap { $0 } + .filter { !Self.ignoredParents.contains($0) }, + members: $0.members + ) + }, + by: \.name + ).mapValues { toMerge -> MergedDictionary in + var dict = toMerge.dropFirst().reduce(into: toMerge.first!) { partialResult, interface in + partialResult.inheritance += interface.inheritance + partialResult.members += interface.members + } + dict.inheritance += includes[dict.name, default: []] + return dict + } + + let mergedNamespaces = Dictionary( + grouping: all(IDLNamespace.self).map { + MergedNamespace( + name: $0.name, + members: addAsync($0.members.array) as! [IDLNamespaceMember] + ) + }, + by: \.name + ).mapValues { + $0.dropFirst().reduce(into: $0.first!) { partialResult, namespace in + partialResult.members += namespace.members + } + } + + print("unhandled callback interfaces", all(IDLCallbackInterface.self).map(\.name)) + + var allTypes: [IDLTypealias] = all(IDLTypedef.self) + all(IDLCallback.self) + allTypes.removeAll(where: { ignoredTypedefs.contains($0.name) }) + let mergedTypes = Dictionary(uniqueKeysWithValues: allTypes.map { ($0.name, $0) }) + + // var unionAliases: [String: String] = [:] + // let unions = Set( + // Dictionary( + // all(IDLTypedef.self).compactMap { type -> (Set, UnionType)? in + // if case let .union(types) = type.idlType.value { + // let typeSet = Set(types.map(SlimIDLType.init)) + // return (typeSet, UnionType(types: typeSet, friendlyName: type.name)) + // } + // return nil + // }, + // uniquingKeysWith: { old, new in + // unionAliases[new.name] = old.name + // return old + // } + // ).values + // ) + + // print(unionAliases) + + let arrays: [DeclarationFile] = + Array(mergedInterfaces.values) + + Array(mergedDictionaries.values) + + Array(mixins.values) + + Array(mergedNamespaces.values) + return MergeResult( + declarations: arrays + + [Typedefs(typedefs: allTypes)] + + all(IDLEnum.self), + interfaces: mergedInterfaces, + types: mergedTypes + // unions: unions + ) + } + + struct MergeResult { + let declarations: [DeclarationFile] + let interfaces: [String: MergedInterface] + let types: [String: IDLTypealias] + // let unions: Set + } +} + +protocol DeclarationFile {} + +extension IDLEnum: DeclarationFile {} + +struct AsyncOperation: IDLNode, IDLNamespaceMember, IDLInterfaceMember, IDLInterfaceMixinMember, IDLNamed { + static var type: String { "" } + var extAttrs: [IDLExtendedAttribute] { operation.extAttrs } + var name: String { operation.name } + let operation: IDLOperation + var returnType: IDLType { + guard case let .generic("Promise", values) = operation.idlType?.value else { + print(operation) + fatalError("Return type of async function \(name) is not a Promise") + } + return values.first! + } +} + +struct MergedNamespace: DeclarationFile { + let name: String + var members: [IDLNamespaceMember] +} + +struct MergedMixin: DeclarationFile { + let name: String + var members: [IDLInterfaceMixinMember] +} + +struct MergedDictionary: DeclarationFile { + let name: String + var inheritance: [String] + var members: [IDLDictionary.Member] +} + +struct MergedInterface: DeclarationFile { + let name: String + var parentClasses: [String] + var mixins: [String] = [] + var members: [IDLInterfaceMember] + var exposed: Set + var exposedToAll: Bool +} + +struct Typedefs: DeclarationFile, SwiftRepresentable { + let name = "Typedefs" + let typedefs: [IDLTypealias] + + var swiftRepresentation: SwiftSource { + "\(lines: typedefs.filter { !DeclarationMerger.ignoredTypedefs.contains($0.name) }.map(toSwift))" + } +} + +protocol IDLTypealias: IDLNode, IDLNamed { + var idlType: IDLType { get } +} + +extension IDLCallback: IDLTypealias {} +extension IDLTypedef: IDLTypealias {} diff --git a/Sources/WebIDLToSwift/SwiftRepresentation.swift b/Sources/WebIDLToSwift/SwiftRepresentation.swift new file mode 100644 index 00000000..e7b87c09 --- /dev/null +++ b/Sources/WebIDLToSwift/SwiftRepresentation.swift @@ -0,0 +1,44 @@ +import WebIDL + +protocol SwiftRepresentable { + var swiftRepresentation: SwiftSource { get } +} + +func toSwift(_ value: T) -> SwiftSource { + if let repr = value as? SwiftRepresentable { + return repr.swiftRepresentation + } else { + let x = value as Any + fatalError("Type \(String(describing: type(of: x))) has no Swift representation") + } +} + +extension String: SwiftRepresentable { + private static let swiftKeywords: Set = [ + "as", + "break", + "class", + "continue", + "default", + "defer", + "enum", + "func", + "in", + "init", + "internal", + "is", + "operator", + "private", + "protocol", + "public", + "repeat", + "self", + "static", + "struct", + "where", + ] + + var swiftRepresentation: SwiftSource { + SwiftSource(Self.swiftKeywords.contains(self) ? "`\(self)`" : self) + } +} diff --git a/Sources/WebIDLToSwift/SwiftSource.swift b/Sources/WebIDLToSwift/SwiftSource.swift new file mode 100644 index 00000000..5237ee61 --- /dev/null +++ b/Sources/WebIDLToSwift/SwiftSource.swift @@ -0,0 +1,105 @@ +import Foundation + +struct SwiftSource: CustomStringConvertible, ExpressibleByStringInterpolation, Equatable { + let source: String + + init(_ value: String) { + source = value + } + + init(stringLiteral value: String) { + source = value + } + + init(stringInterpolation: StringInterpolation) { + source = stringInterpolation.output + } + + var description: String { + source + } + + static func raw(_ value: String) -> SwiftSource { + SwiftSource(value) + } + + struct StringInterpolation: StringInterpolationProtocol { + fileprivate var output = "" + + init(literalCapacity: Int, interpolationCount _: Int) { + output.reserveCapacity(literalCapacity * 2) + } + + mutating func appendLiteral(_ literal: String) { + output += literal + } + + mutating func appendInterpolation(raw value: String) { + output += value + } + + mutating func appendInterpolation(quoted value: String) { + output += "\"\(value)\"" + } + + mutating func appendInterpolation(_ source: SwiftSource) { + output += source.source + } + + @_disfavoredOverload + mutating func appendInterpolation(_ value: T) { + output += toSwift(value).source + } + + mutating func appendInterpolation(sequence values: [SwiftSource]) { + output += values.map(\.source).joined(separator: ", ") + } + + mutating func appendInterpolation(lines values: [SwiftSource]) { + output += values.map(\.source).joined(separator: "\n") + } + + mutating func appendInterpolation(state: Context.State, _ value: T) { + Context.withState(state) { + output += toSwift(value).source + } + } + } +} + +extension Array where Element == SwiftSource { + func joined(separator: String) -> SwiftSource { + SwiftSource(map(\.source).joined(separator: separator)) + } +} + +extension SwiftSource: SwiftRepresentable { + var swiftRepresentation: SwiftSource { + self + } +} + +extension String { + var camelized: String { + guard !isEmpty else { return "_empty" } + + let parts = components(separatedBy: CharacterSet.alphanumerics.inverted) + let first = parts.first!.lowercasingFirst + let rest = parts.dropFirst().map(\.uppercasingFirst) + + let result = ([first] + rest).joined() + if result.first!.isNumber { + return "_" + result + } else { + return result + } + } + + private var uppercasingFirst: String { + prefix(1).uppercased() + dropFirst() + } + + private var lowercasingFirst: String { + prefix(1).lowercased() + dropFirst() + } +} diff --git a/Sources/WebIDLToSwift/UnionType+SwiftRepresentable.swift b/Sources/WebIDLToSwift/UnionType+SwiftRepresentable.swift new file mode 100644 index 00000000..9624df68 --- /dev/null +++ b/Sources/WebIDLToSwift/UnionType+SwiftRepresentable.swift @@ -0,0 +1,213 @@ +import Foundation +import WebIDL + +extension String { + var lowerCamelCased: String { + let prefix = prefix(while: \.isUppercase) + if prefix.count <= 1 { + return prefix.lowercased() + dropFirst(prefix.count) + } else { + return prefix.dropLast().lowercased() + dropFirst(prefix.count - 1) + } + } +} + +extension UnionType: SwiftRepresentable { + var sortedTypes: [SlimIDLType] { + types.sorted(by: { $0.inlineTypeName < $1.inlineTypeName }) + } + + var name: String { + friendlyName ?? defaultName + } + + var sortedNames: [String] { + sortedTypes.map(\.inlineTypeName.lowerCamelCased) + } + + var swiftRepresentation: SwiftSource { + """ + public protocol Any_\(name): ConvertibleToJSValue {} + \(lines: extensions) + + public enum \(name): JSValueCompatible, Any_\(name) { + \(lines: cases) + + \(lines: accessors) + + public static func construct(from value: JSValue) -> Self? { + \(lines: constructors) + return nil + } + + public var jsValue: JSValue { + switch self { + \(lines: exporters) + } + } + } + """ + } + + var extensions: [SwiftSource] { + sortedTypes.map { + "extension \($0.typeName): Any_\(name) \($0.whereClause) {}" + } + } + + var cases: [SwiftSource] { + zip(sortedTypes, sortedNames).map { type, name in + "case \(name)(\(type))" + } + } + + var accessors: [SwiftSource] { + zip(sortedTypes, sortedNames).map { type, name in + """ + var \(name): \(type)? { + switch self { + case let .\(name)(\(name)): return \(name) + default: return nil + } + } + """ + } + } + + var constructors: [SwiftSource] { + zip(sortedTypes, sortedNames).map { type, name in + """ + if let \(name): \(type) = value.fromJSValue() { + return .\(name)(\(name)) + } + """ + } + } + + var exporters: [SwiftSource] { + sortedNames.map { name in + """ + case let .\(name)(\(name)): + return \(name).jsValue + """ + } + } +} + +extension SlimIDLType: SwiftRepresentable { + var swiftRepresentation: SwiftSource { + if nullable { + return "\(value)?" + } + return "\(value)" + } + + var typeName: SwiftSource { + if nullable { + return "Optional" + } + + return "\(value.typeName)" + } + + var whereClause: SwiftSource { + if whereClauses.isEmpty { + return "" + } + return "where \(sequence: whereClauses)" + } + + private var whereClauses: [SwiftSource] { + if nullable { + return ["Wrapped == \(value)"] + } + switch value { + case let .generic(name, args: args): + switch name { + case "sequence": + return ["Element == \(args[0])"] + case "FrozenArray", "ObservableArray": + // ??? + return ["Element == \(args[0])"] + case "Promise": + return [] + case "record": + return ["Key == \(args[0])", "Value == \(args[1])"] + default: + fatalError("Unsupported generic type: \(name)") + } + case .single: + return [] + case .union: + fatalError("Union types cannot be used directly") + } + } +} + +extension SlimIDLType.TypeValue: SwiftRepresentable { + var typeName: SwiftSource { + switch self { + case let .generic(name, _): + switch name { + case "sequence": + return "Array" + case "FrozenArray", "ObservableArray": + // ??? + return "Array" + case "Promise": + return "JSPromise" + case "record": + return "Dictionary" + default: + fatalError("Unsupported generic type: \(name)") + } + case let .single(name): + if let typeName = IDLType.typeNameMap[name] { + return "\(typeName)" + } else { + if name == name.lowercased() { + fatalError("Unsupported type: \(name)") + } + return "\(name)" + } + case let .union(types): + return "\(unionName(types: types))" + } + } + + var swiftRepresentation: SwiftSource { + switch self { + case let .generic(name, args: args): + switch name { + case "sequence": + return "[\(args[0])]" + case "FrozenArray", "ObservableArray": + // ??? + return "[\(args[0])]" + case "Promise": + return "JSPromise" + case "record": + return "[\(args[0]): \(args[1])]" + default: + fatalError("Unsupported generic type: \(name)") + } + case let .single(name): + if let typeName = IDLType.typeNameMap[name] { + return "\(typeName)" + } else { + if name == name.lowercased() { + fatalError("Unsupported type: \(name)") + } + return "\(name)" + } + case let .union(types): + return "\(unionName(types: types))" + } + } +} + +func unionName(types: Set) -> String { + let union = Context.unions.first(where: { $0.types == types }) ?? UnionType(types: types) + Context.unions.insert(union) + return union.name +} diff --git a/Sources/WebIDLToSwift/UnionType.swift b/Sources/WebIDLToSwift/UnionType.swift new file mode 100644 index 00000000..430dd7db --- /dev/null +++ b/Sources/WebIDLToSwift/UnionType.swift @@ -0,0 +1,98 @@ +import WebIDL + +class UnionType: Hashable, Equatable { + let types: Set + var friendlyName: String? + let defaultName: String + + init(types: Set, friendlyName: String? = nil) { + self.types = types + self.friendlyName = friendlyName + defaultName = types.map(\.inlineTypeName).sorted().joined(separator: "_or_") + } + + func hash(into hasher: inout Hasher) { + hasher.combine(defaultName) + } + + static func == (lhs: UnionType, rhs: UnionType) -> Bool { + lhs.types == rhs.types + } +} + +struct SlimIDLType: Hashable, Encodable { + let value: TypeValue + let nullable: Bool + let inlineTypeName: String + + func hash(into hasher: inout Hasher) { + hasher.combine(inlineTypeName) + } + + static func == (lhs: SlimIDLType, rhs: SlimIDLType) -> Bool { + lhs.inlineTypeName == rhs.inlineTypeName + } + + init(_ type: IDLType) { + let value = TypeValue(type.value) + self.value = value + nullable = type.nullable + + if type.nullable { + inlineTypeName = "nullable_\(value.inlineTypeName)" + } else { + inlineTypeName = value.inlineTypeName + } + } + + enum TypeValue: Encodable { + case generic(String, args: [SlimIDLType]) + case single(String) + case union(Set) + + init(_ value: IDLType.TypeValue) { + switch value { + case let .generic(name, args): + self = .generic(name, args: args.map(SlimIDLType.init)) + case let .single(name): + self = .single(name) + case let .union(types): + let slimmed = Set(types.map(SlimIDLType.init)) + self = .union(slimmed) + Context.unions.insert(UnionType(types: slimmed)) + } + } + } +} + +extension SlimIDLType.TypeValue { + var inlineTypeName: String { + switch self { + case let .generic(name, args): + switch name { + case "sequence": + return "seq_of_\(args[0].inlineTypeName)" + case "FrozenArray", "ObservableArray": + // ??? + return "\(name)_of_\(args[0].inlineTypeName)" + case "Promise": + return "JSPromise" + case "record": + return "record_\(args[0].inlineTypeName)_to_\(args[1].inlineTypeName)" + default: + fatalError("Unsupported generic type: \(name)") + } + case let .single(name): + if let typeName = IDLType.typeNameMap[name] { + return "\(typeName)" + } else { + if name == name.lowercased() { + fatalError("Unsupported type: \(name)") + } + return "\(name)" + } + case let .union(types): + return unionName(types: types) + } + } +} diff --git a/Sources/WebIDLToSwift/WebIDL+SwiftRepresentation.swift b/Sources/WebIDLToSwift/WebIDL+SwiftRepresentation.swift new file mode 100644 index 00000000..0a5c4005 --- /dev/null +++ b/Sources/WebIDLToSwift/WebIDL+SwiftRepresentation.swift @@ -0,0 +1,680 @@ +import WebIDL + +extension IDLArgument: SwiftRepresentable { + var swiftRepresentation: SwiftSource { + let type: SwiftSource = variadic ? "\(idlType)..." : "\(idlType)" + if optional { + if idlType.nullable { + return "\(name): \(type) = nil" + } else { + return "\(name): \(type)? = nil" + } + } else { + return "\(name): \(type)" + } + } +} + +extension IDLAttribute: SwiftRepresentable, Initializable { + private var wrapperName: SwiftSource { + "_\(raw: name)" + } + + var swiftRepresentation: SwiftSource { + if Context.ignored[Context.className.source]?.contains(name) ?? false { + return """ + // XXX: attribute '\(name)' is ignored + """ + } + if Context.override { + assert(!Context.static) + // can't do property wrappers on override declarations + return """ + @usableFromInline let \(wrapperName): \(idlType.propertyWrapper(readonly: readonly))<\(idlType)> + @inlinable override public var \(name): \(idlType) { + get { \(wrapperName).wrappedValue } + \(readonly ? "" : "set { \(wrapperName).wrappedValue = newValue }") + } + """ + } else if Context.constructor == nil || Context.static { + // can't do property wrappers on extensions + let setter: SwiftSource = """ + nonmutating set { \(idlType.propertyWrapper(readonly: readonly))[\(Context.source(for: name)), in: jsObject] = newValue } + """ + + return """ + @inlinable public\(raw: Context.static ? " static" : "") var \(name): \(idlType) { + get { \(idlType.propertyWrapper(readonly: readonly))[\(Context.source(for: name)), in: jsObject] } + \(readonly ? "" : setter) + } + """ + } else { + return """ + @\(idlType.propertyWrapper(readonly: readonly)) + public var \(name): \(idlType) + """ + } + } + + var initializer: SwiftSource? { + assert(!Context.static) + return """ + \(wrapperName) = \(idlType.propertyWrapper(readonly: readonly))(jsObject: jsObject, name: \(Context.source(for: name))) + """ + } +} + +extension MergedDictionary: SwiftRepresentable { + var swiftRepresentation: SwiftSource { + """ + public class \(name): BridgedDictionary { + \(swiftInit) + \(swiftMembers.joined(separator: "\n\n")) + } + """ + } + + private var membersWithPropertyWrapper: [(IDLDictionary.Member, SwiftSource)] { + members.map { + ($0, $0.idlType.propertyWrapper(readonly: false)) + } + } + + private var swiftInit: SwiftSource { + let params: [SwiftSource] = members.map { + "\($0.name): \($0.idlType.isFunction ? "@escaping " : "")\($0.idlType)" + } + return """ + public convenience init(\(sequence: params)) { + let object = JSObject.global[\(Context.source(for: "Object"))].function!.new() + \(lines: membersWithPropertyWrapper.map { member, wrapper in + if member.idlType.isFunction { + return """ + \(wrapper)[\(Context.source(for: member.name)), in: object] = \(member.name) + """ + } else { + return """ + object[\(Context.source(for: member.name))] = \(member.name).jsValue + """ + } + }) + self.init(unsafelyWrapping: object) + } + + public required init(unsafelyWrapping object: JSObject) { + \(lines: membersWithPropertyWrapper.map { member, wrapper in + "_\(raw: member.name) = \(wrapper)(jsObject: object, name: \(Context.source(for: member.name)))" + }) + super.init(unsafelyWrapping: object) + } + """ + } + + private var swiftMembers: [SwiftSource] { + membersWithPropertyWrapper.map { member, wrapper in + """ + @\(wrapper) + public var \(member.name): \(member.idlType) + """ + } + } +} + +extension IDLEnum: SwiftRepresentable { + var swiftRepresentation: SwiftSource { + """ + public enum \(name): JSString, JSValueCompatible { + \(lines: cases.map { "case \($0.camelized) = \(quoted: $0)" }) + + @inlinable public static func construct(from jsValue: JSValue) -> Self? { + if let string = jsValue.jsString { + return Self(rawValue: string) + } + return nil + } + + @inlinable public init?(string: String) { + self.init(rawValue: JSString(string)) + } + + @inlinable public var jsValue: JSValue { rawValue.jsValue } + } + """ + } +} + +extension IDLCallback: SwiftRepresentable { + var swiftRepresentation: SwiftSource { + let isVoid = idlType.swiftRepresentation == "Void" + Context.closurePatterns.insert(ClosurePattern(nullable: false, void: isVoid, argCount: arguments.count)) + Context.closurePatterns.insert(ClosurePattern(nullable: true, void: isVoid, argCount: arguments.count)) + return """ + public typealias \(name) = (\(sequence: arguments.map { + "\($0.idlType)\($0.variadic ? "..." : "")" + })) -> \(idlType) + """ + } +} + +extension IDLCallbackInterface: SwiftRepresentable { + var swiftRepresentation: SwiftSource { + "// XXX: unsupported callback interface: \(name)" + } +} + +protocol Initializable { + var initializer: SwiftSource? { get } +} + +extension MergedInterface: SwiftRepresentable { + var swiftRepresentation: SwiftSource { + let constructor: SwiftSource = "JSObject.global[\(Context.source(for: name))].function!" + let body = Context.withState(.instance(constructor: constructor, this: "jsObject", className: "\(name)")) { + members.map { member in + let isOverride: Bool + if let memberName = (member as? IDLNamed)?.name { + if Context.ignored[name]?.contains(memberName) ?? false { + return "// XXX: member '\(memberName)' is ignored" + } + isOverride = parentClasses.flatMap { + Context.interfaces[$0]?.members ?? [] + }.contains { + memberName == ($0 as? IDLNamed)?.name + } + } else { + isOverride = false + } + return Context.withState(.override(isOverride)) { + toSwift(member) + } + }.joined(separator: "\n\n") + } + + let inheritance = (parentClasses.isEmpty ? ["JSBridgedClass"] : parentClasses) + mixins + return """ + public class \(name): \(sequence: inheritance.map(SwiftSource.init(_:))) { + @inlinable public\(parentClasses.isEmpty ? "" : " override") class var constructor: JSFunction { \(constructor) } + + \(parentClasses.isEmpty ? "public let jsObject: JSObject" : "") + + public required init(unsafelyWrapping jsObject: JSObject) { + \(memberInits.joined(separator: "\n")) + \(parentClasses.isEmpty ? "self.jsObject = jsObject" : "super.init(unsafelyWrapping: jsObject)") + } + + \(body) + } + """ + } + + var memberInits: [SwiftSource] { + members.filter { member in + if let ignored = Context.ignored[name], + let memberName = (member as? IDLNamed)?.name + { + return !ignored.contains(memberName) + } else { + return true + } + }.compactMap { + if let alt = $0 as? Initializable { + return alt.initializer + } else { + fatalError("Add Initializable conformance to \(Swift.type(of: $0))") + } + } + } +} + +extension IDLMapLikeDeclaration: SwiftRepresentable, Initializable { + var swiftRepresentation: SwiftSource { + "// XXX: make me Map-like!" + } + + var initializer: SwiftSource? { nil } +} + +extension IDLSetLikeDeclaration: SwiftRepresentable, Initializable { + var swiftRepresentation: SwiftSource { + "// XXX: make me Set-like!" + } + + var initializer: SwiftSource? { nil } +} + +extension MergedMixin: SwiftRepresentable { + var swiftRepresentation: SwiftSource { + Context.withState(.instance(constructor: nil, this: "jsObject", className: "\(name)", inProtocol: true)) { + """ + public protocol \(name): JSBridgedClass {} + public extension \(name) { + \(members.map(toSwift).joined(separator: "\n\n")) + } + """ + } + } +} + +extension IDLConstant: SwiftRepresentable, Initializable { + var swiftRepresentation: SwiftSource { + if Context.inProtocol { + // Static stored properties not supported in protocol extensions + return """ + @inlinable public static var \(name): \(idlType) { \(value) } + """ + } else { + return """ + public static let \(name): \(idlType) = \(value) + """ + } + } + + var initializer: SwiftSource? { nil } +} + +extension IDLConstructor: SwiftRepresentable, Initializable { + var swiftRepresentation: SwiftSource { + assert(!Context.static) + assert(arguments.dropLast().allSatisfy { !$0.variadic }) + if Context.ignored[Context.className.source]?.contains("") ?? false { + return "// XXX: constructor is ignored" + } + let args: [SwiftSource] = arguments.map { + "\($0.name)\($0.optional ? "?" : "").jsValue \($0.optional ? " ?? .undefined" : "")" + } + let argsArray: SwiftSource + if let last = arguments.last, last.variadic { + // TODO: handle optional variadics (if necessary?) + let variadic: SwiftSource = "\(last.name).map(\\.jsValue)" + if args.count == 1 { + argsArray = variadic + } else { + argsArray = "[\(sequence: args.dropLast())] + \(variadic)" + } + } else { + argsArray = "[\(sequence: args)]" + } + return """ + @inlinable public convenience init(\(sequence: arguments.map(\.swiftRepresentation))) { + self.init(unsafelyWrapping: Self.constructor.new(arguments: \(argsArray))) + } + """ + } + + var initializer: SwiftSource? { nil } +} + +extension IDLIterableDeclaration: SwiftRepresentable, Initializable { + var swiftRepresentation: SwiftSource { + if async { + return """ + public typealias Element = \(idlType[0]) + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + public func makeAsyncIterator() -> ValueIterableAsyncIterator<\(Context.className)> { + ValueIterableAsyncIterator(sequence: self) + } + """ + } else { + return """ + public typealias Element = \(idlType[0]) + public func makeIterator() -> ValueIterableIterator<\(Context.className)> { + ValueIterableIterator(sequence: self) + } + """ + } + } + + var initializer: SwiftSource? { nil } +} + +extension MergedNamespace: SwiftRepresentable { + var swiftRepresentation: SwiftSource { + let this: SwiftSource = "JSObject.global[\(Context.source(for: name))].object!" + let body = Context.withState(.static(this: this, inClass: false, className: "\(name)")) { + members.map(toSwift).joined(separator: "\n\n") + } + return """ + public enum \(name) { + @inlinable public static var jsObject: JSObject { + \(this) + } + + \(body) + } + """ + } +} + +extension IDLOperation: SwiftRepresentable, Initializable { + var swiftRepresentation: SwiftSource { + if Context.ignored[Context.className.source]?.contains(name) ?? false { + return """ + // XXX: method '\(name)' is ignored + """ + } + if special.isEmpty { + return defaultRepresentation + } else { + assert(!Context.static) + switch special { + case "stringifier": + return """ + @inlinable public var description: String { + \(Context.this)[Strings.toString]!().fromJSValue()! + } + """ + case "static": + return Context.withState(.static(this: "constructor", className: Context.className)) { + defaultRepresentation + } + case "getter": + var keyType = toSwift(arguments[0].idlType) + if keyType == "UInt32" { + keyType = "Int" + } + return """ + @inlinable public subscript(key: \(keyType)) -> \(idlType!) { + jsObject[key].fromJSValue()\(idlType!.nullable ? "" : "!") + } + """ + case "setter": + return "// XXX: unsupported setter for keys of type \(arguments[0].idlType)" + case "deleter": + return "// XXX: unsupported deleter for keys of type \(arguments[0].idlType)" + default: + fatalError("Unsupported special operation \(special)") + } + } + } + + fileprivate var defaultBody: (prep: SwiftSource, call: SwiftSource) { + let args: [SwiftSource] + let prep: [SwiftSource] + assert(arguments.dropLast().allSatisfy { !$0.variadic }) + if arguments.count <= 5 { + args = arguments.map { arg in + if arg.optional { + return "\(arg.name)?.jsValue ?? .undefined" + } else { + return "\(arg.name).jsValue" + } + } + prep = [] + } else { + args = (0 ..< arguments.count).map { "_arg\(String($0))" } + prep = arguments.enumerated().map { i, arg in + if arg.optional { + return "let _arg\(String(i)) = \(arg.name)?.jsValue ?? .undefined" + } else { + return "let _arg\(String(i)) = \(arg.name).jsValue" + } + } + } + + let argsArray: SwiftSource + if let last = arguments.last, last.variadic { + // TODO: handle optional variadics (if necessary?) + let variadic: SwiftSource = "\(last.name).map(\\.jsValue)" + if args.count == 1 { + argsArray = variadic + } else { + argsArray = "[\(sequence: args.dropLast())] + \(variadic)" + } + } else { + argsArray = "[\(sequence: args)]" + } + + let function: SwiftSource = "this[\(Context.source(for: name))].function!" + return ( + prep: """ + \(lines: prep) + let this = \(Context.this) + """, + call: "\(function)(this: this, arguments: \(argsArray))" + ) + } + + fileprivate var nameAndParams: SwiftSource { + let accessModifier: SwiftSource = Context.static ? (Context.inClass ? " class" : " static") : "" + let overrideModifier: SwiftSource = Context.override ? "override " : "" + return """ + \(overrideModifier)public\(accessModifier) func \(name)(\(sequence: arguments.map(\.swiftRepresentation))) + """ + } + + private var defaultRepresentation: SwiftSource { + var returnType = idlType!.swiftRepresentation + if returnType == Context.className { + returnType = "Self" + } + if Context.override, Context.static { + return """ + // XXX: illegal static override + // \(nameAndParams) -> \(returnType) + """ + } + + let (prep, call) = defaultBody + + let body: SwiftSource + if idlType?.swiftRepresentation.source == "Void" { + body = "_ = \(call)" + } else { + body = "return \(call).fromJSValue()!" + } + + return """ + @inlinable \(nameAndParams) -> \(returnType) { + \(prep) + \(body) + } + """ + } + + var initializer: SwiftSource? { nil } +} + +extension AsyncOperation: SwiftRepresentable, Initializable { + var swiftRepresentation: SwiftSource { + if Context.ignored[Context.className.source]?.contains(name) ?? false { + // covered by non-async operation + return "" + } + switch operation.special { + case "static": + return Context.withState(.static(this: "constructor", className: Context.className)) { + defaultRepresentation + } + case "": + return defaultRepresentation + default: + fatalError("Unexpected special async operation of type \(operation.special)") + } + } + + var defaultRepresentation: SwiftSource { + if Context.override, Context.static || operation.special == "static" { + return """ + // XXX: illegal static override + // \(operation.nameAndParams) async -> \(returnType) + """ + } + + let (prep, call) = operation.defaultBody + let result: SwiftSource + if returnType.swiftRepresentation.source == "Void" { + result = "_ = try await _promise.value" + } else { + result = "return try await _promise.value.fromJSValue()!" + } + return """ + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) + @inlinable \(operation.nameAndParams) async throws -> \(returnType) { + \(prep) + let _promise: JSPromise = \(call).fromJSValue()! + \(result) + } + """ + } + + var initializer: SwiftSource? { nil } +} + +extension IDLType: SwiftRepresentable { + static let typeNameMap = [ + "boolean": "Bool", + "any": "JSValue", + "DOMString": "String", + "USVString": "String", + "CSSOMString": "String", + "ByteString": "String", + "object": "JSObject", + "undefined": "Void", + "float": "Float", // must not be +/-.infinity or .nan + "unrestricted float": "Float", + "double": "Double", // must not be +/-.infinity or .nan + "unrestricted double": "Double", + "octet": "UInt8", + "unsigned short": "UInt16", + "unsigned long": "UInt32", + "unsigned long long": "UInt64", + "byte": "Int8", + "short": "Int16", + "long": "Int32", + "long long": "Int64", + "Function": "JSFunction", + "bigint": "__UNSUPPORTED_BIGINT__", + ] + + var swiftRepresentation: SwiftSource { + if nullable { + return "\(baseType)?" + } + return baseType + } + + var baseType: SwiftSource { + switch value { + case let .generic(name, args): + switch name { + case "sequence": + return "[\(args[0])]" + case "FrozenArray", "ObservableArray": + // ??? + return "[\(args[0])]" + case "Promise": + return "JSPromise" + case "record": + return "[\(args[0]): \(args[1])]" + default: + fatalError("Unsupported generic type: \(name)") + } + case let .single(name): + if let typeName = Self.typeNameMap[name] { + return "\(typeName)" + } else { + if name == name.lowercased() { + fatalError("Unsupported type: \(name)") + } + return "\(name)" + } + case let .union(types): + if types.count == 2, + case .single("undefined") = types[1].value + { + return "\(types[0])?" + } + return "\(unionName(types: Set(types.map(SlimIDLType.init))))" + } + } + + var isFunction: Bool { + if case let .single(name) = value { + if Context.types[name] is IDLCallback { + return true + } + if let ref = Context.types[name] as? IDLTypedef, + case let .single(name) = ref.idlType.value, + Context.types[name] is IDLCallback + { + assert(ref.idlType.nullable) + return true + } + } + return false + } + + func propertyWrapper(readonly: Bool) -> SwiftSource { + // TODO: handle readonly closure properties + // (should they be a JSFunction? or a closure? or something else?)) + if case let .single(name) = value { + let readonlyComment: SwiftSource = readonly ? " /* XXX: should be readonly! */ " : "" + if let callback = Context.types[name] as? IDLCallback { + return "\(closureWrapper(callback, optional: false))\(readonlyComment)" + } + if let ref = Context.types[name] as? IDLTypedef, + case let .single(name) = ref.idlType.value, + let callback = Context.types[name] as? IDLCallback + { + assert(ref.idlType.nullable) + return "\(closureWrapper(callback, optional: true))\(readonlyComment)" + } + } + + if readonly { + return "ReadonlyAttribute" + } else { + return "ReadWriteAttribute" + } + } + + private func closureWrapper(_ callback: IDLCallback, optional: Bool) -> SwiftSource { + let void: SwiftSource = callback.idlType.swiftRepresentation == "Void" ? "Void" : "" + let optional: SwiftSource = optional ? "Optional" : "" + let argCount = String(callback.arguments.count) + return "ClosureAttribute\(argCount)\(optional)\(void)" + } +} + +extension IDLTypedef: SwiftRepresentable { + var swiftRepresentation: SwiftSource { + if case let .union(types) = idlType.value { + let typeSet = Set(types.map(SlimIDLType.init)) + if let existing = Context.unions.first(where: { $0.types == typeSet }) { + if let existingName = existing.friendlyName { + return "public typealias \(name) = \(existingName)" + } else { + existing.friendlyName = name + return "" + } + } else { + Context.unions.insert(UnionType(types: typeSet, friendlyName: name)) + return "" + } + } + return "public typealias \(name) = \(idlType)" + } +} + +extension IDLValue: SwiftRepresentable { + var swiftRepresentation: SwiftSource { + switch self { + case let .string(value): + return .raw(value) + case let .number(value): + return .raw(value) + case let .boolean(value): + return "\(value)" + case .null: + fatalError("`null` is not supported as a value in Swift") + case let .infinity(negative): + return negative ? "-.infinity" : ".infinity" + case .nan: + return ".nan" + case .sequence: + return "[]" + case .dictionary: + return "[:]" + } + } +} diff --git a/Sources/WebIDLToSwift/main.swift b/Sources/WebIDLToSwift/main.swift new file mode 100644 index 00000000..734959a4 --- /dev/null +++ b/Sources/WebIDLToSwift/main.swift @@ -0,0 +1,51 @@ +import Foundation +import WebIDL + +main() + +func main() { + do { + let startTime = Date() + let idl = try IDLParser.parseIDL() + print("Removing old files...") + try IDLBuilder.cleanOutputFolder() + print("Generating bindings...") + try IDLBuilder.generateIDLBindings(idl: idl) + print("Generating closure property wrappers...") + try IDLBuilder.generateClosureTypes() + print("Generating JSString constants...") + try IDLBuilder.generateStrings() + print("Generating union protocols...") + try IDLBuilder.generateUnions() + SwiftFormatter.run() + print("Done in \(Int(Date().timeIntervalSince(startTime) * 1000))ms.") + } catch { + handleDecodingError(error) + } +} + +private func handleDecodingError(_ error: Error) { + switch error as? DecodingError { + case let .dataCorrupted(ctx), let .typeMismatch(_, ctx): + debugContext(ctx) + case let .valueNotFound(type, ctx): + print("Value of type \(type) not found") + debugContext(ctx) + case let .keyNotFound(key, ctx): + print("Key \(key.stringValue) not found") + debugContext(ctx) + case nil, .some: + print(error.localizedDescription) + } + exit(1) +} + +private func debugContext(_ ctx: DecodingError.Context) { + print("Key path: \(ctx.codingPath.map { "." + $0.stringValue }.joined())") + print(ctx.debugDescription) + if let underlying = ctx.underlyingError as NSError?, + let debugDescription = underlying.userInfo["NSDebugDescription"] + { + print(debugDescription) + } +} diff --git a/parse-idl/.prettierrc.json b/parse-idl/.prettierrc.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/parse-idl/.prettierrc.json @@ -0,0 +1 @@ +{} diff --git a/parse-idl/package-lock.json b/parse-idl/package-lock.json new file mode 100644 index 00000000..d4a7c019 --- /dev/null +++ b/parse-idl/package-lock.json @@ -0,0 +1,63 @@ +{ + "name": "fetch-idl", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "@webref/idl": "^3.5.0", + "webidl2": "^24.2.1" + }, + "devDependencies": { + "prettier": "2.6.1" + } + }, + "node_modules/@webref/idl": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/@webref/idl/-/idl-3.5.0.tgz", + "integrity": "sha512-e4nMYUWVSheHbA9j2kqLAeh3mjTVxG0H4ucVbi8l5nUHWP6kKW2qYik3nHcg7HNfHCDBm+ID6ZuSY0aT9tSDIg==", + "peerDependencies": { + "webidl2": "^24.2.1" + } + }, + "node_modules/prettier": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.6.1.tgz", + "integrity": "sha512-8UVbTBYGwN37Bs9LERmxCPjdvPxlEowx2urIL6urHzdb3SDq4B/Z6xLFCblrSnE4iKWcS6ziJ3aOYrc1kz/E2A==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/webidl2": { + "version": "24.2.1", + "resolved": "https://registry.npmjs.org/webidl2/-/webidl2-24.2.1.tgz", + "integrity": "sha512-1jod69oNcC9BnFt3dgL5te+erImZqji1FCnJStIYOGK+fFrjVc03PGJrcJrhIUVJDIb/KyUNWy+xXIGQnAvQRA==" + } + }, + "dependencies": { + "@webref/idl": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/@webref/idl/-/idl-3.5.0.tgz", + "integrity": "sha512-e4nMYUWVSheHbA9j2kqLAeh3mjTVxG0H4ucVbi8l5nUHWP6kKW2qYik3nHcg7HNfHCDBm+ID6ZuSY0aT9tSDIg==", + "requires": {} + }, + "prettier": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.6.1.tgz", + "integrity": "sha512-8UVbTBYGwN37Bs9LERmxCPjdvPxlEowx2urIL6urHzdb3SDq4B/Z6xLFCblrSnE4iKWcS6ziJ3aOYrc1kz/E2A==", + "dev": true + }, + "webidl2": { + "version": "24.2.1", + "resolved": "https://registry.npmjs.org/webidl2/-/webidl2-24.2.1.tgz", + "integrity": "sha512-1jod69oNcC9BnFt3dgL5te+erImZqji1FCnJStIYOGK+fFrjVc03PGJrcJrhIUVJDIb/KyUNWy+xXIGQnAvQRA==" + } + } +} diff --git a/parse-idl/package.json b/parse-idl/package.json new file mode 100644 index 00000000..0ee60740 --- /dev/null +++ b/parse-idl/package.json @@ -0,0 +1,14 @@ +{ + "private": true, + "type": "module", + "scripts": { + "start": "node parse-all.js" + }, + "devDependencies": { + "prettier": "2.6.1" + }, + "dependencies": { + "@webref/idl": "^3.5.0", + "webidl2": "^24.2.1" + } +} diff --git a/parse-idl/parse-all.js b/parse-idl/parse-all.js new file mode 100644 index 00000000..de36842c --- /dev/null +++ b/parse-idl/parse-all.js @@ -0,0 +1,28 @@ +import { parseAll } from "@webref/idl"; +import fs from "node:fs/promises"; + +const parsedFiles = await parseAll(); +// console.log(Object.keys(parsedFiles).join('\n')) +// console.log(JSON.stringify(Object.values(parsedFiles), null, 2)); +console.log( + JSON.stringify( + [ + "dom", + "fetch", + "FileAPI", + "html", + "geometry", + "hr-time", + "referrer-policy", + "uievents", + "wai-aria", + "webidl", + "web-animations", + "xhr", + "service-workers", + "url", + ].map((key) => parsedFiles[key]), + null, + 2 + ) +);