mount-observer 0.1.30 → 0.1.32

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
@@ -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 5 built-in handlers in their respective root nodes
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 5 built-in handlers:
734
- - `builtIns.mountObserverScript`
735
- - `builtIns.scriptExport`
736
- - `builtIns.HTMLInclude`
737
- - `builtIns.hoistTemplate`
738
- - `builtIns.emcScript`
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 5 built-in handlers in their shadow root
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
@@ -1,6 +1,7 @@
1
1
  import './ElementMountExtension.js';
2
2
  import { waitForEvent } from 'assign-gingerly/waitForEvent.js';
3
3
  import { AddedScriptElementEvent } from './Events.js';
4
+ import { registryItem as inferRegistryItem } from 'assign-gingerly/Infer.js';
4
5
  import 'mount-observer/handlers/MountObserverScript.js';
5
6
  import { mos } from 'mount-observer/handlers/MountObserverScript.js';
6
7
  import 'mount-observer/handlers/ScriptExport.js';
@@ -13,6 +14,8 @@ import { emc } from 'mount-observer/handlers/EMCScript.js';
13
14
  import 'mount-observer/handlers/EMCScript.js';
14
15
  import 'mount-observer/handlers/EMCParserScript.js';
15
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';
16
19
  /**
17
20
  * Track which root nodes have already had handlers activated.
18
21
  * Uses WeakSet to avoid memory leaks when nodes are garbage collected.
@@ -55,11 +58,16 @@ export class Synthesizer extends HTMLElement {
55
58
  * List of built-in handlers to activate.
56
59
  */
57
60
  static builtInHandlers = [
58
- mos, scriptExport, include, hoist, emcParser, emc
61
+ mos, scriptExport, include, hoist, genIds, emcParser, emc
59
62
  ];
60
63
  connectedCallback() {
61
64
  // Synthesizer elements are infrastructure, not UI
62
65
  this.hidden = true;
66
+ // Register the Infer enhancement in the appropriate registry
67
+ const registry = this.customElementRegistry || customElements;
68
+ if (registry.enhancementRegistry) {
69
+ registry.enhancementRegistry.push(inferRegistryItem);
70
+ }
63
71
  // Identify the root node
64
72
  const rootNode = this.getRootNode();
65
73
  // Determine if this is a syndicator or subscriber
package/Synthesizer.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import './ElementMountExtension.js';
2
2
  import { waitForEvent } from 'assign-gingerly/waitForEvent.js';
3
3
  import { AddedScriptElementEvent } from './Events.js';
4
+ import { registryItem as inferRegistryItem } from 'assign-gingerly/Infer.js';
4
5
 
5
6
  import 'mount-observer/handlers/MountObserverScript.js';
6
7
  import {mos} from 'mount-observer/handlers/MountObserverScript.js';
@@ -14,6 +15,8 @@ import {emc} from 'mount-observer/handlers/EMCScript.js';
14
15
  import 'mount-observer/handlers/EMCScript.js';
15
16
  import 'mount-observer/handlers/EMCParserScript.js';
16
17
  import {emcParser} from 'mount-observer/handlers/EMCParserScript.js';
18
+ import 'mount-observer/handlers/GenIds.js';
19
+ import {genIds} from 'mount-observer/handlers/GenIds.js';
17
20
 
18
21
  /**
19
22
  * Track which root nodes have already had handlers activated.
@@ -59,13 +62,19 @@ export abstract class Synthesizer extends HTMLElement {
59
62
  * List of built-in handlers to activate.
60
63
  */
61
64
  protected static builtInHandlers = [
62
- mos, scriptExport, include, hoist, emcParser, emc
65
+ mos, scriptExport, include, hoist, genIds, emcParser, emc
63
66
  ];
64
67
 
65
68
  connectedCallback(): void {
66
69
  // Synthesizer elements are infrastructure, not UI
67
70
  this.hidden = true;
68
71
 
72
+ // Register the Infer enhancement in the appropriate registry
73
+ const registry = (this as any).customElementRegistry || customElements;
74
+ if (registry.enhancementRegistry) {
75
+ registry.enhancementRegistry.push(inferRegistryItem);
76
+ }
77
+
69
78
  // Identify the root node
70
79
  const rootNode = this.getRootNode();
71
80
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "mount-observer",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "description": "Observe and act on css matches.",
5
5
  "main": "MountObserver.js",
6
6
  "module": "MountObserver.js",
7
7
  "dependencies": {
8
- "assign-gingerly": "0.0.28",
8
+ "assign-gingerly": "0.0.30",
9
9
  "id-generation": "0.0.4"
10
10
  },
11
11
  "devDependencies": {
@@ -0,0 +1,55 @@
1
+ import { StatementsResult } from "../nested-regex-groups/types";
2
+
3
+ export interface EndUserProps{
4
+ parsedStatements: StatementsResult<IncParameters>,
5
+ }
6
+
7
+ export interface AllProps extends EndUserProps{
8
+ enhancedElement: Element;
9
+ resolved: boolean;
10
+ }
11
+
12
+ export type AP = AllProps;
13
+
14
+ export type PAP = Partial<AP>;
15
+
16
+ export type ProPAP = Promise<PAP>
17
+
18
+ export interface Actions{
19
+ hydrate(self: AP & Actions): ProPAP;
20
+ handleEvent(self: AP, event: Event, incParameters: IncParameters): void;
21
+ init(self: AP, enhancedElement: Element, initVals: PAP): Promise<void>
22
+ }
23
+
24
+ export type asOptions =
25
+ | 'number'
26
+ | 'boolean'
27
+ | 'string'
28
+ | 'object'
29
+ | 'regexp'
30
+ | 'urlpattern'
31
+ | 'boolean|number'
32
+ ;
33
+
34
+ export type SubPropPath = string;
35
+ export type EventName = string;
36
+
37
+ export interface Specifier {
38
+ id?: string,
39
+ prop?: string,
40
+ path?: SubPropPath,
41
+ evtName?: EventName,
42
+ as?: asOptions,
43
+ constVal?: any;
44
+ enhKey?: string;
45
+ ish?: boolean;
46
+ host?: boolean;
47
+ }
48
+
49
+ export interface IncParameters {
50
+ prop: string,
51
+ byAmtS?: string,
52
+ byAmtN?: number,
53
+ targetElementId?: string,
54
+ localEventType?: string,
55
+ }
@@ -1,15 +1,17 @@
1
+ import { StatementsResult } from "../nested-regex-groups/types";
2
+
1
3
  export interface Specifier {
2
4
  selector?: string;
3
5
  prop?: string;
4
6
  }
5
7
 
6
8
  export interface EndUserProps{
7
- invokeParamSets: Array<InvokingParameters>,
9
+ invokeParamSet: StatementsResult<InvokingParameters>,
8
10
  }
9
11
 
10
12
  export interface AllProps extends EndUserProps{
11
13
  enhancedElement: Element;
12
- rawStatements: Array<string>,
14
+ resolved: boolean;
13
15
  }
14
16
 
15
17
  export type AP = AllProps;
@@ -20,9 +22,16 @@ export type ProPAP = Promise<PAP>
20
22
 
21
23
  export interface Actions{
22
24
  hydrate(self: AP): ProPAP;
25
+ init(self: AP, enhancedElement: Element, initVals: PAP): Promise<void>
23
26
  }
24
27
 
28
+
29
+
25
30
  export interface InvokingParameters {
26
- remoteSpecifier: Specifier,
27
- localEventType?: string,
31
+ targetSpecifier: {
32
+ hostOrPeerMethodName: string,
33
+ targetElementId?: string,
34
+ },
35
+ //defaults to "click" if not specified
36
+ localEventType: string,
28
37
  }
@@ -0,0 +1,26 @@
1
+ import { StatementsResult } from "../nested-regex-groups/types";
2
+
3
+ export interface EndUserProps{}
4
+
5
+ export interface AllProps extends EndUserProps{
6
+ enhancedElement: Element;
7
+ parsedStatements: StatementsResult<TogglingParameters>;
8
+ resolved?: boolean;
9
+ }
10
+
11
+ export type AP = AllProps;
12
+
13
+ export type PAP = Partial<AP>;
14
+
15
+ export type ProPAP = Promise<PAP>
16
+
17
+ export interface Actions{
18
+ init(self: AllProps, enhancedElement: Element, initVals: PAP): void;
19
+ hydrate(self: AP): ProPAP;
20
+ handleEvent(self: AP, e: Event, parsedStatement: TogglingParameters): void;
21
+ }
22
+
23
+ export interface TogglingParameters {
24
+ prop: string;
25
+ localEventType?: string;
26
+ }
@@ -54,6 +54,12 @@ export interface PatternConfig {
54
54
  name: string;
55
55
  pattern: string;
56
56
  description?: string;
57
+ /**
58
+ * Default values to merge into the parsed result
59
+ * Keys can use dot notation for nested values
60
+ * Example: { trigger: 'on', 'lhs.id': '#lhs' }
61
+ */
62
+ defaultVals?: Record<string, string>;
57
63
  }
58
64
 
59
65
  /**