Skip to main content

Module: ghostly-runtime

Namespaces​

Classes​

Interfaces​

Type aliases​

GhostlyEvent​

Ζ¬ GhostlyEvent: ["ghostlyEvent", object | null]

Defined in​

ghostly-runtime/src/types.ts:153


GhostlyPacket​

Ζ¬ GhostlyPacket: [string, string | null, ("Uint8Array" | "JSON")?]

Defined in​

ghostly-runtime/src/types.ts:156


GhostlyRequest​

Ζ¬ GhostlyRequest: ["ghostlyLoad", string] | ["ghostlyInit", Model] | ["ghostlyRender", View] | ["ghostlyFetch", AttachmentInfo] | ["ghostlyPreview", PreviewCommand] | ["ghostlyEnd", null]

Defined in​

ghostly-runtime/src/types.ts:147


GhostlyResponse​

Ζ¬ GhostlyResponse: ["ghostlyACK", GhostlyTypes] | ["ghostlyNACK", GhostlyTypes]

Defined in​

ghostly-runtime/src/types.ts:154


GhostlyTypes​

Ζ¬ GhostlyTypes: Uint8Array | string | object | null

Defined in​

ghostly-runtime/src/types.ts:157


HTMLTransform​

Ζ¬ HTMLTransform: "identity" | "inline" | "noscript" | "sanitize" | "minimize"

An operation to apply to the HTML view before returning the result.

  • identity: Do nothing.
  • inline: Inlines external resources for all element which have an ghostly-inline attribute or URL query parameter. The attribute/parameter may optionally include a comma-separated list of operations to apply to the inlined resource (default is all current transforms).
  • noscript: Removes all script elements (unless attribute 'ghostly-noscript' is set to 'false').
  • sanitize: Removes all scripts or otherwise dangerous markup/XSS using DOMPurify (way more strict than 'noscript'!).
  • minimize: Minifies the HTML and CSS.

Defined in​

ghostly-runtime/src/types.ts:141


OnGhostlyEvent​

Ζ¬ OnGhostlyEvent: (event: object) => void

Type declaration​

β–Έ (event): void

Parameters​
NameType
eventobject
Returns​

void

Defined in​

ghostly-runtime/src/types.ts:128


PaperFormat​

Ζ¬ PaperFormat: "A0" | "A1" | "A2" | "A3" | "A4" | "A5" | "A6" | "Letter" | "Legal" | "Tabloid" | "Ledger"

Defined in​

ghostly-runtime/src/types.ts:143


PaperSize​

Ζ¬ PaperSize: Object

Type declaration​

NameType
format?PaperFormat
orientation?"portrait" | "landscape"

Defined in​

ghostly-runtime/src/types.ts:144


ViewportSize​

Ζ¬ ViewportSize: Object

Type declaration​

NameType
height?number
width?number

Defined in​

ghostly-runtime/src/types.ts:145

Functions​

parseGhostlyPacket​

β–Έ parseGhostlyPacket(request, response): GhostlyTypes

Unmarshals a response from sendGhostlyMessage and either returns the payload or throws an execption.

throws GhostlyError

see sendGhostlyMessage

Parameters​

NameTypeDescription
requestGhostlyRequestThe request object that was sent via sendGhostlyMessage.
responseGhostlyPacketThe raw response object returned by sendGhostlyMessage.

Returns​

GhostlyTypes

An unpacked response.

Defined in​

ghostly-runtime/src/driver.ts:308


sendGhostlyMessage​

β–Έ sendGhostlyMessage(target, request, onGhostlyEvent?, timeout?): Promise<GhostlyPacket>

Sends a command to the Ghostly template and marshals the result so it can be transferred from browser to Node.js.

NOTE: This function must be self-contained and serializable, since the Ghostly Engine will inject it into the Playwright browser instance! No external helper functions or too fancy JS/TS allowed (including GhostlyError).

throws RangeError The command timed out.

throws TypeError The template returned an illegal response packet.

see parseGhostlyPacket

see TemplateDriver

see PreviewDriver

Parameters​

NameTypeDescription
targetWindowThe window where the Ghostly template is running.
requestGhostlyRequestThe command to send.
onGhostlyEvent?OnGhostlyEventAn optional handler that will be invoked when a the template calls notify.
timeout?numberAn optional timeout, in seconds, to wait for a response, before an error is thrown. Defaults to 10 s.

Returns​

Promise<GhostlyPacket>

The raw response packet. Must be unpacked using parseGhostlyPacket.

Defined in​

ghostly-runtime/src/driver.ts:240