Hosanna UI API v2.3.0-next
    Preparing search index...

    The AppConfig class implements the IAppConfig interface and provides the core functionality for managing application configuration data loaded from app.config.json files. These configuration files contain styling information, text strings, service endpoints, and behavioral settings that control how Hosanna UI applications look and behave.

    Configurations can be loaded from:

    • Local app.config.json files bundled with the app
    • Remote services via HTTP/HTTPS endpoints for dynamic theming and A/B testing
    • Multiple sources that are merged together for layered configuration management

    Key features:

    • Automatic resolution of style inheritance using $extends syntax
    • Dynamic data binding with ${data.key} expressions that map to runtime data
    • Resolution-aware styling with automatic FHD/SD scaling
    • Internationalization support with locale switching
    • Performance optimization through style caching and lazy resolution
    • Circular reference detection to prevent infinite loops

    Implements

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    activeDataMap: null | IViewFragmentDataMap = null
    cachedStyles: { [key: string]: IStyle } = {}
    configLoaded: boolean = false
    currentLanguage: string = 'en'
    currentReadingDirection: ReadingDirection = ReadingDirection.LeftToRight
    localeChangeHandlers: Record<string, LocaleChangeHandler> = {}
    localeSubscriptionCounter: number = 0
    mapCounter: number = 0
    resolutionInfo: IResolutionInfo
    resolutionSuffix: string = 'fhd'
    resolvedStyleGenerationByKey: Record<string, number> = {}
    resolvedStyleGenerationCounter: number = 0
    styleLayoutRevision: number = 0

    Bumped with fragment constraint layout cache clear when style or active locale changes; see getStyleLayoutRevision.

    styles: IStyleDictionary = {}
    translations: IStyleDictionary = {}
    MAX_FLATTEN_DEPTH: 6
    SKIP_KEYS: Record<string, boolean> = ...

    Methods

    • Parameters

      • args: unknown[]
      • min: number
      • max: number
      • viewId: string
      • original: string

      Returns void

    • Parameters

      • edge: string
      • viewId: string
      • original: string

      Returns void

    • Clears fragment constraint layout replay entries and advances the epoch used in cache keys.

      Returns void

    • Configures the app config, setting up necessary resolution information. This method is called by the framework to initialize the config with device-specific settings.

      Returns void

    • Parameters

      • args: unknown[]
      • viewId: string
      • original: string

      Returns { args: unknown[]; options?: IConstraintRuleOptions }

    • Walk one style value that may be nested inside an array (objects, nested arrays, primitives).

      Parameters

      • item: unknown
      • path: string
      • depth: number
      • result: { path: string; type: string }[]

      Returns void

    • Parameters

      • obj: IStyleDictionary
      • prefix: string
      • depth: number
      • result: { path: string; type: string }[]

      Returns void

    • Generates a unique key for a style object to track seen styles.

      Parameters

      Returns string

      The generated key.

    • Retrieves a configuration by its key, resolving nested references as needed.

      Type Parameters

      Parameters

      • key: string

        The key for the configuration to retrieve.

      Returns undefined | T

      The resolved configuration.

    • Retrieves a configuration by its key, resolving nested references as needed.

      Type Parameters

      • T

      Parameters

      • key: string

        The key for the configuration to retrieve.

      • defaultValue: T

        The value returned when the configuration is missing.

      Returns T

      The resolved configuration.

    • Returns all style keys from the config as flattened dot-paths with their value types. Used by the remote debugger extension for style key autocompletion.

      Returns { path: string; type: string }[]

    • Parameters

      • args: unknown[]
      • index: number
      • viewId: string
      • original: string

      Returns number

    • Parameters

      • fieldKey: string
      • fn: string
      • viewId: string
      • original: string

      Returns ConstraintProperty

    • Parameters

      • args: unknown[]
      • index: number
      • viewId: string
      • original: string

      Returns string

    • Returns the active BCP-47 language tag.

      Returns string

    • Parameters

      • args: unknown[]
      • index: number
      • defaultValue: number
      • viewId: string
      • original: string

      Returns number

    • Parameters

      • args: unknown[]
      • index: number
      • viewId: string
      • original: string

      Returns undefined | number

    • Returns the physical reading direction resolved for the active locale.

      Returns ReadingDirection

    • Returns the generation of the resolved style currently cached at key. A newly resolved style receives a new generation even when a targeted invalidation does not advance the global layout revision.

      Parameters

      • key: string

      Returns number

    • Monotonic epoch bumped whenever resolved styles or constraint layout validity may change (setConfig, set, resetCache). Included in fragment constraint layout cache keys.

      Returns number

    • Deep-cloned styles JSON for remote debugger tree view. Omits root-only noise keys ($schema, note, translations) consistent with getAllStyleKeys.

      Returns JsonData

    • Invalidates cached resolved styles for a branch and its descendants without clearing unrelated resolved-style cache entries.

      Parameters

      • key: string

      Returns void

    • Parameters

      • value: unknown

      Returns value is string

    • Parameters

      • value: string

      Returns boolean

    • Indicates whether setConfig(...) has been called with app configuration data.

      Returns boolean

    • Parameters

      • value: unknown

      Returns value is JsonData

    • Parameters

      • value: unknown

      Returns value is ParsedConstraintOptions

    • Parameters

      • event: LocaleChangeEvent

      Returns void

    • Parameters

      • value: string
      • fieldKey: string
      • viewId: string

      Returns IConstraintRule

    • Parameters

      • ref: string
      • viewId: string
      • original: string

      Returns { edge: string; id: string }

    • Parameters

      • ref: string
      • viewId: string
      • original: string

      Returns { edge: string; id: string }

    • Parameters

      • key: string
      • seenStyles: { [key: string]: boolean }

      Returns IStyle

    • Clears resolved-style cache and process-local fragment constraint layout cache (clearFragmentConstraintLayoutCache from FragmentConstraintLayoutCache.ts), so constraint replay keys cannot outlive style reloads.

      Returns void

    • Resolves a configuration while carrying private circular-reference state.

      Type Parameters

      Parameters

      • key: string
      • seenStyles: Record<string, boolean> = {}

      Returns undefined | T

    • Parameters

      • value: string
      • fieldKey: string
      • OptionalownerId: string

      Returns IStyle

    • Parameters

      • fn: string
      • args: (string | number)[]

      Returns (string | number)[]

    • Parameters

      • value: undefined | string | number

      Returns string | number

    • Parameters

      • value: string
      • key: string

      Returns string

    • Resolves nested styles by handling $extends and ~reference within the style.

      Parameters

      • style: IStyle

        The style object to resolve.

      • seenStyles: Record<string, boolean> = {}
      • OptionalownerId: string

      Returns IStyle

      The resolved style.

    • Resolves nested style values for a given style key, handling multiple types of references:

      • If the value is a string starting with ~, it treats it as a reference to another named style and recursively resolves it (while detecting circular references).
      • If the value is a string starting with ${}, it binds the value dynamically to a data/view/fn section of the active data map, mapping the key for reactive updates.
      • If the value is a string starting with $(), it binds the value to an observer for the style.
      • If the value is an array or an object, it recursively resolves nested styles.

      This function is critical for supporting dynamic and nested style bindings, enabling the framework to handle complex style dependencies and reactivity.

      Parameters

      • value: IStyle
      • style: IStyle = {}
      • key: string = ''
      • seenStyles: Record<string, boolean> = {}
      • OptionalownerId: string

      Returns IStyle

    • Parameters

      • languageCode: string

      Returns ReadingDirection

    • Parameters

      • value: unknown[]
      • seenStyles: Record<string, boolean>
      • OptionalownerId: string

      Returns IStyle

    • Sets a single configuration entry in the registry, with an option to merge with existing configurations.

      Parameters

      • key: string

        The unique identifier for the configuration.

      • config: IStyle

        The configuration data to be set.

      • merge: boolean = true

        If true, merges with an existing configuration.

      Returns void

    • Sets the current language/locale for translations.

      Parameters

      • languageCode: string

        The language code to set.

      • sectionKey: string = 'locale'

        The section key for translations (optional).

      Returns void

    • Subscribes to successful locale changes and returns a removable subscription id.

      Parameters

      • handler: LocaleChangeHandler

      Returns number

    • Replaces

      Parameters

      Returns IStyle

      in URL-like strings with -{currentLanguage} (e.g. pkg:/hero@locale.png → pkg:/hero-en.png). Scoped to pkg:/http(s):/ URLs only so arbitrary copy (e.g. emails containing "@locale") is not rewritten.

    • Gets a translation for the given key.

      Parameters

      • key: string

        The translation key.

      Returns string

      The translated string.

    • Removes a locale-change subscription.

      Parameters

      • subscriptionId: number

      Returns void

    • Updates a single branch inside the configuration tree and invalidates cached resolved styles for that branch only.

      Parameters

      • key: string
      • config: IStyle
      • options: { invalidateCache?: boolean; merge?: boolean } = {}

      Returns void

    • Parameters

      • options: ParsedConstraintOptions
      • viewId: string
      • original: string

      Returns IConstraintRuleOptions