eligius 1.1.0 → 1.1.2

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/README.md CHANGED
@@ -274,7 +274,9 @@ engine.init().then(()=> {console.log('Eligius engine ready for business');});
274
274
 
275
275
  ## Configuration API
276
276
 
277
- Obviously having to type all of that JSON by hand can be a tad overwhelming and time consuming. Check out the [ConfigurationFactory](https://rolandzwaga.github.io/eligius/classes/ConfigurationFactory.html) for a strongly typed, fluent API to construct a configuration programmatically.
277
+ Obviously having to type all of that JSON by hand can be a tad overwhelming and time consuming. Check out the [ConfigurationFactory](https://rolandzwaga.github.io/eligius/classes/ConfigurationFactory.html) for a strongly typed, fluent and extensible API to construct a configuration programmatically.
278
+
279
+ It is encouraged to use this API to build specialized DSL's for specific presentations.
278
280
 
279
281
  ## Source documentation
280
282
 
@@ -3,9 +3,11 @@ import { IEventbus } from '../eventbus/types';
3
3
  import { TOperationData } from '../operation/types';
4
4
  import { IStrictDuration } from '../types';
5
5
  import { EndableAction } from './endable-action';
6
- export declare class TimelineAction extends EndableAction {
6
+ import { ITimelineAction } from './types';
7
+ export declare class TimelineAction extends EndableAction implements ITimelineAction {
7
8
  duration: IStrictDuration;
8
- active: boolean;
9
+ private _active;
10
+ get active(): boolean;
9
11
  constructor(name: string, startOperations: IResolvedOperation[], endOperations: IResolvedOperation[], duration: IStrictDuration, eventBus: IEventbus);
10
12
  start(initOperationData?: TOperationData): Promise<TOperationData>;
11
13
  end(initOperationData: TOperationData): Promise<TOperationData>;
@@ -12,6 +12,6 @@ export interface IEndableAction extends IAction {
12
12
  end(initOperationData?: TOperationData): Promise<TOperationData>;
13
13
  }
14
14
  export interface ITimelineAction extends IEndableAction {
15
- active: boolean;
15
+ get active(): boolean;
16
16
  duration: IStrictDuration;
17
17
  }
@@ -1,12 +1,13 @@
1
- import { ILabel, ILanguageLabel, TimelineTypes } from '../../types';
1
+ import { TimelineTypes } from '../../types';
2
2
  import { IActionConfiguration, IEngineConfiguration, ITimelineActionConfiguration, ITimelineConfiguration } from '../types';
3
3
  import { ActionCreatorFactory } from './action-creator-factory';
4
4
  import { ActionEditor, EndableActionEditor, TimelineActionEditor } from './action-editor';
5
+ import { LabelEditor } from './label-editor';
5
6
  import { TimelineProvidersSettingsEditor } from './timeline-provider-settings-editor';
6
7
  export declare type TEngineConfigurationLists = Pick<IEngineConfiguration, 'availableLanguages' | 'initActions' | 'actions' | 'eventActions' | 'timelines' | 'labels'>;
7
8
  declare type ConfigurationFactoryExtension = (this: ConfigurationFactory, ...rest: any[]) => void;
8
9
  /**
9
- * This class offers a fluent and strongly typed DSL for creating Eligius configurations.
10
+ * This class offers a fluent, extensible and strongly typed DSL for creating Eligius configurations.
10
11
  *
11
12
  * @example Building a configuration using the factory
12
13
  * To initialize a basic configuration to start off of:
@@ -104,10 +105,10 @@ export declare class ConfigurationFactory {
104
105
  setDefaultLanguage(defaultLanguage: string): this;
105
106
  setContainerSelector(selector: string): this;
106
107
  editTimelineProviderSettings(): TimelineProvidersSettingsEditor;
107
- getConfiguration(callBack?: (copy: IEngineConfiguration) => IEngineConfiguration | undefined): IEngineConfiguration;
108
+ getConfiguration(callBack?: (copy: IEngineConfiguration) => IEngineConfiguration): IEngineConfiguration;
108
109
  addLanguage(languageCode: string, languageLabel: string): this;
109
- _internalAddAction(collectionName: keyof TEngineConfigurationLists, action: IActionConfiguration): void;
110
- _initializeCollection<T, K extends keyof T>(parent: T, name: K): T[K];
110
+ private _internalAddAction;
111
+ private _initializeCollection;
111
112
  addAction(action: IActionConfiguration): void;
112
113
  addInitAction(action: IActionConfiguration): void;
113
114
  addEventAction(action: IActionConfiguration): void;
@@ -119,9 +120,11 @@ export declare class ConfigurationFactory {
119
120
  addTimeline(uri: string, type: TimelineTypes, duration: number, loop: boolean, selector: string): this;
120
121
  getTimeline(uri: string): ITimelineConfiguration | undefined;
121
122
  removeTimeline(uri: string): this;
122
- _initializeLabel(id: string, labels: ILanguageLabel[]): ILanguageLabel;
123
- _getLabelTranslation(labelTranslations: ILabel[], languageCode: string): ILabel;
123
+ private _initializeLabel;
124
+ private _getLabelTranslation;
125
+ editLabel(id: string): LabelEditor;
124
126
  addLabel(id: string, code: string, translation: string): this;
127
+ addLabels(id: string, translations: Record<string, string>): this;
125
128
  removeLabel(id: string): this;
126
129
  editAction(id: string): EndableActionEditor<import("../types").IEndableActionConfiguration>;
127
130
  editEventAction(id: string): ActionEditor<import("../types").IEventActionConfiguration>;
@@ -2,4 +2,6 @@ export * from './action-creator-factory';
2
2
  export * from './action-editor';
3
3
  export * from './configuration-factory';
4
4
  export * from './name-providers';
5
+ export * from './subtitle-converter';
6
+ export * from './subtitle-editor';
5
7
  export * from './timeline-provider-settings-editor';
@@ -0,0 +1,11 @@
1
+ import { ILanguageLabel } from '../../types';
2
+ import { ConfigurationFactory } from './configuration-factory';
3
+ export declare class LabelEditor {
4
+ private factory;
5
+ private languageLabel;
6
+ constructor(factory: ConfigurationFactory, languageLabel: ILanguageLabel);
7
+ private _internalGetLabel;
8
+ setLabel(languageCode: string, translation: string): this;
9
+ removeLabel(languageCode: string): this;
10
+ end(): ConfigurationFactory;
11
+ }
@@ -0,0 +1,11 @@
1
+ import { IStrictDuration, ISubtitle } from '../../types';
2
+ /**
3
+ * This class converts an AVID subtitle file to an `ISubtitle` array.
4
+ */
5
+ export declare class SubtitleImporter {
6
+ importSubtitles(rawLines: string[]): ISubtitle[];
7
+ stripNewlineChars(str: string): string;
8
+ isValidLine(line: string): boolean;
9
+ convertDuration(time: string): IStrictDuration;
10
+ convertTimeToSeconds(time: string): number;
11
+ }
@@ -0,0 +1,14 @@
1
+ import { ISubtitle, ISubtitleCollection } from '../../types';
2
+ /**
3
+ * Used to edit and add to an {@link ISubtitleCollection}.
4
+ */
5
+ export declare class SubtitleEditor {
6
+ private collection;
7
+ constructor(collection?: ISubtitleCollection[]);
8
+ private _getLanguage;
9
+ addLanguage(languageCode: string): this;
10
+ addSubtitle(languageCode: string, subtitle: ISubtitle): this;
11
+ addSubtitles(subtitles: Record<string, ISubtitle>): this;
12
+ setSubtitle(languageCode: string, subtitle: ISubtitle): this;
13
+ export(): ISubtitleCollection[];
14
+ }
@@ -4,6 +4,7 @@ import { IController } from './types';
4
4
  export interface ILabelControllerMetadata {
5
5
  selectedElement: JQuery;
6
6
  labelId: string;
7
+ attributeName?: string;
7
8
  }
8
9
  /**
9
10
  * This controller attaches to the given selected element and renders the text associated with the given label id in it.
@@ -1,11 +1,11 @@
1
1
  /// <reference types="jquery" />
2
2
  import { IEventbus, TEventbusRemover } from '../eventbus/types';
3
- import { TOperationData } from '../operation/types';
3
+ import { ISubtitleCollection } from '../types';
4
4
  import { IController } from './types';
5
5
  export interface ISubtitlesControllerOperationData {
6
6
  selectedElement: JQuery;
7
7
  language: string;
8
- subtitleData: any;
8
+ subtitleData: ISubtitleCollection[];
9
9
  }
10
10
  export declare class SubtitlesController implements IController<ISubtitlesControllerOperationData> {
11
11
  actionLookup: Record<string, any>;
@@ -20,6 +20,6 @@ export declare class SubtitlesController implements IController<ISubtitlesContro
20
20
  onTimeHandler(position: number): void;
21
21
  onSeekedHandler(arg: any): void;
22
22
  setTitle(container: JQuery, titleLanguageLookup: Record<string, string>): void;
23
- createActionLookup(operationData: TOperationData, container: JQuery): Record<number, () => void>;
23
+ createActionLookup(operationData: ISubtitlesControllerOperationData, container: JQuery): Record<number, () => void>;
24
24
  init(operationData: ISubtitlesControllerOperationData): void;
25
25
  }
@@ -1,8 +1,15 @@
1
+ import { IEndableAction } from './action/types';
1
2
  import { IResolvedEngineConfiguration } from './configuration/types';
2
3
  import { IEventbus } from './eventbus/types';
3
4
  import { LanguageManager } from './language-manager';
4
5
  import { ITimelineProvider } from './timelineproviders/types';
5
6
  import { IEligiusEngine, ITimelineProviderInfo, TimelineTypes } from './types';
7
+ declare type ActionMethod = (IEndableAction['start'] & ActionMethodMetadata) | (IEndableAction['end'] & ActionMethodMetadata);
8
+ interface ActionMethodMetadata {
9
+ id: string;
10
+ isStart: boolean;
11
+ startPosition?: number;
12
+ }
6
13
  /**
7
14
  * This is where the magic happens. The engine is responsible for starting and stopping
8
15
  * the given timeline provider and triggering the actions associated with the positions along the timeline.
@@ -48,6 +55,8 @@ export declare class EligiusEngine implements IEligiusEngine {
48
55
  private _playRequest;
49
56
  private _toggleplay;
50
57
  private _createTimelineLookup;
58
+ static sortTimelines(timelines: Record<number, ActionMethod[]>[]): void;
59
+ static sortActionsPerPosition(actions: ActionMethod[]): ActionMethod[];
51
60
  private _addTimelineActionStart;
52
61
  private _addTimelineActionEnd;
53
62
  private _initializeUriLookup;
@@ -69,12 +78,11 @@ export declare class EligiusEngine implements IEligiusEngine {
69
78
  private _executeRelevantActions;
70
79
  private _handleRequestTimelinePosition;
71
80
  private _handleTimelineComplete;
72
- private _handleExecuteTimelineAction;
73
- private _resizeTimelineAction;
74
- private _getRelevantTimelineActions;
81
+ private _getTimelineActionsForCurrentTimeline;
75
82
  private _requestCurrentTimeline;
76
83
  private _getTimelineActionsForUri;
77
84
  private _onTimeHandler;
78
85
  private _executeActionsForPosition;
79
86
  private _executeSeekActions;
80
87
  }
88
+ export {};