aberdeen 1.0.4 → 1.0.6
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 +4 -6
- package/dist/aberdeen.d.ts +3 -8
- package/dist/aberdeen.js +87 -80
- package/dist/aberdeen.js.map +4 -4
- package/dist/prediction.d.ts +2 -2
- package/dist/prediction.js +21 -22
- package/dist/prediction.js.map +3 -3
- package/dist/route.d.ts +2 -2
- package/dist/route.js +29 -15
- package/dist/route.js.map +3 -3
- package/dist/transitions.d.ts +14 -14
- package/dist/transitions.js +19 -6
- package/dist/transitions.js.map +3 -3
- package/dist-min/aberdeen.js +5 -5
- package/dist-min/aberdeen.js.map +4 -4
- package/dist-min/prediction.js +2 -2
- package/dist-min/prediction.js.map +3 -3
- package/dist-min/route.js +2 -2
- package/dist-min/route.js.map +3 -3
- package/dist-min/transitions.js +2 -2
- package/dist-min/transitions.js.map +3 -3
- package/html-to-aberdeen +354 -0
- package/package.json +3 -2
- package/src/aberdeen.ts +591 -401
- package/src/helpers/reverseSortedSet.ts +187 -178
- package/src/prediction.ts +73 -55
- package/src/route.ts +115 -97
- package/src/transitions.ts +49 -37
package/README.md
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
# [Aberdeen](https://aberdeenjs.org/) [](https://github.com/vanviegen/aberdeen/blob/master/LICENSE.txt) [](https://badge.fury.io/js/aberdeen)  [](https://github.com/vanviegen/aberdeen)
|
|
2
2
|
|
|
3
|
-
Build
|
|
3
|
+
Build fast reactive UIs in pure TypeScript/JavaScript without a virtual DOM.
|
|
4
4
|
|
|
5
|
-
Aberdeen
|
|
5
|
+
Aberdeen's approach is refreshingly simple:
|
|
6
6
|
|
|
7
|
-
> Use many small
|
|
8
|
-
|
|
9
|
-
Now, let's dive into why this matters...
|
|
7
|
+
> Use many small anonymous functions for emitting DOM elements, and automatically rerun them when their underlying data changes. JavaScript `Proxy` is used to track reads and updates to this data, which can consist of anything, from simple values to complex, typed, and deeply nested data structures.
|
|
10
8
|
|
|
11
9
|
## Why use Aberdeen?
|
|
12
10
|
|
|
@@ -54,7 +52,7 @@ Okay, next up is a somewhat more complex app - a todo-list with the following be
|
|
|
54
52
|
- Pressing one of the buttons, or pressing enter will transition from 'editing state' to 'viewing state', saving the new label text unless cancel was pressed.
|
|
55
53
|
- In 'viewing state', the label is shown as non-editable. There's an 'Edit' link, that will transition the item to 'editing state'. Clicking anywhere else will toggle the done status.
|
|
56
54
|
- The list of items is sorted alphabetically by label. Items move when 'save' changes their label.
|
|
57
|
-
- Items that are created, moved or deleted
|
|
55
|
+
- Items that are created, moved or deleted grow and shrink as appropriate.
|
|
58
56
|
|
|
59
57
|
Pfew.. now let's look at the code:
|
|
60
58
|
|
package/dist/aberdeen.d.ts
CHANGED
|
@@ -222,7 +222,7 @@ export declare function unproxy<T>(target: T): T;
|
|
|
222
222
|
* console.log(source.nested); // [1, 2, 3] (source was modified)
|
|
223
223
|
* ```
|
|
224
224
|
*/
|
|
225
|
-
export declare function copy<T extends object>(dst: T, src: T
|
|
225
|
+
export declare function copy<T extends object>(dst: T, src: Partial<T>, flags?: number): void;
|
|
226
226
|
/** Flag to {@link copy} causing it to use merge semantics. See {@link copy} for details. */
|
|
227
227
|
export declare const MERGE = 1;
|
|
228
228
|
/** Flag to {@link copy} and {@link clone} causing them to create a shallow copy (instead of the deep copy done by default).*/
|
|
@@ -358,7 +358,7 @@ export declare function ref<T extends TargetType, K extends keyof T>(target: T,
|
|
|
358
358
|
* });
|
|
359
359
|
* ```
|
|
360
360
|
*/
|
|
361
|
-
export declare function $(...args: (string | null | undefined | false | (() => void) | Record<string, any>)[]):
|
|
361
|
+
export declare function $(...args: (string | null | undefined | false | (() => void) | Record<string, any>)[]): undefined | Element;
|
|
362
362
|
/**
|
|
363
363
|
* Inserts CSS rules into the document, optionally scoping them with a unique class name.
|
|
364
364
|
*
|
|
@@ -579,7 +579,7 @@ export declare function clean(cleaner: () => void): void;
|
|
|
579
579
|
* @overload
|
|
580
580
|
* @param func Func without a return value.
|
|
581
581
|
*/
|
|
582
|
-
export declare function observe<T
|
|
582
|
+
export declare function observe<T>(func: () => T): ValueRef<T>;
|
|
583
583
|
/**
|
|
584
584
|
* Similar to {@link observe}, creates a reactive scope that re-executes the function
|
|
585
585
|
* when its proxied dependencies change.
|
|
@@ -728,8 +728,3 @@ export declare function partition<IN_K extends string | number | symbol, OUT_K e
|
|
|
728
728
|
* ```
|
|
729
729
|
*/
|
|
730
730
|
export declare function dump<T>(data: T): T;
|
|
731
|
-
declare global {
|
|
732
|
-
interface String {
|
|
733
|
-
replaceAll(from: string, to: string): string;
|
|
734
|
-
}
|
|
735
|
-
}
|
package/dist/aberdeen.js
CHANGED
|
@@ -33,7 +33,7 @@ class ReverseSortedSet {
|
|
|
33
33
|
return this.symbols[0] in item;
|
|
34
34
|
}
|
|
35
35
|
fetchLast() {
|
|
36
|
-
|
|
36
|
+
const item = this.tail[this.symbols[0]];
|
|
37
37
|
if (item) {
|
|
38
38
|
this.remove(item);
|
|
39
39
|
return item;
|
|
@@ -54,7 +54,7 @@ class ReverseSortedSet {
|
|
|
54
54
|
return current[this.symbols[0]]?.[keyProp] === indexValue ? current[this.symbols[0]] : undefined;
|
|
55
55
|
}
|
|
56
56
|
*[Symbol.iterator]() {
|
|
57
|
-
|
|
57
|
+
const symbol = this.symbols[0];
|
|
58
58
|
let node = this.tail[symbol];
|
|
59
59
|
while (node) {
|
|
60
60
|
yield node;
|
|
@@ -132,7 +132,7 @@ function runQueue() {
|
|
|
132
132
|
}
|
|
133
133
|
function partToStr(part) {
|
|
134
134
|
if (typeof part === "string") {
|
|
135
|
-
return part
|
|
135
|
+
return `${part}\x01`;
|
|
136
136
|
}
|
|
137
137
|
let result = "";
|
|
138
138
|
let num = Math.abs(Math.round(part));
|
|
@@ -174,7 +174,7 @@ class ContentScope extends Scope {
|
|
|
174
174
|
return findLastNodeInPrevSiblings(this.lastChild);
|
|
175
175
|
}
|
|
176
176
|
delete() {
|
|
177
|
-
for (
|
|
177
|
+
for (const cleaner of this.cleaners) {
|
|
178
178
|
if (typeof cleaner === "function")
|
|
179
179
|
cleaner();
|
|
180
180
|
else
|
|
@@ -230,7 +230,7 @@ class RegularScope extends ChainedScope {
|
|
|
230
230
|
this.redraw();
|
|
231
231
|
}
|
|
232
232
|
redraw() {
|
|
233
|
-
|
|
233
|
+
const savedScope = currentScope;
|
|
234
234
|
currentScope = this;
|
|
235
235
|
try {
|
|
236
236
|
this.renderer();
|
|
@@ -275,7 +275,7 @@ class MountScope extends ContentScope {
|
|
|
275
275
|
function removeNodes(node, preNode) {
|
|
276
276
|
while (node && node !== preNode) {
|
|
277
277
|
const prevNode = node.previousSibling;
|
|
278
|
-
|
|
278
|
+
const onDestroy = onDestroyMap.get(node);
|
|
279
279
|
if (onDestroy && node instanceof Element) {
|
|
280
280
|
if (onDestroy !== true) {
|
|
281
281
|
if (typeof onDestroy === "function") {
|
|
@@ -306,7 +306,7 @@ class ResultScope extends ChainedScope {
|
|
|
306
306
|
this.redraw();
|
|
307
307
|
}
|
|
308
308
|
redraw() {
|
|
309
|
-
|
|
309
|
+
const savedScope = currentScope;
|
|
310
310
|
currentScope = this;
|
|
311
311
|
try {
|
|
312
312
|
this.result.value = this.renderer();
|
|
@@ -327,7 +327,7 @@ class SetArgScope extends ChainedScope {
|
|
|
327
327
|
this.redraw();
|
|
328
328
|
}
|
|
329
329
|
redraw() {
|
|
330
|
-
|
|
330
|
+
const savedScope = currentScope;
|
|
331
331
|
currentScope = this;
|
|
332
332
|
applyArg(this.key, this.target.value);
|
|
333
333
|
currentScope = savedScope;
|
|
@@ -348,7 +348,7 @@ function runImmediateQueue() {
|
|
|
348
348
|
throw new Error("Too many immediate-mode recursive updates");
|
|
349
349
|
}
|
|
350
350
|
immediateQueueRunning = true;
|
|
351
|
-
|
|
351
|
+
const copy = immediateQueue;
|
|
352
352
|
immediateQueue = new ReverseSortedSet("prio");
|
|
353
353
|
try {
|
|
354
354
|
for (const scope of copy) {
|
|
@@ -401,9 +401,9 @@ class OnEachScope extends Scope {
|
|
|
401
401
|
queue(this);
|
|
402
402
|
}
|
|
403
403
|
queueRun() {
|
|
404
|
-
|
|
404
|
+
const indexes = this.changedIndexes;
|
|
405
405
|
this.changedIndexes = new Set;
|
|
406
|
-
for (
|
|
406
|
+
for (const index of indexes) {
|
|
407
407
|
const oldScope = this.byIndex.get(index);
|
|
408
408
|
if (oldScope)
|
|
409
409
|
oldScope.remove();
|
|
@@ -425,7 +425,7 @@ class OnEachScope extends Scope {
|
|
|
425
425
|
}, 1);
|
|
426
426
|
}
|
|
427
427
|
getLastNode() {
|
|
428
|
-
for (
|
|
428
|
+
for (const scope of this.sortedSet) {
|
|
429
429
|
const node = scope.getActualLastNode();
|
|
430
430
|
if (node)
|
|
431
431
|
return node;
|
|
@@ -486,12 +486,12 @@ class OnEachItemScope extends ContentScope {
|
|
|
486
486
|
}
|
|
487
487
|
redraw() {
|
|
488
488
|
const value = optProxy(this.parent.target[this.itemIndex]);
|
|
489
|
-
|
|
489
|
+
const savedScope = currentScope;
|
|
490
490
|
currentScope = this;
|
|
491
491
|
let sortKey;
|
|
492
492
|
try {
|
|
493
493
|
if (this.parent.makeSortKey) {
|
|
494
|
-
|
|
494
|
+
const rawSortKey = this.parent.makeSortKey(value, this.itemIndex);
|
|
495
495
|
if (rawSortKey != null)
|
|
496
496
|
sortKey = rawSortKey instanceof Array ? rawSortKey.map(partToStr).join("") : rawSortKey;
|
|
497
497
|
} else {
|
|
@@ -555,7 +555,7 @@ function subscribe(target, index, observer = currentScope) {
|
|
|
555
555
|
if (observer === currentScope) {
|
|
556
556
|
currentScope.cleaners.push(byIndex);
|
|
557
557
|
} else {
|
|
558
|
-
currentScope.cleaners.push(
|
|
558
|
+
currentScope.cleaners.push(() => {
|
|
559
559
|
byIndex.delete(observer);
|
|
560
560
|
});
|
|
561
561
|
}
|
|
@@ -567,7 +567,7 @@ function onEach(target, render, makeKey) {
|
|
|
567
567
|
new OnEachScope(target, render, makeKey);
|
|
568
568
|
}
|
|
569
569
|
function isObjEmpty(obj) {
|
|
570
|
-
for (
|
|
570
|
+
for (const k in obj)
|
|
571
571
|
return false;
|
|
572
572
|
return true;
|
|
573
573
|
}
|
|
@@ -575,30 +575,29 @@ function isEmpty(proxied) {
|
|
|
575
575
|
const target = proxied[TARGET_SYMBOL] || proxied;
|
|
576
576
|
const scope = currentScope;
|
|
577
577
|
if (target instanceof Array) {
|
|
578
|
-
subscribe(target, "length",
|
|
578
|
+
subscribe(target, "length", (index, newData, oldData) => {
|
|
579
579
|
if (!newData !== !oldData)
|
|
580
580
|
queue(scope);
|
|
581
581
|
});
|
|
582
582
|
return !target.length;
|
|
583
|
-
} else {
|
|
584
|
-
const result = isObjEmpty(target);
|
|
585
|
-
subscribe(target, ANY_SYMBOL, function(index, newData, oldData) {
|
|
586
|
-
if (result ? oldData === undefined : newData === undefined)
|
|
587
|
-
queue(scope);
|
|
588
|
-
});
|
|
589
|
-
return result;
|
|
590
583
|
}
|
|
584
|
+
const result = isObjEmpty(target);
|
|
585
|
+
subscribe(target, ANY_SYMBOL, (index, newData, oldData) => {
|
|
586
|
+
if (result ? oldData === undefined : newData === undefined)
|
|
587
|
+
queue(scope);
|
|
588
|
+
});
|
|
589
|
+
return result;
|
|
591
590
|
}
|
|
592
591
|
function count(proxied) {
|
|
593
592
|
if (proxied instanceof Array)
|
|
594
593
|
return ref(proxied, "length");
|
|
595
594
|
const target = proxied[TARGET_SYMBOL] || proxied;
|
|
596
595
|
let cnt = 0;
|
|
597
|
-
for (
|
|
596
|
+
for (const k in target)
|
|
598
597
|
if (target[k] !== undefined)
|
|
599
598
|
cnt++;
|
|
600
599
|
const result = proxy(cnt);
|
|
601
|
-
subscribe(target, ANY_SYMBOL,
|
|
600
|
+
subscribe(target, ANY_SYMBOL, (index, newData, oldData) => {
|
|
602
601
|
if (oldData === newData) {} else if (oldData === undefined)
|
|
603
602
|
result.value = ++cnt;
|
|
604
603
|
else if (newData === undefined)
|
|
@@ -613,9 +612,9 @@ function defaultEmitHandler(target, index, newData, oldData) {
|
|
|
613
612
|
if (byTarget === undefined)
|
|
614
613
|
return;
|
|
615
614
|
for (const what of [index, ANY_SYMBOL]) {
|
|
616
|
-
|
|
615
|
+
const byIndex = byTarget.get(what);
|
|
617
616
|
if (byIndex) {
|
|
618
|
-
for (
|
|
617
|
+
for (const observer of byIndex) {
|
|
619
618
|
if (typeof observer === "function")
|
|
620
619
|
observer(index, newData, oldData);
|
|
621
620
|
else
|
|
@@ -665,14 +664,14 @@ function arraySet(target, prop, newData) {
|
|
|
665
664
|
newData = newData[TARGET_SYMBOL] || newData;
|
|
666
665
|
const oldData = target[prop];
|
|
667
666
|
if (newData !== oldData) {
|
|
668
|
-
|
|
667
|
+
const oldLength = target.length;
|
|
669
668
|
if (prop === "length") {
|
|
670
669
|
target.length = newData;
|
|
671
670
|
for (let i = newData;i < oldLength; i++) {
|
|
672
671
|
emit(target, i, undefined, target[i]);
|
|
673
672
|
}
|
|
674
673
|
} else {
|
|
675
|
-
const intProp = parseInt(prop);
|
|
674
|
+
const intProp = Number.parseInt(prop);
|
|
676
675
|
if (intProp.toString() === prop)
|
|
677
676
|
prop = intProp;
|
|
678
677
|
target[prop] = newData;
|
|
@@ -691,7 +690,7 @@ var arrayHandler = {
|
|
|
691
690
|
return target;
|
|
692
691
|
let subProp = prop;
|
|
693
692
|
if (typeof prop !== "symbol") {
|
|
694
|
-
const intProp = parseInt(prop);
|
|
693
|
+
const intProp = Number.parseInt(prop);
|
|
695
694
|
if (intProp.toString() === prop)
|
|
696
695
|
subProp = intProp;
|
|
697
696
|
}
|
|
@@ -776,11 +775,11 @@ function copyRecurse(dst, src, flags) {
|
|
|
776
775
|
}
|
|
777
776
|
}
|
|
778
777
|
} else {
|
|
779
|
-
for (
|
|
778
|
+
for (const k in src) {
|
|
780
779
|
copyValue(dst, src, k, flags);
|
|
781
780
|
}
|
|
782
781
|
if (!(flags & MERGE)) {
|
|
783
|
-
for (
|
|
782
|
+
for (const k in dst) {
|
|
784
783
|
if (!(k in src)) {
|
|
785
784
|
const old = dst[k];
|
|
786
785
|
delete dst[k];
|
|
@@ -793,7 +792,7 @@ function copyRecurse(dst, src, flags) {
|
|
|
793
792
|
}
|
|
794
793
|
}
|
|
795
794
|
function copyValue(dst, src, index, flags) {
|
|
796
|
-
|
|
795
|
+
const dstValue = dst[index];
|
|
797
796
|
let srcValue = src[index];
|
|
798
797
|
if (srcValue !== dstValue) {
|
|
799
798
|
if (srcValue && dstValue && typeof srcValue === "object" && typeof dstValue === "object" && (srcValue.constructor === dstValue.constructor || flags & MERGE && dstValue instanceof Array)) {
|
|
@@ -801,7 +800,7 @@ function copyValue(dst, src, index, flags) {
|
|
|
801
800
|
return;
|
|
802
801
|
}
|
|
803
802
|
if (!(flags & SHALLOW) && srcValue && typeof srcValue === "object") {
|
|
804
|
-
|
|
803
|
+
const copy2 = Object.create(Object.getPrototypeOf(srcValue));
|
|
805
804
|
copyRecurse(copy2, srcValue, 0);
|
|
806
805
|
srcValue = copy2;
|
|
807
806
|
}
|
|
@@ -834,30 +833,41 @@ var refHandler = {
|
|
|
834
833
|
function ref(target, index) {
|
|
835
834
|
return new Proxy({ proxy: target, index }, refHandler);
|
|
836
835
|
}
|
|
837
|
-
function applyBind(
|
|
838
|
-
const el = _el;
|
|
836
|
+
function applyBind(el, target) {
|
|
839
837
|
let onProxyChange;
|
|
840
838
|
let onInputChange;
|
|
841
|
-
|
|
842
|
-
|
|
839
|
+
const type = el.getAttribute("type");
|
|
840
|
+
const value = unproxy(target).value;
|
|
843
841
|
if (type === "checkbox") {
|
|
844
842
|
if (value === undefined)
|
|
845
843
|
target.value = el.checked;
|
|
846
|
-
onProxyChange = () =>
|
|
847
|
-
|
|
844
|
+
onProxyChange = () => {
|
|
845
|
+
el.checked = target.value;
|
|
846
|
+
};
|
|
847
|
+
onInputChange = () => {
|
|
848
|
+
target.value = el.checked;
|
|
849
|
+
};
|
|
848
850
|
} else if (type === "radio") {
|
|
849
851
|
if (value === undefined && el.checked)
|
|
850
852
|
target.value = el.value;
|
|
851
|
-
onProxyChange = () =>
|
|
853
|
+
onProxyChange = () => {
|
|
854
|
+
el.checked = target.value === el.value;
|
|
855
|
+
};
|
|
852
856
|
onInputChange = () => {
|
|
853
857
|
if (el.checked)
|
|
854
858
|
target.value = el.value;
|
|
855
859
|
};
|
|
856
860
|
} else {
|
|
857
|
-
onInputChange = () =>
|
|
861
|
+
onInputChange = () => {
|
|
862
|
+
target.value = type === "number" || type === "range" ? el.value === "" ? null : +el.value : el.value;
|
|
863
|
+
};
|
|
858
864
|
if (value === undefined)
|
|
859
865
|
onInputChange();
|
|
860
|
-
onProxyChange = () =>
|
|
866
|
+
onProxyChange = () => {
|
|
867
|
+
el.value = target.value;
|
|
868
|
+
if (el.tagName === "SELECT" && el.value != target.value)
|
|
869
|
+
throw new Error(`SELECT has no '${target.value}' OPTION (yet)`);
|
|
870
|
+
};
|
|
861
871
|
}
|
|
862
872
|
observe(onProxyChange);
|
|
863
873
|
el.addEventListener("input", onInputChange);
|
|
@@ -866,7 +876,7 @@ function applyBind(_el, target) {
|
|
|
866
876
|
});
|
|
867
877
|
}
|
|
868
878
|
var SPECIAL_PROPS = {
|
|
869
|
-
create:
|
|
879
|
+
create: (value) => {
|
|
870
880
|
const el = currentScope.parentElement;
|
|
871
881
|
if (currentScope !== topRedrawScope)
|
|
872
882
|
return;
|
|
@@ -875,26 +885,26 @@ var SPECIAL_PROPS = {
|
|
|
875
885
|
} else {
|
|
876
886
|
const classes = value.split(".").filter((c) => c);
|
|
877
887
|
el.classList.add(...classes);
|
|
878
|
-
(async
|
|
888
|
+
(async () => {
|
|
879
889
|
el.offsetHeight;
|
|
880
890
|
el.classList.remove(...classes);
|
|
881
891
|
})();
|
|
882
892
|
}
|
|
883
893
|
},
|
|
884
|
-
destroy:
|
|
894
|
+
destroy: (value) => {
|
|
885
895
|
const el = currentScope.parentElement;
|
|
886
896
|
onDestroyMap.set(el, value);
|
|
887
897
|
},
|
|
888
|
-
html:
|
|
889
|
-
|
|
890
|
-
tmpParent.innerHTML =
|
|
898
|
+
html: (value) => {
|
|
899
|
+
const tmpParent = document.createElement(currentScope.parentElement.tagName);
|
|
900
|
+
tmpParent.innerHTML = `${value}`;
|
|
891
901
|
while (tmpParent.firstChild)
|
|
892
902
|
addNode(tmpParent.firstChild);
|
|
893
903
|
},
|
|
894
|
-
text:
|
|
904
|
+
text: (value) => {
|
|
895
905
|
addNode(document.createTextNode(value));
|
|
896
906
|
},
|
|
897
|
-
element:
|
|
907
|
+
element: (value) => {
|
|
898
908
|
if (!(value instanceof Node))
|
|
899
909
|
throw new Error(`Unexpected element-argument: ${JSON.parse(value)}`);
|
|
900
910
|
addNode(value);
|
|
@@ -908,7 +918,8 @@ function $(...args) {
|
|
|
908
918
|
if (arg == null || arg === false)
|
|
909
919
|
continue;
|
|
910
920
|
if (typeof arg === "string") {
|
|
911
|
-
let text
|
|
921
|
+
let text;
|
|
922
|
+
let classes;
|
|
912
923
|
const textPos = arg.indexOf(":");
|
|
913
924
|
if (textPos >= 0) {
|
|
914
925
|
text = arg.substring(textPos + 1);
|
|
@@ -942,7 +953,7 @@ function $(...args) {
|
|
|
942
953
|
if (!savedCurrentScope) {
|
|
943
954
|
savedCurrentScope = currentScope;
|
|
944
955
|
}
|
|
945
|
-
|
|
956
|
+
const newScope = new ChainedScope(result, true);
|
|
946
957
|
newScope.lastChild = result.lastChild || undefined;
|
|
947
958
|
if (topRedrawScope === currentScope)
|
|
948
959
|
topRedrawScope = newScope;
|
|
@@ -973,10 +984,10 @@ function $(...args) {
|
|
|
973
984
|
}
|
|
974
985
|
var cssCount = 0;
|
|
975
986
|
function insertCss(style, global = false) {
|
|
976
|
-
const prefix = global ? "" :
|
|
977
|
-
|
|
987
|
+
const prefix = global ? "" : `.AbdStl${++cssCount}`;
|
|
988
|
+
const css = styleToCss(style, prefix);
|
|
978
989
|
if (css)
|
|
979
|
-
$(
|
|
990
|
+
$(`style:${css}`);
|
|
980
991
|
return prefix;
|
|
981
992
|
}
|
|
982
993
|
function styleToCss(style, prefix) {
|
|
@@ -987,20 +998,20 @@ function styleToCss(style, prefix) {
|
|
|
987
998
|
for (const k of kOr.split(/, ?/g)) {
|
|
988
999
|
if (v && typeof v === "object") {
|
|
989
1000
|
if (k.startsWith("@")) {
|
|
990
|
-
rules += k
|
|
991
|
-
|
|
1001
|
+
rules += `${k}{
|
|
1002
|
+
${styleToCss(v, prefix)}}
|
|
992
1003
|
`;
|
|
993
1004
|
} else {
|
|
994
|
-
rules += styleToCss(v, k.includes("&") ? k.replace(/&/g, prefix) : prefix
|
|
1005
|
+
rules += styleToCss(v, k.includes("&") ? k.replace(/&/g, prefix) : `${prefix} ${k}`);
|
|
995
1006
|
}
|
|
996
1007
|
} else {
|
|
997
|
-
props += k.replace(/[A-Z]/g, (letter) =>
|
|
1008
|
+
props += `${k.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}:${v};`;
|
|
998
1009
|
}
|
|
999
1010
|
}
|
|
1000
1011
|
}
|
|
1001
1012
|
if (props)
|
|
1002
|
-
rules =
|
|
1003
|
-
|
|
1013
|
+
rules = `${prefix.trimStart() || "*"}{${props}}
|
|
1014
|
+
${rules}`;
|
|
1004
1015
|
return rules;
|
|
1005
1016
|
}
|
|
1006
1017
|
function applyArg(key, value) {
|
|
@@ -1022,7 +1033,7 @@ function applyArg(key, value) {
|
|
|
1022
1033
|
if (value == null || value === false)
|
|
1023
1034
|
el.style[name] = "";
|
|
1024
1035
|
else
|
|
1025
|
-
el.style[name] =
|
|
1036
|
+
el.style[name] = `${value}`;
|
|
1026
1037
|
} else if (value == null) {} else if (key in SPECIAL_PROPS) {
|
|
1027
1038
|
SPECIAL_PROPS[key](value);
|
|
1028
1039
|
} else if (typeof value === "function") {
|
|
@@ -1070,9 +1081,9 @@ function peek(func) {
|
|
|
1070
1081
|
}
|
|
1071
1082
|
}
|
|
1072
1083
|
function map(source, func) {
|
|
1073
|
-
|
|
1084
|
+
const out = optProxy(source instanceof Array ? [] : {});
|
|
1074
1085
|
onEach(source, (item, key) => {
|
|
1075
|
-
|
|
1086
|
+
const value = func(item, key);
|
|
1076
1087
|
if (value !== undefined) {
|
|
1077
1088
|
out[key] = value;
|
|
1078
1089
|
clean(() => {
|
|
@@ -1083,14 +1094,14 @@ function map(source, func) {
|
|
|
1083
1094
|
return out;
|
|
1084
1095
|
}
|
|
1085
1096
|
function multiMap(source, func) {
|
|
1086
|
-
|
|
1097
|
+
const out = optProxy({});
|
|
1087
1098
|
onEach(source, (item, key) => {
|
|
1088
|
-
|
|
1099
|
+
const pairs = func(item, key);
|
|
1089
1100
|
if (pairs) {
|
|
1090
|
-
for (
|
|
1101
|
+
for (const key2 in pairs)
|
|
1091
1102
|
out[key2] = pairs[key2];
|
|
1092
1103
|
clean(() => {
|
|
1093
|
-
for (
|
|
1104
|
+
for (const key2 in pairs)
|
|
1094
1105
|
delete out[key2];
|
|
1095
1106
|
});
|
|
1096
1107
|
}
|
|
@@ -1101,18 +1112,18 @@ function partition(source, func) {
|
|
|
1101
1112
|
const unproxiedOut = {};
|
|
1102
1113
|
const out = proxy(unproxiedOut);
|
|
1103
1114
|
onEach(source, (item, key) => {
|
|
1104
|
-
|
|
1115
|
+
const rsp = func(item, key);
|
|
1105
1116
|
if (rsp != null) {
|
|
1106
1117
|
const buckets = rsp instanceof Array ? rsp : [rsp];
|
|
1107
1118
|
if (buckets.length) {
|
|
1108
|
-
for (
|
|
1119
|
+
for (const bucket of buckets) {
|
|
1109
1120
|
if (unproxiedOut[bucket])
|
|
1110
1121
|
out[bucket][key] = item;
|
|
1111
1122
|
else
|
|
1112
1123
|
out[bucket] = { [key]: item };
|
|
1113
1124
|
}
|
|
1114
1125
|
clean(() => {
|
|
1115
|
-
for (
|
|
1126
|
+
for (const bucket of buckets) {
|
|
1116
1127
|
delete out[bucket][key];
|
|
1117
1128
|
if (isObjEmpty(unproxiedOut[bucket]))
|
|
1118
1129
|
delete out[bucket];
|
|
@@ -1128,7 +1139,7 @@ function dump(data) {
|
|
|
1128
1139
|
$({ text: data instanceof Array ? "<array>" : "<object>" });
|
|
1129
1140
|
$("ul", () => {
|
|
1130
1141
|
onEach(data, (value, key) => {
|
|
1131
|
-
$(
|
|
1142
|
+
$(`li:${JSON.stringify(key)}: `, () => {
|
|
1132
1143
|
dump(value);
|
|
1133
1144
|
});
|
|
1134
1145
|
});
|
|
@@ -1139,7 +1150,7 @@ function dump(data) {
|
|
|
1139
1150
|
return data;
|
|
1140
1151
|
}
|
|
1141
1152
|
function internalError(code) {
|
|
1142
|
-
throw new Error(
|
|
1153
|
+
throw new Error(`Aberdeen internal error ${code}`);
|
|
1143
1154
|
}
|
|
1144
1155
|
function handleError(e, showMessage) {
|
|
1145
1156
|
try {
|
|
@@ -1162,10 +1173,6 @@ function withEmitHandler(handler, func) {
|
|
|
1162
1173
|
emit = oldEmitHandler;
|
|
1163
1174
|
}
|
|
1164
1175
|
}
|
|
1165
|
-
if (!String.prototype.replaceAll)
|
|
1166
|
-
String.prototype.replaceAll = function(from, to) {
|
|
1167
|
-
return this.split(from).join(to);
|
|
1168
|
-
};
|
|
1169
1176
|
export {
|
|
1170
1177
|
withEmitHandler,
|
|
1171
1178
|
unproxy,
|
|
@@ -1197,5 +1204,5 @@ export {
|
|
|
1197
1204
|
$
|
|
1198
1205
|
};
|
|
1199
1206
|
|
|
1200
|
-
//# debugId=
|
|
1207
|
+
//# debugId=7D3AE73408804D7B64756E2164756E21
|
|
1201
1208
|
//# sourceMappingURL=aberdeen.js.map
|