eligius 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lint.d.mts CHANGED
@@ -12,6 +12,21 @@ declare namespace JQuery {
12
12
  type Duration = number | 'fast' | 'slow';
13
13
  type Node = Element | Text | Comment | Document | DocumentFragment;
14
14
  }
15
+ /**
16
+ * DOM-free configuration linter (`eligius/lint`).
17
+ *
18
+ * `lintConfiguration` runs the real `ConfigurationResolver` with stand-ins
19
+ * for the operations, controllers and timeline providers, so every error the
20
+ * engine would throw at `createEngine` time is found at build time, with the
21
+ * same message and JSON path. It then checks every operation list for
22
+ * control-flow blocks that do not nest, missing required properties, invalid
23
+ * `when` expressions, forbidden property chains, unknown `requestAction`
24
+ * names and data that nothing provides.
25
+ *
26
+ * This entry never imports the operation or controller implementations, so
27
+ * it works in plain Node without jquery or lottie-web: build steps, editors
28
+ * and the Eligian compiler can run it.
29
+ */
15
30
  /**
16
31
  * Event: before-request-timeline-uri
17
32
  *
@@ -62,10 +77,65 @@ interface EngineCommandErrorEvent {
62
77
  name: 'engine-command-error';
63
78
  args: [command: string, error: unknown];
64
79
  }
80
+ /**
81
+ * Engine internals that actions, operations and controllers look up by name.
82
+ *
83
+ * Every engine has its own services object. Operations reach it as
84
+ * `this.services` (see `IOperationScope`), controllers receive it in
85
+ * `attach(eventbus, services)`. Because it belongs to one engine, a lookup
86
+ * always answers for that engine, also when several engines share an
87
+ * eventbus.
88
+ */
89
+ interface IEngineServices {
90
+ /**
91
+ * Returns the configured action (from `actions` or `eventActions`) with
92
+ * this name.
93
+ *
94
+ * @param systemName - The action name
95
+ * @returns The action
96
+ * @throws Error for an unknown name, with a "did you mean" hint
97
+ */
98
+ getAction(systemName: string): IAction;
99
+ /**
100
+ * Returns what the resource importer provides under this name: a custom
101
+ * function, registered JSON or template, or any built-in export.
102
+ *
103
+ * @param systemName - The registered name
104
+ * @returns The registered entry; registered JSON may be `0`, `''` or `false`
105
+ * @throws Error when nothing is registered under the name (the importer's
106
+ * "did you mean" hint is kept)
107
+ */
108
+ getImport(systemName: string): unknown;
109
+ /**
110
+ * Creates a new instance of the class the resource importer provides under
111
+ * this name (a controller, for example), constructed with the engine's
112
+ * eventbus.
113
+ *
114
+ * @param systemName - The registered class name
115
+ * @returns The new instance
116
+ * @throws Error when nothing is registered under the name, or when it is not
117
+ * a class
118
+ */
119
+ createInstance<T = unknown>(systemName: string): T;
120
+ /**
121
+ * Returns the engine's root element (its container selector). From
122
+ * `engine.init()` until `engine.destroy()` this is the same jQuery instance.
123
+ *
124
+ * @returns The engine root
125
+ */
126
+ getEngineRoot(): JQuery<HTMLElement>;
127
+ }
65
128
  interface IController<T extends TOperationData> {
66
129
  name: string;
67
130
  init(operationData: T): void;
68
- attach(eventbus: IEventbus): Promise<any> | void;
131
+ /**
132
+ * Starts the controller.
133
+ *
134
+ * @param eventbus - The engine's eventbus
135
+ * @param services - The engine's services, for looking up actions, classes
136
+ * and the engine root
137
+ */
138
+ attach(eventbus: IEventbus, services: IEngineServices): Promise<any> | void;
69
139
  detach(eventbus: IEventbus): void;
70
140
  }
71
141
  /** A start and end frame. Mirrors lottie-web's `AnimationSegment`. */
@@ -387,20 +457,6 @@ interface PushHistoryStateEvent {
387
457
  name: 'push-history-state';
388
458
  args: [state: any];
389
459
  }
390
- /**
391
- * Request: request-action
392
- * Answered through `eventbus.request('request-action', actionName)` by
393
- * EngineFactory with the configured action of that name. Throws for an
394
- * unknown name, with a "did you mean" hint.
395
- * @param actionName - The name of the action to request
396
- * @returns The action
397
- * @category Engine Request
398
- */
399
- interface RequestActionEvent {
400
- name: 'request-action';
401
- args: [actionName: string];
402
- returns: IAction;
403
- }
404
460
  /**
405
461
  * Request: request-current-language
406
462
  * Answered through `eventbus.request('request-current-language')` by
@@ -447,50 +503,6 @@ interface RequestCurrentVideoPositionEvent {
447
503
  name: 'request-current-video-position';
448
504
  args: [callback: (position: number) => void];
449
505
  }
450
- /**
451
- * Request: request-engine-root
452
- * Answered through `eventbus.request('request-engine-root')` with the
453
- * engine's root element (the container selector). From `engine.init()` until
454
- * `engine.destroy()` every answer is the same jQuery instance. The engine also
455
- * answers the legacy form, a broadcast whose last argument is a callback that
456
- * receives the value.
457
- * @returns The engine root element
458
- * @category Engine Request
459
- */
460
- interface RequestEngineRootEvent {
461
- name: 'request-engine-root';
462
- args: [];
463
- returns: JQuery<HTMLElement>;
464
- }
465
- /**
466
- * Request: request-function
467
- * Answered through `eventbus.request('request-function', systemName)` by
468
- * EngineFactory with the function (such as an operation) the resource
469
- * importer provides under that name. Throws for an unknown name.
470
- * @param systemName - The name of the function to request
471
- * @returns The function
472
- * @category Engine Request
473
- */
474
- interface RequestFunctionEvent {
475
- name: 'request-function';
476
- args: [systemName: string];
477
- returns: unknown;
478
- }
479
- /**
480
- * Request: request-instance
481
- * Answered through `eventbus.request('request-instance', systemName)` by
482
- * EngineFactory with a new instance of the class the resource importer
483
- * provides under that name (a controller, for example), constructed with the
484
- * eventbus. Throws for an unknown name.
485
- * @param systemName - The name of the class to instantiate
486
- * @returns The new instance
487
- * @category Engine Request
488
- */
489
- interface RequestInstanceEvent {
490
- name: 'request-instance';
491
- args: [systemName: string];
492
- returns: unknown;
493
- }
494
506
  /**
495
507
  * Event: request-label-collection
496
508
  * @param language - The language code
@@ -777,7 +789,7 @@ interface VideoCompleteEvent {
777
789
  name: 'video-complete';
778
790
  args: [index: number];
779
791
  }
780
- type AllEvents = BeforeRequestTimelineUriEvent | BeforeRequestVideoUrlEvent | DomMutationEvent | EngineCommandErrorEvent | EngineErrorEvent | HighlightNavigationEvent | LanguageChangeEvent | NavigateToVideoUrlEvent | PushHistoryStateEvent | RequestActionEvent | RequestCurrentLanguageEvent | RequestCurrentNavigationEvent | RequestCurrentTimelinePositionEvent | RequestCurrentVideoPositionEvent | RequestEngineRootEvent | RequestFunctionEvent | RequestInstanceEvent | RequestLabelCollectionEvent | RequestLabelCollectionsEvent | RequestTimelineCleanupEvent | RequestTimelineUriEvent | RequestTranslationEvent | RequestVideoCleanupEvent | RequestVideoUrlEvent | CompleteEvent | ContainerRequestEvent | CurrentTimelineChangeEvent | DurationRequestEvent | DurationEvent | FirstFrameEvent | PauseRequestEvent | PauseEvent | PlayRequestEvent | PlayToggleRequestEvent | PlayEvent | RequestCurrentTimelineEvent | ResizeRequestEvent | ResizeEvent | RestartEvent | SeekRequestEvent | SeekEvent | SeekedEvent | StopRequestEvent | StopEvent | TimeEvent | VideoCompleteEvent;
792
+ type AllEvents = BeforeRequestTimelineUriEvent | BeforeRequestVideoUrlEvent | DomMutationEvent | EngineCommandErrorEvent | EngineErrorEvent | HighlightNavigationEvent | LanguageChangeEvent | NavigateToVideoUrlEvent | PushHistoryStateEvent | RequestCurrentLanguageEvent | RequestCurrentNavigationEvent | RequestCurrentTimelinePositionEvent | RequestCurrentVideoPositionEvent | RequestLabelCollectionEvent | RequestLabelCollectionsEvent | RequestTimelineCleanupEvent | RequestTimelineUriEvent | RequestTranslationEvent | RequestVideoCleanupEvent | RequestVideoUrlEvent | CompleteEvent | ContainerRequestEvent | CurrentTimelineChangeEvent | DurationRequestEvent | DurationEvent | FirstFrameEvent | PauseRequestEvent | PauseEvent | PlayRequestEvent | PlayToggleRequestEvent | PlayEvent | RequestCurrentTimelineEvent | ResizeRequestEvent | ResizeEvent | RestartEvent | SeekRequestEvent | SeekEvent | SeekedEvent | StopRequestEvent | StopEvent | TimeEvent | VideoCompleteEvent;
781
793
  type EventMap = { [K in AllEvents as K['name']]: K extends {
782
794
  returns: infer R;
783
795
  } ? [...K['args'], callback?: (result: R) => void] : K['args']; };
@@ -794,10 +806,6 @@ type EventName = keyof EventMap;
794
806
  * The untyped string overloads remain for custom request names.
795
807
  */
796
808
  interface RequestMap {
797
- 'request-action': {
798
- args: RequestActionEvent['args'];
799
- returns: RequestActionEvent['returns'];
800
- };
801
809
  'request-current-language': {
802
810
  args: RequestCurrentLanguageEvent['args'];
803
811
  returns: RequestCurrentLanguageEvent['returns'];
@@ -806,18 +814,6 @@ interface RequestMap {
806
814
  args: RequestCurrentTimelinePositionEvent['args'];
807
815
  returns: RequestCurrentTimelinePositionEvent['returns'];
808
816
  };
809
- 'request-engine-root': {
810
- args: RequestEngineRootEvent['args'];
811
- returns: RequestEngineRootEvent['returns'];
812
- };
813
- 'request-function': {
814
- args: RequestFunctionEvent['args'];
815
- returns: RequestFunctionEvent['returns'];
816
- };
817
- 'request-instance': {
818
- args: RequestInstanceEvent['args'];
819
- returns: RequestInstanceEvent['returns'];
820
- };
821
817
  'request-translation': {
822
818
  args: RequestTranslationEvent['args'];
823
819
  returns: RequestTranslationEvent['returns'];
@@ -999,6 +995,11 @@ interface IOperationScope {
999
995
  * The eventbus instance shared amongst actions and operations
1000
996
  */
1001
997
  eventbus: IEventbus;
998
+ /**
999
+ * The services of the engine this operation runs in: looks up actions,
1000
+ * registered imports and classes, and the engine root
1001
+ */
1002
+ services: IEngineServices;
1002
1003
  /**
1003
1004
  * The list of operations that is currently being executed
1004
1005
  */
@@ -1093,12 +1094,13 @@ declare class DOMEventListenerController implements IController<IDOMEventListene
1093
1094
  /**
1094
1095
  * Looks up the configured actions and starts listening for the DOM event.
1095
1096
  *
1096
- * @param eventbus - The eventbus to request the actions from
1097
- * @throws when an action name is unknown (`request-action` throws or
1098
- * returns nothing); the message names the controller, the action and the
1099
- * DOM event, and keeps the responder's "did you mean" hint
1097
+ * @param eventbus - The eventbus the actions report errors on
1098
+ * @param services - The engine services to look the actions up in
1099
+ * @throws when an action name is unknown; the message names the
1100
+ * controller, the action and the DOM event, and keeps the "did you mean"
1101
+ * hint
1100
1102
  */
1101
- attach(eventbus: IEventbus): void;
1103
+ attach(eventbus: IEventbus, services: IEngineServices): void;
1102
1104
  private _eventHandler;
1103
1105
  /**
1104
1106
  * Removes only the handler this controller registered, so other handlers for
@@ -1198,13 +1200,13 @@ declare class KeyboardController implements IController<IKeyboardControllerOpera
1198
1200
  /**
1199
1201
  * Looks up the configured actions and starts listening for the keys.
1200
1202
  *
1201
- * @param eventbus - The eventbus to request the actions and the engine root
1202
- * from
1203
- * @throws when an action name is unknown (`request-action` throws or
1204
- * returns nothing); the message names the controller, the action and the
1205
- * keys, and keeps the responder's "did you mean" hint
1203
+ * @param eventbus - The eventbus the actions report errors on
1204
+ * @param services - The engine services to look the actions and the engine
1205
+ * root up in
1206
+ * @throws when an action name is unknown; the message names the
1207
+ * controller, the action and the keys, and keeps the "did you mean" hint
1206
1208
  */
1207
- attach(eventbus: IEventbus): void;
1209
+ attach(eventbus: IEventbus, services: IEngineServices): void;
1208
1210
  /**
1209
1211
  * Removes only the handler this controller bound, so other bindings of the
1210
1212
  * same keys keep working, and resets the action instances so a later
@@ -1213,7 +1215,7 @@ declare class KeyboardController implements IController<IKeyboardControllerOpera
1213
1215
  detach(_eventbus: IEventbus): void;
1214
1216
  private _handleKey;
1215
1217
  private _trigger;
1216
- private _requestEngineRoot;
1218
+ private _engineRootElement;
1217
1219
  /**
1218
1220
  * @returns The keys with `' '` replaced by `space`
1219
1221
  * @throws when the keys are empty or name a key hotkeys-js can't match
@@ -1282,7 +1284,7 @@ declare abstract class BaseController<T extends TOperationData> implements ICont
1282
1284
  */
1283
1285
  detach(_eventbus: IEventbus): void;
1284
1286
  abstract init(operationData: T): void;
1285
- abstract attach(eventbus: IEventbus): Promise<any> | void;
1287
+ abstract attach(eventbus: IEventbus, services: IEngineServices): Promise<any> | void;
1286
1288
  }
1287
1289
  interface ILabelControllerMetadata {
1288
1290
  /**
@@ -1648,9 +1650,10 @@ declare class NavigationController extends BaseController<INavigationControllerO
1648
1650
  navLookup: Record<string, any>;
1649
1651
  navVidIdLookup: Record<string, any>;
1650
1652
  ctrlLookup: Record<string, LabelController>;
1651
- activeNavigationPoint: any | null;
1653
+ activeNavigationPoint: any;
1652
1654
  labelControllers: LabelController[];
1653
1655
  eventbus: IEventbus | null;
1656
+ services: IEngineServices | null;
1654
1657
  container: JQuery | null;
1655
1658
  private _menuElement;
1656
1659
  private _anchorLookup;
@@ -1661,7 +1664,7 @@ declare class NavigationController extends BaseController<INavigationControllerO
1661
1664
  * navigation id in roots, nextId or children
1662
1665
  */
1663
1666
  init(operationData: INavigationControllerOperationData): void;
1664
- attach(eventbus: IEventbus): void;
1667
+ attach(eventbus: IEventbus, services: IEngineServices): void;
1665
1668
  /**
1666
1669
  * Sets the active navigation point and the menu highlight from the URL hash,
1667
1670
  * falling back to the item with videoUrlIndex 0 when the hash is missing or
@@ -2373,8 +2376,8 @@ interface ICustomFunctionOperationData {
2373
2376
  * This operation retrieves a custom function defined by the given system name
2374
2377
  * and invokes it with the current operation data and eventbus.
2375
2378
  *
2376
- * The function is looked up with the `request-function` event, which the
2377
- * `EngineFactory` answers from its resource importer. Register the function
2379
+ * The function is looked up with `this.services.getImport`, which answers from
2380
+ * the engine's resource importer. Register the function
2378
2381
  * with the `EligiusResourceImporter` constructor:
2379
2382
  * `new EligiusResourceImporter({functions: {myFunction}})`.
2380
2383
  *
@@ -2534,7 +2537,7 @@ interface IFindInArrayOperationData {
2534
2537
  /**
2535
2538
  * @output
2536
2539
  */
2537
- foundItem?: any | undefined;
2540
+ foundItem?: any;
2538
2541
  /**
2539
2542
  * @output
2540
2543
  */
@@ -2885,8 +2888,8 @@ interface IGetImportOperationData {
2885
2888
  * This operation retrieves the import specified by the given `systemName` and
2886
2889
  * assigns it to the `importedInstance` property on the current operaton date.
2887
2890
  *
2888
- * The import is looked up with the `request-function` event, which the
2889
- * `EngineFactory` answers from its resource importer. Functions, templates
2891
+ * The import is looked up with `this.services.getImport`, which answers from
2892
+ * the engine's resource importer. Functions, templates
2890
2893
  * and JSON registered with the `EligiusResourceImporter` constructor
2891
2894
  * (`new EligiusResourceImporter({json: {settings}})`) can be imported this
2892
2895
  * way, as can every built-in operation, controller and provider export.
@@ -3364,14 +3367,16 @@ interface IMapArrayOperationData {
3364
3367
  */
3365
3368
  declare const mapArray: TOperation<IMapArrayOperationData, Omit<IMapArrayOperationData, 'mapFunction'>>;
3366
3369
  type MathFunctionKeys = { [K in keyof Math]: Math[K] extends ((...args: any) => any) ? K : never; }[keyof Math];
3367
- type MathNonFunctionKeys = { [K in keyof Math]: Math[K] extends ((...args: any) => any) ? never : K; }[keyof Math];
3368
3370
  interface IMathOperationData {
3369
3371
  /**
3372
+ * Numbers, property chains, or names of Math constants
3373
+ * ({@link MathNonFunctionKeys}).
3374
+ *
3370
3375
  * @type=ParameterType:array
3371
3376
  * @required
3372
3377
  * @erased
3373
3378
  */
3374
- args: (number | string | MathNonFunctionKeys)[];
3379
+ args: (number | string)[];
3375
3380
  /**
3376
3381
  * @type=ParameterType:mathfunction
3377
3382
  * @required
@@ -5021,5 +5026,4 @@ interface IFlowControlProblem {
5021
5026
  * @returns The problems in list order, empty when the blocks are well formed
5022
5027
  */
5023
5028
  export declare function findFlowControlProblems(systemNames: readonly string[]): IFlowControlProblem[];
5024
- export type { Controllers, ExtractOperationDataType, GetControllerByName, GetOperationByName, IActionConfiguration, IConfigurationResolverOptions, IConfigurationWarning, IContainerProviderConfig, IEndableActionConfiguration, IEngineConfiguration, IEngineInfo, IEventActionConfiguration, IFlowControlProblem, ILabel, ILintDiagnostic, ILintOptions, IOperationConfiguration, IPlaylistConfig, IPositionSourceConfig, IResolvedActionConfiguration, IResolvedEndableActionConfiguration, IResolvedEngineConfiguration, IResolvedOperation, IResolvedTimelineConfiguration, ITimelineActionConfiguration, ITimelineConfiguration, ITimelineFlow, ITimelineProviderSettings, Operations, TControllerName, TControllerType, TLanguageCode, TLintSeverity, TOperationName, TOperationType, TTimelineProviderSettings, TimelineTypes };
5025
- //# sourceMappingURL=lint.d.mts.map
5029
+ export type { Controllers, ExtractOperationDataType, GetControllerByName, GetOperationByName, IActionConfiguration, IConfigurationResolverOptions, IConfigurationWarning, IContainerProviderConfig, IEndableActionConfiguration, IEngineConfiguration, IEngineInfo, IEventActionConfiguration, IFlowControlProblem, ILabel, ILintDiagnostic, ILintOptions, IOperationConfiguration, IPlaylistConfig, IPositionSourceConfig, IResolvedActionConfiguration, IResolvedEndableActionConfiguration, IResolvedEngineConfiguration, IResolvedOperation, IResolvedTimelineConfiguration, ITimelineActionConfiguration, ITimelineConfiguration, ITimelineFlow, ITimelineProviderSettings, Operations, TControllerName, TControllerType, TLanguageCode, TLintSeverity, TOperationName, TOperationType, TTimelineProviderSettings, TimelineTypes };
package/dist/lint.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { t as __exportAll } from "./rolldown-runtime-CGzGPw9x.mjs";
2
+ import { t as __exportAll } from "./rolldown-runtime-DTOZ5ltL.mjs";
3
3
  import { isDefined } from "ts-is-present";
4
4
 
5
5
  // src/operation/helper/flow-control-names.ts
@@ -559,6 +559,7 @@ var Action = class {
559
559
  name;
560
560
  startOperations;
561
561
  eventbus;
562
+ services;
562
563
  id = "";
563
564
  /**
564
565
  * Scope stack used by {@link executeOperation} when it is called without an
@@ -575,10 +576,11 @@ var Action = class {
575
576
  * again instead of deep-copying the collection on every iteration.
576
577
  */
577
578
  _loopOperationData = /* @__PURE__ */ new WeakMap();
578
- constructor(name, startOperations, eventbus) {
579
+ constructor(name, startOperations, eventbus, services) {
579
580
  this.name = name;
580
581
  this.startOperations = startOperations;
581
582
  this.eventbus = eventbus;
583
+ this.services = services;
582
584
  }
583
585
  /**
584
586
  * Runs the start operations.
@@ -621,6 +623,7 @@ var Action = class {
621
623
  return [{
622
624
  currentIndex: -1,
623
625
  eventbus: this.eventbus,
626
+ services: this.services,
624
627
  operations
625
628
  }];
626
629
  }
@@ -642,6 +645,9 @@ var Action = class {
642
645
  get eventbus() {
643
646
  return parentScope.eventbus;
644
647
  },
648
+ get services() {
649
+ return parentScope.services;
650
+ },
645
651
  get operations() {
646
652
  return parentScope.operations;
647
653
  },
@@ -787,8 +793,8 @@ function copyConfiguredOperationData(operationData, systemName) {
787
793
  // src/action/endable-action.ts
788
794
  var EndableAction = class extends Action {
789
795
  endOperations;
790
- constructor(name, startOperations, endOperations, eventBus) {
791
- super(name, startOperations, eventBus);
796
+ constructor(name, startOperations, endOperations, eventBus, services) {
797
+ super(name, startOperations, eventBus, services);
792
798
  this.endOperations = endOperations;
793
799
  }
794
800
  /**
@@ -829,8 +835,8 @@ var TimelineAction = class extends EndableAction {
829
835
  get active() {
830
836
  return this._active;
831
837
  }
832
- constructor(name, startOperations, endOperations, duration, eventBus) {
833
- super(name, startOperations, endOperations, eventBus);
838
+ constructor(name, startOperations, endOperations, duration, eventBus, services) {
839
+ super(name, startOperations, endOperations, eventBus, services);
834
840
  this.duration = duration;
835
841
  }
836
842
  /**
@@ -1213,16 +1219,19 @@ function warnToConsole(warning) {
1213
1219
  var ConfigurationResolver = class {
1214
1220
  importer;
1215
1221
  eventbus;
1222
+ services;
1216
1223
  _warn;
1217
1224
  /**
1218
1225
  * @param importer - Resolves system names to operations, controllers and providers
1219
1226
  * @param eventbus - The eventbus the resolved actions run on
1227
+ * @param services - The services of the engine the resolved actions run in
1220
1228
  * @param options - Optional. `onWarning` receives the configuration
1221
1229
  * warnings instead of the console.
1222
1230
  */
1223
- constructor(importer, eventbus, options = {}) {
1231
+ constructor(importer, eventbus, services, options = {}) {
1224
1232
  this.importer = importer;
1225
1233
  this.eventbus = eventbus;
1234
+ this.services = services;
1226
1235
  this._warn = options.onWarning ?? warnToConsole;
1227
1236
  }
1228
1237
  process(configuration, actionRegistryListener) {
@@ -1239,16 +1248,16 @@ var ConfigurationResolver = class {
1239
1248
  language: configuration.language,
1240
1249
  layoutTemplate: configuration.layoutTemplate,
1241
1250
  availableLanguages: deepCopy(configuration.availableLanguages),
1242
- actions: resolveActions(configuration.actions, this.importer, this.eventbus, "actions", this._warn),
1243
- initActions: resolveActions(configuration.initActions, this.importer, this.eventbus, "initActions", this._warn),
1251
+ actions: resolveActions(configuration.actions, this.importer, this.eventbus, this.services, "actions", this._warn),
1252
+ initActions: resolveActions(configuration.initActions, this.importer, this.eventbus, this.services, "initActions", this._warn),
1244
1253
  timelineFlow: deepCopy(configuration.timelineFlow),
1245
- timelines: resolveTimelines(configuration.timelines, this.importer, this.eventbus, this._warn)
1254
+ timelines: resolveTimelines(configuration.timelines, this.importer, this.eventbus, this.services, this._warn)
1246
1255
  };
1247
1256
  assertTimelineProviderSettings(configuration, this.importer);
1248
1257
  let eventActions = [];
1249
1258
  if (isDefined(configuration.eventActions)) {
1250
1259
  assertArray(configuration.eventActions, "eventActions");
1251
- if (actionRegistryListener) eventActions = resolveEventActions(configuration.eventActions, this.importer, this.eventbus, this._warn);
1260
+ if (actionRegistryListener) eventActions = resolveEventActions(configuration.eventActions, this.importer, this.eventbus, this.services, this._warn);
1252
1261
  }
1253
1262
  const actionsLookup = createActionsLookup([...resolvedConfig.actions.map((action, index) => [action, `actions[${index}]`]), ...eventActions.map(({ action }, index) => [action, `eventActions[${index}]`])]);
1254
1263
  for (const { action, eventName, eventTopic } of eventActions) actionRegistryListener?.registerAction(action, eventName, eventTopic);
@@ -1383,17 +1392,17 @@ function createActionsLookup(actions) {
1383
1392
  /**
1384
1393
  * Creates the event actions without registering them.
1385
1394
  */
1386
- function resolveEventActions(eventActionConfigurations, importer, eventbus, warn) {
1395
+ function resolveEventActions(eventActionConfigurations, importer, eventbus, services, warn) {
1387
1396
  return eventActionConfigurations.map((config, index) => resolveActionConfiguration(config, importer, `eventActions[${index}]`, warn)).map((config, index) => {
1388
1397
  const { eventName, eventTopic } = eventActionConfigurations[index];
1389
1398
  return {
1390
- action: new Action(config.name, config.startOperations, eventbus),
1399
+ action: new Action(config.name, config.startOperations, eventbus, services),
1391
1400
  eventName,
1392
1401
  eventTopic
1393
1402
  };
1394
1403
  });
1395
1404
  }
1396
- function resolveTimelines(timelines, importer, eventbus, warn) {
1405
+ function resolveTimelines(timelines, importer, eventbus, services, warn) {
1397
1406
  assertArray(timelines, "timelines");
1398
1407
  return timelines.map((config, timelineIndex) => {
1399
1408
  const path = `timelines[${timelineIndex}]`;
@@ -1402,7 +1411,7 @@ function resolveTimelines(timelines, importer, eventbus, warn) {
1402
1411
  ...config,
1403
1412
  ...isDefined(config.positionSource) && { positionSource: deepCopy(config.positionSource) },
1404
1413
  ...isDefined(config.containerProvider) && { containerProvider: deepCopy(config.containerProvider) },
1405
- timelineActions: config.timelineActions.map((actionConfig, index) => resolveTimelineAction(importer, eventbus, actionConfig, `${path}.timelineActions[${index}]`, warn))
1414
+ timelineActions: config.timelineActions.map((actionConfig, index) => resolveTimelineAction(importer, eventbus, services, actionConfig, `${path}.timelineActions[${index}]`, warn))
1406
1415
  };
1407
1416
  });
1408
1417
  }
@@ -1501,20 +1510,20 @@ function resolveDuration(duration, path) {
1501
1510
  end
1502
1511
  };
1503
1512
  }
1504
- function resolveTimelineAction(importer, eventbus, actionConfiguration, path, warn) {
1513
+ function resolveTimelineAction(importer, eventbus, services, actionConfiguration, path, warn) {
1505
1514
  const duration = resolveDuration(actionConfiguration.duration, `${path}.duration`);
1506
1515
  const { id, name, endOperations, startOperations } = resolveEndableActionConfiguration(actionConfiguration, importer, path, warn);
1507
- const action = new TimelineAction(name, startOperations, endOperations, duration, eventbus);
1516
+ const action = new TimelineAction(name, startOperations, endOperations, duration, eventbus, services);
1508
1517
  action.id = id;
1509
1518
  return action;
1510
1519
  }
1511
- function resolveActions(actionConfigurations, importer, eventbus, path, warn) {
1520
+ function resolveActions(actionConfigurations, importer, eventbus, services, path, warn) {
1512
1521
  assertArray(actionConfigurations, path);
1513
1522
  return actionConfigurations.map((config, index) => {
1514
1523
  return resolveEndableActionConfiguration(config, importer, `${path}[${index}]`, warn);
1515
1524
  }).map((resolvedConfig) => {
1516
1525
  const { name, endOperations, startOperations } = resolvedConfig;
1517
- const action = new EndableAction(name, startOperations, endOperations, eventbus);
1526
+ const action = new EndableAction(name, startOperations, endOperations, eventbus, services);
1518
1527
  action.id = resolvedConfig.id;
1519
1528
  return action;
1520
1529
  });
@@ -1643,8 +1652,8 @@ const onceOriginals = /* @__PURE__ */ new WeakMap();
1643
1652
  *
1644
1653
  * @example Request/Response pattern
1645
1654
  * ```ts
1646
- * eventbus.onRequest('request-instance', (name) => new MyClass(name));
1647
- * const instance = eventbus.request<MyClass>('request-instance', 'test');
1655
+ * eventbus.onRequest('request-translation', (key) => translations[key]);
1656
+ * const label = eventbus.request<string>('request-translation', 'nav.home');
1648
1657
  * ```
1649
1658
  *
1650
1659
  * Broadcasts isolate errors: a handler, listener or interceptor that throws, or
@@ -1847,6 +1856,27 @@ var Eventbus = class {
1847
1856
  }
1848
1857
  };
1849
1858
 
1859
+ // src/engine-services.ts
1860
+ /**
1861
+ * Creates services for a context that has no engine, such as linting or a
1862
+ * scope made by `createDefaultScope`. Every lookup throws an error naming
1863
+ * that context.
1864
+ *
1865
+ * @param context - Who created the services, for the error message
1866
+ * @returns Services whose every lookup throws
1867
+ */
1868
+ function createUnavailableServices(context) {
1869
+ const unavailable = () => {
1870
+ throw new Error(`${context}: engine services are not available here (no engine)`);
1871
+ };
1872
+ return {
1873
+ getAction: unavailable,
1874
+ getImport: unavailable,
1875
+ createInstance: unavailable,
1876
+ getEngineRoot: unavailable
1877
+ };
1878
+ }
1879
+
1850
1880
  // src/controllers/metadata/dom-event-listener-controller.ts
1851
1881
  function DOMEventListenerController() {
1852
1882
  return {
@@ -2433,8 +2463,8 @@ function customFunction() {
2433
2463
  description: `This operation retrieves a custom function defined by the given system name
2434
2464
  and invokes it with the current operation data and eventbus.
2435
2465
 
2436
- The function is looked up with the \`request-function\` event, which the
2437
- \`EngineFactory\` answers from its resource importer. Register the function
2466
+ The function is looked up with \`this.services.getImport\`, which answers from
2467
+ the engine's resource importer. Register the function
2438
2468
  with the \`EligiusResourceImporter\` constructor:
2439
2469
  \`new EligiusResourceImporter({functions: {myFunction}})\`.
2440
2470
 
@@ -2757,8 +2787,8 @@ function getImport() {
2757
2787
  description: `This operation retrieves the import specified by the given \`systemName\` and
2758
2788
  assigns it to the \`importedInstance\` property on the current operaton date.
2759
2789
 
2760
- The import is looked up with the \`request-function\` event, which the
2761
- \`EngineFactory\` answers from its resource importer. Functions, templates
2790
+ The import is looked up with \`this.services.getImport\`, which answers from
2791
+ the engine's resource importer. Functions, templates
2762
2792
  and JSON registered with the \`EligiusResourceImporter\` constructor
2763
2793
  (\`new EligiusResourceImporter({json: {settings}})\`) can be imported this
2764
2794
  way, as can every built-in operation, controller and provider export.`,
@@ -4314,7 +4344,7 @@ function lintConfiguration(configuration, options = {}) {
4314
4344
  const diagnostics = [];
4315
4345
  const copy = deepCopy(configuration);
4316
4346
  const importer = createLintImporter(options, collectPlaceholderNames(copy));
4317
- const resolver = new ConfigurationResolver(importer, new Eventbus(), { onWarning: () => {} });
4347
+ const resolver = new ConfigurationResolver(importer, new Eventbus(), createUnavailableServices("lintConfiguration"), { onWarning: () => {} });
4318
4348
  try {
4319
4349
  resolver.process(copy, new ActionRegistryEventbusListener());
4320
4350
  } catch (error) {