mount-observer 0.0.58 → 0.0.60
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 -6
- package/MountObserver.ts +6 -6
- package/Newish.js +16 -10
- package/Newish.ts +26 -10
- package/bindish.js +6 -6
- package/bindish.ts +10 -6
- package/package.json +5 -1
- package/refid/getIsh.js +27 -0
- package/refid/getIsh.ts +27 -0
- package/refid/regIsh.js +12 -0
- package/refid/regIsh.ts +14 -0
- package/ts-refs/mount-observer/types.d.ts +9 -0
- package/ts-refs/per-each/types.d.ts +2 -1
- package/ts-refs/trans-render/froop/types.d.ts +4 -0
- package/ts-refs/trans-render/types.d.ts +26 -4
package/MountObserver.js
CHANGED
|
@@ -219,7 +219,7 @@ export class MountObserver extends EventTarget {
|
|
|
219
219
|
this.dispatchEvent(new AttrChangeEvent(key, value));
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
-
this.#filterAndMount(elsToInspect, true, false);
|
|
222
|
+
this.#filterAndMount(elsToInspect, within, true, false);
|
|
223
223
|
for (const el of elsToInspect) {
|
|
224
224
|
await this.#inspectWithin(el, false);
|
|
225
225
|
}
|
|
@@ -371,7 +371,7 @@ export class MountObserver extends EventTarget {
|
|
|
371
371
|
const { whereSatisfies, whereInstanceOf } = this.#mountInit;
|
|
372
372
|
const match = await this.#selector();
|
|
373
373
|
const els = Array.from(document.querySelectorAll(match));
|
|
374
|
-
this.#filterAndMount(els, false, true);
|
|
374
|
+
this.#filterAndMount(els, document.body, false, true);
|
|
375
375
|
}
|
|
376
376
|
async #filterAndDismount() {
|
|
377
377
|
const returnSet = new Set();
|
|
@@ -396,7 +396,7 @@ export class MountObserver extends EventTarget {
|
|
|
396
396
|
this.#mountedList = Array.from(returnSet).map(x => new WeakRef(x));
|
|
397
397
|
return returnSet;
|
|
398
398
|
}
|
|
399
|
-
async #filterAndMount(els, checkMatch, initializing) {
|
|
399
|
+
async #filterAndMount(els, target, checkMatch, initializing) {
|
|
400
400
|
const { whereSatisfies, whereInstanceOf, assigner } = this.#mountInit;
|
|
401
401
|
const match = await this.#selector();
|
|
402
402
|
const elsToMount = els.filter(x => {
|
|
@@ -419,15 +419,15 @@ export class MountObserver extends EventTarget {
|
|
|
419
419
|
await this.#compose(elToMount, 0);
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
|
-
await bindishIt(els, { assigner });
|
|
422
|
+
await bindishIt(els, target, { assigner });
|
|
423
423
|
this.#mount(elsToMount, initializing);
|
|
424
424
|
}
|
|
425
425
|
async #inspectWithin(within, initializing) {
|
|
426
|
-
await bindish(within, { assigner: this.#mountInit.assigner });
|
|
426
|
+
await bindish(within, within, { assigner: this.#mountInit.assigner });
|
|
427
427
|
await this.composeFragment(within, 0);
|
|
428
428
|
const match = await this.#selector();
|
|
429
429
|
const els = Array.from(within.querySelectorAll(match));
|
|
430
|
-
this.#filterAndMount(els, false, initializing);
|
|
430
|
+
this.#filterAndMount(els, within, false, initializing);
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
433
|
export function waitForIdleNodes(nodes, idleTimeout) {
|
package/MountObserver.ts
CHANGED
|
@@ -234,7 +234,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
234
234
|
this.dispatchEvent(new AttrChangeEvent(key, value))
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
|
-
this.#filterAndMount(elsToInspect, true, false);
|
|
237
|
+
this.#filterAndMount(elsToInspect, within, true, false);
|
|
238
238
|
for(const el of elsToInspect){
|
|
239
239
|
await this.#inspectWithin(el, false);
|
|
240
240
|
}
|
|
@@ -392,7 +392,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
392
392
|
const {whereSatisfies, whereInstanceOf} = this.#mountInit;
|
|
393
393
|
const match = await this.#selector();
|
|
394
394
|
const els = Array.from(document.querySelectorAll(match));
|
|
395
|
-
this.#filterAndMount(els, false, true);
|
|
395
|
+
this.#filterAndMount(els, document.body, false, true);
|
|
396
396
|
}
|
|
397
397
|
|
|
398
398
|
async #filterAndDismount(): Promise<Set<Element>>{
|
|
@@ -416,7 +416,7 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
416
416
|
return returnSet;
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
-
async #filterAndMount(els: Array<Element>, checkMatch: boolean, initializing: boolean){
|
|
419
|
+
async #filterAndMount(els: Array<Element>, target: Node, checkMatch: boolean, initializing: boolean){
|
|
420
420
|
const {whereSatisfies, whereInstanceOf, assigner} = this.#mountInit;
|
|
421
421
|
const match = await this.#selector();
|
|
422
422
|
const elsToMount = els.filter(x => {
|
|
@@ -437,16 +437,16 @@ export class MountObserver extends EventTarget implements IMountObserver{
|
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
}
|
|
440
|
-
await bindishIt(els, {assigner});
|
|
440
|
+
await bindishIt(els, target, {assigner});
|
|
441
441
|
this.#mount(elsToMount, initializing);
|
|
442
442
|
}
|
|
443
443
|
|
|
444
444
|
async #inspectWithin(within: Node, initializing: boolean){
|
|
445
|
-
await bindish(within as DocumentFragment, {assigner: this.#mountInit.assigner});
|
|
445
|
+
await bindish(within as DocumentFragment, within, {assigner: this.#mountInit.assigner});
|
|
446
446
|
await this.composeFragment(within as DocumentFragment, 0);
|
|
447
447
|
const match = await this.#selector();
|
|
448
448
|
const els = Array.from((within as Element).querySelectorAll(match));
|
|
449
|
-
this.#filterAndMount(els, false, initializing);
|
|
449
|
+
this.#filterAndMount(els, within, false, initializing);
|
|
450
450
|
}
|
|
451
451
|
|
|
452
452
|
}
|
package/Newish.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { waitForEvent } from './waitForEvent.js';
|
|
2
2
|
import { ObsAttr } from './ObsAttr.js';
|
|
3
3
|
import { splitRefs } from './refid/splitRefs.js';
|
|
4
|
+
import { getIsh } from './refid/getIsh.js';
|
|
4
5
|
export const attached = Symbol.for('xyyspnstnU+CDrNVa0VnxA');
|
|
5
6
|
export class Newish {
|
|
6
7
|
queue = [];
|
|
@@ -9,10 +10,10 @@ export class Newish {
|
|
|
9
10
|
#ref;
|
|
10
11
|
//#assigner: undefined | Assigner = undefined;
|
|
11
12
|
#options;
|
|
12
|
-
constructor(enhancedElement, itemscope, options) {
|
|
13
|
+
constructor(enhancedElement, target, itemscope, options) {
|
|
13
14
|
this.#options = options || { assigner: Object.assign };
|
|
14
15
|
this.#ref = new WeakRef(enhancedElement);
|
|
15
|
-
this.#do(enhancedElement, itemscope);
|
|
16
|
+
this.#do(enhancedElement, target, itemscope);
|
|
16
17
|
}
|
|
17
18
|
handleEvent(event) {
|
|
18
19
|
const enhancedElement = this.#ref.deref();
|
|
@@ -20,11 +21,11 @@ export class Newish {
|
|
|
20
21
|
return;
|
|
21
22
|
this.#attachItemrefs(enhancedElement);
|
|
22
23
|
}
|
|
23
|
-
async #do(enhancedElement, itemscope) {
|
|
24
|
+
async #do(enhancedElement, target, itemscope) {
|
|
24
25
|
if (enhancedElement[attached] === true)
|
|
25
26
|
return;
|
|
26
27
|
enhancedElement[attached] = true;
|
|
27
|
-
|
|
28
|
+
const ctr = getIsh(enhancedElement.isConnected ? enhancedElement : target, itemscope);
|
|
28
29
|
const initPropVals = enhancedElement['ish'];
|
|
29
30
|
if (enhancedElement instanceof HTMLElement) {
|
|
30
31
|
if (enhancedElement.dataset.ish) {
|
|
@@ -32,11 +33,13 @@ export class Newish {
|
|
|
32
33
|
this.queue.push(parsedHostProps);
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
+
const resolvedConstructor = ctr.constructor.name === 'AsyncFunction' ? await ctr() : ctr;
|
|
37
|
+
const isInstance = initPropVals instanceof resolvedConstructor;
|
|
38
|
+
const ce = isInstance ? initPropVals : new resolvedConstructor();
|
|
39
|
+
if (initPropVals !== undefined && !isInstance)
|
|
36
40
|
this.queue.push(initPropVals);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
await ce.attachedCallback(enhancedElement, this.#options);
|
|
41
|
+
if ('<mount>' in ce && typeof ce['<mount>'] === 'function') {
|
|
42
|
+
await ce['<mount>'](ce, enhancedElement, this.#options);
|
|
40
43
|
}
|
|
41
44
|
this.#ce = ce;
|
|
42
45
|
const self = this;
|
|
@@ -45,6 +48,9 @@ export class Newish {
|
|
|
45
48
|
return self.#ce;
|
|
46
49
|
},
|
|
47
50
|
set(nv) {
|
|
51
|
+
if (self.#ce === nv)
|
|
52
|
+
return;
|
|
53
|
+
console.log({ nv });
|
|
48
54
|
self.queue.push(nv);
|
|
49
55
|
self.#assignGingerly();
|
|
50
56
|
},
|
|
@@ -63,7 +69,7 @@ export class Newish {
|
|
|
63
69
|
#attachItemrefs(enhancedElement) {
|
|
64
70
|
//TODO: watch for already attached itemrefs to be removed and remove them from the set
|
|
65
71
|
// and call outOfScopeCallback on them
|
|
66
|
-
if ('
|
|
72
|
+
if ('<inScope>' in this.#ce && enhancedElement.hasAttribute('itemref')) {
|
|
67
73
|
const itemref = enhancedElement.getAttribute('itemref');
|
|
68
74
|
const itemrefList = splitRefs(itemref); // itemref.split(' ').map((id) => id.trim()).filter((id) => id.length > 0);
|
|
69
75
|
if (itemrefList.length === 0)
|
|
@@ -74,7 +80,7 @@ export class Newish {
|
|
|
74
80
|
continue;
|
|
75
81
|
const itemrefElement = rn.getElementById(id);
|
|
76
82
|
if (itemrefElement) {
|
|
77
|
-
this.#ce
|
|
83
|
+
this.#ce['<inScope>'](this.#ce, itemrefElement, this.#options);
|
|
78
84
|
this.#alreadyAttached.add(id);
|
|
79
85
|
}
|
|
80
86
|
}
|
package/Newish.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Assigner, BindishOptions } from './ts-refs/mount-observer/types.js';
|
|
|
3
3
|
export {waitForEvent} from './waitForEvent.js';
|
|
4
4
|
import {ObsAttr} from './ObsAttr.js';
|
|
5
5
|
import {splitRefs} from './refid/splitRefs.js';
|
|
6
|
+
import {getIsh} from './refid/getIsh.js';
|
|
6
7
|
export const attached = Symbol.for('xyyspnstnU+CDrNVa0VnxA');
|
|
7
8
|
export class Newish implements EventListenerObject {
|
|
8
9
|
queue: Array<any> = [];
|
|
@@ -13,10 +14,12 @@ export class Newish implements EventListenerObject {
|
|
|
13
14
|
//#assigner: undefined | Assigner = undefined;
|
|
14
15
|
#options: BindishOptions;
|
|
15
16
|
|
|
16
|
-
constructor(enhancedElement: Element,
|
|
17
|
+
constructor(enhancedElement: Element,
|
|
18
|
+
target: Node,
|
|
19
|
+
itemscope: string, options?: BindishOptions){
|
|
17
20
|
this.#options = options || {assigner: Object.assign};
|
|
18
21
|
this.#ref = new WeakRef(enhancedElement);
|
|
19
|
-
this.#do(enhancedElement, itemscope);
|
|
22
|
+
this.#do(enhancedElement, target, itemscope);
|
|
20
23
|
}
|
|
21
24
|
handleEvent(event: Event): void {
|
|
22
25
|
const enhancedElement = this.#ref.deref();
|
|
@@ -24,10 +27,15 @@ export class Newish implements EventListenerObject {
|
|
|
24
27
|
this.#attachItemrefs(enhancedElement);
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
async #do(
|
|
30
|
+
async #do(
|
|
31
|
+
enhancedElement: Element,
|
|
32
|
+
target: Node,
|
|
33
|
+
itemscope: string
|
|
34
|
+
){
|
|
28
35
|
if((<any>enhancedElement)[attached] === true) return;
|
|
29
36
|
(<any>enhancedElement)[attached] = true;
|
|
30
|
-
|
|
37
|
+
const ctr = getIsh(enhancedElement.isConnected ? enhancedElement :target, itemscope)! as any;
|
|
38
|
+
|
|
31
39
|
const initPropVals = (<any>enhancedElement)['ish'];
|
|
32
40
|
if(enhancedElement instanceof HTMLElement){
|
|
33
41
|
if(enhancedElement.dataset.ish){
|
|
@@ -35,11 +43,17 @@ export class Newish implements EventListenerObject {
|
|
|
35
43
|
this.queue.push(parsedHostProps);
|
|
36
44
|
}
|
|
37
45
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
const resolvedConstructor = ctr.constructor.name === 'AsyncFunction' ? await ctr() : ctr;
|
|
49
|
+
const isInstance = initPropVals instanceof resolvedConstructor
|
|
50
|
+
const ce = isInstance ? initPropVals : new resolvedConstructor();
|
|
51
|
+
if(initPropVals !== undefined && !isInstance) this.queue.push(initPropVals);
|
|
52
|
+
|
|
53
|
+
if('<mount>' in ce && typeof ce['<mount>'] === 'function'){
|
|
54
|
+
await ce['<mount>'](ce, enhancedElement, this.#options)
|
|
42
55
|
}
|
|
56
|
+
|
|
43
57
|
this.#ce = ce;
|
|
44
58
|
const self = this;
|
|
45
59
|
Object.defineProperty(enhancedElement, 'ish', {
|
|
@@ -47,6 +61,8 @@ export class Newish implements EventListenerObject {
|
|
|
47
61
|
return self.#ce;
|
|
48
62
|
},
|
|
49
63
|
set(nv: any){
|
|
64
|
+
if(self.#ce === nv) return;
|
|
65
|
+
console.log({nv});
|
|
50
66
|
self.queue.push(nv);
|
|
51
67
|
self.#assignGingerly();
|
|
52
68
|
},
|
|
@@ -69,7 +85,7 @@ export class Newish implements EventListenerObject {
|
|
|
69
85
|
#attachItemrefs(enhancedElement: Element){
|
|
70
86
|
//TODO: watch for already attached itemrefs to be removed and remove them from the set
|
|
71
87
|
// and call outOfScopeCallback on them
|
|
72
|
-
if('
|
|
88
|
+
if('<inScope>' in (<any>this.#ce) && enhancedElement.hasAttribute('itemref')){
|
|
73
89
|
const itemref = enhancedElement.getAttribute('itemref')!;
|
|
74
90
|
const itemrefList = splitRefs(itemref);// itemref.split(' ').map((id) => id.trim()).filter((id) => id.length > 0);
|
|
75
91
|
if(itemrefList.length === 0) return;
|
|
@@ -78,7 +94,7 @@ export class Newish implements EventListenerObject {
|
|
|
78
94
|
if(this.#alreadyAttached.has(id)) continue;
|
|
79
95
|
const itemrefElement = rn.getElementById(id);
|
|
80
96
|
if(itemrefElement){
|
|
81
|
-
(<any>this.#ce)
|
|
97
|
+
(<any>this.#ce)['<inScope>'](this.#ce, itemrefElement, this.#options);
|
|
82
98
|
this.#alreadyAttached.add(id);
|
|
83
99
|
}
|
|
84
100
|
}
|
package/bindish.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export const itemscopeQry = '[itemscope
|
|
2
|
-
export async function bindish(fragment, options) {
|
|
1
|
+
export const itemscopeQry = '[itemscope]:not([itemscope=""])';
|
|
2
|
+
export async function bindish(fragment, target, options) {
|
|
3
3
|
const scopes = Array.from(fragment.querySelectorAll(`${itemscopeQry}`));
|
|
4
|
-
await bindishIt(scopes, options);
|
|
4
|
+
await bindishIt(scopes, target, options);
|
|
5
5
|
}
|
|
6
|
-
export async function bindishIt(scopes, options) {
|
|
6
|
+
export async function bindishIt(scopes, target, options) {
|
|
7
7
|
for (const scope of scopes) {
|
|
8
8
|
const itemscope = scope.getAttribute('itemscope');
|
|
9
|
-
if (itemscope &&
|
|
9
|
+
if (itemscope && !(scope.ish instanceof HTMLElement)) {
|
|
10
10
|
const { Newish } = await import('./Newish.js');
|
|
11
|
-
new Newish(scope, itemscope, options);
|
|
11
|
+
new Newish(scope, target, itemscope, options);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
}
|
package/bindish.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { Assigner, BindishOptions } from './ts-refs/mount-observer/types.js';
|
|
2
2
|
|
|
3
|
-
export const itemscopeQry = '[itemscope
|
|
4
|
-
export async function bindish(
|
|
3
|
+
export const itemscopeQry = '[itemscope]:not([itemscope=""])';
|
|
4
|
+
export async function bindish(
|
|
5
|
+
fragment: DocumentFragment,
|
|
6
|
+
target: Node,
|
|
7
|
+
options?: BindishOptions
|
|
8
|
+
){
|
|
5
9
|
const scopes = Array.from(fragment.querySelectorAll(`${itemscopeQry}`));
|
|
6
|
-
await bindishIt(scopes, options);
|
|
10
|
+
await bindishIt(scopes, target, options);
|
|
7
11
|
}
|
|
8
12
|
|
|
9
|
-
export async function bindishIt(scopes: Array<Element>, options?: BindishOptions){
|
|
13
|
+
export async function bindishIt(scopes: Array<Element>, target: Node, options?: BindishOptions){
|
|
10
14
|
for(const scope of scopes){
|
|
11
15
|
const itemscope = scope.getAttribute('itemscope');
|
|
12
|
-
if(itemscope &&
|
|
16
|
+
if(itemscope && !((<any>scope).ish instanceof HTMLElement)){
|
|
13
17
|
const {Newish} = await import('./Newish.js');
|
|
14
|
-
new Newish(scope, itemscope, options);
|
|
18
|
+
new Newish(scope, target, itemscope, options);
|
|
15
19
|
}
|
|
16
20
|
}
|
|
17
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mount-observer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.60",
|
|
4
4
|
"description": "Observe and act on css matches.",
|
|
5
5
|
"main": "MountObserver.js",
|
|
6
6
|
"module": "MountObserver.js",
|
|
@@ -45,6 +45,10 @@
|
|
|
45
45
|
"default": "./waitForIsh.js",
|
|
46
46
|
"types": "./waitForIsh.ts"
|
|
47
47
|
},
|
|
48
|
+
"./refid/regIsh.js": {
|
|
49
|
+
"default": "./refid/regIsh.js",
|
|
50
|
+
"types": "./refid/regIsh.js"
|
|
51
|
+
},
|
|
48
52
|
"./refid/splitRefs.js": {
|
|
49
53
|
"default": "./refid/splitRefs.js",
|
|
50
54
|
"types": "./refid/splitRefs.ts"
|
package/refid/getIsh.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { sym } from './regIsh.js';
|
|
2
|
+
export function getIsh(scope, name) {
|
|
3
|
+
let test = scope;
|
|
4
|
+
while (true) {
|
|
5
|
+
const map = test[sym];
|
|
6
|
+
if (map !== undefined) {
|
|
7
|
+
if (map.has(name)) {
|
|
8
|
+
return map.get(name);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
if (test === document)
|
|
12
|
+
throw 404;
|
|
13
|
+
if (test instanceof ShadowRoot) {
|
|
14
|
+
test = test.host;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
let newTest = test.parentElement;
|
|
18
|
+
if (newTest) {
|
|
19
|
+
test = newTest;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const lastTest = test;
|
|
23
|
+
test = test.getRootNode();
|
|
24
|
+
if (test === lastTest)
|
|
25
|
+
throw 404;
|
|
26
|
+
}
|
|
27
|
+
}
|
package/refid/getIsh.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {sym} from './regIsh.js';
|
|
2
|
+
import {IshCtr} from '../ts-refs/mount-observer/types.js';
|
|
3
|
+
export function getIsh(scope: Element | ShadowRoot | Document | Node, name: string){
|
|
4
|
+
let test = scope as any;
|
|
5
|
+
|
|
6
|
+
while(true){
|
|
7
|
+
const map = test[sym] as Map<string, IshCtr>;
|
|
8
|
+
if(map !== undefined){
|
|
9
|
+
if(map.has(name)){
|
|
10
|
+
return map.get(name);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if(test === document) throw 404;
|
|
14
|
+
if(test instanceof ShadowRoot){
|
|
15
|
+
test = test.host;
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
let newTest = test.parentElement;
|
|
19
|
+
if(newTest){
|
|
20
|
+
test = newTest;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const lastTest = test;
|
|
24
|
+
test = test.getRootNode();
|
|
25
|
+
if(test === lastTest) throw 404;
|
|
26
|
+
}
|
|
27
|
+
}
|
package/refid/regIsh.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const sym = Symbol.for('La8Cx9vHsUOd03WomqdnPw');
|
|
2
|
+
export function regIsh(scope, name, ctr) {
|
|
3
|
+
let map = scope[sym];
|
|
4
|
+
if (map === undefined) {
|
|
5
|
+
map = new Map();
|
|
6
|
+
scope[sym] = map;
|
|
7
|
+
}
|
|
8
|
+
if (map.has(name)) {
|
|
9
|
+
throw 403;
|
|
10
|
+
}
|
|
11
|
+
map.set(name, ctr);
|
|
12
|
+
}
|
package/refid/regIsh.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {IshCtr} from '../ts-refs/mount-observer/types';
|
|
2
|
+
export const sym = Symbol.for('La8Cx9vHsUOd03WomqdnPw');
|
|
3
|
+
|
|
4
|
+
export function regIsh(scope: Element | ShadowRoot | Document, name: string, ctr:IshCtr){
|
|
5
|
+
let map = (<any>scope)[sym] as Map<string, IshCtr>;
|
|
6
|
+
if(map === undefined){
|
|
7
|
+
map = new Map<string, IshCtr>();
|
|
8
|
+
(<any>scope)[sym] = map;
|
|
9
|
+
}
|
|
10
|
+
if(map.has(name)){
|
|
11
|
+
throw 403;
|
|
12
|
+
}
|
|
13
|
+
map.set(name, ctr);
|
|
14
|
+
}
|
|
@@ -218,6 +218,15 @@ export interface BindishOptions{
|
|
|
218
218
|
csr?: boolean,
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
export interface Ishcycle{
|
|
222
|
+
'<mount>'?(self: Ishcycle, el: Element, options: BindishOptions): Promise<void>;
|
|
223
|
+
//'</dismount>'?(self: IshFace, el: Element): Promise<void>;
|
|
224
|
+
'<inScope>'?(self: Ishcycle, el: Element, options: BindishOptions): Promise<void>;
|
|
225
|
+
//'</outOfScope>'?(self: IshFace, el: Element): Promise<void>;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export type IshCtr = ({new() : Ishcycle}) | (() => Promise<{new() : Ishcycle}>);
|
|
229
|
+
|
|
221
230
|
//#endregion
|
|
222
231
|
|
|
223
232
|
|
|
@@ -2,10 +2,11 @@ import {IEnhancement, BEAllProps} from '../trans-render/be/types';
|
|
|
2
2
|
import { HasIshList } from '../trans-render/dss/types';
|
|
3
3
|
|
|
4
4
|
export interface EndUserProps extends IEnhancement{
|
|
5
|
-
|
|
5
|
+
each: string;
|
|
6
6
|
mapIdxTo: string;
|
|
7
7
|
idxStart: number;
|
|
8
8
|
idleTimeout: number;
|
|
9
|
+
options: Partial<EndUserProps>;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export interface AllProps extends EndUserProps{
|
|
@@ -257,6 +257,8 @@ export interface LogicOp<Props = any>{
|
|
|
257
257
|
|
|
258
258
|
delay?: number,
|
|
259
259
|
|
|
260
|
+
do?: (x: Props) => (Promise<Partial<Props>> | Partial<Props>)
|
|
261
|
+
|
|
260
262
|
}
|
|
261
263
|
|
|
262
264
|
export interface SetLogicOps<Props = any>{
|
|
@@ -278,6 +280,8 @@ export interface SetLogicOps<Props = any>{
|
|
|
278
280
|
debug?: boolean,
|
|
279
281
|
|
|
280
282
|
delay?: number,
|
|
283
|
+
|
|
284
|
+
do?: (x: Props) => (Promise<Partial<Props>> | Partial<Props>),
|
|
281
285
|
}
|
|
282
286
|
|
|
283
287
|
export interface Action<MCProps = any, MCActions = MCProps> extends LogicOp<MCProps>{
|
|
@@ -53,7 +53,11 @@ export type DerivationCriteria<TProps, TMethods> = {
|
|
|
53
53
|
path: string,
|
|
54
54
|
from?: number,
|
|
55
55
|
//TODO
|
|
56
|
-
as?: ConvertOptions
|
|
56
|
+
as?: ConvertOptions,
|
|
57
|
+
//TODO - applicable to arrays
|
|
58
|
+
filter?: keyof TModhods & string | ((val: any) => boolean),
|
|
59
|
+
//TODO
|
|
60
|
+
//map?: keyof TModhods & string | ((val: any) => any,
|
|
57
61
|
};
|
|
58
62
|
|
|
59
63
|
export interface TransformOptions{
|
|
@@ -144,6 +148,15 @@ export interface ConditionGate<TProps, TMethods, TElement = {}>{
|
|
|
144
148
|
|
|
145
149
|
}
|
|
146
150
|
|
|
151
|
+
export interface ScopingConfig<TProps=any, TMethods = TProps> {
|
|
152
|
+
name: string;
|
|
153
|
+
config?: IshConfig<TProps, TMethods>;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export type ScopeInstructions<TProps=any, TMethods=TProps> =
|
|
157
|
+
| ScopingConfig
|
|
158
|
+
;
|
|
159
|
+
|
|
147
160
|
export type WhereConditions =
|
|
148
161
|
| string //css matches
|
|
149
162
|
| {
|
|
@@ -183,6 +196,12 @@ export interface ForEach<TProps, TMethods, TElement = {}>{
|
|
|
183
196
|
outOfRangeProp?: string,
|
|
184
197
|
}
|
|
185
198
|
|
|
199
|
+
// export interface MapInstructions<TProps, TMethods, TElement = {}>{
|
|
200
|
+
// // itemCss: CSSQuery,
|
|
201
|
+
// // each: string | [string, IshConfig<TProps, TMethods, TElement>],
|
|
202
|
+
// // in: string | [string, IshConfig<TProps, TMethods, TElement>],
|
|
203
|
+
// }
|
|
204
|
+
|
|
186
205
|
export interface ForEachInterface{
|
|
187
206
|
init(): Promise<void>;
|
|
188
207
|
update(model: any[]): Promise<void>;
|
|
@@ -224,7 +243,7 @@ export interface UnitOfWork<TProps, TMethods = TProps, TElement = {}>{
|
|
|
224
243
|
|
|
225
244
|
forEachBinding?: ForEach<any, any, any>
|
|
226
245
|
/**
|
|
227
|
-
* for each
|
|
246
|
+
* for each -- deprecated?
|
|
228
247
|
*/
|
|
229
248
|
f?: ForEach<any, any, any>,
|
|
230
249
|
|
|
@@ -244,6 +263,7 @@ export interface UnitOfWork<TProps, TMethods = TProps, TElement = {}>{
|
|
|
244
263
|
*/
|
|
245
264
|
invoke?: string,
|
|
246
265
|
|
|
266
|
+
|
|
247
267
|
/**
|
|
248
268
|
* modify the model in a (mostly) declarative way
|
|
249
269
|
*/
|
|
@@ -303,7 +323,9 @@ export interface UnitOfWork<TProps, TMethods = TProps, TElement = {}>{
|
|
|
303
323
|
*/
|
|
304
324
|
w?: WhereConditions,
|
|
305
325
|
|
|
306
|
-
y?: number | YieldSettings<TProps
|
|
326
|
+
y?: number | YieldSettings<TProps>,
|
|
327
|
+
|
|
328
|
+
$?: ScopeInstructions<TProps, TMethods>,
|
|
307
329
|
}
|
|
308
330
|
|
|
309
331
|
export interface YieldSettings<TProps>{
|
|
@@ -455,7 +477,7 @@ export interface TransRenderMethods{
|
|
|
455
477
|
skipInit: boolean,
|
|
456
478
|
}
|
|
457
479
|
|
|
458
|
-
import {OConfig} from './froop/types';
|
|
480
|
+
import {IshConfig, OConfig} from './froop/types';
|
|
459
481
|
export interface MntCfg<TProps = any, TActions = TProps, ETProps = TProps> extends OConfig<TProps, TActions, ETProps>{
|
|
460
482
|
mainTemplate: string | HTMLTemplateElement,
|
|
461
483
|
/**
|