Skip to content

PureJS / PureTS Dialect Template Reference

PureJavaScript and PureTypeScript generate self-contained output with no imports from @yantrix/core. All built-in functions are bundled inline at build time by scripts/buildBuiltins.mjs.

PureTypeScript runs the same code generation as PureJavaScript (same buildTemplateModel, same JS templates), and additionally generates a .d.ts declaration file from pure-ts/declarations.eta.

The it object extends the JS/TS base with one extra field:

it = {
  // ...all base JS/TS fields...
  builtins,    // string - pre-bundled @yantrix/functions source, inlined verbatim
}

Entry: pure-js/module.eta (9 includes in order):

StepTemplatePurpose
1js/shared/imports/namespaceNamespace import (only when functionFilePath is set)
2<%~ it.builtins %>Inlined functions bundle (raw string, no include)
3pure-js/runtime/modulecreateFunctionRegistry(), createEventAdapter()
4pure-js/functions/moduleFunction dictionary, user defines, inject registrations
5js/shared/forks/modulePredicate map for fork/choice states
6pure-js/dictionaries/modulestatesDictionary, actionsDictionary, eventDictionary, epoch/incrementEpoch/getEpoch
7pure-js/events/moduleeventAdapter, createEventBus() factory
8js/context/modulereducer, getDefaultContext (shared with class-based)
9pure-js/factory/modulecreate<ClassName>() factory + getState/getAction/createAction/hasState helpers

Entry: pure-ts/declarations.eta (.d.ts only):

  • Declares all exports: statesDictionary, actionsDictionary, eventDictionary, helpers, factory, createEventBus
  • Defines T<ClassName>Instance type with all instance methods and getters
  • Defines TActions<ClassName> union type

Module-level exports:

ExportTypeDescription
statesDictionaryRecord<string, number>State name to hash mapping
actionsDictionaryRecord<string, number>Action name to hash mapping
eventDictionaryRecord<string, number>Event name to hash mapping
actionsMap, statesMapRecord<string, string>Identity name maps
functionDictionary{ get, register, call, has }Inline function registry
epoch{ val: number }Shared epoch counter (module-level)
incrementEpoch()() => voidIncrements epoch on each dispatch
getEpoch()() => numberReturns current epoch value
getState(name)(name: string) => numberLookup state value by name
getAction(name)(name: string) => numberLookup action value by name
createAction(name, payload)(name, payload) => { action, payload }Build action payload
hasState(instance, state)(inst, name) => booleanCheck FSM state by name
createEventBus(id, factories)(id, Record<string, factory>) => [EventBus, automatas, cleanup]Wire FSM instances to a shared event bus
create<ClassName>()() => InstanceFactory function
defaultsame as factoryRe-export of factory