eligius 4.1.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.
@@ -12,6 +12,23 @@ 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 entry point for the fluent configuration API
17
+ * (`eligius/configuration-api`).
18
+ *
19
+ * Build tools (code generators, the Eligian DSL compiler) run in plain Node,
20
+ * where importing the main `eligius` entry fails: it evaluates jquery@4, which
21
+ * throws `jQuery requires a window with a document`. This entry exports the
22
+ * `ConfigurationFactory` and its editors and the configuration types, and
23
+ * validates operation names against the generated metadata. It never imports
24
+ * the operation or controller implementations, so it stays free of jquery
25
+ * and lottie-web.
26
+ *
27
+ * The `...ByType` methods (for example `addStartOperationByType`) need the
28
+ * operation implementations to map a function to its name, so they only work
29
+ * through the main `eligius` entry. Here they throw; use the name based methods
30
+ * (`addStartOperation('selectElement', ...)`) instead.
31
+ */
15
32
  /**
16
33
  * Event: before-request-timeline-uri
17
34
  *
@@ -62,10 +79,65 @@ interface EngineCommandErrorEvent {
62
79
  name: 'engine-command-error';
63
80
  args: [command: string, error: unknown];
64
81
  }
82
+ /**
83
+ * Engine internals that actions, operations and controllers look up by name.
84
+ *
85
+ * Every engine has its own services object. Operations reach it as
86
+ * `this.services` (see `IOperationScope`), controllers receive it in
87
+ * `attach(eventbus, services)`. Because it belongs to one engine, a lookup
88
+ * always answers for that engine, also when several engines share an
89
+ * eventbus.
90
+ */
91
+ interface IEngineServices {
92
+ /**
93
+ * Returns the configured action (from `actions` or `eventActions`) with
94
+ * this name.
95
+ *
96
+ * @param systemName - The action name
97
+ * @returns The action
98
+ * @throws Error for an unknown name, with a "did you mean" hint
99
+ */
100
+ getAction(systemName: string): IAction;
101
+ /**
102
+ * Returns what the resource importer provides under this name: a custom
103
+ * function, registered JSON or template, or any built-in export.
104
+ *
105
+ * @param systemName - The registered name
106
+ * @returns The registered entry; registered JSON may be `0`, `''` or `false`
107
+ * @throws Error when nothing is registered under the name (the importer's
108
+ * "did you mean" hint is kept)
109
+ */
110
+ getImport(systemName: string): unknown;
111
+ /**
112
+ * Creates a new instance of the class the resource importer provides under
113
+ * this name (a controller, for example), constructed with the engine's
114
+ * eventbus.
115
+ *
116
+ * @param systemName - The registered class name
117
+ * @returns The new instance
118
+ * @throws Error when nothing is registered under the name, or when it is not
119
+ * a class
120
+ */
121
+ createInstance<T = unknown>(systemName: string): T;
122
+ /**
123
+ * Returns the engine's root element (its container selector). From
124
+ * `engine.init()` until `engine.destroy()` this is the same jQuery instance.
125
+ *
126
+ * @returns The engine root
127
+ */
128
+ getEngineRoot(): JQuery<HTMLElement>;
129
+ }
65
130
  interface IController<T extends TOperationData> {
66
131
  name: string;
67
132
  init(operationData: T): void;
68
- attach(eventbus: IEventbus): Promise<any> | void;
133
+ /**
134
+ * Starts the controller.
135
+ *
136
+ * @param eventbus - The engine's eventbus
137
+ * @param services - The engine's services, for looking up actions, classes
138
+ * and the engine root
139
+ */
140
+ attach(eventbus: IEventbus, services: IEngineServices): Promise<any> | void;
69
141
  detach(eventbus: IEventbus): void;
70
142
  }
71
143
  /** A start and end frame. Mirrors lottie-web's `AnimationSegment`. */
@@ -268,9 +340,28 @@ interface IEngineActionError extends Error {
268
340
  readonly operationSystemName?: string;
269
341
  /** Index of the failing operation in its operation list, when known */
270
342
  readonly operationIndex?: number;
343
+ /**
344
+ * The operations between the failing action and the failing operation,
345
+ * outermost first, when known. Entry 0 is an operation of the failing
346
+ * action itself: for a failure inside a called action it is the
347
+ * `startAction` or `endAction` that called it. Each further entry is an
348
+ * operation of the action the previous entry started. The last entry is the
349
+ * failing operation, the same as `operationSystemName` and
350
+ * `operationIndex`. A direct failure has one entry.
351
+ */
352
+ readonly operationPath?: readonly IOperationPathEntry[];
271
353
  /** The original error */
272
354
  readonly cause: unknown;
273
355
  }
356
+ /**
357
+ * One operation on {@link IEngineActionError.operationPath}.
358
+ */
359
+ interface IOperationPathEntry {
360
+ /** System name of the operation */
361
+ readonly systemName: string;
362
+ /** Its index in the operation list of its action */
363
+ readonly index: number;
364
+ }
274
365
  type KeysOfType<T, U> = { [P in keyof T]-?: T[P] extends U | undefined ? P : never; }[keyof T];
275
366
  /**
276
367
  * Describes a duration of time expressed in a start and an optional end range with a one second interval.
@@ -301,7 +392,8 @@ type RequireKeys<T, K extends keyof T> = { [P in K]-?: T[P]; };
301
392
  * Event: engine-error
302
393
  * Broadcast when a timeline action that the engine started or ended on its
303
394
  * own fails. The error names the action, the phase (start or end) and, when
304
- * known, the failing operation.
395
+ * known, the failing operation (`operationSystemName`, `operationIndex`) and
396
+ * the path to it through called actions (`operationPath`, outermost first).
305
397
  * @param error - The error, with the original error as its `cause`
306
398
  * @category Engine
307
399
  */
@@ -348,20 +440,6 @@ interface PushHistoryStateEvent {
348
440
  name: 'push-history-state';
349
441
  args: [state: any];
350
442
  }
351
- /**
352
- * Request: request-action
353
- * Answered through `eventbus.request('request-action', actionName)` by
354
- * EngineFactory with the configured action of that name. Throws for an
355
- * unknown name, with a "did you mean" hint.
356
- * @param actionName - The name of the action to request
357
- * @returns The action
358
- * @category Engine Request
359
- */
360
- interface RequestActionEvent {
361
- name: 'request-action';
362
- args: [actionName: string];
363
- returns: IAction;
364
- }
365
443
  /**
366
444
  * Request: request-current-language
367
445
  * Answered through `eventbus.request('request-current-language')` by
@@ -408,50 +486,6 @@ interface RequestCurrentVideoPositionEvent {
408
486
  name: 'request-current-video-position';
409
487
  args: [callback: (position: number) => void];
410
488
  }
411
- /**
412
- * Request: request-engine-root
413
- * Answered through `eventbus.request('request-engine-root')` with the
414
- * engine's root element (the container selector). From `engine.init()` until
415
- * `engine.destroy()` every answer is the same jQuery instance. The engine also
416
- * answers the legacy form, a broadcast whose last argument is a callback that
417
- * receives the value.
418
- * @returns The engine root element
419
- * @category Engine Request
420
- */
421
- interface RequestEngineRootEvent {
422
- name: 'request-engine-root';
423
- args: [];
424
- returns: JQuery<HTMLElement>;
425
- }
426
- /**
427
- * Request: request-function
428
- * Answered through `eventbus.request('request-function', systemName)` by
429
- * EngineFactory with the function (such as an operation) the resource
430
- * importer provides under that name. Throws for an unknown name.
431
- * @param systemName - The name of the function to request
432
- * @returns The function
433
- * @category Engine Request
434
- */
435
- interface RequestFunctionEvent {
436
- name: 'request-function';
437
- args: [systemName: string];
438
- returns: unknown;
439
- }
440
- /**
441
- * Request: request-instance
442
- * Answered through `eventbus.request('request-instance', systemName)` by
443
- * EngineFactory with a new instance of the class the resource importer
444
- * provides under that name (a controller, for example), constructed with the
445
- * eventbus. Throws for an unknown name.
446
- * @param systemName - The name of the class to instantiate
447
- * @returns The new instance
448
- * @category Engine Request
449
- */
450
- interface RequestInstanceEvent {
451
- name: 'request-instance';
452
- args: [systemName: string];
453
- returns: unknown;
454
- }
455
489
  /**
456
490
  * Event: request-label-collection
457
491
  * @param language - The language code
@@ -738,7 +772,7 @@ interface VideoCompleteEvent {
738
772
  name: 'video-complete';
739
773
  args: [index: number];
740
774
  }
741
- 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;
775
+ 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;
742
776
  type EventMap = { [K in AllEvents as K['name']]: K extends {
743
777
  returns: infer R;
744
778
  } ? [...K['args'], callback?: (result: R) => void] : K['args']; };
@@ -755,10 +789,6 @@ type EventName = keyof EventMap;
755
789
  * The untyped string overloads remain for custom request names.
756
790
  */
757
791
  interface RequestMap {
758
- 'request-action': {
759
- args: RequestActionEvent['args'];
760
- returns: RequestActionEvent['returns'];
761
- };
762
792
  'request-current-language': {
763
793
  args: RequestCurrentLanguageEvent['args'];
764
794
  returns: RequestCurrentLanguageEvent['returns'];
@@ -767,18 +797,6 @@ interface RequestMap {
767
797
  args: RequestCurrentTimelinePositionEvent['args'];
768
798
  returns: RequestCurrentTimelinePositionEvent['returns'];
769
799
  };
770
- 'request-engine-root': {
771
- args: RequestEngineRootEvent['args'];
772
- returns: RequestEngineRootEvent['returns'];
773
- };
774
- 'request-function': {
775
- args: RequestFunctionEvent['args'];
776
- returns: RequestFunctionEvent['returns'];
777
- };
778
- 'request-instance': {
779
- args: RequestInstanceEvent['args'];
780
- returns: RequestInstanceEvent['returns'];
781
- };
782
800
  'request-translation': {
783
801
  args: RequestTranslationEvent['args'];
784
802
  returns: RequestTranslationEvent['returns'];
@@ -960,6 +978,11 @@ interface IOperationScope {
960
978
  * The eventbus instance shared amongst actions and operations
961
979
  */
962
980
  eventbus: IEventbus;
981
+ /**
982
+ * The services of the engine this operation runs in: looks up actions,
983
+ * registered imports and classes, and the engine root
984
+ */
985
+ services: IEngineServices;
963
986
  /**
964
987
  * The list of operations that is currently being executed
965
988
  */
@@ -1054,12 +1077,13 @@ declare class DOMEventListenerController implements IController<IDOMEventListene
1054
1077
  /**
1055
1078
  * Looks up the configured actions and starts listening for the DOM event.
1056
1079
  *
1057
- * @param eventbus - The eventbus to request the actions from
1058
- * @throws when an action name is unknown (`request-action` throws or
1059
- * returns nothing); the message names the controller, the action and the
1060
- * DOM event, and keeps the responder's "did you mean" hint
1080
+ * @param eventbus - The eventbus the actions report errors on
1081
+ * @param services - The engine services to look the actions up in
1082
+ * @throws when an action name is unknown; the message names the
1083
+ * controller, the action and the DOM event, and keeps the "did you mean"
1084
+ * hint
1061
1085
  */
1062
- attach(eventbus: IEventbus): void;
1086
+ attach(eventbus: IEventbus, services: IEngineServices): void;
1063
1087
  private _eventHandler;
1064
1088
  /**
1065
1089
  * Removes only the handler this controller registered, so other handlers for
@@ -1159,13 +1183,13 @@ declare class KeyboardController implements IController<IKeyboardControllerOpera
1159
1183
  /**
1160
1184
  * Looks up the configured actions and starts listening for the keys.
1161
1185
  *
1162
- * @param eventbus - The eventbus to request the actions and the engine root
1163
- * from
1164
- * @throws when an action name is unknown (`request-action` throws or
1165
- * returns nothing); the message names the controller, the action and the
1166
- * keys, and keeps the responder's "did you mean" hint
1186
+ * @param eventbus - The eventbus the actions report errors on
1187
+ * @param services - The engine services to look the actions and the engine
1188
+ * root up in
1189
+ * @throws when an action name is unknown; the message names the
1190
+ * controller, the action and the keys, and keeps the "did you mean" hint
1167
1191
  */
1168
- attach(eventbus: IEventbus): void;
1192
+ attach(eventbus: IEventbus, services: IEngineServices): void;
1169
1193
  /**
1170
1194
  * Removes only the handler this controller bound, so other bindings of the
1171
1195
  * same keys keep working, and resets the action instances so a later
@@ -1174,7 +1198,7 @@ declare class KeyboardController implements IController<IKeyboardControllerOpera
1174
1198
  detach(_eventbus: IEventbus): void;
1175
1199
  private _handleKey;
1176
1200
  private _trigger;
1177
- private _requestEngineRoot;
1201
+ private _engineRootElement;
1178
1202
  /**
1179
1203
  * @returns The keys with `' '` replaced by `space`
1180
1204
  * @throws when the keys are empty or name a key hotkeys-js can't match
@@ -1243,7 +1267,7 @@ declare abstract class BaseController<T extends TOperationData> implements ICont
1243
1267
  */
1244
1268
  detach(_eventbus: IEventbus): void;
1245
1269
  abstract init(operationData: T): void;
1246
- abstract attach(eventbus: IEventbus): Promise<any> | void;
1270
+ abstract attach(eventbus: IEventbus, services: IEngineServices): Promise<any> | void;
1247
1271
  }
1248
1272
  interface ILabelControllerMetadata {
1249
1273
  /**
@@ -1609,9 +1633,10 @@ declare class NavigationController extends BaseController<INavigationControllerO
1609
1633
  navLookup: Record<string, any>;
1610
1634
  navVidIdLookup: Record<string, any>;
1611
1635
  ctrlLookup: Record<string, LabelController>;
1612
- activeNavigationPoint: any | null;
1636
+ activeNavigationPoint: any;
1613
1637
  labelControllers: LabelController[];
1614
1638
  eventbus: IEventbus | null;
1639
+ services: IEngineServices | null;
1615
1640
  container: JQuery | null;
1616
1641
  private _menuElement;
1617
1642
  private _anchorLookup;
@@ -1622,7 +1647,7 @@ declare class NavigationController extends BaseController<INavigationControllerO
1622
1647
  * navigation id in roots, nextId or children
1623
1648
  */
1624
1649
  init(operationData: INavigationControllerOperationData): void;
1625
- attach(eventbus: IEventbus): void;
1650
+ attach(eventbus: IEventbus, services: IEngineServices): void;
1626
1651
  /**
1627
1652
  * Sets the active navigation point and the menu highlight from the URL hash,
1628
1653
  * falling back to the item with videoUrlIndex 0 when the hash is missing or
@@ -2334,8 +2359,8 @@ interface ICustomFunctionOperationData {
2334
2359
  * This operation retrieves a custom function defined by the given system name
2335
2360
  * and invokes it with the current operation data and eventbus.
2336
2361
  *
2337
- * The function is looked up with the `request-function` event, which the
2338
- * `EngineFactory` answers from its resource importer. Register the function
2362
+ * The function is looked up with `this.services.getImport`, which answers from
2363
+ * the engine's resource importer. Register the function
2339
2364
  * with the `EligiusResourceImporter` constructor:
2340
2365
  * `new EligiusResourceImporter({functions: {myFunction}})`.
2341
2366
  *
@@ -2495,7 +2520,7 @@ interface IFindInArrayOperationData {
2495
2520
  /**
2496
2521
  * @output
2497
2522
  */
2498
- foundItem?: any | undefined;
2523
+ foundItem?: any;
2499
2524
  /**
2500
2525
  * @output
2501
2526
  */
@@ -2846,8 +2871,8 @@ interface IGetImportOperationData {
2846
2871
  * This operation retrieves the import specified by the given `systemName` and
2847
2872
  * assigns it to the `importedInstance` property on the current operaton date.
2848
2873
  *
2849
- * The import is looked up with the `request-function` event, which the
2850
- * `EngineFactory` answers from its resource importer. Functions, templates
2874
+ * The import is looked up with `this.services.getImport`, which answers from
2875
+ * the engine's resource importer. Functions, templates
2851
2876
  * and JSON registered with the `EligiusResourceImporter` constructor
2852
2877
  * (`new EligiusResourceImporter({json: {settings}})`) can be imported this
2853
2878
  * way, as can every built-in operation, controller and provider export.
@@ -3325,14 +3350,16 @@ interface IMapArrayOperationData {
3325
3350
  */
3326
3351
  declare const mapArray: TOperation<IMapArrayOperationData, Omit<IMapArrayOperationData, 'mapFunction'>>;
3327
3352
  type MathFunctionKeys = { [K in keyof Math]: Math[K] extends ((...args: any) => any) ? K : never; }[keyof Math];
3328
- type MathNonFunctionKeys = { [K in keyof Math]: Math[K] extends ((...args: any) => any) ? never : K; }[keyof Math];
3329
3353
  interface IMathOperationData {
3330
3354
  /**
3355
+ * Numbers, property chains, or names of Math constants
3356
+ * ({@link MathNonFunctionKeys}).
3357
+ *
3331
3358
  * @type=ParameterType:array
3332
3359
  * @required
3333
3360
  * @erased
3334
3361
  */
3335
- args: (number | string | MathNonFunctionKeys)[];
3362
+ args: (number | string)[];
3336
3363
  /**
3337
3364
  * @type=ParameterType:mathfunction
3338
3365
  * @required
@@ -5922,5 +5949,4 @@ export declare class SubtitleEditor {
5922
5949
  setSubtitle(languageCode: TLanguageCode, subtitle: ISubtitle): this;
5923
5950
  export(): ISubtitleCollection[];
5924
5951
  }
5925
- export type { Controllers, ExtractOperationDataType, GetControllerByName, GetOperationByName, IActionConfiguration, IContainerProviderConfig, IEndableActionConfiguration, IEngineConfiguration, IEngineInfo, IEventActionConfiguration, ILabel, IOperationConfiguration, IPlaylistConfig, IPositionSourceConfig, IResolvedActionConfiguration, IResolvedEndableActionConfiguration, IResolvedEngineConfiguration, IResolvedOperation, IResolvedTimelineConfiguration, ITimelineActionConfiguration, ITimelineConfiguration, ITimelineFlow, ITimelineProviderSettings, Operations, TControllerName, TControllerType, TLanguageCode, TOperationName, TOperationType, TTimelineProviderSettings, TimelineTypes };
5926
- //# sourceMappingURL=configuration-api.d.mts.map
5952
+ export type { Controllers, ExtractOperationDataType, GetControllerByName, GetOperationByName, IActionConfiguration, IContainerProviderConfig, IEndableActionConfiguration, IEngineConfiguration, IEngineInfo, IEventActionConfiguration, ILabel, IOperationConfiguration, IPlaylistConfig, IPositionSourceConfig, IResolvedActionConfiguration, IResolvedEndableActionConfiguration, IResolvedEngineConfiguration, IResolvedOperation, IResolvedTimelineConfiguration, ITimelineActionConfiguration, ITimelineConfiguration, ITimelineFlow, ITimelineProviderSettings, Operations, TControllerName, TControllerType, TLanguageCode, TOperationName, TOperationType, TTimelineProviderSettings, TimelineTypes };
@@ -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 { v4 } from "uuid";
4
4
  import { isDefined } from "ts-is-present";
5
5
 
@@ -462,8 +462,8 @@ function customFunction() {
462
462
  description: `This operation retrieves a custom function defined by the given system name
463
463
  and invokes it with the current operation data and eventbus.
464
464
 
465
- The function is looked up with the \`request-function\` event, which the
466
- \`EngineFactory\` answers from its resource importer. Register the function
465
+ The function is looked up with \`this.services.getImport\`, which answers from
466
+ the engine's resource importer. Register the function
467
467
  with the \`EligiusResourceImporter\` constructor:
468
468
  \`new EligiusResourceImporter({functions: {myFunction}})\`.
469
469
 
@@ -786,8 +786,8 @@ function getImport() {
786
786
  description: `This operation retrieves the import specified by the given \`systemName\` and
787
787
  assigns it to the \`importedInstance\` property on the current operaton date.
788
788
 
789
- The import is looked up with the \`request-function\` event, which the
790
- \`EngineFactory\` answers from its resource importer. Functions, templates
789
+ The import is looked up with \`this.services.getImport\`, which answers from
790
+ the engine's resource importer. Functions, templates
791
791
  and JSON registered with the \`EligiusResourceImporter\` constructor
792
792
  (\`new EligiusResourceImporter({json: {settings}})\`) can be imported this
793
793
  way, as can every built-in operation, controller and provider export.`,
@@ -2669,7 +2669,7 @@ var OperationEditor = class {
2669
2669
  */
2670
2670
  setOperationDataItem(key, value) {
2671
2671
  return this.setOperationData({
2672
- ...this.operationConfig.operationData ?? {},
2672
+ ...this.operationConfig.operationData,
2673
2673
  [key]: value
2674
2674
  });
2675
2675
  }