mount-observer 0.0.41 → 0.0.42

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/MountObserver.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import { RootMutObs } from './RootMutObs.js';
2
+ export const guid = '5Pv6bHOVH0ae07opRZ8N/g';
2
3
  const mutationObserverLookup = new WeakMap();
3
4
  const refCount = new WeakMap();
4
5
  export class MountObserver extends EventTarget {
5
6
  #mountInit;
7
+ #options;
6
8
  //#rootMutObs: RootMutObs | undefined;
7
9
  #abortController;
8
10
  mountedElements;
@@ -111,7 +113,8 @@ export class MountObserver extends EventTarget {
111
113
  }
112
114
  this.dispatchEvent(new Event('disconnectedCallback'));
113
115
  }
114
- async observe(within) {
116
+ async observe(within, options) {
117
+ this.#options = options;
115
118
  const init = this.#mountInit;
116
119
  const { whereMediaMatches } = init;
117
120
  if (whereMediaMatches === undefined) {
@@ -249,6 +252,7 @@ export class MountObserver extends EventTarget {
249
252
  const mount = this.#mountInit.do?.mount;
250
253
  const { import: imp } = this.#mountInit;
251
254
  const me = this.mountedElements;
255
+ const options = this.#options;
252
256
  for (const match of matching) {
253
257
  if (alreadyMounted.has(match))
254
258
  continue;
@@ -280,6 +284,12 @@ export class MountObserver extends EventTarget {
280
284
  initializing
281
285
  });
282
286
  }
287
+ if (options?.LeaveBreadcrumb) {
288
+ if (match[guid] === undefined) {
289
+ match[guid] = new Set();
290
+ }
291
+ match[guid].add(this);
292
+ }
283
293
  this.dispatchEvent(new MountEvent(match, initializing));
284
294
  //should we automatically call readAttrs?
285
295
  //the thinking is it might make more sense to call that after mounting
package/MountObserver.ts CHANGED
@@ -2,16 +2,19 @@ import {MountInit, IMountObserver, AddMutationEventListener,
2
2
  MutationEvent, dismountEventName, mountEventName, IMountEvent, IDismountEvent,
3
3
  disconnectedEventName, IDisconnectEvent, IAttrChangeEvent, attrChangeEventName, AttrChangeInfo, loadEventName, ILoadEvent,
4
4
  AttrParts,
5
- MOSE, WeakDual
5
+ MOSE, WeakDual,
6
+ MountObserverOptions
6
7
  } from './ts-refs/mount-observer/types';
7
8
  import {RootMutObs} from './RootMutObs.js';
8
9
  export {MOSE} from './ts-refs/mount-observer/types';
10
+ export const guid = '5Pv6bHOVH0ae07opRZ8N/g';
9
11
 
10
12
  const mutationObserverLookup = new WeakMap<Node, RootMutObs>();
11
13
  const refCount = new WeakMap<Node, number>();
12
14
  export class MountObserver extends EventTarget implements IMountObserver{
13
15
 
14
16
  #mountInit: MountInit;
17
+ #options: MountObserverOptions | undefined;
15
18
  //#rootMutObs: RootMutObs | undefined;
16
19
  #abortController: AbortController;
17
20
  mountedElements: WeakDual<Element>;
@@ -120,7 +123,8 @@ export class MountObserver extends EventTarget implements IMountObserver{
120
123
 
121
124
  }
122
125
 
123
- async observe(within: Node){
126
+ async observe(within: Node, options?: MountObserverOptions){
127
+ this.#options = options;
124
128
  const init = this.#mountInit;
125
129
  const {whereMediaMatches} = init;
126
130
  if(whereMediaMatches === undefined){
@@ -261,6 +265,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
261
265
  const mount = this.#mountInit.do?.mount;
262
266
  const {import: imp} = this.#mountInit;
263
267
  const me = this.mountedElements;
268
+ const options = this.#options;
264
269
  for(const match of matching){
265
270
  if(alreadyMounted.has(match)) continue;
266
271
  if(!me.weakSet.has(match)){
@@ -291,6 +296,12 @@ export class MountObserver extends EventTarget implements IMountObserver{
291
296
  initializing
292
297
  })
293
298
  }
299
+ if(options?.LeaveBreadcrumb){
300
+ if((<any>match)[guid] === undefined){
301
+ (<any>match)[guid] = new Set();
302
+ }
303
+ (<any>match)[guid].add(this);
304
+ }
294
305
  this.dispatchEvent(new MountEvent(match, initializing));
295
306
  //should we automatically call readAttrs?
296
307
  //the thinking is it might make more sense to call that after mounting
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "mount-observer",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "description": "Observe and act on css matches.",
5
5
  "main": "MountObserver.js",
6
6
  "module": "MountObserver.js",
7
7
  "devDependencies": {
8
- "@playwright/test": "1.49.1",
8
+ "@playwright/test": "1.50.0",
9
9
  "ssi-server": "0.0.1"
10
10
  },
11
11
  "exports": {
@@ -32,6 +32,10 @@ export interface MountInit extends JSONSerializableMountInit{
32
32
  // readonly ignoreInitialMatches?: boolean,
33
33
  }
34
34
 
35
+ export interface MountObserverOptions{
36
+ LeaveBreadcrumb?: boolean,
37
+ }
38
+
35
39
  export interface MountObserverCallbacks{
36
40
  readonly mount?: PipelineProcessor,
37
41
  readonly dismount?: PipelineProcessor,
@@ -131,7 +135,7 @@ interface AttrChangeInfo{
131
135
 
132
136
  //#region mount event
133
137
  export type mountEventName = 'mount';
134
- export interface IMountEvent{
138
+ export interface IMountEvent extends Event{
135
139
  mountedElement: Element,
136
140
  }
137
141
  export type mountEventHandler = (e: IMountEvent) => void;
@@ -0,0 +1,21 @@
1
+ import {IEnhancement, BEAllProps} from '../trans-render/be/types';
2
+
3
+ export interface EndUserProps extends IEnhancement{
4
+ doEval: boolean;
5
+ }
6
+
7
+ export interface AllProps extends EndUserProps{
8
+ //enhKey: string;
9
+ }
10
+
11
+ export type AP = AllProps;
12
+
13
+ export type PAP = Partial<AP>;
14
+
15
+ export type ProPAP = Promise<PAP>;
16
+
17
+ export type BAP = AP & BEAllProps;
18
+
19
+ export interface Actions{
20
+ hydrate(self: BAP): ProPAP;
21
+ }