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 anghostly-inlineattribute 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β
| Name | Type |
|---|---|
event | object |
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β
| Name | Type |
|---|---|
format? | PaperFormat |
orientation? | "portrait" | "landscape" |
Defined inβ
ghostly-runtime/src/types.ts:144
ViewportSizeβ
Ζ¬ ViewportSize: Object
Type declarationβ
| Name | Type |
|---|---|
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β
| Name | Type | Description |
|---|---|---|
request | GhostlyRequest | The request object that was sent via sendGhostlyMessage. |
response | GhostlyPacket | The raw response object returned by sendGhostlyMessage. |
Returnsβ
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β
| Name | Type | Description |
|---|---|---|
target | Window | The window where the Ghostly template is running. |
request | GhostlyRequest | The command to send. |
onGhostlyEvent? | OnGhostlyEvent | An optional handler that will be invoked when a the template calls notify. |
timeout? | number | An 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.