eligius 2.0.0 → 2.2.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/index.d.mts +602 -235
- package/dist/index.mjs +639 -331
- package/dist/index.mjs.map +1 -1
- package/jsonschema/eligius-configuration.json +708 -81
- package/jsonschema/operations/add-class.json +20 -23
- package/jsonschema/operations/add-controller-to-element.json +13 -12
- package/jsonschema/operations/animate-with-class.json +21 -25
- package/jsonschema/operations/animate.json +23 -31
- package/jsonschema/operations/announce-to-screen-reader.json +20 -24
- package/jsonschema/operations/broadcast-event.json +19 -31
- package/jsonschema/operations/calc.json +24 -30
- package/jsonschema/operations/clear-element.json +24 -13
- package/jsonschema/operations/clear-operation-data.json +15 -18
- package/jsonschema/operations/compare-date.json +51 -23
- package/jsonschema/operations/concatenate-strings.json +22 -24
- package/jsonschema/operations/create-element.json +11 -144
- package/jsonschema/operations/custom-function.json +15 -22
- package/jsonschema/operations/end-action.json +19 -22
- package/jsonschema/operations/extend-controller.json +19 -22
- package/jsonschema/operations/filter-array.json +40 -26
- package/jsonschema/operations/find-in-array.json +40 -26
- package/jsonschema/operations/for-each.json +23 -22
- package/jsonschema/operations/format-date.json +33 -22
- package/jsonschema/operations/format-text.json +22 -20
- package/jsonschema/operations/get-attributes-from-element.json +28 -22
- package/jsonschema/operations/get-controller-from-element.json +23 -34
- package/jsonschema/operations/get-controller-instance.json +11 -25
- package/jsonschema/operations/get-current-time.json +23 -13
- package/jsonschema/operations/get-element-dimensions.json +30 -20
- package/jsonschema/operations/get-focused-element.json +20 -13
- package/jsonschema/operations/get-form-data.json +27 -13
- package/jsonschema/operations/get-import.json +17 -23
- package/jsonschema/operations/get-query-params.json +17 -18
- package/jsonschema/operations/get-scroll-position.json +23 -13
- package/jsonschema/operations/get-text-content.json +27 -13
- package/jsonschema/operations/http-delete.json +20 -24
- package/jsonschema/operations/http-post.json +21 -30
- package/jsonschema/operations/http-put.json +21 -30
- package/jsonschema/operations/invoke-object-method.json +26 -24
- package/jsonschema/operations/is-element-in-viewport.json +27 -13
- package/jsonschema/operations/load-from-storage.json +19 -26
- package/jsonschema/operations/load-json.json +21 -24
- package/jsonschema/operations/log.json +13 -26
- package/jsonschema/operations/map-array.json +39 -22
- package/jsonschema/operations/math.json +33 -27
- package/jsonschema/operations/remove-class.json +20 -23
- package/jsonschema/operations/remove-controller-from-element.json +20 -34
- package/jsonschema/operations/remove-element.json +24 -13
- package/jsonschema/operations/remove-properties-from-operation-data.json +18 -22
- package/jsonschema/operations/reparent-element.json +20 -22
- package/jsonschema/operations/replace-string.json +32 -25
- package/jsonschema/operations/replace-text.json +32 -25
- package/jsonschema/operations/request-action.json +18 -22
- package/jsonschema/operations/save-to-storage.json +19 -32
- package/jsonschema/operations/scroll-to-element.json +21 -22
- package/jsonschema/operations/scroll-to-position.json +18 -29
- package/jsonschema/operations/select-element.json +19 -24
- package/jsonschema/operations/set-data.json +15 -22
- package/jsonschema/operations/set-element-attributes.json +20 -22
- package/jsonschema/operations/set-element-content.json +36 -20
- package/jsonschema/operations/set-focus.json +24 -13
- package/jsonschema/operations/set-form-value.json +24 -20
- package/jsonschema/operations/set-global-data.json +18 -22
- package/jsonschema/operations/set-style.json +20 -22
- package/jsonschema/operations/set-variable.json +17 -31
- package/jsonschema/operations/set.json +40 -0
- package/jsonschema/operations/sort-array.json +39 -22
- package/jsonschema/operations/split-string.json +34 -22
- package/jsonschema/operations/start-action.json +19 -20
- package/jsonschema/operations/substring-text.json +23 -24
- package/jsonschema/operations/toggle-class.json +21 -23
- package/jsonschema/operations/toggle-element.json +24 -13
- package/jsonschema/operations/toggle-form-element.json +20 -22
- package/jsonschema/operations/validate-form.json +25 -18
- package/jsonschema/operations/wait.json +16 -22
- package/jsonschema/operations/when.json +15 -22
- package/package.json +4 -2
- package/jsonschema/endable-action-template.json +0 -525
- package/jsonschema/endable-action.json +0 -525
- package/jsonschema/engine-config.json +0 -21
- package/jsonschema/event-action.json +0 -293
- package/jsonschema/mediaplayer-timeline-provider-settings.json +0 -40
- package/jsonschema/operation-templates/add-class.json +0 -40
- package/jsonschema/operation-templates/add-controller-to-element.json +0 -26
- package/jsonschema/operation-templates/add-globals-to-operation.json +0 -39
- package/jsonschema/operation-templates/animate-with-class.json +0 -44
- package/jsonschema/operation-templates/animate.json +0 -51
- package/jsonschema/operation-templates/announce-to-screen-reader.json +0 -43
- package/jsonschema/operation-templates/break-for-each.json +0 -26
- package/jsonschema/operation-templates/broadcast-event.json +0 -51
- package/jsonschema/operation-templates/calc.json +0 -49
- package/jsonschema/operation-templates/clear-element.json +0 -26
- package/jsonschema/operation-templates/clear-operation-data.json +0 -37
- package/jsonschema/operation-templates/clear-storage.json +0 -41
- package/jsonschema/operation-templates/compare-date.json +0 -41
- package/jsonschema/operation-templates/concatenate-strings.json +0 -43
- package/jsonschema/operation-templates/continue-for-each.json +0 -26
- package/jsonschema/operation-templates/create-element.json +0 -156
- package/jsonschema/operation-templates/custom-function.json +0 -39
- package/jsonschema/operation-templates/end-action.json +0 -39
- package/jsonschema/operation-templates/end-for-each.json +0 -26
- package/jsonschema/operation-templates/end-when.json +0 -26
- package/jsonschema/operation-templates/extend-controller.json +0 -39
- package/jsonschema/operation-templates/filter-array.json +0 -47
- package/jsonschema/operation-templates/find-in-array.json +0 -47
- package/jsonschema/operation-templates/for-each.json +0 -40
- package/jsonschema/operation-templates/format-date.json +0 -39
- package/jsonschema/operation-templates/format-text.json +0 -37
- package/jsonschema/operation-templates/get-attributes-from-element.json +0 -39
- package/jsonschema/operation-templates/get-controller-from-element.json +0 -51
- package/jsonschema/operation-templates/get-controller-instance.json +0 -37
- package/jsonschema/operation-templates/get-current-time.json +0 -26
- package/jsonschema/operation-templates/get-element-dimensions.json +0 -39
- package/jsonschema/operation-templates/get-focused-element.json +0 -26
- package/jsonschema/operation-templates/get-form-data.json +0 -26
- package/jsonschema/operation-templates/get-import.json +0 -39
- package/jsonschema/operation-templates/get-query-params.json +0 -37
- package/jsonschema/operation-templates/get-scroll-position.json +0 -26
- package/jsonschema/operation-templates/get-text-content.json +0 -26
- package/jsonschema/operation-templates/http-delete.json +0 -43
- package/jsonschema/operation-templates/http-post.json +0 -49
- package/jsonschema/operation-templates/http-put.json +0 -49
- package/jsonschema/operation-templates/invoke-object-method.json +0 -43
- package/jsonschema/operation-templates/is-element-in-viewport.json +0 -26
- package/jsonschema/operation-templates/load-from-storage.json +0 -43
- package/jsonschema/operation-templates/load-json.json +0 -43
- package/jsonschema/operation-templates/log.json +0 -47
- package/jsonschema/operation-templates/map-array.json +0 -39
- package/jsonschema/operation-templates/math.json +0 -45
- package/jsonschema/operation-templates/otherwise.json +0 -26
- package/jsonschema/operation-templates/remove-class.json +0 -40
- package/jsonschema/operation-templates/remove-controller-from-element.json +0 -51
- package/jsonschema/operation-templates/remove-element.json +0 -26
- package/jsonschema/operation-templates/remove-properties-from-operation-data.json +0 -39
- package/jsonschema/operation-templates/reparent-element.json +0 -39
- package/jsonschema/operation-templates/replace-string.json +0 -43
- package/jsonschema/operation-templates/replace-text.json +0 -43
- package/jsonschema/operation-templates/request-action.json +0 -39
- package/jsonschema/operation-templates/save-to-storage.json +0 -49
- package/jsonschema/operation-templates/scroll-to-element.json +0 -45
- package/jsonschema/operation-templates/scroll-to-position.json +0 -49
- package/jsonschema/operation-templates/select-element.json +0 -43
- package/jsonschema/operation-templates/set-data.json +0 -39
- package/jsonschema/operation-templates/set-element-attributes.json +0 -39
- package/jsonschema/operation-templates/set-element-content.json +0 -41
- package/jsonschema/operation-templates/set-focus.json +0 -26
- package/jsonschema/operation-templates/set-form-value.json +0 -37
- package/jsonschema/operation-templates/set-global-data.json +0 -39
- package/jsonschema/operation-templates/set-operation-data.json +0 -43
- package/jsonschema/operation-templates/set-style.json +0 -39
- package/jsonschema/operation-templates/set-variable.json +0 -49
- package/jsonschema/operation-templates/sort-array.json +0 -45
- package/jsonschema/operation-templates/split-string.json +0 -41
- package/jsonschema/operation-templates/start-action.json +0 -39
- package/jsonschema/operation-templates/substring-text.json +0 -43
- package/jsonschema/operation-templates/toggle-class.json +0 -40
- package/jsonschema/operation-templates/toggle-element.json +0 -26
- package/jsonschema/operation-templates/toggle-form-element.json +0 -39
- package/jsonschema/operation-templates/validate-form.json +0 -37
- package/jsonschema/operation-templates/wait.json +0 -39
- package/jsonschema/operation-templates/when.json +0 -39
- package/jsonschema/operations/add-globals-to-operation.json +0 -43
- package/jsonschema/operations/break-for-each.json +0 -26
- package/jsonschema/operations/clear-storage.json +0 -45
- package/jsonschema/operations/continue-for-each.json +0 -26
- package/jsonschema/operations/end-for-each.json +0 -26
- package/jsonschema/operations/end-when.json +0 -26
- package/jsonschema/operations/otherwise.json +0 -26
- package/jsonschema/operations/set-operation-data.json +0 -47
- package/jsonschema/raf-timeline-provider-settings.json +0 -29
- package/jsonschema/timeline-action.json +0 -540
- package/jsonschema/timeline-provider-settings.json +0 -16
- package/jsonschema/timeline.json +0 -52
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import $ from "jquery";
|
|
|
5
5
|
import { v4 } from "uuid";
|
|
6
6
|
import lt from "lottie-web";
|
|
7
7
|
import vjs from "video.js";
|
|
8
|
+
import rosetta from "rosetta";
|
|
8
9
|
|
|
9
10
|
//#region src/operation/helper/find-matching-operation-index.ts
|
|
10
11
|
/**
|
|
@@ -546,7 +547,7 @@ var EngineEventbusAdapter = class {
|
|
|
546
547
|
|
|
547
548
|
//#endregion
|
|
548
549
|
//#region src/adapters/engine-input-adapter.ts
|
|
549
|
-
const hotkeys = hk.default || hk;
|
|
550
|
+
const hotkeys$1 = hk.default || hk;
|
|
550
551
|
/**
|
|
551
552
|
* Handles external input sources (hotkeys, resize).
|
|
552
553
|
*
|
|
@@ -583,8 +584,8 @@ var EngineInputAdapter = class {
|
|
|
583
584
|
}
|
|
584
585
|
_registerHotkeys() {
|
|
585
586
|
const handleSpaceBound = this._handleSpacePress.bind(this);
|
|
586
|
-
hotkeys("space", handleSpaceBound);
|
|
587
|
-
this._removers.push(() => hotkeys.unbind("space", handleSpaceBound));
|
|
587
|
+
hotkeys$1("space", handleSpaceBound);
|
|
588
|
+
this._removers.push(() => hotkeys$1.unbind("space", handleSpaceBound));
|
|
588
589
|
}
|
|
589
590
|
_handleSpacePress(keyboardEvent, _hotkeysEvent) {
|
|
590
591
|
keyboardEvent.preventDefault();
|
|
@@ -611,23 +612,17 @@ var EngineInputAdapter = class {
|
|
|
611
612
|
};
|
|
612
613
|
|
|
613
614
|
//#endregion
|
|
614
|
-
//#region src/adapters/
|
|
615
|
+
//#region src/adapters/locale-eventbus-adapter.ts
|
|
615
616
|
/**
|
|
616
|
-
* Bridges
|
|
617
|
-
*
|
|
618
|
-
* This adapter:
|
|
619
|
-
* - Forwards language manager events to eventbus broadcasts
|
|
620
|
-
* - Forwards eventbus language commands to language manager methods
|
|
621
|
-
* - Handles eventbus state queries by reading language manager properties
|
|
622
|
-
* - Updates DOM lang attribute when language changes
|
|
617
|
+
* Bridges LocaleManager to/from the eventbus.
|
|
623
618
|
*
|
|
624
|
-
* Note: Requires engine reference to update DOM lang attribute on
|
|
619
|
+
* Note: Requires engine reference to update DOM lang attribute on locale change.
|
|
625
620
|
*/
|
|
626
|
-
var
|
|
627
|
-
|
|
621
|
+
var LocaleEventbusAdapter = class {
|
|
622
|
+
_localeEventRemovers = [];
|
|
628
623
|
_eventbusRemovers = [];
|
|
629
|
-
constructor(
|
|
630
|
-
this.
|
|
624
|
+
constructor(_localeManager, _eventbus, _engine) {
|
|
625
|
+
this._localeManager = _localeManager;
|
|
631
626
|
this._eventbus = _eventbus;
|
|
632
627
|
this._engine = _engine;
|
|
633
628
|
}
|
|
@@ -635,41 +630,42 @@ var LanguageEventbusAdapter = class {
|
|
|
635
630
|
* Connect adapter - start listening and forwarding
|
|
636
631
|
*/
|
|
637
632
|
connect() {
|
|
638
|
-
this.
|
|
633
|
+
this._subscribeToLocaleManagerEvents();
|
|
639
634
|
this._subscribeToEventbusEvents();
|
|
640
635
|
}
|
|
641
636
|
/**
|
|
642
637
|
* Disconnect adapter - stop all listeners
|
|
643
638
|
*/
|
|
644
639
|
disconnect() {
|
|
645
|
-
this.
|
|
646
|
-
this.
|
|
640
|
+
this._localeEventRemovers.forEach((remove) => remove());
|
|
641
|
+
this._localeEventRemovers = [];
|
|
647
642
|
this._eventbusRemovers.forEach((remove) => remove());
|
|
648
643
|
this._eventbusRemovers = [];
|
|
649
644
|
}
|
|
650
|
-
|
|
651
|
-
this.
|
|
652
|
-
this._setRootElementLang(
|
|
653
|
-
this._eventbus.broadcast("language-change", [
|
|
645
|
+
_subscribeToLocaleManagerEvents() {
|
|
646
|
+
this._onLocaleEvent("change", (newLocale, _oldLocale) => {
|
|
647
|
+
this._setRootElementLang(newLocale);
|
|
648
|
+
this._eventbus.broadcast("language-change", [newLocale]);
|
|
654
649
|
});
|
|
655
650
|
}
|
|
656
|
-
|
|
657
|
-
const remover = this.
|
|
658
|
-
this.
|
|
651
|
+
_onLocaleEvent(event, handler) {
|
|
652
|
+
const remover = this._localeManager.on(event, handler);
|
|
653
|
+
this._localeEventRemovers.push(remover);
|
|
659
654
|
}
|
|
660
655
|
_subscribeToEventbusEvents() {
|
|
661
656
|
this._onEventbusEvent("language-change", (language) => {
|
|
662
|
-
this.
|
|
657
|
+
if (!this._localeManager.availableLocales.includes(language)) {
|
|
658
|
+
console.warn(`[LocaleEventbusAdapter] Locale '${language}' is not available. Available locales: ${this._localeManager.availableLocales.join(", ")}`);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
this._localeManager.setLocale(language);
|
|
663
662
|
this._setRootElementLang(language);
|
|
664
663
|
});
|
|
665
664
|
this._registerRequest("request-current-language", () => {
|
|
666
|
-
return this.
|
|
667
|
-
});
|
|
668
|
-
this._registerRequest("request-label-collection", (labelId) => {
|
|
669
|
-
return this._languageManager.getLabelCollection(labelId);
|
|
665
|
+
return this._localeManager.locale;
|
|
670
666
|
});
|
|
671
|
-
this._registerRequest("request-
|
|
672
|
-
return this.
|
|
667
|
+
this._registerRequest("request-translation", (key, params) => {
|
|
668
|
+
return this._localeManager.t(key, params);
|
|
673
669
|
});
|
|
674
670
|
}
|
|
675
671
|
_onEventbusEvent(eventName, handler) {
|
|
@@ -680,12 +676,12 @@ var LanguageEventbusAdapter = class {
|
|
|
680
676
|
const remover = this._eventbus.onRequest(eventName, responder);
|
|
681
677
|
this._eventbusRemovers.push(remover);
|
|
682
678
|
}
|
|
683
|
-
_setRootElementLang(
|
|
684
|
-
const lang = this._extractPrimaryLanguage(
|
|
679
|
+
_setRootElementLang(locale) {
|
|
680
|
+
const lang = this._extractPrimaryLanguage(locale);
|
|
685
681
|
this._engine.engineRoot.attr("lang", lang);
|
|
686
682
|
}
|
|
687
|
-
_extractPrimaryLanguage(
|
|
688
|
-
return
|
|
683
|
+
_extractPrimaryLanguage(locale) {
|
|
684
|
+
return locale.split("-").shift();
|
|
689
685
|
}
|
|
690
686
|
};
|
|
691
687
|
|
|
@@ -3694,57 +3690,6 @@ var OperationEditor = class {
|
|
|
3694
3690
|
}
|
|
3695
3691
|
};
|
|
3696
3692
|
|
|
3697
|
-
//#endregion
|
|
3698
|
-
//#region src/configuration/api/label-editor.ts
|
|
3699
|
-
/**
|
|
3700
|
-
* Factory that assists with editing a label
|
|
3701
|
-
*/
|
|
3702
|
-
var LabelEditor = class {
|
|
3703
|
-
constructor(configurationFactory, languageLabel) {
|
|
3704
|
-
this.configurationFactory = configurationFactory;
|
|
3705
|
-
this.languageLabel = languageLabel;
|
|
3706
|
-
}
|
|
3707
|
-
_internalGetLabel(languageCode) {
|
|
3708
|
-
return this.languageLabel.labels.find((x) => x.languageCode === languageCode);
|
|
3709
|
-
}
|
|
3710
|
-
/**
|
|
3711
|
-
*
|
|
3712
|
-
* Set the translation associated with the given language code
|
|
3713
|
-
*
|
|
3714
|
-
* @param languageCode
|
|
3715
|
-
* @param translation
|
|
3716
|
-
* @returns
|
|
3717
|
-
*/
|
|
3718
|
-
setLabel(languageCode, translation) {
|
|
3719
|
-
const label = this._internalGetLabel(languageCode);
|
|
3720
|
-
if (label) label.label;
|
|
3721
|
-
else throw new Error(`No label found for language code '${languageCode}'`);
|
|
3722
|
-
return this;
|
|
3723
|
-
}
|
|
3724
|
-
/**
|
|
3725
|
-
*
|
|
3726
|
-
* Remove all of the translations for the given language code
|
|
3727
|
-
*
|
|
3728
|
-
* @param languageCode
|
|
3729
|
-
* @returns
|
|
3730
|
-
*/
|
|
3731
|
-
removeLabel(languageCode) {
|
|
3732
|
-
const idx = this.languageLabel.labels.findIndex((x) => x.languageCode === languageCode);
|
|
3733
|
-
if (idx > -1) this.languageLabel.labels.splice(idx, 1);
|
|
3734
|
-
else throw new Error(`No label found for language code '${languageCode}'`);
|
|
3735
|
-
return this;
|
|
3736
|
-
}
|
|
3737
|
-
/**
|
|
3738
|
-
*
|
|
3739
|
-
* Returns the fluent scope back to the `ConfigurationFactory`
|
|
3740
|
-
*
|
|
3741
|
-
* @returns
|
|
3742
|
-
*/
|
|
3743
|
-
end() {
|
|
3744
|
-
return this.configurationFactory;
|
|
3745
|
-
}
|
|
3746
|
-
};
|
|
3747
|
-
|
|
3748
3693
|
//#endregion
|
|
3749
3694
|
//#region src/configuration/api/timeline-provider-settings-editor.ts
|
|
3750
3695
|
/**
|
|
@@ -4067,8 +4012,7 @@ var ConfigurationFactory = class ConfigurationFactory {
|
|
|
4067
4012
|
layoutTemplate: "",
|
|
4068
4013
|
initActions: [],
|
|
4069
4014
|
actions: [],
|
|
4070
|
-
timelines: []
|
|
4071
|
-
labels: []
|
|
4015
|
+
timelines: []
|
|
4072
4016
|
};
|
|
4073
4017
|
this.configuration = mergeIfMissing(this.configuration, newConfiguration);
|
|
4074
4018
|
return this;
|
|
@@ -4296,82 +4240,6 @@ var ConfigurationFactory = class ConfigurationFactory {
|
|
|
4296
4240
|
}
|
|
4297
4241
|
return this;
|
|
4298
4242
|
}
|
|
4299
|
-
_initializeLabel(id, labels) {
|
|
4300
|
-
let label = labels.find((l) => l.id === id);
|
|
4301
|
-
if (!label) {
|
|
4302
|
-
labels.push({
|
|
4303
|
-
id,
|
|
4304
|
-
labels: []
|
|
4305
|
-
});
|
|
4306
|
-
label = labels[labels.length - 1];
|
|
4307
|
-
}
|
|
4308
|
-
return label;
|
|
4309
|
-
}
|
|
4310
|
-
_getLabelTranslation(labelTranslations, languageCode) {
|
|
4311
|
-
let translation = labelTranslations.find((l) => l.languageCode === languageCode);
|
|
4312
|
-
if (!translation) {
|
|
4313
|
-
translation = {
|
|
4314
|
-
id: v4(),
|
|
4315
|
-
languageCode,
|
|
4316
|
-
label: ""
|
|
4317
|
-
};
|
|
4318
|
-
labelTranslations.push(translation);
|
|
4319
|
-
}
|
|
4320
|
-
return translation;
|
|
4321
|
-
}
|
|
4322
|
-
/**
|
|
4323
|
-
*
|
|
4324
|
-
* Starts an editor for the label that is associated with the specified id
|
|
4325
|
-
*
|
|
4326
|
-
* @param id
|
|
4327
|
-
* @returns
|
|
4328
|
-
*/
|
|
4329
|
-
editLabel(id) {
|
|
4330
|
-
const label = this.configuration.labels?.find((x) => x.id === id);
|
|
4331
|
-
if (label) return new LabelEditor(this, label);
|
|
4332
|
-
else throw new Error(`Language label with id '${id}' not found`);
|
|
4333
|
-
}
|
|
4334
|
-
/**
|
|
4335
|
-
*
|
|
4336
|
-
* Adds a label translation with the specified data
|
|
4337
|
-
*
|
|
4338
|
-
* @param id The id for the label
|
|
4339
|
-
* @param languageCode The language code associated with the label
|
|
4340
|
-
* @param translation The label text in the language specified by the language code
|
|
4341
|
-
* @returns
|
|
4342
|
-
*/
|
|
4343
|
-
addLabel(id, languageCode, translation) {
|
|
4344
|
-
const labels = this._initializeCollection(this.configuration, "labels");
|
|
4345
|
-
const labelConfig = this._initializeLabel(id, labels);
|
|
4346
|
-
const labelTranslation = this._getLabelTranslation(labelConfig.labels, languageCode);
|
|
4347
|
-
labelTranslation.label = translation;
|
|
4348
|
-
return this;
|
|
4349
|
-
}
|
|
4350
|
-
/**
|
|
4351
|
-
*
|
|
4352
|
-
* Adds multiple translations with the specified data
|
|
4353
|
-
*
|
|
4354
|
-
* @param id The id for the label
|
|
4355
|
-
* @param translations A record that holds language code to translations lookups
|
|
4356
|
-
* @returns
|
|
4357
|
-
*/
|
|
4358
|
-
addLabels(id, translations) {
|
|
4359
|
-
Object.entries(translations).forEach(([code, translation]) => this.addLabel(id, code, translation));
|
|
4360
|
-
return this;
|
|
4361
|
-
}
|
|
4362
|
-
/**
|
|
4363
|
-
*
|
|
4364
|
-
* Removes all translations with the given id
|
|
4365
|
-
*
|
|
4366
|
-
* @param id the id for the label
|
|
4367
|
-
* @returns
|
|
4368
|
-
*/
|
|
4369
|
-
removeLabel(id) {
|
|
4370
|
-
const idx = this.configuration.labels.findIndex((x) => x.id === id);
|
|
4371
|
-
if (idx > -1) this.configuration.labels.splice(idx, 1);
|
|
4372
|
-
else throw new Error(`Label with id '${id}' not found!`);
|
|
4373
|
-
return this;
|
|
4374
|
-
}
|
|
4375
4243
|
/**
|
|
4376
4244
|
*
|
|
4377
4245
|
* Starts an editor for the action from the `actions` list associated with the given id
|
|
@@ -4557,58 +4425,51 @@ var BaseController = class {
|
|
|
4557
4425
|
//#endregion
|
|
4558
4426
|
//#region src/controllers/label-controller.ts
|
|
4559
4427
|
/**
|
|
4560
|
-
* This controller attaches to the given selected element and renders the text
|
|
4428
|
+
* This controller attaches to the given selected element and renders the text
|
|
4429
|
+
* associated with the given translation key.
|
|
4561
4430
|
*
|
|
4562
|
-
* The controller
|
|
4431
|
+
* The controller listens for the `language-change` event and re-renders the text
|
|
4432
|
+
* with the new language after such an event.
|
|
4563
4433
|
*
|
|
4434
|
+
* Uses the rosetta-based locale system via `request-translation` event.
|
|
4564
4435
|
*/
|
|
4565
4436
|
var LabelController = class extends BaseController {
|
|
4566
|
-
currentLanguage = null;
|
|
4567
|
-
labelData = {};
|
|
4568
4437
|
name = "LabelController";
|
|
4569
|
-
|
|
4438
|
+
_eventbus = null;
|
|
4570
4439
|
init(operationData) {
|
|
4571
4440
|
this.operationData = Object.assign({}, operationData);
|
|
4572
4441
|
}
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4442
|
+
/**
|
|
4443
|
+
* Sets the translation key and re-renders the label.
|
|
4444
|
+
*/
|
|
4445
|
+
setTranslationKey(newKey) {
|
|
4446
|
+
if (this.operationData) {
|
|
4447
|
+
this.operationData.translationKey = newKey;
|
|
4576
4448
|
this._setLabel();
|
|
4577
4449
|
}
|
|
4578
4450
|
}
|
|
4579
4451
|
attach(eventbus$1) {
|
|
4580
4452
|
if (!this.operationData) return;
|
|
4581
|
-
this.
|
|
4582
|
-
this.requestLabelDataBound = this._requestLabelData.bind(this, eventbus$1);
|
|
4583
|
-
this.requestLabelDataBound(this.operationData.labelId);
|
|
4453
|
+
this._eventbus = eventbus$1;
|
|
4584
4454
|
this._setLabel();
|
|
4585
4455
|
this.addListener(eventbus$1, "language-change", this._handleLanguageChange);
|
|
4586
4456
|
}
|
|
4587
|
-
_requestLabelData(eventbus$1, labelId) {
|
|
4588
|
-
const labelCollection = eventbus$1.request("request-label-collection", labelId);
|
|
4589
|
-
if (labelCollection) this._createTextDataLookup(labelCollection);
|
|
4590
|
-
else throw new Error(`Label id '${labelId}' does not exist!`);
|
|
4591
|
-
}
|
|
4592
4457
|
_setLabel() {
|
|
4593
|
-
if (this.
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4458
|
+
if (!this._eventbus || !this.operationData?.translationKey) return;
|
|
4459
|
+
const text = this._eventbus.request("request-translation", this.operationData.translationKey) ?? "";
|
|
4460
|
+
this._applyText(text);
|
|
4461
|
+
}
|
|
4462
|
+
_applyText(text) {
|
|
4463
|
+
if (!this.operationData?.attributeName) this.operationData?.selectedElement.html(text);
|
|
4464
|
+
else this.operationData?.selectedElement.attr(this.operationData?.attributeName, text);
|
|
4598
4465
|
}
|
|
4599
4466
|
detach(eventbus$1) {
|
|
4600
4467
|
super.detach(eventbus$1);
|
|
4601
|
-
this.
|
|
4468
|
+
this._eventbus = null;
|
|
4602
4469
|
}
|
|
4603
|
-
_handleLanguageChange(
|
|
4604
|
-
this.currentLanguage = code;
|
|
4470
|
+
_handleLanguageChange(_code) {
|
|
4605
4471
|
this._setLabel();
|
|
4606
4472
|
}
|
|
4607
|
-
_createTextDataLookup(data) {
|
|
4608
|
-
data.forEach((d) => {
|
|
4609
|
-
this.labelData[d.languageCode] = d.label;
|
|
4610
|
-
});
|
|
4611
|
-
}
|
|
4612
4473
|
};
|
|
4613
4474
|
|
|
4614
4475
|
//#endregion
|
|
@@ -4861,10 +4722,10 @@ var NavigationController = class extends BaseController {
|
|
|
4861
4722
|
}
|
|
4862
4723
|
_handleRequestCurrentNavigation(resultCallback) {
|
|
4863
4724
|
if (this.activeNavigationPoint) {
|
|
4864
|
-
const
|
|
4725
|
+
const title = this.eventbus?.request("request-translation", this.activeNavigationPoint.labelId) ?? "";
|
|
4865
4726
|
resultCallback({
|
|
4866
4727
|
navigationData: this.activeNavigationPoint,
|
|
4867
|
-
title
|
|
4728
|
+
title
|
|
4868
4729
|
});
|
|
4869
4730
|
} else resultCallback(null);
|
|
4870
4731
|
}
|
|
@@ -4880,11 +4741,10 @@ var NavigationController = class extends BaseController {
|
|
|
4880
4741
|
}
|
|
4881
4742
|
_pushCurrentState(position = -1) {
|
|
4882
4743
|
if (!this.activeNavigationPoint) return;
|
|
4883
|
-
const
|
|
4884
|
-
if (!labelCtrl) return;
|
|
4744
|
+
const title = this.eventbus?.request("request-translation", this.activeNavigationPoint.labelId) ?? "";
|
|
4885
4745
|
const state = {
|
|
4886
4746
|
navigationData: this.activeNavigationPoint,
|
|
4887
|
-
title
|
|
4747
|
+
title,
|
|
4888
4748
|
position: -1
|
|
4889
4749
|
};
|
|
4890
4750
|
if (position > -1) state.position = position;
|
|
@@ -4938,17 +4798,17 @@ var NavigationController = class extends BaseController {
|
|
|
4938
4798
|
if (navData.autoNext) this.eventbus?.broadcast("request-video-url", [navData.next.videoUrlIndex]);
|
|
4939
4799
|
else this.eventbus?.broadcast("request-video-cleanup", []);
|
|
4940
4800
|
}
|
|
4941
|
-
_addLabel(parentElm,
|
|
4801
|
+
_addLabel(parentElm, translationKey) {
|
|
4942
4802
|
const data = {
|
|
4943
4803
|
selectedElement: parentElm,
|
|
4944
|
-
|
|
4804
|
+
translationKey
|
|
4945
4805
|
};
|
|
4946
4806
|
const instance = this.eventbus?.request("request-instance", "LabelController");
|
|
4947
4807
|
if (instance) {
|
|
4948
4808
|
instance.init(data);
|
|
4949
4809
|
instance.attach(this.eventbus);
|
|
4950
4810
|
this.labelControllers.push(instance);
|
|
4951
|
-
this.ctrlLookup[
|
|
4811
|
+
this.ctrlLookup[translationKey] = instance;
|
|
4952
4812
|
}
|
|
4953
4813
|
}
|
|
4954
4814
|
_buildNavigationData(data) {
|
|
@@ -6943,51 +6803,6 @@ var OperationMetadataProvider = class {
|
|
|
6943
6803
|
return getMetadata();
|
|
6944
6804
|
}
|
|
6945
6805
|
};
|
|
6946
|
-
/**
|
|
6947
|
-
*
|
|
6948
|
-
* Provider for all the available event names
|
|
6949
|
-
*
|
|
6950
|
-
*/
|
|
6951
|
-
var TimeLineEventNamesProvider = class {
|
|
6952
|
-
getEventNames() {
|
|
6953
|
-
return [
|
|
6954
|
-
"timeline-play-toggle-request",
|
|
6955
|
-
"timeline-play-request",
|
|
6956
|
-
"timeline-stop-request",
|
|
6957
|
-
"timeline-pause-request",
|
|
6958
|
-
"timeline-seek-request",
|
|
6959
|
-
"timeline-resize-request",
|
|
6960
|
-
"timeline-container-request",
|
|
6961
|
-
"timeline-duration-request",
|
|
6962
|
-
"timeline-request-current-timeline",
|
|
6963
|
-
"timeline-duration",
|
|
6964
|
-
"timeline-time",
|
|
6965
|
-
"timeline-seeked",
|
|
6966
|
-
"timeline-complete",
|
|
6967
|
-
"timeline-restart",
|
|
6968
|
-
"timeline-play",
|
|
6969
|
-
"timeline-stop",
|
|
6970
|
-
"timeline-pause",
|
|
6971
|
-
"timeline-seek",
|
|
6972
|
-
"timeline-resize",
|
|
6973
|
-
"timeline-current-timeline-change",
|
|
6974
|
-
"timeline-firstframe",
|
|
6975
|
-
"request-instance",
|
|
6976
|
-
"request-action",
|
|
6977
|
-
"request-function",
|
|
6978
|
-
"request-timeline-uri",
|
|
6979
|
-
"before-request-timeline-uri",
|
|
6980
|
-
"request-engine-root",
|
|
6981
|
-
"request-current-timeline-position",
|
|
6982
|
-
"request-timeline-cleanup",
|
|
6983
|
-
"request-label-collection",
|
|
6984
|
-
"request-label-collections",
|
|
6985
|
-
"request-current-language",
|
|
6986
|
-
"language-change",
|
|
6987
|
-
"dom-mutation"
|
|
6988
|
-
];
|
|
6989
|
-
}
|
|
6990
|
-
};
|
|
6991
6806
|
|
|
6992
6807
|
//#endregion
|
|
6993
6808
|
//#region src/configuration/api/subtitle-converter.ts
|
|
@@ -7165,7 +6980,6 @@ var ConfigurationResolver = class {
|
|
|
7165
6980
|
availableLanguages: deepCopy(configuration.availableLanguages),
|
|
7166
6981
|
actions: resolveActions(configuration.actions, this.importer, this.eventbus),
|
|
7167
6982
|
initActions: resolveActions(configuration.initActions, this.importer, this.eventbus),
|
|
7168
|
-
labels: deepCopy(configuration.labels),
|
|
7169
6983
|
timelineFlow: deepCopy(configuration.timelineFlow),
|
|
7170
6984
|
timelines: resolveTimelines(configuration.timelines, this.importer, this.eventbus)
|
|
7171
6985
|
};
|
|
@@ -7287,13 +7101,17 @@ prefix the action name with \`end:\`.`,
|
|
|
7287
7101
|
//#region src/controllers/metadata/label-controller.ts
|
|
7288
7102
|
function LabelController$1() {
|
|
7289
7103
|
return {
|
|
7290
|
-
description: `This controller attaches to the given selected element and renders the text
|
|
7104
|
+
description: `This controller attaches to the given selected element and renders the text
|
|
7105
|
+
associated with the given translation key.
|
|
7106
|
+
|
|
7107
|
+
The controller listens for the \`language-change\` event and re-renders the text
|
|
7108
|
+
with the new language after such an event.
|
|
7291
7109
|
|
|
7292
|
-
|
|
7110
|
+
Uses the rosetta-based locale system via \`request-translation\` event.`,
|
|
7293
7111
|
dependentProperties: ["selectedElement"],
|
|
7294
7112
|
properties: {
|
|
7295
|
-
|
|
7296
|
-
type: "ParameterType:
|
|
7113
|
+
translationKey: {
|
|
7114
|
+
type: "ParameterType:string",
|
|
7297
7115
|
required: true
|
|
7298
7116
|
},
|
|
7299
7117
|
attributeName: { type: [{ value: "undefined" }, { value: "string" }] }
|
|
@@ -8358,6 +8176,285 @@ var BasePositionSource = class {
|
|
|
8358
8176
|
}
|
|
8359
8177
|
};
|
|
8360
8178
|
|
|
8179
|
+
//#endregion
|
|
8180
|
+
//#region src/timelineproviders/position-sources/keyboard-step-source.ts
|
|
8181
|
+
const hotkeys = hk.default || hk;
|
|
8182
|
+
/**
|
|
8183
|
+
* Key bindings used by KeyboardStepSource.
|
|
8184
|
+
*/
|
|
8185
|
+
const KEY_BINDINGS = {
|
|
8186
|
+
stepForward: "right",
|
|
8187
|
+
stepBackward: "left",
|
|
8188
|
+
largeStepForward: "shift+right",
|
|
8189
|
+
largeStepBackward: "shift+left",
|
|
8190
|
+
jumpToStart: "home",
|
|
8191
|
+
jumpToEnd: "end",
|
|
8192
|
+
verticalPrev: "up",
|
|
8193
|
+
verticalNext: "down"
|
|
8194
|
+
};
|
|
8195
|
+
/**
|
|
8196
|
+
* Keyboard-based position source for stepping through a timeline.
|
|
8197
|
+
*
|
|
8198
|
+
* Supports:
|
|
8199
|
+
* - Left/Right arrows: step by `stepSize` (default 1s)
|
|
8200
|
+
* - Shift+Left/Right: large step by `largeStepSize` (default 10s)
|
|
8201
|
+
* - Home/End: jump to start/end
|
|
8202
|
+
* - Up/Down: configurable (timeline switch, chapter navigation, or disabled)
|
|
8203
|
+
*
|
|
8204
|
+
* @example
|
|
8205
|
+
* ```typescript
|
|
8206
|
+
* const source = new KeyboardStepSource({
|
|
8207
|
+
* duration: 60,
|
|
8208
|
+
* verticalMode: 'chapter-navigation',
|
|
8209
|
+
* markers: [0, 10, 20, 30, 40, 50],
|
|
8210
|
+
* });
|
|
8211
|
+
*
|
|
8212
|
+
* await source.init();
|
|
8213
|
+
*
|
|
8214
|
+
* source.onPosition((position) => {
|
|
8215
|
+
* console.log(`Position: ${position}s`);
|
|
8216
|
+
* });
|
|
8217
|
+
*
|
|
8218
|
+
* source.onMarkerJump((index, position) => {
|
|
8219
|
+
* console.log(`Jumped to marker ${index} at ${position}s`);
|
|
8220
|
+
* });
|
|
8221
|
+
*
|
|
8222
|
+
* await source.activate();
|
|
8223
|
+
* ```
|
|
8224
|
+
*/
|
|
8225
|
+
var KeyboardStepSource = class extends BasePositionSource {
|
|
8226
|
+
_stepSize;
|
|
8227
|
+
_largeStepSize;
|
|
8228
|
+
_verticalMode;
|
|
8229
|
+
_wrapNavigation;
|
|
8230
|
+
_markers;
|
|
8231
|
+
_targetElementConfig;
|
|
8232
|
+
_targetElement;
|
|
8233
|
+
_scopeId;
|
|
8234
|
+
_timelineChangeCallbacks = [];
|
|
8235
|
+
_markerJumpCallbacks = [];
|
|
8236
|
+
/**
|
|
8237
|
+
* Create a new keyboard-based position source.
|
|
8238
|
+
*
|
|
8239
|
+
* @param config - Configuration options
|
|
8240
|
+
*/
|
|
8241
|
+
constructor(config) {
|
|
8242
|
+
super(config.duration);
|
|
8243
|
+
this._stepSize = config.stepSize ?? 1;
|
|
8244
|
+
this._largeStepSize = config.largeStepSize ?? 10;
|
|
8245
|
+
this._verticalMode = config.verticalMode;
|
|
8246
|
+
this._wrapNavigation = config.wrapNavigation ?? true;
|
|
8247
|
+
this._markers = config.markers ? [...config.markers] : [];
|
|
8248
|
+
this._targetElementConfig = config.targetElement;
|
|
8249
|
+
this._scopeId = `keyboard-step-source-${v4()}`;
|
|
8250
|
+
}
|
|
8251
|
+
doInit() {
|
|
8252
|
+
this._markers.sort((a, b) => a - b);
|
|
8253
|
+
if (typeof this._targetElementConfig === "string") {
|
|
8254
|
+
const element = document.querySelector(this._targetElementConfig);
|
|
8255
|
+
if (element instanceof HTMLElement) this._targetElement = element;
|
|
8256
|
+
} else if (this._targetElementConfig instanceof HTMLElement) this._targetElement = this._targetElementConfig;
|
|
8257
|
+
return Promise.resolve();
|
|
8258
|
+
}
|
|
8259
|
+
doDestroy() {
|
|
8260
|
+
this._unbindKeys();
|
|
8261
|
+
}
|
|
8262
|
+
startTicking() {
|
|
8263
|
+
this._bindKeys();
|
|
8264
|
+
}
|
|
8265
|
+
stopTicking() {
|
|
8266
|
+
this._unbindKeys();
|
|
8267
|
+
}
|
|
8268
|
+
/**
|
|
8269
|
+
* Seek to a specific position.
|
|
8270
|
+
*
|
|
8271
|
+
* Position is clamped to the valid range [0, duration].
|
|
8272
|
+
*
|
|
8273
|
+
* @param position - Target position in seconds
|
|
8274
|
+
* @returns Actual position after seek (may be clamped)
|
|
8275
|
+
*/
|
|
8276
|
+
async seek(position) {
|
|
8277
|
+
const clampedPosition = Math.max(0, Math.min(position, this.getDuration()));
|
|
8278
|
+
this.setPosition(clampedPosition);
|
|
8279
|
+
return clampedPosition;
|
|
8280
|
+
}
|
|
8281
|
+
/**
|
|
8282
|
+
* Register callback for timeline change requests (timeline-switch mode).
|
|
8283
|
+
*
|
|
8284
|
+
* @param callback - Called with 'prev' or 'next' when Up/Down is pressed
|
|
8285
|
+
*/
|
|
8286
|
+
onTimelineChangeRequest(callback) {
|
|
8287
|
+
this._timelineChangeCallbacks.push(callback);
|
|
8288
|
+
}
|
|
8289
|
+
/**
|
|
8290
|
+
* Register callback for marker jumps (chapter-navigation mode).
|
|
8291
|
+
*
|
|
8292
|
+
* @param callback - Called with marker index and position when jumping
|
|
8293
|
+
*/
|
|
8294
|
+
onMarkerJump(callback) {
|
|
8295
|
+
this._markerJumpCallbacks.push(callback);
|
|
8296
|
+
}
|
|
8297
|
+
/**
|
|
8298
|
+
* Bind all keyboard handlers.
|
|
8299
|
+
*/
|
|
8300
|
+
_bindKeys() {
|
|
8301
|
+
const options = { scope: this._scopeId };
|
|
8302
|
+
if (this._targetElement) options.element = this._targetElement;
|
|
8303
|
+
hotkeys.setScope(this._scopeId);
|
|
8304
|
+
hotkeys(KEY_BINDINGS.stepForward, options, (event) => {
|
|
8305
|
+
event.preventDefault();
|
|
8306
|
+
this._handleStepForward();
|
|
8307
|
+
});
|
|
8308
|
+
hotkeys(KEY_BINDINGS.stepBackward, options, (event) => {
|
|
8309
|
+
event.preventDefault();
|
|
8310
|
+
this._handleStepBackward();
|
|
8311
|
+
});
|
|
8312
|
+
hotkeys(KEY_BINDINGS.largeStepForward, options, (event) => {
|
|
8313
|
+
event.preventDefault();
|
|
8314
|
+
this._handleLargeStepForward();
|
|
8315
|
+
});
|
|
8316
|
+
hotkeys(KEY_BINDINGS.largeStepBackward, options, (event) => {
|
|
8317
|
+
event.preventDefault();
|
|
8318
|
+
this._handleLargeStepBackward();
|
|
8319
|
+
});
|
|
8320
|
+
hotkeys(KEY_BINDINGS.jumpToStart, options, (event) => {
|
|
8321
|
+
event.preventDefault();
|
|
8322
|
+
this._handleJumpToStart();
|
|
8323
|
+
});
|
|
8324
|
+
hotkeys(KEY_BINDINGS.jumpToEnd, options, (event) => {
|
|
8325
|
+
event.preventDefault();
|
|
8326
|
+
this._handleJumpToEnd();
|
|
8327
|
+
});
|
|
8328
|
+
if (this._verticalMode !== "disabled") {
|
|
8329
|
+
hotkeys(KEY_BINDINGS.verticalPrev, options, (event) => {
|
|
8330
|
+
event.preventDefault();
|
|
8331
|
+
this._handleVerticalPrev();
|
|
8332
|
+
});
|
|
8333
|
+
hotkeys(KEY_BINDINGS.verticalNext, options, (event) => {
|
|
8334
|
+
event.preventDefault();
|
|
8335
|
+
this._handleVerticalNext();
|
|
8336
|
+
});
|
|
8337
|
+
}
|
|
8338
|
+
}
|
|
8339
|
+
/**
|
|
8340
|
+
* Unbind all keyboard handlers.
|
|
8341
|
+
*/
|
|
8342
|
+
_unbindKeys() {
|
|
8343
|
+
hotkeys.deleteScope(this._scopeId);
|
|
8344
|
+
}
|
|
8345
|
+
_handleStepForward() {
|
|
8346
|
+
const currentPosition = this.getPosition();
|
|
8347
|
+
const duration = this.getDuration();
|
|
8348
|
+
let newPosition = currentPosition + this._stepSize;
|
|
8349
|
+
if (newPosition > duration) {
|
|
8350
|
+
if (this._wrapNavigation) {
|
|
8351
|
+
newPosition = 0;
|
|
8352
|
+
this.setPosition(newPosition);
|
|
8353
|
+
this.emitBoundary("start");
|
|
8354
|
+
}
|
|
8355
|
+
} else this.setPosition(newPosition);
|
|
8356
|
+
}
|
|
8357
|
+
_handleStepBackward() {
|
|
8358
|
+
const currentPosition = this.getPosition();
|
|
8359
|
+
const duration = this.getDuration();
|
|
8360
|
+
let newPosition = currentPosition - this._stepSize;
|
|
8361
|
+
if (newPosition < 0) {
|
|
8362
|
+
if (this._wrapNavigation) {
|
|
8363
|
+
newPosition = duration;
|
|
8364
|
+
this.setPosition(newPosition);
|
|
8365
|
+
this.emitBoundary("end");
|
|
8366
|
+
}
|
|
8367
|
+
} else this.setPosition(newPosition);
|
|
8368
|
+
}
|
|
8369
|
+
_handleLargeStepForward() {
|
|
8370
|
+
const currentPosition = this.getPosition();
|
|
8371
|
+
const duration = this.getDuration();
|
|
8372
|
+
let newPosition = currentPosition + this._largeStepSize;
|
|
8373
|
+
if (newPosition > duration) if (this._wrapNavigation) {
|
|
8374
|
+
newPosition = 0;
|
|
8375
|
+
this.setPosition(newPosition);
|
|
8376
|
+
this.emitBoundary("start");
|
|
8377
|
+
} else {
|
|
8378
|
+
newPosition = duration;
|
|
8379
|
+
this.setPosition(newPosition);
|
|
8380
|
+
}
|
|
8381
|
+
else this.setPosition(newPosition);
|
|
8382
|
+
}
|
|
8383
|
+
_handleLargeStepBackward() {
|
|
8384
|
+
const currentPosition = this.getPosition();
|
|
8385
|
+
const duration = this.getDuration();
|
|
8386
|
+
let newPosition = currentPosition - this._largeStepSize;
|
|
8387
|
+
if (newPosition < 0) if (this._wrapNavigation) {
|
|
8388
|
+
newPosition = duration;
|
|
8389
|
+
this.setPosition(newPosition);
|
|
8390
|
+
this.emitBoundary("end");
|
|
8391
|
+
} else {
|
|
8392
|
+
newPosition = 0;
|
|
8393
|
+
this.setPosition(newPosition);
|
|
8394
|
+
}
|
|
8395
|
+
else this.setPosition(newPosition);
|
|
8396
|
+
}
|
|
8397
|
+
_handleJumpToStart() {
|
|
8398
|
+
this.setPosition(0);
|
|
8399
|
+
this.emitBoundary("start");
|
|
8400
|
+
}
|
|
8401
|
+
_handleJumpToEnd() {
|
|
8402
|
+
this.setPosition(this.getDuration());
|
|
8403
|
+
this.emitBoundary("end");
|
|
8404
|
+
}
|
|
8405
|
+
_handleVerticalPrev() {
|
|
8406
|
+
if (this._verticalMode === "timeline-switch") this._emitTimelineChange("prev");
|
|
8407
|
+
else if (this._verticalMode === "chapter-navigation") this._jumpToPreviousMarker();
|
|
8408
|
+
}
|
|
8409
|
+
_handleVerticalNext() {
|
|
8410
|
+
if (this._verticalMode === "timeline-switch") this._emitTimelineChange("next");
|
|
8411
|
+
else if (this._verticalMode === "chapter-navigation") this._jumpToNextMarker();
|
|
8412
|
+
}
|
|
8413
|
+
_emitTimelineChange(direction) {
|
|
8414
|
+
for (const callback of this._timelineChangeCallbacks) callback(direction);
|
|
8415
|
+
}
|
|
8416
|
+
_jumpToPreviousMarker() {
|
|
8417
|
+
if (this._markers.length === 0) return;
|
|
8418
|
+
const currentPosition = this.getPosition();
|
|
8419
|
+
const currentMarkerIndex = this._findCurrentMarkerIndex(currentPosition);
|
|
8420
|
+
let targetIndex;
|
|
8421
|
+
if (this._markers[currentMarkerIndex] === currentPosition) if (currentMarkerIndex <= 0) if (this._wrapNavigation) targetIndex = this._markers.length - 1;
|
|
8422
|
+
else return;
|
|
8423
|
+
else targetIndex = currentMarkerIndex - 1;
|
|
8424
|
+
else targetIndex = currentMarkerIndex;
|
|
8425
|
+
const targetPosition = this._markers[targetIndex];
|
|
8426
|
+
this.setPosition(targetPosition);
|
|
8427
|
+
this._emitMarkerJump(targetIndex, targetPosition);
|
|
8428
|
+
}
|
|
8429
|
+
_jumpToNextMarker() {
|
|
8430
|
+
if (this._markers.length === 0) return;
|
|
8431
|
+
const currentPosition = this.getPosition();
|
|
8432
|
+
const currentMarkerIndex = this._findCurrentMarkerIndex(currentPosition);
|
|
8433
|
+
let targetIndex;
|
|
8434
|
+
if (currentMarkerIndex >= this._markers.length - 1) if (this._wrapNavigation) targetIndex = 0;
|
|
8435
|
+
else return;
|
|
8436
|
+
else targetIndex = currentMarkerIndex + 1;
|
|
8437
|
+
const targetPosition = this._markers[targetIndex];
|
|
8438
|
+
this.setPosition(targetPosition);
|
|
8439
|
+
this._emitMarkerJump(targetIndex, targetPosition);
|
|
8440
|
+
}
|
|
8441
|
+
/**
|
|
8442
|
+
* Find the index of the current or previous marker.
|
|
8443
|
+
*
|
|
8444
|
+
* If position matches a marker exactly, returns that marker's index.
|
|
8445
|
+
* Otherwise, returns the index of the marker before the current position.
|
|
8446
|
+
* Returns 0 if before first marker.
|
|
8447
|
+
*/
|
|
8448
|
+
_findCurrentMarkerIndex(position) {
|
|
8449
|
+
if (this._markers.length === 0) return -1;
|
|
8450
|
+
for (let i = this._markers.length - 1; i >= 0; i--) if (position >= this._markers[i]) return i;
|
|
8451
|
+
return 0;
|
|
8452
|
+
}
|
|
8453
|
+
_emitMarkerJump(markerIndex, position) {
|
|
8454
|
+
for (const callback of this._markerJumpCallbacks) callback(markerIndex, position);
|
|
8455
|
+
}
|
|
8456
|
+
};
|
|
8457
|
+
|
|
8361
8458
|
//#endregion
|
|
8362
8459
|
//#region src/util/animation-interval.ts
|
|
8363
8460
|
function animationInterval(ms, signal, callback) {
|
|
@@ -9005,6 +9102,7 @@ var SimplePlaylist = class {
|
|
|
9005
9102
|
var timelineproviders_exports = /* @__PURE__ */ __export({
|
|
9006
9103
|
BasePositionSource: () => BasePositionSource,
|
|
9007
9104
|
DomContainerProvider: () => DomContainerProvider,
|
|
9105
|
+
KeyboardStepSource: () => KeyboardStepSource,
|
|
9008
9106
|
RafPositionSource: () => RafPositionSource,
|
|
9009
9107
|
ScrollPositionSource: () => ScrollPositionSource,
|
|
9010
9108
|
SimplePlaylist: () => SimplePlaylist,
|
|
@@ -9168,11 +9266,11 @@ var EligiusEngine = class EligiusEngine {
|
|
|
9168
9266
|
get engineRoot() {
|
|
9169
9267
|
return $(this.configuration.containerSelector);
|
|
9170
9268
|
}
|
|
9171
|
-
constructor(configuration, eventbus$1, timelineProviders,
|
|
9269
|
+
constructor(configuration, eventbus$1, timelineProviders, localeManager) {
|
|
9172
9270
|
this.configuration = configuration;
|
|
9173
9271
|
this.eventbus = eventbus$1;
|
|
9174
9272
|
this.timelineProviders = timelineProviders;
|
|
9175
|
-
this.
|
|
9273
|
+
this.localeManager = localeManager;
|
|
9176
9274
|
}
|
|
9177
9275
|
/**
|
|
9178
9276
|
* Subscribe to engine events
|
|
@@ -9340,7 +9438,7 @@ var EligiusEngine = class EligiusEngine {
|
|
|
9340
9438
|
*/
|
|
9341
9439
|
async destroy() {
|
|
9342
9440
|
await this._cleanUp();
|
|
9343
|
-
this.
|
|
9441
|
+
this.localeManager.destroy();
|
|
9344
9442
|
this._activePositionSource = void 0;
|
|
9345
9443
|
this._activeContainerProvider = void 0;
|
|
9346
9444
|
this._activePlaylist = void 0;
|
|
@@ -9552,93 +9650,159 @@ var EligiusResourceImporter = class {
|
|
|
9552
9650
|
};
|
|
9553
9651
|
|
|
9554
9652
|
//#endregion
|
|
9555
|
-
//#region src/
|
|
9556
|
-
function setGlobal(name, value) {
|
|
9557
|
-
const cache$2 = getGlobals();
|
|
9558
|
-
cache$2[name] = value;
|
|
9559
|
-
}
|
|
9560
|
-
|
|
9561
|
-
//#endregion
|
|
9562
|
-
//#region src/language-manager.ts
|
|
9653
|
+
//#region src/locale/locale-manager.ts
|
|
9563
9654
|
/**
|
|
9564
|
-
*
|
|
9655
|
+
* LocaleManager - Core locale management class wrapping rosetta
|
|
9656
|
+
* Feature: 005-rosetta-locale-manager
|
|
9565
9657
|
*
|
|
9566
|
-
*
|
|
9567
|
-
*
|
|
9568
|
-
*
|
|
9569
|
-
* Eventbus integration is handled by LanguageEventbusAdapter.
|
|
9658
|
+
* Provides translation retrieval, locale switching, and event emission
|
|
9659
|
+
* for the Eligius timeline engine.
|
|
9570
9660
|
*/
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
|
|
9661
|
+
/**
|
|
9662
|
+
* LocaleManager wraps the rosetta library to provide translation management
|
|
9663
|
+
* with event-based locale switching support.
|
|
9664
|
+
*/
|
|
9665
|
+
var LocaleManager = class {
|
|
9666
|
+
_rosetta;
|
|
9667
|
+
_listeners;
|
|
9668
|
+
_locale;
|
|
9669
|
+
_availableLocales;
|
|
9670
|
+
_debug;
|
|
9671
|
+
/** Raw locale data for debug mode variable checking (rosetta interpolates on access) */
|
|
9672
|
+
_rawLocaleData;
|
|
9673
|
+
/**
|
|
9674
|
+
* Creates a new LocaleManager instance.
|
|
9675
|
+
*
|
|
9676
|
+
* @param options - Configuration options for the locale manager
|
|
9677
|
+
*/
|
|
9678
|
+
constructor(options) {
|
|
9679
|
+
this._rosetta = rosetta();
|
|
9680
|
+
this._listeners = /* @__PURE__ */ new Map();
|
|
9681
|
+
this._locale = options.defaultLocale;
|
|
9682
|
+
this._availableLocales = /* @__PURE__ */ new Set();
|
|
9683
|
+
this._debug = options.debug ?? false;
|
|
9684
|
+
this._rawLocaleData = /* @__PURE__ */ new Map();
|
|
9685
|
+
this._rosetta.locale(this._locale);
|
|
9578
9686
|
}
|
|
9579
|
-
/**
|
|
9580
|
-
|
|
9581
|
-
|
|
9687
|
+
/**
|
|
9688
|
+
* Gets the current locale.
|
|
9689
|
+
*/
|
|
9690
|
+
get locale() {
|
|
9691
|
+
return this._locale;
|
|
9582
9692
|
}
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
this._availableLanguages = this._extractAvailableLanguages(labels);
|
|
9693
|
+
/**
|
|
9694
|
+
* Gets the list of available locales.
|
|
9695
|
+
*/
|
|
9696
|
+
get availableLocales() {
|
|
9697
|
+
return Array.from(this._availableLocales);
|
|
9589
9698
|
}
|
|
9590
9699
|
/**
|
|
9591
|
-
*
|
|
9592
|
-
*
|
|
9593
|
-
* @param
|
|
9594
|
-
* @
|
|
9700
|
+
* Loads translation data for a specific locale.
|
|
9701
|
+
*
|
|
9702
|
+
* @param locale - The locale code (e.g., 'en-US', 'nl-NL')
|
|
9703
|
+
* @param data - The translation data object
|
|
9595
9704
|
*/
|
|
9596
|
-
|
|
9597
|
-
|
|
9705
|
+
loadLocale(locale, data) {
|
|
9706
|
+
this._rosetta.set(locale, data);
|
|
9707
|
+
this._availableLocales.add(locale);
|
|
9708
|
+
if (this._debug) {
|
|
9709
|
+
this._rawLocaleData.set(locale, data);
|
|
9710
|
+
console.log(`[LocaleManager] Loaded locale: ${locale}`);
|
|
9711
|
+
}
|
|
9712
|
+
}
|
|
9713
|
+
/**
|
|
9714
|
+
* Retrieves a translation for the given key.
|
|
9715
|
+
*
|
|
9716
|
+
* @param key - The translation key (string or array of strings for nested keys)
|
|
9717
|
+
* @param params - Optional parameters for interpolation
|
|
9718
|
+
* @param locale - Optional locale override (uses current locale if not specified)
|
|
9719
|
+
* @returns The translated string, or empty string if key not found
|
|
9720
|
+
*/
|
|
9721
|
+
t(key, params, locale) {
|
|
9722
|
+
const targetLocale = locale ?? this._locale;
|
|
9723
|
+
if (locale && locale !== this._locale) this._rosetta.locale(targetLocale);
|
|
9724
|
+
if (this._debug && params) this._checkMissingInterpolationVars(key, params);
|
|
9725
|
+
const result = this._rosetta.t(key, params) ?? "";
|
|
9726
|
+
if (locale && locale !== this._locale) this._rosetta.locale(this._locale);
|
|
9727
|
+
if (this._debug && result === "") console.warn(`[LocaleManager] Missing translation for key: ${Array.isArray(key) ? key.join(".") : key}`);
|
|
9728
|
+
return result;
|
|
9598
9729
|
}
|
|
9599
9730
|
/**
|
|
9600
|
-
*
|
|
9601
|
-
*
|
|
9602
|
-
|
|
9731
|
+
* Checks for missing interpolation variables in debug mode.
|
|
9732
|
+
* Extracts {{variable}} patterns from raw translation and compares with provided params.
|
|
9733
|
+
*/
|
|
9734
|
+
_checkMissingInterpolationVars(key, params) {
|
|
9735
|
+
const rawTranslation = this._getRawTranslation(key);
|
|
9736
|
+
if (typeof rawTranslation !== "string") return;
|
|
9737
|
+
const variablePattern = /\{\{(\w+)\}\}/g;
|
|
9738
|
+
const requiredVars = [];
|
|
9739
|
+
let match;
|
|
9740
|
+
while ((match = variablePattern.exec(rawTranslation)) !== null) requiredVars.push(match[1]);
|
|
9741
|
+
const missingVars = requiredVars.filter((varName) => !(varName in params));
|
|
9742
|
+
if (missingVars.length > 0) {
|
|
9743
|
+
const keyStr = Array.isArray(key) ? key.join(".") : key;
|
|
9744
|
+
console.warn(`[LocaleManager] Missing interpolation variable(s) for key '${keyStr}': ${missingVars.join(", ")}`);
|
|
9745
|
+
}
|
|
9746
|
+
}
|
|
9747
|
+
/**
|
|
9748
|
+
* Gets raw translation value from stored locale data (without interpolation).
|
|
9603
9749
|
*/
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9750
|
+
_getRawTranslation(key) {
|
|
9751
|
+
const localeData = this._rawLocaleData.get(this._locale);
|
|
9752
|
+
if (!localeData) return;
|
|
9753
|
+
const keyPath = Array.isArray(key) ? key : key.split(".");
|
|
9754
|
+
let current = localeData;
|
|
9755
|
+
for (const segment of keyPath) {
|
|
9756
|
+
if (current === null || typeof current !== "object") return;
|
|
9757
|
+
current = current[segment];
|
|
9758
|
+
}
|
|
9759
|
+
return current;
|
|
9609
9760
|
}
|
|
9610
9761
|
/**
|
|
9611
|
-
*
|
|
9612
|
-
*
|
|
9613
|
-
* @
|
|
9762
|
+
* Sets the current locale and emits a change event.
|
|
9763
|
+
*
|
|
9764
|
+
* @param locale - The new locale to set
|
|
9614
9765
|
*/
|
|
9615
|
-
|
|
9616
|
-
|
|
9766
|
+
setLocale(locale) {
|
|
9767
|
+
const previousLocale = this._locale;
|
|
9768
|
+
this._locale = locale;
|
|
9769
|
+
this._rosetta.locale(locale);
|
|
9770
|
+
this._emit("change", locale, previousLocale);
|
|
9771
|
+
if (this._debug) console.log(`[LocaleManager] Locale changed: ${previousLocale} -> ${locale}`);
|
|
9617
9772
|
}
|
|
9618
9773
|
/**
|
|
9619
|
-
*
|
|
9620
|
-
*
|
|
9621
|
-
* @
|
|
9774
|
+
* Subscribes to a locale event.
|
|
9775
|
+
*
|
|
9776
|
+
* @param event - The event name to subscribe to
|
|
9777
|
+
* @param handler - The event handler function
|
|
9778
|
+
* @returns An unsubscribe function
|
|
9622
9779
|
*/
|
|
9623
|
-
|
|
9624
|
-
|
|
9780
|
+
on(event, handler) {
|
|
9781
|
+
if (!this._listeners.has(event)) this._listeners.set(event, /* @__PURE__ */ new Set());
|
|
9782
|
+
const handlers = this._listeners.get(event);
|
|
9783
|
+
handlers.add(handler);
|
|
9784
|
+
return () => {
|
|
9785
|
+
handlers.delete(handler);
|
|
9786
|
+
};
|
|
9625
9787
|
}
|
|
9626
9788
|
/**
|
|
9627
|
-
*
|
|
9789
|
+
* Destroys the LocaleManager, cleaning up all listeners and data.
|
|
9628
9790
|
*/
|
|
9629
9791
|
destroy() {
|
|
9630
|
-
this.
|
|
9792
|
+
this._listeners.clear();
|
|
9793
|
+
this._availableLocales.clear();
|
|
9794
|
+
this._rawLocaleData.clear();
|
|
9795
|
+
if (this._debug) console.log("[LocaleManager] Destroyed");
|
|
9631
9796
|
}
|
|
9632
|
-
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
|
|
9636
|
-
|
|
9637
|
-
|
|
9638
|
-
|
|
9639
|
-
const
|
|
9640
|
-
|
|
9641
|
-
return Array.from(languages);
|
|
9797
|
+
/**
|
|
9798
|
+
* Emits an event to all registered listeners.
|
|
9799
|
+
*
|
|
9800
|
+
* @param event - The event name
|
|
9801
|
+
* @param args - The event arguments
|
|
9802
|
+
*/
|
|
9803
|
+
_emit(event, ...args) {
|
|
9804
|
+
const handlers = this._listeners.get(event);
|
|
9805
|
+
if (handlers) for (const handler of handlers) handler(...args);
|
|
9642
9806
|
}
|
|
9643
9807
|
};
|
|
9644
9808
|
|
|
@@ -9711,12 +9875,12 @@ var EngineFactory = class {
|
|
|
9711
9875
|
* This method:
|
|
9712
9876
|
* - Resolves the configuration
|
|
9713
9877
|
* - Creates timeline providers
|
|
9714
|
-
* - Instantiates the engine and
|
|
9878
|
+
* - Instantiates the engine and locale manager
|
|
9715
9879
|
* - Creates and connects adapters for eventbus integration
|
|
9716
9880
|
*
|
|
9717
9881
|
* @param configuration - The engine configuration
|
|
9718
9882
|
* @param resolver - Optional custom configuration resolver
|
|
9719
|
-
* @returns Engine result with engine,
|
|
9883
|
+
* @returns Engine result with engine, locale manager, eventbus, and destroy function
|
|
9720
9884
|
*/
|
|
9721
9885
|
createEngine(configuration, resolver) {
|
|
9722
9886
|
const { systemName } = configuration.engine;
|
|
@@ -9731,22 +9895,23 @@ var EngineFactory = class {
|
|
|
9731
9895
|
const [actionLookup, resolvedConfiguration] = resolver.process(configuration, actionRegistryListener);
|
|
9732
9896
|
this._actionsLookup = actionLookup;
|
|
9733
9897
|
const timelineProviders = this._createTimelineProviders(resolvedConfiguration);
|
|
9734
|
-
const { language,
|
|
9735
|
-
const
|
|
9736
|
-
const
|
|
9898
|
+
const { language, locales } = configuration;
|
|
9899
|
+
const localeManager = new LocaleManager({ defaultLocale: language });
|
|
9900
|
+
if (locales) for (const [locale, data] of Object.entries(locales)) localeManager.loadLocale(locale, data);
|
|
9901
|
+
const engineInstance = new EngineClass(resolvedConfiguration, this._eventbus, timelineProviders, localeManager);
|
|
9737
9902
|
const engineEventbusAdapter = new EngineEventbusAdapter(engineInstance, this._eventbus);
|
|
9738
|
-
const
|
|
9903
|
+
const localeEventbusAdapter = new LocaleEventbusAdapter(localeManager, this._eventbus, engineInstance);
|
|
9739
9904
|
const engineInputAdapter = new EngineInputAdapter(engineInstance, this._eventbus, this._windowRef);
|
|
9740
9905
|
engineEventbusAdapter.connect();
|
|
9741
|
-
|
|
9906
|
+
localeEventbusAdapter.connect();
|
|
9742
9907
|
engineInputAdapter.connect();
|
|
9743
9908
|
return {
|
|
9744
9909
|
engine: engineInstance,
|
|
9745
|
-
|
|
9910
|
+
localeManager,
|
|
9746
9911
|
eventbus: this._eventbus,
|
|
9747
9912
|
destroy: async () => {
|
|
9748
9913
|
engineInputAdapter.disconnect();
|
|
9749
|
-
|
|
9914
|
+
localeEventbusAdapter.disconnect();
|
|
9750
9915
|
engineEventbusAdapter.disconnect();
|
|
9751
9916
|
await engineInstance.destroy();
|
|
9752
9917
|
}
|
|
@@ -9847,5 +10012,148 @@ var EngineFactory = class {
|
|
|
9847
10012
|
};
|
|
9848
10013
|
|
|
9849
10014
|
//#endregion
|
|
9850
|
-
|
|
10015
|
+
//#region src/locale/locale-loader.ts
|
|
10016
|
+
/**
|
|
10017
|
+
* LocaleLoader loads external locale files referenced via $ref syntax.
|
|
10018
|
+
*
|
|
10019
|
+
* Features:
|
|
10020
|
+
* - Fetches JSON locale files from URLs
|
|
10021
|
+
* - Caches results to avoid redundant fetches
|
|
10022
|
+
* - Detects circular references
|
|
10023
|
+
* - Supports baseUrl for relative path resolution
|
|
10024
|
+
*/
|
|
10025
|
+
var LocaleLoader = class {
|
|
10026
|
+
_fetch;
|
|
10027
|
+
_baseUrl;
|
|
10028
|
+
_cache;
|
|
10029
|
+
_loading;
|
|
10030
|
+
/**
|
|
10031
|
+
* Creates a new LocaleLoader instance.
|
|
10032
|
+
*
|
|
10033
|
+
* @param options - Configuration options
|
|
10034
|
+
*/
|
|
10035
|
+
constructor(options = {}) {
|
|
10036
|
+
this._fetch = options.fetch ?? globalThis.fetch;
|
|
10037
|
+
this._baseUrl = options.baseUrl ?? "";
|
|
10038
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
10039
|
+
this._loading = /* @__PURE__ */ new Map();
|
|
10040
|
+
}
|
|
10041
|
+
/**
|
|
10042
|
+
* Loads a single locale from an external reference.
|
|
10043
|
+
*
|
|
10044
|
+
* @param locale - The locale code
|
|
10045
|
+
* @param reference - The external reference to load
|
|
10046
|
+
* @returns The loaded locale data
|
|
10047
|
+
* @throws If file cannot be loaded, parsed, or circular reference detected
|
|
10048
|
+
*/
|
|
10049
|
+
async load(locale, reference) {
|
|
10050
|
+
const visitedPaths = /* @__PURE__ */ new Set();
|
|
10051
|
+
return this._loadWithVisited(locale, reference, visitedPaths);
|
|
10052
|
+
}
|
|
10053
|
+
/**
|
|
10054
|
+
* Internal load method with visited path tracking.
|
|
10055
|
+
*/
|
|
10056
|
+
async _loadWithVisited(locale, reference, visitedPaths) {
|
|
10057
|
+
const url = this._resolveUrl(reference.$ref);
|
|
10058
|
+
if (visitedPaths.has(url)) throw new Error(`[LocaleLoader] Circular reference detected: ${url} has already been visited`);
|
|
10059
|
+
visitedPaths.add(url);
|
|
10060
|
+
const data = await this._fetchWithCache(url);
|
|
10061
|
+
await this._resolveNestedRefs(data, url, visitedPaths);
|
|
10062
|
+
return {
|
|
10063
|
+
locale,
|
|
10064
|
+
data
|
|
10065
|
+
};
|
|
10066
|
+
}
|
|
10067
|
+
/**
|
|
10068
|
+
* Loads multiple locales in parallel.
|
|
10069
|
+
*
|
|
10070
|
+
* @param entries - Map of locale codes to references
|
|
10071
|
+
* @returns Array of loaded locale data
|
|
10072
|
+
*/
|
|
10073
|
+
async loadAll(entries) {
|
|
10074
|
+
const promises = [];
|
|
10075
|
+
for (const [locale, reference] of entries) promises.push(this.load(locale, reference));
|
|
10076
|
+
return Promise.all(promises);
|
|
10077
|
+
}
|
|
10078
|
+
/**
|
|
10079
|
+
* Fetches URL with caching to avoid redundant requests.
|
|
10080
|
+
*/
|
|
10081
|
+
async _fetchWithCache(url) {
|
|
10082
|
+
if (this._cache.has(url)) return this._cache.get(url);
|
|
10083
|
+
if (this._loading.has(url)) return this._loading.get(url);
|
|
10084
|
+
const promise = this._doFetch(url);
|
|
10085
|
+
this._loading.set(url, promise);
|
|
10086
|
+
try {
|
|
10087
|
+
const data = await promise;
|
|
10088
|
+
this._cache.set(url, data);
|
|
10089
|
+
return data;
|
|
10090
|
+
} finally {
|
|
10091
|
+
this._loading.delete(url);
|
|
10092
|
+
}
|
|
10093
|
+
}
|
|
10094
|
+
/**
|
|
10095
|
+
* Performs the actual fetch request.
|
|
10096
|
+
*/
|
|
10097
|
+
async _doFetch(url) {
|
|
10098
|
+
try {
|
|
10099
|
+
const response = await this._fetch(url);
|
|
10100
|
+
if (!response.ok) throw new Error(`[LocaleLoader] Failed to load locale file '${url}': ${response.status} ${response.statusText}`);
|
|
10101
|
+
return await response.json();
|
|
10102
|
+
} catch (error) {
|
|
10103
|
+
if (error instanceof Error && error.message.includes("[LocaleLoader]")) throw error;
|
|
10104
|
+
throw new Error(`[LocaleLoader] Failed to load locale file '${url}': ${error instanceof Error ? error.message : String(error)}`);
|
|
10105
|
+
}
|
|
10106
|
+
}
|
|
10107
|
+
/**
|
|
10108
|
+
* Resolves a potentially relative URL using the baseUrl.
|
|
10109
|
+
*/
|
|
10110
|
+
_resolveUrl(ref) {
|
|
10111
|
+
if (!this._baseUrl) return ref;
|
|
10112
|
+
if (ref.startsWith("http://") || ref.startsWith("https://") || ref.startsWith("/")) return ref;
|
|
10113
|
+
return `${this._baseUrl.endsWith("/") ? this._baseUrl : `${this._baseUrl}/`}${ref}`;
|
|
10114
|
+
}
|
|
10115
|
+
/**
|
|
10116
|
+
* Recursively resolves nested $ref references in loaded data.
|
|
10117
|
+
*/
|
|
10118
|
+
async _resolveNestedRefs(data, parentUrl, visitedPaths) {
|
|
10119
|
+
for (const key of Object.keys(data)) {
|
|
10120
|
+
const value = data[key];
|
|
10121
|
+
if (this._isReference(value)) {
|
|
10122
|
+
const nestedUrl = this._resolveRelativeToParent(value.$ref, parentUrl);
|
|
10123
|
+
if (visitedPaths.has(nestedUrl)) throw new Error(`[LocaleLoader] Circular reference detected: ${nestedUrl} has already been visited (referenced from ${parentUrl})`);
|
|
10124
|
+
visitedPaths.add(nestedUrl);
|
|
10125
|
+
const nestedData = await this._fetchWithCache(nestedUrl);
|
|
10126
|
+
await this._resolveNestedRefs(nestedData, nestedUrl, visitedPaths);
|
|
10127
|
+
data[key] = nestedData;
|
|
10128
|
+
} else if (typeof value === "object" && value !== null && !Array.isArray(value)) await this._resolveNestedRefs(value, parentUrl, visitedPaths);
|
|
10129
|
+
}
|
|
10130
|
+
}
|
|
10131
|
+
/**
|
|
10132
|
+
* Type guard for reference objects.
|
|
10133
|
+
*/
|
|
10134
|
+
_isReference(value) {
|
|
10135
|
+
return typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string";
|
|
10136
|
+
}
|
|
10137
|
+
/**
|
|
10138
|
+
* Resolves a relative path relative to a parent URL.
|
|
10139
|
+
*/
|
|
10140
|
+
_resolveRelativeToParent(ref, parentUrl) {
|
|
10141
|
+
if (ref.startsWith("http://") || ref.startsWith("https://") || ref.startsWith("/")) return ref;
|
|
10142
|
+
const lastSlash = parentUrl.lastIndexOf("/");
|
|
10143
|
+
if (lastSlash === -1) return ref;
|
|
10144
|
+
return `${parentUrl.substring(0, lastSlash + 1)}${ref}`;
|
|
10145
|
+
}
|
|
10146
|
+
};
|
|
10147
|
+
|
|
10148
|
+
//#endregion
|
|
10149
|
+
//#region src/locale/types.ts
|
|
10150
|
+
/**
|
|
10151
|
+
* Type guard for ILocaleReference
|
|
10152
|
+
*/
|
|
10153
|
+
function isLocaleReference(value) {
|
|
10154
|
+
return typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string";
|
|
10155
|
+
}
|
|
10156
|
+
|
|
10157
|
+
//#endregion
|
|
10158
|
+
export { Action, ActionCreator, ActionCreatorFactory, ActionEditor, ActionRegistryEventbusListener, BasePositionSource, ConfigurationFactory, ConfigurationResolver, ControllerNamesProvider, DOMEventListenerController, DomContainerProvider, EligiusEngine, EligiusResourceImporter, EndableAction, EndableActionCreator, EndableActionEditor, EngineEventbusAdapter, EngineFactory, EngineInputAdapter, Eventbus, KeyboardStepSource, LabelController, LocaleEventbusAdapter, LocaleLoader, LocaleManager, LottieController, MutationObserverController, NavigationController, OperationEditor, OperationMetadataProvider, OperationNamesProvider, ProgressbarController, RafPositionSource, RequestVideoUriInterceptor, RoutingController, ScrollPositionSource, SimplePlaylist, SubtitleEditor, SubtitleImporter, SubtitlesController, TimelineAction, TimelineActionCreator, TimelineActionEditor, TimelineProviderSettingsEditor, TimelineProvidersSettingsEditor, TypedEventEmitter, VideoPositionSource, addClass, addControllerToElement, addGlobalsToOperation, animate, animateWithClass, announceToScreenReader, breakForEach, broadcastEvent, calc, clearElement, clearOperationData, clearStorage, compareDate, concatenateStrings, continueForEach, createElement, metadata_exports as ctrlmetadata, customFunction, endAction, endForEach, endWhen, metadata_exports$1 as eventmetadata, extendController, filterArray, findInArray, forEach, formatDate, formatText, getAttributesFromElement, getControllerFromElement, getControllerInstance, getCurrentTime, getElementDimensions, getFocusedElement, getFormData, getImport, getQueryParams, getScrollPosition, getTextContent, httpDelete, httpPost, httpPut, invokeObjectMethod, isElementInViewport, isLocaleReference, isSeekable, loadFromStorage, loadJson, log, mapArray, math, metadata_exports$2 as metadata, otherwise, removeClass, removeControllerFromElement, removeElement, removePropertiesFromOperationData, reparentElement, replaceString, replaceText, requestAction, saveToStorage, scrollToElement, scrollToPosition, selectElement, setData, setElementAttributes, setElementContent, setFocus, setFormValue, setGlobalData, setOperationData, setStyle, setVariable, sortArray, splitString, startAction, substringText, toggleClass, toggleElement, toggleFormElement, validateForm, wait, when };
|
|
9851
10159
|
//# sourceMappingURL=index.mjs.map
|