Class: AvenxComponent

AvenxComponent(initialStateopt, computedopt, bridgesopt, templateopt, methodsopt, propsopt, stylesopt, resourcesopt, optionsopt)

Base class for all Avenx components. Manages state, reactivity, rendering, and lifecycle.

Constructor

new AvenxComponent(initialStateopt, computedopt, bridgesopt, templateopt, methodsopt, propsopt, stylesopt, resourcesopt, optionsopt)

Parameters:
Name Type Attributes Description
initialState object <optional>

The initial state of the component.

computed object <optional>

Computed properties definitions.

bridges object <optional>

External bridges accessible to the component.

template string <optional>

The HTML template string.

methods object <optional>

Component methods.

props object <optional>

Component properties.

styles object <optional>

Component CSS variables.

resources object <optional>

Reactive resources.

options object <optional>

Component options and compiler contracts.

Source:

Classes

AvenxComponent

Members

$app

Resolves the app instance associated with this component.

Source:

$app

Sets the app instance associated with this component.

Source:

$compiled

Whether this component renders through a compiled program.

Exposed for tests and diagnostics: "did this component take the fast path" is otherwise unanswerable from outside, and a performance property nobody can observe is a performance property nobody can defend.

Source:

$element

Getter for the component's root element.

Source:

$isMounted

Whether the component is currently mounted in the DOM.

Source:

$isUnmounted

Whether the component has been unmounted.

Source:

$keepAlive

KeepAlive invalidation API for clearing cached components.

Source:

$logContext

Returns component context metadata for diagnostic logging.

Source:

$parent :AvenxComponent|null

Type:
Source:

$refs

Getter for component reference elements marked with data-ax-ref. Lazily resolves references if marked dirty.

Source:

$route

The current active route metadata.

Source:

$slots

Slot helpers for checking whether the parent provided content for a slot. Available after mount target setup populates #transcludedGroups.

Source:

_scope :DisposalScope

Owns teardown callbacks created while this component runs its own code (lifecycle hooks, actions, event handlers). Bridge subscriptions register here and are released in __performTeardown().

Type:
Source:

_watchers :Array:.<AvenxWatcher:>

Type:
Source:

contracts

Returns the set of active compiler contracts for this component.

Source:

Methods

$destroy() → {Promise:.<void:>|void}

Destroys/unmounts the component and performs teardown of watchers and resources. Alias for unmount().

Source:
Returns:
Type
Promise:.<void:> | void

$emit(eventName, detailopt)

Emits a custom event to the parent component.

Parameters:
Name Type Attributes Description
eventName string

Name of the event to emit.

detail object <optional>

Event details.

Source:

$inspect() → {Object}

Returns a diagnostic snapshot of the component for runtime debugging. Props and state are sanitized clones (safe to log, serialize, or diff); element is intentionally the live root element so it stays inspectable in browser devtools. Computed properties are listed by key only, so inspecting never evaluates them.

Source:
Returns:
Type
Object

$nextTick(callbackopt) → {Promise:.<void:>|void}

Executes a callback (or resolves a Promise) after the current reactive update cycle has finished flushing pending DOM updates.

Parameters:
Name Type Attributes Description
callback function <optional>

Optional callback to run after the flush.

Source:
Returns:

A promise resolving after the flush, if no callback was given.

Type
Promise:.<void:> | void

$resetDeadlockBoundary(boundaryNameopt)

Resets a named deadlock boundary inside this component's DOM tree.

Parameters:
Name Type Attributes Default Description
boundaryName string | null <optional>
null
Source:

$tripDeadlockBoundary(boundaryNameopt, erroropt)

Trips a named deadlock boundary inside this component's DOM tree, rendering its fallback template.

Parameters:
Name Type Attributes Default Description
boundaryName string | null <optional>
null

Name of the deadlock boundary (or null for first boundary).

error Error | object <optional>

Error context to pass to fallback template.

Source:

$validateElement(el) → {Array:.<string:>}

Evaluates validation rules for an element and updates this.state.$validation.

Parameters:
Name Type Description
el Element

The element to validate.

Source:
Returns:

Validation errors for the field.

Type
Array:.<string:>

$watch(source, callback, optionsopt) → {AvenxWatcher}

Reactively listens to changes in specific state values or getters.

Parameters:
Name Type Attributes Description
source string | function | Array:.<(string:|function())>

State property key string, getter function, or array of sources.

callback function

Triggered when the value changes.

options object <optional>

Config options.

Properties
Name Type Attributes Description
immediate boolean <optional>

Run callback immediately on watcher creation.

deep boolean <optional>

Deeply watch nested properties.

Source:
Returns:
Type
AvenxWatcher

$watchEffect(effect, optionsopt) → {function}

Reactively runs an immediate effect hook that automatically tracks dependencies and re-runs on state mutation. Automatically registers the watcher in this._watchers and tears it down when the component unmounts.

Parameters:
Name Type Attributes Description
effect function

Effect function to run immediately and track.

options object <optional>

Config options.

Source:
Returns:

Stop handle function () => watcher.teardown().

Type
function

__bridgeValues() → {object}

The bridges this component can see.

Source:
Returns:

Bridges by name.

Type
object

__buildScope() → {object}

Builds one evaluation scope, without evaluating anything in it.

Scope construction used to happen once per interpolation per render, which made it a hot path nobody could see. It is measurable from here.

Source:
Returns:

A fresh scope.

Type
object

__computedKeys() → {Array:.<string:>}

The names the component's computed values bind.

Read by ComponentScope; a component's computed registry is private and the scope has no business reaching into it.

Source:
Returns:

Computed names.

Type
Array:.<string:>

__evaluate(expression, extraScopeopt) → {any}

Evaluates one template expression against this component's scope.

Exposed for renderer benchmarks and tests, which need to price expression evaluation on its own rather than inferring it from a whole update.

Parameters:
Name Type Attributes Description
expression string

The expression source.

extraScope object <optional>

Additional scope bindings.

Source:
Returns:

The value.

Type
any

__getTemplate() → {string}

The compiled template this component renders.

An internal seam, in the same family as __setMountTarget. Benchmarks and renderer tests need the exact string the compiler produced, and reaching it by recompiling the source would measure a reconstruction rather than what the component actually holds.

Source:
Returns:

The template source.

Type
string

__hasImports() → {boolean}

Whether the component's module bound any imports.

Source:
Returns:

True when there are imports in scope.

Type
boolean

__importValues() → {object}

The values the component's module imported.

Source:
Returns:

Imported values by local name.

Type
object

__isIsolated() → {boolean}

Whether the component declared the isolated contract.

Source:
Returns:

True when bridges are kept out of scope.

Type
boolean

__methods() → {object}

The component's executable actions.

Source:
Returns:

The action map.

Type
object

__notifyInjectingChildren()

Notifies all registered injecting child components that a provided value has shifted.

Source:

__onChildPropsChanged()

Called when a compiled prop for a child component changed value.

A plain component does not mount children, so this is a no-op here. AvenxPage overrides it: pages own the child mount points, and a changed prop is the one thing that has to reach an already-mounted child.

Source:

__readResource(name) → {any}

Reads a resource, suspending if it is still in flight.

Parameters:
Name Type Description
name string

The resource name.

Source:
Returns:

The resource's value.

Type
any

__registerInjectingChild(key, child)

Registers a child component that is injecting a provided key.

Parameters:
Name Type Description
key string

The provided key.

child AvenxComponent

The child component.

Source:

__resourceNames() → {Array:.<string:>}

The names of the component's declared resources.

Source:
Returns:

Resource names.

Type
Array:.<string:>

__unregisterInjectingChild(key, child)

Unregisters an injecting child component.

Parameters:
Name Type Description
key string

The provided key.

child AvenxComponent

The child component.

Source:

__updateProvidedState()

Dynamically re-evaluates the provide option and updates providedState.

Source:

(protected) _evaluate(expression, extraScopeopt) → {any}

Evaluates an expression in the component's scope.

Parameters:
Name Type Attributes Description
expression string

The expression to evaluate.

extraScope object <optional>

Additional scope variables.

Source:
Returns:

The result of the evaluation.

Type
any

(protected) _getBridges() → {object}

Source:
Returns:

The bridges accessible to the component.

Type
object

(protected) _getElement() → {Element|null}

Source:
Returns:

The component's root element.

Type
Element | null

(protected) _getScopeValue(key) → {any}

Retrieves a property or method from the component's scope. Used for array-based provide to resolve keys dynamically.

Parameters:
Name Type Description
key string

The key to retrieve.

Source:
Returns:

The value.

Type
any

(protected) _getTranscludedGroups() → {object}

Retrieves the transcluded groups for this component.

Source:
Returns:

The transcluded groups.

Type
object

clearKeepAliveCache(pageNameopt) → {boolean}

Helper method to clear cached KeepAlive component instances.

Parameters:
Name Type Attributes Description
pageName string <optional>

Optional component or page name to clear from cache.

Source:
Returns:

True if cache entries were evicted, false otherwise.

Type
boolean

destroy() → {Promise:.<void:>|void}

Destroys/unmounts the component and performs teardown of watchers and resources. Alias for unmount().

Source:
Returns:
Type
Promise:.<void:> | void

emit(eventName, detailopt, optionsopt)

Emits a custom event up to parent components with unified bubble options.

Parameters:
Name Type Attributes Description
eventName string

Name of the event to emit.

detail object <optional>

Event details payload.

options object <optional>

Optional custom event options.

Source:

mount(target)

Mounts the component to a target element.

Parameters:
Name Type Description
target Element | string

The target element or selector.

Source:

nextTick(callbackopt) → {Promise:.<void:>|void}

Parameters:
Name Type Attributes Description
callback function <optional>

Optional callback to run after the flush.

Source:
Returns:
Type
Promise:.<void:> | void

onBeforeLeave() → {Promise:.<void:>|void}

Called before the component leaves the DOM. Can return a Promise to postpone DOM removal.

Source:
Returns:
Type
Promise:.<void:> | void

onEnter()

Called when the component is mounted to the DOM and enters.

Source:

onLeave()

Called when the component is unmounted and leaves the DOM.

Source:

render() → {string}

Renders the component template with current state.

Source:
Returns:

The rendered HTML string.

Type
string

runUpdate()

Performs the actual update/render of the component.

Source:

scheduleUpdate()

Schedules an update to run asynchronously in a microtask.

Source:

setProps(newProps)

Updates the component's props and triggers an update if they changed.

Parameters:
Name Type Description
newProps object

The new props to apply.

Source:

unmount() → {Promise:.<void:>|void}

Unmounts the component and triggers cleanup.

Source:
Returns:
Type
Promise:.<void:> | void

update()

Renders the component.

On the compiled path this builds the DOM once and hands ownership to the per-binding effects; afterwards it is only reached when something outside the reactive graph asks for a re-read. On the string path it evaluates the render watcher, which re-renders and re-patches the whole template.

Source:

watch(getter, callback, optionsopt) → {AvenxWatcher}

Programmatically registers a watcher on a reactive expression/function.

Parameters:
Name Type Attributes Description
getter function

Evaluation function returning the value to watch.

callback function

Triggered when the value changes.

options object <optional>

Config options.

Source:
Returns:
Type
AvenxWatcher

(static) clearMixins()

Resets/clears the global mixins list. Useful for testing environments.

Source:

(static) extend(optionsopt) → {function}

Helper method to programmatically create component subclasses without ES class boilerplate.

Parameters:
Name Type Attributes Description
options object <optional>

Component definition options.

Source:
Returns:

The generated component subclass.

Type
function

(static) mixin(mixin)

Registers a global mixin.

Parameters:
Name Type Description
mixin object

The mixin definition.

Source: