mount-observer 0.0.93 → 0.0.95
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/package.json +5 -1
- package/refid/genIds.js +21 -9
- package/refid/genIds.ts +19 -8
- package/refid/hostish.js +4 -4
- package/refid/hostish.ts +5 -4
- package/ts-refs/be-switched/types.d.ts +9 -5
- package/ts-refs/trans-render/dss/types.d.ts +17 -183
- package/ts-refs/trans-render/lib/prs/types.d.ts +1 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mount-observer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.95",
|
|
4
4
|
"description": "Observe and act on css matches.",
|
|
5
5
|
"main": "MountObserver.js",
|
|
6
6
|
"module": "MountObserver.js",
|
|
@@ -57,6 +57,10 @@
|
|
|
57
57
|
"default": "./refid/getAdjRefs.js",
|
|
58
58
|
"types": "./refid/getAdjRefs.ts"
|
|
59
59
|
},
|
|
60
|
+
"./refid/getCount.js": {
|
|
61
|
+
"default": "./refid/getCount.js",
|
|
62
|
+
"types": "./refid/getCount.ts"
|
|
63
|
+
},
|
|
60
64
|
"./refid/joinMatching.js": {
|
|
61
65
|
"default": "./refid/joinMatching.js",
|
|
62
66
|
"types": "./refid/joinMatching.ts"
|
package/refid/genIds.js
CHANGED
|
@@ -4,12 +4,23 @@ const attrMap = {
|
|
|
4
4
|
'@': 'name',
|
|
5
5
|
'|': 'itemprop',
|
|
6
6
|
};
|
|
7
|
+
const scopeMatches = '[itemscope],fieldset';
|
|
8
|
+
export function inScope(scopeFragment, el) {
|
|
9
|
+
const closest = el.closest(scopeMatches); //TODO account for itemref?
|
|
10
|
+
if (closest === null)
|
|
11
|
+
return true;
|
|
12
|
+
if (scopeFragment === closest)
|
|
13
|
+
return true;
|
|
14
|
+
if (scopeFragment.contains(closest))
|
|
15
|
+
return false;
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
7
18
|
export function genIds(enhancedElement) {
|
|
8
|
-
const {
|
|
9
|
-
if
|
|
10
|
-
|
|
19
|
+
// const {parentElement} = enhancedElement;
|
|
20
|
+
// if(parentElement === null) throw 404;
|
|
21
|
+
const scopeFragment = (enhancedElement.closest(scopeMatches) || enhancedElement.getRootNode());
|
|
11
22
|
//first find all elements with attribute #
|
|
12
|
-
const hashIds = Array.from(
|
|
23
|
+
const hashIds = Array.from(scopeFragment.querySelectorAll('[\\#]')).filter(x => inScope(scopeFragment, x));
|
|
13
24
|
const uniqueCheck = new Set();
|
|
14
25
|
for (const hi of hashIds) {
|
|
15
26
|
if (!(hi instanceof HTMLElement))
|
|
@@ -26,7 +37,7 @@ export function genIds(enhancedElement) {
|
|
|
26
37
|
hi.dataset.id = `{{${sideEffects}${localName}}}`;
|
|
27
38
|
hi.removeAttribute('#');
|
|
28
39
|
}
|
|
29
|
-
const dataIds = Array.from(
|
|
40
|
+
const dataIds = Array.from(scopeFragment.querySelectorAll('[data-id^="{{"][data-id$="}}"]')).filter(x => inScope(scopeFragment, x));
|
|
30
41
|
const ids = [];
|
|
31
42
|
for (const di of dataIds) {
|
|
32
43
|
if (!(di instanceof HTMLElement))
|
|
@@ -41,8 +52,9 @@ export function genIds(enhancedElement) {
|
|
|
41
52
|
throw 500;
|
|
42
53
|
ids.push(id);
|
|
43
54
|
}
|
|
44
|
-
const allChildren = Array.from(
|
|
45
|
-
|
|
55
|
+
const allChildren = Array.from(scopeFragment.querySelectorAll('*')).filter(x => inScope(scopeFragment, x));
|
|
56
|
+
if (scopeFragment instanceof Element)
|
|
57
|
+
allChildren.push(scopeFragment);
|
|
46
58
|
const idLookup = {};
|
|
47
59
|
const base = 'gid';
|
|
48
60
|
for (const child of allChildren) {
|
|
@@ -124,7 +136,7 @@ export function genIds(enhancedElement) {
|
|
|
124
136
|
nudge(child, name);
|
|
125
137
|
}
|
|
126
138
|
}
|
|
127
|
-
if ('disabled' in
|
|
128
|
-
nudge(
|
|
139
|
+
if (scopeFragment instanceof Element && 'disabled' in scopeFragment) {
|
|
140
|
+
nudge(scopeFragment);
|
|
129
141
|
}
|
|
130
142
|
}
|
package/refid/genIds.ts
CHANGED
|
@@ -6,12 +6,23 @@ const attrMap = {
|
|
|
6
6
|
'|': 'itemprop',
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
const scopeMatches = '[itemscope],fieldset';
|
|
10
|
+
|
|
11
|
+
export function inScope(scopeFragment: DocumentFragment | Element, el: Element){
|
|
12
|
+
const closest = el.closest(scopeMatches);//TODO account for itemref?
|
|
13
|
+
if(closest === null) return true;
|
|
14
|
+
if(scopeFragment === closest) return true;
|
|
15
|
+
if(scopeFragment.contains(closest)) return false;
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
export function genIds(enhancedElement: Element){
|
|
10
|
-
const {parentElement} = enhancedElement;
|
|
11
|
-
if(parentElement === null) throw 404;
|
|
20
|
+
// const {parentElement} = enhancedElement;
|
|
21
|
+
// if(parentElement === null) throw 404;
|
|
22
|
+
const scopeFragment = (enhancedElement.closest(scopeMatches) || enhancedElement.getRootNode()) as DocumentFragment | Element;
|
|
12
23
|
|
|
13
24
|
//first find all elements with attribute #
|
|
14
|
-
const hashIds = Array.from(
|
|
25
|
+
const hashIds = Array.from(scopeFragment.querySelectorAll('[\\#]')).filter(x => inScope(scopeFragment, x));
|
|
15
26
|
const uniqueCheck = new Set();
|
|
16
27
|
for(const hi of hashIds){
|
|
17
28
|
if(!(hi instanceof HTMLElement)) continue;
|
|
@@ -27,7 +38,7 @@ export function genIds(enhancedElement: Element){
|
|
|
27
38
|
hi.removeAttribute('#');
|
|
28
39
|
}
|
|
29
40
|
|
|
30
|
-
const dataIds = Array.from(
|
|
41
|
+
const dataIds = Array.from(scopeFragment.querySelectorAll('[data-id^="{{"][data-id$="}}"]')).filter(x => inScope(scopeFragment, x));
|
|
31
42
|
const ids: Array<string> = [];
|
|
32
43
|
for(const di of dataIds){
|
|
33
44
|
if(!(di instanceof HTMLElement)) continue;
|
|
@@ -40,8 +51,8 @@ export function genIds(enhancedElement: Element){
|
|
|
40
51
|
ids.push(id);
|
|
41
52
|
}
|
|
42
53
|
|
|
43
|
-
const allChildren = Array.from(
|
|
44
|
-
allChildren.push(
|
|
54
|
+
const allChildren = Array.from(scopeFragment.querySelectorAll('*')).filter(x => inScope(scopeFragment, x));
|
|
55
|
+
if(scopeFragment instanceof Element) allChildren.push(scopeFragment);
|
|
45
56
|
|
|
46
57
|
const idLookup: {[key: string]: string} = {};
|
|
47
58
|
const base = 'gid';
|
|
@@ -120,7 +131,7 @@ export function genIds(enhancedElement: Element){
|
|
|
120
131
|
nudge(child, name);
|
|
121
132
|
}
|
|
122
133
|
}
|
|
123
|
-
if('disabled' in
|
|
124
|
-
nudge(
|
|
134
|
+
if(scopeFragment instanceof Element && 'disabled' in scopeFragment){
|
|
135
|
+
nudge(scopeFragment);
|
|
125
136
|
}
|
|
126
137
|
}
|
package/refid/hostish.js
CHANGED
|
@@ -4,14 +4,14 @@ Element.prototype.hostish = async function () {
|
|
|
4
4
|
if (closest === null)
|
|
5
5
|
return this.getRootNode().host;
|
|
6
6
|
const { localName } = closest;
|
|
7
|
-
if (localName.includes('-')) {
|
|
8
|
-
await customElements.whenDefined(localName);
|
|
9
|
-
return closest;
|
|
10
|
-
}
|
|
11
7
|
const itemScopeAttr = closest.getAttribute('itemscope');
|
|
12
8
|
if (itemScopeAttr) {
|
|
13
9
|
const { waitForIsh } = await import('mount-observer/waitForIsh.js');
|
|
14
10
|
return await waitForIsh(closest);
|
|
15
11
|
}
|
|
12
|
+
if (localName.includes('-')) {
|
|
13
|
+
await customElements.whenDefined(localName);
|
|
14
|
+
return closest;
|
|
15
|
+
}
|
|
16
16
|
return this.getRootNode().host;
|
|
17
17
|
};
|
package/refid/hostish.ts
CHANGED
|
@@ -5,14 +5,15 @@ Element.prototype.hostish = async function(){
|
|
|
5
5
|
const closest = this.closest('[itemscope]') as HTMLElement;
|
|
6
6
|
if(closest === null) return (<any>this.getRootNode()).host;
|
|
7
7
|
const {localName} = closest;
|
|
8
|
-
if(localName.includes('-')){
|
|
9
|
-
await customElements.whenDefined(localName);
|
|
10
|
-
return closest;
|
|
11
|
-
}
|
|
12
8
|
const itemScopeAttr = closest.getAttribute('itemscope');
|
|
13
9
|
if(itemScopeAttr){
|
|
14
10
|
const {waitForIsh} = await import('mount-observer/waitForIsh.js');
|
|
15
11
|
return await waitForIsh(closest);
|
|
16
12
|
}
|
|
13
|
+
if(localName.includes('-')){
|
|
14
|
+
await customElements.whenDefined(localName);
|
|
15
|
+
return closest;
|
|
16
|
+
}
|
|
17
|
+
|
|
17
18
|
return (<any>this.getRootNode()).host;
|
|
18
19
|
}
|
|
@@ -4,7 +4,11 @@ import {BEAllProps, EMC, IEnhancement} from '../trans-render/be/types';
|
|
|
4
4
|
//import {AP as BPAP, ISignal, Actions as BPActions} from 'be-propagating/types';
|
|
5
5
|
//import {ElTypes, SignalRefType} from 'be-linked/types';
|
|
6
6
|
//import { Propagator } from "../trans-render/froop/PropSvc";
|
|
7
|
-
import {
|
|
7
|
+
import {Specifier} from '../trans-render/dss/types';
|
|
8
|
+
|
|
9
|
+
export interface Element{
|
|
10
|
+
hostish(): Promise<any>
|
|
11
|
+
}
|
|
8
12
|
|
|
9
13
|
export interface EndUserProps extends IEnhancement<HTMLTemplateElement>{
|
|
10
14
|
lhs?: any,
|
|
@@ -58,7 +62,7 @@ export type SwitchStatement = string;
|
|
|
58
62
|
|
|
59
63
|
export interface OneValueSwitch{
|
|
60
64
|
ifPart: string,
|
|
61
|
-
|
|
65
|
+
specifier: Specifier,
|
|
62
66
|
req?: boolean,
|
|
63
67
|
}
|
|
64
68
|
|
|
@@ -72,8 +76,8 @@ export interface TwoPartOpStatement{
|
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
export interface TwoValueSwitch{
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
lhsSpecifier: Specifier,
|
|
80
|
+
rhsSpecifier: Specifier,
|
|
77
81
|
req?: boolean,
|
|
78
82
|
op?: Op,
|
|
79
83
|
lhs?: ISide,
|
|
@@ -86,7 +90,7 @@ export interface TwoValueSwitch{
|
|
|
86
90
|
|
|
87
91
|
}
|
|
88
92
|
|
|
89
|
-
export interface Dependency extends
|
|
93
|
+
export interface Dependency extends Specifier{}
|
|
90
94
|
|
|
91
95
|
export interface CanBeSwitchedOn {
|
|
92
96
|
switchedOn?: boolean,
|
|
@@ -1,55 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export type ID = `#${string}`;
|
|
2
|
+
export type Host = `:host()`;
|
|
3
|
+
export type Hostish = ``;
|
|
4
|
+
export type Target = ID | Host | Hostish;
|
|
3
5
|
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
export type
|
|
7
|
-
/**
|
|
8
|
-
* upward direction, non recursive
|
|
9
|
-
*/
|
|
10
|
-
|'^'
|
|
11
|
-
/**
|
|
12
|
-
* downward direction, next element siblings only
|
|
13
|
-
*/
|
|
14
|
-
|'Y'
|
|
15
|
-
/**
|
|
16
|
-
* IdRef query
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|'?'
|
|
20
|
-
/**
|
|
21
|
-
* self
|
|
22
|
-
*/
|
|
23
|
-
|'.'
|
|
24
|
-
/**
|
|
25
|
-
* modulo
|
|
26
|
-
*/
|
|
27
|
-
|'%'
|
|
28
|
-
/**
|
|
29
|
-
* itemscoped host
|
|
30
|
-
*/
|
|
31
|
-
|'$'
|
|
32
|
-
/**
|
|
33
|
-
* comment scope
|
|
34
|
-
*/
|
|
35
|
-
|'/**/'
|
|
36
|
-
;
|
|
37
|
-
|
|
38
|
-
export type AttrSigils =
|
|
39
|
-
/**
|
|
40
|
-
* Reference to self / local element
|
|
41
|
-
*/
|
|
42
|
-
'$0' |
|
|
43
|
-
/**
|
|
44
|
-
* Reference by ID
|
|
45
|
-
*/
|
|
46
|
-
'#' | '@' | '-' | '|' | '%';
|
|
47
|
-
|
|
48
|
-
export type ElementSigils = '/' | '~';
|
|
49
|
-
|
|
50
|
-
export type ScopeSigils = '';
|
|
51
|
-
|
|
52
|
-
export type Sigils = AttrSigils | ElementSigils | ScopeSigils;
|
|
6
|
+
export type MindReadProp = ``;
|
|
7
|
+
export type PropPath = `?.${string}`;
|
|
8
|
+
export type ConstVal = `\`${string}\``;
|
|
53
9
|
|
|
54
10
|
export type asOptions =
|
|
55
11
|
| 'number'
|
|
@@ -60,113 +16,32 @@ export type asOptions =
|
|
|
60
16
|
| 'urlpattern'
|
|
61
17
|
| 'boolean|number'
|
|
62
18
|
;
|
|
19
|
+
export type MindReadType = ``;
|
|
20
|
+
export type TypeQualifier = `-as-${asOptions}`;
|
|
63
21
|
|
|
64
|
-
export
|
|
65
|
-
ceName?: string,
|
|
66
|
-
itemProp?: string,
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface $ScopeHierarchy {
|
|
70
|
-
home: Element;
|
|
71
|
-
satellites?: Array<Element>;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// deprecated
|
|
75
|
-
export interface Specifier {
|
|
76
|
-
/** Directional Scope Sigil */
|
|
77
|
-
dss?: DirectionalScopeSigils,
|
|
78
|
-
/**
|
|
79
|
-
* recursive
|
|
80
|
-
*/
|
|
81
|
-
rec?: boolean,
|
|
82
|
-
/**
|
|
83
|
-
* root node fallback
|
|
84
|
-
*/
|
|
85
|
-
rnf?: boolean,
|
|
86
|
-
/**
|
|
87
|
-
* include siblings in scope search
|
|
88
|
-
*/
|
|
89
|
-
isiss?: boolean,
|
|
90
|
-
scopeS?: CSSSelector,
|
|
91
|
-
elS?: CSSSelector,
|
|
92
|
-
el?: string,
|
|
93
|
-
idRefS?: string,
|
|
94
|
-
s?: Sigils,
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Inferred prop name
|
|
98
|
-
* This should be the last token word of the DSS expression
|
|
99
|
-
*/
|
|
100
|
-
prop?: InferredPropName,
|
|
101
|
-
path?: SubPropPath;
|
|
102
|
-
/**
|
|
103
|
-
* Event Name
|
|
104
|
-
*/
|
|
105
|
-
evt?: EventName;
|
|
22
|
+
export type ValExpression = `${PropPath | ConstVal | MindReadProp}${TypeQualifier | MindReadType}`;
|
|
106
23
|
|
|
107
|
-
|
|
108
|
-
* RoundAbout Prop events to listen for
|
|
109
|
-
*/
|
|
110
|
-
raps?: Array<string>;
|
|
24
|
+
export type MindReadEvent = ``;
|
|
111
25
|
|
|
112
|
-
|
|
113
|
-
self?: boolean;
|
|
114
|
-
/**
|
|
115
|
-
* must have a dash in the localName
|
|
116
|
-
* wait for whenDefined in find
|
|
117
|
-
*/
|
|
118
|
-
host?: boolean;
|
|
119
|
-
/**
|
|
120
|
-
* host prop
|
|
121
|
-
*/
|
|
122
|
-
hp?: string;
|
|
123
|
-
/**
|
|
124
|
-
* host prop fallback
|
|
125
|
-
*/
|
|
126
|
-
hpf?: string;
|
|
127
|
-
|
|
128
|
-
as?: asOptions
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* is a scope query within the aria-[row|col|row]index[text]
|
|
132
|
-
*/
|
|
133
|
-
isModulo?: boolean;
|
|
134
|
-
/**
|
|
135
|
-
* Specify which aria-[?]index to use
|
|
136
|
-
*/
|
|
137
|
-
modulo?: Modulo;
|
|
26
|
+
export type EventPart = `::${string}`;
|
|
138
27
|
|
|
139
|
-
|
|
140
|
-
* is a scope query within comments
|
|
141
|
-
*/
|
|
142
|
-
cmtWrap?: boolean;
|
|
28
|
+
export type DSS = `${Target}${ValExpression}${EventPart}`;
|
|
143
29
|
|
|
144
|
-
/**
|
|
145
|
-
* itemscope hierarchy domain specifier
|
|
146
|
-
*/
|
|
147
|
-
is$cope?: boolean;
|
|
148
30
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
constVal?: any;
|
|
152
|
-
|
|
153
|
-
enhBase?: string;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export interface IPE {
|
|
31
|
+
export interface Specifier {
|
|
157
32
|
id?: string,
|
|
158
33
|
prop?: string,
|
|
159
34
|
path?: SubPropPath,
|
|
160
|
-
evtName?:
|
|
35
|
+
evtName?: EventName,
|
|
161
36
|
as?: asOptions,
|
|
162
37
|
constVal?: any;
|
|
163
38
|
enhKey?: string;
|
|
164
39
|
ish?: boolean;
|
|
40
|
+
//element to observe must be a shadowed custom element host.
|
|
41
|
+
host?: boolean;
|
|
165
42
|
}
|
|
166
43
|
|
|
167
|
-
export type Modulo = 'aria-rowindex' | 'aria-colindex' | 'aria-rowindextext'
|
|
168
44
|
|
|
169
|
-
export type InferredPropName = string;
|
|
170
45
|
|
|
171
46
|
/**
|
|
172
47
|
* can contain dot (.) for sub property access and pipes (|) for method invocations
|
|
@@ -175,44 +50,3 @@ export type SubPropPath = string;
|
|
|
175
50
|
|
|
176
51
|
export type EventName = string;
|
|
177
52
|
|
|
178
|
-
export type CSSSelector = string;
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* starts with a dash, typically all kebab case
|
|
182
|
-
* inferred prop name will be camel cased based on this.
|
|
183
|
-
*/
|
|
184
|
-
export type MarkerString = string;
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* PIP stands for Partner in Prop (for now) -- supports bi-directional data flow to property
|
|
188
|
-
* IP stands for In Prop (for now) -- Data only Flow only goes in
|
|
189
|
-
* OP s
|
|
190
|
-
*/
|
|
191
|
-
|
|
192
|
-
export interface GetPIPOptions{
|
|
193
|
-
//name of event to listen for for when the prop being monitored for changes
|
|
194
|
-
evtName?: string,
|
|
195
|
-
isRoundAboutReady?: boolean;
|
|
196
|
-
prop?: string,
|
|
197
|
-
sota?: string,
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Partner In Prop
|
|
202
|
-
*/
|
|
203
|
-
export interface PIP<TProp = any, TElement = Element> extends EventListenerObject{
|
|
204
|
-
readonly propagator: EventTarget;
|
|
205
|
-
async getValue(el: TElement): Promise<TProp | undefined>;
|
|
206
|
-
async setValue(el: TElement, val: TProp);
|
|
207
|
-
async hydrate(el: TElement);
|
|
208
|
-
syncVal(el: TElement);
|
|
209
|
-
disconnect();
|
|
210
|
-
toString(nv: TProp): string;
|
|
211
|
-
readonly outEvtName: string;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
export interface HasIshList {
|
|
217
|
-
ishList: Array<any>;
|
|
218
|
-
}
|
|
@@ -25,13 +25,10 @@ export interface ElO {
|
|
|
25
25
|
export interface RegExpExt<TStatementGroup = any>{
|
|
26
26
|
regExp: RegExp | string,
|
|
27
27
|
defaultVals: Partial<TStatementGroup>,
|
|
28
|
-
// deprecated
|
|
29
28
|
dssKeys?: [string, string][],
|
|
30
|
-
// deprecated
|
|
31
29
|
dssArrayKeys?: [string, string][],
|
|
32
30
|
statementPartParser?: StatementPartParser,
|
|
33
|
-
|
|
34
|
-
ipeArrayKeys?: [string, string][];
|
|
31
|
+
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
export interface StatementPartParser {
|