Classes
- JavaScriptEventLoop
-
Singleton type responsible for integrating JavaScript event loop as a Swift concurrency executor, conforming to
SerialExecutor
protocol from the standard library. To utilize it: - JSArray
-
A wrapper around the JavaScript
Array
class that exposes its properties in a type-safe and Swifty way. - JSArray.Iterator
-
Iterator type for
JSArray
, conforming toIteratorProtocol
from the standard library, which allows easy iteration over elements ofJSArray
instances. - JSDate
-
A wrapper around the JavaScript
Date
class that exposes its properties in a type-safe way. This doesn't 100% match the JS API, for examplegetMonth
/setMonth
etc accessor methods are converted to properties, but the rest of it matches in the naming. Parts of the JavaScriptDate
API that are not consistent across browsers and JS implementations are not exposed in a type-safe manner, you should access the underlyingjsObject
property if you need those. - JSError
-
A wrapper around the JavaScript
Error
class that exposes its properties in a type-safe way. - JSPromise
-
A wrapper around the JavaScript
Promise
class - JSTimer
-
This timer is an abstraction over
setInterval
/clearInterval
andsetTimeout
/clearTimeout
JavaScript functions. It intentionally doesn't match the JavaScript API, as a special care is needed to hold a reference to the timer closure and to callJSClosure.release()
on it when the timer is deallocated. As a user, you have to hold a reference to aJSTimer
instance for it to stay valid. TheJSTimer
API is also intentionally trivial, the timer is started right away, and the only way to invalidate the timer is to bring the reference count of theJSTimer
instance to zero. For invalidation you should either store the timer in an optional property and assignnil
to it, or deallocate the object that owns the timer. - JSTypedArray
-
A wrapper around all JavaScript
TypedArray
classes that exposes their properties in a type-safe way. - JSUInt8ClampedArray
-
A wrapper around the JavaScript
Uint8ClampedArray
class that exposes its properties in a type-safe and Swifty way. - JSBigInt
-
A wrapper around the JavaScript
BigInt
class that exposes its properties in a type-safe and Swifty way. - JSOneshotClosure
-
JSOneshotClosure
is a JavaScript function that can be called only once. This class can be used for optimized memory management when compared to the commonJSClosure
. - JSClosure
-
JSClosure
represents a JavaScript function the body of which is written in Swift. This type can be passed as a callback handler to JavaScript functions. - JSFunction
-
JSFunction
represents a function in JavaScript and supports new object instantiation. This type can be callable as a function usingcallAsFunction
. - JSObject
-
JSObject
represents an object in JavaScript and supports dynamic member lookup. Any member access likeobject.foo
will dynamically request the JavaScript and Swift runtime bridge library for a member with the specified name in this object. - JSThrowingObject
-
A
JSObject
wrapper that enables throwing method calls capturingthis
. Exceptions produced by JavaScript functions will be thrown asJSValue
. - JSSymbol
-
A wrapper around the JavaScript
Symbol
class that exposes its properties in a type-safe and Swifty way. - JSThrowingFunction
-
A
JSFunction
wrapper that enables throwing function calls. Exceptions produced by JavaScript functions will be thrown asJSValue
. - JSValueDecoder
-
JSValueDecoder
facilitates the decoding of JavaScript value into semanticDecodable
types.
Structures
- JSString
-
JSString
represents a string in JavaScript and supports bridging string between JavaScript and Swift.
Enumerations
- JSValue
-
JSValue
represents a value in JavaScript.
Protocols
- TypedArrayElement
-
A protocol that allows a Swift numeric type to be mapped to the JavaScript TypedArray that holds integers of its type
- ConstructibleFromJSValue
-
Types conforming to this protocol can be constructed from
JSValue
. - ConvertibleToJSValue
-
Objects that can be converted to a JavaScript value, preferably in a lossless manner.
- JSBigIntExtended
- JSClosureProtocol
-
JSClosureProtocol
wraps Swift closure objects for use in JavaScript. Conforming types are responsible for managing the lifetime of the closure they wrap, but can delegate that task to the user by requiring an explicitrelease()
call. - JSBridgedType
-
Use this protocol when your type has no single JavaScript class. For example, a union type of multiple classes or primitive values.
- JSBridgedClass
-
Conform to this protocol when your Swift class wraps a JavaScript class.
Typealiases
- JSValueCompatible
- JSObjectRef
- JSArrayRef
- JSFunctionRef
- JSValueConvertible
- JSValueConstructible
- JSValueCodable
Functions
- getJSValue(this:name:)
- setJSValue(this:name:value:)
- getJSValue(this:index:)
- setJSValue(this:index:value:)
- getJSValue(this:symbol:)
- setJSValue(this:symbol:value:)
Extensions
- Array
- BinaryFloatingPoint
- Bool
- Dictionary
- Double
- Float
- Float32
- Float64
- Int
- Int16
- Int32
- Int64
- Int8
- Optional
- RawJSValue
- SignedInteger
- String
- UInt
- UInt16
- UInt32
- UInt64
- UInt8
- UnsignedInteger