-
Notifications
You must be signed in to change notification settings - Fork 0
/
Seeker.js
81 lines (81 loc) · 3.18 KB
/
Seeker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { find, getSubProp } from 'trans-render/dss/find.js';
export class Seeker {
specifier;
doCallback;
constructor(specifier, doCallback) {
this.specifier = specifier;
this.doCallback = doCallback;
}
val;
async do(self, ctx, enhancedElement, within) {
const { specifier } = this;
const { evt, prop, s, scopeS, ms } = specifier;
let signal = undefined;
let eventSuggestion = undefined;
let signalRef = await find(enhancedElement, specifier, within);
let propagator = undefined;
switch (s) {
case '|':
if (signalRef.hasAttribute('contenteditable')) {
signal = new WeakRef(signalRef);
eventSuggestion = 'input';
}
else {
[signalRef, signal, eventSuggestion] = await this.addValue(signalRef);
}
break;
case '$0':
case '%':
case '@':
case '#': {
if (!signalRef)
throw 404;
signal = new WeakRef(signalRef);
eventSuggestion = evt || 'input';
break;
}
case '~':
case '-':
case '/': {
let propToSubscribeTo = prop;
switch (s) {
case '~': {
//TODO: the line below is likely to appear elsewhere, share it
const subPropToConsider = getSubProp(specifier, enhancedElement);
const { camelToLisp } = await import('trans-render/lib/camelToLisp.js');
const localName = camelToLisp(prop);
const { substrBefore } = await import('trans-render/lib/substrBefore.js');
propToSubscribeTo = substrBefore(substrBefore(subPropToConsider, '.'), '|');
}
}
await customElements.whenDefined(signalRef.localName);
propagator = signalRef.propagator;
if (!propagator) {
const { emc } = await import('be-propagating/behivior.js');
const bePropagating = await signalRef.beEnhanced.whenResolved(emc);
const signal2 = await bePropagating.getGate(prop);
propagator = signal2.propagator;
}
eventSuggestion = propToSubscribeTo;
signal = new WeakRef(signalRef);
break;
}
}
if (this.doCallback && signalRef !== undefined && eventSuggestion !== undefined) {
await this.callback(self, signalRef, eventSuggestion, propagator, ctx);
}
return {
signal,
eventSuggestion,
propagator,
};
}
async callback(self, signalRef, eventSuggestion, propagator, ctx) {
}
async addValue(signalRef) {
const { emc } = await import('be-value-added/behivior.js');
const newSignalRef = await signalRef.beEnhanced.whenResolved(emc);
const signal = new WeakRef(newSignalRef);
return [newSignalRef, signal, 'value'];
}
}