mount-observer 0.1.14 → 0.1.16

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.
Files changed (40) hide show
  1. package/ElementMountExtension.js +5 -2
  2. package/ElementMountExtension.ts +7 -2
  3. package/MountObserver.js +3 -0
  4. package/MountObserver.ts +3 -0
  5. package/RegistryMountCoordinator.js +5 -5
  6. package/RegistryMountCoordinator.ts +8 -6
  7. package/{DefineCustomElementHandler.js → handlers/DefineCustomElement.js} +103 -99
  8. package/handlers/DefineCustomElement.ts +123 -0
  9. package/{EnhanceMountedElementHandler.js → handlers/EnhanceMountedElement.js} +109 -96
  10. package/handlers/EnhanceMountedElement.ts +126 -0
  11. package/handlers/Events.js +110 -0
  12. package/handlers/EvtRt.js +59 -0
  13. package/handlers/GenIds.js +37 -0
  14. package/handlers/GenIds.ts +45 -0
  15. package/handlers/HTMLInclude.js +393 -0
  16. package/handlers/HTMLInclude.ts +453 -0
  17. package/handlers/HoistTemplate.js +77 -0
  18. package/handlers/HoistTemplate.ts +89 -0
  19. package/handlers/MountObserver.js +941 -0
  20. package/handlers/MountObserverScript.js +78 -0
  21. package/handlers/MountObserverScript.ts +89 -0
  22. package/handlers/ScriptExport.js +83 -0
  23. package/handlers/ScriptExport.ts +97 -0
  24. package/handlers/SharedMutationObserver.js +78 -0
  25. package/handlers/arr.js +16 -0
  26. package/handlers/connectionMonitor.js +122 -0
  27. package/handlers/elementIntersection.js +73 -0
  28. package/handlers/emitEvents.js +187 -0
  29. package/handlers/getRegistryRoot.js +52 -0
  30. package/handlers/loadImports.js +129 -0
  31. package/handlers/mediaQuery.js +90 -0
  32. package/handlers/rootSizeObserver.js +131 -0
  33. package/handlers/upShadowSearch.js +70 -0
  34. package/handlers/withScopePerimeter.js +22 -0
  35. package/package.json +12 -2
  36. package/types/assign-gingerly/types.d.ts +244 -0
  37. package/types/be-a-beacon/types.d.ts +3 -0
  38. package/types/global.d.ts +29 -0
  39. package/types/id-generation/types.d.ts +26 -0
  40. package/types/mount-observer/types.d.ts +332 -0
@@ -1,96 +1,109 @@
1
- import { EvtRt } from './EvtRt.js';
2
- //import { buildCSSQuery } from 'assign-gingerly/buildCSSQuery.js';
3
- import 'assign-gingerly/object-extension.js';
4
- /**
5
- * Handler for automatically enhancing mounted elements using assign-gingerly.
6
- * Searches the first imported module for an export with a "spawn" property
7
- * and uses element.enh.get() to spawn the enhancement.
8
- */
9
- export class EnhanceMountedElementHandler extends EvtRt {
10
- async mount(mountedElement, MountConfig, context) {
11
- this.abort();
12
- // Check if modules are specified
13
- if (!context.modules || context.modules.length === 0) {
14
- throw new Error('Must specify an ES Module with import property');
15
- }
16
- const module = context.modules[0];
17
- // Find registry item (object with spawn property)
18
- const registryItem = await this._findRegistryItem(module, mountedElement);
19
- if (!registryItem) {
20
- throw new Error('No registry item found in module. Expected an export with a "spawn" property.');
21
- }
22
- // Validate spawn is a constructor
23
- if (typeof registryItem.spawn !== 'function') {
24
- throw new Error('Registry item "spawn" property must be a constructor function');
25
- }
26
- // Spawn the enhancement
27
- this.#spawnEnhancement(mountedElement, registryItem, context);
28
- }
29
- /**
30
- * Spawn the enhancement using element.enh.get().
31
- * Polyfills customElementRegistry if needed for browsers without scoped registry support.
32
- */
33
- #spawnEnhancement(element, registryItem, context) {
34
- // Polyfill element.customElementRegistry if it doesn't exist (for browsers without scoped registries)
35
- if (!element.customElementRegistry) {
36
- Object.defineProperty(element, 'customElementRegistry', {
37
- value: customElements,
38
- writable: true,
39
- enumerable: false,
40
- configurable: true
41
- });
42
- }
43
- // Use element.enh.get() to spawn the enhancement
44
- const enh = element.enh;
45
- if (!enh || typeof enh.get !== 'function') {
46
- throw new Error('Element does not have enh.get() method. Make sure assign-gingerly/object-extension.js is loaded.');
47
- }
48
- enh.get(registryItem, context);
49
- }
50
- /**
51
- * Find a registry item in the module exports.
52
- * A registry item is an object with a "spawn" property.
53
- * @param module - The imported module
54
- * @returns The registry item or null if not found
55
- */
56
- async _findRegistryItem(module, el) {
57
- // Check default export first
58
- if (module.default && await this._isRegistryItem(module.default, el)) {
59
- return module.default;
60
- }
61
- // Search all exports for a registry item
62
- const exports = Object.values(module);
63
- const registryItems = [];
64
- for (const e of exports) {
65
- const isRegistryItem = await this._isRegistryItem(e, el);
66
- if (isRegistryItem)
67
- registryItems.push(e);
68
- }
69
- if (registryItems.length === 0) {
70
- return null;
71
- }
72
- if (registryItems.length > 1) {
73
- throw new Error('More than one registry item found in module. Expected exactly one export with a "spawn" property.');
74
- }
75
- return registryItems[0];
76
- }
77
- /**
78
- * Check if an export is a registry item (has a spawn property).
79
- * @param exp - The export to check
80
- * @returns True if the export is a registry item
81
- */
82
- async _isRegistryItem(exp, mountedElement) {
83
- let test = exp !== null
84
- && typeof exp === 'object'
85
- && 'spawn' in exp
86
- && typeof exp.spawn === 'function';
87
- if (!test)
88
- return false;
89
- const emc = exp;
90
- if (emc.withAttrs !== undefined) {
91
- const cssQuery = (await import('assign-gingerly/buildCSSQuery.js')).buildCSSQuery(emc);
92
- return mountedElement.matches(cssQuery);
93
- }
94
- return true;
95
- }
96
- }
1
+ import { EvtRt } from '../EvtRt.js';
2
+ //import { buildCSSQuery } from 'assign-gingerly/buildCSSQuery.js';
3
+ import 'assign-gingerly/object-extension.js';
4
+ /**
5
+ * Handler for automatically enhancing mounted elements using assign-gingerly.
6
+ * Searches the first imported module for an export with a "spawn" property
7
+ * and uses element.enh.get() to spawn the enhancement.
8
+ */
9
+ export class EnhanceMountedElementHandler extends EvtRt {
10
+ async mount(mountedElement, MountConfig, context) {
11
+ this.abort();
12
+ // Check if modules are specified
13
+ if (!context.modules || context.modules.length === 0) {
14
+ throw new Error('Must specify an ES Module with import property');
15
+ }
16
+ const module = context.modules[0];
17
+ // Find registry item (object with spawn property)
18
+ const registryItem = await this._findRegistryItem(module, mountedElement);
19
+ if (!registryItem) {
20
+ throw new Error('No registry item found in module. Expected an export with a "spawn" property.');
21
+ }
22
+ // Validate spawn is a constructor
23
+ if (typeof registryItem.spawn !== 'function') {
24
+ throw new Error('Registry item "spawn" property must be a constructor function');
25
+ }
26
+ const tbd = context?.observer?.options?.mose;
27
+ if (tbd) {
28
+ const se = tbd.deref();
29
+ const { parentElement } = se;
30
+ const { enhKey } = registryItem;
31
+ if (!se.id && enhKey) {
32
+ se.id = `${parentElement?.localName}.${enhKey}`;
33
+ }
34
+ }
35
+ console.log({ tbd });
36
+ // Spawn the enhancement
37
+ this.#spawnEnhancement(mountedElement, registryItem, context);
38
+ }
39
+ /**
40
+ * Spawn the enhancement using element.enh.get().
41
+ * Polyfills customElementRegistry if needed for browsers without scoped registry support.
42
+ */
43
+ #spawnEnhancement(element, registryItem, context) {
44
+ // Polyfill element.customElementRegistry if it doesn't exist (for browsers without scoped registries)
45
+ if (!element.customElementRegistry) {
46
+ Object.defineProperty(element, 'customElementRegistry', {
47
+ value: customElements,
48
+ writable: true,
49
+ enumerable: false,
50
+ configurable: true
51
+ });
52
+ }
53
+ // Use element.enh.get() to spawn the enhancement
54
+ const enh = element.enh;
55
+ if (!enh || typeof enh.get !== 'function') {
56
+ throw new Error('Element does not have enh.get() method. Make sure assign-gingerly/object-extension.js is loaded.');
57
+ }
58
+ enh.get(registryItem, context);
59
+ }
60
+ /**
61
+ * Find a registry item in the module exports.
62
+ * A registry item is an object with a "spawn" property.
63
+ * @param module - The imported module
64
+ * @returns The registry item or null if not found
65
+ */
66
+ async _findRegistryItem(module, el) {
67
+ // Check default export first
68
+ if (module.default && await this._isRegistryItem(module.default, el)) {
69
+ return module.default;
70
+ }
71
+ // Search all exports for a registry item
72
+ const exports = Object.values(module);
73
+ const registryItems = [];
74
+ for (const e of exports) {
75
+ const isRegistryItem = await this._isRegistryItem(e, el);
76
+ if (isRegistryItem)
77
+ registryItems.push(e);
78
+ }
79
+ if (registryItems.length === 0) {
80
+ return null;
81
+ }
82
+ if (registryItems.length > 1) {
83
+ throw new Error('More than one registry item found in module. Expected exactly one export with a "spawn" property.');
84
+ }
85
+ return registryItems[0];
86
+ }
87
+ /**
88
+ * Check if an export is a registry item (has a spawn property).
89
+ * @param exp - The export to check
90
+ * @returns True if the export is a registry item
91
+ */
92
+ async _isRegistryItem(exp, mountedElement) {
93
+ let test = exp !== null
94
+ && typeof exp === 'object'
95
+ && 'spawn' in exp
96
+ && typeof exp.spawn === 'function';
97
+ if (!test)
98
+ return false;
99
+ const emc = exp;
100
+ if (emc.withAttrs !== undefined) {
101
+ const cssQuery = (await import('assign-gingerly/buildCSSQuery.js')).buildCSSQuery(emc);
102
+ return mountedElement.matches(cssQuery);
103
+ }
104
+ return true;
105
+ }
106
+ }
107
+ // Register built-in handler
108
+ import { MountObserver } from '../MountObserver.js';
109
+ MountObserver.define('builtIns.enhanceMountedElement', EnhanceMountedElementHandler);
@@ -0,0 +1,126 @@
1
+ import { EvtRt } from '../EvtRt.js';
2
+ import {EnhancementConfig} from '../types/assign-gingerly/types.js';
3
+ import { MountConfig, MountContext } from '../types/mount-observer/types.js';
4
+ //import { buildCSSQuery } from 'assign-gingerly/buildCSSQuery.js';
5
+ import 'assign-gingerly/object-extension.js';
6
+
7
+ /**
8
+ * Handler for automatically enhancing mounted elements using assign-gingerly.
9
+ * Searches the first imported module for an export with a "spawn" property
10
+ * and uses element.enh.get() to spawn the enhancement.
11
+ */
12
+ export class EnhanceMountedElementHandler extends EvtRt {
13
+ async mount(mountedElement: Element, MountConfig: MountConfig, context: MountContext){
14
+ this.abort();
15
+ // Check if modules are specified
16
+ if (!context.modules || context.modules.length === 0) {
17
+ throw new Error('Must specify an ES Module with import property');
18
+ }
19
+
20
+ const module = context.modules[0];
21
+
22
+ // Find registry item (object with spawn property)
23
+ const registryItem = await this._findRegistryItem(module, mountedElement);
24
+
25
+ if (!registryItem) {
26
+ throw new Error('No registry item found in module. Expected an export with a "spawn" property.');
27
+ }
28
+
29
+ // Validate spawn is a constructor
30
+ if (typeof registryItem.spawn !== 'function') {
31
+ throw new Error('Registry item "spawn" property must be a constructor function');
32
+ }
33
+ const tbd = context?.observer?.options?.mose;
34
+ if(tbd){
35
+ const se = tbd.deref() as HTMLScriptElement;
36
+ const {parentElement} = se;
37
+ const {enhKey} = registryItem;
38
+ if(!se.id && enhKey){
39
+ se.id = `${parentElement?.localName}.${ enhKey}`;
40
+ }
41
+ }
42
+ console.log({ tbd });
43
+
44
+ // Spawn the enhancement
45
+ this.#spawnEnhancement(mountedElement, registryItem, context);
46
+ }
47
+
48
+ /**
49
+ * Spawn the enhancement using element.enh.get().
50
+ * Polyfills customElementRegistry if needed for browsers without scoped registry support.
51
+ */
52
+ #spawnEnhancement(element: Element, registryItem: any, context: MountContext): void {
53
+ // Polyfill element.customElementRegistry if it doesn't exist (for browsers without scoped registries)
54
+ if (!(element as any).customElementRegistry) {
55
+ Object.defineProperty(element, 'customElementRegistry', {
56
+ value: customElements,
57
+ writable: true,
58
+ enumerable: false,
59
+ configurable: true
60
+ });
61
+ }
62
+
63
+ // Use element.enh.get() to spawn the enhancement
64
+ const enh = (element as any).enh;
65
+ if (!enh || typeof enh.get !== 'function') {
66
+ throw new Error('Element does not have enh.get() method. Make sure assign-gingerly/object-extension.js is loaded.');
67
+ }
68
+
69
+ enh.get(registryItem, context);
70
+ }
71
+
72
+ /**
73
+ * Find a registry item in the module exports.
74
+ * A registry item is an object with a "spawn" property.
75
+ * @param module - The imported module
76
+ * @returns The registry item or null if not found
77
+ */
78
+ protected async _findRegistryItem(module: any, el: Element): Promise<any | null> {
79
+ // Check default export first
80
+ if (module.default && await this._isRegistryItem(module.default, el)) {
81
+ return module.default;
82
+ }
83
+
84
+ // Search all exports for a registry item
85
+ const exports = Object.values(module);
86
+ const registryItems = [];
87
+ for(const e of exports){
88
+ const isRegistryItem = await this._isRegistryItem(e, el);
89
+ if(isRegistryItem) registryItems.push(e);
90
+ }
91
+
92
+ if (registryItems.length === 0) {
93
+ return null;
94
+ }
95
+
96
+ if (registryItems.length > 1) {
97
+ throw new Error('More than one registry item found in module. Expected exactly one export with a "spawn" property.');
98
+ }
99
+
100
+ return registryItems[0];
101
+ }
102
+
103
+ /**
104
+ * Check if an export is a registry item (has a spawn property).
105
+ * @param exp - The export to check
106
+ * @returns True if the export is a registry item
107
+ */
108
+ protected async _isRegistryItem(exp: any, mountedElement: Element): Promise<boolean> {
109
+ let test = exp !== null
110
+ && typeof exp === 'object'
111
+ && 'spawn' in exp
112
+ && typeof exp.spawn === 'function';
113
+ if(!test) return false;
114
+ const emc = exp as EnhancementConfig;
115
+ if(emc.withAttrs !== undefined){
116
+ const cssQuery = (await import('assign-gingerly/buildCSSQuery.js')).buildCSSQuery(emc);
117
+ return mountedElement.matches(cssQuery);
118
+ }
119
+ return true;
120
+ }
121
+ }
122
+
123
+ // Register built-in handler
124
+ import { MountObserver } from '../MountObserver.js';
125
+
126
+ MountObserver.define('builtIns.enhanceMountedElement', EnhanceMountedElementHandler);
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.ResolvedEvent = exports.MediaUnmatchEvent = exports.MediaMatchEvent = exports.LoadEvent = exports.DisconnectEvent = exports.DismountEvent = exports.MountEvent = exports.resolvedEventName = exports.mediaunmatchEventName = exports.mediamatchEventName = exports.disconnectEventName = exports.dismountEventName = exports.mountEventName = exports.loadEventName = void 0;
19
+ // Event name constants
20
+ exports.loadEventName = 'load';
21
+ exports.mountEventName = 'mount';
22
+ exports.dismountEventName = 'dismount';
23
+ exports.disconnectEventName = 'disconnect';
24
+ exports.mediamatchEventName = 'mediamatch';
25
+ exports.mediaunmatchEventName = 'mediaunmatch';
26
+ exports.resolvedEventName = 'resolved';
27
+ var MountEvent = /** @class */ (function (_super) {
28
+ __extends(MountEvent, _super);
29
+ function MountEvent(mountedElement, modules, mountConfig, mountContext) {
30
+ var _this = _super.call(this, MountEvent.eventName) || this;
31
+ _this.mountedElement = mountedElement;
32
+ _this.modules = modules;
33
+ _this.mountConfig = mountConfig;
34
+ _this.mountContext = mountContext;
35
+ return _this;
36
+ }
37
+ MountEvent.eventName = exports.mountEventName;
38
+ return MountEvent;
39
+ }(Event));
40
+ exports.MountEvent = MountEvent;
41
+ var DismountEvent = /** @class */ (function (_super) {
42
+ __extends(DismountEvent, _super);
43
+ function DismountEvent(mountedElement, reason, mountConfig) {
44
+ var _this = _super.call(this, DismountEvent.eventName) || this;
45
+ _this.mountedElement = mountedElement;
46
+ _this.reason = reason;
47
+ _this.mountConfig = mountConfig;
48
+ return _this;
49
+ }
50
+ DismountEvent.eventName = exports.dismountEventName;
51
+ return DismountEvent;
52
+ }(Event));
53
+ exports.DismountEvent = DismountEvent;
54
+ var DisconnectEvent = /** @class */ (function (_super) {
55
+ __extends(DisconnectEvent, _super);
56
+ function DisconnectEvent(mountedElement, mountConfig) {
57
+ var _this = _super.call(this, DisconnectEvent.eventName) || this;
58
+ _this.mountedElement = mountedElement;
59
+ _this.mountConfig = mountConfig;
60
+ return _this;
61
+ }
62
+ DisconnectEvent.eventName = exports.disconnectEventName;
63
+ return DisconnectEvent;
64
+ }(Event));
65
+ exports.DisconnectEvent = DisconnectEvent;
66
+ var LoadEvent = /** @class */ (function (_super) {
67
+ __extends(LoadEvent, _super);
68
+ function LoadEvent(modules, mountConfig) {
69
+ var _this = _super.call(this, LoadEvent.eventName) || this;
70
+ _this.modules = modules;
71
+ _this.mountConfig = mountConfig;
72
+ return _this;
73
+ }
74
+ LoadEvent.eventName = exports.loadEventName;
75
+ return LoadEvent;
76
+ }(Event));
77
+ exports.LoadEvent = LoadEvent;
78
+ var MediaMatchEvent = /** @class */ (function (_super) {
79
+ __extends(MediaMatchEvent, _super);
80
+ function MediaMatchEvent(mountConfig) {
81
+ var _this = _super.call(this, MediaMatchEvent.eventName) || this;
82
+ _this.mountConfig = mountConfig;
83
+ return _this;
84
+ }
85
+ MediaMatchEvent.eventName = exports.mediamatchEventName;
86
+ return MediaMatchEvent;
87
+ }(Event));
88
+ exports.MediaMatchEvent = MediaMatchEvent;
89
+ var MediaUnmatchEvent = /** @class */ (function (_super) {
90
+ __extends(MediaUnmatchEvent, _super);
91
+ function MediaUnmatchEvent(mountConfig) {
92
+ var _this = _super.call(this, MediaUnmatchEvent.eventName) || this;
93
+ _this.mountConfig = mountConfig;
94
+ return _this;
95
+ }
96
+ MediaUnmatchEvent.eventName = exports.mediaunmatchEventName;
97
+ return MediaUnmatchEvent;
98
+ }(Event));
99
+ exports.MediaUnmatchEvent = MediaUnmatchEvent;
100
+ var ResolvedEvent = /** @class */ (function (_super) {
101
+ __extends(ResolvedEvent, _super);
102
+ function ResolvedEvent(exportValue) {
103
+ var _this = _super.call(this, ResolvedEvent.eventName) || this;
104
+ _this.export = exportValue;
105
+ return _this;
106
+ }
107
+ ResolvedEvent.eventName = exports.resolvedEventName;
108
+ return ResolvedEvent;
109
+ }(Event));
110
+ exports.ResolvedEvent = ResolvedEvent;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _EvtRt_ac;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.EvtRt = void 0;
16
+ var Events_js_1 = require("./Events.js");
17
+ var MountObserver_js_1 = require("./MountObserver.js");
18
+ var EvtRt = /** @class */ (function () {
19
+ function EvtRt(mountedElement, ctx) {
20
+ _EvtRt_ac.set(this, void 0);
21
+ var observer = ctx.observer, mountConfig = ctx.mountConfig;
22
+ __classPrivateFieldSet(this, _EvtRt_ac, new AbortController(), "f");
23
+ var et = observer.getNotifier(mountedElement);
24
+ et.addEventListener(Events_js_1.mountEventName, this, { signal: __classPrivateFieldGet(this, _EvtRt_ac, "f").signal });
25
+ et.addEventListener(Events_js_1.disconnectEventName, this, { signal: __classPrivateFieldGet(this, _EvtRt_ac, "f").signal });
26
+ et.addEventListener(Events_js_1.dismountEventName, this, { signal: __classPrivateFieldGet(this, _EvtRt_ac, "f").signal });
27
+ this.mount(mountedElement, mountConfig, ctx);
28
+ }
29
+ EvtRt.prototype.abort = function () {
30
+ __classPrivateFieldGet(this, _EvtRt_ac, "f").abort();
31
+ };
32
+ EvtRt.prototype.mount = function (mountedElement, mountConfig, context) {
33
+ console.log({ mountedElement: mountedElement, mountConfig: mountConfig, context: context });
34
+ };
35
+ EvtRt.prototype.disconnect = function (mountedElement, mountConfig) {
36
+ console.log({ mountedElement: mountedElement, mountConfig: mountConfig });
37
+ };
38
+ EvtRt.prototype.dismount = function (mountedElement, mountConfig) {
39
+ console.log({ mountedElement: mountedElement, mountConfig: mountConfig });
40
+ };
41
+ EvtRt.prototype.handleEvent = function (evt) {
42
+ if (evt instanceof Events_js_1.MountEvent) {
43
+ var mountedElement = evt.mountedElement, mountContext = evt.mountContext, mountConfig = evt.mountConfig;
44
+ this.mount(mountedElement, mountConfig, mountContext);
45
+ }
46
+ else if (evt instanceof Events_js_1.DismountEvent) {
47
+ var mountedElement = evt.mountedElement, mountConfig = evt.mountConfig;
48
+ this.dismount(mountedElement, mountConfig);
49
+ }
50
+ else if (evt instanceof Events_js_1.DisconnectEvent) {
51
+ var mountedElement = evt.mountedElement, mountConfig = evt.mountConfig;
52
+ this.disconnect(mountedElement, mountConfig);
53
+ }
54
+ };
55
+ return EvtRt;
56
+ }());
57
+ exports.EvtRt = EvtRt;
58
+ _EvtRt_ac = new WeakMap();
59
+ MountObserver_js_1.MountObserver.define('builtIns.logToConsole', EvtRt);
@@ -0,0 +1,37 @@
1
+ import { EvtRt } from '../EvtRt.js';
2
+ /**
3
+ * Handler for automatically generating IDs when elements with -id attribute are mounted.
4
+ * This handler integrates with the id-generation package to provide automatic ID generation
5
+ * for elements within scoped containers (fieldset, [itemscope], or root).
6
+ *
7
+ * Usage:
8
+ * ```javascript
9
+ * document.mount({
10
+ * do: 'builtIns.generateIds'
11
+ * });
12
+ * ```
13
+ *
14
+ * The handler will automatically:
15
+ * 1. Watch for elements with the -id attribute
16
+ * 2. Call genIds from id-generation package
17
+ * 3. Generate IDs for elements with data-id, #, @, or | attributes
18
+ * 4. Replace #{{name}} references with generated IDs
19
+ * 5. Remove -id and defer-* attributes after processing
20
+ */
21
+ export class GenerateIdsHandler extends EvtRt {
22
+ // Static properties to define matching criteria
23
+ static matching = '[-id]';
24
+ static whereInstanceOf = Element;
25
+ async mount(mountedElement, mountConfig, context) {
26
+ this.abort();
27
+ // Dynamically import processScope from id-generation
28
+ const { genIds } = await import('id-generation/genIds.js');
29
+ // Get the root node for fallback container
30
+ const rootNode = context.rootNode || document;
31
+ // Process the scope starting from this trigger element
32
+ genIds(mountedElement, rootNode);
33
+ }
34
+ }
35
+ // Register built-in handler
36
+ import { MountObserver } from '../MountObserver.js';
37
+ MountObserver.define('builtIns.generateIds', GenerateIdsHandler);
@@ -0,0 +1,45 @@
1
+ import { EvtRt } from '../EvtRt.js';
2
+ import { MountConfig, MountContext } from '../types/mount-observer/types.js';
3
+
4
+ /**
5
+ * Handler for automatically generating IDs when elements with -id attribute are mounted.
6
+ * This handler integrates with the id-generation package to provide automatic ID generation
7
+ * for elements within scoped containers (fieldset, [itemscope], or root).
8
+ *
9
+ * Usage:
10
+ * ```javascript
11
+ * document.mount({
12
+ * do: 'builtIns.generateIds'
13
+ * });
14
+ * ```
15
+ *
16
+ * The handler will automatically:
17
+ * 1. Watch for elements with the -id attribute
18
+ * 2. Call genIds from id-generation package
19
+ * 3. Generate IDs for elements with data-id, #, @, or | attributes
20
+ * 4. Replace #{{name}} references with generated IDs
21
+ * 5. Remove -id and defer-* attributes after processing
22
+ */
23
+ export class GenerateIdsHandler extends EvtRt {
24
+ // Static properties to define matching criteria
25
+ static matching = '[-id]';
26
+ static whereInstanceOf = Element;
27
+
28
+ async mount(mountedElement: Element, mountConfig: MountConfig, context: MountContext) {
29
+ this.abort();
30
+
31
+ // Dynamically import processScope from id-generation
32
+ const { genIds } = await import('id-generation/genIds.js');
33
+
34
+ // Get the root node for fallback container
35
+ const rootNode = context.rootNode || document;
36
+
37
+ // Process the scope starting from this trigger element
38
+ genIds(mountedElement, rootNode);
39
+ }
40
+ }
41
+
42
+ // Register built-in handler
43
+ import { MountObserver } from '../MountObserver.js';
44
+
45
+ MountObserver.define('builtIns.generateIds', GenerateIdsHandler);