mount-observer 0.0.97 → 0.0.99

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mount-observer",
3
- "version": "0.0.97",
3
+ "version": "0.0.99",
4
4
  "description": "Observe and act on css matches.",
5
5
  "main": "MountObserver.js",
6
6
  "module": "MountObserver.js",
@@ -69,6 +69,10 @@
69
69
  "default": "./refid/joinMatching.js",
70
70
  "types": "./refid/joinMatching.ts"
71
71
  },
72
+ "./refid/nudge.js": {
73
+ "default": "./refid/nudge.js",
74
+ "types": "./refid/nudge.ts"
75
+ },
72
76
  "./refid/refs.js": {
73
77
  "default": "./refid/refs.js",
74
78
  "types": "./refid/refs.ts"
package/refid/genIds.js CHANGED
@@ -25,16 +25,16 @@ export function genIds(enhancedElement) {
25
25
  for (const hi of hashIds) {
26
26
  if (!(hi instanceof HTMLElement))
27
27
  continue;
28
- const { localName } = hi;
29
- if (uniqueCheck.has(localName))
28
+ const idName = hi.getAttribute('itemscope') || hi.localName;
29
+ if (uniqueCheck.has(idName))
30
30
  throw 500;
31
- uniqueCheck.add(localName);
31
+ uniqueCheck.add(idName);
32
32
  let sideEffects = '';
33
33
  const hashValue = hi.getAttribute('#');
34
34
  if (hashValue) {
35
35
  sideEffects = `${hashValue} `;
36
36
  }
37
- hi.dataset.id = `{{${sideEffects}${localName}}}`;
37
+ hi.dataset.id = `{{${sideEffects}${idName}}}`;
38
38
  hi.removeAttribute('#');
39
39
  }
40
40
  //now find all elements with attribute @
@@ -54,6 +54,23 @@ export function genIds(enhancedElement) {
54
54
  nameEl.dataset.id = `{{${sideEffects}${val}}}`;
55
55
  nameEl.removeAttribute('@');
56
56
  }
57
+ //now find all elements with attribute |
58
+ const itemprops = Array.from(scopeFragment.querySelectorAll('[itemprop]:not([itemprop=""])[\\|]')).filter(x => inScope(scopeFragment, x));
59
+ for (const itempropEl of itemprops) {
60
+ if (!(itempropEl instanceof HTMLElement))
61
+ continue;
62
+ const val = itempropEl.getAttribute('itemprop');
63
+ if (uniqueCheck.has(val))
64
+ throw 500;
65
+ uniqueCheck.add(val);
66
+ let sideEffects = '';
67
+ const nameValue = itempropEl.getAttribute('|');
68
+ if (nameValue) {
69
+ sideEffects = `${nameValue} `;
70
+ }
71
+ itempropEl.dataset.id = `{{${sideEffects}${val}}}`;
72
+ itempropEl.removeAttribute('|');
73
+ }
57
74
  const dataIds = Array.from(scopeFragment.querySelectorAll('[data-id^="{{"][data-id$="}}"]')).filter(x => inScope(scopeFragment, x));
58
75
  const ids = [];
59
76
  for (const di of dataIds) {
@@ -69,6 +86,8 @@ export function genIds(enhancedElement) {
69
86
  throw 500;
70
87
  ids.push(id);
71
88
  }
89
+ if (ids.length === 0)
90
+ return;
72
91
  const allChildren = Array.from(scopeFragment.querySelectorAll('*')).filter(x => inScope(scopeFragment, x));
73
92
  if (scopeFragment instanceof Element)
74
93
  allChildren.push(scopeFragment);
package/refid/genIds.ts CHANGED
@@ -26,15 +26,15 @@ export function genIds(enhancedElement: Element){
26
26
  const uniqueCheck = new Set();
27
27
  for(const hi of hashIds){
28
28
  if(!(hi instanceof HTMLElement)) continue;
29
- const {localName} = hi;
30
- if(uniqueCheck.has(localName)) throw 500;
31
- uniqueCheck.add(localName);
29
+ const idName = hi.getAttribute('itemscope') || hi.localName;
30
+ if(uniqueCheck.has(idName)) throw 500;
31
+ uniqueCheck.add(idName);
32
32
  let sideEffects = '';
33
33
  const hashValue = hi.getAttribute('#');
34
34
  if(hashValue){
35
35
  sideEffects = `${hashValue} `;
36
36
  }
37
- hi.dataset.id = `{{${sideEffects}${localName}}}`;
37
+ hi.dataset.id = `{{${sideEffects}${idName}}}`;
38
38
  hi.removeAttribute('#');
39
39
  }
40
40
 
@@ -54,6 +54,22 @@ export function genIds(enhancedElement: Element){
54
54
  nameEl.removeAttribute('@');
55
55
  }
56
56
 
57
+ //now find all elements with attribute |
58
+ const itemprops = Array.from(scopeFragment.querySelectorAll('[itemprop]:not([itemprop=""])[\\|]')).filter(x => inScope(scopeFragment, x));
59
+ for(const itempropEl of itemprops){
60
+ if(!(itempropEl instanceof HTMLElement)) continue;
61
+ const val = itempropEl.getAttribute('itemprop');
62
+ if(uniqueCheck.has(val)) throw 500;
63
+ uniqueCheck.add(val);
64
+ let sideEffects = '';
65
+ const nameValue = itempropEl.getAttribute('|');
66
+ if(nameValue){
67
+ sideEffects = `${nameValue} `;
68
+ }
69
+ itempropEl.dataset.id = `{{${sideEffects}${val}}}`;
70
+ itempropEl.removeAttribute('|');
71
+ }
72
+
57
73
  const dataIds = Array.from(scopeFragment.querySelectorAll('[data-id^="{{"][data-id$="}}"]')).filter(x => inScope(scopeFragment, x));
58
74
  const ids: Array<string> = [];
59
75
  for(const di of dataIds){
@@ -66,7 +82,7 @@ export function genIds(enhancedElement: Element){
66
82
  if(ids.includes(id)) throw 500;
67
83
  ids.push(id);
68
84
  }
69
-
85
+ if(ids.length === 0) return;
70
86
  const allChildren = Array.from(scopeFragment.querySelectorAll('*')).filter(x => inScope(scopeFragment, x));
71
87
  if(scopeFragment instanceof Element) allChildren.push(scopeFragment);
72
88
 
@@ -0,0 +1,28 @@
1
+ import {IEnhancement, BEAllProps} from '../trans-render/be/types';
2
+ import { Specifier } from '../trans-render/dss/types';
3
+
4
+ export interface EndUserProps extends IEnhancement{}
5
+
6
+ export interface AP extends EndUserProps{
7
+ parsedStatements: Array<IncParameters>,
8
+ rawStatements: Array<string>,
9
+ }
10
+
11
+ export type AllProps = AP;
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 & BEAllProps): ProPAP;
21
+
22
+ }
23
+
24
+ export interface IncParameters {
25
+ targetSpecifier: Specifier,
26
+ sourceSpecifier: Specifier,
27
+ localEventType?: string,
28
+ }
@@ -0,0 +1,28 @@
1
+ import {IEnhancement, BEAllProps} from '../trans-render/be/types';
2
+ import { Specifier } from '../trans-render/dss/types';
3
+
4
+ export interface EndUserProps extends IEnhancement{
5
+
6
+ }
7
+
8
+ export interface AP extends EndUserProps{
9
+ parsedStatements: Array<InvokingParameters>,
10
+ rawStatements: Array<string>,
11
+ }
12
+
13
+ export type AllProps = AP;
14
+
15
+ export type PAP = Partial<AP>;
16
+
17
+ export type ProPAP = Promise<PAP>
18
+
19
+ export type BAP = AP & BEAllProps;
20
+
21
+ export interface Actions{
22
+ hydrate(self: this): ProPAP;
23
+ }
24
+
25
+ export interface InvokingParameters {
26
+ remoteSpecifier: Specifier,
27
+ localEventType?: string,
28
+ }
@@ -0,0 +1,27 @@
1
+ import {IEnhancement, BEAllProps} from '../trans-render/be/types';
2
+ import { Specifier } from '../trans-render/dss/types';
3
+
4
+ export interface EndUserProps extends IEnhancement{}
5
+
6
+ export interface AP extends EndUserProps{
7
+ parsedStatements: Array<TogglingParameters>,
8
+ rawStatements: Array<string>,
9
+ }
10
+
11
+ export type AllProps = AP;
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 & BEAllProps): ProPAP;
21
+
22
+ }
23
+
24
+ export interface TogglingParameters {
25
+ remoteSpecifier: Specifier,
26
+ localEventType?: string,
27
+ }
@@ -5,6 +5,8 @@ export type Target = ID | Host | Hostish;
5
5
 
6
6
  export type MindReadProp = ``;
7
7
  export type PropPath = `?.${string}`;
8
+
9
+ export type Prop = string;
8
10
  export type ConstVal = `\`${string}\``;
9
11
 
10
12
  export type asOptions =
@@ -19,7 +21,7 @@ export type asOptions =
19
21
  export type MindReadType = ``;
20
22
  export type TypeQualifier = `-as-${asOptions}`;
21
23
 
22
- export type ValExpression = `${PropPath | ConstVal | MindReadProp}${TypeQualifier | MindReadType}`;
24
+ export type ValExpression = `${Prop | PropPath | ConstVal | MindReadProp}${TypeQualifier | MindReadType}`;
23
25
 
24
26
  export type MindReadEvent = ``;
25
27