mount-observer 0.0.111 → 0.1.0
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/Events.js +28 -26
- package/Events.ts +34 -30
- package/MountObserver.js +235 -520
- package/MountObserver.ts +281 -542
- package/README.md +149 -56
- package/attrCoordinates.js +93 -0
- package/attrCoordinates.ts +122 -0
- package/constants.js +6 -0
- package/constants.ts +7 -0
- package/index.js +3 -0
- package/index.ts +19 -0
- package/loadImports.js +47 -0
- package/loadImports.ts +56 -0
- package/package.json +8 -115
- package/playwright.config.ts +0 -1
- package/types.d.ts +86 -0
- package/whereAttr.js +174 -0
- package/whereAttr.ts +221 -0
- package/LICENSE +0 -21
- package/Newish.js +0 -145
- package/Newish.ts +0 -169
- package/ObsAttr.js +0 -18
- package/ObsAttr.ts +0 -18
- package/RootMutObs.js +0 -49
- package/RootMutObs.ts +0 -58
- package/Synthesizer.js +0 -125
- package/Synthesizer.ts +0 -130
- package/bindish.js +0 -15
- package/bindish.ts +0 -22
- package/compose.js +0 -148
- package/compose.ts +0 -164
- package/doCleanup.js +0 -31
- package/doCleanup.ts +0 -34
- package/getWhereAttrSelector.js +0 -83
- package/getWhereAttrSelector.ts +0 -92
- package/preloadContent.js +0 -44
- package/preloadContent.ts +0 -47
- package/readAttrs.ts +0 -60
- package/refid/README.md +0 -259
- package/refid/arr.js +0 -4
- package/refid/arr.ts +0 -4
- package/refid/camelToKebab.js +0 -4
- package/refid/camelToKebab.ts +0 -4
- package/refid/genIds.js +0 -190
- package/refid/genIds.ts +0 -177
- package/refid/getAdjRefs.js +0 -38
- package/refid/getAdjRefs.ts +0 -38
- package/refid/getContext.js +0 -13
- package/refid/getContext.ts +0 -14
- package/refid/getCount.js +0 -8
- package/refid/getCount.ts +0 -8
- package/refid/getIsh.js +0 -35
- package/refid/getIsh.ts +0 -37
- package/refid/hostish.js +0 -18
- package/refid/hostish.ts +0 -20
- package/refid/ism.js +0 -78
- package/refid/ism.ts +0 -81
- package/refid/itemprops.js +0 -60
- package/refid/itemprops.ts +0 -67
- package/refid/joinMatching.js +0 -56
- package/refid/joinMatching.ts +0 -54
- package/refid/nudge.js +0 -23
- package/refid/nudge.ts +0 -23
- package/refid/regIsh.js +0 -27
- package/refid/regIsh.ts +0 -31
- package/refid/secretKeys.js +0 -5
- package/refid/secretKeys.ts +0 -5
- package/refid/splitRefs.js +0 -6
- package/refid/splitRefs.ts +0 -6
- package/refid/stdVal.js +0 -15
- package/refid/stdVal.ts +0 -15
- package/refid/via.js +0 -114
- package/refid/via.ts +0 -113
- package/slotkin/affine.js +0 -39
- package/slotkin/affine.ts +0 -46
- package/slotkin/beKindred.js +0 -45
- package/slotkin/beKindred.ts +0 -55
- package/slotkin/getBreadth.js +0 -19
- package/slotkin/getBreadth.ts +0 -21
- package/slotkin/getFrag.js +0 -22
- package/slotkin/getFrag.ts +0 -21
- package/slotkin/toQuery.js +0 -12
- package/slotkin/toQuery.ts +0 -13
- package/slotkin/wrap.js +0 -13
- package/slotkin/wrap.ts +0 -18
- package/ts-refs/LICENSE +0 -21
- package/ts-refs/README.md +0 -18
- package/ts-refs/be-a-beacon/types.d.ts +0 -22
- package/ts-refs/be-alit/types.d.ts +0 -1
- package/ts-refs/be-based/types.d.ts +0 -32
- package/ts-refs/be-bound/types.d.ts +0 -65
- package/ts-refs/be-buttoned-up/types.d.ts +0 -21
- package/ts-refs/be-calculating/types.d.ts +0 -57
- package/ts-refs/be-clonable/types.d.ts +0 -28
- package/ts-refs/be-committed/types.d.ts +0 -26
- package/ts-refs/be-consoling/types.d.ts +0 -25
- package/ts-refs/be-counted/types.d.ts +0 -88
- package/ts-refs/be-delible/types.d.ts +0 -26
- package/ts-refs/be-directive/types.d.ts +0 -43
- package/ts-refs/be-dispatching/types.d.ts +0 -41
- package/ts-refs/be-elevating/types.d.ts +0 -55
- package/ts-refs/be-enhanced/types.d.ts +0 -32
- package/ts-refs/be-enhancing/types.d.ts +0 -31
- package/ts-refs/be-evanescent/types.d.ts +0 -20
- package/ts-refs/be-eventing/types.d.ts +0 -27
- package/ts-refs/be-exportable/types.d.ts +0 -26
- package/ts-refs/be-fetching/types.d.ts +0 -73
- package/ts-refs/be-flashy/types.d.ts +0 -27
- package/ts-refs/be-formalizing/types.d.ts +0 -29
- package/ts-refs/be-formidable/types.d.ts +0 -64
- package/ts-refs/be-giddy/types.d.ts +0 -26
- package/ts-refs/be-gingerly/types.d.ts +0 -19
- package/ts-refs/be-gone/types.d.ts +0 -24
- package/ts-refs/be-hashing-out/types.d.ts +0 -22
- package/ts-refs/be-hive/types.d.ts +0 -18
- package/ts-refs/be-imbued/types.d.ts +0 -30
- package/ts-refs/be-included/types.d.ts +0 -20
- package/ts-refs/be-inclusive/types.d.ts +0 -30
- package/ts-refs/be-intersectional/types.d.ts +0 -37
- package/ts-refs/be-intl/types.d.ts +0 -28
- package/ts-refs/be-invoking/types.d.ts +0 -28
- package/ts-refs/be-joining/types.d.ts +0 -26
- package/ts-refs/be-kvetching/types.d.ts +0 -24
- package/ts-refs/be-lazy/types.d.ts +0 -29
- package/ts-refs/be-literate/types.d.ts +0 -29
- package/ts-refs/be-mediating/types.d.ts +0 -34
- package/ts-refs/be-methodical/types.d.ts +0 -20
- package/ts-refs/be-modding/types.d.ts +0 -18
- package/ts-refs/be-observant/types.d.ts +0 -27
- package/ts-refs/be-observing/types.d.ts +0 -84
- package/ts-refs/be-parsed/types.d.ts +0 -19
- package/ts-refs/be-parsing/types.d.ts +0 -37
- package/ts-refs/be-persistent/types.d.ts +0 -66
- package/ts-refs/be-propagating/types.d.ts +0 -26
- package/ts-refs/be-reformable/types.d.ts +0 -48
- package/ts-refs/be-render-neutral/types.d.ts +0 -31
- package/ts-refs/be-scoped/types.d.ts +0 -24
- package/ts-refs/be-sharing/types.d.ts +0 -17
- package/ts-refs/be-switched/types.d.ts +0 -155
- package/ts-refs/be-typed/types.d.ts +0 -36
- package/ts-refs/be-value-added/types.d.ts +0 -34
- package/ts-refs/be-valued/types.d.ts +0 -22
- package/ts-refs/be-written/types.d.ts +0 -59
- package/ts-refs/css-charts/types.d.ts +0 -38
- package/ts-refs/css-echarts/types.d.ts +0 -13
- package/ts-refs/data-props/types.d.ts +0 -27
- package/ts-refs/do-inc/types.d.ts +0 -28
- package/ts-refs/do-invoke/types.d.ts +0 -28
- package/ts-refs/do-toggle/types.d.ts +0 -27
- package/ts-refs/em-bower/types.d.ts +0 -18
- package/ts-refs/fetch-for/types.d.ts +0 -37
- package/ts-refs/folder-picker/types.d.ts +0 -43
- package/ts-refs/for-fetch/doc.d.ts +0 -98
- package/ts-refs/for-fetch/types.d.ts +0 -83
- package/ts-refs/mount-observer/types.d.ts +0 -248
- package/ts-refs/mt-si/types.d.ts +0 -21
- package/ts-refs/per-each/types.d.ts +0 -51
- package/ts-refs/soak-up/types.d.ts +0 -36
- package/ts-refs/trans-render/XV/types.d.ts +0 -69
- package/ts-refs/trans-render/asmr/types.d.ts +0 -138
- package/ts-refs/trans-render/be/types.d.ts +0 -190
- package/ts-refs/trans-render/dss/types.d.ts +0 -57
- package/ts-refs/trans-render/froop/types.d.ts +0 -416
- package/ts-refs/trans-render/funions/types.d.ts +0 -12
- package/ts-refs/trans-render/lib/mixins/types.d.ts +0 -42
- package/ts-refs/trans-render/lib/prs/types.d.ts +0 -40
- package/ts-refs/trans-render/lib/types.d.ts +0 -489
- package/ts-refs/trans-render/types.d.ts +0 -583
- package/ts-refs/wc-info/SimpleWCInfo.d.ts +0 -15
- package/ts-refs/when-resolved/types.d.ts +0 -30
- package/ts-refs/xp-as/types.d.ts +0 -20
- package/ts-refs/xtal-element/types.d.ts +0 -43
- package/ts-refs/xtal-frappe-chart/types.d.ts +0 -193
- package/upShadowSearch.js +0 -25
- package/upShadowSearch.ts +0 -23
- package/waitForEvent.js +0 -12
- package/waitForEvent.ts +0 -13
- package/waitForIsh.js +0 -21
- package/waitForIsh.ts +0 -20
package/refid/via.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import {splitRefs} from './splitRefs.js';
|
|
2
|
-
import {MountObserver} from '../MountObserver.js';
|
|
3
|
-
import {camelToKebab} from './camelToKebab.js';
|
|
4
|
-
const proxies = new WeakMap<Element, ProxyConstructor>();
|
|
5
|
-
const refLookup = new WeakMap<Element, RefLookup>();
|
|
6
|
-
Object.defineProperty(Element.prototype, 'via', {
|
|
7
|
-
get(){
|
|
8
|
-
if(!proxies.has(this)){
|
|
9
|
-
const handler = {
|
|
10
|
-
get(target: Element, prop: string) {
|
|
11
|
-
let lookup: RefLookup;
|
|
12
|
-
if(refLookup.has(target)){
|
|
13
|
-
lookup = refLookup.get(target)!;
|
|
14
|
-
}else{
|
|
15
|
-
lookup = new Map<attr, RefManager>();
|
|
16
|
-
refLookup.set(target, lookup);
|
|
17
|
-
}
|
|
18
|
-
if(lookup.has(prop)){
|
|
19
|
-
return lookup.get(prop);
|
|
20
|
-
}else{
|
|
21
|
-
const refManager = new RefManager(target, prop as string);
|
|
22
|
-
lookup.set(prop, refManager);
|
|
23
|
-
return refManager;
|
|
24
|
-
}
|
|
25
|
-
//return Reflect.get(target, prop);
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
proxies.set(this, new Proxy(this, handler));
|
|
30
|
-
}
|
|
31
|
-
return proxies.get(this);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
type attr = string;
|
|
36
|
-
|
|
37
|
-
type RefLookup = Map<attr, RefManager>;
|
|
38
|
-
|
|
39
|
-
class RefManager extends EventTarget {
|
|
40
|
-
#el: WeakRef<Element>;
|
|
41
|
-
#children: Map<string, WeakRef<Element>> | undefined;
|
|
42
|
-
#attr: string;
|
|
43
|
-
#lastAttrVal: string = '';
|
|
44
|
-
//#parents: Array<WeakRef<Element>> | undefined;
|
|
45
|
-
constructor(el: Element, prop: string){
|
|
46
|
-
super();
|
|
47
|
-
this.#attr = camelToKebab(prop);
|
|
48
|
-
this.#el = new WeakRef(el);
|
|
49
|
-
}
|
|
50
|
-
get children(){
|
|
51
|
-
const el = this.#el.deref();
|
|
52
|
-
if(el === undefined) return [];
|
|
53
|
-
const attr = el.getAttribute(this.#attr);
|
|
54
|
-
if(this.#children === undefined || attr !== this.#lastAttrVal){
|
|
55
|
-
if(!attr) return [];
|
|
56
|
-
this.#lastAttrVal = attr;
|
|
57
|
-
const refIds = splitRefs(attr);
|
|
58
|
-
const qry = refIds.map(id => `#${id}`).join(',');
|
|
59
|
-
const rn = el.getRootNode() as DocumentFragment;
|
|
60
|
-
const refsArr = Array.from(rn.querySelectorAll(qry));
|
|
61
|
-
const refs = new Map<string, WeakRef<Element>>();
|
|
62
|
-
for(const ref of refsArr){
|
|
63
|
-
refs.set(ref.id, new WeakRef(ref));
|
|
64
|
-
}
|
|
65
|
-
this.#children = refs;
|
|
66
|
-
const mo = new MountObserver({
|
|
67
|
-
on: qry,
|
|
68
|
-
do: {
|
|
69
|
-
mount: (el) => {
|
|
70
|
-
const id = el.id;
|
|
71
|
-
if(id && !this.#children?.has(id)){
|
|
72
|
-
this.#children?.set(id, new WeakRef(el));
|
|
73
|
-
this.dispatchEvent(new ChangeEvent([el], []));
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
dismount: (el) => {
|
|
77
|
-
const id = el.id;
|
|
78
|
-
if(id && this.#children?.has(id)){
|
|
79
|
-
this.#children?.delete(id);
|
|
80
|
-
this.dispatchEvent(new ChangeEvent([], [el]));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
mo.observe(rn);
|
|
86
|
-
this.dispatchEvent(new ChangeEvent((refsArr), []));
|
|
87
|
-
}
|
|
88
|
-
return Array.from(this.#children?.values().map(ref => ref.deref()).filter(el => el !== undefined)) || [];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
get parents(){
|
|
92
|
-
//for now, hold off on caching parents until a use case arises
|
|
93
|
-
//if(this.#parents === undefined){
|
|
94
|
-
const el = this.#el.deref();
|
|
95
|
-
if(el === undefined) return [];
|
|
96
|
-
if(el.id === '') return [];
|
|
97
|
-
const rn = el.getRootNode() as DocumentFragment;
|
|
98
|
-
const qry = `[${this.#attr}~="${el.id}"]`;
|
|
99
|
-
const parents = Array.from(rn.querySelectorAll(qry));
|
|
100
|
-
//this.#parents = parents.map(parent => new WeakRef(parent));
|
|
101
|
-
return parents;
|
|
102
|
-
//}
|
|
103
|
-
//return this.#parents.map(ref => ref.deref()).filter(el => el !== undefined) || [];
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export class ChangeEvent extends Event {
|
|
109
|
-
static eventName = 'change';
|
|
110
|
-
constructor(public addedChildren: Array<Element>, public removedChildren: Array<Element>){
|
|
111
|
-
super(ChangeEvent.eventName);
|
|
112
|
-
}
|
|
113
|
-
}
|
package/slotkin/affine.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { toQuery } from './toQuery.js';
|
|
2
|
-
import { splitRefs } from '../refid/splitRefs.js';
|
|
3
|
-
export function affine(fragment, el) {
|
|
4
|
-
const qry = toQuery(el);
|
|
5
|
-
const { elFragment, map } = prep(el);
|
|
6
|
-
const matches = Array.from(fragment.querySelectorAll(qry));
|
|
7
|
-
for (const match of matches) {
|
|
8
|
-
clone(match, elFragment, map);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
export function prep(el) {
|
|
12
|
-
const elFragment = new DocumentFragment();
|
|
13
|
-
const clone = el.cloneNode(true);
|
|
14
|
-
for (const child of clone.childNodes) {
|
|
15
|
-
elFragment.appendChild(child);
|
|
16
|
-
}
|
|
17
|
-
const insertAttrs = el.getAttribute('-i');
|
|
18
|
-
let map = null;
|
|
19
|
-
if (insertAttrs !== null) {
|
|
20
|
-
const attrs = splitRefs(insertAttrs);
|
|
21
|
-
map = {};
|
|
22
|
-
for (const attr of attrs) {
|
|
23
|
-
map[attr] = el.getAttribute(attr);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
elFragment, map
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
export function clone(matchingElement, elFragment, map) {
|
|
31
|
-
const fragmentClone = elFragment.cloneNode(true);
|
|
32
|
-
matchingElement.replaceChildren(fragmentClone);
|
|
33
|
-
if (map !== null) {
|
|
34
|
-
for (const key in map) {
|
|
35
|
-
const value = map[key];
|
|
36
|
-
matchingElement.setAttribute(key, value);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
package/slotkin/affine.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {toQuery} from './toQuery.js';
|
|
2
|
-
import {splitRefs} from '../refid/splitRefs.js';
|
|
3
|
-
|
|
4
|
-
export function affine(fragment: DocumentFragment | Element,
|
|
5
|
-
el: Element){
|
|
6
|
-
const qry = toQuery(el);
|
|
7
|
-
const {elFragment, map} = prep(el);
|
|
8
|
-
const matches = Array.from(fragment.querySelectorAll(qry));
|
|
9
|
-
for(const match of matches){
|
|
10
|
-
clone(match, elFragment, map);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function prep(el: Element){
|
|
15
|
-
const elFragment = new DocumentFragment();
|
|
16
|
-
const clone = el.cloneNode(true);
|
|
17
|
-
for(const child of clone.childNodes){
|
|
18
|
-
elFragment.appendChild(child);
|
|
19
|
-
}
|
|
20
|
-
const insertAttrs = el.getAttribute('-i');
|
|
21
|
-
let map: {[key: string]: string} | null = null;
|
|
22
|
-
if(insertAttrs !== null){
|
|
23
|
-
const attrs = splitRefs(insertAttrs);
|
|
24
|
-
map = {};
|
|
25
|
-
for(const attr of attrs){
|
|
26
|
-
map[attr] = el.getAttribute(attr)!;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
elFragment, map
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function clone(
|
|
35
|
-
matchingElement: Element,
|
|
36
|
-
elFragment: DocumentFragment,
|
|
37
|
-
map: {[key: string]: string} | null){
|
|
38
|
-
const fragmentClone = elFragment.cloneNode(true) as DocumentFragment;
|
|
39
|
-
matchingElement.replaceChildren(fragmentClone);
|
|
40
|
-
if(map !== null){
|
|
41
|
-
for(const key in map){
|
|
42
|
-
const value = map[key]!;
|
|
43
|
-
matchingElement.setAttribute(key, value);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
package/slotkin/beKindred.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { toQuery } from './toQuery.js';
|
|
2
|
-
import { MountObserver } from '../MountObserver.js';
|
|
3
|
-
import { prep, clone } from './affine.js';
|
|
4
|
-
const previousObservers = new WeakMap();
|
|
5
|
-
export function beKindred(fragment, el) {
|
|
6
|
-
if (!fragment.isConnected)
|
|
7
|
-
throw 'too soon, use affine';
|
|
8
|
-
const qry = toQuery(el);
|
|
9
|
-
const previousObserversOfFragment = previousObservers.get(fragment);
|
|
10
|
-
if (previousObserversOfFragment !== undefined) {
|
|
11
|
-
const staleObservers = previousObserversOfFragment.filter(x => el.matches(x[0]));
|
|
12
|
-
const nonStaleObservers = previousObserversOfFragment.filter(x => !el.matches(x[0]));
|
|
13
|
-
if (staleObservers !== undefined && staleObservers.length > 0) {
|
|
14
|
-
for (const staleObserver of staleObservers) {
|
|
15
|
-
staleObserver[1].disconnect(fragment);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
previousObservers.set(fragment, nonStaleObservers);
|
|
19
|
-
}
|
|
20
|
-
const { elFragment, map } = prep(el);
|
|
21
|
-
const mo = new MountObserver({
|
|
22
|
-
on: qry,
|
|
23
|
-
do: {
|
|
24
|
-
mount: (matchingElement) => {
|
|
25
|
-
clone(matchingElement, elFragment, map);
|
|
26
|
-
// const fragmentClone = elFragment.cloneNode(true) as DocumentFragment;
|
|
27
|
-
// matchingElement.replaceChildren(fragmentClone);
|
|
28
|
-
// if(map !== null){
|
|
29
|
-
// for(const key in map){
|
|
30
|
-
// const value = map[key]!;
|
|
31
|
-
// matchingElement.setAttribute(key, value);
|
|
32
|
-
// }
|
|
33
|
-
// }
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
mo.observe(fragment);
|
|
38
|
-
if (previousObservers.has(fragment)) {
|
|
39
|
-
previousObservers.get(fragment).push([qry, mo]);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
previousObservers.set(fragment, [[qry, mo]]);
|
|
43
|
-
}
|
|
44
|
-
return mo;
|
|
45
|
-
}
|
package/slotkin/beKindred.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import {toQuery} from './toQuery.js';
|
|
2
|
-
import {splitRefs} from '../refid/splitRefs.js';
|
|
3
|
-
import {MountObserver} from '../MountObserver.js';
|
|
4
|
-
import {prep, clone} from './affine.js';
|
|
5
|
-
|
|
6
|
-
type OnMountObserver = [string, MountObserver];
|
|
7
|
-
const previousObservers = new WeakMap<DocumentFragment | Element, Array<OnMountObserver>>();
|
|
8
|
-
|
|
9
|
-
export function beKindred(
|
|
10
|
-
fragment: DocumentFragment | Element,
|
|
11
|
-
el: Element,
|
|
12
|
-
){
|
|
13
|
-
if(!fragment.isConnected) throw 'too soon, use affine';
|
|
14
|
-
const qry = toQuery(el);
|
|
15
|
-
const previousObserversOfFragment = previousObservers.get(fragment);
|
|
16
|
-
if(previousObserversOfFragment !== undefined){
|
|
17
|
-
const staleObservers = previousObserversOfFragment.filter(x => el.matches(x[0]));
|
|
18
|
-
const nonStaleObservers = previousObserversOfFragment.filter(x => !el.matches(x[0]));
|
|
19
|
-
if(staleObservers !== undefined && staleObservers.length > 0){
|
|
20
|
-
for(const staleObserver of staleObservers){
|
|
21
|
-
staleObserver[1].disconnect(fragment);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
previousObservers.set(fragment, nonStaleObservers);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const {elFragment, map} = prep(el);
|
|
30
|
-
|
|
31
|
-
const mo = new MountObserver({
|
|
32
|
-
on: qry,
|
|
33
|
-
do: {
|
|
34
|
-
mount: (matchingElement) => {
|
|
35
|
-
clone(matchingElement, elFragment, map);
|
|
36
|
-
// const fragmentClone = elFragment.cloneNode(true) as DocumentFragment;
|
|
37
|
-
// matchingElement.replaceChildren(fragmentClone);
|
|
38
|
-
// if(map !== null){
|
|
39
|
-
// for(const key in map){
|
|
40
|
-
// const value = map[key]!;
|
|
41
|
-
// matchingElement.setAttribute(key, value);
|
|
42
|
-
// }
|
|
43
|
-
// }
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
mo.observe(fragment);
|
|
48
|
-
if(previousObservers.has(fragment)){
|
|
49
|
-
previousObservers.get(fragment)!.push([qry, mo]);
|
|
50
|
-
}else{
|
|
51
|
-
previousObservers.set(fragment, [[qry, mo]]);
|
|
52
|
-
}
|
|
53
|
-
return mo;
|
|
54
|
-
|
|
55
|
-
}
|
package/slotkin/getBreadth.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export function getBreadth(innerEl, base) {
|
|
2
|
-
const priors = [];
|
|
3
|
-
let ps = innerEl.previousSibling;
|
|
4
|
-
while (ps !== null && !(ps.nodeType === Node.COMMENT_NODE && ps.data.includes(` ${base} `))) {
|
|
5
|
-
priors.push(ps);
|
|
6
|
-
ps = ps.previousSibling;
|
|
7
|
-
}
|
|
8
|
-
if (ps !== null)
|
|
9
|
-
priors.push(ps);
|
|
10
|
-
const nexts = [];
|
|
11
|
-
let ns = innerEl.nextSibling;
|
|
12
|
-
while (ns !== null && !(ns.nodeType === Node.COMMENT_NODE && ns.data.includes(` /${base} `))) {
|
|
13
|
-
nexts.push(ns);
|
|
14
|
-
ns = ns.nextSibling;
|
|
15
|
-
}
|
|
16
|
-
if (ns !== null)
|
|
17
|
-
nexts.push(ns);
|
|
18
|
-
return [...priors.reverse(), ...nexts];
|
|
19
|
-
}
|
package/slotkin/getBreadth.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export function getBreadth(
|
|
2
|
-
innerEl: Element,
|
|
3
|
-
base: string,
|
|
4
|
-
){
|
|
5
|
-
const priors: Array<Node> = [];
|
|
6
|
-
let ps = innerEl.previousSibling as Comment | null;
|
|
7
|
-
while(ps !== null && !(ps.nodeType === Node.COMMENT_NODE && (ps as Comment).data.includes( ` ${base} `))){
|
|
8
|
-
priors.push(ps);
|
|
9
|
-
ps = ps.previousSibling as Comment | null;
|
|
10
|
-
}
|
|
11
|
-
if(ps !== null) priors.push(ps);
|
|
12
|
-
const nexts: Array<Node> = [];
|
|
13
|
-
let ns = innerEl.nextSibling as Comment | null;
|
|
14
|
-
while(ns !== null && !(ns.nodeType === Node.COMMENT_NODE && (ns as Comment).data.includes( ` /${base} `))){
|
|
15
|
-
nexts.push(ns);
|
|
16
|
-
ns = ns.nextSibling as Comment | null;
|
|
17
|
-
}
|
|
18
|
-
if(ns !== null) nexts.push(ns);
|
|
19
|
-
return [...priors.reverse(), ...nexts];
|
|
20
|
-
|
|
21
|
-
}
|
package/slotkin/getFrag.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export function getFrag(templ, base) {
|
|
2
|
-
let openComment = templ.nextSibling;
|
|
3
|
-
if (openComment === null || openComment.nodeType !== Node.COMMENT_NODE)
|
|
4
|
-
return null;
|
|
5
|
-
if (base !== undefined && !openComment.data.includes(` ${base} `))
|
|
6
|
-
return null;
|
|
7
|
-
if (base === undefined) {
|
|
8
|
-
base = openComment.data.trim().split(' ')[1];
|
|
9
|
-
if (base === undefined)
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
const returnArr = [openComment];
|
|
13
|
-
let ns = openComment.nextSibling;
|
|
14
|
-
while (ns !== null && !(ns.nodeType === Node.COMMENT_NODE && ns.data.includes(` /${base} `))) {
|
|
15
|
-
returnArr.push(ns);
|
|
16
|
-
ns = ns.nextSibling;
|
|
17
|
-
}
|
|
18
|
-
if (ns === null)
|
|
19
|
-
return null;
|
|
20
|
-
returnArr.push(ns);
|
|
21
|
-
return returnArr;
|
|
22
|
-
}
|
package/slotkin/getFrag.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export function getFrag(
|
|
2
|
-
templ: HTMLTemplateElement,
|
|
3
|
-
base?: string,
|
|
4
|
-
){
|
|
5
|
-
let openComment = templ.nextSibling as Comment | null;
|
|
6
|
-
if(openComment === null || openComment.nodeType !== Node.COMMENT_NODE) return null;
|
|
7
|
-
if(base !== undefined && !openComment.data.includes(` ${base} `)) return null;
|
|
8
|
-
if(base === undefined){
|
|
9
|
-
base = openComment.data.trim().split(' ')[1];
|
|
10
|
-
if(base === undefined) return null;
|
|
11
|
-
}
|
|
12
|
-
const returnArr: Array<Node> = [openComment];
|
|
13
|
-
let ns = openComment.nextSibling;
|
|
14
|
-
while(ns !== null && !(ns.nodeType === Node.COMMENT_NODE && (ns as Comment).data.includes( ` /${base} `))){
|
|
15
|
-
returnArr.push(ns);
|
|
16
|
-
ns = ns.nextSibling;
|
|
17
|
-
}
|
|
18
|
-
if(ns === null) return null;
|
|
19
|
-
returnArr.push(ns);
|
|
20
|
-
return returnArr;
|
|
21
|
-
}
|
package/slotkin/toQuery.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function toQuery(el) {
|
|
2
|
-
//from the element el, create a selector that matches all the classes and parts of the element el, as
|
|
3
|
-
//well as the values of all the attributes of el.
|
|
4
|
-
const classes = Array.from(el.classList).map(c => `.${c}`).join('');
|
|
5
|
-
const parts = Array.from(el.part).map(p => `[part~="${p}"`).join('');
|
|
6
|
-
const attributes = Array.from(el.attributes)
|
|
7
|
-
.filter(attr => attr.name !== '-i')
|
|
8
|
-
.map(attr => `[${attr.name}="${attr.value}"]`)
|
|
9
|
-
.join('');
|
|
10
|
-
const { localName } = el;
|
|
11
|
-
return `${localName}${classes}${parts}${attributes}`;
|
|
12
|
-
}
|
package/slotkin/toQuery.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export function toQuery(el: Element): string {
|
|
3
|
-
//from the element el, create a selector that matches all the classes and parts of the element el, as
|
|
4
|
-
//well as the values of all the attributes of el.
|
|
5
|
-
const classes = Array.from(el.classList).map(c => `.${c}`).join('');
|
|
6
|
-
const parts = Array.from(el.part).map(p => `[part~="${p}"`).join('');
|
|
7
|
-
const attributes = Array.from(el.attributes)
|
|
8
|
-
.filter(attr => attr.name !== '-i')
|
|
9
|
-
.map(attr => `[${attr.name}="${attr.value}"]`)
|
|
10
|
-
.join('');
|
|
11
|
-
const {localName} = el;
|
|
12
|
-
return `${localName}${classes}${parts}${attributes}`;
|
|
13
|
-
}
|
package/slotkin/wrap.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const wrapped = Symbol.for('50tzQZt95ECXUtHF7a40og');
|
|
2
|
-
export function wrap(templ, base, force = false) {
|
|
3
|
-
const wasWrapped = templ[wrapped];
|
|
4
|
-
if (!wasWrapped) {
|
|
5
|
-
templ[wrapped] = base;
|
|
6
|
-
if (force || templ.content.childElementCount > 1) {
|
|
7
|
-
const start = document.createComment(` ${base} `);
|
|
8
|
-
templ.content.prepend(start);
|
|
9
|
-
const end = document.createComment(` /${base} `);
|
|
10
|
-
templ.content.appendChild(end);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
package/slotkin/wrap.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export const wrapped = Symbol.for('50tzQZt95ECXUtHF7a40og');
|
|
2
|
-
|
|
3
|
-
export function wrap(
|
|
4
|
-
templ: HTMLTemplateElement,
|
|
5
|
-
base: string,
|
|
6
|
-
force: boolean = false,
|
|
7
|
-
){
|
|
8
|
-
const wasWrapped = (<any>templ)[wrapped];
|
|
9
|
-
if (!wasWrapped) {
|
|
10
|
-
(<any>templ)[wrapped] = base;
|
|
11
|
-
if (force || templ.content.childElementCount > 1) {
|
|
12
|
-
const start = document.createComment(` ${base} `);
|
|
13
|
-
templ.content.prepend(start);
|
|
14
|
-
const end = document.createComment(` /${base} `);
|
|
15
|
-
templ.content.appendChild(end);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
package/ts-refs/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Bruce B. Anderson
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/ts-refs/README.md
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# ts-refs
|
|
2
|
-
|
|
3
|
-
The recent typescript [blog post](https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#the-jsdoc-import-tag) found it amusing, it seems, to imply that developers were all quite aware that the buildless typescript Microsoft supports had support for importing modules from type definition files:
|
|
4
|
-
|
|
5
|
-
> To avoid this, developers typically had to use import(...) types in JSDoc comments.
|
|
6
|
-
|
|
7
|
-
Where were developers supposed to learn that such an option even existed?
|
|
8
|
-
|
|
9
|
-
[No](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html) [idea](https://www.google.com/search?q=jsdoc+import+types+from+type+definition+files&sca_esv=f583aec8b3671997&sxsrf=ADLYWILWHAvQOa24i969M3KTSHnvI4CCtQ%3A1722464335667&source=hp&ei=T7iqZu_wJuTzkPIP3NfOsAw&iflsig=AL9hbdgAAAAAZqrGX5766U3yi_U8VDQynbrnqQTG0duO&ved=0ahUKEwiv1PTWp9KHAxXkOUQIHdyrE8YQ4dUDCBg&uact=5&oq=jsdoc+import+types+from+type+definition+files&gs_lp=Egdnd3Mtd2l6Ii1qc2RvYyBpbXBvcnQgdHlwZXMgZnJvbSB0eXBlIGRlZmluaXRpb24gZmlsZXMyBRAhGKABMgUQIRigATIFECEYoAEyBRAhGKABMgUQIRirAjIFECEYqwJIpwpQAFgAcAB4AJABAJgBeqABeqoBAzAuMbgBA8gBAPgBAvgBAZgCAaAChgGYAwCSBwMwLjGgB5wH&sclient=gws-wiz)
|
|
10
|
-
|
|
11
|
-
Anyway, my experiments with it are promising, and I'm excited to use this feature, in order to avoid adding to the global warming that requiring compiling my ts files has to be adding to.
|
|
12
|
-
|
|
13
|
-
But I've found that a sticking point to this solution has to do with [lack of full support for bare import specifiers / import maps](https://github.com/microsoft/TypeScript/issues/43326). This causes problems when importing types from one package, which imports chains of types from another dependent package.
|
|
14
|
-
|
|
15
|
-
Having gone this far, I feel compelled to find workarounds until that critical issue is sorted out.
|
|
16
|
-
|
|
17
|
-
So the solution is this interim library, shared by projects that use this feature, via git's [submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
|
|
18
|
-
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import {IEnhancement, BEAllProps, EMC} from '../trans-render/be/types';
|
|
2
|
-
|
|
3
|
-
export interface EndUserProps extends IEnhancement{
|
|
4
|
-
eventName: string, //TODO
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface AllProps extends EndUserProps{
|
|
8
|
-
emc: EMC<any, AllProps>,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type AP = AllProps;
|
|
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): PAP;
|
|
21
|
-
retire(self: BAP): void;
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//using be-render-neutral for now, but that could change in the future
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {IEnhancement, BEAllProps} from '../trans-render/be/types';
|
|
2
|
-
|
|
3
|
-
export interface EndUserProps extends IEnhancement{
|
|
4
|
-
forAll?: Array<string>,
|
|
5
|
-
base?: string,
|
|
6
|
-
fileName?: string
|
|
7
|
-
puntOn?: Array<string>,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface AllProps extends EndUserProps{
|
|
11
|
-
forAll: Array<string>,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export interface PuntEvent{
|
|
16
|
-
count: number,
|
|
17
|
-
instance: Element,
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type AP = AllProps;
|
|
21
|
-
|
|
22
|
-
export type PAP = Partial<AP>;
|
|
23
|
-
|
|
24
|
-
export type ProPAP = Promise<PAP>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export interface Actions{
|
|
29
|
-
hydrate(self: AP & BEAllProps): PAP;
|
|
30
|
-
//finale(): void;
|
|
31
|
-
}
|
|
32
|
-
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import {IEnhancement, BEAllProps} from '../trans-render/be/types';
|
|
2
|
-
import { Specifier } from "../trans-render/dss/types";
|
|
3
|
-
import {AbsorbingObject, SharingObject} from '../trans-render/asmr/types';
|
|
4
|
-
|
|
5
|
-
export interface EndUserProps extends IEnhancement{
|
|
6
|
-
With?: Array<WithStatement>,
|
|
7
|
-
Between?: Array<BetweenStatement>,
|
|
8
|
-
with?: Array<WithStatement>,
|
|
9
|
-
between?: Array<BetweenStatement>,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface AllProps extends EndUserProps{
|
|
13
|
-
bindingRules: Array<BindingRule>,
|
|
14
|
-
bindings: Array<Binding>,
|
|
15
|
-
isParsed?: boolean,
|
|
16
|
-
rawStatements?: Array<string>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type SignalEnhancement = 'be-value-added' | 'be-propagating' | undefined;
|
|
20
|
-
|
|
21
|
-
export interface BindingRule {
|
|
22
|
-
|
|
23
|
-
localProp?: string,
|
|
24
|
-
localEvent?: string,
|
|
25
|
-
remoteSpecifierString?: string,
|
|
26
|
-
remoteSpecifier?: Specifier,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface Binding {
|
|
32
|
-
//new and improved
|
|
33
|
-
localAbsObj: AbsorbingObject;
|
|
34
|
-
localShareObj: SharingObject;
|
|
35
|
-
remoteAbsObj: AbsorbingObject;
|
|
36
|
-
remoteShareObj: SharingObject;
|
|
37
|
-
//remoteRef: WeakRef<Element>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type AP = AllProps;
|
|
41
|
-
|
|
42
|
-
export type PAP = Partial<AP>;
|
|
43
|
-
|
|
44
|
-
export type ProPAP = Promise<PAP>;
|
|
45
|
-
|
|
46
|
-
export type BAP = AP & BEAllProps;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
export interface Actions{
|
|
50
|
-
noAttrs(self: BAP): ProPAP;
|
|
51
|
-
getBindings(self: BAP): ProPAP;
|
|
52
|
-
hydrate(self: BAP): ProPAP;
|
|
53
|
-
onRawStatements(self: BAP): void;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export type WithStatement = string;
|
|
57
|
-
|
|
58
|
-
export type BetweenStatement = string;
|
|
59
|
-
|
|
60
|
-
export type TriggerSource = 'local' | 'remote' | 'tie';
|
|
61
|
-
|
|
62
|
-
export interface SpecificityResult {
|
|
63
|
-
val?: any,
|
|
64
|
-
winner?: TriggerSource;
|
|
65
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {IEnhancement, BEAllProps} from '../trans-render/be/types';
|
|
2
|
-
|
|
3
|
-
export interface EndUserProps extends IEnhancement<HTMLButtonElement>{
|
|
4
|
-
closeOnSelect: boolean;
|
|
5
|
-
eventName: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface AllProps extends EndUserProps {}
|
|
9
|
-
|
|
10
|
-
export type AP = AllProps;
|
|
11
|
-
|
|
12
|
-
export type PAP = Partial<AP>;
|
|
13
|
-
|
|
14
|
-
export type ProPAP = Promise<PAP>;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export type BAP = AP & BEAllProps;
|
|
18
|
-
|
|
19
|
-
export interface Actions{
|
|
20
|
-
hydrate(self: BAP): PAP
|
|
21
|
-
}
|