be-hive 0.0.223 → 0.0.225

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/be-hive.js CHANGED
@@ -127,8 +127,9 @@ export class BeHive extends Synthesizer {
127
127
  initialPropValues[mapLocalNameTo] = mountedElement.localName;
128
128
  }
129
129
  initialPropValues.customHandlers = registeredHandlers.get(synConfig.top)?.get(enhPropKey);
130
+ let filteredWs;
130
131
  if (ws !== undefined) {
131
- (await import('./e.js')).e(mountedElement, ws);
132
+ filteredWs = (await import('./e.js')).e(mountedElement, ws, initialPropValues);
132
133
  }
133
134
  //initialPropValues.scopedCustomHandlers = scopedHandlers.get(synConfig.top)?.get(enhPropKey);
134
135
  enhancementInstance.attach(mountedElement, {
@@ -136,7 +137,8 @@ export class BeHive extends Synthesizer {
136
137
  initialPropValues,
137
138
  mountCnfg: mergeWithDefaults,
138
139
  synConfig,
139
- observedAttrs
140
+ observedAttrs,
141
+ ws: filteredWs
140
142
  });
141
143
  });
142
144
  }
package/be-hive.ts CHANGED
@@ -4,7 +4,8 @@ export {EMC} from './ts-refs/trans-render/be/types';
4
4
  export {MountObserver, MOSE} from 'mount-observer/MountObserver.js';
5
5
  import {
6
6
  AttrMapPoint, CustomHandlerCluster, EMC, EventListenerOrFn,
7
- HandlerKey,
7
+ HandlerKey,
8
+ IW,
8
9
  } from './ts-refs/trans-render/be/types';
9
10
  import { MountEvent } from 'mount-observer/MountObserver';
10
11
  import 'be-enhanced/beEnhanced.js';
@@ -148,9 +149,9 @@ export class BeHive extends Synthesizer {
148
149
  initialPropValues[mapLocalNameTo] = mountedElement.localName;
149
150
  }
150
151
  initialPropValues.customHandlers = registeredHandlers.get(synConfig.top)?.get(enhPropKey);
151
-
152
+ let filteredWs: Array<IW> | undefined;
152
153
  if(ws !== undefined){
153
- (await import('./e.js')).e(mountedElement, ws);
154
+ filteredWs = (await import('./e.js')).e(mountedElement, ws, initialPropValues);
154
155
  }
155
156
  //initialPropValues.scopedCustomHandlers = scopedHandlers.get(synConfig.top)?.get(enhPropKey);
156
157
  enhancementInstance.attach(mountedElement, {
@@ -158,7 +159,8 @@ export class BeHive extends Synthesizer {
158
159
  initialPropValues,
159
160
  mountCnfg: mergeWithDefaults,
160
161
  synConfig,
161
- observedAttrs
162
+ observedAttrs,
163
+ ws: filteredWs
162
164
  });
163
165
  });
164
166
  }
package/e.js CHANGED
@@ -1,8 +1,10 @@
1
- export function e(matchingElement, ws, ac) {
1
+ export function e(matchingElement, ws, initialPropVals, ac) {
2
+ const matchingWs = [];
2
3
  for (const w of ws) {
3
4
  if (!matchingElement.matches(w.q))
4
5
  continue;
5
- const { listeners } = w;
6
+ matchingWs.push(w);
7
+ const { listeners, props } = w;
6
8
  for (const key in listeners) {
7
9
  let listener = listeners[key];
8
10
  if (listener.toString().substring(0, 5) === 'class') {
@@ -10,5 +12,7 @@ export function e(matchingElement, ws, ac) {
10
12
  }
11
13
  matchingElement.addEventListener(key, listener, { signal: ac?.signal });
12
14
  }
15
+ Object.assign(initialPropVals, props);
13
16
  }
17
+ return matchingWs;
14
18
  }
package/e.ts CHANGED
@@ -1,16 +1,20 @@
1
1
  import { EventListenerClass, EventListenerOrFn, IW } from "./ts-refs/trans-render/be/types";
2
2
 
3
- export function e(matchingElement: Element, ws: Array<IW>, ac?: AbortController){
3
+
4
+ export function e(matchingElement: Element, ws: Array<IW>, initialPropVals: any, ac?: AbortController){
5
+ const matchingWs = [];
4
6
  for(const w of ws){
5
7
  if(!matchingElement.matches(w.q)) continue;
6
- const {listeners} = w;
8
+ matchingWs.push(w);
9
+ const {listeners, props} = w;
7
10
  for(const key in listeners){
8
11
  let listener = listeners[key] as any;
9
12
  if(listener.toString().substring(0, 5) === 'class'){
10
13
  listener = new (<EventListenerClass>listener)() as any as EventListenerOrFn;
11
14
  }
12
15
  matchingElement.addEventListener(key, listener, {signal: ac?.signal});
13
-
14
16
  }
17
+ Object.assign(initialPropVals, props);
15
18
  }
19
+ return matchingWs;
16
20
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "be-hive",
3
- "version": "0.0.223",
3
+ "version": "0.0.225",
4
4
  "keywords": [
5
5
  "web-components",
6
6
  "web-component",
7
7
  "custom-element",
8
8
  "custom-elements"
9
9
  ],
10
- "description": "Specify that ShadowDOM should inherit be-haviors from parent Shadow DOM",
10
+ "description": "Specify that ShadowDOM should inherit be-hiviors from the parent Shadow DOM",
11
11
  "main": "be-hive.js",
12
12
  "module": "be-hive.js",
13
13
  "exports": {
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "./Registry.js": {
31
31
  "default": "./Registry.js",
32
- "types": "./Registry.Ts"
32
+ "types": "./Registry.ts"
33
33
  },
34
34
  "./w.js": {
35
35
  "default": "./w.js",
@@ -41,16 +41,16 @@
41
41
  "*.ts"
42
42
  ],
43
43
  "scripts": {
44
- "serve": "node node_modules/may-it-serve/serve.js",
44
+ "serve": "python3 ./node_modules/ssi-server/ssi_server.py",
45
45
  "update": "ncu -u && npm install"
46
46
  },
47
47
  "dependencies": {
48
- "be-enhanced": "0.0.146",
49
- "mount-observer": "0.0.38",
50
- "trans-render": "0.0.847"
48
+ "be-enhanced": "0.0.147",
49
+ "mount-observer": "0.0.39",
50
+ "trans-render": "0.0.848"
51
51
  },
52
52
  "devDependencies": {
53
- "may-it-serve": "0.0.8"
53
+ "ssi-server": "0.0.1"
54
54
  },
55
55
  "repository": {
56
56
  "type": "git",
package/w.js CHANGED
@@ -12,8 +12,39 @@ export class W {
12
12
  get listeners() {
13
13
  return this.#listeners;
14
14
  }
15
+ #props = {};
16
+ get props() {
17
+ return this.#props;
18
+ }
19
+ #refs = {};
20
+ get refs() {
21
+ return this.#refs;
22
+ }
23
+ /**
24
+ * add events
25
+ * @param eventsToAdd
26
+ * @returns
27
+ */
15
28
  a(eventsToAdd) {
16
29
  this.#listeners = { ...this.#listeners, ...eventsToAdd };
17
30
  return this;
18
31
  }
32
+ /**
33
+ * set props
34
+ * @param props
35
+ * @returns
36
+ */
37
+ s(props) {
38
+ this.#props = { ...this.#props, ...props };
39
+ return this;
40
+ }
41
+ /**
42
+ * register refs
43
+ * @param refs
44
+ * @returns
45
+ */
46
+ r(refs) {
47
+ this.#refs = { ...this.#refs, ...refs };
48
+ return this;
49
+ }
19
50
  }
package/w.ts CHANGED
@@ -6,15 +6,47 @@ export function w(q: CSSQuery, ws: Array<IW>){
6
6
  return returnObj;
7
7
  }
8
8
 
9
- export class W implements IW{
9
+ export class W<T = EventTarget> implements IW<T>{
10
10
  constructor(public q: CSSQuery){}
11
11
  #listeners: MappedListeners = {};
12
12
  get listeners(){
13
13
  return this.#listeners;
14
14
  }
15
+ #props: Partial<T> = {};
16
+ get props(){
17
+ return this.#props;
18
+ }
19
+ #refs: {[key: string]: any} = {};
20
+ get refs(){
21
+ return this.#refs;
22
+ }
23
+ /**
24
+ * add events
25
+ * @param eventsToAdd
26
+ * @returns
27
+ */
15
28
  a(eventsToAdd: {[key: string]: EventListenerOrFn}){
16
29
  this.#listeners = {...this.#listeners, ...eventsToAdd};
17
30
  return this;
18
31
  }
32
+ /**
33
+ * set props
34
+ * @param props
35
+ * @returns
36
+ */
37
+ s(props: Partial<T>){
38
+ this.#props = {...this.#props, ...props};
39
+ return this;
40
+ }
41
+
42
+ /**
43
+ * register refs
44
+ * @param refs
45
+ * @returns
46
+ */
47
+ r(refs: {[key: string]: any}){
48
+ this.#refs = {...this.#refs, ...refs};
49
+ return this;
50
+ }
19
51
 
20
52
  }