eligius 2.1.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 +452 -227
- package/dist/index.mjs +356 -283
- package/dist/index.mjs.map +1 -1
- package/jsonschema/eligius-configuration.json +698 -125
- 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 -527
- package/jsonschema/endable-action.json +0 -527
- package/jsonschema/engine-config.json +0 -21
- package/jsonschema/event-action.json +0 -295
- package/jsonschema/mediaplayer-timeline-provider-settings.json +0 -95
- 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 -141
- package/jsonschema/timeline-action.json +0 -542
- package/jsonschema/timeline-provider-settings.json +0 -19
- package/jsonschema/timeline.json +0 -73
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
|
/**
|
|
@@ -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
|
+
* Bridges LocaleManager to/from the eventbus.
|
|
617
618
|
*
|
|
618
|
-
*
|
|
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
|
|
623
|
-
*
|
|
624
|
-
* Note: Requires engine reference to update DOM lang attribute on language change
|
|
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) {
|
|
@@ -7120,7 +6980,6 @@ var ConfigurationResolver = class {
|
|
|
7120
6980
|
availableLanguages: deepCopy(configuration.availableLanguages),
|
|
7121
6981
|
actions: resolveActions(configuration.actions, this.importer, this.eventbus),
|
|
7122
6982
|
initActions: resolveActions(configuration.initActions, this.importer, this.eventbus),
|
|
7123
|
-
labels: deepCopy(configuration.labels),
|
|
7124
6983
|
timelineFlow: deepCopy(configuration.timelineFlow),
|
|
7125
6984
|
timelines: resolveTimelines(configuration.timelines, this.importer, this.eventbus)
|
|
7126
6985
|
};
|
|
@@ -7242,13 +7101,17 @@ prefix the action name with \`end:\`.`,
|
|
|
7242
7101
|
//#region src/controllers/metadata/label-controller.ts
|
|
7243
7102
|
function LabelController$1() {
|
|
7244
7103
|
return {
|
|
7245
|
-
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.
|
|
7246
7109
|
|
|
7247
|
-
|
|
7110
|
+
Uses the rosetta-based locale system via \`request-translation\` event.`,
|
|
7248
7111
|
dependentProperties: ["selectedElement"],
|
|
7249
7112
|
properties: {
|
|
7250
|
-
|
|
7251
|
-
type: "ParameterType:
|
|
7113
|
+
translationKey: {
|
|
7114
|
+
type: "ParameterType:string",
|
|
7252
7115
|
required: true
|
|
7253
7116
|
},
|
|
7254
7117
|
attributeName: { type: [{ value: "undefined" }, { value: "string" }] }
|
|
@@ -9403,11 +9266,11 @@ var EligiusEngine = class EligiusEngine {
|
|
|
9403
9266
|
get engineRoot() {
|
|
9404
9267
|
return $(this.configuration.containerSelector);
|
|
9405
9268
|
}
|
|
9406
|
-
constructor(configuration, eventbus$1, timelineProviders,
|
|
9269
|
+
constructor(configuration, eventbus$1, timelineProviders, localeManager) {
|
|
9407
9270
|
this.configuration = configuration;
|
|
9408
9271
|
this.eventbus = eventbus$1;
|
|
9409
9272
|
this.timelineProviders = timelineProviders;
|
|
9410
|
-
this.
|
|
9273
|
+
this.localeManager = localeManager;
|
|
9411
9274
|
}
|
|
9412
9275
|
/**
|
|
9413
9276
|
* Subscribe to engine events
|
|
@@ -9575,7 +9438,7 @@ var EligiusEngine = class EligiusEngine {
|
|
|
9575
9438
|
*/
|
|
9576
9439
|
async destroy() {
|
|
9577
9440
|
await this._cleanUp();
|
|
9578
|
-
this.
|
|
9441
|
+
this.localeManager.destroy();
|
|
9579
9442
|
this._activePositionSource = void 0;
|
|
9580
9443
|
this._activeContainerProvider = void 0;
|
|
9581
9444
|
this._activePlaylist = void 0;
|
|
@@ -9787,93 +9650,159 @@ var EligiusResourceImporter = class {
|
|
|
9787
9650
|
};
|
|
9788
9651
|
|
|
9789
9652
|
//#endregion
|
|
9790
|
-
//#region src/
|
|
9791
|
-
function setGlobal(name, value) {
|
|
9792
|
-
const cache$2 = getGlobals();
|
|
9793
|
-
cache$2[name] = value;
|
|
9794
|
-
}
|
|
9795
|
-
|
|
9796
|
-
//#endregion
|
|
9797
|
-
//#region src/language-manager.ts
|
|
9653
|
+
//#region src/locale/locale-manager.ts
|
|
9798
9654
|
/**
|
|
9799
|
-
*
|
|
9800
|
-
*
|
|
9801
|
-
* This class manages the labels for an {@link IEligiusEngine} instance.
|
|
9802
|
-
* It provides a pure API for language management and emits events for language changes.
|
|
9655
|
+
* LocaleManager - Core locale management class wrapping rosetta
|
|
9656
|
+
* Feature: 005-rosetta-locale-manager
|
|
9803
9657
|
*
|
|
9804
|
-
*
|
|
9658
|
+
* Provides translation retrieval, locale switching, and event emission
|
|
9659
|
+
* for the Eligius timeline engine.
|
|
9805
9660
|
*/
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
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);
|
|
9813
9686
|
}
|
|
9814
|
-
/**
|
|
9815
|
-
|
|
9816
|
-
|
|
9687
|
+
/**
|
|
9688
|
+
* Gets the current locale.
|
|
9689
|
+
*/
|
|
9690
|
+
get locale() {
|
|
9691
|
+
return this._locale;
|
|
9817
9692
|
}
|
|
9818
|
-
|
|
9819
|
-
|
|
9820
|
-
|
|
9821
|
-
|
|
9822
|
-
|
|
9823
|
-
this._availableLanguages = this._extractAvailableLanguages(labels);
|
|
9693
|
+
/**
|
|
9694
|
+
* Gets the list of available locales.
|
|
9695
|
+
*/
|
|
9696
|
+
get availableLocales() {
|
|
9697
|
+
return Array.from(this._availableLocales);
|
|
9824
9698
|
}
|
|
9825
9699
|
/**
|
|
9826
|
-
*
|
|
9827
|
-
*
|
|
9828
|
-
* @param
|
|
9829
|
-
* @
|
|
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
|
|
9830
9704
|
*/
|
|
9831
|
-
|
|
9832
|
-
|
|
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;
|
|
9729
|
+
}
|
|
9730
|
+
/**
|
|
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
|
+
}
|
|
9833
9746
|
}
|
|
9834
9747
|
/**
|
|
9835
|
-
*
|
|
9836
|
-
* @param language - New language code
|
|
9837
|
-
* @throws If language code is empty or null
|
|
9748
|
+
* Gets raw translation value from stored locale data (without interpolation).
|
|
9838
9749
|
*/
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
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;
|
|
9844
9760
|
}
|
|
9845
9761
|
/**
|
|
9846
|
-
*
|
|
9847
|
-
*
|
|
9848
|
-
* @
|
|
9762
|
+
* Sets the current locale and emits a change event.
|
|
9763
|
+
*
|
|
9764
|
+
* @param locale - The new locale to set
|
|
9849
9765
|
*/
|
|
9850
|
-
|
|
9851
|
-
|
|
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}`);
|
|
9852
9772
|
}
|
|
9853
9773
|
/**
|
|
9854
|
-
*
|
|
9855
|
-
*
|
|
9856
|
-
* @
|
|
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
|
|
9857
9779
|
*/
|
|
9858
|
-
|
|
9859
|
-
|
|
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
|
+
};
|
|
9860
9787
|
}
|
|
9861
9788
|
/**
|
|
9862
|
-
*
|
|
9789
|
+
* Destroys the LocaleManager, cleaning up all listeners and data.
|
|
9863
9790
|
*/
|
|
9864
9791
|
destroy() {
|
|
9865
|
-
this.
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
acc[label.id] = label.labels;
|
|
9870
|
-
return acc;
|
|
9871
|
-
}, {});
|
|
9792
|
+
this._listeners.clear();
|
|
9793
|
+
this._availableLocales.clear();
|
|
9794
|
+
this._rawLocaleData.clear();
|
|
9795
|
+
if (this._debug) console.log("[LocaleManager] Destroyed");
|
|
9872
9796
|
}
|
|
9873
|
-
|
|
9874
|
-
|
|
9875
|
-
|
|
9876
|
-
|
|
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);
|
|
9877
9806
|
}
|
|
9878
9807
|
};
|
|
9879
9808
|
|
|
@@ -9946,12 +9875,12 @@ var EngineFactory = class {
|
|
|
9946
9875
|
* This method:
|
|
9947
9876
|
* - Resolves the configuration
|
|
9948
9877
|
* - Creates timeline providers
|
|
9949
|
-
* - Instantiates the engine and
|
|
9878
|
+
* - Instantiates the engine and locale manager
|
|
9950
9879
|
* - Creates and connects adapters for eventbus integration
|
|
9951
9880
|
*
|
|
9952
9881
|
* @param configuration - The engine configuration
|
|
9953
9882
|
* @param resolver - Optional custom configuration resolver
|
|
9954
|
-
* @returns Engine result with engine,
|
|
9883
|
+
* @returns Engine result with engine, locale manager, eventbus, and destroy function
|
|
9955
9884
|
*/
|
|
9956
9885
|
createEngine(configuration, resolver) {
|
|
9957
9886
|
const { systemName } = configuration.engine;
|
|
@@ -9966,22 +9895,23 @@ var EngineFactory = class {
|
|
|
9966
9895
|
const [actionLookup, resolvedConfiguration] = resolver.process(configuration, actionRegistryListener);
|
|
9967
9896
|
this._actionsLookup = actionLookup;
|
|
9968
9897
|
const timelineProviders = this._createTimelineProviders(resolvedConfiguration);
|
|
9969
|
-
const { language,
|
|
9970
|
-
const
|
|
9971
|
-
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);
|
|
9972
9902
|
const engineEventbusAdapter = new EngineEventbusAdapter(engineInstance, this._eventbus);
|
|
9973
|
-
const
|
|
9903
|
+
const localeEventbusAdapter = new LocaleEventbusAdapter(localeManager, this._eventbus, engineInstance);
|
|
9974
9904
|
const engineInputAdapter = new EngineInputAdapter(engineInstance, this._eventbus, this._windowRef);
|
|
9975
9905
|
engineEventbusAdapter.connect();
|
|
9976
|
-
|
|
9906
|
+
localeEventbusAdapter.connect();
|
|
9977
9907
|
engineInputAdapter.connect();
|
|
9978
9908
|
return {
|
|
9979
9909
|
engine: engineInstance,
|
|
9980
|
-
|
|
9910
|
+
localeManager,
|
|
9981
9911
|
eventbus: this._eventbus,
|
|
9982
9912
|
destroy: async () => {
|
|
9983
9913
|
engineInputAdapter.disconnect();
|
|
9984
|
-
|
|
9914
|
+
localeEventbusAdapter.disconnect();
|
|
9985
9915
|
engineEventbusAdapter.disconnect();
|
|
9986
9916
|
await engineInstance.destroy();
|
|
9987
9917
|
}
|
|
@@ -10082,5 +10012,148 @@ var EngineFactory = class {
|
|
|
10082
10012
|
};
|
|
10083
10013
|
|
|
10084
10014
|
//#endregion
|
|
10085
|
-
|
|
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 };
|
|
10086
10159
|
//# sourceMappingURL=index.mjs.map
|