4
4
5
5
import JavaScriptKit
6
6
7
- public class Promise < Type> : JSBridgedClass {
7
+ public class Global {
8
+ public let jsObject = JSObject . global
9
+ public let document : Document
8
10
9
- public static var constructor : JSFunction { JSObject . global. Promise. function! }
10
-
11
- public let jsObject : JSObject
11
+ init ( ) {
12
+ document = Document ( unsafelyWrapping: jsObject. document. object!)
13
+ }
14
+ }
12
15
13
- public required init ( unsafelyWrapping jsObject: JSObject ) {
16
+ public extension Document {
17
+ var body : HTMLElement {
18
+ . init( unsafelyWrapping: jsObject. body. object!)
19
+ }
20
+ }
14
21
15
- self . jsObject = jsObject
22
+ public extension HTMLElement {
23
+ convenience init ? ( from element: Element ) {
24
+ self . init ( from: . object( element. jsObject) )
16
25
}
17
26
}
18
27
28
+ public let global = Global ( )
29
+
19
30
public class ReadableStream : JSBridgedClass {
20
31
21
32
public static var constructor : JSFunction { JSObject . global. ReadableStream. function! }
@@ -32,7 +43,7 @@ public class ReadableStream: JSBridgedClass {
32
43
}
33
44
}
34
45
35
- @propertyWrapper public struct ClosureHandler < ArgumentType: JSValueCodable , ReturnType: JSValueCodable > {
46
+ @propertyWrapper public struct ClosureHandler < ArgumentType: JSValueCompatible , ReturnType: JSValueCompatible > {
36
47
37
48
let jsObject : JSObject
38
49
let name : String
@@ -52,7 +63,7 @@ public class ReadableStream: JSBridgedClass {
52
63
}
53
64
}
54
65
55
- @propertyWrapper public struct OptionalClosureHandler < ArgumentType: JSValueCodable , ReturnType: JSValueCodable > {
66
+ @propertyWrapper public struct OptionalClosureHandler < ArgumentType: JSValueCompatible , ReturnType: JSValueCompatible > {
56
67
57
68
let jsObject : JSObject
58
69
let name : String
@@ -79,7 +90,7 @@ public class ReadableStream: JSBridgedClass {
79
90
}
80
91
}
81
92
82
- @propertyWrapper public struct ReadWriteAttribute < Wrapped: JSValueCodable > {
93
+ @propertyWrapper public struct ReadWriteAttribute < Wrapped: JSValueCompatible > {
83
94
84
95
let jsObject : JSObject
85
96
let name : String
@@ -99,7 +110,7 @@ public class ReadableStream: JSBridgedClass {
99
110
}
100
111
}
101
112
102
- @propertyWrapper public struct ReadonlyAttribute < Wrapped: JSValueConstructible > {
113
+ @propertyWrapper public struct ReadonlyAttribute < Wrapped: ConstructibleFromJSValue > {
103
114
104
115
let jsObject : JSObject
105
116
let name : String
@@ -116,7 +127,7 @@ public class ReadableStream: JSBridgedClass {
116
127
}
117
128
}
118
129
119
- public class ValueIterableIterator < SequenceType: JSBridgedClass & Sequence > : IteratorProtocol where SequenceType. Element: JSValueConstructible {
130
+ public class ValueIterableIterator < SequenceType: JSBridgedClass & Sequence > : IteratorProtocol where SequenceType. Element: ConstructibleFromJSValue {
120
131
121
132
private var index : Int = 0
122
133
private let sequence : SequenceType
@@ -142,7 +153,7 @@ public protocol KeyValueSequence: Sequence where Element == (String, Value) {
142
153
associatedtype Value
143
154
}
144
155
145
- public class PairIterableIterator < SequenceType: JSBridgedClass & KeyValueSequence > : IteratorProtocol where SequenceType. Value: JSValueConstructible {
156
+ public class PairIterableIterator < SequenceType: JSBridgedClass & KeyValueSequence > : IteratorProtocol where SequenceType. Value: ConstructibleFromJSValue {
146
157
147
158
private let iterator : JSObject
148
159
private let sequence : SequenceType
0 commit comments