mount-observer 0.0.55 → 0.0.57
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 +6 -3
- package/MountObserver.ts +6 -3
- package/Newish.js +3 -3
- package/Newish.ts +5 -5
- package/README.md +2 -0
- package/RootMutObs.js +4 -2
- package/RootMutObs.ts +5 -4
- package/package.json +5 -5
- package/ts-refs/be-scoped/types.d.ts +3 -2
- package/ts-refs/be-switched/types.d.ts +2 -1
- package/ts-refs/mount-observer/types.d.ts +7 -1
- package/ts-refs/per-each/types.d.ts +1 -0
- /package/{itemRefUtils → refid}/splitRefs.js +0 -0
- /package/{itemRefUtils → refid}/splitRefs.ts +0 -0
package/MountObserver.js
CHANGED
|
@@ -147,7 +147,7 @@ export class MountObserver extends EventTarget {
|
|
|
147
147
|
this.objNde = new WeakRef(within);
|
|
148
148
|
const nodeToMonitor = this.#isComplex ? (within instanceof ShadowRoot ? within : within.getRootNode()) : within;
|
|
149
149
|
if (!mutationObserverLookup.has(nodeToMonitor)) {
|
|
150
|
-
mutationObserverLookup.set(nodeToMonitor, new RootMutObs(nodeToMonitor));
|
|
150
|
+
mutationObserverLookup.set(nodeToMonitor, new RootMutObs(nodeToMonitor, this.#mountInit));
|
|
151
151
|
refCount.set(nodeToMonitor, 1);
|
|
152
152
|
}
|
|
153
153
|
else {
|
|
@@ -430,7 +430,10 @@ export class MountObserver extends EventTarget {
|
|
|
430
430
|
this.#filterAndMount(els, false, initializing);
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
|
-
export function waitForIdleNodes(nodes) {
|
|
433
|
+
export function waitForIdleNodes(nodes, idleTimeout) {
|
|
434
|
+
const mountInit = {
|
|
435
|
+
idleTimeout
|
|
436
|
+
};
|
|
434
437
|
return new Promise((resolve) => {
|
|
435
438
|
const mutObservers = [];
|
|
436
439
|
for (const node of nodes) {
|
|
@@ -440,7 +443,7 @@ export function waitForIdleNodes(nodes) {
|
|
|
440
443
|
}
|
|
441
444
|
else {
|
|
442
445
|
const currentCount = refCount.get(node) || 0;
|
|
443
|
-
const newMutObs = new RootMutObs(node);
|
|
446
|
+
const newMutObs = new RootMutObs(node, mountInit);
|
|
444
447
|
mutationObserverLookup.set(node, newMutObs);
|
|
445
448
|
refCount.set(node, currentCount + 1);
|
|
446
449
|
mutObservers.push(newMutObs);
|
package/MountObserver.ts
CHANGED
|
@@ -159,7 +159,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
159
159
|
this.objNde = new WeakRef(within);
|
|
160
160
|
const nodeToMonitor = this.#isComplex ? (within instanceof ShadowRoot ? within : within.getRootNode()) : within;
|
|
161
161
|
if(!mutationObserverLookup.has(nodeToMonitor)){
|
|
162
|
-
mutationObserverLookup.set(nodeToMonitor, new RootMutObs(nodeToMonitor));
|
|
162
|
+
mutationObserverLookup.set(nodeToMonitor, new RootMutObs(nodeToMonitor, this.#mountInit));
|
|
163
163
|
refCount.set(nodeToMonitor, 1);
|
|
164
164
|
}else{
|
|
165
165
|
const currentCount = refCount.get(nodeToMonitor);
|
|
@@ -451,7 +451,10 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
451
451
|
|
|
452
452
|
}
|
|
453
453
|
|
|
454
|
-
export function waitForIdleNodes(nodes: Array<Node
|
|
454
|
+
export function waitForIdleNodes(nodes: Array<Node>, idleTimeout?: number): Promise<void>{
|
|
455
|
+
const mountInit: MountInit = {
|
|
456
|
+
idleTimeout
|
|
457
|
+
};
|
|
455
458
|
return new Promise((resolve) => {
|
|
456
459
|
const mutObservers: Array<RootMutObs> = [];
|
|
457
460
|
for(const node of nodes){
|
|
@@ -460,7 +463,7 @@ export function waitForIdleNodes(nodes: Array<Node>): Promise<void>{
|
|
|
460
463
|
mutObservers.push(mutObs);
|
|
461
464
|
}else{
|
|
462
465
|
const currentCount = refCount.get(node) || 0;
|
|
463
|
-
const newMutObs = new RootMutObs(node);
|
|
466
|
+
const newMutObs = new RootMutObs(node, mountInit);
|
|
464
467
|
mutationObserverLookup.set(node, newMutObs);
|
|
465
468
|
refCount.set(node, currentCount + 1);
|
|
466
469
|
mutObservers.push(newMutObs);
|
package/Newish.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { waitForEvent } from './waitForEvent.js';
|
|
2
2
|
import { ObsAttr } from './ObsAttr.js';
|
|
3
|
-
import { splitRefs } from './
|
|
3
|
+
import { splitRefs } from './refid/splitRefs.js';
|
|
4
4
|
export const attached = Symbol.for('xyyspnstnU+CDrNVa0VnxA');
|
|
5
5
|
export class Newish {
|
|
6
6
|
queue = [];
|
|
@@ -63,7 +63,7 @@ export class Newish {
|
|
|
63
63
|
#attachItemrefs(enhancedElement) {
|
|
64
64
|
//TODO: watch for already attached itemrefs to be removed and remove them from the set
|
|
65
65
|
// and call outOfScopeCallback on them
|
|
66
|
-
if (enhancedElement.hasAttribute('itemref')) {
|
|
66
|
+
if ('inScopeCallback' in this.#ce && enhancedElement.hasAttribute('itemref')) {
|
|
67
67
|
const itemref = enhancedElement.getAttribute('itemref');
|
|
68
68
|
const itemrefList = splitRefs(itemref); // itemref.split(' ').map((id) => id.trim()).filter((id) => id.length > 0);
|
|
69
69
|
if (itemrefList.length === 0)
|
|
@@ -89,7 +89,7 @@ export class Newish {
|
|
|
89
89
|
const fi = this.queue.shift();
|
|
90
90
|
//TODO: Provide support for a virtual slice of a very large list
|
|
91
91
|
if (Array.isArray(fi)) {
|
|
92
|
-
ce
|
|
92
|
+
ce.ishList = fi;
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
95
95
|
const { assigner } = this.#options;
|
package/Newish.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Assigner, BindishOptions } from './ts-refs/mount-observer/types.js';
|
|
|
2
2
|
|
|
3
3
|
export {waitForEvent} from './waitForEvent.js';
|
|
4
4
|
import {ObsAttr} from './ObsAttr.js';
|
|
5
|
-
import {splitRefs} from './
|
|
5
|
+
import {splitRefs} from './refid/splitRefs.js';
|
|
6
6
|
export const attached = Symbol.for('xyyspnstnU+CDrNVa0VnxA');
|
|
7
7
|
export class Newish implements EventListenerObject {
|
|
8
8
|
queue: Array<any> = [];
|
|
@@ -38,7 +38,7 @@ export class Newish implements EventListenerObject {
|
|
|
38
38
|
if(initPropVals !== undefined) this.queue.push(initPropVals);
|
|
39
39
|
const ce = document.createElement(itemscope);
|
|
40
40
|
if('attachedCallback' in ce && typeof ce.attachedCallback === 'function'){
|
|
41
|
-
await ce.attachedCallback(enhancedElement)
|
|
41
|
+
await ce.attachedCallback(enhancedElement, this.#options)
|
|
42
42
|
}
|
|
43
43
|
this.#ce = ce;
|
|
44
44
|
const self = this;
|
|
@@ -69,7 +69,7 @@ export class Newish implements EventListenerObject {
|
|
|
69
69
|
#attachItemrefs(enhancedElement: Element){
|
|
70
70
|
//TODO: watch for already attached itemrefs to be removed and remove them from the set
|
|
71
71
|
// and call outOfScopeCallback on them
|
|
72
|
-
if(enhancedElement.hasAttribute('itemref')){
|
|
72
|
+
if('inScopeCallback' in (<any>this.#ce) && enhancedElement.hasAttribute('itemref')){
|
|
73
73
|
const itemref = enhancedElement.getAttribute('itemref')!;
|
|
74
74
|
const itemrefList = splitRefs(itemref);// itemref.split(' ').map((id) => id.trim()).filter((id) => id.length > 0);
|
|
75
75
|
if(itemrefList.length === 0) return;
|
|
@@ -78,7 +78,7 @@ export class Newish implements EventListenerObject {
|
|
|
78
78
|
if(this.#alreadyAttached.has(id)) continue;
|
|
79
79
|
const itemrefElement = rn.getElementById(id);
|
|
80
80
|
if(itemrefElement){
|
|
81
|
-
(<any>this.#ce).inScopeCallback(itemrefElement);
|
|
81
|
+
(<any>this.#ce).inScopeCallback(itemrefElement, this.#options);
|
|
82
82
|
this.#alreadyAttached.add(id);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -95,7 +95,7 @@ export class Newish implements EventListenerObject {
|
|
|
95
95
|
const fi = this.queue.shift();
|
|
96
96
|
//TODO: Provide support for a virtual slice of a very large list
|
|
97
97
|
if(Array.isArray(fi)){
|
|
98
|
-
(<any>ce)
|
|
98
|
+
(<any>ce).ishList = fi;
|
|
99
99
|
}else{
|
|
100
100
|
const {assigner} = this.#options;
|
|
101
101
|
await assigner!(ce, fi);
|
package/README.md
CHANGED
package/RootMutObs.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export class RootMutObs extends EventTarget {
|
|
2
|
-
#idleTimeout
|
|
2
|
+
#idleTimeout; //TODO: make this configurable
|
|
3
3
|
#idlePointer = 0;
|
|
4
|
-
constructor(rootNode) {
|
|
4
|
+
constructor(rootNode, options) {
|
|
5
5
|
super();
|
|
6
|
+
this.#idleTimeout = options?.idleTimeout ?? 30;
|
|
7
|
+
console.log(this.#idleTimeout);
|
|
6
8
|
this.#mutationObserver = new MutationObserver(mutationRecords => {
|
|
7
9
|
this.dispatchEvent(new MutationEvent(mutationRecords));
|
|
8
10
|
this.#triggerIsIdle();
|
package/RootMutObs.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {mutationEventName, AddMutationEventListener} from './ts-refs/mount-observer/types';
|
|
1
|
+
import {mutationEventName, AddMutationEventListener, MountInit} from './ts-refs/mount-observer/types';
|
|
2
2
|
|
|
3
3
|
export class RootMutObs extends EventTarget{
|
|
4
|
-
#idleTimeout
|
|
4
|
+
#idleTimeout: number; //TODO: make this configurable
|
|
5
5
|
#idlePointer = 0;
|
|
6
|
-
constructor(rootNode: Node ){
|
|
6
|
+
constructor(rootNode: Node, options: MountInit ){
|
|
7
7
|
super();
|
|
8
|
-
|
|
8
|
+
this.#idleTimeout = options?.idleTimeout ?? 30;
|
|
9
|
+
console.log(this.#idleTimeout);
|
|
9
10
|
this.#mutationObserver = new MutationObserver(mutationRecords => {
|
|
10
11
|
this.dispatchEvent(new MutationEvent(mutationRecords));
|
|
11
12
|
this.#triggerIsIdle();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mount-observer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.57",
|
|
4
4
|
"description": "Observe and act on css matches.",
|
|
5
5
|
"main": "MountObserver.js",
|
|
6
6
|
"module": "MountObserver.js",
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
"default": "./waitForIsh.js",
|
|
46
46
|
"types": "./waitForIsh.ts"
|
|
47
47
|
},
|
|
48
|
-
"./
|
|
49
|
-
"default": "./
|
|
50
|
-
"types": "./
|
|
48
|
+
"./refid/splitRefs.js": {
|
|
49
|
+
"default": "./refid/splitRefs.js",
|
|
50
|
+
"types": "./refid/splitRefs.ts"
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"files": [
|
|
54
54
|
"*.js",
|
|
55
55
|
"*.ts",
|
|
56
56
|
"./ts-refs/*",
|
|
57
|
-
"./
|
|
57
|
+
"./refid/*"
|
|
58
58
|
],
|
|
59
59
|
"types": "./ts-refs/mount-observer/types.d.ts",
|
|
60
60
|
"scripts": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {IEnhancement, BEAllProps} from '../trans-render/be/types';
|
|
1
|
+
import {IEnhancement, BEAllProps, EMC} from '../trans-render/be/types';
|
|
2
2
|
|
|
3
3
|
export interface EndUserProps extends IEnhancement{
|
|
4
4
|
names: string;
|
|
@@ -6,6 +6,7 @@ export interface EndUserProps extends IEnhancement{
|
|
|
6
6
|
|
|
7
7
|
export interface AllProps extends EndUserProps{
|
|
8
8
|
parsedNames: string[];
|
|
9
|
+
emc: EMC<any, AllProps>;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export type AP = AllProps;
|
|
@@ -17,7 +18,7 @@ export type ProPAP = Promise<PAP>;
|
|
|
17
18
|
export type BAP = AP & BEAllProps;
|
|
18
19
|
|
|
19
20
|
export interface Actions{
|
|
20
|
-
parse(self: BAP):
|
|
21
|
+
parse(self: BAP): ProPAP;
|
|
21
22
|
hydrate(self: BAP): ProPAP;
|
|
22
23
|
retire(self: BAP): void;
|
|
23
24
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//import { ActionOnEventConfigs } from "trans-render/froop/types";
|
|
2
|
-
import {BEAllProps, IEnhancement} from '../trans-render/be/types';
|
|
2
|
+
import {BEAllProps, EMC, IEnhancement} from '../trans-render/be/types';
|
|
3
3
|
//import {BVAAllProps} from 'be-value-added/types';
|
|
4
4
|
//import {AP as BPAP, ISignal, Actions as BPActions} from 'be-propagating/types';
|
|
5
5
|
//import {ElTypes, SignalRefType} from 'be-linked/types';
|
|
@@ -43,6 +43,7 @@ export interface AllProps extends EndUserProps{
|
|
|
43
43
|
nValueSwitches?: Array<NValueScriptSwitch>
|
|
44
44
|
rawStatements?: Array<string>,
|
|
45
45
|
notProcessedJS?: boolean,
|
|
46
|
+
emc: EMC<any, AllProps>,
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
export type SwitchStatement = string;
|
|
@@ -27,6 +27,7 @@ export interface MountInit extends JSONSerializableMountInit{
|
|
|
27
27
|
readonly whereSatisfies?: PipelineProcessor<boolean>,
|
|
28
28
|
readonly do?: MountObserverCallbacks,
|
|
29
29
|
readonly assigner?: Assigner,
|
|
30
|
+
readonly idleTimeout?: number
|
|
30
31
|
// /**
|
|
31
32
|
// * Purpose -- there are scenarios where we may only want to affect changes that occur after the initial
|
|
32
33
|
// * server rendering, so we only want to mount elements that appear
|
|
@@ -209,7 +210,12 @@ export interface MOSE<TSynConfig=any>
|
|
|
209
210
|
|
|
210
211
|
export interface BindishOptions{
|
|
211
212
|
assigner?: Assigner,
|
|
212
|
-
waitFor?: string,
|
|
213
|
+
//waitFor?: string,
|
|
214
|
+
/**
|
|
215
|
+
* If derived from a template, set to true
|
|
216
|
+
* to indicate that the initial
|
|
217
|
+
*/
|
|
218
|
+
csr?: boolean,
|
|
213
219
|
}
|
|
214
220
|
|
|
215
221
|
//#endregion
|
|
File without changes
|
|
File without changes
|