mount-observer 0.0.105 → 0.0.107
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/Events.js +42 -0
- package/Events.ts +45 -0
- package/MountObserver.js +14 -43
- package/MountObserver.ts +13 -37
- package/package.json +5 -1
- package/readAttrs.ts +60 -0
- package/refid/ism.js +80 -0
- package/refid/ism.ts +82 -0
- package/refid/stdVal.js +15 -0
- package/refid/stdVal.ts +15 -0
- package/ts-refs/be-consoling/types.d.ts +25 -0
- package/ts-refs/be-evanescent/types.d.ts +20 -0
- package/ts-refs/be-fetching/types.d.ts +73 -0
- package/ts-refs/be-gone/types.d.ts +24 -0
- package/ts-refs/be-intersectional/types.d.ts +37 -0
- package/ts-refs/be-lazy/types.d.ts +29 -0
- package/ts-refs/be-parsing/types.d.ts +37 -0
- package/ts-refs/do-invoke/types.d.ts +3 -3
- package/ts-refs/fetch-for/types.d.ts +37 -0
- package/ts-refs/for-fetch/doc.d.ts +98 -0
- package/ts-refs/for-fetch/types.d.ts +4 -96
- package/ts-refs/soak-up/types.d.ts +36 -0
- package/ts-refs/trans-render/froop/types.d.ts +14 -5
- package/ts-refs/trans-render/types.d.ts +4 -3
- package/ts-refs/wc-info/SimpleWCInfo.d.ts +15 -0
package/Events.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//TODO: make thes external
|
|
2
|
+
// https://github.com/webcomponents-cg/community-protocols/issues/12#issuecomment-872415080
|
|
3
|
+
/**
|
|
4
|
+
* The `mutation-event` event represents something that happened.
|
|
5
|
+
* We can document it here.
|
|
6
|
+
*/
|
|
7
|
+
export class MountEvent extends Event {
|
|
8
|
+
mountedElement;
|
|
9
|
+
initializing;
|
|
10
|
+
static eventName = 'mount';
|
|
11
|
+
constructor(mountedElement, initializing) {
|
|
12
|
+
super(MountEvent.eventName);
|
|
13
|
+
this.mountedElement = mountedElement;
|
|
14
|
+
this.initializing = initializing;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class DismountEvent extends Event {
|
|
18
|
+
dismountedElement;
|
|
19
|
+
static eventName = 'dismount';
|
|
20
|
+
constructor(dismountedElement) {
|
|
21
|
+
super(DismountEvent.eventName);
|
|
22
|
+
this.dismountedElement = dismountedElement;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class DisconnectEvent extends Event {
|
|
26
|
+
disconnectedElement;
|
|
27
|
+
static eventName = 'disconnect';
|
|
28
|
+
constructor(disconnectedElement) {
|
|
29
|
+
super(DisconnectEvent.eventName);
|
|
30
|
+
this.disconnectedElement = disconnectedElement;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export class AttrChangeEvent extends Event {
|
|
34
|
+
mountedElement;
|
|
35
|
+
attrChangeInfos;
|
|
36
|
+
static eventName = 'attrChange';
|
|
37
|
+
constructor(mountedElement, attrChangeInfos) {
|
|
38
|
+
super(AttrChangeEvent.eventName);
|
|
39
|
+
this.mountedElement = mountedElement;
|
|
40
|
+
this.attrChangeInfos = attrChangeInfos;
|
|
41
|
+
}
|
|
42
|
+
}
|
package/Events.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {MountInit, IMountObserver, AddMutationEventListener,
|
|
2
|
+
MutationEvent, dismountEventName, mountEventName, IMountEvent, IDismountEvent,
|
|
3
|
+
disconnectedEventName, IDisconnectEvent, IAttrChangeEvent, attrChangeEventName, AttrChangeInfo, loadEventName, ILoadEvent,
|
|
4
|
+
AttrParts,
|
|
5
|
+
MOSE, WeakDual,
|
|
6
|
+
MountObserverOptions,
|
|
7
|
+
Assigner,
|
|
8
|
+
RefType
|
|
9
|
+
} from './ts-refs/mount-observer/types';
|
|
10
|
+
//TODO: make thes external
|
|
11
|
+
// https://github.com/webcomponents-cg/community-protocols/issues/12#issuecomment-872415080
|
|
12
|
+
/**
|
|
13
|
+
* The `mutation-event` event represents something that happened.
|
|
14
|
+
* We can document it here.
|
|
15
|
+
*/
|
|
16
|
+
export class MountEvent extends Event implements IMountEvent {
|
|
17
|
+
static eventName: mountEventName = 'mount';
|
|
18
|
+
|
|
19
|
+
constructor(public mountedElement: Element, public initializing: boolean) {
|
|
20
|
+
super(MountEvent.eventName);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class DismountEvent extends Event implements IDismountEvent{
|
|
25
|
+
static eventName: dismountEventName = 'dismount';
|
|
26
|
+
|
|
27
|
+
constructor(public dismountedElement: Element){
|
|
28
|
+
super(DismountEvent.eventName);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class DisconnectEvent extends Event implements IDisconnectEvent{
|
|
33
|
+
static eventName: disconnectedEventName = 'disconnect';
|
|
34
|
+
|
|
35
|
+
constructor(public disconnectedElement: Element){
|
|
36
|
+
super(DisconnectEvent.eventName);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export class AttrChangeEvent extends Event implements IAttrChangeEvent{
|
|
41
|
+
static eventName: attrChangeEventName = 'attrChange';
|
|
42
|
+
constructor(public mountedElement: Element, public attrChangeInfos: Array<AttrChangeInfo>){
|
|
43
|
+
super(AttrChangeEvent.eventName);
|
|
44
|
+
}
|
|
45
|
+
}
|
package/MountObserver.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RootMutObs } from './RootMutObs.js';
|
|
2
2
|
import { bindish, bindishIt } from './bindish.js';
|
|
3
|
-
import './refid/hostish.js';
|
|
3
|
+
import './refid/hostish.js'; // gets embedded even if not used
|
|
4
4
|
export const guid = '5Pv6bHOVH0ae07opRZ8N/g';
|
|
5
5
|
export const wasItemReffed = Symbol.for('8aA6xB8+PkScmivaslBk5Q');
|
|
6
6
|
export const mutationObserverLookup = new WeakMap();
|
|
@@ -73,6 +73,7 @@ export class MountObserver extends EventTarget {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
async #compose(el, level) {
|
|
76
|
+
//[TODO]: load async, not used often
|
|
76
77
|
const src = el.getAttribute('src');
|
|
77
78
|
if (src === null || src.length < 2)
|
|
78
79
|
return;
|
|
@@ -84,6 +85,7 @@ export class MountObserver extends EventTarget {
|
|
|
84
85
|
}
|
|
85
86
|
#templLookUp = new Map();
|
|
86
87
|
#searchForComment(refName, fragment) {
|
|
88
|
+
//get rid of
|
|
87
89
|
const iterator = document.evaluate(`//comment()[.="${refName}"]`, fragment, null, XPathResult.ANY_TYPE, null);
|
|
88
90
|
//console.log({xpathResult})
|
|
89
91
|
try {
|
|
@@ -94,7 +96,9 @@ export class MountObserver extends EventTarget {
|
|
|
94
96
|
return null;
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
|
-
async findByID(
|
|
99
|
+
async findByID(
|
|
100
|
+
//[TODO]: make external, not always used
|
|
101
|
+
refName, fragment, refType) {
|
|
98
102
|
if (this.#templLookUp.has(refName))
|
|
99
103
|
return this.#templLookUp.get(refName);
|
|
100
104
|
let templ = null;
|
|
@@ -262,6 +266,7 @@ export class MountObserver extends EventTarget {
|
|
|
262
266
|
elsToInspect.push(target);
|
|
263
267
|
}
|
|
264
268
|
const deletedElements = Array.from(removedNodes).filter(x => x instanceof Element);
|
|
269
|
+
const { DisconnectEvent } = await import('./Events.js');
|
|
265
270
|
for (const deletedElement of deletedElements) {
|
|
266
271
|
this.#disconnected.add(deletedElement);
|
|
267
272
|
if (doDisconnect !== undefined) {
|
|
@@ -271,6 +276,7 @@ export class MountObserver extends EventTarget {
|
|
|
271
276
|
}
|
|
272
277
|
}
|
|
273
278
|
if (attrChangeInfosMap !== undefined) {
|
|
279
|
+
const { AttrChangeEvent } = await import('./Events.js');
|
|
274
280
|
for (const [key, value] of attrChangeInfosMap) {
|
|
275
281
|
this.dispatchEvent(new AttrChangeEvent(key, value));
|
|
276
282
|
}
|
|
@@ -283,6 +289,7 @@ export class MountObserver extends EventTarget {
|
|
|
283
289
|
await this.#inspectWithin(within, true);
|
|
284
290
|
}
|
|
285
291
|
static synthesize(within, customElement, mose) {
|
|
292
|
+
//TODO: make external
|
|
286
293
|
mose.type = 'mountobserver';
|
|
287
294
|
const name = customElements.getName(customElement);
|
|
288
295
|
if (name === null)
|
|
@@ -350,6 +357,7 @@ export class MountObserver extends EventTarget {
|
|
|
350
357
|
}
|
|
351
358
|
match[guid].add(this);
|
|
352
359
|
}
|
|
360
|
+
const { MountEvent } = await import('./Events.js');
|
|
353
361
|
this.dispatchEvent(new MountEvent(match, initializing));
|
|
354
362
|
//should we automatically call readAttrs?
|
|
355
363
|
//the thinking is it might make more sense to call that after mounting
|
|
@@ -357,6 +365,7 @@ export class MountObserver extends EventTarget {
|
|
|
357
365
|
}
|
|
358
366
|
}
|
|
359
367
|
readAttrs(match, branchIndexes) {
|
|
368
|
+
//TODO: externalize
|
|
360
369
|
const fullListOfAttrs = this.#fullListOfEnhancementAttrs;
|
|
361
370
|
const attrChangeInfos = [];
|
|
362
371
|
const oldValue = null;
|
|
@@ -409,6 +418,7 @@ export class MountObserver extends EventTarget {
|
|
|
409
418
|
}
|
|
410
419
|
async #dismount(unmatching) {
|
|
411
420
|
const onDismount = this.#mountInit.do?.dismount;
|
|
421
|
+
const { DismountEvent } = await import('./Events.js');
|
|
412
422
|
for (const unmatch of unmatching) {
|
|
413
423
|
if (onDismount !== undefined) {
|
|
414
424
|
onDismount(unmatch, this, {});
|
|
@@ -519,6 +529,7 @@ export class MountObserver extends EventTarget {
|
|
|
519
529
|
this.#filterAndMount(els, within, false, initializing);
|
|
520
530
|
}
|
|
521
531
|
}
|
|
532
|
+
//ToDO: make external
|
|
522
533
|
export function waitForIdleNodes(nodes, idleTimeout) {
|
|
523
534
|
const mountInit = {
|
|
524
535
|
idleTimeout
|
|
@@ -550,6 +561,7 @@ export function waitForIdleNodes(nodes, idleTimeout) {
|
|
|
550
561
|
}
|
|
551
562
|
});
|
|
552
563
|
}
|
|
564
|
+
//make external
|
|
553
565
|
function areAllIdle(mutObs) {
|
|
554
566
|
for (const mo of mutObs) {
|
|
555
567
|
if (!mo.isIdle)
|
|
@@ -559,45 +571,4 @@ function areAllIdle(mutObs) {
|
|
|
559
571
|
}
|
|
560
572
|
const refCountErr = 'mount-observer ref count mismatch';
|
|
561
573
|
export const inclTemplQry = 'template[src^="#"]:not([hidden]),template[src^="!"]:not([hidden])';
|
|
562
|
-
// https://github.com/webcomponents-cg/community-protocols/issues/12#issuecomment-872415080
|
|
563
|
-
/**
|
|
564
|
-
* The `mutation-event` event represents something that happened.
|
|
565
|
-
* We can document it here.
|
|
566
|
-
*/
|
|
567
|
-
export class MountEvent extends Event {
|
|
568
|
-
mountedElement;
|
|
569
|
-
initializing;
|
|
570
|
-
static eventName = 'mount';
|
|
571
|
-
constructor(mountedElement, initializing) {
|
|
572
|
-
super(MountEvent.eventName);
|
|
573
|
-
this.mountedElement = mountedElement;
|
|
574
|
-
this.initializing = initializing;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
export class DismountEvent extends Event {
|
|
578
|
-
dismountedElement;
|
|
579
|
-
static eventName = 'dismount';
|
|
580
|
-
constructor(dismountedElement) {
|
|
581
|
-
super(DismountEvent.eventName);
|
|
582
|
-
this.dismountedElement = dismountedElement;
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
export class DisconnectEvent extends Event {
|
|
586
|
-
disconnectedElement;
|
|
587
|
-
static eventName = 'disconnect';
|
|
588
|
-
constructor(disconnectedElement) {
|
|
589
|
-
super(DisconnectEvent.eventName);
|
|
590
|
-
this.disconnectedElement = disconnectedElement;
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
export class AttrChangeEvent extends Event {
|
|
594
|
-
mountedElement;
|
|
595
|
-
attrChangeInfos;
|
|
596
|
-
static eventName = 'attrChange';
|
|
597
|
-
constructor(mountedElement, attrChangeInfos) {
|
|
598
|
-
super(AttrChangeEvent.eventName);
|
|
599
|
-
this.mountedElement = mountedElement;
|
|
600
|
-
this.attrChangeInfos = attrChangeInfos;
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
574
|
//const hasRootInDefault = ['data', 'enh', 'data-enh']
|
package/MountObserver.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {MountInit, IMountObserver, AddMutationEventListener,
|
|
|
9
9
|
} from './ts-refs/mount-observer/types';
|
|
10
10
|
import {RootMutObs} from './RootMutObs.js';
|
|
11
11
|
import {bindish, bindishIt} from './bindish.js';
|
|
12
|
-
import './refid/hostish.js';
|
|
12
|
+
import './refid/hostish.js'; // gets embedded even if not used
|
|
13
13
|
export {MOSE} from './ts-refs/mount-observer/types';
|
|
14
14
|
export const guid = '5Pv6bHOVH0ae07opRZ8N/g';
|
|
15
15
|
export const wasItemReffed = Symbol.for('8aA6xB8+PkScmivaslBk5Q');
|
|
@@ -88,6 +88,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
async #compose(el: HTMLTemplateElement, level: number){
|
|
91
|
+
//[TODO]: load async, not used often
|
|
91
92
|
const src = el.getAttribute('src');
|
|
92
93
|
if(src === null || src.length < 2) return;
|
|
93
94
|
const refType = src[0] as RefType;
|
|
@@ -99,6 +100,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
99
100
|
}
|
|
100
101
|
#templLookUp: Map<string, HTMLElement> = new Map();
|
|
101
102
|
#searchForComment(refName: string, fragment: Node){
|
|
103
|
+
//get rid of
|
|
102
104
|
const iterator = document.evaluate(
|
|
103
105
|
`//comment()[.="${refName}"]`,
|
|
104
106
|
fragment,
|
|
@@ -115,6 +117,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
async findByID(
|
|
120
|
+
//[TODO]: make external, not always used
|
|
118
121
|
refName: string, fragment: DocumentFragment,
|
|
119
122
|
refType: RefType): Promise<HTMLElement | DocumentFragment | null>{
|
|
120
123
|
if(this.#templLookUp.has(refName)) return this.#templLookUp.get(refName)!;
|
|
@@ -288,6 +291,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
288
291
|
}
|
|
289
292
|
|
|
290
293
|
const deletedElements = Array.from(removedNodes).filter(x => x instanceof Element) as Array<Element>;
|
|
294
|
+
const {DisconnectEvent} = await import('./Events.js');
|
|
291
295
|
for(const deletedElement of deletedElements){
|
|
292
296
|
this.#disconnected.add(deletedElement);
|
|
293
297
|
if(doDisconnect !== undefined){
|
|
@@ -298,6 +302,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
298
302
|
|
|
299
303
|
}
|
|
300
304
|
if(attrChangeInfosMap !== undefined){
|
|
305
|
+
const {AttrChangeEvent} = await import('./Events.js');
|
|
301
306
|
for(const [key, value] of attrChangeInfosMap){
|
|
302
307
|
this.dispatchEvent(new AttrChangeEvent(key, value))
|
|
303
308
|
}
|
|
@@ -312,6 +317,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
312
317
|
}
|
|
313
318
|
|
|
314
319
|
static synthesize(within: Document | ShadowRoot, customElement: {new(): HTMLElement}, mose: MOSE){
|
|
320
|
+
//TODO: make external
|
|
315
321
|
mose.type = 'mountobserver';
|
|
316
322
|
const name = customElements.getName(customElement);
|
|
317
323
|
if(name === null) throw 400;
|
|
@@ -377,6 +383,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
377
383
|
}
|
|
378
384
|
(<any>match)[guid].add(this);
|
|
379
385
|
}
|
|
386
|
+
const {MountEvent} = await import('./Events.js');
|
|
380
387
|
this.dispatchEvent(new MountEvent(match, initializing));
|
|
381
388
|
//should we automatically call readAttrs?
|
|
382
389
|
//the thinking is it might make more sense to call that after mounting
|
|
@@ -386,6 +393,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
386
393
|
}
|
|
387
394
|
|
|
388
395
|
readAttrs(match: Element, branchIndexes?: Set<number>){
|
|
396
|
+
//TODO: externalize
|
|
389
397
|
const fullListOfAttrs = this.#fullListOfEnhancementAttrs;
|
|
390
398
|
const attrChangeInfos: Array<AttrChangeInfo> = [];
|
|
391
399
|
const oldValue = null;
|
|
@@ -440,7 +448,8 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
440
448
|
}
|
|
441
449
|
|
|
442
450
|
async #dismount(unmatching: Array<Element>){
|
|
443
|
-
const onDismount = this.#mountInit.do?.dismount
|
|
451
|
+
const onDismount = this.#mountInit.do?.dismount;
|
|
452
|
+
const {DismountEvent} = await import('./Events.js');
|
|
444
453
|
for(const unmatch of unmatching){
|
|
445
454
|
if(onDismount !== undefined){
|
|
446
455
|
onDismount(unmatch, this, {});
|
|
@@ -552,6 +561,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
552
561
|
|
|
553
562
|
}
|
|
554
563
|
|
|
564
|
+
//ToDO: make external
|
|
555
565
|
export function waitForIdleNodes(nodes: Array<Node>, idleTimeout?: number): Promise<void>{
|
|
556
566
|
const mountInit: MountInit = {
|
|
557
567
|
idleTimeout
|
|
@@ -583,6 +593,7 @@ export function waitForIdleNodes(nodes: Array<Node>, idleTimeout?: number): Prom
|
|
|
583
593
|
});
|
|
584
594
|
}
|
|
585
595
|
|
|
596
|
+
//make external
|
|
586
597
|
function areAllIdle(mutObs: Array<RootMutObs>){
|
|
587
598
|
for(const mo of mutObs){
|
|
588
599
|
if(!mo.isIdle) return false;
|
|
@@ -596,41 +607,6 @@ export const inclTemplQry = 'template[src^="#"]:not([hidden]),template[src^="!"]
|
|
|
596
607
|
|
|
597
608
|
export interface MountObserver extends IMountObserver{}
|
|
598
609
|
|
|
599
|
-
// https://github.com/webcomponents-cg/community-protocols/issues/12#issuecomment-872415080
|
|
600
|
-
/**
|
|
601
|
-
* The `mutation-event` event represents something that happened.
|
|
602
|
-
* We can document it here.
|
|
603
|
-
*/
|
|
604
|
-
export class MountEvent extends Event implements IMountEvent {
|
|
605
|
-
static eventName: mountEventName = 'mount';
|
|
606
|
-
|
|
607
|
-
constructor(public mountedElement: Element, public initializing: boolean) {
|
|
608
|
-
super(MountEvent.eventName);
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
export class DismountEvent extends Event implements IDismountEvent{
|
|
613
|
-
static eventName: dismountEventName = 'dismount';
|
|
614
|
-
|
|
615
|
-
constructor(public dismountedElement: Element){
|
|
616
|
-
super(DismountEvent.eventName);
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
export class DisconnectEvent extends Event implements IDisconnectEvent{
|
|
621
|
-
static eventName: disconnectedEventName = 'disconnect';
|
|
622
|
-
|
|
623
|
-
constructor(public disconnectedElement: Element){
|
|
624
|
-
super(DisconnectEvent.eventName);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
export class AttrChangeEvent extends Event implements IAttrChangeEvent{
|
|
629
|
-
static eventName: attrChangeEventName = 'attrChange';
|
|
630
|
-
constructor(public mountedElement: Element, public attrChangeInfos: Array<AttrChangeInfo>){
|
|
631
|
-
super(AttrChangeEvent.eventName);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
610
|
|
|
635
611
|
|
|
636
612
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mount-observer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.107",
|
|
4
4
|
"description": "Observe and act on css matches.",
|
|
5
5
|
"main": "MountObserver.js",
|
|
6
6
|
"module": "MountObserver.js",
|
|
@@ -69,6 +69,10 @@
|
|
|
69
69
|
"default": "./refid/getCount.js",
|
|
70
70
|
"types": "./refid/getCount.ts"
|
|
71
71
|
},
|
|
72
|
+
"./refid/ism.js": {
|
|
73
|
+
"default": "./refid/ism.js",
|
|
74
|
+
"types": "./refid/ism.ts"
|
|
75
|
+
},
|
|
72
76
|
"./refid/itemprops.js": {
|
|
73
77
|
"default": "./refid/itemprops.js",
|
|
74
78
|
"types": "./refid/itemprops.ts"
|
package/readAttrs.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AttrChangeInfo, AttrParts, MountInit } from "./ts-refs/mount-observer/types";
|
|
2
|
+
|
|
3
|
+
export function readAttrs(
|
|
4
|
+
match: Element, mountInit: MountInit, branchIndexes?: Set<number>,
|
|
5
|
+
fullListOfEnhancementAttrs?: string[],
|
|
6
|
+
attrParts?: AttrParts[],
|
|
7
|
+
){
|
|
8
|
+
//TODO: externalize
|
|
9
|
+
const fullListOfAttrs = fullListOfEnhancementAttrs;
|
|
10
|
+
const attrChangeInfos: Array<AttrChangeInfo> = [];
|
|
11
|
+
const oldValue = null;
|
|
12
|
+
if(fullListOfAttrs !== undefined){
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
for(let idx = 0, ii = fullListOfAttrs.length; idx < ii; idx++){
|
|
16
|
+
const parts = attrParts![idx];
|
|
17
|
+
const {branchIdx} = parts;
|
|
18
|
+
if(branchIndexes !== undefined){
|
|
19
|
+
if(!branchIndexes.has(branchIdx)) continue;
|
|
20
|
+
}
|
|
21
|
+
const name = fullListOfAttrs[idx];
|
|
22
|
+
|
|
23
|
+
const newValue = match.getAttribute(name);
|
|
24
|
+
|
|
25
|
+
attrChangeInfos.push({
|
|
26
|
+
idx,
|
|
27
|
+
isSOfTAttr: false,
|
|
28
|
+
newValue,
|
|
29
|
+
oldValue,
|
|
30
|
+
name,
|
|
31
|
+
parts
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
const {observedAttrsWhenMounted} = mountInit;
|
|
37
|
+
if(observedAttrsWhenMounted !== undefined){
|
|
38
|
+
for(const observedAttr of observedAttrsWhenMounted){
|
|
39
|
+
const attrIsString = typeof observedAttr === 'string';
|
|
40
|
+
const name = attrIsString ? observedAttr : observedAttr.name;
|
|
41
|
+
let mapsTo: string | undefined;
|
|
42
|
+
let newValue = match.getAttribute(name);
|
|
43
|
+
if(!attrIsString){
|
|
44
|
+
const {customParser, instanceOf, mapsTo: mt, valIfNull} = observedAttr;
|
|
45
|
+
if(instanceOf || customParser) throw 'NI';
|
|
46
|
+
if(newValue === null) newValue = valIfNull;
|
|
47
|
+
mapsTo = mt;
|
|
48
|
+
}
|
|
49
|
+
attrChangeInfos.push({
|
|
50
|
+
isSOfTAttr: true,
|
|
51
|
+
newValue,
|
|
52
|
+
oldValue,
|
|
53
|
+
name,
|
|
54
|
+
mapsTo
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return attrChangeInfos;
|
|
60
|
+
}
|
package/refid/ism.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { upShadowSearch } from '../upShadowSearch.js';
|
|
2
|
+
import { stdVal } from './stdVal.js';
|
|
3
|
+
Object.defineProperty(HTMLElement.prototype, 'ishm', {
|
|
4
|
+
get() {
|
|
5
|
+
const el = this;
|
|
6
|
+
return parse(el);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
const parsedItempropmaps = new WeakMap();
|
|
10
|
+
export function parse(el, obj = {}) {
|
|
11
|
+
const itemprop = el.getAttribute('itemprop');
|
|
12
|
+
if (itemprop) {
|
|
13
|
+
obj[itemprop] = stdVal(el); //TODO full logic
|
|
14
|
+
}
|
|
15
|
+
const itempropmap = el.getAttribute('itempropmap');
|
|
16
|
+
if (itempropmap) {
|
|
17
|
+
//const el = document.getElementById(itempropmap);
|
|
18
|
+
const jsonEl = upShadowSearch(el, itempropmap);
|
|
19
|
+
if (!jsonEl)
|
|
20
|
+
throw 500;
|
|
21
|
+
if (!parsedItempropmaps.has(jsonEl)) {
|
|
22
|
+
parsedItempropmaps.set(jsonEl, JSON.parse(jsonEl.innerHTML));
|
|
23
|
+
}
|
|
24
|
+
const parsed = /** @type {ItemPropMap} */ (parsedItempropmaps.get(jsonEl));
|
|
25
|
+
for (const key in parsed) {
|
|
26
|
+
const attr = el.getAttribute(key);
|
|
27
|
+
if (attr === null)
|
|
28
|
+
continue;
|
|
29
|
+
const rhs = parsed[key];
|
|
30
|
+
switch (typeof rhs) {
|
|
31
|
+
case 'string':
|
|
32
|
+
obj[rhs] = attr;
|
|
33
|
+
break;
|
|
34
|
+
case 'object':
|
|
35
|
+
const { instanceOf, mapsTo } = rhs;
|
|
36
|
+
switch (instanceOf) {
|
|
37
|
+
case 'Number':
|
|
38
|
+
case Number:
|
|
39
|
+
obj[mapsTo] = Number(attr);
|
|
40
|
+
break;
|
|
41
|
+
case 'Object':
|
|
42
|
+
case Object:
|
|
43
|
+
case 'Boolean':
|
|
44
|
+
case Boolean:
|
|
45
|
+
obj[mapsTo] = JSON.parse(attr);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//el.ish = obj;
|
|
52
|
+
const children = Array.from(el.children);
|
|
53
|
+
const isItemScoped = el.hasAttribute('itemscope');
|
|
54
|
+
let itemscopeMap;
|
|
55
|
+
if (isItemScoped) {
|
|
56
|
+
itemscopeMap = {};
|
|
57
|
+
}
|
|
58
|
+
for (const child of children) {
|
|
59
|
+
if (!(child instanceof HTMLElement))
|
|
60
|
+
continue;
|
|
61
|
+
const objToPass = child.hasAttribute('itemscope') ? {} : obj;
|
|
62
|
+
parse(child, objToPass);
|
|
63
|
+
const isItemScopeAndChildHasBothItempropAndItemscope = itemscopeMap && child.hasAttribute('itemprop') && child.hasAttribute('itemscope');
|
|
64
|
+
if (isItemScopeAndChildHasBothItempropAndItemscope) {
|
|
65
|
+
const itemprops = child.getAttribute('itemprop').split(" ").filter(x => x);
|
|
66
|
+
for (const itemprop of itemprops) {
|
|
67
|
+
if (!itemscopeMap[itemprop])
|
|
68
|
+
itemscopeMap[itemprop] = [];
|
|
69
|
+
itemscopeMap[itemprop].push(objToPass);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// if(itemscopeMap){
|
|
74
|
+
// el.ism = itemscopeMap;
|
|
75
|
+
// }
|
|
76
|
+
return {
|
|
77
|
+
obj,
|
|
78
|
+
itemscopeMap
|
|
79
|
+
};
|
|
80
|
+
}
|
package/refid/ism.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {upShadowSearch} from '../upShadowSearch.js';
|
|
2
|
+
import {stdVal} from './stdVal.js';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(HTMLElement.prototype, 'ishm', {
|
|
5
|
+
get(){
|
|
6
|
+
const el = this as HTMLElement;
|
|
7
|
+
return parse(el);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const parsedItempropmaps = new WeakMap<HTMLScriptElement, any>();
|
|
12
|
+
|
|
13
|
+
export function parse(el: HTMLElement, obj: any = {}){
|
|
14
|
+
const itemprop = el.getAttribute('itemprop');
|
|
15
|
+
if(itemprop){
|
|
16
|
+
obj[itemprop] = stdVal(el); //TODO full logic
|
|
17
|
+
}
|
|
18
|
+
const itempropmap = el.getAttribute('itempropmap');
|
|
19
|
+
if(itempropmap){
|
|
20
|
+
//const el = document.getElementById(itempropmap);
|
|
21
|
+
const jsonEl = upShadowSearch(el, itempropmap)
|
|
22
|
+
if(!jsonEl) throw 500;
|
|
23
|
+
if(!parsedItempropmaps.has(jsonEl)){
|
|
24
|
+
parsedItempropmaps.set(jsonEl, JSON.parse(jsonEl.innerHTML));
|
|
25
|
+
}
|
|
26
|
+
const parsed =/** @type {ItemPropMap} */ (parsedItempropmaps.get(jsonEl));
|
|
27
|
+
for(const key in parsed){
|
|
28
|
+
const attr = el.getAttribute(key);
|
|
29
|
+
if(attr === null) continue;
|
|
30
|
+
const rhs = parsed[key];
|
|
31
|
+
switch(typeof rhs){
|
|
32
|
+
case 'string':
|
|
33
|
+
obj[rhs] = attr;
|
|
34
|
+
break;
|
|
35
|
+
case 'object':
|
|
36
|
+
const {instanceOf, mapsTo} = rhs;
|
|
37
|
+
switch(instanceOf){
|
|
38
|
+
case 'Number':
|
|
39
|
+
case Number:
|
|
40
|
+
obj[mapsTo] = Number(attr);
|
|
41
|
+
break;
|
|
42
|
+
case 'Object':
|
|
43
|
+
case Object:
|
|
44
|
+
case 'Boolean':
|
|
45
|
+
case Boolean:
|
|
46
|
+
obj[mapsTo] = JSON.parse(attr);
|
|
47
|
+
break;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
//el.ish = obj;
|
|
56
|
+
const children = Array.from(el.children);
|
|
57
|
+
const isItemScoped = el.hasAttribute('itemscope');
|
|
58
|
+
let itemscopeMap: {[key: string] : any[]} | undefined;
|
|
59
|
+
if(isItemScoped){
|
|
60
|
+
itemscopeMap = {};
|
|
61
|
+
}
|
|
62
|
+
for(const child of children){
|
|
63
|
+
if(!(child instanceof HTMLElement)) continue;
|
|
64
|
+
const objToPass = child.hasAttribute('itemscope') ? {} : obj;
|
|
65
|
+
parse(child, objToPass);
|
|
66
|
+
const isItemScopeAndChildHasBothItempropAndItemscope = itemscopeMap && child.hasAttribute('itemprop') && child.hasAttribute('itemscope');
|
|
67
|
+
if(isItemScopeAndChildHasBothItempropAndItemscope){
|
|
68
|
+
const itemprops = child.getAttribute('itemprop')!.split(" ").filter(x => x);
|
|
69
|
+
for(const itemprop of itemprops){
|
|
70
|
+
if(!itemscopeMap![itemprop]) itemscopeMap![itemprop] = [];
|
|
71
|
+
itemscopeMap![itemprop].push(objToPass);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// if(itemscopeMap){
|
|
76
|
+
// el.ism = itemscopeMap;
|
|
77
|
+
// }
|
|
78
|
+
return {
|
|
79
|
+
obj,
|
|
80
|
+
itemscopeMap
|
|
81
|
+
};
|
|
82
|
+
}
|
package/refid/stdVal.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function stdVal(el) {
|
|
2
|
+
const { localName } = el;
|
|
3
|
+
switch (localName) {
|
|
4
|
+
case 'form':
|
|
5
|
+
throw 'NI';
|
|
6
|
+
case 'input':
|
|
7
|
+
throw 'NI';
|
|
8
|
+
case 'a':
|
|
9
|
+
return el.href;
|
|
10
|
+
case 'data':
|
|
11
|
+
return JSON.parse(el.value);
|
|
12
|
+
default:
|
|
13
|
+
return el.textContent;
|
|
14
|
+
}
|
|
15
|
+
}
|
package/refid/stdVal.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function stdVal(el: Element){
|
|
2
|
+
const {localName} = el;
|
|
3
|
+
switch(localName){
|
|
4
|
+
case 'form':
|
|
5
|
+
throw 'NI';
|
|
6
|
+
case 'input':
|
|
7
|
+
throw 'NI';
|
|
8
|
+
case 'a':
|
|
9
|
+
return (el as HTMLAnchorElement).href;
|
|
10
|
+
case 'data':
|
|
11
|
+
return JSON.parse((el as HTMLDataElement).value);
|
|
12
|
+
default:
|
|
13
|
+
return el.textContent;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {IEnhancement, BEAllProps, EMC} from '../trans-render/be/types';
|
|
2
|
+
|
|
3
|
+
export interface EndUserProps extends IEnhancement{
|
|
4
|
+
level:
|
|
5
|
+
| 'log'
|
|
6
|
+
| 'warn'
|
|
7
|
+
| 'error',
|
|
8
|
+
ignore: string[]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface AllProps extends EndUserProps{}
|
|
12
|
+
|
|
13
|
+
export type AP = AllProps;
|
|
14
|
+
|
|
15
|
+
export type PAP = Partial<AP>;
|
|
16
|
+
|
|
17
|
+
export type ProPAP = Promise<PAP>;
|
|
18
|
+
|
|
19
|
+
export type BAP = AP & BEAllProps;
|
|
20
|
+
|
|
21
|
+
export interface Actions {
|
|
22
|
+
hydrate(self: BAP): PAP;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type dispatch = (event: Event) => boolean ;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {IEnhancement, BEAllProps, EMC} from '../trans-render/be/types';
|
|
2
|
+
|
|
3
|
+
export interface EndUserProps extends IEnhancement{
|
|
4
|
+
whenDefined: string[];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface AllProps extends EndUserProps{
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type AP = AllProps;
|
|
11
|
+
|
|
12
|
+
export type PAP = Partial<AP>;
|
|
13
|
+
|
|
14
|
+
export type ProPAP = Promise<PAP>;
|
|
15
|
+
|
|
16
|
+
export type BAP = AP & BEAllProps;
|
|
17
|
+
|
|
18
|
+
export interface Actions{
|
|
19
|
+
//onWhenDefined(self: BAP): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {IEnhancement, BEAllProps, EMC} from '../trans-render/be/types';
|
|
2
|
+
|
|
3
|
+
export interface EndUserProps extends IEnhancement{
|
|
4
|
+
pre?: string,
|
|
5
|
+
post?: string,
|
|
6
|
+
on?: string,
|
|
7
|
+
eventName?: string,
|
|
8
|
+
eventCount?: number,
|
|
9
|
+
debounceDuration?: number,
|
|
10
|
+
options?: FetchOptions,
|
|
11
|
+
urlProp: string,
|
|
12
|
+
baseLink?: string,
|
|
13
|
+
}
|
|
14
|
+
export interface AllProps extends EndUserProps {
|
|
15
|
+
value: any;
|
|
16
|
+
interpolating: boolean;
|
|
17
|
+
full: boolean;
|
|
18
|
+
url: string;
|
|
19
|
+
urlEcho: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface FetchOptions {
|
|
23
|
+
|
|
24
|
+
init?: RequestInit,
|
|
25
|
+
authorization?:{
|
|
26
|
+
winObj?: 'sessionStorage' | 'localStorage',
|
|
27
|
+
key?: string
|
|
28
|
+
val?: string,
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
//headers?: {[key: string]: string},
|
|
32
|
+
//headerFormSelector?: string,
|
|
33
|
+
//headerFormSubmitOn?: string | string[],
|
|
34
|
+
//valObservePairs: ValObservePairs;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// export interface ValObservePairs{
|
|
38
|
+
// authorization?: IObserve,
|
|
39
|
+
// authorizationVal?: string,
|
|
40
|
+
// body?: IObserve,
|
|
41
|
+
// bodyVal?: any,
|
|
42
|
+
// cache?: IObserve<'default' | 'no-store' | 'reload' | 'no-cache' | 'force-cache' | 'only-if-cached'>,
|
|
43
|
+
// cacheVal?: 'default' | 'no-store' | 'reload' | 'no-cache' | 'force-cache' | 'only-if-cached',
|
|
44
|
+
// contentType?: IObserve,
|
|
45
|
+
// contentTypeVal?: string,
|
|
46
|
+
// credentials?: IObserve<'omit' | 'same-origin' | 'include'>,
|
|
47
|
+
// credentialsVal?: 'omit' | 'same-origin' | 'include',
|
|
48
|
+
// method?: IObserve<'GET' | 'POST' | 'PUT' | 'DELETE'>,
|
|
49
|
+
// methodVal?: 'GET' | 'POST' | 'PUT' | 'DELETE',
|
|
50
|
+
// mode?: IObserve<'cors' | 'no-cors' | 'same-origin' | 'navigate'>,
|
|
51
|
+
// modeVal?: 'cors' | 'no-cors' | 'same-origin' | 'navigate',
|
|
52
|
+
// redirect?: IObserve<'follow' | 'error' | 'manual'>,
|
|
53
|
+
// redirectVal?: 'follow' | 'error' | 'manual',
|
|
54
|
+
// referrerPolicy?: IObserve<'no-referrer' | 'no-referrer-when-downgrade' | 'same-origin' | 'origin' | 'strict-origin' | 'origin-when-cross-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url'>,
|
|
55
|
+
// referrerPolicyVal?: 'no-referrer' | 'no-referrer-when-downgrade' | 'same-origin' | 'origin' | 'strict-origin' | 'origin-when-cross-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url',
|
|
56
|
+
// }
|
|
57
|
+
|
|
58
|
+
export interface AllProps extends EndUserProps {}
|
|
59
|
+
|
|
60
|
+
export type AP = AllProps;
|
|
61
|
+
|
|
62
|
+
export type PAP = Partial<AP>;
|
|
63
|
+
|
|
64
|
+
export type ProPAP = Promise<PAP>;
|
|
65
|
+
|
|
66
|
+
export type BAP = AP & BEAllProps;
|
|
67
|
+
|
|
68
|
+
export interface Actions{
|
|
69
|
+
setUp(self: BAP): PAP;
|
|
70
|
+
interpolateIfValid(self: BAP): PAP | void;
|
|
71
|
+
setFullUrlIfValid(self: BAP): PAP | void;
|
|
72
|
+
fetchWhenSettled(self: BAP): Promise<PAP | void>;
|
|
73
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {IEnhancement, BEAllProps, EMC} from '../trans-render/be/types';
|
|
2
|
+
|
|
3
|
+
export interface EndUserProps extends IEnhancement{
|
|
4
|
+
whenMissing: string
|
|
5
|
+
onDefined: Array<string>
|
|
6
|
+
whenDef: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface AllProps extends EndUserProps{
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type AP = AllProps;
|
|
13
|
+
|
|
14
|
+
export type PAP = Partial<AP>;
|
|
15
|
+
|
|
16
|
+
export type ProPAP = Promise<PAP>;
|
|
17
|
+
|
|
18
|
+
export type BAP = AP & BEAllProps;
|
|
19
|
+
|
|
20
|
+
export interface Actions{
|
|
21
|
+
onOnDefined(self: BAP): ProPAP
|
|
22
|
+
hydrateOnMissing(self: BAP): ProPAP
|
|
23
|
+
parseWhenDef(self: BAP): PAP
|
|
24
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {IEnhancement, BEAllProps} from '../trans-render/be/types';
|
|
2
|
+
|
|
3
|
+
export interface EndUserProps extends IEnhancement{
|
|
4
|
+
options: IntersectionObserverInit;
|
|
5
|
+
rootClosest?: string;
|
|
6
|
+
observeClosest?: string;
|
|
7
|
+
enterDelay?: number;
|
|
8
|
+
exitDelay?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface AP extends EndUserProps{
|
|
12
|
+
isIntersecting: boolean;
|
|
13
|
+
isIntersectingEcho: boolean;
|
|
14
|
+
isNotIntersecting: boolean;
|
|
15
|
+
isNotIntersectingEcho: boolean;
|
|
16
|
+
}
|
|
17
|
+
export type PAP = Partial<AP>;
|
|
18
|
+
export type ProPAP = Promise<PAP>;
|
|
19
|
+
export type BAP = AP & BEAllProps;
|
|
20
|
+
|
|
21
|
+
export interface IntersectionalActions {
|
|
22
|
+
onOptions(self: AP & BEAllProps): PAP;
|
|
23
|
+
// onIntersectingChange(self: AP & BEAllProps): void;
|
|
24
|
+
// onNonIntersectingEcho(self: AP & BEAllProps)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface Actions extends IntersectionalActions{
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
onIntersecting(self: this): void;
|
|
31
|
+
|
|
32
|
+
onNotIntersecting(self: this): void;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
//onNotIntersectingEcho(self: this): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EndUserProps as BeIntersectiontalEndUserProps,
|
|
3
|
+
AP as BeIntersectionalAllProps,
|
|
4
|
+
BeIntersectionalActions,
|
|
5
|
+
} from '../../node_modules/be-intersectional/types';
|
|
6
|
+
import { BEAllProps } from '../be-enhanced/types';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export interface EndUserProps extends BeIntersectiontalEndUserProps{
|
|
10
|
+
//transform?: {[key: string]: MatchRHS};
|
|
11
|
+
//host: any;
|
|
12
|
+
//ctx: RenderContext;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface AllProps extends BeIntersectionalAllProps, EndUserProps{}
|
|
16
|
+
|
|
17
|
+
export type AP = AllProps;
|
|
18
|
+
|
|
19
|
+
export type PAP = Partial<AP>;
|
|
20
|
+
|
|
21
|
+
export type ProPAP = Promise<PAP>;
|
|
22
|
+
|
|
23
|
+
export type BAP = AP & BEAllProps;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export interface BeLazyActions extends BeIntersectionalActions{
|
|
27
|
+
onIntersecting(self: AP & BEAllProps): void
|
|
28
|
+
onOptions(self: AP & BEAllProps): PAP;
|
|
29
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {IEnhancement, BEAllProps, EMC} from '../trans-render/be/types';
|
|
2
|
+
|
|
3
|
+
export interface EndUserProps extends IEnhancement{
|
|
4
|
+
nudges: boolean
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface AllProps extends EndUserProps{
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type AP = AllProps;
|
|
11
|
+
|
|
12
|
+
export type PAP = Partial<AP>;
|
|
13
|
+
|
|
14
|
+
export type ProPAP = Promise<PAP>;
|
|
15
|
+
|
|
16
|
+
export type BAP = AP & BEAllProps;
|
|
17
|
+
|
|
18
|
+
export interface Actions{
|
|
19
|
+
do(self: BAP): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface AttrInfo {
|
|
23
|
+
instanceOf:
|
|
24
|
+
| String
|
|
25
|
+
| 'String'
|
|
26
|
+
| Object
|
|
27
|
+
| 'Object'
|
|
28
|
+
| Number
|
|
29
|
+
| 'Number'
|
|
30
|
+
| Boolean
|
|
31
|
+
| 'Boolean'
|
|
32
|
+
mapsTo: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type RHS = string | AttrInfo;
|
|
36
|
+
|
|
37
|
+
export type ItemPropMap = {[key: string]: RHS}
|
|
@@ -2,11 +2,11 @@ import {IEnhancement, BEAllProps} from '../trans-render/be/types';
|
|
|
2
2
|
import { Specifier } from '../trans-render/dss/types';
|
|
3
3
|
|
|
4
4
|
export interface EndUserProps extends IEnhancement{
|
|
5
|
-
|
|
5
|
+
invokeParamSets: Array<InvokingParameters>,
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface AP extends EndUserProps{
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
rawStatements: Array<string>,
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -19,7 +19,7 @@ export type ProPAP = Promise<PAP>
|
|
|
19
19
|
export type BAP = AP & BEAllProps;
|
|
20
20
|
|
|
21
21
|
export interface Actions{
|
|
22
|
-
hydrate(self:
|
|
22
|
+
hydrate(self: BAP): ProPAP;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export interface InvokingParameters {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {IEnhancement, BEAllProps, EMC} from '../trans-render/be/types';
|
|
2
|
+
import { Specifier } from '../trans-render/dss/types';
|
|
3
|
+
|
|
4
|
+
interface FetchReadyEvent {
|
|
5
|
+
url: string
|
|
6
|
+
options: RequestInit
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface EndUserProps extends IEnhancement{
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AllProps extends EndUserProps{
|
|
15
|
+
//evtCount: number,
|
|
16
|
+
fetchReadyEvent: FetchReadyEvent
|
|
17
|
+
rawStatements: Array<string>
|
|
18
|
+
fetchForParams: Array<FetchForParameters>
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type AP = AllProps;
|
|
23
|
+
|
|
24
|
+
export type PAP = Partial<AP>;
|
|
25
|
+
|
|
26
|
+
export type ProPAP = Promise<PAP>;
|
|
27
|
+
|
|
28
|
+
export type BAP = AP & BEAllProps;
|
|
29
|
+
|
|
30
|
+
export interface Actions{
|
|
31
|
+
hydrate(self: BAP): PAP;
|
|
32
|
+
doFetch(self: BAP): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface FetchForParameters {
|
|
36
|
+
remoteSpecifier: Specifier
|
|
37
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
|
|
2
|
+
import {SimpleWCInfo} from '../wc-info/SimpleWCInfo';
|
|
3
|
+
|
|
4
|
+
export interface EndUserProps {
|
|
5
|
+
|
|
6
|
+
accept?: string,
|
|
7
|
+
/**
|
|
8
|
+
* Url to invoke
|
|
9
|
+
* @readonly true
|
|
10
|
+
*/
|
|
11
|
+
src?: string,
|
|
12
|
+
|
|
13
|
+
':src': string,
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Specifier for list of form associated or contentEditable peer elements that
|
|
17
|
+
* should partake in forming the URL.
|
|
18
|
+
*/
|
|
19
|
+
for?: string,
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Indicates whether to treat the response as HTML or JSON or Text
|
|
23
|
+
*/
|
|
24
|
+
as?: 'html' | 'json' | 'text',
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The http verb to be used for the request
|
|
28
|
+
*/
|
|
29
|
+
method?:
|
|
30
|
+
| 'GET'
|
|
31
|
+
| 'HEAD'
|
|
32
|
+
| 'POST'
|
|
33
|
+
| 'PUT'
|
|
34
|
+
| 'DELETE'
|
|
35
|
+
| 'OPTIONS'
|
|
36
|
+
| 'TRACE'
|
|
37
|
+
| 'PATCH',
|
|
38
|
+
/**
|
|
39
|
+
* Either the JSON stringified or the parsed JSON object
|
|
40
|
+
* If parsed, the web component will stringify it.
|
|
41
|
+
*/
|
|
42
|
+
body?: any,
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Request credentials
|
|
46
|
+
*/
|
|
47
|
+
credentials?: RequestCredentials,
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Directed Scoped Specifier to the
|
|
51
|
+
* DOM element where the retrieved content should be applied.
|
|
52
|
+
*/
|
|
53
|
+
target?: string,
|
|
54
|
+
/**
|
|
55
|
+
* If as=html, specify whether to (stream) the contents into an attached shadow DOM or not.
|
|
56
|
+
*/
|
|
57
|
+
shadow?: ShadowRootMode,
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Do not cache results even if the url has been invoked before.
|
|
61
|
+
*/
|
|
62
|
+
noCache?: boolean,
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Stream the contents into the target element
|
|
66
|
+
*/
|
|
67
|
+
stream?: boolean,
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Directed Scoped Specifier to a
|
|
71
|
+
* (button) element, to delay submitting the fetch request until that button is clicked.
|
|
72
|
+
*/
|
|
73
|
+
when?: string,
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Directed Scoped Specifier to a form element
|
|
77
|
+
* that we should use to form the url and body from.
|
|
78
|
+
*/
|
|
79
|
+
form?: string,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* fetch-for web component
|
|
84
|
+
*/
|
|
85
|
+
export abstract class ForFetchInfo implements SimpleWCInfo {
|
|
86
|
+
src: './for-fetch.js';
|
|
87
|
+
tagName: 'for-fetch';
|
|
88
|
+
props: EndUserProps;
|
|
89
|
+
name: 'for-fetch';
|
|
90
|
+
homepage: 'https://github.com/bahrus/for-fetch';
|
|
91
|
+
license: 'MIT';
|
|
92
|
+
description: 'Base web component for fetch'
|
|
93
|
+
cssParts: {
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type Package = [ForFetchInfo];
|
|
@@ -1,91 +1,12 @@
|
|
|
1
1
|
import { JSONObject } from '../trans-render/lib/types';
|
|
2
2
|
import { Specifier } from '../trans-render/dss/types';
|
|
3
3
|
import { URLBuilder } from '../../URLBuilder';
|
|
4
|
-
|
|
4
|
+
import {SimpleWCInfo} from '../wc-info/SimpleWCInfo';
|
|
5
|
+
import {EndUserProps} from './doc';
|
|
6
|
+
export {EndUserProps} from './doc';
|
|
5
7
|
|
|
6
8
|
declare class WeakRef<TProps = any>{}
|
|
7
|
-
/**
|
|
8
|
-
* fetch-for props
|
|
9
|
-
*/
|
|
10
|
-
export interface EndUserProps{
|
|
11
|
-
|
|
12
|
-
accept?: string,
|
|
13
|
-
/**
|
|
14
|
-
* Url to invoke
|
|
15
|
-
* @readonly true
|
|
16
|
-
*/
|
|
17
|
-
src?: string,
|
|
18
|
-
|
|
19
|
-
':src': string,
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Specifier for list of form associated or contentEditable peer elements that
|
|
23
|
-
* should partake in forming the URL.
|
|
24
|
-
*/
|
|
25
|
-
for?: string,
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Indicates whether to treat the response as HTML or JSON or Text
|
|
29
|
-
*/
|
|
30
|
-
as?: 'html' | 'json' | 'text',
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The http verb to be used for the request
|
|
34
|
-
*/
|
|
35
|
-
method?:
|
|
36
|
-
| 'GET'
|
|
37
|
-
| 'HEAD'
|
|
38
|
-
| 'POST'
|
|
39
|
-
| 'PUT'
|
|
40
|
-
| 'DELETE'
|
|
41
|
-
| 'OPTIONS'
|
|
42
|
-
| 'TRACE'
|
|
43
|
-
| 'PATCH',
|
|
44
|
-
/**
|
|
45
|
-
* Either the JSON stringified or the parsed JSON object
|
|
46
|
-
* If parsed, the web component will stringify it.
|
|
47
|
-
*/
|
|
48
|
-
body?: any,
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Request credentials
|
|
52
|
-
*/
|
|
53
|
-
credentials?: RequestCredentials,
|
|
54
9
|
|
|
55
|
-
/**
|
|
56
|
-
* Directed Scoped Specifier to the
|
|
57
|
-
* DOM element where the retrieved content should be applied.
|
|
58
|
-
*/
|
|
59
|
-
target?: string,
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* If as=html, specify whether to (stream) the contents into an attached shadow DOM or not.
|
|
63
|
-
*/
|
|
64
|
-
shadow?: ShadowRootMode,
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Do not cache results even if the url has been invoked before.
|
|
68
|
-
*/
|
|
69
|
-
noCache?: boolean,
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Stream the contents into the target element
|
|
73
|
-
*/
|
|
74
|
-
stream?: boolean,
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Directed Scoped Specifier to a
|
|
78
|
-
* (button) element, to delay submitting the fetch request until that button is clicked.
|
|
79
|
-
*/
|
|
80
|
-
when?: string,
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Directed Scoped Specifier to a form element
|
|
84
|
-
* that we should use to form the url and body from.
|
|
85
|
-
*/
|
|
86
|
-
form?: string,
|
|
87
|
-
|
|
88
|
-
}
|
|
89
10
|
|
|
90
11
|
export interface OverridableGetters{
|
|
91
12
|
//request$: RequestInit,
|
|
@@ -138,7 +59,7 @@ export interface Actions{
|
|
|
138
59
|
parseTarget(self: this): ProPP;
|
|
139
60
|
// listenForInput(self: this): ProPP;
|
|
140
61
|
// doInitialLoad(self: this): ProPP;
|
|
141
|
-
initializeWhen(self: this): Promise<
|
|
62
|
+
initializeWhen(self: this): Promise<PAP | undefined>;
|
|
142
63
|
// onForm(self: this): ProPP;
|
|
143
64
|
// onFormSpecifier(self: this): ProPP;
|
|
144
65
|
// onFormRef(self: this): Promise<void>,
|
|
@@ -159,17 +80,4 @@ export interface EventForFetch {
|
|
|
159
80
|
|
|
160
81
|
export type ForData = {[key: string]: HTMLInputElement}
|
|
161
82
|
|
|
162
|
-
// /**
|
|
163
|
-
// * fetch-for web component
|
|
164
|
-
// */
|
|
165
|
-
// export abstract class ForFetchInfo implements SimpleWCInfo {
|
|
166
|
-
// src: './for-fetch.js';
|
|
167
|
-
// tagName: 'for-fetch';
|
|
168
|
-
// props: EndUserProps;
|
|
169
|
-
// cssParts: {
|
|
170
|
-
|
|
171
|
-
// }
|
|
172
|
-
// }
|
|
173
|
-
|
|
174
|
-
// export type Package = [ForFetchInfo];
|
|
175
83
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {IEnhancement, BEAllProps, EMC} from '../trans-render/be/types';
|
|
2
|
+
import { Specifier } from "../trans-render/dss/types";
|
|
3
|
+
|
|
4
|
+
export interface EndUserProps extends IEnhancement{
|
|
5
|
+
soakUpRules: SoakUpRule[]
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface AllProps extends EndUserProps{
|
|
9
|
+
|
|
10
|
+
fullyParsed?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type AP = AllProps;
|
|
14
|
+
|
|
15
|
+
export type PAP = Partial<AP>;
|
|
16
|
+
|
|
17
|
+
export type ProPAP = Promise<PAP>;
|
|
18
|
+
|
|
19
|
+
export type BAP = AP & BEAllProps;
|
|
20
|
+
|
|
21
|
+
export interface Actions{
|
|
22
|
+
fullyParse(self: BAP): PAP;
|
|
23
|
+
hydrate(self: BAP): ProPAP;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface PropMap {
|
|
27
|
+
srcProp: string,
|
|
28
|
+
destProp?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface SoakUpRule {
|
|
32
|
+
propMap: string
|
|
33
|
+
sourceSpecifier: Specifier
|
|
34
|
+
sourceSpecifierString: string
|
|
35
|
+
parsedPropMap: PropMap[]
|
|
36
|
+
}
|
|
@@ -115,8 +115,11 @@ export interface OConfig<TProps = any, TActions = TProps, ETProps = TProps> exte
|
|
|
115
115
|
export type Positractions<TProps = any, TActions = TProps> =
|
|
116
116
|
| Array<Positraction<TProps, TActions>>;
|
|
117
117
|
|
|
118
|
-
export interface Positraction<TProps = any, TActions = TProps> extends LogicOp<TProps> {
|
|
119
|
-
do:
|
|
118
|
+
export interface Positraction<TProps = any, TActions = TProps> extends LogicOp<TProps, TActions> {
|
|
119
|
+
do:
|
|
120
|
+
| Function
|
|
121
|
+
| (keyof TActions & string)
|
|
122
|
+
| PropsToProps<TProps>
|
|
120
123
|
ifKeyIn?: Array<keyof TProps & string>,
|
|
121
124
|
ifAllOf?: Array<keyof TProps & string>,
|
|
122
125
|
//ifNoneOf: Array<keyof TProps & string>,
|
|
@@ -149,7 +152,7 @@ export interface ExtHandlerOptions {
|
|
|
149
152
|
}
|
|
150
153
|
|
|
151
154
|
export type ExtHandlers<ETProps = any> =
|
|
152
|
-
| Partial<{[key in `inc_${keyof
|
|
155
|
+
| Partial<{[key in `inc_${keyof ETProps & string}` & string]: ExtHandlerOptions}>
|
|
153
156
|
;
|
|
154
157
|
|
|
155
158
|
export type Handlers<ETProps = any, TActions = ETProps> =
|
|
@@ -162,7 +165,9 @@ export type ListOfLogicalExpressions<MCProps = any> = (keyof MCProps | LogicOp<M
|
|
|
162
165
|
export type LogicOpProp<MCProps = any> =
|
|
163
166
|
|LogicOp<MCProps> | (keyof MCProps & string)[];
|
|
164
167
|
|
|
165
|
-
|
|
168
|
+
type PropsToProps<Props> = (x: Props) => (Promise<Partial<Props>> | Partial<Props>)
|
|
169
|
+
|
|
170
|
+
export interface LogicOp<Props = any, TActions = Props>{
|
|
166
171
|
/**
|
|
167
172
|
* Supported by trans-render
|
|
168
173
|
*/
|
|
@@ -182,7 +187,10 @@ export interface LogicOp<Props = any>{
|
|
|
182
187
|
|
|
183
188
|
delay?: number,
|
|
184
189
|
|
|
185
|
-
do?:
|
|
190
|
+
do?:
|
|
191
|
+
| Function
|
|
192
|
+
| (keyof TActions & string)
|
|
193
|
+
| PropsToProps<Props>
|
|
186
194
|
|
|
187
195
|
}
|
|
188
196
|
|
|
@@ -242,6 +250,7 @@ export interface PropInfo<TProps=any, TActions=any> extends IshPropInfo<TProps,
|
|
|
242
250
|
parse?: boolean;
|
|
243
251
|
def?: any;
|
|
244
252
|
attrName?: string;
|
|
253
|
+
reflect?: boolean;
|
|
245
254
|
/**
|
|
246
255
|
* form associated read only property
|
|
247
256
|
* https://web.dev/articles/more-capable-form-controls#:~:text=Form-associated%20custom%20elements%20aim%20to%20bridge%20the%20gap,associated%20with%20the%20form%2C%20like%20a%20browser-provided%20control.
|
|
@@ -55,7 +55,7 @@ export type DerivationCriteria<TProps, TMethods> = {
|
|
|
55
55
|
//TODO
|
|
56
56
|
as?: ConvertOptions,
|
|
57
57
|
//TODO - applicable to arrays
|
|
58
|
-
filter?: keyof
|
|
58
|
+
filter?: keyof TMethods & string | ((val: any) => boolean),
|
|
59
59
|
//TODO
|
|
60
60
|
//map?: keyof TModhods & string | ((val: any) => any,
|
|
61
61
|
};
|
|
@@ -317,7 +317,7 @@ export interface UnitOfWork<TProps, TMethods = TProps, TElement = {}>{
|
|
|
317
317
|
/**
|
|
318
318
|
* two way bind the listed props to data- attributes
|
|
319
319
|
*/
|
|
320
|
-
data?: Array<keyof
|
|
320
|
+
data?: Array<keyof TProps & string>
|
|
321
321
|
|
|
322
322
|
/**
|
|
323
323
|
* negate to
|
|
@@ -568,7 +568,8 @@ export type StringWithAutocompleteOptions<TOptions> =
|
|
|
568
568
|
| TOptions;
|
|
569
569
|
|
|
570
570
|
export interface Clone$Options{
|
|
571
|
-
ish: HasIshList,
|
|
571
|
+
//ish: HasIshList,
|
|
572
|
+
ish: any,
|
|
572
573
|
ishContainer: Element,
|
|
573
574
|
seedEl: Element,
|
|
574
575
|
idxStart: number,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface SimpleWCInfo<TProps = any, TPublicMethods = any>{
|
|
2
|
+
tagName: string;
|
|
3
|
+
cssParts?: {[key: string]: string};
|
|
4
|
+
props?: any;
|
|
5
|
+
methods?: any;
|
|
6
|
+
nonAttribProps?: (keyof TProps)[];
|
|
7
|
+
cssProps?: {[key: string]: string};
|
|
8
|
+
slots?: {[key: string]: string};
|
|
9
|
+
events?: {[key: string]: string};
|
|
10
|
+
name: string,
|
|
11
|
+
description: string,
|
|
12
|
+
homepage: string,
|
|
13
|
+
license: string,
|
|
14
|
+
|
|
15
|
+
}
|