mount-observer 0.0.40 → 0.0.41
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
|
@@ -21,7 +21,7 @@ export class MountObserver extends EventTarget {
|
|
|
21
21
|
isComplex = reducedMatch.includes(' ') || (reducedMatch.includes(':') && reducedMatch.includes('('));
|
|
22
22
|
}
|
|
23
23
|
this.#isComplex = isComplex;
|
|
24
|
-
if (whereElementIntersectsWith
|
|
24
|
+
if (whereElementIntersectsWith)
|
|
25
25
|
throw 'NI'; //not implemented
|
|
26
26
|
this.#mountInit = init;
|
|
27
27
|
this.#abortController = new AbortController();
|
|
@@ -112,6 +112,33 @@ export class MountObserver extends EventTarget {
|
|
|
112
112
|
this.dispatchEvent(new Event('disconnectedCallback'));
|
|
113
113
|
}
|
|
114
114
|
async observe(within) {
|
|
115
|
+
const init = this.#mountInit;
|
|
116
|
+
const { whereMediaMatches } = init;
|
|
117
|
+
if (whereMediaMatches === undefined) {
|
|
118
|
+
await this.#observe2(within);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const mql = window.matchMedia(whereMediaMatches);
|
|
122
|
+
if (mql.matches) {
|
|
123
|
+
await this.#observe2(within);
|
|
124
|
+
}
|
|
125
|
+
mql.addEventListener('change', async (e) => {
|
|
126
|
+
if (e.matches) {
|
|
127
|
+
if (this.objNde === undefined) {
|
|
128
|
+
await this.#observe2(within);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
await this.#mountAll();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
if (this.objNde !== undefined) {
|
|
136
|
+
await this.#dismountAll();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
async #observe2(within) {
|
|
115
142
|
await this.#selector();
|
|
116
143
|
this.objNde = new WeakRef(within);
|
|
117
144
|
const nodeToMonitor = this.#isComplex ? (within instanceof ShadowRoot ? within : within.getRootNode()) : within;
|
|
@@ -319,6 +346,19 @@ export class MountObserver extends EventTarget {
|
|
|
319
346
|
this.dispatchEvent(new DismountEvent(unmatch));
|
|
320
347
|
}
|
|
321
348
|
}
|
|
349
|
+
async #dismountAll() {
|
|
350
|
+
const mounted = this.#mountedList;
|
|
351
|
+
if (mounted === undefined)
|
|
352
|
+
return;
|
|
353
|
+
this.#dismount(mounted.map(x => x.deref()).filter(x => x !== undefined));
|
|
354
|
+
}
|
|
355
|
+
async #mountAll() {
|
|
356
|
+
//TODO: copilot created, check if needed
|
|
357
|
+
const { whereSatisfies, whereInstanceOf } = this.#mountInit;
|
|
358
|
+
const match = await this.#selector();
|
|
359
|
+
const els = Array.from(document.querySelectorAll(match));
|
|
360
|
+
this.#filterAndMount(els, false, true);
|
|
361
|
+
}
|
|
322
362
|
async #filterAndDismount() {
|
|
323
363
|
const returnSet = new Set();
|
|
324
364
|
if (this.#mountedList !== undefined) {
|
package/MountObserver.ts
CHANGED
|
@@ -31,7 +31,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
31
31
|
isComplex = reducedMatch.includes(' ') || (reducedMatch.includes(':') && reducedMatch.includes('('));
|
|
32
32
|
}
|
|
33
33
|
this.#isComplex = isComplex;
|
|
34
|
-
if(whereElementIntersectsWith
|
|
34
|
+
if(whereElementIntersectsWith) throw 'NI'; //not implemented
|
|
35
35
|
this.#mountInit = init;
|
|
36
36
|
this.#abortController = new AbortController();
|
|
37
37
|
this.mountedElements = {
|
|
@@ -121,6 +121,32 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
async observe(within: Node){
|
|
124
|
+
const init = this.#mountInit;
|
|
125
|
+
const {whereMediaMatches} = init;
|
|
126
|
+
if(whereMediaMatches === undefined){
|
|
127
|
+
await this.#observe2(within);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const mql = window.matchMedia(whereMediaMatches);
|
|
131
|
+
if(mql.matches){
|
|
132
|
+
await this.#observe2(within);
|
|
133
|
+
}
|
|
134
|
+
mql.addEventListener('change', async (e) => {
|
|
135
|
+
if(e.matches){
|
|
136
|
+
if(this.objNde === undefined){
|
|
137
|
+
await this.#observe2(within);
|
|
138
|
+
}else{
|
|
139
|
+
await this.#mountAll();
|
|
140
|
+
}
|
|
141
|
+
}else{
|
|
142
|
+
if(this.objNde !== undefined){
|
|
143
|
+
await this.#dismountAll();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async #observe2(within: Node){
|
|
124
150
|
await this.#selector();
|
|
125
151
|
this.objNde = new WeakRef(within);
|
|
126
152
|
const nodeToMonitor = this.#isComplex ? (within instanceof ShadowRoot ? within : within.getRootNode()) : within;
|
|
@@ -204,7 +230,6 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
204
230
|
}, {signal: this.#abortController.signal});
|
|
205
231
|
|
|
206
232
|
await this.#inspectWithin(within, true);
|
|
207
|
-
|
|
208
233
|
}
|
|
209
234
|
|
|
210
235
|
static synthesize(within: Document | ShadowRoot, customElement: {new(): HTMLElement}, mose: MOSE){
|
|
@@ -338,6 +363,20 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
338
363
|
}
|
|
339
364
|
}
|
|
340
365
|
|
|
366
|
+
async #dismountAll(){
|
|
367
|
+
const mounted = this.#mountedList;
|
|
368
|
+
if(mounted === undefined) return;
|
|
369
|
+
this.#dismount(mounted.map(x => x.deref()).filter(x => x !== undefined) as Array<Element>);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
async #mountAll(){
|
|
373
|
+
//TODO: copilot created, check if needed
|
|
374
|
+
const {whereSatisfies, whereInstanceOf} = this.#mountInit;
|
|
375
|
+
const match = await this.#selector();
|
|
376
|
+
const els = Array.from(document.querySelectorAll(match));
|
|
377
|
+
this.#filterAndMount(els, false, true);
|
|
378
|
+
}
|
|
379
|
+
|
|
341
380
|
async #filterAndDismount(): Promise<Set<Element>>{
|
|
342
381
|
const returnSet = new Set<Element>();
|
|
343
382
|
if(this.#mountedList !== undefined){
|
package/package.json
CHANGED
|
@@ -26,6 +26,7 @@ export interface EndUserProps extends IEnhancement<HTMLTemplateElement>{
|
|
|
26
26
|
*/
|
|
27
27
|
beOosoom?: string;
|
|
28
28
|
js?: string;
|
|
29
|
+
transitional: boolean;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export interface AllProps extends EndUserProps{
|
|
@@ -69,9 +70,15 @@ export interface TwoValueSwitch{
|
|
|
69
70
|
withinSpecifier?: Specifier,
|
|
70
71
|
req?: boolean,
|
|
71
72
|
op?: Op,
|
|
72
|
-
negate?: boolean,
|
|
73
|
+
//negate?: boolean,
|
|
73
74
|
lhs?: ISide,
|
|
74
75
|
rhs?: ISide,
|
|
76
|
+
onOrOff:
|
|
77
|
+
| 'on'
|
|
78
|
+
| 'On'
|
|
79
|
+
| 'off'
|
|
80
|
+
| 'Off',
|
|
81
|
+
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
export interface Dependency extends Specifier{}
|
|
@@ -128,12 +135,12 @@ export interface Elevate {
|
|
|
128
135
|
|
|
129
136
|
export interface EventForNValueSwitch {
|
|
130
137
|
ctx: NValueScriptSwitch,
|
|
131
|
-
factors: {[key: string] :
|
|
138
|
+
factors: {[key: string] : any},
|
|
132
139
|
switchOn?: boolean,
|
|
133
140
|
elevate?: Elevate
|
|
134
141
|
}
|
|
135
142
|
|
|
136
|
-
export interface SignalAndEvent {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
143
|
+
// export interface SignalAndEvent {
|
|
144
|
+
// signal?: WeakRef<SignalRefType>,
|
|
145
|
+
// eventSuggestion?: string
|
|
146
|
+
// }
|
|
@@ -356,8 +356,7 @@ export type roundaboutOptions<TProps = any, TActions = TProps, ETProps = TProps>
|
|
|
356
356
|
//onsets?: Onsets<TProps, TActions>,
|
|
357
357
|
handlers?: Handlers<ETProps, TActions>,
|
|
358
358
|
hitch?: Hitches<TProps, TActions>,
|
|
359
|
-
positractions?: Positractions<TProps
|
|
360
|
-
//do?: Partial<{[key in `${keyof TActions & string}_on`]: Keysh<TProps> }>
|
|
359
|
+
positractions?: Positractions<TProps>,
|
|
361
360
|
}
|
|
362
361
|
|
|
363
362
|
export type PropsToPartialProps<TProps = any> =
|
|
@@ -60,6 +60,7 @@ export interface TransformOptions{
|
|
|
60
60
|
propagator?: MarkedUpEventTarget,
|
|
61
61
|
propagatorIsReady?: boolean,
|
|
62
62
|
skipInit?: boolean,
|
|
63
|
+
useViewTransition?: boolean,
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
export type Derivative<TProps, TMethods, TElement = {}> =
|
|
@@ -467,11 +468,19 @@ export interface MntCfg<TProps = any, TActions = TProps, ETProps = TProps> exten
|
|
|
467
468
|
*/
|
|
468
469
|
lcXform?: XForm<TProps, TActions>,
|
|
469
470
|
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* transforms within ShadowRoot if applicable that uses view transitions
|
|
474
|
+
*/
|
|
475
|
+
xxform?: XForm<TProps, TActions>
|
|
476
|
+
|
|
470
477
|
styles?: /*CSSStyleSheet[] |*/ string | string[] | CSSStyleSheet | Array<CSSStyleSheet>;
|
|
471
478
|
|
|
472
479
|
shadowRootInit?: ShadowRootInit,
|
|
473
480
|
|
|
474
|
-
assumeCSR?: boolean
|
|
481
|
+
assumeCSR?: boolean,
|
|
482
|
+
|
|
483
|
+
|
|
475
484
|
}
|
|
476
485
|
|
|
477
486
|
export interface MountProps<TProps = any, TActions = TProps, ETProps = TProps>{
|
|
@@ -480,7 +489,7 @@ export interface MountProps<TProps = any, TActions = TProps, ETProps = TProps>{
|
|
|
480
489
|
readonly hydrated?: boolean;
|
|
481
490
|
readonly csr?: boolean;
|
|
482
491
|
readonly xform?: XForm<TProps, TActions>,
|
|
483
|
-
|
|
492
|
+
readonly xxform?: XForm<TProps, TActions>,
|
|
484
493
|
}
|
|
485
494
|
export type PMP<TProps = any, TActions = TProps, ETProps = TProps> = Partial<MountProps<TProps, TActions, ETProps>>;
|
|
486
495
|
export type ProPMP<TProps = any, TActions = TProps, ETProps = TProps> = Promise<PMP<TProps, TActions, ETProps>>
|