mount-observer 0.1.16 → 0.1.18

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.
@@ -23,16 +23,15 @@ export class EnhanceMountedElementHandler extends EvtRt {
23
23
  if (typeof registryItem.spawn !== 'function') {
24
24
  throw new Error('Registry item "spawn" property must be a constructor function');
25
25
  }
26
- const tbd = context?.observer?.options?.mose;
27
- if (tbd) {
28
- const se = tbd.deref();
26
+ const mose = context?.observer?.options?.mose;
27
+ if (mose) {
28
+ const se = mose.deref();
29
29
  const { parentElement } = se;
30
30
  const { enhKey } = registryItem;
31
31
  if (!se.id && enhKey) {
32
32
  se.id = `${parentElement?.localName}.${enhKey}`;
33
33
  }
34
34
  }
35
- console.log({ tbd });
36
35
  // Spawn the enhancement
37
36
  this.#spawnEnhancement(mountedElement, registryItem, context);
38
37
  }
@@ -30,16 +30,15 @@ export class EnhanceMountedElementHandler extends EvtRt {
30
30
  if (typeof registryItem.spawn !== 'function') {
31
31
  throw new Error('Registry item "spawn" property must be a constructor function');
32
32
  }
33
- const tbd = context?.observer?.options?.mose;
34
- if(tbd){
35
- const se = tbd.deref() as HTMLScriptElement;
33
+ const mose = context?.observer?.options?.mose;
34
+ if(mose){
35
+ const se = mose.deref() as HTMLScriptElement;
36
36
  const {parentElement} = se;
37
37
  const {enhKey} = registryItem;
38
38
  if(!se.id && enhKey){
39
39
  se.id = `${parentElement?.localName}.${ enhKey}`;
40
40
  }
41
41
  }
42
- console.log({ tbd });
43
42
 
44
43
  // Spawn the enhancement
45
44
  this.#spawnEnhancement(mountedElement, registryItem, context);
@@ -34,4 +34,5 @@ export class GenerateIdsHandler extends EvtRt {
34
34
  }
35
35
  // Register built-in handler
36
36
  import { MountObserver } from '../MountObserver.js';
37
- MountObserver.define('builtIns.generateIds', GenerateIdsHandler);
37
+ export const genIds = 'builtIns.generateIds';
38
+ MountObserver.define(genIds, GenerateIdsHandler);
@@ -42,4 +42,5 @@ export class GenerateIdsHandler extends EvtRt {
42
42
  // Register built-in handler
43
43
  import { MountObserver } from '../MountObserver.js';
44
44
 
45
- MountObserver.define('builtIns.generateIds', GenerateIdsHandler);
45
+ export const genIds = 'builtIns.generateIds';
46
+ MountObserver.define(genIds, GenerateIdsHandler);
@@ -390,4 +390,5 @@ export class HTMLIncludeHandler extends EvtRt {
390
390
  }
391
391
  // Register the handler
392
392
  import { MountObserver } from '../MountObserver.js';
393
- MountObserver.define('builtIns.HTMLInclude', HTMLIncludeHandler);
393
+ export const include = 'builtIns.HTMLInclude';
394
+ MountObserver.define(include, HTMLIncludeHandler);
@@ -450,4 +450,6 @@ export class HTMLIncludeHandler extends EvtRt {
450
450
  // Register the handler
451
451
  import { MountObserver } from '../MountObserver.js';
452
452
 
453
- MountObserver.define('builtIns.HTMLInclude', HTMLIncludeHandler);
453
+ export const include = 'builtIns.HTMLInclude';
454
+
455
+ MountObserver.define(include, HTMLIncludeHandler);
@@ -74,4 +74,5 @@ function hoistTemplate(templ) {
74
74
  }
75
75
  // Register the handler
76
76
  import { MountObserver } from '../MountObserver.js';
77
- MountObserver.define('builtIns.hoistTemplate', HoistTemplateHandler);
77
+ export const hoist = 'builtIns.hoistTemplate';
78
+ MountObserver.define(hoist, HoistTemplateHandler);
@@ -86,4 +86,6 @@ function hoistTemplate(templ: HTMLTemplateElement): void {
86
86
  // Register the handler
87
87
  import { MountObserver } from '../MountObserver.js';
88
88
 
89
- MountObserver.define('builtIns.hoistTemplate', HoistTemplateHandler);
89
+ export const hoist = 'builtIns.hoistTemplate';
90
+
91
+ MountObserver.define(hoist, HoistTemplateHandler);
@@ -75,4 +75,5 @@ export class MountObserverScriptHandler extends EvtRt {
75
75
  }
76
76
  // Register built-in handler
77
77
  import { MountObserver } from '../MountObserver.js';
78
- MountObserver.define('builtIns.mountObserverScript', MountObserverScriptHandler);
78
+ export const mos = 'builtIns.mountObserverScript';
79
+ MountObserver.define(mos, MountObserverScriptHandler);
@@ -86,4 +86,7 @@ export class MountObserverScriptHandler extends EvtRt {
86
86
  // Register built-in handler
87
87
  import { MountObserver } from '../MountObserver.js';
88
88
 
89
- MountObserver.define('builtIns.mountObserverScript', MountObserverScriptHandler);
89
+ export const mos = 'builtIns.mountObserverScript';
90
+
91
+ MountObserver.define(mos, MountObserverScriptHandler);
92
+
@@ -80,4 +80,5 @@ export class ScriptExportHandler extends EvtRt {
80
80
  }
81
81
  // Register built-in handler
82
82
  import { MountObserver } from '../MountObserver.js';
83
- MountObserver.define('builtIns.scriptExport', ScriptExportHandler);
83
+ export const scriptExport = 'builtIns.scriptExport';
84
+ MountObserver.define(scriptExport, ScriptExportHandler);
@@ -94,4 +94,6 @@ export class ScriptExportHandler extends EvtRt {
94
94
  // Register built-in handler
95
95
  import { MountObserver } from '../MountObserver.js';
96
96
 
97
- MountObserver.define('builtIns.scriptExport', ScriptExportHandler);
97
+ export const scriptExport = 'builtIns.scriptExport';
98
+
99
+ MountObserver.define(scriptExport, ScriptExportHandler);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mount-observer",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "Observe and act on css matches.",
5
5
  "main": "MountObserver.js",
6
6
  "module": "MountObserver.js",
@@ -1,110 +0,0 @@
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;
package/handlers/EvtRt.js DELETED
@@ -1,59 +0,0 @@
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);