mount-observer 0.1.30 → 0.1.31
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 +35 -8
- package/Synthesizer.js +3 -1
- package/Synthesizer.ts +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -682,7 +682,7 @@ The `Synthesizer` abstract base class enables automatic propagation of mount obs
|
|
|
682
682
|
|
|
683
683
|
1. **Syndicator** (in document root): Watches for `script[type="mountobserver"]` and `script[type="emc"]` elements and broadcasts them to subscribers
|
|
684
684
|
2. **Subscriber** (in shadow roots): Receives and clones script elements from the syndicator
|
|
685
|
-
3. **Automatic activation**: Both syndicator and subscriber activate
|
|
685
|
+
3. **Automatic activation**: Both syndicator and subscriber activate 7 built-in handlers in their respective root nodes
|
|
686
686
|
|
|
687
687
|
**Basic usage:**
|
|
688
688
|
|
|
@@ -730,12 +730,31 @@ The `Synthesizer` abstract base class enables automatic propagation of mount obs
|
|
|
730
730
|
|
|
731
731
|
**What happens:**
|
|
732
732
|
|
|
733
|
-
1. The syndicator (`<app-synthesizer>` in document root) activates
|
|
734
|
-
- `builtIns.mountObserverScript`
|
|
735
|
-
- `builtIns.scriptExport`
|
|
736
|
-
- `builtIns.HTMLInclude`
|
|
737
|
-
- `builtIns.hoistTemplate`
|
|
738
|
-
- `builtIns.
|
|
733
|
+
1. The syndicator (`<app-synthesizer>` in document root) activates 7 built-in handlers:
|
|
734
|
+
- `builtIns.mountObserverScript` - Process MOSE scripts
|
|
735
|
+
- `builtIns.scriptExport` - Expose module exports from script elements
|
|
736
|
+
- `builtIns.HTMLInclude` - Enable intra-document HTML includes
|
|
737
|
+
- `builtIns.hoistTemplate` - Optimize template usage
|
|
738
|
+
- `builtIns.generateIds` - Auto-generate unique IDs
|
|
739
|
+
- `builtIns.emcParserScript` - Load parsers for EMC scripts
|
|
740
|
+
- `builtIns.emcScript` - Process EMC scripts
|
|
741
|
+
|
|
742
|
+
<details>
|
|
743
|
+
<summary>Why these handlers?</summary>
|
|
744
|
+
|
|
745
|
+
These handlers form the core infrastructure for declarative progressive enhancement:
|
|
746
|
+
|
|
747
|
+
- **mountObserverScript**: Enables fully declarative mount observer configuration via `<script type="mountobserver">` elements
|
|
748
|
+
- **scriptExport**: Makes ES module exports accessible from script elements, enabling configuration sharing
|
|
749
|
+
- **HTMLInclude**: Allows template reuse and inheritance patterns with `<template src="#id">`
|
|
750
|
+
- **hoistTemplate**: Optimizes memory usage by centralizing template content
|
|
751
|
+
- **generateIds**: Automates ID generation for forms and accessibility features
|
|
752
|
+
- **emcParserScript**: Enables lazy-loading of complex parsers for enhancement attributes
|
|
753
|
+
- **emcScript**: Processes enhancement configurations for progressive enhancement
|
|
754
|
+
|
|
755
|
+
Together, these handlers enable a complete HTML-first development workflow where behaviors, enhancements, and configurations can be declared in HTML and automatically propagated across shadow DOM boundaries.
|
|
756
|
+
|
|
757
|
+
</details>
|
|
739
758
|
|
|
740
759
|
2. The syndicator watches for script elements being added to its light children
|
|
741
760
|
|
|
@@ -749,7 +768,7 @@ The `Synthesizer` abstract base class enables automatic propagation of mount obs
|
|
|
749
768
|
- Subscribe to `addedscriptelement` events for new scripts
|
|
750
769
|
- Clone each script element and copy its `export` property
|
|
751
770
|
- Append cloned scripts to their own light children
|
|
752
|
-
- Activate the same
|
|
771
|
+
- Activate the same 7 built-in handlers in their shadow root
|
|
753
772
|
|
|
754
773
|
**Syndicator vs Subscriber:**
|
|
755
774
|
|
|
@@ -775,6 +794,12 @@ await this.getRootNode().mount({
|
|
|
775
794
|
await this.getRootNode().mount({
|
|
776
795
|
do: 'builtIns.hoistTemplate'
|
|
777
796
|
});
|
|
797
|
+
await this.getRootNode().mount({
|
|
798
|
+
do: 'builtIns.generateIds'
|
|
799
|
+
});
|
|
800
|
+
await this.getRootNode().mount({
|
|
801
|
+
do: 'builtIns.emcParserScript'
|
|
802
|
+
});
|
|
778
803
|
await this.getRootNode().mount({
|
|
779
804
|
do: 'builtIns.emcScript'
|
|
780
805
|
});
|
|
@@ -785,6 +810,8 @@ This ensures that:
|
|
|
785
810
|
- Script exports are available
|
|
786
811
|
- HTML includes work within each shadow root
|
|
787
812
|
- Templates are hoisted for performance
|
|
813
|
+
- IDs are auto-generated in forms and components
|
|
814
|
+
- Parsers are loaded for EMC scripts
|
|
788
815
|
- EMC scripts enhance elements in each scope
|
|
789
816
|
|
|
790
817
|
**Script processing:**
|
package/Synthesizer.js
CHANGED
|
@@ -13,6 +13,8 @@ import { emc } from 'mount-observer/handlers/EMCScript.js';
|
|
|
13
13
|
import 'mount-observer/handlers/EMCScript.js';
|
|
14
14
|
import 'mount-observer/handlers/EMCParserScript.js';
|
|
15
15
|
import { emcParser } from 'mount-observer/handlers/EMCParserScript.js';
|
|
16
|
+
import 'mount-observer/handlers/GenIds.js';
|
|
17
|
+
import { genIds } from 'mount-observer/handlers/GenIds.js';
|
|
16
18
|
/**
|
|
17
19
|
* Track which root nodes have already had handlers activated.
|
|
18
20
|
* Uses WeakSet to avoid memory leaks when nodes are garbage collected.
|
|
@@ -55,7 +57,7 @@ export class Synthesizer extends HTMLElement {
|
|
|
55
57
|
* List of built-in handlers to activate.
|
|
56
58
|
*/
|
|
57
59
|
static builtInHandlers = [
|
|
58
|
-
mos, scriptExport, include, hoist, emcParser, emc
|
|
60
|
+
mos, scriptExport, include, hoist, genIds, emcParser, emc
|
|
59
61
|
];
|
|
60
62
|
connectedCallback() {
|
|
61
63
|
// Synthesizer elements are infrastructure, not UI
|
package/Synthesizer.ts
CHANGED
|
@@ -14,6 +14,8 @@ import {emc} from 'mount-observer/handlers/EMCScript.js';
|
|
|
14
14
|
import 'mount-observer/handlers/EMCScript.js';
|
|
15
15
|
import 'mount-observer/handlers/EMCParserScript.js';
|
|
16
16
|
import {emcParser} from 'mount-observer/handlers/EMCParserScript.js';
|
|
17
|
+
import 'mount-observer/handlers/GenIds.js';
|
|
18
|
+
import {genIds} from 'mount-observer/handlers/GenIds.js';
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Track which root nodes have already had handlers activated.
|
|
@@ -59,7 +61,7 @@ export abstract class Synthesizer extends HTMLElement {
|
|
|
59
61
|
* List of built-in handlers to activate.
|
|
60
62
|
*/
|
|
61
63
|
protected static builtInHandlers = [
|
|
62
|
-
mos, scriptExport, include, hoist, emcParser, emc
|
|
64
|
+
mos, scriptExport, include, hoist, genIds, emcParser, emc
|
|
63
65
|
];
|
|
64
66
|
|
|
65
67
|
connectedCallback(): void {
|