Skip to content

Commit afdb8e2

Browse files
committed
Add initial sources
1 parent c16e40d commit afdb8e2

File tree

128 files changed

+6014
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+6014
-8
lines changed

Package.resolved

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

Package.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@ import PackageDescription
66
let package = Package(
77
name: "DOMKit",
88
products: [
9-
// Products define the executables and libraries a package produces, and make them visible to other packages.
109
.library(
1110
name: "DOMKit",
1211
targets: ["DOMKit"]),
1312
],
1413
dependencies: [
15-
// Dependencies declare other packages that this package depends on.
16-
// .package(url: /* package url */, from: "1.0.0"),
14+
.package(url: "https://github.com/kateinoigakukun/JavaScriptKit.git", .revision("c90e82f")),
1715
],
1816
targets: [
19-
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
20-
// Targets can depend on other targets in this package, and on products in packages this package depends on.
2117
.target(
2218
name: "DOMKit",
2319
dependencies: []),
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
/*
3+
* The following code is auto generated using webidl2swift
4+
*/
5+
6+
import ECMAScript
7+
import JavaScriptKit
8+
9+
public class AbortController: JSBridgedType {
10+
public class var classRef: JSFunctionRef { JSObjectRef.global.AbortController.function! }
11+
12+
public let objectRef: JSObjectRef
13+
14+
public required init(objectRef: JSObjectRef) {
15+
_signal = ReadonlyAttribute(objectRef: objectRef, name: "signal")
16+
self.objectRef = objectRef
17+
}
18+
19+
public convenience init() {
20+
self.init(objectRef: AbortController.classRef.new())
21+
}
22+
23+
@ReadonlyAttribute
24+
public var signal: AbortSignal
25+
26+
public func abort() {
27+
_ = objectRef.abort!()
28+
}
29+
}

Sources/DOMKit/AbortSignal.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
/*
3+
* The following code is auto generated using webidl2swift
4+
*/
5+
6+
import ECMAScript
7+
import JavaScriptKit
8+
9+
public class AbortSignal: EventTarget {
10+
override public class var classRef: JSFunctionRef { JSObjectRef.global.AbortSignal.function! }
11+
12+
public required init(objectRef: JSObjectRef) {
13+
_aborted = ReadonlyAttribute(objectRef: objectRef, name: "aborted")
14+
_onabort = OptionalClosureHandler(objectRef: objectRef, name: "onabort")
15+
super.init(objectRef: objectRef)
16+
}
17+
18+
@ReadonlyAttribute
19+
public var aborted: Bool
20+
21+
@OptionalClosureHandler
22+
public var onabort: EventHandler
23+
}

Sources/DOMKit/AbstractRange.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
/*
3+
* The following code is auto generated using webidl2swift
4+
*/
5+
6+
import ECMAScript
7+
import JavaScriptKit
8+
9+
public class AbstractRange: JSBridgedType {
10+
public class var classRef: JSFunctionRef { JSObjectRef.global.AbstractRange.function! }
11+
12+
public let objectRef: JSObjectRef
13+
14+
public required init(objectRef: JSObjectRef) {
15+
_startContainer = ReadonlyAttribute(objectRef: objectRef, name: "startContainer")
16+
_startOffset = ReadonlyAttribute(objectRef: objectRef, name: "startOffset")
17+
_endContainer = ReadonlyAttribute(objectRef: objectRef, name: "endContainer")
18+
_endOffset = ReadonlyAttribute(objectRef: objectRef, name: "endOffset")
19+
_collapsed = ReadonlyAttribute(objectRef: objectRef, name: "collapsed")
20+
self.objectRef = objectRef
21+
}
22+
23+
@ReadonlyAttribute
24+
public var startContainer: Node
25+
26+
@ReadonlyAttribute
27+
public var startOffset: UInt32
28+
29+
@ReadonlyAttribute
30+
public var endContainer: Node
31+
32+
@ReadonlyAttribute
33+
public var endOffset: UInt32
34+
35+
@ReadonlyAttribute
36+
public var collapsed: Bool
37+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
/*
3+
* The following code is auto generated using webidl2swift
4+
*/
5+
6+
import ECMAScript
7+
import JavaScriptKit
8+
9+
public struct AddEventListenerOptions: ExpressibleByDictionaryLiteral, JSValueCodable {
10+
public static func canDecode(from jsValue: JSValue) -> Bool {
11+
return jsValue.isObject
12+
}
13+
14+
public enum Key: String, Hashable {
15+
case capture, passive, once
16+
}
17+
18+
public typealias Value = AnyJSValueCodable
19+
20+
private let dictionary: [String: AnyJSValueCodable]
21+
22+
public init(uniqueKeysWithValues elements: [(Key, Value)]) {
23+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
24+
}
25+
26+
public init(dictionaryLiteral elements: (Key, AnyJSValueCodable)...) {
27+
dictionary = Dictionary(uniqueKeysWithValues: elements.map { ($0.0.rawValue, $0.1) })
28+
}
29+
30+
subscript(_ key: Key) -> AnyJSValueCodable? {
31+
dictionary[key.rawValue]
32+
}
33+
34+
public init(jsValue: JSValue) {
35+
dictionary = jsValue.fromJSValue()
36+
}
37+
38+
public func jsValue() -> JSValue {
39+
return dictionary.jsValue()
40+
}
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
/*
3+
* The following code is auto generated using webidl2swift
4+
*/
5+
6+
import ECMAScript
7+
import JavaScriptKit
8+
9+
public enum AddEventListenerOptionsOrBool: JSValueEncodable, JSValueDecodable, ExpressibleByBooleanLiteral, ExpressibleByDictionaryLiteral {
10+
public static func canDecode(from jsValue: JSValue) -> Bool {
11+
return AddEventListenerOptions.canDecode(from: jsValue) || Bool.canDecode(from: jsValue)
12+
}
13+
14+
case addEventListenerOptions(AddEventListenerOptions)
15+
case bool(Bool)
16+
17+
public init(jsValue: JSValue) {
18+
if AddEventListenerOptions.canDecode(from: jsValue) {
19+
self = .addEventListenerOptions(jsValue.fromJSValue())
20+
} else if Bool.canDecode(from: jsValue) {
21+
self = .bool(jsValue.fromJSValue())
22+
} else {
23+
fatalError()
24+
}
25+
}
26+
27+
public init(dictionaryLiteral elements: (AddEventListenerOptions.Key, AddEventListenerOptions.Value)...) {
28+
self = .addEventListenerOptions(.init(uniqueKeysWithValues: elements))
29+
}
30+
31+
public init(booleanLiteral value: Bool) {
32+
self = .bool(value)
33+
}
34+
35+
public func jsValue() -> JSValue {
36+
switch self {
37+
case let .addEventListenerOptions(v): return v.jsValue()
38+
case let .bool(v): return v.jsValue()
39+
}
40+
}
41+
}

Sources/DOMKit/AnyChildNode.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
/*
3+
* The following code is auto generated using webidl2swift
4+
*/
5+
6+
import ECMAScript
7+
import JavaScriptKit
8+
9+
class AnyChildNode: JSBridgedType, ChildNode {
10+
let objectRef: JSObjectRef
11+
12+
required init(objectRef: JSObjectRef) {
13+
self.objectRef = objectRef
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
/*
3+
* The following code is auto generated using webidl2swift
4+
*/
5+
6+
import ECMAScript
7+
import JavaScriptKit
8+
9+
class AnyDocumentAndElementEventHandlers: JSBridgedType, DocumentAndElementEventHandlers {
10+
let objectRef: JSObjectRef
11+
12+
required init(objectRef: JSObjectRef) {
13+
self.objectRef = objectRef
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
/*
3+
* The following code is auto generated using webidl2swift
4+
*/
5+
6+
import ECMAScript
7+
import JavaScriptKit
8+
9+
class AnyDocumentOrShadowRoot: JSBridgedType, DocumentOrShadowRoot {
10+
let objectRef: JSObjectRef
11+
12+
required init(objectRef: JSObjectRef) {
13+
self.objectRef = objectRef
14+
}
15+
}

0 commit comments

Comments
 (0)