Capability first · transport second

Mail.js

Builds complete reports and prefers the native mail capability with an explicit HTTP transport fallback.

SDK 0.5.18Runtime 0.8.12Protocol arcane/1
On this page

Overview

Builds complete reports and prefers the native mail capability with an explicit HTTP transport fallback.

  • Artifact
    Mail.js · esm
  • Classification
    public first party
  • Availability
    Browser/native hybrid + cloud
  • Normalization
    Mail inputs/results normalized; transport failures mixed.

Import and lifecycle

JavaScript
import * as module from '/arcane/modules/Mail.js';

Import installs window.mail once when window exists. After installation, every later new Mail(config) returns that existing singleton and ignores the new config. send() builds complete content, prefers native delivery, otherwise uses MailTransport; report/crisis formatting may lazily load User/DBOPFS and best-effort persist a report before delivery.

Application-facing behavior: default Mail, resolveMailConfig(); installs window.mail; send().

Protocol and host implementation

Arcane.mail.send or MailTransport HTTP(S) This detail does not widen the application-facing API or grant authority.

Exports, signatures, parameters, and results

BindingFormDeclaration or signatureParameter syntax
resolveMailConfigfunctionfunction resolveMailConfig( config=globalThis.arcane?.config?.mail||{}, {document=globalThis.document,location=globalThis.location}={} ) config=globalThis.arcane?.config?.mail||{}, {document=globalThis.document,location=globalThis.location}={}
defaultdefault · classclass Mail
CallableKindExact public signatureParameter syntax
resolveMailConfigexported-functionfunction resolveMailConfig( config=globalThis.arcane?.config?.mail||{}, {document=globalThis.document,location=globalThis.location}={} ) config=globalThis.arcane?.config?.mail||{}, {document=globalThis.document,location=globalThis.location}={}
Mail.sendpublic-memberasync send(to=[], subject='', payload={}, messageStyle='', messageType='')to=[], subject='', payload={}, messageStyle='', messageType=''
MemberKindExact public declarationParameter syntax
Mail.constructorconstructorconstructor(config=globalThis.arcane?.config?.mail||{},options={})config=globalThis.arcane?.config?.mail||{},options={}
Mail.startedgetget started()
Mail.disposedgetget disposed()
Mail.eventsgetget events()
Mail.invalidOutboxRecordsgetget invalidOutboxRecords()
Mail.lastBackgroundErrorgetget lastBackgroundError()
Mail.startasync methodasync start({signal=null}={}){signal=null}={}
Mail.drainasync methodasync drain({reason='manual',signal=null}={}){reason='manual',signal=null}={}
Mail.listOutboxasync methodasync listOutbox()
Mail.auditOutboxasync methodasync auditOutbox()
Mail.getOutboxRecordasync methodasync getOutboxRecord(reportKey)reportKey
Mail.deleteInvalidOutboxasync methodasync deleteInvalidOutbox(fileName)fileName
Mail.repairInvalidOutboxasync methodasync repairInvalidOutbox(fileName,replacement)fileName,replacement
Mail.quarantineInvalidOutboxasync methodasync quarantineInvalidOutbox()
Mail.stopmethodstop()
Mail.disposemethoddispose()
Mail.sendasync methodasync send(to=[], subject='', payload={}, messageStyle='', messageType='')to=[], subject='', payload={}, messageStyle='', messageType=''

Parameter meanings and results

resolveMailConfig(config,{document,location}) returns {appName,appKey,endpoint,requestTimeout}. The first new Mail(config) owns singleton configuration in a browser window; send(to[],subject,payload,messageStyle,messageType:'error'|'report'|'crisis_detected') resolves the transport result plus reportKey without content-size or recipient-count gates.

Events, side effects, and errors

Source-literal CustomEvent dispatches

No source-literal CustomEvent dispatch is part of this artifact.

Lifecycle and event flow

This artifact has no additional documented lifecycle event flow.

Direct coded failures

This artifact directly assigns no stable coded failure.

Exported Error subclasses

This artifact exports no Error subclass.

Documented failure behavior

  • Uncoded TypeError or structured-clone/serialization failure for malformed recipients, subject, payload, type, or configuration.
  • Native or HTTP transport rejection propagates; optional profile/storage failures are logged and contained.

Availability and capabilities

Browser/native hybrid + cloud. Mail inputs/results normalized; transport failures mixed.

Preferred Arcane.mail.send requires mail.send, is Core-only, and is limited to Precrisis/Warrior Spirit. HTTP fallback has caller-configured network authority.

Contract example

JavaScript
import {resolveMailConfig} from '/arcane/modules/Mail.js';

const config = resolveMailConfig(
    {appName:'hello-app', endpoint:'https://mail.example.com/v1/mail'},
    {document:null, location:new URL('https://hello.example.com/')}
);
console.log(config);