Custom Modules
Context
Detailed reference for StringContext and the injected surfaces available inside a custom module.
Context
Every custom module constructor receives a StringContext. In practice, StringModule copies that context onto protected fields, so custom modules usually work through this.* instead of keeping the raw context reference around.
What StringContext Contains
The current runtime provides:
toolsdatasettingseventscentershoverobjectManager
How You Usually Access It
Inside a custom module, use:
this.toolsthis.datathis.settingsthis.eventsthis.centersthis.hoverthis.objectManager
That is the normal authoring path. Reaching back to the original constructor argument usually adds noise but no value.
this.settings
this.settings is the merged module-level settings object.
Its inputs are:
- global defaults from
stringTune.setupSettings(...) - per-module overrides from
stringTune.use(MyModule, settings)
Use this.settings for module-wide defaults, not for per-element state.
Good uses:
- default strength
- default radius
- fallback CSS variable key
- module feature toggles
this.objectManager
this.objectManager is the most advanced surface in the context. Most custom modules should touch it rarely.
The most practical public-ish use is forcing layout refresh after DOM changes:
this.objectManager.refreshLayoutForRoot(object.htmlElement);
Use this sparingly. If a module needs it constantly, the DOM design is usually too heavy.
this.centers and this.hover
These are helper surfaces for more advanced interaction work.
centershelps with cached center lookups and invalidationhoverexposes hover tracking helpers
They are useful when a module genuinely needs those runtime caches. For many modules, data, settings, tools, and events are enough.
Mental Model
Think of StringContext as the dependency-injection layer for custom modules:
datagives you live runtime factstoolsgives you shared parsers and helperseventsgives you communicationsettingsgives you module defaults
Everything else is support structure around those main surfaces.