eligius 3.0.1 → 4.1.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/README.md +102 -6
- package/dist/configuration-api.d.mts +144 -328
- package/dist/configuration-api.mjs +197 -241
- package/dist/configuration-api.mjs.map +1 -1
- package/dist/engine-factory-BHDMlt6g.mjs +14404 -0
- package/dist/engine-factory-BHDMlt6g.mjs.map +1 -0
- package/dist/index.d.mts +835 -9673
- package/dist/index.mjs +1555 -15430
- package/dist/index.mjs.map +1 -1
- package/dist/lint.d.mts +5005 -0
- package/dist/lint.mjs +4406 -0
- package/dist/lint.mjs.map +1 -0
- package/dist/locale-manager-CNZ2kj0g.d.mts +8537 -0
- package/dist/metadata.d.mts +128 -567
- package/dist/metadata.mjs +184 -276
- package/dist/metadata.mjs.map +1 -1
- package/dist/{rolldown-runtime-BOlb2svz.mjs → rolldown-runtime-CGzGPw9x.mjs} +1 -2
- package/dist/runtime.d.mts +3 -0
- package/dist/runtime.mjs +4 -0
- package/jsonschema/eligius-configuration.json +53 -7
- package/package.json +24 -11
package/README.md
CHANGED
|
@@ -75,9 +75,27 @@ These settings describe the providers that are available for the different kinds
|
|
|
75
75
|
**Position Sources** (required) - drive timeline position:
|
|
76
76
|
- `RafPositionSource` - RequestAnimationFrame-based, for animation timelines
|
|
77
77
|
- `ScrollPositionSource` - Scroll-based, for scroll-driven timelines
|
|
78
|
-
- `VideoPositionSource` -
|
|
78
|
+
- `VideoPositionSource` - native HTML `<video>` element, for video and audio timelines (browser-playable media files such as MP4, WebM or MP3; no HLS/DASH player)
|
|
79
79
|
- `KeyboardStepSource` - Keyboard-driven stepping through markers or fixed steps
|
|
80
80
|
|
|
81
|
+
A media timeline names the container, the sources (in order of preference) and an optional poster:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
"mediaplayer": {
|
|
85
|
+
"positionSource": {
|
|
86
|
+
"systemName": "VideoPositionSource",
|
|
87
|
+
"selector": "#video",
|
|
88
|
+
"sources": [
|
|
89
|
+
{"src": "/intro.webm", "type": "video/webm"},
|
|
90
|
+
{"src": "/intro.mp4", "type": "video/mp4"}
|
|
91
|
+
],
|
|
92
|
+
"poster": "/intro.jpg"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The source appends a `<video class="eligius-video">` without controls to the container; size it with CSS. `init()` rejects when no source can be played, or when none becomes playable within `loadTimeout` milliseconds (default `30000`, `0` disables the limit). Since 4.0.0 there is no `options` key.
|
|
98
|
+
|
|
81
99
|
**Container Providers** (optional) - manage DOM elements where content is rendered:
|
|
82
100
|
- `DomContainerProvider` - Manages a DOM element by selector
|
|
83
101
|
|
|
@@ -273,7 +291,7 @@ Or name another class to give one timeline a different clock, for example a scro
|
|
|
273
291
|
{ "uri": "chapter-2", "type": "animation", "positionSource": { "systemName": "ScrollPositionSource", "selector": "#chapter-2" }, ... }
|
|
274
292
|
```
|
|
275
293
|
|
|
276
|
-
An override that names a different `systemName` replaces the type settings instead of merging with them, so options meant for one class never reach another. A timeline that names its own `systemName` needs no `timelineProviderSettings` entry for its type. Video timelines share one
|
|
294
|
+
An override that names a different `systemName` replaces the type settings instead of merging with them, so options meant for one class never reach another. A timeline that names its own `systemName` needs no `timelineProviderSettings` entry for its type. Video timelines share one video element unless an override changes the video settings, for example `{"positionSource": {"sources": [{"src": "/chapter-2.mp4", "type": "video/mp4"}]}}`, which gives that timeline its own video element. With the fluent API use `factory.setTimelinePositionSource('chapter-2', {...})` and `setTimelineContainerProvider`.
|
|
277
295
|
|
|
278
296
|
### event actions
|
|
279
297
|
|
|
@@ -481,7 +499,48 @@ await engine.init();
|
|
|
481
499
|
await engine.start();
|
|
482
500
|
```
|
|
483
501
|
|
|
484
|
-
Custom operations have no generated metadata, so the JSON schema and the fluent API do not type or validate their operation data; only their names are checked. Custom position sources, container providers and playlists cannot be registered this way: pass your own `IResourceImporter` to the `EngineFactory` and delegate the other names to an `EligiusResourceImporter`.
|
|
502
|
+
Custom operations have no generated metadata, so the JSON schema and the fluent API do not type or validate their operation data; only their names are checked. Custom position sources, container providers and playlists cannot be registered this way: build the importer with `createImporter` (next section), or pass your own `IResourceImporter` to the `EngineFactory` and delegate the other names to an `EligiusResourceImporter`.
|
|
503
|
+
|
|
504
|
+
## Smaller bundles (`eligius/runtime` and `createImporter`)
|
|
505
|
+
|
|
506
|
+
`EligiusResourceImporter` references every operation, controller and timeline provider, so a bundler has to keep them all. A presentation that plays a finished configuration can instead name only what it uses with `createImporter`, and import the engine from `eligius/runtime`:
|
|
507
|
+
|
|
508
|
+
```typescript
|
|
509
|
+
import {
|
|
510
|
+
addClass,
|
|
511
|
+
createImporter,
|
|
512
|
+
DomContainerProvider,
|
|
513
|
+
EngineFactory,
|
|
514
|
+
RafPositionSource,
|
|
515
|
+
selectElement,
|
|
516
|
+
SimplePlaylist,
|
|
517
|
+
} from 'eligius/runtime';
|
|
518
|
+
|
|
519
|
+
const importer = createImporter({
|
|
520
|
+
operations: {selectElement, addClass, trackEvent},
|
|
521
|
+
providers: {RafPositionSource, DomContainerProvider, SimplePlaylist},
|
|
522
|
+
functions: {formatPrice},
|
|
523
|
+
templates: {layout: '<div id="stage"></div>'},
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
const {engine} = new EngineFactory(importer, window).createEngine(configuration);
|
|
527
|
+
await engine.init();
|
|
528
|
+
await engine.start();
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
`createImporter` takes the same `operations`, `functions`, `controllers`, `templates` and `json` maps as the `EligiusResourceImporter` registrations, plus `providers` (position sources, container providers and playlists) and `engines` (defaults to `{EligiusEngine}`). There are no built-in names, so there is no `override`. A misspelled name in the configuration fails with a "did you mean" hint over the names you passed.
|
|
532
|
+
|
|
533
|
+
`eligius/runtime` exports everything `eligius` exports except the fluent configuration API (`ConfigurationFactory` and the editors) and `EligiusResourceImporter`. Both entries come out of one build, so an application that imports from both shares one engine, one global data store and one JSON cache. Authoring tools that need the fluent API without a DOM use `eligius/configuration-api`.
|
|
534
|
+
|
|
535
|
+
The package declares `"sideEffects": false`. For a 15-operation sample deck (jQuery external, minified, gzipped):
|
|
536
|
+
|
|
537
|
+
| Importer and entry | Vite 8 (rolldown) | webpack 5 | esbuild |
|
|
538
|
+
|---|---|---|---|
|
|
539
|
+
| `EligiusResourceImporter` from `eligius` | 59.2 KB | 58.9 KB | 60.0 KB |
|
|
540
|
+
| `createImporter` from `eligius` | 28.1 KB | 28.3 KB | 49.0 KB |
|
|
541
|
+
| `createImporter` from `eligius/runtime` | 28.1 KB | 28.3 KB | 29.0 KB |
|
|
542
|
+
|
|
543
|
+
esbuild keeps the operation registration of the main entry, so use `eligius/runtime` there. The remaining size is the engine core; see `specs/007-aot-compiler/measurements.md` for the breakdown.
|
|
485
544
|
|
|
486
545
|
## Metadata import (`eligius/metadata`)
|
|
487
546
|
|
|
@@ -494,10 +553,48 @@ const operationNames = Object.keys(metadata); // 'addClass', 'selectElement
|
|
|
494
553
|
const { description, properties } = metadata.addClass();
|
|
495
554
|
```
|
|
496
555
|
|
|
497
|
-
This entry is bundled separately and contains **only metadata** — it does not pull in the engine runtime (jQuery, lottie-web
|
|
556
|
+
This entry is bundled separately and contains **only metadata** — it does not pull in the engine runtime (jQuery, lottie-web). As a result it can be imported from a plain Node process **without a DOM**, unlike the main `eligius` entry, which evaluates the browser runtime (jQuery) on import and therefore requires a `window`.
|
|
498
557
|
|
|
499
558
|
Rule of thumb: use `eligius/metadata` for build-time and server-side tooling; use the main `eligius` entry to actually run the engine.
|
|
500
559
|
|
|
560
|
+
## Linting configurations (`eligius/lint`)
|
|
561
|
+
|
|
562
|
+
`lintConfiguration` checks a configuration at build time, in plain Node, without running it:
|
|
563
|
+
|
|
564
|
+
```javascript
|
|
565
|
+
import {lintConfiguration} from 'eligius/lint';
|
|
566
|
+
|
|
567
|
+
const diagnostics = lintConfiguration(configuration, {
|
|
568
|
+
customOperations: ['trackEvent'],
|
|
569
|
+
templates: ['layout'],
|
|
570
|
+
});
|
|
571
|
+
for (const {severity, code, path, message} of diagnostics) {
|
|
572
|
+
console.log(`${severity} ${code} at ${path}: ${message}`);
|
|
573
|
+
}
|
|
574
|
+
// error E001 at timelines[0].timelineActions[0].startOperations[0].systemName: Unknown operation 'selectElemen' at ... Did you mean 'selectElement'?
|
|
575
|
+
// error E101 at timelines[0].timelineActions[0].startOperations[3].systemName: endWhen at index 3 has no open when to close. ...
|
|
576
|
+
// warning W110 at timelines[0].timelineActions[0].startOperations[1]: addClass: 'selectedElement' must be provided by an earlier operation ...
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
It runs the real `ConfigurationResolver` with stand-ins for the operations, controllers and timeline providers, so every error `createEngine` would throw is reported with the same message and JSON path (`E001`). It then checks every operation list:
|
|
580
|
+
|
|
581
|
+
| Code | Reports |
|
|
582
|
+
|---|---|
|
|
583
|
+
| `E101` | `when`/`forEach` blocks that are not balanced or do not nest, `breakForEach` outside a loop |
|
|
584
|
+
| `E111` / `W111` | a required property that neither the operation data nor an earlier operation provides |
|
|
585
|
+
| `E120` | a value outside its allowed literals (for example a `calc` operator) |
|
|
586
|
+
| `E130` / `E131` | a `when` expression that does not parse, an unknown operand |
|
|
587
|
+
| `E140` / `E141` | a property chain with `__proto__`, `prototype` or `constructor`, a `__proto__` key in operation data |
|
|
588
|
+
| `E160` / `W160` | an unrecognized `setData` target, a write to a scope field the engine uses |
|
|
589
|
+
| `E310` | a `requestAction` name that no action has |
|
|
590
|
+
| `W110` | a dependency (such as `selectedElement`) that no earlier operation provides |
|
|
591
|
+
| `W150` | a property chain in a field the operation does not resolve, so it is passed on as text |
|
|
592
|
+
| `W151` | an `$operationdata` read of a property that nothing provides |
|
|
593
|
+
|
|
594
|
+
Errors are certain. Warnings are likely mistakes; the data-flow warnings are only reported for timeline actions and init actions, which start with empty operation data, and never after an operation whose effect on the data is not described (a custom operation, `customFunction`, `startAction`). The options name the custom operations, controllers, providers and functions the host registers, and optionally the templates and JSON values `template:` and `json:` placeholders may use.
|
|
595
|
+
|
|
596
|
+
The engine reports the `E101` shapes as well: `ConfigurationResolver` warns about them on the console (or through its `onWarning` option) while still resolving the configuration. They become errors in the next major version.
|
|
597
|
+
|
|
501
598
|
## Source documentation
|
|
502
599
|
|
|
503
600
|
[Check out this link for the full type docs](https://rolandzwaga.github.io/eligius/)
|
|
@@ -518,10 +615,9 @@ Peer dependencies:
|
|
|
518
615
|
|
|
519
616
|
- `jquery` (required)
|
|
520
617
|
- `lottie-web` (optional, only for `LottieController`, loaded on first use)
|
|
521
|
-
- `video.js` (optional, only for `VideoPositionSource`, loaded on first use)
|
|
522
618
|
- `@types/jquery` (optional, for TypeScript users of the main entry; also add `"DOM"` to your `lib`)
|
|
523
619
|
|
|
524
|
-
Upgrading from
|
|
620
|
+
Upgrading from 3.x? Version 4.0.0 replaces the video.js player with the native video element and removes the `options` key of `VideoPositionSource`; read the [changelog](CHANGELOG.md) first. Upgrading from 2.x? Read the 3.0.0 breaking changes too.
|
|
525
621
|
|
|
526
622
|
## development
|
|
527
623
|
|