Classes
- JSArray
-
A wrapper around the JavaScript Array class that exposes its properties in a type-safe and Swifty way.
- JSArray.Iterator
- 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 example
getMonth/setMonthetc accessor methods are converted to properties, but the rest of it matches in the naming. Parts of the JavaScriptDateAPI that are not consistent across browsers and JS implementations are not exposed in a type-safe manner, you should access the underlyingjsObjectproperty 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
Promiseclass that exposes its functions in a type-safe and Swifty way. TheJSPromiseAPI is generic over bothSuccessandFailuretypes, which improves compatibility with other statically-typed APIs such as Combine. If you don't know the exact type of yourSuccessvalue, you should useJSValue, e.g.JSPromise<JSValue, JSError>. In the rare case, where you can't guarantee that the error thrown is of actual JavaScriptErrortype, you should useJSPromise<JSValue, JSValue>. - JSTimer
-
This timer is an abstraction over
setInterval/clearIntervalandsetTimeout/clearTimeoutJavaScript 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 aJSTimerinstance for it to stay valid. TheJSTimerAPI 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 theJSTimerinstance to zero. For invalidation you should either store the timer in an optional property and assignnilto 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. FIXME: the BigInt-based TypedArrays are not supported (https://github.com/swiftwasm/JavaScriptKit/issues/56)
- JSFunction
-
JSFunctionrepresents a function in JavaScript and supports new object instantiation. This type can be callable as a function usingcallAsFunction. - JSThrowingFunction
-
A
JSFunctionwrapper that enables throwing function calls. Exceptions produced by JavaScript functions will be thrown asJSValue. - JSClosure
-
JSClosurerepresents a JavaScript function the body of which is written in Swift. This type can be passed as a callback handler to JavaScript functions. Note that the lifetime ofJSClosureshould be managed by users manually due to GC boundary between Swift and JavaScript. For further discussion, see also swiftwasm/JavaScriptKit #33 - JSObject
-
JSObjectrepresents an object in JavaScript and supports dynamic member lookup. Any member access likeobject.foowill dynamically request the JavaScript and Swift runtime bridge library for a member with the specified name in this object. - JSThrowingObject
-
A
JSObjectwrapper that enables throwing method calls capturingthis. Exceptions produced by JavaScript functions will be thrown asJSValue. - JSValueDecoder
-
JSValueDecoderfacilitates the decoding of JavaScript value into semanticDecodabletypes.
Structures
- JSString
-
JSStringrepresents a string in JavaScript and supports bridging string between JavaScript and Swift.
Enumerations
- JSValue
-
JSValuerepresents 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.
- 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:)