diff --git a/Sources/JavaScriptKit/JSValueConvertible.swift b/Sources/JavaScriptKit/JSValueConvertible.swift index d7edcb1d..d324877c 100644 --- a/Sources/JavaScriptKit/JSValueConvertible.swift +++ b/Sources/JavaScriptKit/JSValueConvertible.swift @@ -23,17 +23,19 @@ public protocol JSValueConvertible { public typealias JSValueCodable = JSValueConvertible & JSValueConstructible -extension JSBridgedType { - public static func canDecode(from jsValue: JSValue) -> Bool { - jsValue.isInstanceOf(Self.classRef) - } - +extension JSAbstractBridgedType { public init(jsValue: JSValue) { self.init(objectRef: jsValue.object!) } public func jsValue() -> JSValue { - return JSValue.object(objectRef) + .object(objectRef) + } +} + +extension JSBridgedType { + public static func canDecode(from jsValue: JSValue) -> Bool { + jsValue.isInstanceOf(Self.classRef) } } diff --git a/Sources/JavaScriptKit/Support.swift b/Sources/JavaScriptKit/Support.swift index 9b516999..1993afc1 100644 --- a/Sources/JavaScriptKit/Support.swift +++ b/Sources/JavaScriptKit/Support.swift @@ -45,7 +45,7 @@ public struct AnyJSValueCodable: JSValueCodable, ExpressibleByNilLiteral { } } -public func staticCast(_ ref: JSBridgedType) -> Type { +public func staticCast(_ ref: JSAbstractBridgedType) -> Type { return Type(objectRef: ref.objectRef) }