aberdeen 1.18.1 → 1.19.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/README.md +9 -0
- package/dist/src/aberdeen.d.ts +29 -0
- package/{dist-docs/assets/aberdeen/aberdeen.js → dist/src/aberdeen.dev.js} +796 -21
- package/dist/src/aberdeen.dev.js.map +12 -0
- package/dist/src/aberdeen.js +79 -19
- package/dist/src/aberdeen.js.map +3 -3
- package/dist/src/devtools.d.ts +26 -0
- package/dist/tests/fakedom.js +20 -3
- package/dist/tests/fakedom.js.map +3 -3
- package/dist/tests/helpers.js +20 -3
- package/dist/tests/helpers.js.map +3 -3
- package/html-to-aberdeen +9 -5
- package/package.json +17 -10
- package/skill/A.md +127 -0
- package/skill/Dispatcher.md +51 -0
- package/skill/OPAQUE.md +15 -0
- package/skill/PromiseProxy.md +25 -0
- package/skill/Route.md +50 -0
- package/skill/SKILL.md +272 -156
- package/skill/applyCanon.md +20 -0
- package/skill/applyPrediction.md +15 -0
- package/skill/back.md +11 -0
- package/skill/clean.md +43 -0
- package/skill/clone.md +15 -0
- package/skill/copy.md +40 -0
- package/skill/count.md +32 -0
- package/skill/cssVars.md +15 -0
- package/skill/darkMode.md +26 -0
- package/skill/derive.md +56 -0
- package/skill/developer-tools.md +23 -0
- package/skill/disableCreateDestroy.md +11 -0
- package/skill/dump.md +37 -0
- package/skill/freeze.md +20 -0
- package/skill/full-example-multi-page-app.md +146 -0
- package/skill/go.md +25 -0
- package/skill/grow.md +13 -0
- package/skill/html-to-aberdeen.md +9 -0
- package/skill/insertCss.md +79 -0
- package/skill/insertGlobalCss.md +68 -0
- package/skill/interceptLinks.md +19 -0
- package/skill/invertString.md +32 -0
- package/skill/isEmpty.md +38 -0
- package/skill/map.md +16 -0
- package/skill/matchCurrent.md +27 -0
- package/skill/merge.md +27 -0
- package/skill/mount.md +48 -0
- package/skill/multiMap.md +15 -0
- package/skill/onEach.md +14 -0
- package/skill/partition.md +15 -0
- package/skill/peek.md +36 -0
- package/skill/persistScroll.md +13 -0
- package/skill/proxy.md +11 -0
- package/skill/push.md +13 -0
- package/skill/ref.md +39 -0
- package/skill/runQueue.md +34 -0
- package/skill/setErrorHandler.md +48 -0
- package/skill/setLog.md +9 -0
- package/skill/setSpacingCssVars.md +31 -0
- package/skill/shrink.md +13 -0
- package/skill/unmountAll.md +9 -0
- package/skill/unproxy.md +43 -0
- package/skill/up.md +13 -0
- package/src/aberdeen.ts +220 -82
- package/src/devtools.ts +685 -0
- package/dist-docs/.nojekyll +0 -1
- package/dist-docs/Tutorial/index.html +0 -305
- package/dist-docs/aberdeen/A/index.html +0 -115
- package/dist-docs/aberdeen/CUSTOM_DUMP/index.html +0 -7
- package/dist-docs/aberdeen/NO_COPY/index.html +0 -2
- package/dist-docs/aberdeen/OPAQUE/index.html +0 -12
- package/dist-docs/aberdeen/PromiseProxy/index.html +0 -8
- package/dist-docs/aberdeen/clean/index.html +0 -11
- package/dist-docs/aberdeen/clone/index.html +0 -5
- package/dist-docs/aberdeen/copy/index.html +0 -22
- package/dist-docs/aberdeen/count/index.html +0 -7
- package/dist-docs/aberdeen/cssVars/index.html +0 -11
- package/dist-docs/aberdeen/darkMode/index.html +0 -9
- package/dist-docs/aberdeen/default/index.html +0 -341
- package/dist-docs/aberdeen/derive/index.html +0 -18
- package/dist-docs/aberdeen/disableCreateDestroy/index.html +0 -6
- package/dist-docs/aberdeen/dump/index.html +0 -11
- package/dist-docs/aberdeen/index.html +0 -54
- package/dist-docs/aberdeen/insertCss/index.html +0 -30
- package/dist-docs/aberdeen/insertGlobalCss/index.html +0 -19
- package/dist-docs/aberdeen/invertString/index.html +0 -13
- package/dist-docs/aberdeen/isEmpty/index.html +0 -12
- package/dist-docs/aberdeen/map/index.html +0 -26
- package/dist-docs/aberdeen/merge/index.html +0 -11
- package/dist-docs/aberdeen/mount/index.html +0 -17
- package/dist-docs/aberdeen/multiMap/index.html +0 -28
- package/dist-docs/aberdeen/onEach/index.html +0 -19
- package/dist-docs/aberdeen/partition/index.html +0 -36
- package/dist-docs/aberdeen/peek/index.html +0 -40
- package/dist-docs/aberdeen/proxy/index.html +0 -35
- package/dist-docs/aberdeen/ref/index.html +0 -13
- package/dist-docs/aberdeen/runQueue/index.html +0 -13
- package/dist-docs/aberdeen/setErrorHandler/index.html +0 -16
- package/dist-docs/aberdeen/setSpacingCssVars/index.html +0 -8
- package/dist-docs/aberdeen/unmountAll/index.html +0 -5
- package/dist-docs/aberdeen/unproxy/index.html +0 -11
- package/dist-docs/assets/aberdeen/aberdeen.d.ts +0 -961
- package/dist-docs/assets/aberdeen/aberdeen.js.map +0 -11
- package/dist-docs/assets/aberdeen/dispatcher.d.ts +0 -57
- package/dist-docs/assets/aberdeen/dispatcher.js +0 -66
- package/dist-docs/assets/aberdeen/dispatcher.js.map +0 -10
- package/dist-docs/assets/aberdeen/helpers/reverseSortedSet.d.ts +0 -96
- package/dist-docs/assets/aberdeen/prediction.d.ts +0 -33
- package/dist-docs/assets/aberdeen/prediction.js +0 -112
- package/dist-docs/assets/aberdeen/prediction.js.map +0 -10
- package/dist-docs/assets/aberdeen/route.d.ts +0 -137
- package/dist-docs/assets/aberdeen/route.js +0 -287
- package/dist-docs/assets/aberdeen/route.js.map +0 -10
- package/dist-docs/assets/aberdeen/transitions.d.ts +0 -18
- package/dist-docs/assets/aberdeen/transitions.js +0 -47
- package/dist-docs/assets/aberdeen/transitions.js.map +0 -10
- package/dist-docs/assets/custom.js +0 -573
- package/dist-docs/assets/favicon.png +0 -0
- package/dist-docs/assets/hierarchy.js +0 -1
- package/dist-docs/assets/highlight.css +0 -134
- package/dist-docs/assets/icons.js +0 -18
- package/dist-docs/assets/icons.svg +0 -1
- package/dist-docs/assets/main.js +0 -60
- package/dist-docs/assets/navigation.js +0 -1
- package/dist-docs/assets/search.js +0 -1
- package/dist-docs/assets/style.css +0 -1640
- package/dist-docs/dispatcher/Dispatcher/index.html +0 -21
- package/dist-docs/dispatcher/MATCH_FAILED/index.html +0 -2
- package/dist-docs/dispatcher/MATCH_REST/index.html +0 -2
- package/dist-docs/dispatcher/index.html +0 -4
- package/dist-docs/hierarchy.html +0 -1
- package/dist-docs/index.html +0 -61
- package/dist-docs/media/CHANGELOG.md +0 -260
- package/dist-docs/modules.html +0 -1
- package/dist-docs/prediction/applyCanon/index.html +0 -13
- package/dist-docs/prediction/applyPrediction/index.html +0 -8
- package/dist-docs/prediction/index.html +0 -9
- package/dist-docs/route/Route/index.html +0 -23
- package/dist-docs/route/back/index.html +0 -4
- package/dist-docs/route/current/index.html +0 -2
- package/dist-docs/route/go/index.html +0 -14
- package/dist-docs/route/index.html +0 -15
- package/dist-docs/route/interceptLinks/index.html +0 -8
- package/dist-docs/route/matchCurrent/index.html +0 -10
- package/dist-docs/route/persistScroll/index.html +0 -6
- package/dist-docs/route/push/index.html +0 -6
- package/dist-docs/route/setLog/index.html +0 -3
- package/dist-docs/route/up/index.html +0 -5
- package/dist-docs/sitemap.xml +0 -239
- package/dist-docs/transitions/grow/index.html +0 -6
- package/dist-docs/transitions/index.html +0 -5
- package/dist-docs/transitions/shrink/index.html +0 -6
- package/skill/aberdeen.md +0 -4584
- package/skill/dispatcher.md +0 -129
- package/skill/prediction.md +0 -73
- package/skill/route.md +0 -322
- package/skill/transitions.md +0 -59
package/dist/src/aberdeen.js
CHANGED
|
@@ -101,6 +101,7 @@ class ReverseSortedSet {
|
|
|
101
101
|
// src/aberdeen.ts
|
|
102
102
|
var sortedQueue;
|
|
103
103
|
var runQueueDepth = 0;
|
|
104
|
+
var freezeCount = 0;
|
|
104
105
|
var topRedrawScope;
|
|
105
106
|
var survivingEl;
|
|
106
107
|
function recordSideEffect(scope, type, key, value) {
|
|
@@ -115,7 +116,10 @@ function undoSideEffects(el, se) {
|
|
|
115
116
|
value ? el.classList.add(key) : el.classList.remove(key);
|
|
116
117
|
break;
|
|
117
118
|
case 1 /* Style */:
|
|
118
|
-
|
|
119
|
+
if (key[0] === "-" && key[1] === "-")
|
|
120
|
+
value ? el.style.setProperty(key, value) : el.style.removeProperty(key);
|
|
121
|
+
else
|
|
122
|
+
el.style[key] = value == null ? "" : value;
|
|
119
123
|
break;
|
|
120
124
|
case 2 /* Prop */:
|
|
121
125
|
el[key] = value;
|
|
@@ -142,6 +146,8 @@ function queue(runner) {
|
|
|
142
146
|
sortedQueue.add(runner);
|
|
143
147
|
}
|
|
144
148
|
function runQueue() {
|
|
149
|
+
if (freezeCount)
|
|
150
|
+
return;
|
|
145
151
|
let time = Date.now();
|
|
146
152
|
while (sortedQueue) {
|
|
147
153
|
const runner = sortedQueue.fetchLast();
|
|
@@ -157,6 +163,17 @@ function runQueue() {
|
|
|
157
163
|
if (time > 9)
|
|
158
164
|
console.debug(`Aberdeen queue took ${time}ms`);
|
|
159
165
|
}
|
|
166
|
+
function freeze() {
|
|
167
|
+
freezeCount++;
|
|
168
|
+
let released = false;
|
|
169
|
+
return () => {
|
|
170
|
+
if (released)
|
|
171
|
+
return;
|
|
172
|
+
released = true;
|
|
173
|
+
if (!--freezeCount)
|
|
174
|
+
runQueue();
|
|
175
|
+
};
|
|
176
|
+
}
|
|
160
177
|
function arrayToStr(parts) {
|
|
161
178
|
let result = "";
|
|
162
179
|
for (const part of parts) {
|
|
@@ -245,6 +262,7 @@ class ContentScope extends Scope {
|
|
|
245
262
|
if (!this.changes) {
|
|
246
263
|
this.changes = new Map;
|
|
247
264
|
queue(this);
|
|
265
|
+
dev?.schedule(this, index, oldData, newData, new Error);
|
|
248
266
|
}
|
|
249
267
|
let targetDelta = this.changes.get(target);
|
|
250
268
|
if (!targetDelta) {
|
|
@@ -302,6 +320,7 @@ class ChainedScope extends ContentScope {
|
|
|
302
320
|
}
|
|
303
321
|
if (!useParentCleaners)
|
|
304
322
|
currentScope.cleaners.push(this);
|
|
323
|
+
dev?.create(this, currentScope, new Error);
|
|
305
324
|
}
|
|
306
325
|
getPrecedingNode() {
|
|
307
326
|
return findLastNodeInPrevSiblings(this.prevSibling);
|
|
@@ -321,6 +340,7 @@ class RegularScope extends ChainedScope {
|
|
|
321
340
|
redraw() {
|
|
322
341
|
const savedScope = currentScope;
|
|
323
342
|
currentScope = this;
|
|
343
|
+
dev?.render(this);
|
|
324
344
|
try {
|
|
325
345
|
this.renderer();
|
|
326
346
|
} catch (e) {
|
|
@@ -347,6 +367,7 @@ class MountScope extends ContentScope {
|
|
|
347
367
|
this.el = el;
|
|
348
368
|
this.renderer = renderer;
|
|
349
369
|
this.svg = el.namespaceURI === "http://www.w3.org/2000/svg";
|
|
370
|
+
dev?.create(this, currentScope, new Error);
|
|
350
371
|
const oldTopRedrawScope = topRedrawScope;
|
|
351
372
|
topRedrawScope = this;
|
|
352
373
|
this.redraw();
|
|
@@ -451,6 +472,7 @@ class OnEachScope extends Scope {
|
|
|
451
472
|
this.prevSibling = currentScope.getChildPrevSibling();
|
|
452
473
|
currentScope.lastChild = this;
|
|
453
474
|
currentScope.cleaners.push(this);
|
|
475
|
+
dev?.create(this, currentScope, new Error);
|
|
454
476
|
if (target instanceof Array) {
|
|
455
477
|
for (let i = 0;i < target.length; i++) {
|
|
456
478
|
new OnEachItemScope(this, i, false);
|
|
@@ -481,8 +503,10 @@ class OnEachScope extends Scope {
|
|
|
481
503
|
this.changedIndexes = new Map;
|
|
482
504
|
for (const index of indexes.keys()) {
|
|
483
505
|
const oldScope = this.byIndex.get(index);
|
|
484
|
-
if (oldScope)
|
|
506
|
+
if (oldScope) {
|
|
485
507
|
oldScope.remove();
|
|
508
|
+
dev?.delete(oldScope);
|
|
509
|
+
}
|
|
486
510
|
if (this.target instanceof Set || this.target instanceof Map ? this.target.has(index) : (index in this.target)) {
|
|
487
511
|
new OnEachItemScope(this, index, true);
|
|
488
512
|
} else {
|
|
@@ -524,6 +548,7 @@ class OnEachItemScope extends ContentScope {
|
|
|
524
548
|
this.svg = currentScope.svg;
|
|
525
549
|
this.parent.byIndex.set(this.itemIndex, this);
|
|
526
550
|
this.lastChild = this;
|
|
551
|
+
dev?.create(this, this.parent, new Error);
|
|
527
552
|
if (topRedraw)
|
|
528
553
|
topRedrawScope = this;
|
|
529
554
|
this.redraw();
|
|
@@ -582,6 +607,7 @@ class OnEachItemScope extends ContentScope {
|
|
|
582
607
|
}
|
|
583
608
|
const savedScope = currentScope;
|
|
584
609
|
currentScope = this;
|
|
610
|
+
dev?.render(this);
|
|
585
611
|
let sortKey;
|
|
586
612
|
try {
|
|
587
613
|
if (this.parent.makeSortKey) {
|
|
@@ -626,15 +652,31 @@ class OnEachItemScope extends ContentScope {
|
|
|
626
652
|
function addNode(el, node) {
|
|
627
653
|
if (el !== currentScope.el) {
|
|
628
654
|
el.appendChild(node);
|
|
655
|
+
dev?.node(currentScope, node, false);
|
|
629
656
|
return;
|
|
630
657
|
}
|
|
631
658
|
const parentEl = currentScope.el;
|
|
632
659
|
const prevNode = currentScope.getInsertAfterNode();
|
|
633
660
|
parentEl.insertBefore(node, prevNode ? prevNode.nextSibling : parentEl.firstChild);
|
|
634
661
|
currentScope.lastChild = node;
|
|
662
|
+
dev?.node(currentScope, node, true);
|
|
635
663
|
}
|
|
636
664
|
var ROOT_SCOPE = new RootScope;
|
|
637
665
|
var currentScope = ROOT_SCOPE;
|
|
666
|
+
var dev;
|
|
667
|
+
function _setDev(hooks) {
|
|
668
|
+
dev = hooks;
|
|
669
|
+
if (!hooks)
|
|
670
|
+
return;
|
|
671
|
+
const childScopes = (scope) => scope instanceof OnEachScope ? [...scope.byIndex.values()] : scope.cleaners.filter((c) => c instanceof Scope);
|
|
672
|
+
const replay = (scope, parent) => {
|
|
673
|
+
hooks.create(scope, parent, undefined);
|
|
674
|
+
for (const child of childScopes(scope))
|
|
675
|
+
replay(child, scope);
|
|
676
|
+
};
|
|
677
|
+
for (const child of childScopes(ROOT_SCOPE))
|
|
678
|
+
replay(child, ROOT_SCOPE);
|
|
679
|
+
}
|
|
638
680
|
function leakScope(func) {
|
|
639
681
|
const savedScope = currentScope;
|
|
640
682
|
currentScope = new RootScope;
|
|
@@ -652,6 +694,8 @@ var peeking = 0;
|
|
|
652
694
|
function subscribe(target, index, observer = currentScope) {
|
|
653
695
|
if (observer === ROOT_SCOPE || peeking)
|
|
654
696
|
return;
|
|
697
|
+
if (observer === currentScope)
|
|
698
|
+
dev?.read(currentScope, target, index);
|
|
655
699
|
let byTarget = subscribers.get(target);
|
|
656
700
|
if (!byTarget)
|
|
657
701
|
subscribers.set(target, byTarget = new Map);
|
|
@@ -1250,7 +1294,7 @@ function setSpacingCssVars(base = 1, unit = "rem") {
|
|
|
1250
1294
|
cssVars[i] = 2 ** (i - 3) * base + unit;
|
|
1251
1295
|
}
|
|
1252
1296
|
}
|
|
1253
|
-
var CSS_VAR_PATTERN = /(\burl\([^)]*\))|("[^"]*")|(^|
|
|
1297
|
+
var CSS_VAR_PATTERN = /(\burl\([^)]*\))|("[^"]*")|(^|[\s(,])\$([\w-]+)/g;
|
|
1254
1298
|
var DIGIT_FIRST = /^\d/;
|
|
1255
1299
|
function cssVarRef(value) {
|
|
1256
1300
|
if (value.indexOf("$") < 0)
|
|
@@ -1557,12 +1601,22 @@ function insertCss(style) {
|
|
|
1557
1601
|
const prefix = `.AbdStl${++cssCount}`;
|
|
1558
1602
|
const css = typeof style === "string" ? styleStringToCss(style, prefix) : objectToCss(style, prefix);
|
|
1559
1603
|
if (css) {
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1604
|
+
const cnt = cssSnippetCount++;
|
|
1605
|
+
const key = arrayToStr([currentScope.prio, cnt]);
|
|
1606
|
+
cssSnippets[key] = css;
|
|
1607
|
+
clean(() => delete cssSnippets[key]);
|
|
1563
1608
|
}
|
|
1564
1609
|
return prefix;
|
|
1565
1610
|
}
|
|
1611
|
+
function insertGlobalCss(style) {
|
|
1612
|
+
const css = objectToCss(style, "");
|
|
1613
|
+
if (css) {
|
|
1614
|
+
const cnt = cssSnippetCount++;
|
|
1615
|
+
const key = arrayToStr([currentScope.prio, cnt]);
|
|
1616
|
+
cssSnippets[key] = css;
|
|
1617
|
+
clean(() => delete cssSnippets[key]);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1566
1620
|
var cssSnippets = proxy({});
|
|
1567
1621
|
var cssSnippetCount = 0;
|
|
1568
1622
|
function combinePrefixSelector(prefix, key) {
|
|
@@ -1634,14 +1688,6 @@ function styleStringToCss(styleStr, selector) {
|
|
|
1634
1688
|
return props ? `${selector}{${props}}
|
|
1635
1689
|
` : "";
|
|
1636
1690
|
}
|
|
1637
|
-
function insertGlobalCss(style) {
|
|
1638
|
-
const css = objectToCss(style, "");
|
|
1639
|
-
if (css) {
|
|
1640
|
-
let cnt = cssSnippetCount++;
|
|
1641
|
-
cssSnippets[cnt] = css;
|
|
1642
|
-
clean(() => delete cssSnippets[cnt]);
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
1691
|
var CSS_SHORT = {
|
|
1646
1692
|
m: "margin",
|
|
1647
1693
|
mt: "margin-top",
|
|
@@ -1687,16 +1733,27 @@ function applyArg(el, key, value) {
|
|
|
1687
1733
|
list.remove(...classes);
|
|
1688
1734
|
} else if (key[0] === "$") {
|
|
1689
1735
|
key = key.substring(1);
|
|
1736
|
+
if (key[0] === "$")
|
|
1737
|
+
key = "--" + key.substring(1);
|
|
1690
1738
|
const val = value == null || value === false ? "" : typeof value === "string" ? cssVarRef(value) : String(value);
|
|
1691
1739
|
const expanded = CSS_SHORT[key] || key;
|
|
1692
1740
|
const style = el.style;
|
|
1693
1741
|
const setOwn = el === currentScope.el;
|
|
1694
1742
|
const props = typeof expanded === "string" ? [expanded] : expanded;
|
|
1695
1743
|
for (const prop of props) {
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1744
|
+
if (prop[0] === "-" && prop[1] === "-") {
|
|
1745
|
+
if (setOwn)
|
|
1746
|
+
recordSideEffect(currentScope, 1 /* Style */, prop, style.getPropertyValue(prop));
|
|
1747
|
+
if (val === "")
|
|
1748
|
+
style.removeProperty(prop);
|
|
1749
|
+
else
|
|
1750
|
+
style.setProperty(prop, val);
|
|
1751
|
+
} else {
|
|
1752
|
+
const cm = toCamel(prop);
|
|
1753
|
+
if (setOwn)
|
|
1754
|
+
recordSideEffect(currentScope, 1 /* Style */, cm, style[cm]);
|
|
1755
|
+
style[cm] = val;
|
|
1756
|
+
}
|
|
1700
1757
|
}
|
|
1701
1758
|
} else if (value == null) {} else if (key in SPECIAL_PROPS) {
|
|
1702
1759
|
SPECIAL_PROPS[key](el, value);
|
|
@@ -1924,6 +1981,7 @@ var aberdeen_default = Object.assign(A, {
|
|
|
1924
1981
|
derive,
|
|
1925
1982
|
disableCreateDestroy,
|
|
1926
1983
|
dump,
|
|
1984
|
+
freeze,
|
|
1927
1985
|
insertCss,
|
|
1928
1986
|
insertGlobalCss,
|
|
1929
1987
|
invertString,
|
|
@@ -1966,6 +2024,7 @@ export {
|
|
|
1966
2024
|
invertString,
|
|
1967
2025
|
insertGlobalCss,
|
|
1968
2026
|
insertCss,
|
|
2027
|
+
freeze,
|
|
1969
2028
|
dump,
|
|
1970
2029
|
disableCreateDestroy,
|
|
1971
2030
|
derive,
|
|
@@ -1977,6 +2036,7 @@ export {
|
|
|
1977
2036
|
copy,
|
|
1978
2037
|
clone,
|
|
1979
2038
|
clean,
|
|
2039
|
+
_setDev,
|
|
1980
2040
|
OPAQUE,
|
|
1981
2041
|
NO_COPY,
|
|
1982
2042
|
MAP_SIZE_SYMBOL,
|
|
@@ -1985,5 +2045,5 @@ export {
|
|
|
1985
2045
|
A
|
|
1986
2046
|
};
|
|
1987
2047
|
|
|
1988
|
-
//# debugId=
|
|
2048
|
+
//# debugId=BFB325AE18E8016D64756E2164756E21
|
|
1989
2049
|
//# sourceMappingURL=aberdeen.js.map
|