eligius 4.0.0 → 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 CHANGED
@@ -499,7 +499,48 @@ await engine.init();
499
499
  await engine.start();
500
500
  ```
501
501
 
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: 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.
503
544
 
504
545
  ## Metadata import (`eligius/metadata`)
505
546
 
@@ -516,6 +557,44 @@ This entry is bundled separately and contains **only metadata** — it does not
516
557
 
517
558
  Rule of thumb: use `eligius/metadata` for build-time and server-side tooling; use the main `eligius` entry to actually run the engine.
518
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
+
519
598
  ## Source documentation
520
599
 
521
600
  [Check out this link for the full type docs](https://rolandzwaga.github.io/eligius/)