Coralite Type Reference
This document serves as a comprehensive reference for the type definitions used within the Coralite. It outlines the structure, properties, and relationships of core types involved in parsing, rendering, and managing HTML documents, templates, and modules. The following sections provide detailed breakdowns of each type, with tables and internal links for easy navigation.
Core Types #
HTMLData #
Represents HTML file data including path and raw content.
| Property | Type | Description |
|---|---|---|
type |
'page' | 'template' |
The type of HTML file. 'page' for main pages, 'template' for reusable components. |
values |
CoraliteModuleValues |
The initial values for the HTML module. |
path |
CoraliteFilePath |
The file's path information within the project structure. |
content |
string (optional) |
The raw HTML string contents of the file (optional, may be omitted for templates). |
CoraliteFilePath #
Represents a file's path structure within the project.
| Property | Type | Description |
|---|---|---|
pathname |
string |
Full relative path from the project root to the file. |
dirname |
string |
Directory name containing the file. |
filename |
string |
The base file name (including extension). |
CoralitePath #
Defines root directories for pages and templates in a Coralite project.
| Property | Type | Description |
|---|---|---|
pages |
string |
The path to the root pages directory. |
templates |
string |
The path to the root templates directory. |
CoralitePathValues #
Represents URL and file path values available during template rendering.
| Property | Type | Description |
|---|---|---|
$urlPathname |
string |
The URL pathname. |
$urlDirname |
string |
The directory name of the URL. |
$filePathname |
string |
The file path name. |
$fileDirname |
string |
The directory name of the file. |
$filename |
string |
The filename. |
data.values |
Object<string, string> (optional) |
Additional values from data. |
CoraliteValues #
Union type representing values available for token replacement in templates.
| Type | Description |
|---|---|
CoralitePathValues |
URL and file path values. |
Object<string, string> |
Key-value pairs for token replacement. |
CoraliteToken #
Represents a token with name and value.
values |
Object<string, string> |
Key-value pairs for token replacement. |
name |
string |
Token identifier. |
content |
string |
Token value or content. |
CoraliteAttributeToken #
Represents an HTML attribute token linked to its parent element.
| Property | Type | Description |
|---|---|---|
name |
string |
Attribute token identifier. |
element |
CoraliteElement |
Corresponding HTML element for the attribute. |
tokens |
CoraliteToken[] |
Array of associated tokens. |
CoraliteRef #
Represents an element reference with name and element.
| Property | Type | Description |
|---|---|---|
name |
string |
Ref identifier. |
element |
CoraliteElement |
Corresponding HTML element for the ref. |
CoraliteTextNodeToken #
Represents a text node token with associated metadata.
| Property | Type | Description |
|---|---|---|
textNode |
CoraliteTextNode |
Text node that contains the token. |
tokens |
CoraliteToken[] |
Array of associated tokens. |
CoraliteModuleValues #
A collection of module values associated with a module.
| Property | Type | Description |
|---|---|---|
| (Key) | CoraliteModuleValue |
Key-value pairs representing module data. |
__script__ |
ScriptContent (optional) |
Script content for the module. |
ScriptContent #
Coralite module script content.
| Property | Type | Description |
|---|---|---|
fn |
function |
The script function. |
values |
Object<string, CoraliteModuleValue> |
Values associated with the script. |
CoraliteModuleValue #
Represents a single value that a module can store or process.
| Type | Description |
|---|---|
string |
A simple string value. |
string[] |
An array of strings. |
CoraliteDirective[] |
Array of directives (e.g., DOCTYPE). |
CoraliteAnyNode[] |
Array of content nodes (elements, text, comments). |
Document and Result Types #
CoraliteDocumentValues #
Holds tokenized metadata extracted from document attributes, element references and text nodes.
| Property | Type | Description |
|---|---|---|
refs |
CoraliteRef[] |
List of element references. |
attributes |
CoraliteAttributeToken[] |
List of attribute tokens from the document. |
textNodes |
CoraliteTextNodeToken[] |
List of text node tokens from the document. |
CoraliteDocumentResult #
Result of document processing containing extracted values and temporary elements.
| Property | Type | Description |
|---|---|---|
values |
CoraliteModuleValues |
The module values extracted from the document. |
tempElements |
CoraliteElement[] |
Temporary elements created during processing. |
CoraliteResult #
Represents a rendered output document with metadata and statistics.
| Property | Type | Description |
|---|---|---|
item |
CoraliteDocument |
The document object from the rendering process. |
html |
string |
Raw HTML content of the render process as a string. |
duration |
number (optional) |
Time taken to render the page in milliseconds. |
CoraliteDocumentRoot #
Represents the root node of a document containing all content nodes.
| Property | Type | Description |
|---|---|---|
type |
'root' |
Node type. |
children |
CoraliteAnyNode[] | CoraliteDirective[] |
Document list of elements, text nodes, or directives. |
CoraliteDocument #
Represents a complete Coralite document with metadata and rendering structure.
| Property | Type | Description |
|---|---|---|
root |
CoraliteDocumentRoot |
Array of elements and text nodes in the document. |
customElements |
CoraliteElement[] |
Custom elements defined in the document. |
path |
CoralitePath & CoraliteFilePath
|
Document's file path. |
ignoreByAttribute |
IgnoreByAttribute[] |
An array of attribute names and values to ignore by element type. |
CoraliteDirective #
Represents a directive found in HTML content, like a DOCTYPE declaration.
| Property | Type | Description |
|---|---|---|
type |
'directive' |
Node type. |
data |
string |
Raw HTML Doctype. |
name |
string |
Doctype name. |
remove |
boolean (optional) |
Mark element to be removed from stack. |
ParseHTMLResult #
Result of parsing HTML content.
| Property | Type | Description |
|---|---|---|
root |
CoraliteDocumentRoot |
The root element of the parsed HTML document. |
customElements |
CoraliteElement[] |
An array of custom elements identified during parsing. |
tempElements |
CoraliteElement[] |
An array of temporary elements created during the parsing process. |
Module and Plugin Types #
CoraliteModule #
A module within the Coralite library, containing metadata and rendering logic.
| Property | Type | Description |
|---|---|---|
id |
string |
Unique module identifier used to reference this module within the application. |
path |
CoraliteFilePath (optional) |
Template paths associated with this module, if any. |
lineOffset |
number (optional) |
Optional offset value for line numbering purposes within the template. |
template |
CoraliteElement |
Module's rendering template which defines its structure and layout. |
script |
string (optional) |
Module's JavaScript raw code used for logic or behavior associated with this module. |
values |
CoraliteDocumentValues |
Values generated from the module's markup, containing metadata or variable information. |
customElements |
CoraliteElement[] |
Custom elements defined in the module, allowing extension of HTML capabilities. |
slotElements |
Object<string, Object<string, CoraliteModuleSlotElement>> |
Custom slot elements and their configurations, enabling flexible content insertion points within components. |
isTemplate |
boolean |
Indicates whether the module is a template. |
CoraliteModuleSlotElement #
Defines a slot element and its configuration within a module.
| Property | Type | Description |
|---|---|---|
name |
string |
Slot element identifier. |
element |
CoraliteElement |
Corresponding HTML element for the slot. |
CoraliteConfig #
Configuration object for Coralite instance.
| Property | Type | Description |
|---|---|---|
output |
string |
The path to the output directory where built files will be placed. |
templates |
string |
The path to the directory containing Coralite templates. |
pages |
string |
The path to the directory containing pages that will be rendered using the provided templates. |
plugins |
CoralitePluginInstance[] (optional) |
Optional array of plugin instances to extend Coralite functionality. |
CoraliteScriptContent #
Script content for Coralite instances.
| Property | Type | Description |
|---|---|---|
id |
string |
Unique instance identifier. |
templateId |
string (optional) |
Template identifier for shared functions. |
document |
CoraliteDocument |
Coralite document with metadata and rendering structure. |
values |
Object<string, CoraliteModuleValue> (optional) |
Instance values. |
refs |
Object |
Array of reference identifiers. |
CoraliteModuleScript #
Callback for module script execution.
/**
* @callback CoraliteModuleScript
* @param {CoraliteValues} values - The module's current values
* @param {CoraliteRef} refs - References template elements
*/
ScriptPlugin #
Configuration for script plugins.
| Property | Type | Description |
|---|---|---|
setup |
function(any): void (optional) |
Called when plugin is registered. |
helpers |
Object<string, function> (optional) |
Global or instance helpers to add to scripts. |
lifecycle |
Object<'register'|'beforeExecute'|'afterExecute'|'onScriptCompile', function> (optional) |
Lifecycle hooks. |
transform |
function(string, Object): string (optional) |
Transform script content. |
InstanceContext #
Context for Coralite script instances.
| Property | Type | Description |
|---|---|---|
instanceId |
string |
Unique instance identifier. |
templateId |
string |
Template identifier. |
values |
Object<string, CoraliteModuleValue> |
Instance values. |
refs |
Object<string, string> |
Instance refs. |
document |
CoraliteDocument (optional) |
Document context. |
Content Nodes #
CoraliteElement #
Represents a standard HTML element in the Coralite content tree.
| Property | Type | Description |
|---|---|---|
type |
'tag' |
Element type. |
name |
string |
Tag name. |
attribs |
Object<string, string> |
Element attributes. |
helpers |
Object<string, function> (optional) |
Global or instance helpers to add to scripts. |
lifecycle |
Object<'register'|'beforeExecute'|'afterExecute'|'onScriptCompile', function> (optional) |
Lifecycle hooks. |
transform |
function(string, Object): string (optional) |
Transform script content. |
slots |
Object[] (optional) |
Slot configurations. |
remove |
boolean (optional) |
Mark element to be removed from stack. |
CoraliteTextNode #
Represents a text node within the Coralite content tree.
| Property | Type | Description |
|---|---|---|
type |
'text' |
Text node type. |
data |
string |
Additional attributes for the text node. |
parent |
CoraliteContentNode |
Parent element of the text node. |
remove |
boolean (optional) |
Mark element to be removed from stack. |
CoraliteComment #
Represents an HTML comment within the Coralite content tree.
| Property | Type | Description |
|---|---|---|
type |
'comment' |
Comment type. |
data |
string |
The content of the HTML comment. |
parent |
CoraliteContentNode |
Parent element of the comment node. |
remove |
boolean (optional) |
Mark element to be removed from stack. |
CoraliteAnyNode #
Union type representing any content node (element, text, or comment).
| Type | Description |
|---|---|
CoraliteElement |
A standard HTML element. |
CoraliteTextNode |
A text node within the content tree. |
CoraliteComment |
An HTML comment in the content tree. |
CoraliteContentNode #
Union type representing nodes that can be part of a document's content hierarchy.
| Type | Description |
|---|---|
CoraliteElement |
A standard HTML element. |
CoraliteDocumentRoot |
Root node containing all content nodes. |
Plugins, Collections and Events #
IgnoreByAttribute #
An array of attribute name-value pairs to exclude from processing.
| Property | Type | Description |
|---|---|---|
name |
string |
Name of attribute. |
value |
string |
Value of attribute. |
CoraliteCollectionCallbackResult #
Result value returned from event handlers.
| Property | Type | Description |
|---|---|---|
type |
'page' | 'template' (optional) |
Document type. |
result |
* (optional) |
Result value returned from event handlers. |
CoraliteCollectionItem #
A document object with both HTMLData properties and result handling capabilities.
| Type | Description |
|---|---|
CoraliteCollectionCallbackResult & HTMLData
|
Combines callback results and HTML data. |
CoraliteCollectionEventResult #
Processed value from event handlers.
| Property | Type | Description |
|---|---|---|
value |
* |
The processed value. |
type |
'page' | 'template' (optional) |
Document type. |
id |
string (optional) |
Optional identifier for the item. |
CoraliteCollectionEventSet #
Callback for setting an item in a collection.
/**
* @callback CoraliteCollectionEventSet
* @param {CoraliteCollectionItem} value - Item to be set
* @returns {Promise
CoraliteCollectionEventDelete #
Callback for deleting an item from a collection.
/**
* @callback CoraliteCollectionEventDelete
* @param {CoraliteCollectionItem} value - Item or pathname to delete
* @async
*/
CoraliteCollectionEventUpdate #
Callback for updating an item in a collection.
/**
* @callback CoraliteCollectionEventUpdate
* @param {CoraliteCollectionItem} newValue - New item value
* @param {CoraliteCollectionItem} oldValue - Original item value
* @async
*/
CoralitePluginContext #
Runtime context for plugin execution.
| Property | Type | Description |
|---|---|---|
values |
Object<string, string | string[] | CoraliteAnyNode[]> |
Key-value pairs of data relevant to plugin execution. |
values |
Object<string, CoraliteModuleValue> |
Instance values. |
refs |
Object<string, string> |
Instance refs. |
values |
Object<string, string | string[] | CoraliteAnyNode[]> |
Key-value pairs of data relevant to plugin execution. |
values |
Object<string, string | string[] | CoraliteAnyNode[]> |
Key-value pairs of data relevant to plugin execution. |
param.values |
CoraliteFilePath & Object<string, any> |
Values associated with the page path. |
values |
Object<string, CoraliteModuleValue> |
Values associated with the script. |
CoralitePluginModule #
Execution function that processes content using plugin logic.
/**
* @template T
* @this {ThisType
CoralitePlugin #
Definition of a Coralite plugin.
values |
Object<string, CoraliteModuleValue> |
Instance values. |
refs |
Object<string, string> |
Instance refs. |
values |
Object<string, string | string[] | CoraliteAnyNode[]> |
Key-value pairs of data relevant to plugin execution. |
values |
Object<string, string | string[] | CoraliteAnyNode[]> |
Key-value pairs of data relevant to plugin execution. |
param.values |
CoraliteFilePath & Object<string, any> |
Values associated with the page path. |
values |
Object<string, CoraliteModuleValue> (optional) |
Instance values. |
refs |
Object<string, string> |
Instance refs. |
values |
Object<string, string | string[] | CoraliteAnyNode[]> |
Key-value pairs of data relevant to plugin execution. |
values |
Object<string, string | string[] | CoraliteAnyNode[]> |
Key-value pairs of data relevant to plugin execution. |
param.values |
CoraliteFilePath & Object<string, any> |
Values associated with the page path. |
values |
Object<string, CoraliteModuleValue> (optional) |
Instance values. |
CoralitePluginResult #
Result type for Coralite plugins with generic template parameter.
refs |
Object<string, string> |
Instance refs. |
values |
Object<string, string | string[] | CoraliteAnyNode[]> |
Key-value pairs of data relevant to plugin execution. |
values |
Object<string, string | string[] | CoraliteAnyNode[]> |
Key-value pairs of data relevant to plugin execution. |
param.values |
CoraliteFilePath & Object<string, any> |
Values associated with the page path. |
metadata |
Object (optional) |
Plugin metadata. |
script |
Object (optional) |
Script plugin configuration. |
onPageSet |
CoralitePluginPageSetCallback (optional) |
Async callback triggered when a page is created. |
onPageUpdate |
CoralitePluginPageUpdateCallback (optional) |
Async callback triggered when a page is updated. |
onPageDelete |
CoralitePluginPageDeleteCallback (optional) |
Async callback triggered when a page is deleted. |
onTemplateSet |
CoralitePluginTemplateCallback (optional) |
Async callback triggered when a template is created. |
onTemplateUpdate |
CoralitePluginTemplateCallback (optional) |
Async callback triggered when a template is updated. |
onTemplateDelete |
CoralitePluginTemplateCallback (optional) |
Async callback triggered when a template is deleted. |
CoralitePluginInstance #
A Coralite plugin with associated template data.
| Property | Type | Description |
|---|---|---|
name |
string |
Unique identifier/name of the plugin. |
method |
Function (optional) |
Execution function that processes content using plugin logic. |
templates |
HTMLData[] (optional, default: []) |
List of custom templates to be included in the coralite instance. |
script |
ScriptPlugin (optional) |
Script plugin configuration for extending script functionality. |
onPageSet |
CoralitePluginPageSetCallback (optional) |
Async callback triggered when a page is created. |
onPageUpdate |
CoralitePluginPageUpdateCallback (optional) |
Async callback triggered when a page is updated. |
onPageDelete |
CoralitePluginPageDeleteCallback (optional) |
Async callback triggered when a page is deleted. |
onTemplateSet |
CoralitePluginTemplateCallback (optional) |
Async callback triggered when a template is created. |
onTemplateUpdate |
CoralitePluginTemplateCallback (optional) |
Async callback triggered when a template is updated. |
onTemplateDelete |
CoralitePluginTemplateCallback (optional) |
Async callback triggered when a template is deleted. |
CoralitePluginPageSetCallback #
Async callback triggered when a page is created.
/**
* @this {ThisType
CoralitePluginPageUpdateCallback #
Async callback triggered when a page is updated.
/**
* @this {ThisType
CoralitePluginPageDeleteCallback #
Async callback triggered when a page is deleted.
/**
* @this {ThisType
CoralitePluginTemplateCallback #
Async callback triggered for template-related events.
/**
* @this {ThisType