Skip to content

index

@fungi.computer/sprite


@fungi.computer/sprite / index

AssetPolicy = object

Host-owned admission and resource limits for published avatar artwork.

readonly baseURL: string

readonly allowedOrigins: readonly string[]

readonly maxBytes: number

Maximum bytes admitted for one response.

readonly maxTotalBytes: number

Cumulative bytes admitted across one character selection.

readonly maxRequests: number

Number of requests admitted for one character selection.

readonly optional fetch?: typeof fetch


Asset = object

Decoded transport bytes; adapters use these instead of opening their own URLs.

readonly url: string

readonly bytes: Uint8Array<ArrayBuffer>>

readonly contentType: string


Control = z.infer<typeof controlSchema>>

A validated, character-owned customization control.


Appearance = Readonly<Record<string, string | number | boolean>>>>

Values saved by the shell; no renderer objects or transient activity.


CharacterDocument = z.infer<typeof characterSchema>>

A portable character, with renderer data still awaiting its native decoder.


CharacterSource = string | { local: string; }

A served document URL or a host-installed character key.


AvatarPresentation = object

One complete request. Omitted customization resets to character defaults.

readonly src: CharacterSource

readonly optional activity?: string

readonly optional expression?: string

readonly optional appearance?: Appearance


NativePresentation = object

The resolved activity and appearance passed to a native renderer.

readonly activity: string

readonly expression: string | null

readonly appearance: Appearance


NativePlayer = object

The adapter registers native destruction in the selection scope.

readonly activities: readonly string[]

readonly expressions: readonly string[]

set(presentation): void

Update the existing native instance.

NativePresentation

void

pause(paused): void

Pause or resume animation without losing the current frame.

boolean

void


RendererContext = object

Native renderer access to the selected document and its admitted assets.

readonly target: HTMLElement

readonly document: CharacterDocument

readonly signal: AbortSignal

readonly maxPixels: number

readonly reportError: (error) => void

Report a native failure that occurs after the renderer has become ready.

Error

void

readonly assetURL: (reference) => Effect.Effect<string, Error, Scope.Scope>>

Admit an asset and revoke its object URL when the selection closes.

string

Effect.Effect<string, Error, Scope.Scope>


Renderer = (context) => Effect.Effect<NativePlayer, Error, Scope.Scope>>

A native renderer whose resources live in the character selection scope.

RendererContext

Effect.Effect<NativePlayer, Error, Scope.Scope>


EffectivePresentation = NativePresentation & object

A request after native fallback and appearance validation.

readonly requestedActivity: string

readonly requestedExpression: string | null

readonly fallback: boolean


PlayerState = { status: "empty" | "loading" | "destroyed"; } | { status: "error"; error: Error; } | { status: "ready"; document: CharacterDocument; presentation: EffectivePresentation; updateError?: Error; }

Observable loading, ready, error, and disposal states.


LocalCharacter = object

An installed document and its renderer, loaded together by the shell.

readonly document: CharacterDocument

readonly render: Renderer


SpriteOptions = object

Host-owned character registry and resource policy.

readonly optional assets?: AssetPolicy

Omit for local-only characters; network access is denied by default.

readonly optional maxPixels?: number

readonly optional renderers?: Readonly<Record<string, () => Promise<{ default: Renderer; }>>>

Native adapters allowed for served character documents.

readonly optional characters?: Readonly<Record<string, () => Promise<LocalCharacter>>>>>>

Lazy local characters installed by this shell.


AvatarPlayer = object

One mounted avatar; dispose releases its native and browser resources.

readonly state: PlayerState

Current public state.

subscribe(listener): () => void

Observe state changes until the returned unsubscribe function is called.

(next) => void

() => void

set(next): void

Select a source or update its activity and appearance.

AvatarPresentation

void

pause(value): void

Pause or resume the current native animation.

boolean

void

dispose(): Promise<void>>

Cancel loading and release the current native selection.

Promise<void>


SpriteService = object

Stable shell configuration that creates independent mounted players.

mount(target): AvatarPlayer

Claim one DOM host for a new avatar instance.

HTMLElement

AvatarPlayer

const controlSchema: ZodDiscriminatedUnion<[ZodObject<{ type: ZodLiteral<"number">>; label: ZodString; default: ZodNumber; min: ZodNumber; max: ZodNumber; step: ZodOptional<ZodNumber>>; }, $strict>>, ZodObject<{ type: ZodLiteral<"choice">>; label: ZodString; default: ZodString; options: ZodArray<ZodObject<{ value: ZodString; label: ZodString; }, $strict>>>>; }, $strict>>, ZodObject<{ type: ZodLiteral<"color">>; label: ZodString; default: ZodString; }, $strict>>, ZodObject<{ type: ZodLiteral<"boolean">>; label: ZodString; default: ZodBoolean; }, $strict>>], "type">>

Portable editor descriptors; native input bindings belong to each renderer.


const characterSchema: ZodObject<{ version: ZodLiteral<1>>; name: ZodString; renderer: ZodString; controls: ZodDefault<ZodRecord<ZodString, ZodDiscriminatedUnion<[ZodObject<{ type: ZodLiteral<"number">>; label: ZodString; default: ZodNumber; min: ZodNumber; max: ZodNumber; step: ZodOptional<ZodNumber>>; }, $strict>>, ZodObject<{ type: ZodLiteral<"choice">>; label: ZodString; default: ZodString; options: ZodArray<ZodObject<{ value: …; label: …; }, $strict>>>>; }, $strict>>, ZodObject<{ type: ZodLiteral<"color">>; label: ZodString; default: ZodString; }, $strict>>, ZodObject<{ type: ZodLiteral<"boolean">>; label: ZodString; default: ZodBoolean; }, $strict>>], "type">>>>>>; poster: ZodOptional<ZodString>>; data: ZodJSONSchema; }, $strict>>

Shared envelope only. The selected adapter must decode data before use.

resolveAppearance(controls, overrides?): Appearance

Validate the complete appearance before applying any native updates.

Readonly<Record<string, Control>>

Appearance = {}

Appearance


createSprite(options): SpriteService

Stable shell service; each mounted player owns its own selection.

SpriteOptions

SpriteService