aberdeen 1.1.0 → 1.3.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 +32 -15
- package/README.md.bak +212 -0
- package/dist/aberdeen.d.ts +64 -30
- package/dist/aberdeen.js +167 -137
- package/dist/aberdeen.js.map +3 -3
- package/dist/prediction.js.map +1 -1
- package/dist/route.d.ts +3 -2
- package/dist/route.js +4 -4
- package/dist/route.js.map +3 -3
- package/dist-min/aberdeen.js +5 -5
- package/dist-min/aberdeen.js.map +3 -3
- package/dist-min/dispatcher.js +2 -2
- package/dist-min/dispatcher.js.map +2 -2
- package/dist-min/prediction.js +2 -2
- package/dist-min/prediction.js.map +2 -2
- package/dist-min/route.js +2 -2
- package/dist-min/route.js.map +3 -3
- package/html-to-aberdeen +397 -0
- package/package.json +5 -5
- package/src/aberdeen.ts +255 -183
- package/src/route.ts +5 -4
package/dist/aberdeen.js
CHANGED
|
@@ -154,6 +154,9 @@ var lastPrio = 0;
|
|
|
154
154
|
|
|
155
155
|
class Scope {
|
|
156
156
|
prio = --lastPrio;
|
|
157
|
+
onChange(index) {
|
|
158
|
+
queue(this);
|
|
159
|
+
}
|
|
157
160
|
remove() {
|
|
158
161
|
const lastNode = this.getLastNode();
|
|
159
162
|
if (lastNode)
|
|
@@ -164,7 +167,6 @@ class Scope {
|
|
|
164
167
|
|
|
165
168
|
class ContentScope extends Scope {
|
|
166
169
|
cleaners;
|
|
167
|
-
inSvgNamespace = false;
|
|
168
170
|
constructor(cleaners = []) {
|
|
169
171
|
super();
|
|
170
172
|
this.cleaners = cleaners;
|
|
@@ -203,13 +205,14 @@ class ContentScope extends Scope {
|
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
class ChainedScope extends ContentScope {
|
|
206
|
-
|
|
208
|
+
el;
|
|
209
|
+
svg;
|
|
207
210
|
prevSibling;
|
|
208
|
-
constructor(
|
|
211
|
+
constructor(el, svg, useParentCleaners = false) {
|
|
209
212
|
super(useParentCleaners ? currentScope.cleaners : []);
|
|
210
|
-
this.
|
|
211
|
-
this.
|
|
212
|
-
if (
|
|
213
|
+
this.el = el;
|
|
214
|
+
this.svg = svg;
|
|
215
|
+
if (el === currentScope.el) {
|
|
213
216
|
this.prevSibling = currentScope.getChildPrevSibling();
|
|
214
217
|
currentScope.lastChild = this;
|
|
215
218
|
}
|
|
@@ -226,8 +229,8 @@ class ChainedScope extends ContentScope {
|
|
|
226
229
|
|
|
227
230
|
class RegularScope extends ChainedScope {
|
|
228
231
|
renderer;
|
|
229
|
-
constructor(
|
|
230
|
-
super(
|
|
232
|
+
constructor(el, svg, renderer) {
|
|
233
|
+
super(el, svg);
|
|
231
234
|
this.renderer = renderer;
|
|
232
235
|
this.redraw();
|
|
233
236
|
}
|
|
@@ -244,20 +247,22 @@ class RegularScope extends ChainedScope {
|
|
|
244
247
|
}
|
|
245
248
|
|
|
246
249
|
class RootScope extends ContentScope {
|
|
247
|
-
|
|
250
|
+
el = document.body;
|
|
251
|
+
svg = false;
|
|
248
252
|
getPrecedingNode() {
|
|
249
253
|
return;
|
|
250
254
|
}
|
|
251
255
|
}
|
|
252
256
|
|
|
253
257
|
class MountScope extends ContentScope {
|
|
254
|
-
|
|
258
|
+
el;
|
|
255
259
|
renderer;
|
|
256
|
-
|
|
260
|
+
svg;
|
|
261
|
+
constructor(el, renderer) {
|
|
257
262
|
super();
|
|
258
|
-
this.
|
|
263
|
+
this.el = el;
|
|
259
264
|
this.renderer = renderer;
|
|
260
|
-
this.
|
|
265
|
+
this.svg = el.namespaceURI === "http://www.w3.org/2000/svg";
|
|
261
266
|
this.redraw();
|
|
262
267
|
currentScope.cleaners.push(this);
|
|
263
268
|
}
|
|
@@ -303,8 +308,8 @@ function findLastNodeInPrevSiblings(sibling) {
|
|
|
303
308
|
class ResultScope extends ChainedScope {
|
|
304
309
|
renderer;
|
|
305
310
|
result = optProxy({ value: undefined });
|
|
306
|
-
constructor(
|
|
307
|
-
super(
|
|
311
|
+
constructor(renderer) {
|
|
312
|
+
super(currentScope.el, currentScope.svg);
|
|
308
313
|
this.renderer = renderer;
|
|
309
314
|
this.redraw();
|
|
310
315
|
}
|
|
@@ -323,8 +328,9 @@ class ResultScope extends ChainedScope {
|
|
|
323
328
|
class SetArgScope extends ChainedScope {
|
|
324
329
|
key;
|
|
325
330
|
target;
|
|
326
|
-
|
|
327
|
-
|
|
331
|
+
svg = false;
|
|
332
|
+
constructor(el, key, target) {
|
|
333
|
+
super(el, el.namespaceURI === "http://www.w3.org/2000/svg");
|
|
328
334
|
this.key = key;
|
|
329
335
|
this.target = target;
|
|
330
336
|
this.redraw();
|
|
@@ -332,7 +338,7 @@ class SetArgScope extends ChainedScope {
|
|
|
332
338
|
redraw() {
|
|
333
339
|
const savedScope = currentScope;
|
|
334
340
|
currentScope = this;
|
|
335
|
-
applyArg(this.key, this.target.value);
|
|
341
|
+
applyArg(this.el, this.key, this.target.value);
|
|
336
342
|
currentScope = savedScope;
|
|
337
343
|
}
|
|
338
344
|
}
|
|
@@ -340,7 +346,7 @@ class SetArgScope extends ChainedScope {
|
|
|
340
346
|
class OnEachScope extends Scope {
|
|
341
347
|
renderer;
|
|
342
348
|
makeSortKey;
|
|
343
|
-
parentElement = currentScope.
|
|
349
|
+
parentElement = currentScope.el;
|
|
344
350
|
prevSibling;
|
|
345
351
|
target;
|
|
346
352
|
byIndex = new Map;
|
|
@@ -411,13 +417,14 @@ class OnEachItemScope extends ContentScope {
|
|
|
411
417
|
parent;
|
|
412
418
|
itemIndex;
|
|
413
419
|
sortKey;
|
|
414
|
-
|
|
420
|
+
el;
|
|
421
|
+
svg;
|
|
415
422
|
constructor(parent, itemIndex, topRedraw) {
|
|
416
423
|
super();
|
|
417
424
|
this.parent = parent;
|
|
418
425
|
this.itemIndex = itemIndex;
|
|
419
|
-
this.
|
|
420
|
-
this.
|
|
426
|
+
this.el = parent.parentElement;
|
|
427
|
+
this.svg = currentScope.svg;
|
|
421
428
|
this.parent.byIndex.set(this.itemIndex, this);
|
|
422
429
|
this.lastChild = this;
|
|
423
430
|
if (topRedraw)
|
|
@@ -509,8 +516,12 @@ class OnEachItemScope extends ContentScope {
|
|
|
509
516
|
this.delete();
|
|
510
517
|
}
|
|
511
518
|
}
|
|
512
|
-
function addNode(node) {
|
|
513
|
-
|
|
519
|
+
function addNode(el, node) {
|
|
520
|
+
if (el !== currentScope.el) {
|
|
521
|
+
el.appendChild(node);
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
const parentEl = currentScope.el;
|
|
514
525
|
const prevNode = currentScope.getInsertAfterNode();
|
|
515
526
|
parentEl.insertBefore(node, prevNode ? prevNode.nextSibling : parentEl.firstChild);
|
|
516
527
|
currentScope.lastChild = node;
|
|
@@ -645,7 +656,7 @@ var objectHandler = {
|
|
|
645
656
|
return true;
|
|
646
657
|
},
|
|
647
658
|
deleteProperty(target, prop) {
|
|
648
|
-
const old = target.hasOwnProperty(prop) ? target[prop] :
|
|
659
|
+
const old = target.hasOwnProperty(prop) ? target[prop] : EMPTY;
|
|
649
660
|
delete target[prop];
|
|
650
661
|
emit(target, prop, EMPTY, old);
|
|
651
662
|
return true;
|
|
@@ -843,7 +854,7 @@ var mapHandler = {
|
|
|
843
854
|
};
|
|
844
855
|
var proxyMap = new WeakMap;
|
|
845
856
|
function optProxy(value) {
|
|
846
|
-
if (typeof value !== "object" || !value || value[TARGET_SYMBOL] !== undefined) {
|
|
857
|
+
if (typeof value !== "object" || !value || value[TARGET_SYMBOL] !== undefined || NO_COPY in value) {
|
|
847
858
|
return value;
|
|
848
859
|
}
|
|
849
860
|
let proxied = proxyMap.get(value);
|
|
@@ -862,6 +873,19 @@ function optProxy(value) {
|
|
|
862
873
|
return proxied;
|
|
863
874
|
}
|
|
864
875
|
function proxy(target) {
|
|
876
|
+
if (target instanceof Promise) {
|
|
877
|
+
const result = optProxy({
|
|
878
|
+
busy: true
|
|
879
|
+
});
|
|
880
|
+
target.then((value) => {
|
|
881
|
+
result.value = value;
|
|
882
|
+
result.busy = false;
|
|
883
|
+
}).catch((err) => {
|
|
884
|
+
result.error = err;
|
|
885
|
+
result.busy = false;
|
|
886
|
+
});
|
|
887
|
+
return result;
|
|
888
|
+
}
|
|
865
889
|
return optProxy(typeof target === "object" && target !== null ? target : { value: target });
|
|
866
890
|
}
|
|
867
891
|
function unproxy(target) {
|
|
@@ -876,14 +900,14 @@ function destroyWithClass(element, cls) {
|
|
|
876
900
|
function copy(a, b, c) {
|
|
877
901
|
if (arguments.length > 2)
|
|
878
902
|
return copySet(a, b, c, 0);
|
|
879
|
-
return
|
|
903
|
+
return copyImpl(a, b, 0);
|
|
880
904
|
}
|
|
881
905
|
function copySet(dst, dstKey, src, flags) {
|
|
882
906
|
let dstVal = peek(dst, dstKey);
|
|
883
907
|
if (src === dstVal)
|
|
884
908
|
return false;
|
|
885
909
|
if (typeof dstVal === "object" && dstVal && typeof src === "object" && src && dstVal.constructor === src.constructor) {
|
|
886
|
-
return
|
|
910
|
+
return copyImpl(dstVal, src, flags);
|
|
887
911
|
}
|
|
888
912
|
src = clone(src);
|
|
889
913
|
if (dst instanceof Map)
|
|
@@ -895,9 +919,9 @@ function copySet(dst, dstKey, src, flags) {
|
|
|
895
919
|
function merge(a, b, c) {
|
|
896
920
|
if (arguments.length > 2)
|
|
897
921
|
return copySet(a, b, c, MERGE);
|
|
898
|
-
return
|
|
922
|
+
return copyImpl(a, b, MERGE);
|
|
899
923
|
}
|
|
900
|
-
function
|
|
924
|
+
function copyImpl(dst, src, flags) {
|
|
901
925
|
let unproxied = dst[TARGET_SYMBOL];
|
|
902
926
|
if (unproxied) {
|
|
903
927
|
dst = unproxied;
|
|
@@ -909,6 +933,9 @@ function copyRecursive(dst, src, flags) {
|
|
|
909
933
|
if (currentScope !== ROOT_SCOPE && !peeking)
|
|
910
934
|
flags |= COPY_SUBSCRIBE;
|
|
911
935
|
}
|
|
936
|
+
return copyRecursive(dst, src, flags);
|
|
937
|
+
}
|
|
938
|
+
function copyRecursive(dst, src, flags) {
|
|
912
939
|
if (flags & COPY_SUBSCRIBE)
|
|
913
940
|
subscribe(src, ANY_SYMBOL);
|
|
914
941
|
let changed = false;
|
|
@@ -927,7 +954,7 @@ function copyRecursive(dst, src, flags) {
|
|
|
927
954
|
changed = true;
|
|
928
955
|
} else if (dstValue !== srcValue) {
|
|
929
956
|
if (srcValue && typeof srcValue === "object") {
|
|
930
|
-
if (typeof dstValue === "object" && dstValue && srcValue.constructor === dstValue.constructor) {
|
|
957
|
+
if (typeof dstValue === "object" && dstValue && srcValue.constructor === dstValue.constructor && !(NO_COPY in srcValue)) {
|
|
931
958
|
changed = copyRecursive(dstValue, srcValue, flags) || changed;
|
|
932
959
|
continue;
|
|
933
960
|
}
|
|
@@ -961,7 +988,7 @@ function copyRecursive(dst, src, flags) {
|
|
|
961
988
|
dstValue = EMPTY;
|
|
962
989
|
if (dstValue !== srcValue) {
|
|
963
990
|
if (srcValue && typeof srcValue === "object") {
|
|
964
|
-
if (typeof dstValue === "object" && dstValue && srcValue.constructor === dstValue.constructor) {
|
|
991
|
+
if (typeof dstValue === "object" && dstValue && srcValue.constructor === dstValue.constructor && !(NO_COPY in srcValue)) {
|
|
965
992
|
changed = copyRecursive(dstValue, srcValue, flags) || changed;
|
|
966
993
|
continue;
|
|
967
994
|
}
|
|
@@ -991,7 +1018,7 @@ function copyRecursive(dst, src, flags) {
|
|
|
991
1018
|
const dstValue = dst.hasOwnProperty(key) ? dst[key] : EMPTY;
|
|
992
1019
|
if (dstValue !== srcValue) {
|
|
993
1020
|
if (srcValue && typeof srcValue === "object") {
|
|
994
|
-
if (typeof dstValue === "object" && dstValue && srcValue.constructor === dstValue.constructor) {
|
|
1021
|
+
if (typeof dstValue === "object" && dstValue && srcValue.constructor === dstValue.constructor && !(NO_COPY in srcValue)) {
|
|
995
1022
|
changed = copyRecursive(dstValue, srcValue, flags) || changed;
|
|
996
1023
|
continue;
|
|
997
1024
|
}
|
|
@@ -1023,9 +1050,13 @@ function copyRecursive(dst, src, flags) {
|
|
|
1023
1050
|
var MERGE = 1;
|
|
1024
1051
|
var COPY_SUBSCRIBE = 32;
|
|
1025
1052
|
var COPY_EMIT = 64;
|
|
1053
|
+
var NO_COPY = Symbol("NO_COPY");
|
|
1054
|
+
Promise.prototype[NO_COPY] = true;
|
|
1026
1055
|
function clone(src) {
|
|
1056
|
+
if (NO_COPY in src)
|
|
1057
|
+
return src;
|
|
1027
1058
|
const copied = Array.isArray(src) ? [] : src instanceof Map ? new Map : Object.create(Object.getPrototypeOf(src));
|
|
1028
|
-
|
|
1059
|
+
copyImpl(copied, src, MERGE);
|
|
1029
1060
|
return copied;
|
|
1030
1061
|
}
|
|
1031
1062
|
var refHandler = {
|
|
@@ -1091,8 +1122,7 @@ function applyBind(el, target) {
|
|
|
1091
1122
|
});
|
|
1092
1123
|
}
|
|
1093
1124
|
var SPECIAL_PROPS = {
|
|
1094
|
-
create: (value) => {
|
|
1095
|
-
const el = currentScope.parentElement;
|
|
1125
|
+
create: (el, value) => {
|
|
1096
1126
|
if (currentScope !== topRedrawScope)
|
|
1097
1127
|
return;
|
|
1098
1128
|
if (typeof value === "function") {
|
|
@@ -1106,117 +1136,118 @@ var SPECIAL_PROPS = {
|
|
|
1106
1136
|
})();
|
|
1107
1137
|
}
|
|
1108
1138
|
},
|
|
1109
|
-
destroy: (value) => {
|
|
1110
|
-
const el = currentScope.parentElement;
|
|
1139
|
+
destroy: (el, value) => {
|
|
1111
1140
|
onDestroyMap.set(el, value);
|
|
1112
1141
|
},
|
|
1113
|
-
html: (value) => {
|
|
1114
|
-
const tmpParent = document.createElement(currentScope.
|
|
1142
|
+
html: (el, value) => {
|
|
1143
|
+
const tmpParent = document.createElement(currentScope.el.tagName);
|
|
1115
1144
|
tmpParent.innerHTML = `${value}`;
|
|
1116
1145
|
while (tmpParent.firstChild)
|
|
1117
|
-
addNode(tmpParent.firstChild);
|
|
1146
|
+
addNode(el, tmpParent.firstChild);
|
|
1118
1147
|
},
|
|
1119
|
-
text: (value) => {
|
|
1120
|
-
addNode(document.createTextNode(value));
|
|
1148
|
+
text: (el, value) => {
|
|
1149
|
+
addNode(el, document.createTextNode(value));
|
|
1121
1150
|
}
|
|
1122
1151
|
};
|
|
1123
1152
|
function $(...args) {
|
|
1124
|
-
let
|
|
1125
|
-
let
|
|
1126
|
-
|
|
1127
|
-
for (let
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
let
|
|
1132
|
-
let
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1153
|
+
let el = currentScope.el;
|
|
1154
|
+
let svg = currentScope.svg;
|
|
1155
|
+
const argCount = args.length;
|
|
1156
|
+
for (let argIndex = 0;argIndex < argCount; argIndex++) {
|
|
1157
|
+
const arg = args[argIndex];
|
|
1158
|
+
if (arg == null || arg === false) {} else if (typeof arg === "string") {
|
|
1159
|
+
let argLen = arg.length;
|
|
1160
|
+
let nextPos = 0;
|
|
1161
|
+
for (let pos = 0;pos < argLen; pos = nextPos + 1) {
|
|
1162
|
+
nextPos = findFirst(arg, " .=:#", pos);
|
|
1163
|
+
const next = arg[nextPos];
|
|
1164
|
+
if (next === ":" || next === "=") {
|
|
1165
|
+
let key = arg.substring(pos, nextPos);
|
|
1166
|
+
if (next === ":")
|
|
1167
|
+
key = "$" + key;
|
|
1168
|
+
if (nextPos + 1 >= argLen) {
|
|
1169
|
+
applyArg(el, key, args[++argIndex]);
|
|
1170
|
+
break;
|
|
1171
|
+
}
|
|
1172
|
+
if (arg[nextPos + 1] === '"') {
|
|
1173
|
+
const endIndex = findFirst(arg, '"', nextPos + 2);
|
|
1174
|
+
const value = arg.substring(nextPos + 2, endIndex);
|
|
1175
|
+
applyArg(el, key, value);
|
|
1176
|
+
nextPos = endIndex;
|
|
1177
|
+
} else {
|
|
1178
|
+
const endIndex = findFirst(arg, " ", nextPos + 1);
|
|
1179
|
+
const value = arg.substring(nextPos + 1, endIndex);
|
|
1180
|
+
applyArg(el, key, value);
|
|
1181
|
+
nextPos = endIndex;
|
|
1151
1182
|
}
|
|
1152
|
-
}
|
|
1153
|
-
} else if (arg.indexOf(" ") >= 0) {
|
|
1154
|
-
err = `Tag '${arg}' cannot contain space`;
|
|
1155
|
-
break;
|
|
1156
|
-
} else {
|
|
1157
|
-
const useNamespace = currentScope.inSvgNamespace || arg === "svg";
|
|
1158
|
-
if (useNamespace) {
|
|
1159
|
-
result = document.createElementNS("http://www.w3.org/2000/svg", arg);
|
|
1160
1183
|
} else {
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1184
|
+
if (nextPos > pos) {
|
|
1185
|
+
const tag = arg.substring(pos, nextPos);
|
|
1186
|
+
svg ||= tag === "svg";
|
|
1187
|
+
let newEl = svg ? document.createElementNS("http://www.w3.org/2000/svg", tag) : document.createElement(tag);
|
|
1188
|
+
addNode(el, newEl);
|
|
1189
|
+
el = newEl;
|
|
1190
|
+
}
|
|
1191
|
+
if (next === "#") {
|
|
1192
|
+
const text = nextPos + 1 < argLen ? arg.substring(nextPos + 1) : args[++argIndex];
|
|
1193
|
+
applyArg(el, "text", text);
|
|
1194
|
+
break;
|
|
1195
|
+
}
|
|
1196
|
+
if (next === ".") {
|
|
1197
|
+
let classEnd = findFirst(arg, " #=.", nextPos + 1);
|
|
1198
|
+
if (arg[classEnd] === "=" && classEnd + 1 >= argLen) {
|
|
1199
|
+
applyArg(el, arg.substring(nextPos, classEnd), args[++argIndex]);
|
|
1200
|
+
nextPos = classEnd;
|
|
1201
|
+
} else {
|
|
1202
|
+
let className = arg.substring(nextPos + 1, classEnd);
|
|
1203
|
+
el.classList.add(className || args[++argIndex]);
|
|
1204
|
+
nextPos = classEnd - 1;
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1174
1207
|
}
|
|
1175
|
-
newScope.lastChild = result.lastChild || undefined;
|
|
1176
|
-
if (topRedrawScope === currentScope)
|
|
1177
|
-
topRedrawScope = newScope;
|
|
1178
|
-
currentScope = newScope;
|
|
1179
1208
|
}
|
|
1180
1209
|
} else if (typeof arg === "object") {
|
|
1181
1210
|
if (arg.constructor !== Object) {
|
|
1182
1211
|
if (arg instanceof Node) {
|
|
1183
|
-
addNode(arg);
|
|
1212
|
+
addNode(el, arg);
|
|
1184
1213
|
if (arg instanceof Element) {
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
currentScope = new ChainedScope(arg, true);
|
|
1188
|
-
currentScope.lastChild = arg.lastChild || undefined;
|
|
1214
|
+
el = arg;
|
|
1215
|
+
svg = arg.namespaceURI === "http://www.w3.org/2000/svg";
|
|
1189
1216
|
}
|
|
1190
1217
|
} else {
|
|
1191
|
-
|
|
1192
|
-
break;
|
|
1218
|
+
throw new Error(`Unexpected argument: ${arg}`);
|
|
1193
1219
|
}
|
|
1194
1220
|
} else {
|
|
1195
1221
|
for (const key of Object.keys(arg)) {
|
|
1196
|
-
|
|
1197
|
-
applyArg(key, val);
|
|
1222
|
+
applyArg(el, key, arg[key]);
|
|
1198
1223
|
}
|
|
1199
1224
|
}
|
|
1200
1225
|
} else if (typeof arg === "function") {
|
|
1201
|
-
new RegularScope(
|
|
1226
|
+
new RegularScope(el, svg, arg);
|
|
1202
1227
|
} else {
|
|
1203
|
-
|
|
1204
|
-
break;
|
|
1228
|
+
throw new Error(`Unexpected argument: ${arg}`);
|
|
1205
1229
|
}
|
|
1206
1230
|
}
|
|
1207
|
-
|
|
1208
|
-
|
|
1231
|
+
return el;
|
|
1232
|
+
}
|
|
1233
|
+
function findFirst(str, chars, startPos) {
|
|
1234
|
+
if (chars.length === 1) {
|
|
1235
|
+
const idx = str.indexOf(chars, startPos);
|
|
1236
|
+
return idx >= 0 ? idx : str.length;
|
|
1209
1237
|
}
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1238
|
+
const strLen = str.length;
|
|
1239
|
+
for (let i = startPos;i < strLen; i++) {
|
|
1240
|
+
if (chars.indexOf(str[i]) >= 0)
|
|
1241
|
+
return i;
|
|
1242
|
+
}
|
|
1243
|
+
return strLen;
|
|
1213
1244
|
}
|
|
1214
1245
|
var cssCount = 0;
|
|
1215
1246
|
function insertCss(style, global = false) {
|
|
1216
1247
|
const prefix = global ? "" : `.AbdStl${++cssCount}`;
|
|
1217
1248
|
const css = styleToCss(style, prefix);
|
|
1218
1249
|
if (css)
|
|
1219
|
-
$(`style
|
|
1250
|
+
$(`style#${css}`);
|
|
1220
1251
|
return prefix;
|
|
1221
1252
|
}
|
|
1222
1253
|
function styleToCss(style, prefix) {
|
|
@@ -1243,8 +1274,7 @@ ${styleToCss(v, prefix)}}
|
|
|
1243
1274
|
${rules}`;
|
|
1244
1275
|
return rules;
|
|
1245
1276
|
}
|
|
1246
|
-
function applyArg(key, value) {
|
|
1247
|
-
const el = currentScope.parentElement;
|
|
1277
|
+
function applyArg(el, key, value) {
|
|
1248
1278
|
if (typeof value === "object" && value !== null && value[TARGET_SYMBOL]) {
|
|
1249
1279
|
if (key === "bind") {
|
|
1250
1280
|
applyBind(el, value);
|
|
@@ -1264,10 +1294,11 @@ function applyArg(key, value) {
|
|
|
1264
1294
|
else
|
|
1265
1295
|
el.style[name] = `${value}`;
|
|
1266
1296
|
} else if (value == null) {} else if (key in SPECIAL_PROPS) {
|
|
1267
|
-
SPECIAL_PROPS[key](value);
|
|
1297
|
+
SPECIAL_PROPS[key](el, value);
|
|
1268
1298
|
} else if (typeof value === "function") {
|
|
1269
1299
|
el.addEventListener(key, value);
|
|
1270
|
-
|
|
1300
|
+
if (el === currentScope.el)
|
|
1301
|
+
clean(() => el.removeEventListener(key, value));
|
|
1271
1302
|
} else if (value === true || value === false || key === "value" || key === "selectedIndex") {
|
|
1272
1303
|
el[key] = value;
|
|
1273
1304
|
} else {
|
|
@@ -1283,13 +1314,13 @@ function setErrorHandler(handler) {
|
|
|
1283
1314
|
onError = handler || defaultOnError;
|
|
1284
1315
|
}
|
|
1285
1316
|
function getParentElement() {
|
|
1286
|
-
return currentScope.
|
|
1317
|
+
return currentScope.el;
|
|
1287
1318
|
}
|
|
1288
1319
|
function clean(cleaner) {
|
|
1289
1320
|
currentScope.cleaners.push(cleaner);
|
|
1290
1321
|
}
|
|
1291
1322
|
function derive(func) {
|
|
1292
|
-
return new ResultScope(
|
|
1323
|
+
return new ResultScope(func).result;
|
|
1293
1324
|
}
|
|
1294
1325
|
function mount(parentElement, func) {
|
|
1295
1326
|
new MountScope(parentElement, func);
|
|
@@ -1354,7 +1385,7 @@ function multiMap(source, func) {
|
|
|
1354
1385
|
}
|
|
1355
1386
|
function partition(source, func) {
|
|
1356
1387
|
const unproxiedOut = {};
|
|
1357
|
-
const out =
|
|
1388
|
+
const out = optProxy(unproxiedOut);
|
|
1358
1389
|
onEach(source, (item, key) => {
|
|
1359
1390
|
const rsp = func(item, key);
|
|
1360
1391
|
if (rsp != null) {
|
|
@@ -1380,24 +1411,22 @@ function partition(source, func) {
|
|
|
1380
1411
|
}
|
|
1381
1412
|
function dump(data) {
|
|
1382
1413
|
if (data && typeof data === "object") {
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
label = "<Map>";
|
|
1414
|
+
const name = data.constructor.name.toLowerCase() || "unknown object";
|
|
1415
|
+
$(`#<${name}>`);
|
|
1416
|
+
if (NO_COPY in data) {
|
|
1417
|
+
$("# [NO_COPY]");
|
|
1388
1418
|
} else {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
dump(value);
|
|
1419
|
+
$("ul", () => {
|
|
1420
|
+
onEach(data, (value, key) => {
|
|
1421
|
+
$("li", () => {
|
|
1422
|
+
$(`#${JSON.stringify(key)}: `);
|
|
1423
|
+
dump(value);
|
|
1424
|
+
});
|
|
1396
1425
|
});
|
|
1397
1426
|
});
|
|
1398
|
-
}
|
|
1399
|
-
} else {
|
|
1400
|
-
$(
|
|
1427
|
+
}
|
|
1428
|
+
} else if (data !== undefined) {
|
|
1429
|
+
$("#" + JSON.stringify(data));
|
|
1401
1430
|
}
|
|
1402
1431
|
return data;
|
|
1403
1432
|
}
|
|
@@ -1413,7 +1442,7 @@ function handleError(e, showMessage) {
|
|
|
1413
1442
|
}
|
|
1414
1443
|
try {
|
|
1415
1444
|
if (showMessage)
|
|
1416
|
-
$("div.aberdeen-error
|
|
1445
|
+
$("div.aberdeen-error#Error");
|
|
1417
1446
|
} catch {}
|
|
1418
1447
|
}
|
|
1419
1448
|
function withEmitHandler(handler, func) {
|
|
@@ -1452,8 +1481,9 @@ export {
|
|
|
1452
1481
|
copy,
|
|
1453
1482
|
clone,
|
|
1454
1483
|
clean,
|
|
1484
|
+
NO_COPY,
|
|
1455
1485
|
$
|
|
1456
1486
|
};
|
|
1457
1487
|
|
|
1458
|
-
//# debugId=
|
|
1488
|
+
//# debugId=C3082837141CF76064756E2164756E21
|
|
1459
1489
|
//# sourceMappingURL=aberdeen.js.map
|