eligius 4.1.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configuration-api.d.mts +127 -101
- package/dist/configuration-api.mjs +6 -6
- package/dist/configuration-api.mjs.map +1 -1
- package/dist/{engine-factory-BHDMlt6g.mjs → engine-factory-65BHSli8.mjs} +235 -237
- package/dist/engine-factory-65BHSli8.mjs.map +1 -0
- package/dist/index.d.mts +2 -3
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/dist/lint.d.mts +125 -101
- package/dist/lint.mjs +63 -27
- package/dist/lint.mjs.map +1 -1
- package/dist/{locale-manager-CNZ2kj0g.d.mts → locale-manager-DY4_d4Zv.d.mts} +142 -136
- package/dist/metadata.d.mts +122 -102
- package/dist/metadata.mjs +7 -73
- package/dist/metadata.mjs.map +1 -1
- package/dist/{rolldown-runtime-CGzGPw9x.mjs → rolldown-runtime-DTOZ5ltL.mjs} +4 -4
- package/dist/runtime.d.mts +21 -2
- package/dist/runtime.mjs +1 -1
- package/jsonschema/eligius-configuration.json +3 -0
- package/jsonschema/operations/math.json +6 -27
- package/package.json +25 -15
- package/dist/engine-factory-BHDMlt6g.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
2
|
+
import { t as __exportAll } from "./rolldown-runtime-DTOZ5ltL.mjs";
|
|
3
3
|
import hotkeys from "hotkeys-js";
|
|
4
4
|
import $ from "jquery";
|
|
5
5
|
import { isDefined } from "ts-is-present";
|
|
@@ -1009,6 +1009,7 @@ var Action = class {
|
|
|
1009
1009
|
name;
|
|
1010
1010
|
startOperations;
|
|
1011
1011
|
eventbus;
|
|
1012
|
+
services;
|
|
1012
1013
|
id = "";
|
|
1013
1014
|
/**
|
|
1014
1015
|
* Scope stack used by {@link executeOperation} when it is called without an
|
|
@@ -1025,10 +1026,11 @@ var Action = class {
|
|
|
1025
1026
|
* again instead of deep-copying the collection on every iteration.
|
|
1026
1027
|
*/
|
|
1027
1028
|
_loopOperationData = /* @__PURE__ */ new WeakMap();
|
|
1028
|
-
constructor(name, startOperations, eventbus) {
|
|
1029
|
+
constructor(name, startOperations, eventbus, services) {
|
|
1029
1030
|
this.name = name;
|
|
1030
1031
|
this.startOperations = startOperations;
|
|
1031
1032
|
this.eventbus = eventbus;
|
|
1033
|
+
this.services = services;
|
|
1032
1034
|
}
|
|
1033
1035
|
/**
|
|
1034
1036
|
* Runs the start operations.
|
|
@@ -1071,6 +1073,7 @@ var Action = class {
|
|
|
1071
1073
|
return [{
|
|
1072
1074
|
currentIndex: -1,
|
|
1073
1075
|
eventbus: this.eventbus,
|
|
1076
|
+
services: this.services,
|
|
1074
1077
|
operations
|
|
1075
1078
|
}];
|
|
1076
1079
|
}
|
|
@@ -1092,6 +1095,9 @@ var Action = class {
|
|
|
1092
1095
|
get eventbus() {
|
|
1093
1096
|
return parentScope.eventbus;
|
|
1094
1097
|
},
|
|
1098
|
+
get services() {
|
|
1099
|
+
return parentScope.services;
|
|
1100
|
+
},
|
|
1095
1101
|
get operations() {
|
|
1096
1102
|
return parentScope.operations;
|
|
1097
1103
|
},
|
|
@@ -1155,7 +1161,9 @@ var Action = class {
|
|
|
1155
1161
|
};
|
|
1156
1162
|
/**
|
|
1157
1163
|
* Adds the failing operation's system name and index to an error, unless an
|
|
1158
|
-
* inner action already did (the innermost operation is the most specific)
|
|
1164
|
+
* inner action already did (the innermost operation is the most specific),
|
|
1165
|
+
* and prepends the operation to the error's path, so that every action frame
|
|
1166
|
+
* the error passes through adds exactly one entry, outermost first.
|
|
1159
1167
|
* Non-Error values are wrapped in an Error that keeps their message.
|
|
1160
1168
|
*/
|
|
1161
1169
|
function withOperationContext(error, operation, index) {
|
|
@@ -1164,6 +1172,10 @@ function withOperationContext(error, operation, index) {
|
|
|
1164
1172
|
annotated.operationSystemName = operation.systemName;
|
|
1165
1173
|
annotated.operationIndex = index;
|
|
1166
1174
|
}
|
|
1175
|
+
annotated.operationPath = [{
|
|
1176
|
+
systemName: operation.systemName,
|
|
1177
|
+
index
|
|
1178
|
+
}, ...annotated.operationPath ?? []];
|
|
1167
1179
|
return annotated;
|
|
1168
1180
|
}
|
|
1169
1181
|
const emptyOperationData = Object.freeze({});
|
|
@@ -1231,8 +1243,8 @@ function copyConfiguredOperationData(operationData, systemName) {
|
|
|
1231
1243
|
// src/action/endable-action.ts
|
|
1232
1244
|
var EndableAction = class extends Action {
|
|
1233
1245
|
endOperations;
|
|
1234
|
-
constructor(name, startOperations, endOperations, eventBus) {
|
|
1235
|
-
super(name, startOperations, eventBus);
|
|
1246
|
+
constructor(name, startOperations, endOperations, eventBus, services) {
|
|
1247
|
+
super(name, startOperations, eventBus, services);
|
|
1236
1248
|
this.endOperations = endOperations;
|
|
1237
1249
|
}
|
|
1238
1250
|
/**
|
|
@@ -1273,8 +1285,8 @@ var TimelineAction = class extends EndableAction {
|
|
|
1273
1285
|
get active() {
|
|
1274
1286
|
return this._active;
|
|
1275
1287
|
}
|
|
1276
|
-
constructor(name, startOperations, endOperations, duration, eventBus) {
|
|
1277
|
-
super(name, startOperations, endOperations, eventBus);
|
|
1288
|
+
constructor(name, startOperations, endOperations, duration, eventBus, services) {
|
|
1289
|
+
super(name, startOperations, endOperations, eventBus, services);
|
|
1278
1290
|
this.duration = duration;
|
|
1279
1291
|
}
|
|
1280
1292
|
/**
|
|
@@ -1474,9 +1486,6 @@ var EngineEventbusAdapter = class {
|
|
|
1474
1486
|
this._registerRequest("timeline-container-request", () => {
|
|
1475
1487
|
return this._engine.container;
|
|
1476
1488
|
});
|
|
1477
|
-
this._registerRequest("request-engine-root", () => {
|
|
1478
|
-
return this._engine.engineRoot;
|
|
1479
|
-
});
|
|
1480
1489
|
this._registerRequest("timeline-request-current-timeline", () => {
|
|
1481
1490
|
return this._engine.currentTimelineUri;
|
|
1482
1491
|
});
|
|
@@ -1996,7 +2005,7 @@ function unregisterController(element, controller) {
|
|
|
1996
2005
|
const addControllerToElement$1 = function(operationData) {
|
|
1997
2006
|
const { selectedElement, controllerInstance } = operationData;
|
|
1998
2007
|
controllerInstance.init(operationData);
|
|
1999
|
-
const promise = controllerInstance.attach(this.eventbus);
|
|
2008
|
+
const promise = controllerInstance.attach(this.eventbus, this.services);
|
|
2000
2009
|
attachControllerToElement(selectedElement, controllerInstance);
|
|
2001
2010
|
if (promise) return new Promise((resolve, reject) => {
|
|
2002
2011
|
promise.then((newOperationData) => {
|
|
@@ -2958,47 +2967,27 @@ const createElement$1 = function(operationData) {
|
|
|
2958
2967
|
return operationData;
|
|
2959
2968
|
};
|
|
2960
2969
|
|
|
2961
|
-
// src/operation/helper/
|
|
2962
|
-
/**
|
|
2963
|
-
* Requests the entry registered under `systemName` through the
|
|
2964
|
-
* `request-function` event, and fails with an error that names the calling
|
|
2965
|
-
* operation when there is none.
|
|
2966
|
-
*
|
|
2967
|
-
* The `request-function` responder (registered by `EngineFactory`) may throw
|
|
2968
|
-
* for an unknown name, and the default importer then adds a "did you mean"
|
|
2969
|
-
* hint. That message is kept and the original error becomes the `cause`.
|
|
2970
|
-
*
|
|
2971
|
-
* @param eventbus - The eventbus to send the request on
|
|
2972
|
-
* @param operationName - The name of the calling operation, used as the message prefix
|
|
2973
|
-
* @param systemName - The configured name to look up
|
|
2974
|
-
* @param noun - What is being looked up, for the message (for example `'function'`)
|
|
2975
|
-
* @returns The registered entry, never `undefined` or `null`
|
|
2976
|
-
* @throws Error when the lookup throws or nothing is registered under `systemName`
|
|
2977
|
-
*/
|
|
2978
|
-
function requestRegisteredEntry(eventbus, operationName, systemName, noun) {
|
|
2979
|
-
return requestNamedEntry(eventbus, "request-function", operationName, systemName, noun);
|
|
2980
|
-
}
|
|
2970
|
+
// src/operation/helper/lookup-named-entry.ts
|
|
2981
2971
|
/**
|
|
2982
|
-
*
|
|
2983
|
-
*
|
|
2984
|
-
*
|
|
2972
|
+
* Looks up the entry registered under `systemName` with `lookup` (one of the
|
|
2973
|
+
* engine services, such as `this.services.getAction`), and fails with an
|
|
2974
|
+
* error that names the calling operation when the lookup throws or answers
|
|
2975
|
+
* `undefined` or `null`.
|
|
2985
2976
|
*
|
|
2986
|
-
*
|
|
2987
|
-
*
|
|
2988
|
-
* mean" hint) is kept, and the original error becomes the `cause`.
|
|
2977
|
+
* A message thrown by the lookup (such as the importer's "did you mean"
|
|
2978
|
+
* hint) is kept, and the original error becomes the `cause`.
|
|
2989
2979
|
*
|
|
2990
|
-
* @param eventbus - The eventbus to send the request on
|
|
2991
|
-
* @param eventName - The request event, for example `'request-instance'`
|
|
2992
2980
|
* @param operationName - The name of the calling operation, used as the message prefix
|
|
2993
2981
|
* @param systemName - The configured name to look up
|
|
2982
|
+
* @param lookup - Returns the entry for a name, or throws for an unknown one
|
|
2994
2983
|
* @param noun - What is being looked up, for the message (for example `'controller'`)
|
|
2995
2984
|
* @returns The registered entry, never `undefined` or `null`
|
|
2996
2985
|
* @throws Error when the lookup throws or nothing is registered under `systemName`
|
|
2997
2986
|
*/
|
|
2998
|
-
function
|
|
2987
|
+
function lookupNamedEntry(operationName, systemName, lookup, noun) {
|
|
2999
2988
|
let entry;
|
|
3000
2989
|
try {
|
|
3001
|
-
entry =
|
|
2990
|
+
entry = lookup(systemName);
|
|
3002
2991
|
} catch (error) {
|
|
3003
2992
|
const reason = error instanceof Error ? error.message : String(error);
|
|
3004
2993
|
const what = noun ? `${noun} '${systemName}'` : `'${systemName}'`;
|
|
@@ -3021,8 +3010,8 @@ function isFunction(value) {
|
|
|
3021
3010
|
* This operation retrieves a custom function defined by the given system name
|
|
3022
3011
|
* and invokes it with the current operation data and eventbus.
|
|
3023
3012
|
*
|
|
3024
|
-
* The function is looked up with
|
|
3025
|
-
*
|
|
3013
|
+
* The function is looked up with `this.services.getImport`, which answers from
|
|
3014
|
+
* the engine's resource importer. Register the function
|
|
3026
3015
|
* with the `EligiusResourceImporter` constructor:
|
|
3027
3016
|
* `new EligiusResourceImporter({functions: {myFunction}})`.
|
|
3028
3017
|
*
|
|
@@ -3043,7 +3032,7 @@ function isFunction(value) {
|
|
|
3043
3032
|
const customFunction$1 = function(operationData) {
|
|
3044
3033
|
const { systemName } = operationData;
|
|
3045
3034
|
removeProperties(operationData, "systemName");
|
|
3046
|
-
const func =
|
|
3035
|
+
const func = lookupNamedEntry("customFunction", systemName, (name) => this.services.getImport(name), "function");
|
|
3047
3036
|
if (!isFunction(func)) throw new Error(`customFunction: systemName '${systemName}' does not resolve to a function.`);
|
|
3048
3037
|
const result = func.apply(createScopeView(this), [operationData]);
|
|
3049
3038
|
if (result !== null && isPromise(result)) return new Promise((resolve, reject) => {
|
|
@@ -3359,7 +3348,7 @@ const formatText$1 = (operationData) => {
|
|
|
3359
3348
|
case "trim":
|
|
3360
3349
|
text = text.trim();
|
|
3361
3350
|
break;
|
|
3362
|
-
default: throw new Error(`formatText: unknown transformation type "${transformation}"`);
|
|
3351
|
+
default: throw new Error(`formatText: unknown transformation type "${String(transformation)}"`);
|
|
3363
3352
|
}
|
|
3364
3353
|
operationData.formattedText = text;
|
|
3365
3354
|
removeProperties(operationData, "transformation");
|
|
@@ -3416,7 +3405,7 @@ const getControllerFromElement$1 = (operationData) => {
|
|
|
3416
3405
|
const getControllerInstance$1 = function(operationData) {
|
|
3417
3406
|
const { systemName } = operationData;
|
|
3418
3407
|
removeProperties(operationData, "systemName");
|
|
3419
|
-
operationData.controllerInstance =
|
|
3408
|
+
operationData.controllerInstance = lookupNamedEntry("getControllerInstance", systemName, (name) => this.services.createInstance(name), "controller");
|
|
3420
3409
|
return operationData;
|
|
3421
3410
|
};
|
|
3422
3411
|
|
|
@@ -3654,8 +3643,8 @@ const getFormData$1 = (operationData) => {
|
|
|
3654
3643
|
* This operation retrieves the import specified by the given `systemName` and
|
|
3655
3644
|
* assigns it to the `importedInstance` property on the current operaton date.
|
|
3656
3645
|
*
|
|
3657
|
-
* The import is looked up with
|
|
3658
|
-
*
|
|
3646
|
+
* The import is looked up with `this.services.getImport`, which answers from
|
|
3647
|
+
* the engine's resource importer. Functions, templates
|
|
3659
3648
|
* and JSON registered with the `EligiusResourceImporter` constructor
|
|
3660
3649
|
* (`new EligiusResourceImporter({json: {settings}})`) can be imported this
|
|
3661
3650
|
* way, as can every built-in operation, controller and provider export.
|
|
@@ -3670,7 +3659,7 @@ const getFormData$1 = (operationData) => {
|
|
|
3670
3659
|
const getImport$1 = function(operationData) {
|
|
3671
3660
|
const { systemName } = operationData;
|
|
3672
3661
|
delete operationData.systemName;
|
|
3673
|
-
operationData.importedInstance =
|
|
3662
|
+
operationData.importedInstance = lookupNamedEntry("getImport", systemName, (name) => this.services.getImport(name));
|
|
3674
3663
|
return operationData;
|
|
3675
3664
|
};
|
|
3676
3665
|
|
|
@@ -4419,7 +4408,7 @@ const reparentElement$1 = function(operationData) {
|
|
|
4419
4408
|
removeProperties(operationData, "newParentSelector");
|
|
4420
4409
|
if (typeof newParentSelector !== "string" || !newParentSelector.trim()) throw new Error("reparentElement: newParentSelector is required");
|
|
4421
4410
|
if (newParentSelector.trim().startsWith("<")) throw new Error("reparentElement: newParentSelector must be a selector, not HTML");
|
|
4422
|
-
const root = this.
|
|
4411
|
+
const root = this.services.getEngineRoot();
|
|
4423
4412
|
if (!root?.length) throw new Error("reparentElement: the engine root is not available");
|
|
4424
4413
|
const target = root.filter(newParentSelector).add(root.find(newParentSelector));
|
|
4425
4414
|
if (target.length === 0) throw new Error(`reparentElement: '${newParentSelector}' matched no element inside the engine root`);
|
|
@@ -4535,10 +4524,10 @@ const replaceText$1 = (operationData) => {
|
|
|
4535
4524
|
*
|
|
4536
4525
|
* @category Action
|
|
4537
4526
|
*/
|
|
4538
|
-
const requestAction$
|
|
4527
|
+
const requestAction$1 = function(operationData) {
|
|
4539
4528
|
const { systemName } = operationData;
|
|
4540
4529
|
removeProperties(operationData, "systemName");
|
|
4541
|
-
operationData.actionInstance =
|
|
4530
|
+
operationData.actionInstance = lookupNamedEntry("requestAction", systemName, (name) => this.services.getAction(name), "action");
|
|
4542
4531
|
return operationData;
|
|
4543
4532
|
};
|
|
4544
4533
|
|
|
@@ -4691,12 +4680,10 @@ const selectElement$1 = function(operationData) {
|
|
|
4691
4680
|
removeProperties(operationData, "selector", "useSelectedElementAsRoot");
|
|
4692
4681
|
if (!selector) throw new Error("selectElement: selector is either empty or not defined.");
|
|
4693
4682
|
if (useSelectedElementAsRoot && operationData.selectedElement) {
|
|
4694
|
-
|
|
4695
|
-
operationData.selectedElement = findElementBySelector(currentRoot, selector);
|
|
4683
|
+
operationData.selectedElement = findElementBySelector(operationData.selectedElement, selector);
|
|
4696
4684
|
return operationData;
|
|
4697
4685
|
}
|
|
4698
|
-
|
|
4699
|
-
if (root) operationData.selectedElement = findElementBySelector(root, selector);
|
|
4686
|
+
operationData.selectedElement = findElementBySelector(this.services.getEngineRoot(), selector);
|
|
4700
4687
|
return operationData;
|
|
4701
4688
|
};
|
|
4702
4689
|
|
|
@@ -5658,8 +5645,8 @@ function customFunction() {
|
|
|
5658
5645
|
description: `This operation retrieves a custom function defined by the given system name
|
|
5659
5646
|
and invokes it with the current operation data and eventbus.
|
|
5660
5647
|
|
|
5661
|
-
The function is looked up with
|
|
5662
|
-
|
|
5648
|
+
The function is looked up with \`this.services.getImport\`, which answers from
|
|
5649
|
+
the engine's resource importer. Register the function
|
|
5663
5650
|
with the \`EligiusResourceImporter\` constructor:
|
|
5664
5651
|
\`new EligiusResourceImporter({functions: {myFunction}})\`.
|
|
5665
5652
|
|
|
@@ -5982,8 +5969,8 @@ function getImport() {
|
|
|
5982
5969
|
description: `This operation retrieves the import specified by the given \`systemName\` and
|
|
5983
5970
|
assigns it to the \`importedInstance\` property on the current operaton date.
|
|
5984
5971
|
|
|
5985
|
-
The import is looked up with
|
|
5986
|
-
|
|
5972
|
+
The import is looked up with \`this.services.getImport\`, which answers from
|
|
5973
|
+
the engine's resource importer. Functions, templates
|
|
5987
5974
|
and JSON registered with the \`EligiusResourceImporter\` constructor
|
|
5988
5975
|
(\`new EligiusResourceImporter({json: {settings}})\`) can be imported this
|
|
5989
5976
|
way, as can every built-in operation, controller and provider export.`,
|
|
@@ -6427,7 +6414,7 @@ A string pattern replaces every occurrence and inserts the replacement literally
|
|
|
6427
6414
|
}
|
|
6428
6415
|
|
|
6429
6416
|
// src/operation/metadata/request-action.ts
|
|
6430
|
-
function requestAction
|
|
6417
|
+
function requestAction() {
|
|
6431
6418
|
return {
|
|
6432
6419
|
description: `This operation requests an action instance with the specified name and assigns it
|
|
6433
6420
|
to the \`actionInstance\` property on the current operation data.`,
|
|
@@ -7013,7 +7000,7 @@ var metadata_exports$2 = /* @__PURE__ */ __exportAll({
|
|
|
7013
7000
|
reparentElement: () => reparentElement,
|
|
7014
7001
|
replaceString: () => replaceString,
|
|
7015
7002
|
replaceText: () => replaceText,
|
|
7016
|
-
requestAction: () => requestAction
|
|
7003
|
+
requestAction: () => requestAction,
|
|
7017
7004
|
saveToStorage: () => saveToStorage,
|
|
7018
7005
|
scrollToElement: () => scrollToElement,
|
|
7019
7006
|
scrollToPosition: () => scrollToPosition,
|
|
@@ -7557,16 +7544,19 @@ function warnToConsole(warning) {
|
|
|
7557
7544
|
var ConfigurationResolver = class {
|
|
7558
7545
|
importer;
|
|
7559
7546
|
eventbus;
|
|
7547
|
+
services;
|
|
7560
7548
|
_warn;
|
|
7561
7549
|
/**
|
|
7562
7550
|
* @param importer - Resolves system names to operations, controllers and providers
|
|
7563
7551
|
* @param eventbus - The eventbus the resolved actions run on
|
|
7552
|
+
* @param services - The services of the engine the resolved actions run in
|
|
7564
7553
|
* @param options - Optional. `onWarning` receives the configuration
|
|
7565
7554
|
* warnings instead of the console.
|
|
7566
7555
|
*/
|
|
7567
|
-
constructor(importer, eventbus, options = {}) {
|
|
7556
|
+
constructor(importer, eventbus, services, options = {}) {
|
|
7568
7557
|
this.importer = importer;
|
|
7569
7558
|
this.eventbus = eventbus;
|
|
7559
|
+
this.services = services;
|
|
7570
7560
|
this._warn = options.onWarning ?? warnToConsole;
|
|
7571
7561
|
}
|
|
7572
7562
|
process(configuration, actionRegistryListener) {
|
|
@@ -7583,16 +7573,16 @@ var ConfigurationResolver = class {
|
|
|
7583
7573
|
language: configuration.language,
|
|
7584
7574
|
layoutTemplate: configuration.layoutTemplate,
|
|
7585
7575
|
availableLanguages: deepCopy(configuration.availableLanguages),
|
|
7586
|
-
actions: resolveActions(configuration.actions, this.importer, this.eventbus, "actions", this._warn),
|
|
7587
|
-
initActions: resolveActions(configuration.initActions, this.importer, this.eventbus, "initActions", this._warn),
|
|
7576
|
+
actions: resolveActions(configuration.actions, this.importer, this.eventbus, this.services, "actions", this._warn),
|
|
7577
|
+
initActions: resolveActions(configuration.initActions, this.importer, this.eventbus, this.services, "initActions", this._warn),
|
|
7588
7578
|
timelineFlow: deepCopy(configuration.timelineFlow),
|
|
7589
|
-
timelines: resolveTimelines(configuration.timelines, this.importer, this.eventbus, this._warn)
|
|
7579
|
+
timelines: resolveTimelines(configuration.timelines, this.importer, this.eventbus, this.services, this._warn)
|
|
7590
7580
|
};
|
|
7591
7581
|
assertTimelineProviderSettings(configuration, this.importer);
|
|
7592
7582
|
let eventActions = [];
|
|
7593
7583
|
if (isDefined(configuration.eventActions)) {
|
|
7594
7584
|
assertArray(configuration.eventActions, "eventActions");
|
|
7595
|
-
if (actionRegistryListener) eventActions = resolveEventActions(configuration.eventActions, this.importer, this.eventbus, this._warn);
|
|
7585
|
+
if (actionRegistryListener) eventActions = resolveEventActions(configuration.eventActions, this.importer, this.eventbus, this.services, this._warn);
|
|
7596
7586
|
}
|
|
7597
7587
|
const actionsLookup = createActionsLookup([...resolvedConfig.actions.map((action, index) => [action, `actions[${index}]`]), ...eventActions.map(({ action }, index) => [action, `eventActions[${index}]`])]);
|
|
7598
7588
|
for (const { action, eventName, eventTopic } of eventActions) actionRegistryListener?.registerAction(action, eventName, eventTopic);
|
|
@@ -7727,17 +7717,17 @@ function createActionsLookup(actions) {
|
|
|
7727
7717
|
/**
|
|
7728
7718
|
* Creates the event actions without registering them.
|
|
7729
7719
|
*/
|
|
7730
|
-
function resolveEventActions(eventActionConfigurations, importer, eventbus, warn) {
|
|
7720
|
+
function resolveEventActions(eventActionConfigurations, importer, eventbus, services, warn) {
|
|
7731
7721
|
return eventActionConfigurations.map((config, index) => resolveActionConfiguration(config, importer, `eventActions[${index}]`, warn)).map((config, index) => {
|
|
7732
7722
|
const { eventName, eventTopic } = eventActionConfigurations[index];
|
|
7733
7723
|
return {
|
|
7734
|
-
action: new Action(config.name, config.startOperations, eventbus),
|
|
7724
|
+
action: new Action(config.name, config.startOperations, eventbus, services),
|
|
7735
7725
|
eventName,
|
|
7736
7726
|
eventTopic
|
|
7737
7727
|
};
|
|
7738
7728
|
});
|
|
7739
7729
|
}
|
|
7740
|
-
function resolveTimelines(timelines, importer, eventbus, warn) {
|
|
7730
|
+
function resolveTimelines(timelines, importer, eventbus, services, warn) {
|
|
7741
7731
|
assertArray(timelines, "timelines");
|
|
7742
7732
|
return timelines.map((config, timelineIndex) => {
|
|
7743
7733
|
const path = `timelines[${timelineIndex}]`;
|
|
@@ -7746,7 +7736,7 @@ function resolveTimelines(timelines, importer, eventbus, warn) {
|
|
|
7746
7736
|
...config,
|
|
7747
7737
|
...isDefined(config.positionSource) && { positionSource: deepCopy(config.positionSource) },
|
|
7748
7738
|
...isDefined(config.containerProvider) && { containerProvider: deepCopy(config.containerProvider) },
|
|
7749
|
-
timelineActions: config.timelineActions.map((actionConfig, index) => resolveTimelineAction(importer, eventbus, actionConfig, `${path}.timelineActions[${index}]`, warn))
|
|
7739
|
+
timelineActions: config.timelineActions.map((actionConfig, index) => resolveTimelineAction(importer, eventbus, services, actionConfig, `${path}.timelineActions[${index}]`, warn))
|
|
7750
7740
|
};
|
|
7751
7741
|
});
|
|
7752
7742
|
}
|
|
@@ -7845,20 +7835,20 @@ function resolveDuration(duration, path) {
|
|
|
7845
7835
|
end
|
|
7846
7836
|
};
|
|
7847
7837
|
}
|
|
7848
|
-
function resolveTimelineAction(importer, eventbus, actionConfiguration, path, warn) {
|
|
7838
|
+
function resolveTimelineAction(importer, eventbus, services, actionConfiguration, path, warn) {
|
|
7849
7839
|
const duration = resolveDuration(actionConfiguration.duration, `${path}.duration`);
|
|
7850
7840
|
const { id, name, endOperations, startOperations } = resolveEndableActionConfiguration(actionConfiguration, importer, path, warn);
|
|
7851
|
-
const action = new TimelineAction(name, startOperations, endOperations, duration, eventbus);
|
|
7841
|
+
const action = new TimelineAction(name, startOperations, endOperations, duration, eventbus, services);
|
|
7852
7842
|
action.id = id;
|
|
7853
7843
|
return action;
|
|
7854
7844
|
}
|
|
7855
|
-
function resolveActions(actionConfigurations, importer, eventbus, path, warn) {
|
|
7845
|
+
function resolveActions(actionConfigurations, importer, eventbus, services, path, warn) {
|
|
7856
7846
|
assertArray(actionConfigurations, path);
|
|
7857
7847
|
return actionConfigurations.map((config, index) => {
|
|
7858
7848
|
return resolveEndableActionConfiguration(config, importer, `${path}[${index}]`, warn);
|
|
7859
7849
|
}).map((resolvedConfig) => {
|
|
7860
7850
|
const { name, endOperations, startOperations } = resolvedConfig;
|
|
7861
|
-
const action = new EndableAction(name, startOperations, endOperations, eventbus);
|
|
7851
|
+
const action = new EndableAction(name, startOperations, endOperations, eventbus, services);
|
|
7862
7852
|
action.id = resolvedConfig.id;
|
|
7863
7853
|
return action;
|
|
7864
7854
|
});
|
|
@@ -7943,22 +7933,21 @@ function parseActionName(actionName) {
|
|
|
7943
7933
|
* Looks up the actions by name. A name prefixed with `end:` runs the `end`
|
|
7944
7934
|
* operations of the action instead of its `start` operations.
|
|
7945
7935
|
*
|
|
7946
|
-
* @param
|
|
7936
|
+
* @param services - The engine services to look the actions up in
|
|
7947
7937
|
* @param actionNames - The action names, optionally prefixed with `end:`
|
|
7948
7938
|
* @param controllerName - The controller, named in error messages
|
|
7949
7939
|
* @param trigger - What runs the actions, named in error messages
|
|
7950
7940
|
* @returns The actions in the given order
|
|
7951
|
-
* @throws when an action name is unknown
|
|
7952
|
-
*
|
|
7953
|
-
* trigger, and keeps the responder's "did you mean" hint
|
|
7941
|
+
* @throws when an action name is unknown; the message names the controller,
|
|
7942
|
+
* the action and the trigger, and keeps the "did you mean" hint
|
|
7954
7943
|
*/
|
|
7955
|
-
function requestControllerActions(
|
|
7944
|
+
function requestControllerActions(services, actionNames, controllerName, trigger) {
|
|
7956
7945
|
return actionNames.map((actionName) => {
|
|
7957
7946
|
const [start, name] = parseActionName(actionName);
|
|
7958
7947
|
const unknown = `${controllerName}: unknown action "${name}" for ${trigger.kind} "${trigger.name}"`;
|
|
7959
7948
|
let action;
|
|
7960
7949
|
try {
|
|
7961
|
-
action =
|
|
7950
|
+
action = services.getAction(name);
|
|
7962
7951
|
} catch (error) {
|
|
7963
7952
|
const reason = error instanceof Error ? error.message : String(error);
|
|
7964
7953
|
throw new Error(`${unknown}. ${reason}`, { cause: error });
|
|
@@ -8032,16 +8021,17 @@ var DOMEventListenerController = class {
|
|
|
8032
8021
|
/**
|
|
8033
8022
|
* Looks up the configured actions and starts listening for the DOM event.
|
|
8034
8023
|
*
|
|
8035
|
-
* @param eventbus - The eventbus
|
|
8036
|
-
* @
|
|
8037
|
-
*
|
|
8038
|
-
* DOM event, and keeps the
|
|
8024
|
+
* @param eventbus - The eventbus the actions report errors on
|
|
8025
|
+
* @param services - The engine services to look the actions up in
|
|
8026
|
+
* @throws when an action name is unknown; the message names the
|
|
8027
|
+
* controller, the action and the DOM event, and keeps the "did you mean"
|
|
8028
|
+
* hint
|
|
8039
8029
|
*/
|
|
8040
|
-
attach(eventbus) {
|
|
8030
|
+
attach(eventbus, services) {
|
|
8041
8031
|
if (!this.operationData) return;
|
|
8042
8032
|
const { selectedElement, actions, eventName } = this.operationData;
|
|
8043
8033
|
if (!this.actionInstanceInfos) {
|
|
8044
|
-
this.actionInstanceInfos = requestControllerActions(
|
|
8034
|
+
this.actionInstanceInfos = requestControllerActions(services, actions, this.name, {
|
|
8045
8035
|
kind: "DOM event",
|
|
8046
8036
|
name: eventName
|
|
8047
8037
|
});
|
|
@@ -8136,19 +8126,19 @@ var KeyboardController = class {
|
|
|
8136
8126
|
/**
|
|
8137
8127
|
* Looks up the configured actions and starts listening for the keys.
|
|
8138
8128
|
*
|
|
8139
|
-
* @param eventbus - The eventbus
|
|
8140
|
-
*
|
|
8141
|
-
*
|
|
8142
|
-
*
|
|
8143
|
-
* keys, and keeps the
|
|
8129
|
+
* @param eventbus - The eventbus the actions report errors on
|
|
8130
|
+
* @param services - The engine services to look the actions and the engine
|
|
8131
|
+
* root up in
|
|
8132
|
+
* @throws when an action name is unknown; the message names the
|
|
8133
|
+
* controller, the action and the keys, and keeps the "did you mean" hint
|
|
8144
8134
|
*/
|
|
8145
|
-
attach(eventbus) {
|
|
8135
|
+
attach(eventbus, services) {
|
|
8146
8136
|
if (!this.operationData || this.actionInstanceInfos) return;
|
|
8147
8137
|
const { selectedElement, keys, actions, scope } = this.operationData;
|
|
8148
|
-
this.actionInstanceInfos = requestControllerActions(
|
|
8138
|
+
this.actionInstanceInfos = requestControllerActions(services, actions, this.name, this._trigger());
|
|
8149
8139
|
this._eventbus = eventbus;
|
|
8150
8140
|
const element = selectedElement[0];
|
|
8151
|
-
const root = this.
|
|
8141
|
+
const root = this._engineRootElement(services) ?? element;
|
|
8152
8142
|
const container = scope === "element" ? element : root;
|
|
8153
8143
|
const doc = element?.ownerDocument ?? (typeof document === "undefined" ? void 0 : document);
|
|
8154
8144
|
const participant = {
|
|
@@ -8194,8 +8184,8 @@ var KeyboardController = class {
|
|
|
8194
8184
|
name: this.operationData?.keys ?? ""
|
|
8195
8185
|
};
|
|
8196
8186
|
}
|
|
8197
|
-
|
|
8198
|
-
const root =
|
|
8187
|
+
_engineRootElement(services) {
|
|
8188
|
+
const root = services.getEngineRoot()[0];
|
|
8199
8189
|
return root && typeof root.contains === "function" ? root : void 0;
|
|
8200
8190
|
}
|
|
8201
8191
|
/**
|
|
@@ -8772,6 +8762,7 @@ var NavigationController = class extends BaseController {
|
|
|
8772
8762
|
activeNavigationPoint = null;
|
|
8773
8763
|
labelControllers = [];
|
|
8774
8764
|
eventbus = null;
|
|
8765
|
+
services = null;
|
|
8775
8766
|
container = null;
|
|
8776
8767
|
_menuElement = null;
|
|
8777
8768
|
_anchorLookup = /* @__PURE__ */ new Map();
|
|
@@ -8793,10 +8784,11 @@ var NavigationController = class extends BaseController {
|
|
|
8793
8784
|
if (typeof nav.timelineUri === "string" && !this._navByTimelineUri.has(nav.timelineUri)) this._navByTimelineUri.set(nav.timelineUri, nav);
|
|
8794
8785
|
});
|
|
8795
8786
|
}
|
|
8796
|
-
attach(eventbus) {
|
|
8787
|
+
attach(eventbus, services) {
|
|
8797
8788
|
if (!this.container) return;
|
|
8798
8789
|
this.beginAttach(eventbus);
|
|
8799
8790
|
this.eventbus = eventbus;
|
|
8791
|
+
this.services = services;
|
|
8800
8792
|
this.addListener(eventbus, "navigate-to-video-url", this._handleNavigateVideoUrl);
|
|
8801
8793
|
this.addListener(eventbus, "highlight-navigation", this._highlightMenu);
|
|
8802
8794
|
this.addListener(eventbus, "request-current-navigation", this._handleRequestCurrentNavigation);
|
|
@@ -8847,6 +8839,7 @@ var NavigationController = class extends BaseController {
|
|
|
8847
8839
|
this._anchorLookup.clear();
|
|
8848
8840
|
this._highlightedAnchor = null;
|
|
8849
8841
|
this.eventbus = null;
|
|
8842
|
+
this.services = null;
|
|
8850
8843
|
}
|
|
8851
8844
|
_pushCurrentState(position = -1) {
|
|
8852
8845
|
if (!this.activeNavigationPoint) return;
|
|
@@ -8968,13 +8961,13 @@ var NavigationController = class extends BaseController {
|
|
|
8968
8961
|
selectedElement: parentElm,
|
|
8969
8962
|
translationKey
|
|
8970
8963
|
};
|
|
8971
|
-
const
|
|
8972
|
-
if (
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
|
|
8964
|
+
const { eventbus, services } = this;
|
|
8965
|
+
if (!eventbus || !services) return;
|
|
8966
|
+
const instance = services.createInstance("LabelController");
|
|
8967
|
+
instance.init(data);
|
|
8968
|
+
instance.attach(eventbus);
|
|
8969
|
+
this.labelControllers.push(instance);
|
|
8970
|
+
this.ctrlLookup[translationKey] = instance;
|
|
8978
8971
|
}
|
|
8979
8972
|
};
|
|
8980
8973
|
|
|
@@ -9501,7 +9494,8 @@ function engineError() {
|
|
|
9501
9494
|
description: `Event: engine-error
|
|
9502
9495
|
Broadcast when a timeline action that the engine started or ended on its
|
|
9503
9496
|
own fails. The error names the action, the phase (start or end) and, when
|
|
9504
|
-
known, the failing operation
|
|
9497
|
+
known, the failing operation (\`operationSystemName\`, \`operationIndex\`) and
|
|
9498
|
+
the path to it through called actions (\`operationPath\`, outermost first).`,
|
|
9505
9499
|
category: `Engine`,
|
|
9506
9500
|
args: [{
|
|
9507
9501
|
name: "error",
|
|
@@ -9568,22 +9562,6 @@ function pushHistoryState() {
|
|
|
9568
9562
|
};
|
|
9569
9563
|
}
|
|
9570
9564
|
|
|
9571
|
-
// src/eventbus/events/metadata/request-action.ts
|
|
9572
|
-
function requestAction() {
|
|
9573
|
-
return {
|
|
9574
|
-
description: `Request: request-action
|
|
9575
|
-
Answered through \`eventbus.request('request-action', actionName)\` by
|
|
9576
|
-
EngineFactory with the configured action of that name. Throws for an
|
|
9577
|
-
unknown name, with a "did you mean" hint.`,
|
|
9578
|
-
category: `Engine Request`,
|
|
9579
|
-
args: [{
|
|
9580
|
-
name: "actionName",
|
|
9581
|
-
type: "string",
|
|
9582
|
-
description: "The name of the action to request"
|
|
9583
|
-
}]
|
|
9584
|
-
};
|
|
9585
|
-
}
|
|
9586
|
-
|
|
9587
9565
|
// src/eventbus/events/metadata/request-current-language.ts
|
|
9588
9566
|
function requestCurrentLanguage() {
|
|
9589
9567
|
return {
|
|
@@ -9634,53 +9612,6 @@ function requestCurrentVideoPosition() {
|
|
|
9634
9612
|
};
|
|
9635
9613
|
}
|
|
9636
9614
|
|
|
9637
|
-
// src/eventbus/events/metadata/request-engine-root.ts
|
|
9638
|
-
function requestEngineRoot() {
|
|
9639
|
-
return {
|
|
9640
|
-
description: `Request: request-engine-root
|
|
9641
|
-
Answered through \`eventbus.request('request-engine-root')\` with the
|
|
9642
|
-
engine's root element (the container selector). From \`engine.init()\` until
|
|
9643
|
-
\`engine.destroy()\` every answer is the same jQuery instance. The engine also
|
|
9644
|
-
answers the legacy form, a broadcast whose last argument is a callback that
|
|
9645
|
-
receives the value.`,
|
|
9646
|
-
category: `Engine Request`,
|
|
9647
|
-
args: []
|
|
9648
|
-
};
|
|
9649
|
-
}
|
|
9650
|
-
|
|
9651
|
-
// src/eventbus/events/metadata/request-function.ts
|
|
9652
|
-
function requestFunction() {
|
|
9653
|
-
return {
|
|
9654
|
-
description: `Request: request-function
|
|
9655
|
-
Answered through \`eventbus.request('request-function', systemName)\` by
|
|
9656
|
-
EngineFactory with the function (such as an operation) the resource
|
|
9657
|
-
importer provides under that name. Throws for an unknown name.`,
|
|
9658
|
-
category: `Engine Request`,
|
|
9659
|
-
args: [{
|
|
9660
|
-
name: "systemName",
|
|
9661
|
-
type: "string",
|
|
9662
|
-
description: "The name of the function to request"
|
|
9663
|
-
}]
|
|
9664
|
-
};
|
|
9665
|
-
}
|
|
9666
|
-
|
|
9667
|
-
// src/eventbus/events/metadata/request-instance.ts
|
|
9668
|
-
function requestInstance() {
|
|
9669
|
-
return {
|
|
9670
|
-
description: `Request: request-instance
|
|
9671
|
-
Answered through \`eventbus.request('request-instance', systemName)\` by
|
|
9672
|
-
EngineFactory with a new instance of the class the resource importer
|
|
9673
|
-
provides under that name (a controller, for example), constructed with the
|
|
9674
|
-
eventbus. Throws for an unknown name.`,
|
|
9675
|
-
category: `Engine Request`,
|
|
9676
|
-
args: [{
|
|
9677
|
-
name: "systemName",
|
|
9678
|
-
type: "string",
|
|
9679
|
-
description: "The name of the class to instantiate"
|
|
9680
|
-
}]
|
|
9681
|
-
};
|
|
9682
|
-
}
|
|
9683
|
-
|
|
9684
9615
|
// src/eventbus/events/metadata/request-label-collection.ts
|
|
9685
9616
|
function requestLabelCollection() {
|
|
9686
9617
|
return {
|
|
@@ -10064,14 +9995,10 @@ var metadata_exports = /* @__PURE__ */ __exportAll({
|
|
|
10064
9995
|
languageChange: () => languageChange,
|
|
10065
9996
|
navigateToVideoUrl: () => navigateToVideoUrl,
|
|
10066
9997
|
pushHistoryState: () => pushHistoryState,
|
|
10067
|
-
requestAction: () => requestAction,
|
|
10068
9998
|
requestCurrentLanguage: () => requestCurrentLanguage,
|
|
10069
9999
|
requestCurrentNavigation: () => requestCurrentNavigation,
|
|
10070
10000
|
requestCurrentTimelinePosition: () => requestCurrentTimelinePosition,
|
|
10071
10001
|
requestCurrentVideoPosition: () => requestCurrentVideoPosition,
|
|
10072
|
-
requestEngineRoot: () => requestEngineRoot,
|
|
10073
|
-
requestFunction: () => requestFunction,
|
|
10074
|
-
requestInstance: () => requestInstance,
|
|
10075
10002
|
requestLabelCollection: () => requestLabelCollection,
|
|
10076
10003
|
requestLabelCollections: () => requestLabelCollections,
|
|
10077
10004
|
requestTimelineCleanup: () => requestTimelineCleanup,
|
|
@@ -10160,8 +10087,8 @@ const onceOriginals$1 = /* @__PURE__ */ new WeakMap();
|
|
|
10160
10087
|
*
|
|
10161
10088
|
* @example Request/Response pattern
|
|
10162
10089
|
* ```ts
|
|
10163
|
-
* eventbus.onRequest('request-
|
|
10164
|
-
* const
|
|
10090
|
+
* eventbus.onRequest('request-translation', (key) => translations[key]);
|
|
10091
|
+
* const label = eventbus.request<string>('request-translation', 'nav.home');
|
|
10165
10092
|
* ```
|
|
10166
10093
|
*
|
|
10167
10094
|
* Broadcasts isolate errors: a handler, listener or interceptor that throws, or
|
|
@@ -10520,6 +10447,7 @@ var EngineActionError = class extends Error {
|
|
|
10520
10447
|
phase;
|
|
10521
10448
|
operationSystemName;
|
|
10522
10449
|
operationIndex;
|
|
10450
|
+
operationPath;
|
|
10523
10451
|
cause;
|
|
10524
10452
|
/**
|
|
10525
10453
|
* @param action - The failing action
|
|
@@ -10527,26 +10455,45 @@ var EngineActionError = class extends Error {
|
|
|
10527
10455
|
* @param cause - The original error
|
|
10528
10456
|
*/
|
|
10529
10457
|
constructor(action, phase, cause) {
|
|
10530
|
-
const { operationSystemName, operationIndex } = readOperationContext(cause);
|
|
10458
|
+
const { operationSystemName, operationIndex, operationPath } = readOperationContext(cause);
|
|
10531
10459
|
const operation = operationSystemName === void 0 ? "" : ` at operation '${operationSystemName}'${operationIndex === void 0 ? "" : ` (index ${operationIndex})`}`;
|
|
10532
|
-
|
|
10460
|
+
const callers = operationPath && operationPath.length > 1 ? `, reached through ${operationPath.slice(0, -1).map((entry) => `'${entry.systemName}' (index ${entry.index})`).join(" > ")}` : "";
|
|
10461
|
+
super(`Error in action ${phase} '${action.name}'${operation}${callers}: ${describeCause(cause)}`);
|
|
10533
10462
|
this.name = "EngineActionError";
|
|
10534
10463
|
this.actionName = action.name;
|
|
10535
10464
|
this.actionId = action.id;
|
|
10536
10465
|
this.phase = phase;
|
|
10537
10466
|
this.operationSystemName = operationSystemName;
|
|
10538
10467
|
this.operationIndex = operationIndex;
|
|
10468
|
+
this.operationPath = operationPath;
|
|
10539
10469
|
this.cause = cause;
|
|
10540
10470
|
}
|
|
10541
10471
|
};
|
|
10542
10472
|
function readOperationContext(cause) {
|
|
10543
|
-
if (typeof cause !== "object"
|
|
10544
|
-
const { operationSystemName, operationIndex } = cause;
|
|
10473
|
+
if (cause === null || typeof cause !== "object") return {};
|
|
10474
|
+
const { operationSystemName, operationIndex, operationPath } = cause;
|
|
10545
10475
|
return {
|
|
10546
10476
|
operationSystemName: typeof operationSystemName === "string" ? operationSystemName : void 0,
|
|
10547
|
-
operationIndex: typeof operationIndex === "number" ? operationIndex : void 0
|
|
10477
|
+
operationIndex: typeof operationIndex === "number" ? operationIndex : void 0,
|
|
10478
|
+
operationPath: readOperationPath(operationPath)
|
|
10548
10479
|
};
|
|
10549
10480
|
}
|
|
10481
|
+
/**
|
|
10482
|
+
* A frozen copy of a well-formed operation path, or undefined for anything
|
|
10483
|
+
* else, so the engine error never shares or trusts the cause's array.
|
|
10484
|
+
*/
|
|
10485
|
+
function readOperationPath(value) {
|
|
10486
|
+
if (!Array.isArray(value) || value.length === 0) return;
|
|
10487
|
+
const entries = [];
|
|
10488
|
+
for (const entry of value) {
|
|
10489
|
+
if (entry === null || typeof entry !== "object" || typeof entry.systemName !== "string" || typeof entry.index !== "number") return;
|
|
10490
|
+
entries.push(Object.freeze({
|
|
10491
|
+
systemName: entry.systemName,
|
|
10492
|
+
index: entry.index
|
|
10493
|
+
}));
|
|
10494
|
+
}
|
|
10495
|
+
return Object.freeze(entries);
|
|
10496
|
+
}
|
|
10550
10497
|
function describeCause(cause) {
|
|
10551
10498
|
return cause instanceof Error ? cause.message : String(cause);
|
|
10552
10499
|
}
|
|
@@ -10588,7 +10535,7 @@ function createSignal() {
|
|
|
10588
10535
|
*/
|
|
10589
10536
|
function actionEnd(action) {
|
|
10590
10537
|
const { end } = action.duration;
|
|
10591
|
-
return end < 0 ?
|
|
10538
|
+
return end < 0 ? 1e400 : end;
|
|
10592
10539
|
}
|
|
10593
10540
|
/**
|
|
10594
10541
|
* Whether the action is in effect at the given position. Ranges are
|
|
@@ -10778,7 +10725,7 @@ var EligiusEngine = class EligiusEngine {
|
|
|
10778
10725
|
this.localeManager = localeManager;
|
|
10779
10726
|
this.timelineProvidersByUri = timelineProvidersByUri;
|
|
10780
10727
|
this.localesReady = localesReady;
|
|
10781
|
-
const maxCatchUp = options?.maxCatchUp ??
|
|
10728
|
+
const maxCatchUp = options?.maxCatchUp ?? 1e400;
|
|
10782
10729
|
if (typeof maxCatchUp !== "number" || !(maxCatchUp > 0)) throw new Error(`EligiusEngine: options.maxCatchUp must be a positive number of seconds, got ${String(maxCatchUp)}`);
|
|
10783
10730
|
this._maxCatchUp = maxCatchUp;
|
|
10784
10731
|
}
|
|
@@ -11284,11 +11231,11 @@ var EligiusEngine = class EligiusEngine {
|
|
|
11284
11231
|
});
|
|
11285
11232
|
this._transportPending++;
|
|
11286
11233
|
const run = idle ? invoke(task) : previous.then(task);
|
|
11287
|
-
const
|
|
11234
|
+
const settle = () => {
|
|
11288
11235
|
this._transportPending--;
|
|
11289
11236
|
release();
|
|
11290
11237
|
};
|
|
11291
|
-
run.then(
|
|
11238
|
+
run.then(settle, settle);
|
|
11292
11239
|
return run;
|
|
11293
11240
|
}
|
|
11294
11241
|
_addEventListener(eventName, eventHandler, eventTopic) {
|
|
@@ -11305,7 +11252,6 @@ var EligiusEngine = class EligiusEngine {
|
|
|
11305
11252
|
* on) and state broadcasts are owned by EngineEventbusAdapter.
|
|
11306
11253
|
*/
|
|
11307
11254
|
_addEventbusListeners() {
|
|
11308
|
-
this._addEventListener("request-engine-root", this._handleRequestEngineRoot.bind(this));
|
|
11309
11255
|
this._addEventListener("request-current-timeline-position", this._handleRequestTimelinePosition.bind(this));
|
|
11310
11256
|
this._addEventListener("request-timeline-cleanup", this._handleTimelineComplete.bind(this));
|
|
11311
11257
|
this._addEventListener("timeline-request-current-timeline", this._requestCurrentTimeline.bind(this));
|
|
@@ -11379,9 +11325,6 @@ var EligiusEngine = class EligiusEngine {
|
|
|
11379
11325
|
}, [[], []]);
|
|
11380
11326
|
return [...endMethods.sort(sortActionMethodsHighestStartPositionFirst), ...startMethods];
|
|
11381
11327
|
}
|
|
11382
|
-
_handleRequestEngineRoot(resultCallback) {
|
|
11383
|
-
resultCallback(this.engineRoot);
|
|
11384
|
-
}
|
|
11385
11328
|
_getActiveActions(allActions) {
|
|
11386
11329
|
return allActions.filter((action) => action.active).sort(sortActionsHighestStartPositionFirst);
|
|
11387
11330
|
}
|
|
@@ -13401,6 +13344,94 @@ const PARAMETER_TYPES = [
|
|
|
13401
13344
|
"ParameterType:DocumentFragment"
|
|
13402
13345
|
];
|
|
13403
13346
|
|
|
13347
|
+
// src/engine-services.ts
|
|
13348
|
+
/**
|
|
13349
|
+
* The services of one engine, created by `EngineFactory.createEngine`.
|
|
13350
|
+
*
|
|
13351
|
+
* The configuration resolver hands it to every action it creates, before the
|
|
13352
|
+
* action lookup and the engine exist; the factory supplies both once they do
|
|
13353
|
+
* ({@link setActions}, {@link setEngine}). After {@link dispose} every lookup
|
|
13354
|
+
* throws, so a destroyed engine's actions cannot reach its resources.
|
|
13355
|
+
*/
|
|
13356
|
+
var EngineServices = class {
|
|
13357
|
+
importer;
|
|
13358
|
+
eventbus;
|
|
13359
|
+
_actions;
|
|
13360
|
+
_engine;
|
|
13361
|
+
_disposed = false;
|
|
13362
|
+
/**
|
|
13363
|
+
* @param importer - Provides the registered functions, classes and data
|
|
13364
|
+
* @param eventbus - The engine's eventbus, passed to created instances
|
|
13365
|
+
*/
|
|
13366
|
+
constructor(importer, eventbus) {
|
|
13367
|
+
this.importer = importer;
|
|
13368
|
+
this.eventbus = eventbus;
|
|
13369
|
+
}
|
|
13370
|
+
/**
|
|
13371
|
+
* Supplies the resolved actions that {@link getAction} looks up.
|
|
13372
|
+
*
|
|
13373
|
+
* @param actions - The action lookup, by name
|
|
13374
|
+
*/
|
|
13375
|
+
setActions(actions) {
|
|
13376
|
+
this._actions = actions;
|
|
13377
|
+
}
|
|
13378
|
+
/**
|
|
13379
|
+
* Supplies the engine whose root {@link getEngineRoot} returns.
|
|
13380
|
+
*
|
|
13381
|
+
* @param engine - The engine these services belong to
|
|
13382
|
+
*/
|
|
13383
|
+
setEngine(engine) {
|
|
13384
|
+
this._engine = engine;
|
|
13385
|
+
}
|
|
13386
|
+
/**
|
|
13387
|
+
* Releases the actions and the engine. Every lookup throws afterwards.
|
|
13388
|
+
*/
|
|
13389
|
+
dispose() {
|
|
13390
|
+
this._disposed = true;
|
|
13391
|
+
this._actions = void 0;
|
|
13392
|
+
this._engine = void 0;
|
|
13393
|
+
}
|
|
13394
|
+
getAction(systemName) {
|
|
13395
|
+
const actions = this._require(this._actions, "the actions are");
|
|
13396
|
+
if (Object.hasOwn(actions, systemName)) return actions[systemName];
|
|
13397
|
+
throw new Error(unknownActionMessage(systemName, Object.keys(actions)));
|
|
13398
|
+
}
|
|
13399
|
+
getImport(systemName) {
|
|
13400
|
+
this._assertLive();
|
|
13401
|
+
return importSystemEntry(this.importer, systemName);
|
|
13402
|
+
}
|
|
13403
|
+
createInstance(systemName) {
|
|
13404
|
+
return new (this.getImport(systemName))(this.eventbus);
|
|
13405
|
+
}
|
|
13406
|
+
getEngineRoot() {
|
|
13407
|
+
return this._require(this._engine, "the engine is").engineRoot;
|
|
13408
|
+
}
|
|
13409
|
+
_assertLive() {
|
|
13410
|
+
if (this._disposed) throw new Error("EngineServices: the engine was destroyed");
|
|
13411
|
+
}
|
|
13412
|
+
_require(value, what) {
|
|
13413
|
+
this._assertLive();
|
|
13414
|
+
if (value === void 0) throw new Error(`EngineServices: ${what} not available yet; EngineFactory supplies it once the engine is created`);
|
|
13415
|
+
return value;
|
|
13416
|
+
}
|
|
13417
|
+
};
|
|
13418
|
+
/**
|
|
13419
|
+
* Returns the entry the importer provides under `systemName`.
|
|
13420
|
+
*
|
|
13421
|
+
* @param importer - The resource importer
|
|
13422
|
+
* @param systemName - The registered name
|
|
13423
|
+
* @returns The entry; registered JSON and templates may be `0`, `''` or `false`
|
|
13424
|
+
* @throws Error when the importer throws or provides nothing under the name
|
|
13425
|
+
*/
|
|
13426
|
+
function importSystemEntry(importer, systemName) {
|
|
13427
|
+
const entry = importer.import(systemName)?.[systemName];
|
|
13428
|
+
if (entry === void 0) throw new Error(`Failed to import '${systemName}': module does not export '${systemName}'`);
|
|
13429
|
+
return entry;
|
|
13430
|
+
}
|
|
13431
|
+
function unknownActionMessage(name, knownNames) {
|
|
13432
|
+
return `Unknown action '${name}'. ${formatDidYouMean(findClosestNames(name, knownNames)) || "Check the action name in the configuration."}`;
|
|
13433
|
+
}
|
|
13434
|
+
|
|
13404
13435
|
// src/locale/locale-loader.ts
|
|
13405
13436
|
/**
|
|
13406
13437
|
* LocaleLoader - External locale file loading with $ref resolution
|
|
@@ -13963,8 +13994,6 @@ var EngineFactory = class {
|
|
|
13963
13994
|
* An engine's destroy() removes its own; factory.destroy() the rest.
|
|
13964
13995
|
*/
|
|
13965
13996
|
_eventRemovers = /* @__PURE__ */ new Set();
|
|
13966
|
-
/** Action lookups of the live engines, oldest first */
|
|
13967
|
-
_actionLookups = /* @__PURE__ */ new Map();
|
|
13968
13997
|
/** Live engines on the shared eventbus */
|
|
13969
13998
|
_liveSharedEngines = 0;
|
|
13970
13999
|
_importer;
|
|
@@ -13982,7 +14011,6 @@ var EngineFactory = class {
|
|
|
13982
14011
|
this._windowRef = windowRef;
|
|
13983
14012
|
this._options = options;
|
|
13984
14013
|
this._sharedEventbus = options?.eventbus;
|
|
13985
|
-
if (this._sharedEventbus) this._registerResponders(this._sharedEventbus, (systemName) => this._findLiveAction(systemName), () => this._liveActionNames(), (remover) => this._eventRemovers.add(remover));
|
|
13986
14014
|
}
|
|
13987
14015
|
/**
|
|
13988
14016
|
* Destroys the factory and cleans up all registered request handlers.
|
|
@@ -13991,40 +14019,9 @@ var EngineFactory = class {
|
|
|
13991
14019
|
const removers = [...this._eventRemovers];
|
|
13992
14020
|
this._eventRemovers.clear();
|
|
13993
14021
|
removers.forEach((remove) => remove());
|
|
13994
|
-
this._actionLookups.clear();
|
|
13995
14022
|
}
|
|
13996
14023
|
_importSystemEntry(systemName) {
|
|
13997
|
-
|
|
13998
|
-
if (entry === void 0) throw new Error(`Failed to import '${systemName}': module does not export '${systemName}'`);
|
|
13999
|
-
return entry;
|
|
14000
|
-
}
|
|
14001
|
-
/**
|
|
14002
|
-
* Registers the 'request-instance', 'request-action' and
|
|
14003
|
-
* 'request-function' responders on an eventbus. Instances are constructed
|
|
14004
|
-
* with that eventbus. 'request-action' throws for an unknown action name,
|
|
14005
|
-
* with a "did you mean" hint built from `knownActions`.
|
|
14006
|
-
*/
|
|
14007
|
-
_registerResponders(eventbus, findAction, knownActions, addRemover) {
|
|
14008
|
-
addRemover(eventbus.onRequest("request-instance", (systemName) => {
|
|
14009
|
-
return new (this._importSystemEntry(systemName))(eventbus);
|
|
14010
|
-
}));
|
|
14011
|
-
addRemover(eventbus.onRequest("request-action", (systemName) => {
|
|
14012
|
-
const action = findAction(systemName);
|
|
14013
|
-
if (action) return action;
|
|
14014
|
-
throw new Error(unknownActionMessage(systemName, knownActions()));
|
|
14015
|
-
}));
|
|
14016
|
-
addRemover(eventbus.onRequest("request-function", (systemName) => this._importSystemEntry(systemName)));
|
|
14017
|
-
}
|
|
14018
|
-
_findLiveAction(systemName) {
|
|
14019
|
-
const lookups = [...this._actionLookups.values()];
|
|
14020
|
-
for (let i = lookups.length - 1; i >= 0; i--) if (Object.hasOwn(lookups[i], systemName)) return lookups[i][systemName];
|
|
14021
|
-
}
|
|
14022
|
-
_liveActionNames() {
|
|
14023
|
-
const names = /* @__PURE__ */ new Set();
|
|
14024
|
-
this._actionLookups.forEach((lookup) => {
|
|
14025
|
-
Object.keys(lookup).forEach((name) => names.add(name));
|
|
14026
|
-
});
|
|
14027
|
-
return [...names];
|
|
14024
|
+
return importSystemEntry(this._importer, systemName);
|
|
14028
14025
|
}
|
|
14029
14026
|
/**
|
|
14030
14027
|
* Creates a fully wired engine with adapters and event handlers.
|
|
@@ -14046,18 +14043,22 @@ var EngineFactory = class {
|
|
|
14046
14043
|
* `engine.destroy()`) aborts loads that are still pending, disconnects the
|
|
14047
14044
|
* adapters and removes the engine's eventbus registrations.
|
|
14048
14045
|
*
|
|
14046
|
+
* Each engine gets its own {@link EngineServices}: its actions and
|
|
14047
|
+
* operations look up actions, imports and the engine root there, never on
|
|
14048
|
+
* the eventbus, so they always resolve against their own engine.
|
|
14049
|
+
*
|
|
14049
14050
|
* @param configuration - The engine configuration
|
|
14050
|
-
* @param resolver - Optional custom configuration resolver
|
|
14051
14051
|
* @returns Engine result with engine, locale manager, eventbus, and destroy function
|
|
14052
14052
|
* @throws Error when the configuration cannot be resolved or a provider
|
|
14053
14053
|
* cannot be created
|
|
14054
14054
|
*/
|
|
14055
|
-
createEngine(configuration
|
|
14055
|
+
createEngine(configuration) {
|
|
14056
14056
|
const { systemName } = configuration.engine;
|
|
14057
14057
|
const EngineClass = this._importSystemEntry(systemName);
|
|
14058
14058
|
const ownsEventbus = !this._sharedEventbus;
|
|
14059
14059
|
const eventbus = this._sharedEventbus ?? new Eventbus();
|
|
14060
|
-
if (!ownsEventbus && this._liveSharedEngines > 0) console.warn("[EngineFactory] Creating a second live engine on a shared eventbus: requests such as request-
|
|
14060
|
+
if (!ownsEventbus && this._liveSharedEngines > 0) console.warn("[EngineFactory] Creating a second live engine on a shared eventbus: requests such as request-current-timeline-position are answered by the first engine and commands reach both. Use a factory without options.eventbus to give each engine its own eventbus.");
|
|
14061
|
+
const services = new EngineServices(this._importer, eventbus);
|
|
14061
14062
|
const engineRemovers = [];
|
|
14062
14063
|
const addEngineRemover = (remover) => {
|
|
14063
14064
|
engineRemovers.push(remover);
|
|
@@ -14080,6 +14081,7 @@ var EngineFactory = class {
|
|
|
14080
14081
|
released = true;
|
|
14081
14082
|
adapters.forEach((adapter) => adapter.disconnect());
|
|
14082
14083
|
removeEngineRegistrations();
|
|
14084
|
+
services.dispose();
|
|
14083
14085
|
liveEngineCount--;
|
|
14084
14086
|
if (!ownsEventbus) this._liveSharedEngines--;
|
|
14085
14087
|
if (liveEngineCount === 0) {
|
|
@@ -14092,20 +14094,17 @@ var EngineFactory = class {
|
|
|
14092
14094
|
let engineInputAdapter;
|
|
14093
14095
|
try {
|
|
14094
14096
|
const actionRegistryListener = configuration.eventActions?.length ? new ActionRegistryEventbusListener() : void 0;
|
|
14095
|
-
|
|
14096
|
-
|
|
14097
|
+
const [actionLookup, resolvedConfiguration] = new ConfigurationResolver(this._importer, eventbus, services).process(configuration, actionRegistryListener);
|
|
14098
|
+
services.setActions(actionLookup);
|
|
14097
14099
|
const timelineProviders = this._createTimelineProviders(resolvedConfiguration);
|
|
14098
14100
|
const timelineProvidersByUri = this.createTimelineProvidersByUri(resolvedConfiguration, timelineProviders);
|
|
14099
|
-
const lookupKey = {};
|
|
14100
|
-
this._actionLookups.set(lookupKey, actionLookup);
|
|
14101
|
-
addEngineRemover(() => this._actionLookups.delete(lookupKey));
|
|
14102
|
-
if (ownsEventbus) this._registerResponders(eventbus, (name) => Object.hasOwn(actionLookup, name) ? actionLookup[name] : void 0, () => Object.keys(actionLookup), addEngineRemover);
|
|
14103
14101
|
if (actionRegistryListener) addEngineRemover(eventbus.registerEventlistener(actionRegistryListener));
|
|
14104
14102
|
addEngineRemover(eventbus.registerInterceptor("request-timeline-uri", new RequestVideoUriInterceptor(eventbus)));
|
|
14105
14103
|
const { language, locales } = configuration;
|
|
14106
14104
|
localeManager = new LocaleManager({ defaultLocale: language });
|
|
14107
14105
|
const localesReady = this._loadLocales(localeManager, locales, localeLoads.signal);
|
|
14108
14106
|
engineInstance = new EngineClass(resolvedConfiguration, eventbus, timelineProviders, localeManager, timelineProvidersByUri, localesReady, this._options?.engineOptions);
|
|
14107
|
+
services.setEngine(engineInstance);
|
|
14109
14108
|
engineInputAdapter = new EngineInputAdapter(engineInstance, eventbus, this._windowRef, {
|
|
14110
14109
|
playToggleHotkey: this._options?.playToggleHotkey,
|
|
14111
14110
|
...this._options?.input
|
|
@@ -14125,6 +14124,7 @@ var EngineFactory = class {
|
|
|
14125
14124
|
localeLoads.abort();
|
|
14126
14125
|
adapters.forEach((adapter) => adapter.disconnect());
|
|
14127
14126
|
removeEngineRegistrations();
|
|
14127
|
+
services.dispose();
|
|
14128
14128
|
throw error;
|
|
14129
14129
|
}
|
|
14130
14130
|
liveEngineCount++;
|
|
@@ -14143,6 +14143,7 @@ var EngineFactory = class {
|
|
|
14143
14143
|
engine: engineInstance,
|
|
14144
14144
|
localeManager,
|
|
14145
14145
|
eventbus,
|
|
14146
|
+
services,
|
|
14146
14147
|
destroy: () => {
|
|
14147
14148
|
destroyPromise ??= destroyEngine();
|
|
14148
14149
|
return destroyPromise;
|
|
@@ -14375,9 +14376,6 @@ var EngineFactory = class {
|
|
|
14375
14376
|
return sharedContainers.get(key);
|
|
14376
14377
|
}
|
|
14377
14378
|
};
|
|
14378
|
-
function unknownActionMessage(name, knownNames) {
|
|
14379
|
-
return `Unknown action '${name}'. ${formatDidYouMean(findClosestNames(name, knownNames)) || "Check the action name in the configuration."}`;
|
|
14380
|
-
}
|
|
14381
14379
|
function hasIntrinsicContainer(source) {
|
|
14382
14380
|
const candidate = source;
|
|
14383
14381
|
return typeof candidate.getContainer === "function" && typeof candidate.onContainerReady === "function";
|
|
@@ -14400,5 +14398,5 @@ function representativeTimeline(timelines, type, settings) {
|
|
|
14400
14398
|
return ofType.find((t) => !overridesPositionSource(t, settings)) ?? ofType.at(0);
|
|
14401
14399
|
}
|
|
14402
14400
|
|
|
14403
|
-
export { setElementContent$1 as $, calc$1 as $t, LabelController as A, getFormData$1 as At, toggleFormElement$1 as B, filterArray$1 as Bt, metadata_exports as C, httpPut$1 as Ct, NavigationController as D, getScrollPosition$1 as Dt, ProgressbarController as E, getTextContent$1 as Et, findClosestNames as F, getControllerFromElement$1 as Ft, splitString$1 as G, customFunction$1 as Gt, toggleClass$1 as H, endWhen$1 as Ht, formatDidYouMean as I, getAttributesFromElement$1 as It, setStyle$1 as J, concatenateStrings$1 as Jt, sortArray$1 as K, createElement$1 as Kt, metadata_exports$2 as L, formatText$1 as Lt, DOMEventListenerController as M, getElementDimensions$1 as Mt, ConfigurationResolver as N, getCurrentTime$1 as Nt, MutationObserverController as O, getQueryParams$1 as Ot, metadata_exports$1 as P, getControllerInstance$1 as Pt, setFocus$1 as Q, clearElement$1 as Qt, wait$1 as R, formatDate$1 as Rt, ActionRegistryEventbusListener as S, invokeObjectMethod$1 as St, RoutingController as T, httpDelete$1 as Tt, substringText$1 as U, endForEach$1 as Ut, toggleElement$1 as V, extendController$1 as Vt, startAction$1 as W, endAction$1 as Wt, setGlobalData$1 as X, clearStorage$1 as Xt, setOperationData$1 as Y, compareDate$1 as Yt, setFormValue$1 as Z, clearOperationData$1 as Zt, EligiusEngine as _, deepCopy as _n, log$1 as _t, PARAMETER_TYPES as a, addGlobalsToOperation$1 as an, saveToStorage$1 as at, RequestVideoUriInterceptor as b, loadFromStorage$1 as bt, VideoPositionSource as c, LocaleEventbusAdapter as cn, replaceString$1 as ct, KeyboardStepSource as d, TimelineAction as dn, removeElement$1 as dt, broadcastEvent$1 as en, setElementAttributes$1 as et, BasePositionSource as f, EndableAction as fn, removeControllerFromElement$1 as ft, describeKind as g, clearGlobals as gn, mapArray$1 as gt, checkShape as h, forEach$1 as hn, math$1 as ht, LocaleLoader as i, animate$1 as in, scrollToElement$1 as it, KeyboardController as j, getFocusedElement$1 as jt, LottieController as k, getImport$1 as kt, ScrollPositionSource as l, EngineInputAdapter as ln, reparentElement$1 as lt, createImporter as m, when$1 as mn, otherwise$1 as mt, LocaleManager as n, announceToScreenReader$1 as nn, selectElement$1 as nt, SimplePlaylist as o, addControllerToElement$1 as on, requestAction$
|
|
14404
|
-
//# sourceMappingURL=engine-factory-
|
|
14401
|
+
export { setElementContent$1 as $, calc$1 as $t, LabelController as A, getFormData$1 as At, toggleFormElement$1 as B, filterArray$1 as Bt, metadata_exports as C, httpPut$1 as Ct, NavigationController as D, getScrollPosition$1 as Dt, ProgressbarController as E, getTextContent$1 as Et, findClosestNames as F, getControllerFromElement$1 as Ft, splitString$1 as G, customFunction$1 as Gt, toggleClass$1 as H, endWhen$1 as Ht, formatDidYouMean as I, getAttributesFromElement$1 as It, setStyle$1 as J, concatenateStrings$1 as Jt, sortArray$1 as K, createElement$1 as Kt, metadata_exports$2 as L, formatText$1 as Lt, DOMEventListenerController as M, getElementDimensions$1 as Mt, ConfigurationResolver as N, getCurrentTime$1 as Nt, MutationObserverController as O, getQueryParams$1 as Ot, metadata_exports$1 as P, getControllerInstance$1 as Pt, setFocus$1 as Q, clearElement$1 as Qt, wait$1 as R, formatDate$1 as Rt, ActionRegistryEventbusListener as S, invokeObjectMethod$1 as St, RoutingController as T, httpDelete$1 as Tt, substringText$1 as U, endForEach$1 as Ut, toggleElement$1 as V, extendController$1 as Vt, startAction$1 as W, endAction$1 as Wt, setGlobalData$1 as X, clearStorage$1 as Xt, setOperationData$1 as Y, compareDate$1 as Yt, setFormValue$1 as Z, clearOperationData$1 as Zt, EligiusEngine as _, deepCopy as _n, log$1 as _t, PARAMETER_TYPES as a, addGlobalsToOperation$1 as an, saveToStorage$1 as at, RequestVideoUriInterceptor as b, loadFromStorage$1 as bt, VideoPositionSource as c, LocaleEventbusAdapter as cn, replaceString$1 as ct, KeyboardStepSource as d, TimelineAction as dn, removeElement$1 as dt, broadcastEvent$1 as en, setElementAttributes$1 as et, BasePositionSource as f, EndableAction as fn, removeControllerFromElement$1 as ft, describeKind as g, clearGlobals as gn, mapArray$1 as gt, checkShape as h, forEach$1 as hn, math$1 as ht, LocaleLoader as i, animate$1 as in, scrollToElement$1 as it, KeyboardController as j, getFocusedElement$1 as jt, LottieController as k, getImport$1 as kt, ScrollPositionSource as l, EngineInputAdapter as ln, reparentElement$1 as lt, createImporter as m, when$1 as mn, otherwise$1 as mt, LocaleManager as n, announceToScreenReader$1 as nn, selectElement$1 as nt, SimplePlaylist as o, addControllerToElement$1 as on, requestAction$1 as ot, isSeekable as p, Action as pn, removeClass$1 as pt, setVariable$1 as q, continueForEach$1 as qt, isLocaleReference as r, animateWithClass$1 as rn, scrollToPosition$1 as rt, DomContainerProvider as s, addClass$1 as sn, replaceText$1 as st, EngineFactory as t, breakForEach$1 as tn, setData$1 as tt, RafPositionSource as u, EngineEventbusAdapter as un, removePropertiesFromOperationData$1 as ut, EngineActionError as v, clearJsonCache as vt, SubtitlesController as w, httpPost$1 as wt, Eventbus as x, isElementInViewport$1 as xt, TypedEventEmitter as y, loadJson$1 as yt, validateForm$1 as z, findInArray$1 as zt };
|
|
14402
|
+
//# sourceMappingURL=engine-factory-65BHSli8.mjs.map
|