be-hive 0.0.221 → 0.0.223
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/Registry.js +1 -9
- package/Registry.ts +2 -11
- package/be-hive.js +9 -11
- package/be-hive.ts +17 -12
- package/e.js +14 -0
- package/e.ts +16 -0
- package/package.json +9 -5
- package/w.js +19 -0
- package/w.ts +20 -0
package/Registry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { registeredHandlers
|
|
1
|
+
import { registeredHandlers } from './be-hive.js';
|
|
2
2
|
export class Registry {
|
|
3
3
|
static register(emc, handlerName, handler) {
|
|
4
4
|
const cluster = registeredHandlers.get(emc);
|
|
@@ -8,12 +8,4 @@ export class Registry {
|
|
|
8
8
|
}
|
|
9
9
|
customHandlers.set(handlerName, handler);
|
|
10
10
|
}
|
|
11
|
-
static within(emc, q, handlerName, handler) {
|
|
12
|
-
const scopedCluster = scopedHandlers.get(emc);
|
|
13
|
-
const scopedCustomHandlers = scopedCluster.get(emc.handlerKey);
|
|
14
|
-
if (!scopedCustomHandlers.has(handlerName)) {
|
|
15
|
-
scopedCustomHandlers.set(handlerName, []);
|
|
16
|
-
}
|
|
17
|
-
scopedCustomHandlers.get(handlerName).push([q, handler]);
|
|
18
|
-
}
|
|
19
11
|
}
|
package/Registry.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {EMC, EventListenerOrFn} from './ts-refs/trans-render/be/types';
|
|
2
|
-
import {registeredHandlers
|
|
1
|
+
import {EMC, EventListenerOrFn, OnOptions} from './ts-refs/trans-render/be/types';
|
|
2
|
+
import {registeredHandlers} from './be-hive.js';
|
|
3
3
|
import { CSSQuery } from './ts-refs/trans-render/types';
|
|
4
4
|
|
|
5
5
|
export class Registry{
|
|
@@ -12,13 +12,4 @@ export class Registry{
|
|
|
12
12
|
customHandlers.set(handlerName, handler);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
static within(emc: EMC, q: CSSQuery, handlerName: string, handler: EventListenerOrFn){
|
|
16
|
-
const scopedCluster = scopedHandlers.get(emc)!;
|
|
17
|
-
const scopedCustomHandlers = scopedCluster.get(emc.handlerKey!)!;
|
|
18
|
-
if(!scopedCustomHandlers.has(handlerName)){
|
|
19
|
-
scopedCustomHandlers.set(handlerName, []);
|
|
20
|
-
}
|
|
21
|
-
scopedCustomHandlers!.get(handlerName)!.push([q, handler]);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
15
|
}
|
package/be-hive.js
CHANGED
|
@@ -25,7 +25,7 @@ export const defaultObsAttrs = {
|
|
|
25
25
|
enhancedElementInstanceOf: [Element]
|
|
26
26
|
};
|
|
27
27
|
export const registeredHandlers = new Map();
|
|
28
|
-
export const scopedHandlers = new Map();
|
|
28
|
+
//export const scopedHandlers = new Map<EMC, ScopedCustomHandlerCluster>();
|
|
29
29
|
export function seed(emc) {
|
|
30
30
|
if (emc.handlerKey === undefined)
|
|
31
31
|
emc.handlerKey = emc.enhPropKey;
|
|
@@ -38,13 +38,6 @@ export function seed(emc) {
|
|
|
38
38
|
if (!cluster?.has(handlerKey)) {
|
|
39
39
|
cluster.set(handlerKey, new Map());
|
|
40
40
|
}
|
|
41
|
-
if (!scopedHandlers.has(emc)) {
|
|
42
|
-
scopedHandlers.set(emc, new Map());
|
|
43
|
-
}
|
|
44
|
-
const scopedCluster = scopedHandlers.get(emc);
|
|
45
|
-
if (!scopedCluster?.has(handlerKey)) {
|
|
46
|
-
scopedCluster.set(handlerKey, new Map());
|
|
47
|
-
}
|
|
48
41
|
try {
|
|
49
42
|
Enhancers.define(emc);
|
|
50
43
|
}
|
|
@@ -63,7 +56,7 @@ export class BeHive extends Synthesizer {
|
|
|
63
56
|
const mergeWithDefaults = { ...defaultObsAttrs, ...synConfig };
|
|
64
57
|
//TODO allow for programmatic adjustments in load event
|
|
65
58
|
//this.dispatchEvent(new RegistryEventImpl(mergeWithDefaults));
|
|
66
|
-
const { base, block, branches, enhancedElementInstanceOf, enhancedElementMatches, hostInstanceOf, hostMatches, leaves, preBaseDelimiter, preBranchDelimiter, importEnh, preLeafDelimiter, hasRootIn, map, osotas, mapLocalNameTo } = mergeWithDefaults;
|
|
59
|
+
const { base, block, branches, enhancedElementInstanceOf, enhancedElementMatches, hostInstanceOf, hostMatches, leaves, preBaseDelimiter, preBranchDelimiter, importEnh, preLeafDelimiter, hasRootIn, map, osotas, mapLocalNameTo, ws } = mergeWithDefaults;
|
|
67
60
|
const mi = {
|
|
68
61
|
on: enhancedElementMatches,
|
|
69
62
|
whereInstanceOf: enhancedElementInstanceOf,
|
|
@@ -83,6 +76,7 @@ export class BeHive extends Synthesizer {
|
|
|
83
76
|
super.activate(mose);
|
|
84
77
|
const mo = mose.observer;
|
|
85
78
|
mo.addEventListener('mount', async (e) => {
|
|
79
|
+
const observedAttrs = await mo.observedAttrs();
|
|
86
80
|
const { mountedElement } = e;
|
|
87
81
|
const { beEnhanced } = mountedElement;
|
|
88
82
|
const enhancementConstructor = await importEnh();
|
|
@@ -133,12 +127,16 @@ export class BeHive extends Synthesizer {
|
|
|
133
127
|
initialPropValues[mapLocalNameTo] = mountedElement.localName;
|
|
134
128
|
}
|
|
135
129
|
initialPropValues.customHandlers = registeredHandlers.get(synConfig.top)?.get(enhPropKey);
|
|
136
|
-
|
|
130
|
+
if (ws !== undefined) {
|
|
131
|
+
(await import('./e.js')).e(mountedElement, ws);
|
|
132
|
+
}
|
|
133
|
+
//initialPropValues.scopedCustomHandlers = scopedHandlers.get(synConfig.top)?.get(enhPropKey);
|
|
137
134
|
enhancementInstance.attach(mountedElement, {
|
|
138
135
|
initialAttrInfo,
|
|
139
136
|
initialPropValues,
|
|
140
137
|
mountCnfg: mergeWithDefaults,
|
|
141
|
-
synConfig
|
|
138
|
+
synConfig,
|
|
139
|
+
observedAttrs
|
|
142
140
|
});
|
|
143
141
|
});
|
|
144
142
|
}
|
package/be-hive.ts
CHANGED
|
@@ -2,7 +2,10 @@ import {Synthesizer} from 'mount-observer/Synthesizer.js';
|
|
|
2
2
|
import { AddMountEventListener, MountInit, MOSE, MOSEAddedProps} from './ts-refs/mount-observer/types';
|
|
3
3
|
export {EMC} from './ts-refs/trans-render/be/types';
|
|
4
4
|
export {MountObserver, MOSE} from 'mount-observer/MountObserver.js';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
AttrMapPoint, CustomHandlerCluster, EMC, EventListenerOrFn,
|
|
7
|
+
HandlerKey,
|
|
8
|
+
} from './ts-refs/trans-render/be/types';
|
|
6
9
|
import { MountEvent } from 'mount-observer/MountObserver';
|
|
7
10
|
import 'be-enhanced/beEnhanced.js';
|
|
8
11
|
import { BeEnhanced, Enhancers } from 'be-enhanced/beEnhanced.js';
|
|
@@ -37,7 +40,8 @@ export const defaultObsAttrs: Partial<EMC> = {
|
|
|
37
40
|
|
|
38
41
|
export const registeredHandlers = new Map<EMC, CustomHandlerCluster>();
|
|
39
42
|
|
|
40
|
-
export const scopedHandlers = new Map<EMC, ScopedCustomHandlerCluster>();
|
|
43
|
+
//export const scopedHandlers = new Map<EMC, ScopedCustomHandlerCluster>();
|
|
44
|
+
|
|
41
45
|
|
|
42
46
|
export function seed(emc: EMC){
|
|
43
47
|
if(emc.handlerKey === undefined) emc.handlerKey = emc.enhPropKey;
|
|
@@ -50,13 +54,8 @@ export function seed(emc: EMC){
|
|
|
50
54
|
if(!cluster?.has(handlerKey)){
|
|
51
55
|
cluster!.set(handlerKey, new Map());
|
|
52
56
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
const scopedCluster = scopedHandlers.get(emc);
|
|
57
|
-
if(!scopedCluster?.has(handlerKey)){
|
|
58
|
-
scopedCluster!.set(handlerKey, new Map())
|
|
59
|
-
}
|
|
57
|
+
|
|
58
|
+
|
|
60
59
|
try{
|
|
61
60
|
Enhancers.define(emc);
|
|
62
61
|
}catch(e){}
|
|
@@ -80,7 +79,7 @@ export class BeHive extends Synthesizer {
|
|
|
80
79
|
enhancedElementMatches, hostInstanceOf, hostMatches,
|
|
81
80
|
leaves, preBaseDelimiter, preBranchDelimiter, importEnh,
|
|
82
81
|
preLeafDelimiter, hasRootIn, map, osotas,
|
|
83
|
-
mapLocalNameTo
|
|
82
|
+
mapLocalNameTo, ws
|
|
84
83
|
|
|
85
84
|
} = mergeWithDefaults;
|
|
86
85
|
const mi: MountInit = {
|
|
@@ -103,6 +102,7 @@ export class BeHive extends Synthesizer {
|
|
|
103
102
|
super.activate(mose);
|
|
104
103
|
const mo = mose.observer;
|
|
105
104
|
(mo as any as AddMountEventListener).addEventListener('mount', async e => {
|
|
105
|
+
const observedAttrs = await mo.observedAttrs();
|
|
106
106
|
const {mountedElement} = (e as MountEvent);
|
|
107
107
|
const {beEnhanced} : {beEnhanced: BeEnhanced} = (<any>mountedElement);
|
|
108
108
|
const enhancementConstructor = await importEnh!();
|
|
@@ -148,12 +148,17 @@ export class BeHive extends Synthesizer {
|
|
|
148
148
|
initialPropValues[mapLocalNameTo] = mountedElement.localName;
|
|
149
149
|
}
|
|
150
150
|
initialPropValues.customHandlers = registeredHandlers.get(synConfig.top)?.get(enhPropKey);
|
|
151
|
-
|
|
151
|
+
|
|
152
|
+
if(ws !== undefined){
|
|
153
|
+
(await import('./e.js')).e(mountedElement, ws);
|
|
154
|
+
}
|
|
155
|
+
//initialPropValues.scopedCustomHandlers = scopedHandlers.get(synConfig.top)?.get(enhPropKey);
|
|
152
156
|
enhancementInstance.attach(mountedElement, {
|
|
153
157
|
initialAttrInfo,
|
|
154
158
|
initialPropValues,
|
|
155
159
|
mountCnfg: mergeWithDefaults,
|
|
156
|
-
synConfig
|
|
160
|
+
synConfig,
|
|
161
|
+
observedAttrs
|
|
157
162
|
});
|
|
158
163
|
});
|
|
159
164
|
}
|
package/e.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function e(matchingElement, ws, ac) {
|
|
2
|
+
for (const w of ws) {
|
|
3
|
+
if (!matchingElement.matches(w.q))
|
|
4
|
+
continue;
|
|
5
|
+
const { listeners } = w;
|
|
6
|
+
for (const key in listeners) {
|
|
7
|
+
let listener = listeners[key];
|
|
8
|
+
if (listener.toString().substring(0, 5) === 'class') {
|
|
9
|
+
listener = new listener();
|
|
10
|
+
}
|
|
11
|
+
matchingElement.addEventListener(key, listener, { signal: ac?.signal });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
package/e.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EventListenerClass, EventListenerOrFn, IW } from "./ts-refs/trans-render/be/types";
|
|
2
|
+
|
|
3
|
+
export function e(matchingElement: Element, ws: Array<IW>, ac?: AbortController){
|
|
4
|
+
for(const w of ws){
|
|
5
|
+
if(!matchingElement.matches(w.q)) continue;
|
|
6
|
+
const {listeners} = w;
|
|
7
|
+
for(const key in listeners){
|
|
8
|
+
let listener = listeners[key] as any;
|
|
9
|
+
if(listener.toString().substring(0, 5) === 'class'){
|
|
10
|
+
listener = new (<EventListenerClass>listener)() as any as EventListenerOrFn;
|
|
11
|
+
}
|
|
12
|
+
matchingElement.addEventListener(key, listener, {signal: ac?.signal});
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "be-hive",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.223",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"web-components",
|
|
6
6
|
"web-component",
|
|
@@ -29,7 +29,11 @@
|
|
|
29
29
|
},
|
|
30
30
|
"./Registry.js": {
|
|
31
31
|
"default": "./Registry.js",
|
|
32
|
-
"types": "./Registry.
|
|
32
|
+
"types": "./Registry.Ts"
|
|
33
|
+
},
|
|
34
|
+
"./w.js": {
|
|
35
|
+
"default": "./w.js",
|
|
36
|
+
"types": "./w.ts"
|
|
33
37
|
}
|
|
34
38
|
},
|
|
35
39
|
"files": [
|
|
@@ -41,9 +45,9 @@
|
|
|
41
45
|
"update": "ncu -u && npm install"
|
|
42
46
|
},
|
|
43
47
|
"dependencies": {
|
|
44
|
-
"be-enhanced": "0.0.
|
|
45
|
-
"mount-observer": "0.0.
|
|
46
|
-
"trans-render": "0.0.
|
|
48
|
+
"be-enhanced": "0.0.146",
|
|
49
|
+
"mount-observer": "0.0.38",
|
|
50
|
+
"trans-render": "0.0.847"
|
|
47
51
|
},
|
|
48
52
|
"devDependencies": {
|
|
49
53
|
"may-it-serve": "0.0.8"
|
package/w.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function w(q, ws) {
|
|
2
|
+
const returnObj = new W(q);
|
|
3
|
+
ws.push(returnObj);
|
|
4
|
+
return returnObj;
|
|
5
|
+
}
|
|
6
|
+
export class W {
|
|
7
|
+
q;
|
|
8
|
+
constructor(q) {
|
|
9
|
+
this.q = q;
|
|
10
|
+
}
|
|
11
|
+
#listeners = {};
|
|
12
|
+
get listeners() {
|
|
13
|
+
return this.#listeners;
|
|
14
|
+
}
|
|
15
|
+
a(eventsToAdd) {
|
|
16
|
+
this.#listeners = { ...this.#listeners, ...eventsToAdd };
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
}
|
package/w.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EventListenerOrFn, OnOptions, IW, MappedListeners } from './ts-refs/trans-render/be/types';
|
|
2
|
+
import { CSSQuery } from './ts-refs/trans-render/types';
|
|
3
|
+
export function w(q: CSSQuery, ws: Array<IW>){
|
|
4
|
+
const returnObj = new W(q);
|
|
5
|
+
ws.push(returnObj);
|
|
6
|
+
return returnObj;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class W implements IW{
|
|
10
|
+
constructor(public q: CSSQuery){}
|
|
11
|
+
#listeners: MappedListeners = {};
|
|
12
|
+
get listeners(){
|
|
13
|
+
return this.#listeners;
|
|
14
|
+
}
|
|
15
|
+
a(eventsToAdd: {[key: string]: EventListenerOrFn}){
|
|
16
|
+
this.#listeners = {...this.#listeners, ...eventsToAdd};
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|