Remarks
Extend this class to create a custom library, then register an instance withapp.use(new MyLibrary()). A library owns its own context key (see
defineLibraryKey), which is simultaneously its registry identity, its
slot on Context, and the identifier used in dependencies/runBefore/
runAfter.
Example
Constructors
Constructor
new Library(Defined in: packages/common/src/library/library.ts:43relationships?):Library
Parameters
relationships?
Partial<LibraryRelationships>
Optional ordering overrides, keyed by other
libraries’ key.
Returns
Library
Properties
key
Defined in: packages/common/src/library/library.ts:35 This library’s identity: its slot onabstractreadonlykey:string
Context, its registry key, and
the identifier used to reference it in ordering relationships.
Accessors
relationships
Get Signature
get relationships(): LibraryRelationships
Defined in: packages/common/src/library/library.ts:51
Internal
Returns
LibraryRelationships
Methods
__clear()
__clear(Defined in: packages/common/src/library/library.ts:74 Called once after the tick loop stops._ctx):Promise<void>
Parameters
_ctx
Context
Returns
Promise<void>
__events()
__events(Defined in: packages/common/src/library/library.ts:66 Called every tick, in run order, whether or not the tick loop is paused — unlike_ctx):Promise<void>
__run. Use this for event/message draining that must
not be affected by pause (e.g. listening for the command that resumes
the loop), not for gameplay simulation.
Parameters
_ctx
Context
Returns
Promise<void>
__init()
__init(Defined in: packages/common/src/library/library.ts:57 Called once, in dependency order, before the tick loop starts._ctx):Promise<void>
Parameters
_ctx
InitContext
Returns
Promise<void>
__run()
__run(Defined in: packages/common/src/library/library.ts:70 Called every tick, in run order, while the tick loop is active and not paused._ctx):Promise<void>
Parameters
_ctx
Context
Returns
Promise<void>
expose()
expose(): unknown
Defined in: packages/common/src/library/library.ts:85
Returns this library’s public contribution to Context[this.key].
Returns
unknown
Remarks
Return a plain object exposing only what game code should be able to reach — neverthis — so internal state and lifecycle hooks never leak
onto Context. Libraries with nothing to expose (headless libraries)
can leave this unimplemented; they simply won’t appear on Context.
throwNotInitializedError()
Defined in: packages/common/src/library/library.ts:89protectedthrowNotInitializedError():never
Returns
never