Utilities

#anyPendingFrames()

Check if there are any pending nextFrame callbacks

function anyPendingFrames(): boolean;

#css()

Declares a CSS style string to be added to the <head> block

This function is intended to be used as a template literal tag

function css(strings: string[], values: string[]): void;
  • strings The CSS to be added

  • values The interpolated string values

#fetchJsonAsset()

Fetches a JSON asset.

In the browser, issues a fetch request for an asset On the server, uses fs.readFile to load a local file asset.

The asset path must be absolute (start with a '/') and is resolved relative to the project root.

function fetchJsonAsset(path: string): Promise<object>;
  • path The path of the asset to fetch

#fetchTextAsset()

Fetches a text asset.

In the browser, issues a fetch request for an asset On the server, uses fs.readFile to load a local file asset.

The asset path must be absolute (start with a '/') and is resolved relative to the project root.

function fetchTextAsset(path: string): Promise<string>;
  • path The path of the asset to fetch

#htmlEncode()

Encodes a string to make it safe for use in HTML.

function htmlEncode(str: string): string;
  • str The string to encode

#INotify

Interface to a notify service instance.

type INotify =
{
    (sourceObject: any, ...args: any[]): void;
    addEventListener: (sourceObject: any, handler: any) => void;
    removeEventListener: (sourceObject: any, handler: any) => void;
}

#(call signature)

Fires a notification.

(sourceObject: any, ...args: any[]): void;
  • sourceObject The event source object or value

  • args Optional arguments to pass to the event handlers

#addEventListener

Adds an event listener to the notify service.

addEventListener: (sourceObject: any, handler: any) => void;
  • sourceObject The event source object or value

  • handler The event handler

#removeEventListener

Removes previously registered event listener from the notify service.

removeEventListener: (sourceObject: any, handler: any) => void;
  • sourceObject The event source object or value

  • handler The event handler

#nextFrame()

Invokes a callback on the next update cycle.

function nextFrame(callback: () => void, order?: number): void;
  • callback The callback to be invoked.

  • order The priority of the callback in related to others (lowest first, default 0).

#notify

Default Notify Instance

let notify: INotify;

#Notify()

Creates a new notify service instance.

Usuauly notify instances don't need to be created and the default notify instance can be used directly.

function Notify(): INotify;

#postNextFrame()

Invokes a callback after all other nextFrame callbacks have been invoked, or immediately if there are no pending nextFrame callbacks.

function postNextFrame(callback: () => void): void;
  • callback The callback to invoke

#urlPattern()

Converts a URL pattern string to a regular expression string.

function urlPattern(pattern: string): string;
  • pattern The URL pattern to be converted to a regular expression