mount-observer 0.0.45 → 0.0.46
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 +15 -6
- package/MountObserver.ts +16 -6
- package/Newish.js +70 -0
- package/Newish.ts +74 -0
- package/package.json +9 -1
- package/ts-refs/be-flashy/types.d.ts +27 -0
- package/ts-refs/be-joining/types.d.ts +26 -0
- package/ts-refs/be-observing/types.d.ts +8 -0
- package/ts-refs/mount-observer/types.d.ts +2 -1
- package/ts-refs/trans-render/asmr/types.d.ts +8 -0
- package/ts-refs/trans-render/dss/types.d.ts +32 -2
- package/ts-refs/trans-render/froop/types.d.ts +1 -1
- package/ts-refs/xp-as/types.d.ts +20 -0
- package/waitForEvent.js +12 -0
- package/waitForEvent.ts +13 -0
package/MountObserver.js
CHANGED
|
@@ -58,17 +58,21 @@ export class MountObserver extends EventTarget {
|
|
|
58
58
|
return this.#calculatedSelector;
|
|
59
59
|
}
|
|
60
60
|
async composeFragment(fragment, level) {
|
|
61
|
-
const bis = fragment.querySelectorAll(inclTemplQry);
|
|
61
|
+
const bis = fragment.querySelectorAll(`${inclTemplQry},${itemscopeQry}`);
|
|
62
62
|
for (const bi of bis) {
|
|
63
63
|
await this.#compose(bi, level);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
async #compose(el, level) {
|
|
67
|
-
if (
|
|
68
|
-
|
|
67
|
+
if (el.hasAttribute('src')) {
|
|
68
|
+
const { compose } = await import('./compose.js');
|
|
69
|
+
await compose(this, el, level);
|
|
70
|
+
}
|
|
71
|
+
const itemscope = el.getAttribute('itemscope');
|
|
72
|
+
if (itemscope && itemscope.includes('-')) {
|
|
73
|
+
const { Newish } = await import('./Newish.js');
|
|
74
|
+
new Newish(el, itemscope, this.#mountInit.assigner);
|
|
69
75
|
}
|
|
70
|
-
const { compose } = await import('./compose.js');
|
|
71
|
-
await compose(this, el, level);
|
|
72
76
|
}
|
|
73
77
|
#templLookUp = new Map();
|
|
74
78
|
findByID(id, fragment) {
|
|
@@ -393,7 +397,7 @@ export class MountObserver extends EventTarget {
|
|
|
393
397
|
return returnSet;
|
|
394
398
|
}
|
|
395
399
|
async #filterAndMount(els, checkMatch, initializing) {
|
|
396
|
-
const { whereSatisfies, whereInstanceOf } = this.#mountInit;
|
|
400
|
+
const { whereSatisfies, whereInstanceOf, assigner } = this.#mountInit;
|
|
397
401
|
const match = await this.#selector();
|
|
398
402
|
const elsToMount = els.filter(x => {
|
|
399
403
|
if (checkMatch) {
|
|
@@ -414,6 +418,10 @@ export class MountObserver extends EventTarget {
|
|
|
414
418
|
if (elToMount.matches(inclTemplQry)) {
|
|
415
419
|
await this.#compose(elToMount, 0);
|
|
416
420
|
}
|
|
421
|
+
if (elToMount.matches(itemscopeQry)) {
|
|
422
|
+
const { Newish } = await import('./Newish.js');
|
|
423
|
+
new Newish(elToMount, elToMount.getAttribute('itemscope'), assigner);
|
|
424
|
+
}
|
|
417
425
|
}
|
|
418
426
|
this.#mount(elsToMount, initializing);
|
|
419
427
|
}
|
|
@@ -425,6 +433,7 @@ export class MountObserver extends EventTarget {
|
|
|
425
433
|
}
|
|
426
434
|
const refCountErr = 'mount-observer ref count mismatch';
|
|
427
435
|
export const inclTemplQry = 'template[src^="#"]:not([hidden])';
|
|
436
|
+
export const itemscopeQry = '[itemscope~="-"]';
|
|
428
437
|
// https://github.com/webcomponents-cg/community-protocols/issues/12#issuecomment-872415080
|
|
429
438
|
/**
|
|
430
439
|
* The `mutation-event` event represents something that happened.
|
package/MountObserver.ts
CHANGED
|
@@ -69,18 +69,23 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
async composeFragment(fragment: DocumentFragment, level: number){
|
|
72
|
-
const bis = fragment.querySelectorAll(inclTemplQry) as NodeListOf<HTMLTemplateElement>;
|
|
72
|
+
const bis = fragment.querySelectorAll(`${inclTemplQry},${itemscopeQry}`) as NodeListOf<HTMLTemplateElement>;
|
|
73
73
|
for(const bi of bis){
|
|
74
74
|
await this.#compose(bi, level);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
|
|
78
79
|
async #compose(el: HTMLTemplateElement, level: number){
|
|
79
|
-
if(
|
|
80
|
-
|
|
80
|
+
if(el.hasAttribute('src')){
|
|
81
|
+
const {compose} = await import('./compose.js');
|
|
82
|
+
await compose(this, el, level);
|
|
83
|
+
}
|
|
84
|
+
const itemscope = el.getAttribute('itemscope');
|
|
85
|
+
if(itemscope && itemscope.includes('-')){
|
|
86
|
+
const {Newish} = await import('./Newish.js');
|
|
87
|
+
new Newish(el, itemscope, this.#mountInit.assigner);
|
|
81
88
|
}
|
|
82
|
-
const {compose} = await import('./compose.js');
|
|
83
|
-
await compose(this, el, level);
|
|
84
89
|
}
|
|
85
90
|
#templLookUp: Map<string, HTMLElement> = new Map();
|
|
86
91
|
findByID(id: string, fragment: DocumentFragment): HTMLElement | null{
|
|
@@ -410,7 +415,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
410
415
|
}
|
|
411
416
|
|
|
412
417
|
async #filterAndMount(els: Array<Element>, checkMatch: boolean, initializing: boolean){
|
|
413
|
-
const {whereSatisfies, whereInstanceOf} = this.#mountInit;
|
|
418
|
+
const {whereSatisfies, whereInstanceOf, assigner} = this.#mountInit;
|
|
414
419
|
const match = await this.#selector();
|
|
415
420
|
const elsToMount = els.filter(x => {
|
|
416
421
|
if(checkMatch){
|
|
@@ -428,6 +433,10 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
428
433
|
if(elToMount.matches(inclTemplQry)){
|
|
429
434
|
await this.#compose(elToMount as HTMLTemplateElement, 0)
|
|
430
435
|
}
|
|
436
|
+
if(elToMount.matches(itemscopeQry)){
|
|
437
|
+
const {Newish} = await import('./Newish.js');
|
|
438
|
+
new Newish(elToMount, elToMount.getAttribute('itemscope')!, assigner);
|
|
439
|
+
}
|
|
431
440
|
}
|
|
432
441
|
this.#mount(elsToMount, initializing);
|
|
433
442
|
}
|
|
@@ -444,6 +453,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
444
453
|
|
|
445
454
|
const refCountErr = 'mount-observer ref count mismatch';
|
|
446
455
|
export const inclTemplQry = 'template[src^="#"]:not([hidden])';
|
|
456
|
+
export const itemscopeQry = '[itemscope~="-"]';
|
|
447
457
|
export interface MountObserver extends IMountObserver{}
|
|
448
458
|
|
|
449
459
|
// https://github.com/webcomponents-cg/community-protocols/issues/12#issuecomment-872415080
|
package/Newish.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export { waitForEvent } from './waitForEvent.js';
|
|
2
|
+
export class Newish extends EventTarget {
|
|
3
|
+
queue = [];
|
|
4
|
+
isResolved = false;
|
|
5
|
+
#ce;
|
|
6
|
+
#assigner = undefined;
|
|
7
|
+
constructor(enhancedElement, itemscope, assigner) {
|
|
8
|
+
super();
|
|
9
|
+
this.#assigner = assigner;
|
|
10
|
+
this.#do(enhancedElement, itemscope);
|
|
11
|
+
}
|
|
12
|
+
async #do(enhancedElement, itemscope) {
|
|
13
|
+
//if(Object.hasOwn(enhancedElement, 'host')) return;
|
|
14
|
+
await customElements.whenDefined(itemscope);
|
|
15
|
+
const initPropVals = enhancedElement['ish'];
|
|
16
|
+
//check to make sure it didn't already get attached while waiting
|
|
17
|
+
if (initPropVals === undefined || customElements.getName(initPropVals.constructor) !== itemscope) {
|
|
18
|
+
if (enhancedElement instanceof HTMLElement) {
|
|
19
|
+
if (enhancedElement.dataset.ish) {
|
|
20
|
+
const parsedHostProps = JSON.parse(enhancedElement.dataset.ish);
|
|
21
|
+
this.queue.push(parsedHostProps);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (initPropVals !== undefined)
|
|
25
|
+
this.queue.push(initPropVals);
|
|
26
|
+
const ce = document.createElement(itemscope);
|
|
27
|
+
if ('attachedCallback' in ce && typeof ce.attachedCallback === 'function') {
|
|
28
|
+
await ce.attachedCallback(enhancedElement);
|
|
29
|
+
}
|
|
30
|
+
this.#ce = ce;
|
|
31
|
+
const self = this;
|
|
32
|
+
Object.defineProperty(enhancedElement, 'ish', {
|
|
33
|
+
get() {
|
|
34
|
+
return self.#ce;
|
|
35
|
+
},
|
|
36
|
+
set(nv) {
|
|
37
|
+
self.queue.push(nv);
|
|
38
|
+
self.#assignGingerly();
|
|
39
|
+
},
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
});
|
|
43
|
+
this.#assignGingerly();
|
|
44
|
+
}
|
|
45
|
+
this.isResolved = true;
|
|
46
|
+
this.dispatchEvent(new Event('resolved'));
|
|
47
|
+
}
|
|
48
|
+
async #assignGingerly() {
|
|
49
|
+
let ce = this.#ce;
|
|
50
|
+
if (ce === undefined) {
|
|
51
|
+
throw 500;
|
|
52
|
+
}
|
|
53
|
+
//const {assignGingerly} = await import('../lib/assignGingerly.js');
|
|
54
|
+
while (this.queue.length > 0) {
|
|
55
|
+
const fi = this.queue.shift();
|
|
56
|
+
//TODO: Provide support for a virtual slice of a very large list
|
|
57
|
+
if (Array.isArray(fi)) {
|
|
58
|
+
ce.$ = fi;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (this.#assigner !== undefined) {
|
|
62
|
+
await this.#assigner(ce, fi);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
Object.assign(ce, fi);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
package/Newish.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export {waitForEvent} from './waitForEvent.js';
|
|
2
|
+
export class Newish extends EventTarget{
|
|
3
|
+
queue: Array<any> = [];
|
|
4
|
+
isResolved = false;
|
|
5
|
+
#ce: HTMLElement | undefined;
|
|
6
|
+
|
|
7
|
+
#assigner: undefined | ((target: any, source: any) => Promise<void>) = undefined;
|
|
8
|
+
|
|
9
|
+
constructor(enhancedElement: Element, itemscope: string, assigner?: (target: any, source: any) => Promise<void>){
|
|
10
|
+
super();
|
|
11
|
+
this.#assigner = assigner;
|
|
12
|
+
this.#do(enhancedElement, itemscope);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async #do(enhancedElement: Element, itemscope: string){
|
|
16
|
+
//if(Object.hasOwn(enhancedElement, 'host')) return;
|
|
17
|
+
await customElements.whenDefined(itemscope);
|
|
18
|
+
const initPropVals = (<any>enhancedElement)['ish'];
|
|
19
|
+
//check to make sure it didn't already get attached while waiting
|
|
20
|
+
if(initPropVals === undefined || customElements.getName(initPropVals.constructor) !== itemscope){
|
|
21
|
+
if(enhancedElement instanceof HTMLElement){
|
|
22
|
+
if(enhancedElement.dataset.ish){
|
|
23
|
+
const parsedHostProps = JSON.parse(enhancedElement.dataset.ish);
|
|
24
|
+
this.queue.push(parsedHostProps);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if(initPropVals !== undefined) this.queue.push(initPropVals);
|
|
28
|
+
const ce = document.createElement(itemscope);
|
|
29
|
+
if('attachedCallback' in ce && typeof ce.attachedCallback === 'function'){
|
|
30
|
+
await ce.attachedCallback(enhancedElement)
|
|
31
|
+
}
|
|
32
|
+
this.#ce = ce;
|
|
33
|
+
const self = this;
|
|
34
|
+
Object.defineProperty(enhancedElement, 'ish', {
|
|
35
|
+
get(){
|
|
36
|
+
return self.#ce;
|
|
37
|
+
},
|
|
38
|
+
set(nv: any){
|
|
39
|
+
self.queue.push(nv);
|
|
40
|
+
self.#assignGingerly();
|
|
41
|
+
},
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
});
|
|
45
|
+
this.#assignGingerly();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this.isResolved = true;
|
|
49
|
+
this.dispatchEvent(new Event('resolved'));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async #assignGingerly(){
|
|
53
|
+
let ce = this.#ce!;
|
|
54
|
+
if(ce === undefined){
|
|
55
|
+
throw 500;
|
|
56
|
+
}
|
|
57
|
+
//const {assignGingerly} = await import('../lib/assignGingerly.js');
|
|
58
|
+
while(this.queue.length > 0 ){
|
|
59
|
+
const fi = this.queue.shift();
|
|
60
|
+
//TODO: Provide support for a virtual slice of a very large list
|
|
61
|
+
if(Array.isArray(fi)){
|
|
62
|
+
(<any>ce).$ = fi;
|
|
63
|
+
}else{
|
|
64
|
+
if(this.#assigner !== undefined){
|
|
65
|
+
await this.#assigner(ce, fi);
|
|
66
|
+
}else{
|
|
67
|
+
Object.assign(ce, fi);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mount-observer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"description": "Observe and act on css matches.",
|
|
5
5
|
"main": "MountObserver.js",
|
|
6
6
|
"module": "MountObserver.js",
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"default": "./MountObserver.js",
|
|
18
18
|
"types": "./MountObserver.ts"
|
|
19
19
|
},
|
|
20
|
+
"./Newish.js": {
|
|
21
|
+
"default": "./Newish.js",
|
|
22
|
+
"types": "./Newish.ts"
|
|
23
|
+
},
|
|
20
24
|
"./Synthesizer.js": {
|
|
21
25
|
"default": "./Synthesizer.js",
|
|
22
26
|
"types": "./Synthesizer.ts"
|
|
@@ -24,6 +28,10 @@
|
|
|
24
28
|
"./compose.js": {
|
|
25
29
|
"default": "./compose.js",
|
|
26
30
|
"types": "./compose.ts"
|
|
31
|
+
},
|
|
32
|
+
"./waitForEvent.js": {
|
|
33
|
+
"default": "./waitForEvent.js",
|
|
34
|
+
"types": "./waitForEvent.ts"
|
|
27
35
|
}
|
|
28
36
|
},
|
|
29
37
|
"files": [
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {IEnhancement, BEAllProps} from '../trans-render/be/types';
|
|
2
|
+
import {StringWithAutocompleteOptions} from '../trans-render/types';
|
|
3
|
+
|
|
4
|
+
export interface EndUserProps extends IEnhancement{
|
|
5
|
+
duration: number,
|
|
6
|
+
attr: StringWithAutocompleteOptions<
|
|
7
|
+
|'value'
|
|
8
|
+
|'textContent'
|
|
9
|
+
|'innerHTML'
|
|
10
|
+
|'shadowRoot'
|
|
11
|
+
>,
|
|
12
|
+
css: string,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface AllProps extends 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
|
+
export interface Actions{
|
|
26
|
+
hydrate(self: BAP): ProPAP;
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {IEnhancement, BEAllProps} from '../trans-render/be/types';
|
|
2
|
+
import {AllProps as XPAsAllProps} from '../xp-as/types';
|
|
3
|
+
|
|
4
|
+
export interface EndUserProps extends IEnhancement{
|
|
5
|
+
xpAsAttr: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface AllProps extends EndUserProps{
|
|
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
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface Factor{
|
|
24
|
+
NameOfProp: string,
|
|
25
|
+
xpAs: XPAsAllProps,
|
|
26
|
+
}
|
|
@@ -46,8 +46,16 @@ export interface ObservingParameters{
|
|
|
46
46
|
punt: boolean,
|
|
47
47
|
mappings?: Array<AndIfThen>,
|
|
48
48
|
aggKey: StringWithAutocompleteOptions<aggKeys>,
|
|
49
|
+
interpolatingExpr: string,
|
|
49
50
|
JSExpr: string,
|
|
50
51
|
ONExpr: string,
|
|
52
|
+
action:
|
|
53
|
+
| 'set'
|
|
54
|
+
| 'toggle'
|
|
55
|
+
| 'increment'
|
|
56
|
+
| 'decrement'
|
|
57
|
+
| 'set-class'
|
|
58
|
+
| 'set-part'
|
|
51
59
|
//aggregateRemoteVals?: 'Union' | 'Conjunction' | 'ObjectAssign' | 'Sum' | 'Product' | 'ArrayPush'
|
|
52
60
|
}
|
|
53
61
|
|
|
@@ -24,7 +24,8 @@ export interface MountInit extends JSONSerializableMountInit{
|
|
|
24
24
|
readonly withTargetShadowRoot?: ShadowRoot,
|
|
25
25
|
readonly whereInstanceOf?: Array<{new(): Element}>,
|
|
26
26
|
readonly whereSatisfies?: PipelineProcessor<boolean>,
|
|
27
|
-
readonly do?: MountObserverCallbacks
|
|
27
|
+
readonly do?: MountObserverCallbacks,
|
|
28
|
+
readonly assigner?: (target: any, source: any) => Promise<void>,
|
|
28
29
|
// /**
|
|
29
30
|
// * Purpose -- there are scenarios where we may only want to affect changes that occur after the initial
|
|
30
31
|
// * server rendering, so we only want to mount elements that appear
|
|
@@ -72,6 +72,14 @@ export interface ASMROptions<TProp = any>{
|
|
|
72
72
|
export interface SetOptions<TProp = any> extends ASMROptions<TProp>{
|
|
73
73
|
valToDisplay?: (v: TProp) => string;
|
|
74
74
|
allowUnsafe?: boolean;
|
|
75
|
+
action?:
|
|
76
|
+
|'set'
|
|
77
|
+
|'toggle'
|
|
78
|
+
|'increment'
|
|
79
|
+
|'decrement'
|
|
80
|
+
|'set-class'
|
|
81
|
+
|'set-part'
|
|
82
|
+
;
|
|
75
83
|
}
|
|
76
84
|
|
|
77
85
|
export interface AbsOptions<TProp = any> {
|
|
@@ -25,6 +25,10 @@ export type DirectionalScopeSigils =
|
|
|
25
25
|
* modulo
|
|
26
26
|
*/
|
|
27
27
|
|'%'
|
|
28
|
+
/**
|
|
29
|
+
* itemscoped host
|
|
30
|
+
*/
|
|
31
|
+
|'$'
|
|
28
32
|
;
|
|
29
33
|
|
|
30
34
|
export type AttrSigils =
|
|
@@ -51,6 +55,16 @@ export type asOptions =
|
|
|
51
55
|
| 'boolean|number'
|
|
52
56
|
;
|
|
53
57
|
|
|
58
|
+
export interface $copeDetail{
|
|
59
|
+
ceName?: string,
|
|
60
|
+
itemProp?: string,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface $ScopeHierarchy {
|
|
64
|
+
home: Element;
|
|
65
|
+
satellites?: Array<Element>;
|
|
66
|
+
}
|
|
67
|
+
|
|
54
68
|
export interface Specifier {
|
|
55
69
|
/** Directional Scope Sigil */
|
|
56
70
|
dss?: DirectionalScopeSigils,
|
|
@@ -106,9 +120,21 @@ export interface Specifier {
|
|
|
106
120
|
|
|
107
121
|
as?: asOptions
|
|
108
122
|
|
|
109
|
-
|
|
123
|
+
/**
|
|
124
|
+
* is a scope query within the aria-[row|col|row]index[text]
|
|
125
|
+
*/
|
|
110
126
|
isModulo?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Specify which aria-[?]index to use
|
|
129
|
+
*/
|
|
111
130
|
modulo?: Modulo;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* itemscope hierarchy domain specifier
|
|
134
|
+
*/
|
|
135
|
+
is$cope?: boolean;
|
|
136
|
+
|
|
137
|
+
$copeDetail?: $copeDetail
|
|
112
138
|
}
|
|
113
139
|
|
|
114
140
|
export type Modulo = 'aria-rowindex' | 'aria-colindex' | 'aria-rowindextext'
|
|
@@ -126,7 +152,7 @@ export type CSSSelector = string;
|
|
|
126
152
|
|
|
127
153
|
/**
|
|
128
154
|
* starts with a dash, typically all kebab case
|
|
129
|
-
*
|
|
155
|
+
* inferred prop name will be camel cased based on this.
|
|
130
156
|
*/
|
|
131
157
|
export type MarkerString = string;
|
|
132
158
|
|
|
@@ -156,4 +182,8 @@ export interface PIP<TProp = any, TElement = Element> extends EventListenerObjec
|
|
|
156
182
|
disconnect();
|
|
157
183
|
toString(nv: TProp): string;
|
|
158
184
|
readonly outEvtName: string;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface HasIshList extends HTMLElement{
|
|
188
|
+
ishList: Array<any>;
|
|
159
189
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {IEnhancement, BEAllProps} from '../trans-render/be/types';
|
|
2
|
+
|
|
3
|
+
export interface EndUserProps extends IEnhancement{
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface AllProps extends EndUserProps{
|
|
7
|
+
props: EventTarget;
|
|
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
|
+
|
|
20
|
+
}
|
package/waitForEvent.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function waitForEvent(et, eventName, failureEventName) {
|
|
2
|
+
return new Promise((resolved, rejected) => {
|
|
3
|
+
et.addEventListener(eventName, e => {
|
|
4
|
+
resolved(e);
|
|
5
|
+
}, { once: true });
|
|
6
|
+
if (failureEventName !== undefined) {
|
|
7
|
+
et.addEventListener(failureEventName, e => {
|
|
8
|
+
rejected(e);
|
|
9
|
+
}, { once: true });
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
package/waitForEvent.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function waitForEvent<TEvent extends Event = Event>(et: EventTarget, eventName: string, failureEventName?: string): Promise<TEvent>{
|
|
2
|
+
return new Promise((resolved, rejected) => {
|
|
3
|
+
et.addEventListener(eventName, e => {
|
|
4
|
+
resolved(e as TEvent);
|
|
5
|
+
}, {once: true});
|
|
6
|
+
if(failureEventName !== undefined){
|
|
7
|
+
et.addEventListener(failureEventName, e => {
|
|
8
|
+
rejected(e as TEvent);
|
|
9
|
+
}, {once: true});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
})
|
|
13
|
+
}
|