@awesomeness-js/server 1.1.11 → 1.1.13
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 +1 -1
- package/src/componentAndPageMemory.js +47 -19
- package/src/componentDependencies.js +2 -4
- package/tests/componentAndPageMemory.test.js +1 -0
- package/tests/fetchPage.test.js +2 -0
- package/tests/fixtures/site-and-components/components/app/cleanMain/index.js +26 -0
- package/tests/fixtures/site-and-components/components/app/cleanMain.js +14 -0
- package/tests/fixtures/site-and-components/components/app/index.css +4 -0
- package/tests/fixtures/site-and-components/components/app/index.js +42 -0
- package/tests/fixtures/site-and-components/components/app/insertIntoList.jquery.js +150 -0
- package/tests/fixtures/site-and-components/components/app/keyUpWithTimeout.jQuery.js +26 -0
- package/tests/fixtures/site-and-components/components/app/onEnter.jQuery.js +39 -0
- package/tests/fixtures/site-and-components/components/app/onResize.jQuery.js +64 -0
- package/tests/fixtures/site-and-components/components/app/pwa/_.css +305 -0
- package/tests/fixtures/site-and-components/components/app/pwa/index.js +235 -0
- package/tests/fixtures/site-and-components/components/app/pwa/updateProfileImage.js +7 -0
- package/tests/fixtures/site-and-components/components/app/shapes.css +3 -0
- package/tests/fixtures/site-and-components/components/app/simple/_.css +151 -0
- package/tests/fixtures/site-and-components/components/app/simple/index.js +170 -0
- package/tests/fixtures/site-and-components/components/app/start.js +165 -0
- package/tests/fixtures/site-and-components/components/app/vanilla/_.css +1 -0
- package/tests/fixtures/site-and-components/components/app/vanilla/index.js +27 -0
- package/tests/fixtures/site-and-components/components/scrollSpy/elm.js +172 -0
- package/tests/fixtures/site-and-components/components/scrollSpy/index.js +63 -0
- package/tests/fixtures/site-and-components/components/scrollSpy/observerPoolGet.js +91 -0
- package/tests/fixtures/site-and-components/components/scrollSpy/observerPoolRegistry.js +18 -0
- package/tests/fixtures/site-and-components/components/scrollSpy/observerPoolSubscribe.js +37 -0
- package/tests/fixtures/site-and-components/components/scrollSpy/observerPoolUnsubscribe.js +44 -0
- package/tests/fixtures/site-and-components/components/scrollSpy/top.js +86 -0
- package/tests/fixtures/site-and-components/sites/site-a/pages/home/js/index.js +41 -8
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export default ({
|
|
2
|
+
poolEntry,
|
|
3
|
+
targetElm,
|
|
4
|
+
subscriber
|
|
5
|
+
} = {}) => {
|
|
6
|
+
|
|
7
|
+
if (!poolEntry) {
|
|
8
|
+
|
|
9
|
+
throw new Error('observerPoolSubscribe: missing poolEntry');
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (!targetElm) {
|
|
14
|
+
|
|
15
|
+
throw new Error('observerPoolSubscribe: missing targetElm');
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!subscriber) {
|
|
20
|
+
|
|
21
|
+
throw new Error('observerPoolSubscribe: missing subscriber');
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let subscribers = poolEntry.targets.get(targetElm);
|
|
26
|
+
|
|
27
|
+
if (!subscribers) {
|
|
28
|
+
|
|
29
|
+
subscribers = new Set();
|
|
30
|
+
poolEntry.targets.set(targetElm, subscribers);
|
|
31
|
+
poolEntry.observer.observe(targetElm);
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
subscribers.add(subscriber);
|
|
36
|
+
|
|
37
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export default ({
|
|
2
|
+
registry,
|
|
3
|
+
poolEntry,
|
|
4
|
+
targetElm,
|
|
5
|
+
subscriber
|
|
6
|
+
} = {}) => {
|
|
7
|
+
|
|
8
|
+
if (!poolEntry || !targetElm || !subscriber) {
|
|
9
|
+
|
|
10
|
+
return;
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const subscribers = poolEntry.targets.get(targetElm);
|
|
15
|
+
|
|
16
|
+
if (!subscribers) {
|
|
17
|
+
|
|
18
|
+
return;
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
subscribers.delete(subscriber);
|
|
23
|
+
|
|
24
|
+
if (subscribers.size === 0) {
|
|
25
|
+
|
|
26
|
+
poolEntry.targets.delete(targetElm);
|
|
27
|
+
poolEntry.observer.unobserve(targetElm);
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (poolEntry.targets.size === 0) {
|
|
32
|
+
|
|
33
|
+
poolEntry.observer.disconnect();
|
|
34
|
+
|
|
35
|
+
if (registry?.pools) {
|
|
36
|
+
|
|
37
|
+
registry.pools.delete(poolEntry.key);
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export default ({
|
|
2
|
+
$spyOn,
|
|
3
|
+
$applyTo,
|
|
4
|
+
threshold = 100, // X px
|
|
5
|
+
deadZone = 0, // optional hysteresis to avoid flicker
|
|
6
|
+
className = 'spy-past-threshold'
|
|
7
|
+
} = {}) => {
|
|
8
|
+
|
|
9
|
+
const $classEl = ($applyTo && $applyTo.length)
|
|
10
|
+
? $applyTo
|
|
11
|
+
: $('body');
|
|
12
|
+
|
|
13
|
+
const spyTarget = ($spyOn && $spyOn.length)
|
|
14
|
+
? $spyOn.get(0)
|
|
15
|
+
: window;
|
|
16
|
+
|
|
17
|
+
const isWindow = (spyTarget === window);
|
|
18
|
+
|
|
19
|
+
let ticking = false;
|
|
20
|
+
let isApplied = null; // unknown at start
|
|
21
|
+
|
|
22
|
+
function readTop() {
|
|
23
|
+
|
|
24
|
+
return isWindow
|
|
25
|
+
? (window.pageYOffset || document.documentElement.scrollTop || 0)
|
|
26
|
+
: (spyTarget.scrollTop || 0);
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function apply(shouldApply) {
|
|
31
|
+
|
|
32
|
+
if (shouldApply) $classEl.addClass(className);
|
|
33
|
+
else $classEl.removeClass(className);
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function onRaf() {
|
|
38
|
+
|
|
39
|
+
ticking = false;
|
|
40
|
+
|
|
41
|
+
const topNow = readTop();
|
|
42
|
+
|
|
43
|
+
// deadZone gives you hysteresis:
|
|
44
|
+
// once applied, it won't unapply until threshold - deadZone
|
|
45
|
+
// once unapplied, it won't apply until threshold + deadZone
|
|
46
|
+
let shouldApply;
|
|
47
|
+
|
|
48
|
+
if (isApplied === true) {
|
|
49
|
+
|
|
50
|
+
shouldApply = topNow >= (threshold - deadZone);
|
|
51
|
+
|
|
52
|
+
} else if (isApplied === false) {
|
|
53
|
+
|
|
54
|
+
shouldApply = topNow >= (threshold + deadZone);
|
|
55
|
+
|
|
56
|
+
} else {
|
|
57
|
+
|
|
58
|
+
// first run
|
|
59
|
+
shouldApply = topNow >= threshold;
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (shouldApply === isApplied) return;
|
|
64
|
+
|
|
65
|
+
isApplied = shouldApply;
|
|
66
|
+
apply(shouldApply);
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function onScroll() {
|
|
71
|
+
|
|
72
|
+
if (ticking) return;
|
|
73
|
+
ticking = true;
|
|
74
|
+
requestAnimationFrame(onRaf);
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
spyTarget.addEventListener('scroll', onScroll, { passive: true });
|
|
79
|
+
|
|
80
|
+
// run once immediately so the class is correct on load
|
|
81
|
+
onRaf();
|
|
82
|
+
|
|
83
|
+
// optional cleanup if you want it
|
|
84
|
+
return () => spyTarget.removeEventListener('scroll', onScroll);
|
|
85
|
+
|
|
86
|
+
};
|
|
@@ -2,13 +2,39 @@ export default function homePage() {
|
|
|
2
2
|
|
|
3
3
|
ui.pageScript();
|
|
4
4
|
|
|
5
|
+
ui.app.start();
|
|
6
|
+
|
|
5
7
|
const cards = [
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{
|
|
8
|
+
{
|
|
9
|
+
id: "a",
|
|
10
|
+
label: "Analytics",
|
|
11
|
+
value: 132
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
id: "b",
|
|
15
|
+
label: "Sales",
|
|
16
|
+
value: 98
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: "c",
|
|
20
|
+
label: "Leads",
|
|
21
|
+
value: 211
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "d",
|
|
25
|
+
label: "Retention",
|
|
26
|
+
value: 87
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "e",
|
|
30
|
+
label: "Support",
|
|
31
|
+
value: 56
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "f",
|
|
35
|
+
label: "Backlog",
|
|
36
|
+
value: 23
|
|
37
|
+
},
|
|
12
38
|
];
|
|
13
39
|
|
|
14
40
|
const rows = [];
|
|
@@ -31,14 +57,21 @@ export default function homePage() {
|
|
|
31
57
|
|
|
32
58
|
const totals = rows.reduce(
|
|
33
59
|
(acc, row) => {
|
|
60
|
+
|
|
34
61
|
acc.total += row.value;
|
|
35
62
|
acc.high += row.status === "high" ? 1 : 0;
|
|
36
63
|
acc.medium += row.status === "medium" ? 1 : 0;
|
|
37
64
|
acc.low += row.status === "low" ? 1 : 0;
|
|
38
65
|
|
|
39
66
|
return acc;
|
|
67
|
+
|
|
40
68
|
},
|
|
41
|
-
{
|
|
69
|
+
{
|
|
70
|
+
total: 0,
|
|
71
|
+
high: 0,
|
|
72
|
+
medium: 0,
|
|
73
|
+
low: 0
|
|
74
|
+
}
|
|
42
75
|
);
|
|
43
76
|
|
|
44
77
|
const report = {
|
|
@@ -50,7 +83,7 @@ export default function homePage() {
|
|
|
50
83
|
version: "1.0.0",
|
|
51
84
|
notes: [
|
|
52
85
|
"This fixture intentionally has larger content for benchmark-style tests.",
|
|
53
|
-
"
|
|
86
|
+
"ui references in this file: ui.pageScript(), ui.app.start().",
|
|
54
87
|
],
|
|
55
88
|
},
|
|
56
89
|
};
|