Max JS API

Reference for the API available within the [js], [jsui], [v8], [v8.codebox], and [v8ui] objects

Some classes and interfaces are only available with the v8 engine. For more information, refer to the JavaScript Documentation

Globals

ItemEngineDescription
consolev8The global console instance, the Max-console-backed console object exposed by the v8 runtime.
globalThisThe "this" object in the context of JavaScript in Max. The object is the "this" within the context of any function you define that can be invoked from Max, as well as in your global code. See jsthis for more details.
Jitter3DUtilsThe global Jitter3DUtils interface, providing utility functions for 3D vector and matrix operations. See Jitter3dUtilsInterface for more details.
maxSingleton Max object to access and control the Max environment. See Max for more details. In addition to the properties and methods described here, you can also use the global Max object to call methods as defined in Controlling Max with Messages
mgraphicsThe global mgraphics instance, for rendering shapes and images in custom Max objects.
sketchThe global sketch instance, for drawing in custom Max objects with an OpenGL-backed drawing context.

Functions

ItemEngineDescription
clearImmediatev8Cancels an immediate previously created with setImmediate().
clearIntervalv8Cancels an interval previously created with setInterval().
clearTimeoutv8Cancels a timeout previously created with setTimeout().
cpostPrints a message to the system console window. See post() for more details about arguments and formatting.
errorPrints a message to the Max console with a red tint. See post() for more details about arguments and formatting.
fetchv8Fetches a resource over HTTP or HTTPS.
messnamedSends a message to the named Max object.
postPrints a representation of the arguments in the Max window.
queueMicrotaskv8Queues a microtask to run after the current task completes and before the next timer callback.
setImmediatev8Schedules a callback to run on the next scheduler tick.
setIntervalv8Schedules a callback to run repeatedly at a fixed interval.
setTimeoutv8Schedules a one-shot callback to run after a delay.

Built-In Modules

ItemEngineDescription
bufferv8The buffer module exposed by require("buffer"), providing the buffer.IOBuffer class for handling binary data.
dgramv8The dgram module exposed by require("dgram").
httpv8The http module exposed by require("http") to access HTTP/1.1 clients and servers.
This is a minimal http subset, not full Node parity.
httpsv8The https module exposed by require("https"). Mirrors http over TLS, defaulting to https: URLs.
netv8The net module exposed by require("net") providing TCP client and server sockets.
tlsv8The tls module exposed by require("tls"): TLS/SSL client and server sockets.

Classes

ItemEngineDescription
AbortControllerv8Creates an AbortSignal and the means to abort it.
AbortSignalSignals abortion to abortable operations such as fetch().
Blobv8An immutable blob of binary data with a MIME type.
BufferBind to a Max buffer~ object.
DictBind to a Max dict object.
EventSourcev8A Server-Sent Events client.
FileThe File object provides a means of reading and writing files from JavaScript.
FolderIterate through the files in a folder.
FormDatav8A multipart/form-data field set.
GlobalGlobal object for sharing data between Max JavaScript instances.
Headersv8A case-insensitive multimap of HTTP headers.
ImageBitmap image object handle
JitterListenerA listener for changes in a JitterObject.
JitterMatrixA named matrix which may be used for data storage and retrieval, resampling, and matrix type and planecount conversion operations.
JitterObjectA JavaScript representation of a Jitter object in a patcher.
LiveAPIA means of communicating with the Live API from JavaScript.
MaxArrayBind a Max array object
MaxFFTFast Fourier Transform processor
MaxFFT2DTwo-dimensional Fast Fourier Transform processor
MaxobjA JavaScript representation of a Max object in a patcher.
MaxobjListenerA listener for changes in a Maxobj object.
MaxStringBind a Max string object
MGraphicsDrawing context for rendering shapes and images.
MGraphicsSVGSVG object handle
ParameterInfoProviderProvides a list of named parameter objects within a patcher hierarchy as well as information about specific parameter objects. It can also notify when parameter objects are added or removed from a patcher hierarchy.
ParameterListenerA listener for changes in named parameters.
PatcherA JavaScript representation of a Max patcher.
PolyBufferBind to a Max polybuffer~ object.
ReadableStreamv8A byte-oriented readable stream. Used for Response.body and as a streamed request body.
Requestv8A request to be sent with fetch().
Responsev8A response returned by fetch().
Rx256Xoxhiro256+ random number generator
SketchInterface to an OpenGL-backed drawing context
SnapshotAPIProvides access to patcher snapshots.
SQLiteProvides access to the SQLite database system.
SQLResultA container for results obtained in an SQLite.exec() call.
TaskA function that can be scheduled or repeated.
TextDecoderv8Decodes UTF-8 bytes into a JavaScript string.
TextEncoderv8Encodes JavaScript strings into UTF-8 bytes.
TransformStreamv8A byte-oriented transform stream pairing a writable input with a readable output.
URLv8Parses and manipulates URLs.
URLSearchParamsv8Reads and manipulates URL query strings.
WebSocketv8A WebSocket client.
WebSocketServerv8A WebSocket server.
WritableStreamv8A byte-oriented writable stream companion for piping.
XMLHttpRequestXMLHttpRequest provides HTTP client functionality for making network requests from JavaScript in Max.

Interfaces

ItemEngineDescription
AddressInfoThe local or remote endpoint of a socket, as returned by address().
AttributeOptionsOptions accepted by the v8-only forms of declareattribute, describing how an attribute is typed, stored, and presented.
ConsoleThe Max-console-backed console object exposed by the v8 runtime. Output is routed to the Max console: log, info, and debug use normal post rows, warn uses warning rows, and error, assert, and trace use error rows.
Formatting is a pragmatic subset: string joining, Error stack/message rendering, JSON-ish object rendering with a circular fallback, and the %s, %d, %i, %f, %j, %o, %O, and %% format tokens. Full Node util.inspect, console.table, grouping, profiling, and configurable output streams are not implemented.
EventSourceMessageEventAn event delivered to an EventSource.
Jitter3dUtilsInterfaceUtilities for Jitter 3D manipulations
JitterEventThe argument passed to a JitterListener callback function.
jsthisThe "this" object in the context of JavaScript in Max
MaxInterface representing the current Max environment providing access and control.
MaxFFT2DOptionsOptions for constructing a MaxFFT2D instance.
MaxFFTOptionsOptions for constructing a MaxFFT instance.
MaxobjConnectionA JavaScript representation of a patchcord connection.
MaxobjListenerDataThe argument provided to a MaxobjListener callback function.
NetworkErrorNetworking Error
The shape of Error objects delivered to networking 'error' callbacks and promise rejections across fetch(), the net/tls/dgram modules, the http/https modules, WebSocket, and EventSource.
ParameterInfoProviderDataThe argument to the ParameterInfoProvider's callback function
ParameterListenerDataThe argument provided to a ParameterListener callback function.
PatternPattern object for drawing gradients and patterns.
PointerEventPointer event object passed to onpointer* event handlers
ProgressEventProgressEvent provides information about the progress of a network request.
ReadableStreamDefaultReaderA reader that pulls chunks from a ReadableStream.
ReadableStreamReadResultThe result of a single ReadableStreamDefaultReader.read() call.
RequestInitOptions accepted by fetch() and the Request constructor.
WebSocketCloseEventA close event delivered to a WebSocket.
WebSocketConnectionA server-side WebSocket connection accepted by a WebSocketServer.
WebSocketErrorEventAn error event delivered to a WebSocket.
WebSocketMessageEventA message event delivered to a WebSocket.
WindA property of the Patcher which represents its window.
WritableStreamDefaultWriterA writer that pushes chunks to a WritableStream.
XMLHttpRequestUploadv8The upload object of an XMLHttpRequest, exposing progress events for the request body.

Type Aliases

ItemDescription
Basic2dStrokeStyleParameterNamesStroke parameters for use with Sketch.beginstroke() in the "basic2d" drawing style
BodyInitAcceptable values for an outgoing request or response body.
DrawingPrimitiveTypePrimitive type to use for drawing shapes. See Sketch.shapeprim().
FileAccessFile access type Used with File
FileEndiannessFile endianness Used with File
FileFourCharacterCodeFour character file codes. Used with File
FileLineEndingStyleFile line ending style Used with File
HeadersInitAcceptable initializers for Headers.
Jitter3dUtilsMat16A 4x4 matrix Used with Jitter3dUtilsInterface
Jitter3dUtilsVec3A 3D vector Used with Jitter3dUtilsInterface
Jitter3dUtilsVec4A 4D vector Used with Jitter3dUtilsInterface
JitterEventTypeEvent types Possible event types for a JitterEvent
LineStrokeStyleParameterNamesStroke parameters for use with Sketch.beginstroke() in the "line" drawing style
MGraphicsMatrixHandleOpaque handle for an MGraphics transformation matrix.
MGraphicsPathHandleOpaque handle for an MGraphics path.
RequestCredentialsCredentials mode controlling cookie sending/storage for a request.
RequestRedirectRedirect-following mode for a request.