mount-observer 0.0.61 → 0.0.62
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/Newish.js +21 -5
- package/Newish.ts +30 -6
- package/package.json +1 -1
- package/ts-refs/trans-render/types.d.ts +19 -1
- package/waitForIsh.js +1 -1
- package/waitForIsh.ts +1 -1
package/Newish.js
CHANGED
|
@@ -50,20 +50,18 @@ export class Newish {
|
|
|
50
50
|
set(nv) {
|
|
51
51
|
if (self.#ce === nv)
|
|
52
52
|
return;
|
|
53
|
-
console.log({ nv });
|
|
54
53
|
self.queue.push(nv);
|
|
55
|
-
self.#assignGingerly();
|
|
54
|
+
self.#assignGingerly(false);
|
|
56
55
|
},
|
|
57
56
|
enumerable: true,
|
|
58
57
|
configurable: true,
|
|
59
58
|
});
|
|
60
|
-
this.#assignGingerly();
|
|
59
|
+
this.#assignGingerly(true);
|
|
61
60
|
//attach any itemref references
|
|
62
61
|
this.#attachItemrefs(enhancedElement);
|
|
63
62
|
const et = ObsAttr(enhancedElement, 'itemref');
|
|
64
63
|
et.addEventListener('attr-changed', this);
|
|
65
64
|
this.isResolved = true;
|
|
66
|
-
enhancedElement.dispatchEvent(new Event('ishAttached'));
|
|
67
65
|
}
|
|
68
66
|
#alreadyAttached = new Set();
|
|
69
67
|
#attachItemrefs(enhancedElement) {
|
|
@@ -86,7 +84,11 @@ export class Newish {
|
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
|
-
async #assignGingerly() {
|
|
87
|
+
async #assignGingerly(fromDo) {
|
|
88
|
+
const actions = new Set();
|
|
89
|
+
if (fromDo) {
|
|
90
|
+
actions.add('attached');
|
|
91
|
+
}
|
|
90
92
|
let ce = this.#ce;
|
|
91
93
|
if (ce === undefined) {
|
|
92
94
|
throw 500;
|
|
@@ -96,11 +98,25 @@ export class Newish {
|
|
|
96
98
|
//TODO: Provide support for a virtual slice of a very large list
|
|
97
99
|
if (Array.isArray(fi)) {
|
|
98
100
|
ce.ishList = fi;
|
|
101
|
+
actions.add('ishListAssigned');
|
|
99
102
|
}
|
|
100
103
|
else {
|
|
101
104
|
const { assigner } = this.#options;
|
|
102
105
|
await assigner(ce, fi);
|
|
106
|
+
actions.add('ishAssigned');
|
|
103
107
|
}
|
|
104
108
|
}
|
|
109
|
+
const ref = this.#ref.deref();
|
|
110
|
+
if (ref) {
|
|
111
|
+
ref.dispatchEvent(new IshEvent(Array.from(actions)));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export class IshEvent extends Event {
|
|
116
|
+
actions;
|
|
117
|
+
static eventName = 'ish';
|
|
118
|
+
constructor(actions) {
|
|
119
|
+
super(IshEvent.eventName);
|
|
120
|
+
this.actions = actions;
|
|
105
121
|
}
|
|
106
122
|
}
|
package/Newish.ts
CHANGED
|
@@ -62,20 +62,18 @@ export class Newish implements EventListenerObject {
|
|
|
62
62
|
},
|
|
63
63
|
set(nv: any){
|
|
64
64
|
if(self.#ce === nv) return;
|
|
65
|
-
console.log({nv});
|
|
66
65
|
self.queue.push(nv);
|
|
67
|
-
self.#assignGingerly();
|
|
66
|
+
self.#assignGingerly(false);
|
|
68
67
|
},
|
|
69
68
|
enumerable: true,
|
|
70
69
|
configurable: true,
|
|
71
70
|
});
|
|
72
|
-
this.#assignGingerly();
|
|
71
|
+
this.#assignGingerly(true);
|
|
73
72
|
//attach any itemref references
|
|
74
73
|
this.#attachItemrefs(enhancedElement);
|
|
75
74
|
const et = ObsAttr(enhancedElement, 'itemref');
|
|
76
75
|
et.addEventListener('attr-changed', this);
|
|
77
76
|
this.isResolved = true;
|
|
78
|
-
enhancedElement.dispatchEvent(new Event('ishAttached'));
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
|
|
@@ -102,7 +100,11 @@ export class Newish implements EventListenerObject {
|
|
|
102
100
|
|
|
103
101
|
}
|
|
104
102
|
|
|
105
|
-
async #assignGingerly(){
|
|
103
|
+
async #assignGingerly(fromDo: boolean){
|
|
104
|
+
const actions = new Set<Action>();
|
|
105
|
+
if(fromDo){
|
|
106
|
+
actions.add('attached');
|
|
107
|
+
}
|
|
106
108
|
let ce = this.#ce!;
|
|
107
109
|
if(ce === undefined){
|
|
108
110
|
throw 500;
|
|
@@ -112,13 +114,35 @@ export class Newish implements EventListenerObject {
|
|
|
112
114
|
//TODO: Provide support for a virtual slice of a very large list
|
|
113
115
|
if(Array.isArray(fi)){
|
|
114
116
|
(<any>ce).ishList = fi;
|
|
117
|
+
actions.add('ishListAssigned');
|
|
115
118
|
}else{
|
|
116
119
|
const {assigner} = this.#options;
|
|
117
120
|
await assigner!(ce, fi);
|
|
118
|
-
|
|
121
|
+
actions.add('ishAssigned');
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
}
|
|
125
|
+
const ref = this.#ref.deref();
|
|
126
|
+
if(ref){
|
|
127
|
+
ref.dispatchEvent(new IshEvent(Array.from(actions)));
|
|
128
|
+
}
|
|
122
129
|
}
|
|
123
130
|
|
|
124
131
|
}
|
|
132
|
+
|
|
133
|
+
type Action =
|
|
134
|
+
| 'attached'
|
|
135
|
+
| 'ishAssigned'
|
|
136
|
+
| 'ishListAssigned'
|
|
137
|
+
|
|
138
|
+
interface IIshEvent{
|
|
139
|
+
actions: Array<Action>;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export class IshEvent extends Event implements IIshEvent{
|
|
143
|
+
static eventName = 'ish';
|
|
144
|
+
|
|
145
|
+
constructor(public actions: Array<Action>){
|
|
146
|
+
super(IshEvent.eventName);
|
|
147
|
+
}
|
|
148
|
+
}
|
package/package.json
CHANGED
|
@@ -157,6 +157,11 @@ export type ScopeInstructions<TProps=any, TMethods=TProps> =
|
|
|
157
157
|
| ScopingConfig
|
|
158
158
|
;
|
|
159
159
|
|
|
160
|
+
export interface ScopedLoop<TProps = any, TMethods = TProps>{
|
|
161
|
+
config?: IshConfig<TProps, TMethods>;
|
|
162
|
+
options: Partial<Clone$Options>
|
|
163
|
+
}
|
|
164
|
+
|
|
160
165
|
export type WhereConditions =
|
|
161
166
|
| string //css matches
|
|
162
167
|
| {
|
|
@@ -326,6 +331,8 @@ export interface UnitOfWork<TProps, TMethods = TProps, TElement = {}>{
|
|
|
326
331
|
y?: number | YieldSettings<TProps>,
|
|
327
332
|
|
|
328
333
|
$?: ScopeInstructions<TProps, TMethods>,
|
|
334
|
+
|
|
335
|
+
$$?: ScopedLoop<TProps, TMethods>,
|
|
329
336
|
}
|
|
330
337
|
|
|
331
338
|
export interface YieldSettings<TProps>{
|
|
@@ -546,4 +553,15 @@ export type ZeroOrMore<T> = T | Array<T> | undefined;
|
|
|
546
553
|
*/
|
|
547
554
|
export type StringWithAutocompleteOptions<TOptions> =
|
|
548
555
|
| (string & {})
|
|
549
|
-
| TOptions;
|
|
556
|
+
| TOptions;
|
|
557
|
+
|
|
558
|
+
export interface Clone$Options{
|
|
559
|
+
ish: EventTarget & HasIshList
|
|
560
|
+
seedEl: Element,
|
|
561
|
+
idxStart: number,
|
|
562
|
+
itemProp: string,
|
|
563
|
+
mapIdxTo?: string,
|
|
564
|
+
itemTemplate: HTMLTemplateElement;
|
|
565
|
+
baseCrumb: string,
|
|
566
|
+
idleTimeout: number,
|
|
567
|
+
}
|
package/waitForIsh.js
CHANGED
package/waitForIsh.ts
CHANGED
|
@@ -6,7 +6,7 @@ export function waitForIsh(el: Element) : Promise<EventTarget> {
|
|
|
6
6
|
resolve(ish);
|
|
7
7
|
} else {
|
|
8
8
|
// If the element is not yet defined, wait for it to be defined
|
|
9
|
-
el.addEventListener('
|
|
9
|
+
el.addEventListener('ish', () => {
|
|
10
10
|
const ish = (<any>el)['ish'] as EventTarget;
|
|
11
11
|
if (ish) {
|
|
12
12
|
resolve(ish);
|