@anzaui/engine - v0.6.0
    Preparing search index...

    Class Envelope

    A rendered fragment on the wire (format v2), returned by Fragment.run, Stream.run and Engine.renderFragment.

    JSON.stringify(envelope) gives compact JSON with v first and sig / css omitted when undefined. The same JSON goes over fetch, as an SSE data: line (formatEvent) or as a WebSocket text frame (formatPacket).

    When signing is on, sig is the lowercase hex HMAC-SHA256 or Ed25519 signature of message(): the length-prefixed v2 message over ts, slot, html and css (see signatureMessage). Changing any of them breaks the signature.

    The Anza browser library does not apply or verify envelopes: your code puts html into the target, and a server or edge that relays envelopes checks them with verifyEnvelope. html is only escaped where the engine runs with escape: true.

    See the Engine Contract for the format shared by all engines.

    const envelope = await new Fragment('feed/card.html', 'feed', { title: 'New post' }).run(engine);
    JSON.stringify(envelope);
    // {"v":2,"slot":"feed","ts":1724771234,"html":"<ui-card>New post</ui-card>","sig":"…"}

    Implements

    Index
    • Parameters

      • slot: string

        Target name.

      • ts: number

        Unix time in seconds.

      • html: string

        Fragment HTML.

      • Optionalsig: string

        Lowercase hex signature of the v2 message, if signed.

      • Optionalcss: string

        Optional CSS text.

      Returns Envelope

    css?: string

    Optional CSS text; the engine never sets it.

    html: string

    The bound fragment HTML.

    sig?: string

    Lowercase hex signature over message(), present for hmac and ed25519 signing.

    slot: string

    The target name chosen when rendering.

    ts: number

    Unix time in seconds when the envelope was rendered.

    v: 2 = ENVELOPE_VERSION

    Wire-format version, always ENVELOPE_VERSION (2).