import * as cav from "https://deno.land/x/cav@0.2.3/dom.ts";
Functions
f $ | Shorthand for |
f $$ | Shorthand for |
Creates a new client function for making requests to remote Cav handlers. If the type of the handler is provided and it's a Cav handler, the client will have end-to-end typesafety turned on. | |
f cx | Filters out any non-string or empty string arguments and joins the rest to create a class list for an HTML element. |
Deserializes a JSON value that was | |
Determines if the object is a plain object or not. This also checks for prototype poisoning; it returns false whenever the prototype of an input object was poisoned before JSON.parsing it. | |
f make | Creates a new DocumentFragment using the provided HTML. |
Normalizes a Parser into a ParserFunction. | |
Serializes a new Request, which can then be deserialized using
| |
Serializes a new Response, which can then be deserialized back into the input
body using | |
Serializes a value recursively until it's JSON-compatible. Serializers can be plugged in to extend the accepted types beyond what Cav supports by default. If a value isn't recognized by any of the provided or default serializers, an error will be thrown. | |
Constructs a Serializer. This simply returns the first argument, it's only used for type annotations. | |
Deserializes a Request generated with | |
Wraps a WebSocket instance with added serialization functionality and E2E type support. If the input is a string, the wrapped WebSocket will be created with the given URL. |
Interfaces
Arguments for the Client function. | |
Settings used to initialize a | |
A server endpoint handler can use this Request type to ferry type information to the client about what argument types are acceptable and what the result will be into. | |
Init options for constructing HttpErrors, which can expose arbitrary data and status codes during de/serialization. | |
Request type that tracks its content-type just like PackedResponse. | |
Response type that tracks its content-type so the | |
Initializer options when creating a Request with | |
A function that parses data. If data is not shaped as expected, an error should be thrown. | |
An object with a ParserFunction as its "parse" property. Zod compatible. | |
A server router handler can use this Request type to ferry type information to the client about what routes exist and what data they accept/return. The client uses the RouterShape to infer which property accesses are valid and what their response type will be. | |
Interface for serializing and deserializing arbitrary non-JSON primitive values into JSON. | |
Options for the | |
I WS | Isomorphic WebSocket interface with JSON serialization and typed messages. |
Initializer options for the |
Type Aliases
Type alias representing a Serializer with any input or output type. Useful for type constraints. | |
Client function for making requests to a remote Cav handler. If the handler type is a Router or Endpoint, end-to-end type safety kicks in. | |
Type of a Client when the handler is an Endpoint. | |
The shape of an EndpointRequest, holding the type information needed to calculate the allowable ClientArgs. | |
Generic handler type for server-defined Request handlers. | |
Init options for packing/serializing data into a PackedResponse. | |
An object or function responsible for parsing data or throwing errors if the
data isn't shaped as expected. These can either be functions with a single
data argument that return the parsed data or an object with a | |
Extracts the input type of a given Parser. | |
Extracts the output type of a given Parser. | |
Type of a Client when the handler is a Router. | |
The shape of a RouterRequest, mapping allowed routes to their handlers. | |
A group of named Serializer objects. Serializer keys are used to tag serialized values on the output JSON, which is required in order to correctly deserialize the value on the other side. | |
Type of a Client when the handler isn't a Router or Endpoint. | |
Calculates the type returned when unpacking a PackedResponse. | |
Listener for a Socket's "close" event. | |
Listener for a web socket's "error" event. | |
Listener for a web socket's "message" event. The message is deserialized from the event data. | |
Listener for a Socket's "open" event. |