@motifx/core 1.2.0-rc.1 → 1.2.0-rc.3
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 +1 -2
- package/dist/chunks/{core-SS-LXi1V.cjs → core-DD3SssnS.cjs} +1136 -851
- package/dist/chunks/core-DD3SssnS.cjs.map +1 -0
- package/dist/chunks/{core-vVL0WG0n.esm.js → core-W7wNt8bq.esm.js} +1134 -852
- package/dist/chunks/core-W7wNt8bq.esm.js.map +1 -0
- package/dist/devtools.cjs +1 -1
- package/dist/devtools.esm.js +1 -1
- package/dist/index.cjs +101 -156
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -21
- package/dist/index.d.ts +53 -21
- package/dist/index.esm.js +92 -147
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.umd.js +1204 -977
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/core-SS-LXi1V.cjs.map +0 -1
- package/dist/chunks/core-vVL0WG0n.esm.js.map +0 -1
package/dist/index.umd.js
CHANGED
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
setTimeout(() => { throw error; }, 0);
|
|
9
9
|
}
|
|
10
10
|
class ErrorHandler {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
constructor() {
|
|
12
|
+
this.unexpectedErrorHandler = rethrowLater;
|
|
13
|
+
this.listeners = [];
|
|
14
|
+
this._isDevelopment = false;
|
|
15
|
+
this._enableConsoleLogging = true;
|
|
16
|
+
}
|
|
15
17
|
setDevelopmentMode(isDev) {
|
|
16
18
|
this._isDevelopment = isDev;
|
|
17
19
|
}
|
|
@@ -352,7 +354,6 @@
|
|
|
352
354
|
MJX611: () => `The devtools panel failed to load.`,
|
|
353
355
|
};
|
|
354
356
|
class MotifError extends Error {
|
|
355
|
-
code;
|
|
356
357
|
constructor(code, message, options) {
|
|
357
358
|
super(message, options);
|
|
358
359
|
this.name = 'MotifError';
|
|
@@ -384,7 +385,9 @@
|
|
|
384
385
|
}
|
|
385
386
|
|
|
386
387
|
class DisposableCore {
|
|
387
|
-
|
|
388
|
+
constructor() {
|
|
389
|
+
this.disposableTracker = null;
|
|
390
|
+
}
|
|
388
391
|
notifyCreated(target) {
|
|
389
392
|
this.disposableTracker?.trackDisposable(target);
|
|
390
393
|
return target;
|
|
@@ -413,9 +416,8 @@
|
|
|
413
416
|
const disposableCore = new DisposableCore();
|
|
414
417
|
|
|
415
418
|
class DisposableStore {
|
|
416
|
-
_items = new Set();
|
|
417
|
-
_closed = false;
|
|
418
419
|
constructor() {
|
|
420
|
+
this._closed = false;
|
|
419
421
|
disposableCore.notifyCreated(this);
|
|
420
422
|
}
|
|
421
423
|
get isDisposed() {
|
|
@@ -433,7 +435,7 @@
|
|
|
433
435
|
reportWarning('MJX504', [], new Error().stack);
|
|
434
436
|
}
|
|
435
437
|
else {
|
|
436
|
-
this._items.add(item);
|
|
438
|
+
(this._items ??= new Set()).add(item);
|
|
437
439
|
}
|
|
438
440
|
return item;
|
|
439
441
|
}
|
|
@@ -444,20 +446,21 @@
|
|
|
444
446
|
if (item === this) {
|
|
445
447
|
throw motifError('MJX505');
|
|
446
448
|
}
|
|
447
|
-
this._items
|
|
449
|
+
this._items?.delete(item);
|
|
448
450
|
item.dispose();
|
|
449
451
|
}
|
|
450
452
|
detach(item) {
|
|
451
|
-
if (item && this._items
|
|
453
|
+
if (item && this._items?.delete(item)) {
|
|
452
454
|
disposableCore.notifyOwner(item, null);
|
|
453
455
|
}
|
|
454
456
|
}
|
|
455
457
|
clear() {
|
|
456
|
-
|
|
458
|
+
const items = this._items;
|
|
459
|
+
if (!items || items.size === 0) {
|
|
457
460
|
return;
|
|
458
461
|
}
|
|
459
462
|
const failures = [];
|
|
460
|
-
for (const item of
|
|
463
|
+
for (const item of items) {
|
|
461
464
|
try {
|
|
462
465
|
item?.dispose();
|
|
463
466
|
}
|
|
@@ -465,7 +468,7 @@
|
|
|
465
468
|
failures.push(error);
|
|
466
469
|
}
|
|
467
470
|
}
|
|
468
|
-
|
|
471
|
+
items.clear();
|
|
469
472
|
if (failures.length === 1) {
|
|
470
473
|
throw failures[0];
|
|
471
474
|
}
|
|
@@ -483,16 +486,34 @@
|
|
|
483
486
|
}
|
|
484
487
|
}
|
|
485
488
|
|
|
489
|
+
let closedStore;
|
|
490
|
+
function sharedClosedStore() {
|
|
491
|
+
if (closedStore === undefined) {
|
|
492
|
+
closedStore = new DisposableStore();
|
|
493
|
+
closedStore.dispose();
|
|
494
|
+
}
|
|
495
|
+
return closedStore;
|
|
496
|
+
}
|
|
486
497
|
class Disposable {
|
|
487
|
-
_disposables
|
|
498
|
+
get _disposables() {
|
|
499
|
+
let store = this._store;
|
|
500
|
+
if (store === undefined) {
|
|
501
|
+
store = this._store = new DisposableStore();
|
|
502
|
+
disposableCore.notifyOwner(store, this);
|
|
503
|
+
}
|
|
504
|
+
return store;
|
|
505
|
+
}
|
|
488
506
|
constructor() {
|
|
507
|
+
this._store = undefined;
|
|
489
508
|
disposableCore.notifyCreated(this);
|
|
490
|
-
disposableCore.notifyOwner(this._disposables, this);
|
|
491
509
|
}
|
|
492
510
|
dispose() {
|
|
493
511
|
disposableCore.notifyDisposed(this);
|
|
494
|
-
const owned = this.
|
|
495
|
-
if (owned
|
|
512
|
+
const owned = this._store;
|
|
513
|
+
if (owned === undefined) {
|
|
514
|
+
this._store = sharedClosedStore();
|
|
515
|
+
}
|
|
516
|
+
else if (owned && typeof owned.dispose === 'function') {
|
|
496
517
|
owned.dispose();
|
|
497
518
|
}
|
|
498
519
|
else {
|
|
@@ -597,27 +618,17 @@
|
|
|
597
618
|
}
|
|
598
619
|
|
|
599
620
|
class ListBinding {
|
|
600
|
-
component;
|
|
601
|
-
itemsFn;
|
|
602
|
-
renderFn;
|
|
603
|
-
options;
|
|
604
|
-
propertyName = "__list__";
|
|
605
|
-
dataSource;
|
|
606
|
-
dataMember;
|
|
607
|
-
formatString;
|
|
608
|
-
converter;
|
|
609
|
-
converterBack;
|
|
610
|
-
updateMode;
|
|
611
|
-
_isActive = false;
|
|
612
|
-
_effectCleanup;
|
|
613
|
-
_rendered = [];
|
|
614
|
-
_identityMap = new WeakMap();
|
|
615
|
-
container = motifFragment('list-container');
|
|
616
621
|
constructor(component, itemsFn, renderFn, options) {
|
|
617
622
|
this.component = component;
|
|
618
623
|
this.itemsFn = itemsFn;
|
|
619
624
|
this.renderFn = renderFn;
|
|
620
625
|
this.options = options;
|
|
626
|
+
this.propertyName = "__list__";
|
|
627
|
+
this._isActive = false;
|
|
628
|
+
this._rendered = [];
|
|
629
|
+
this._identityMap = new WeakMap();
|
|
630
|
+
this.container = motifFragment('list-container');
|
|
631
|
+
this.olditems = [];
|
|
621
632
|
this.component.controls.add(this.container);
|
|
622
633
|
}
|
|
623
634
|
activate() { if (this._isActive)
|
|
@@ -701,7 +712,6 @@
|
|
|
701
712
|
}
|
|
702
713
|
return component;
|
|
703
714
|
}
|
|
704
|
-
olditems = [];
|
|
705
715
|
get _indexSensitive() {
|
|
706
716
|
try {
|
|
707
717
|
return this.renderFn.length >= 2;
|
|
@@ -905,6 +915,10 @@
|
|
|
905
915
|
return oi === undefined ? -1 : oi;
|
|
906
916
|
});
|
|
907
917
|
const stable = new Set(longestIncreasingIndices(sources));
|
|
918
|
+
if (newComponents.length === items.length && isPermutation(sources, newComponents, this.container)) {
|
|
919
|
+
controls._reorder(newComponents, stable);
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
908
922
|
let anchor = null;
|
|
909
923
|
for (let i = newComponents.length - 1; i >= 0; i--) {
|
|
910
924
|
const comp = newComponents[i];
|
|
@@ -927,6 +941,19 @@
|
|
|
927
941
|
}
|
|
928
942
|
}
|
|
929
943
|
}
|
|
944
|
+
function isPermutation(sources, components, owner) {
|
|
945
|
+
const seen = new Uint8Array(sources.length);
|
|
946
|
+
for (let i = 0; i < sources.length; i++) {
|
|
947
|
+
const s = sources[i];
|
|
948
|
+
if (s === -1 || seen[s])
|
|
949
|
+
return false;
|
|
950
|
+
seen[s] = 1;
|
|
951
|
+
const c = components[i];
|
|
952
|
+
if (c.isDisposed || c.parent !== owner)
|
|
953
|
+
return false;
|
|
954
|
+
}
|
|
955
|
+
return true;
|
|
956
|
+
}
|
|
930
957
|
function longestIncreasingIndices(sources) {
|
|
931
958
|
const predecessors = new Array(sources.length).fill(-1);
|
|
932
959
|
const tails = [];
|
|
@@ -962,16 +989,13 @@
|
|
|
962
989
|
}
|
|
963
990
|
|
|
964
991
|
class NameValuePair {
|
|
965
|
-
Key;
|
|
966
|
-
value;
|
|
967
992
|
}
|
|
968
993
|
|
|
969
994
|
class List {
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
_map = new Set();
|
|
995
|
+
constructor() {
|
|
996
|
+
this.__list = [];
|
|
997
|
+
this._map = new Set();
|
|
998
|
+
}
|
|
975
999
|
Dispose() {
|
|
976
1000
|
this.__list = [];
|
|
977
1001
|
}
|
|
@@ -1105,13 +1129,11 @@
|
|
|
1105
1129
|
}
|
|
1106
1130
|
|
|
1107
1131
|
class LeakMonitor {
|
|
1108
|
-
threshold;
|
|
1109
|
-
name;
|
|
1110
|
-
_origins = new Map();
|
|
1111
|
-
_quietChecks = 0;
|
|
1112
1132
|
constructor(threshold, name) {
|
|
1113
1133
|
this.threshold = threshold;
|
|
1114
1134
|
this.name = name;
|
|
1135
|
+
this._origins = new Map();
|
|
1136
|
+
this._quietChecks = 0;
|
|
1115
1137
|
}
|
|
1116
1138
|
check(size) {
|
|
1117
1139
|
if (this.threshold <= 0 || size < this.threshold) {
|
|
@@ -1141,7 +1163,9 @@
|
|
|
1141
1163
|
}
|
|
1142
1164
|
|
|
1143
1165
|
class Dictionary {
|
|
1144
|
-
|
|
1166
|
+
constructor() {
|
|
1167
|
+
this.__values = new List();
|
|
1168
|
+
}
|
|
1145
1169
|
Add(Key, Value) {
|
|
1146
1170
|
var item = new NameValuePair();
|
|
1147
1171
|
item.Key = Key;
|
|
@@ -1158,7 +1182,6 @@
|
|
|
1158
1182
|
item(key) {
|
|
1159
1183
|
return this.filter(t => t.Key == key)[0];
|
|
1160
1184
|
}
|
|
1161
|
-
OnItemAdded;
|
|
1162
1185
|
removeIndex(index) {
|
|
1163
1186
|
return this.__values.removeIndex(index);
|
|
1164
1187
|
}
|
|
@@ -1195,8 +1218,10 @@
|
|
|
1195
1218
|
return ring;
|
|
1196
1219
|
}
|
|
1197
1220
|
class LinkedList {
|
|
1198
|
-
|
|
1199
|
-
|
|
1221
|
+
constructor() {
|
|
1222
|
+
this._ring = createRing();
|
|
1223
|
+
this._count = 0;
|
|
1224
|
+
}
|
|
1200
1225
|
get size() {
|
|
1201
1226
|
return this._count;
|
|
1202
1227
|
}
|
|
@@ -1265,7 +1290,6 @@
|
|
|
1265
1290
|
return a > b ? 1 : a < b ? -1 : 0;
|
|
1266
1291
|
}
|
|
1267
1292
|
class Query {
|
|
1268
|
-
source;
|
|
1269
1293
|
constructor(source) {
|
|
1270
1294
|
this.source = Array.isArray(source) ? source : Array.from(source);
|
|
1271
1295
|
}
|
|
@@ -1334,11 +1358,12 @@
|
|
|
1334
1358
|
}
|
|
1335
1359
|
}
|
|
1336
1360
|
|
|
1337
|
-
const COMPILER_CONTRACT =
|
|
1361
|
+
const COMPILER_CONTRACT = 2;
|
|
1362
|
+
const SUPPORTED_CONTRACTS = [1, 2];
|
|
1338
1363
|
const reported = new Set();
|
|
1339
1364
|
const pending = new Set();
|
|
1340
1365
|
function motifCompiled(contract) {
|
|
1341
|
-
if (contract
|
|
1366
|
+
if (SUPPORTED_CONTRACTS.includes(contract) || reported.has(contract))
|
|
1342
1367
|
return;
|
|
1343
1368
|
if (!isDevLike()) {
|
|
1344
1369
|
pending.add(contract);
|
|
@@ -1373,15 +1398,12 @@
|
|
|
1373
1398
|
})(exports.NodeTypes || (exports.NodeTypes = {}));
|
|
1374
1399
|
|
|
1375
1400
|
class Effect {
|
|
1376
|
-
fn;
|
|
1377
|
-
callback;
|
|
1378
|
-
deps = [];
|
|
1379
|
-
active = true;
|
|
1380
|
-
running = false;
|
|
1381
|
-
scheduler;
|
|
1382
1401
|
constructor(fn, callback) {
|
|
1383
1402
|
this.fn = fn;
|
|
1384
1403
|
this.callback = callback;
|
|
1404
|
+
this.deps = [];
|
|
1405
|
+
this.active = true;
|
|
1406
|
+
this.running = false;
|
|
1385
1407
|
}
|
|
1386
1408
|
run() {
|
|
1387
1409
|
let value;
|
|
@@ -1620,21 +1642,10 @@
|
|
|
1620
1642
|
return el.value;
|
|
1621
1643
|
}
|
|
1622
1644
|
class Binding {
|
|
1623
|
-
propertyName;
|
|
1624
|
-
dataSource;
|
|
1625
|
-
dataMember;
|
|
1626
|
-
formatString;
|
|
1627
|
-
converter;
|
|
1628
|
-
converterBack;
|
|
1629
|
-
setter;
|
|
1630
|
-
formatInfo;
|
|
1631
|
-
updateMode = 'onPropertyChanged';
|
|
1632
|
-
_isActive = false;
|
|
1633
|
-
_component;
|
|
1634
|
-
_effectCleanup;
|
|
1635
|
-
_memberPath = null;
|
|
1636
|
-
_memberPathSource;
|
|
1637
1645
|
constructor(component, propertyName, dataSource, dataMember, formatString, formatInfo) {
|
|
1646
|
+
this.updateMode = 'onPropertyChanged';
|
|
1647
|
+
this._isActive = false;
|
|
1648
|
+
this._memberPath = null;
|
|
1638
1649
|
this._component = component;
|
|
1639
1650
|
this.propertyName = propertyName;
|
|
1640
1651
|
this.dataSource = dataSource;
|
|
@@ -1886,10 +1897,9 @@
|
|
|
1886
1897
|
return true;
|
|
1887
1898
|
}
|
|
1888
1899
|
class BindingCollection {
|
|
1889
|
-
_items = [];
|
|
1890
|
-
_component;
|
|
1891
|
-
_branchScope = null;
|
|
1892
1900
|
constructor(component) {
|
|
1901
|
+
this._items = [];
|
|
1902
|
+
this._branchScope = null;
|
|
1893
1903
|
this._component = component;
|
|
1894
1904
|
}
|
|
1895
1905
|
_own(stop) {
|
|
@@ -2158,6 +2168,38 @@
|
|
|
2158
2168
|
const [dataSource, dataMember, formatString, formatInfo] = args;
|
|
2159
2169
|
binding = new Binding(this._component, propertyName, dataSource, dataMember, formatString, formatInfo);
|
|
2160
2170
|
}
|
|
2171
|
+
const write = (raw) => {
|
|
2172
|
+
let value = raw;
|
|
2173
|
+
const b = binding;
|
|
2174
|
+
if (typeof b.converterBack === 'function') {
|
|
2175
|
+
value = b.converterBack(value);
|
|
2176
|
+
}
|
|
2177
|
+
if (typeof b.setter === 'function') {
|
|
2178
|
+
b.setter(value);
|
|
2179
|
+
return;
|
|
2180
|
+
}
|
|
2181
|
+
const member = b.dataMember;
|
|
2182
|
+
const source = b.dataSource;
|
|
2183
|
+
if (member && source != null) {
|
|
2184
|
+
const path = member.split('.');
|
|
2185
|
+
let target = source;
|
|
2186
|
+
for (let i = 0; i < path.length && target != null; i++) {
|
|
2187
|
+
const key = path[i];
|
|
2188
|
+
if (!isWritablePathKey(target, key))
|
|
2189
|
+
return;
|
|
2190
|
+
if (i === path.length - 1) {
|
|
2191
|
+
target[key] = value;
|
|
2192
|
+
}
|
|
2193
|
+
else {
|
|
2194
|
+
target = target[key];
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
else if (source != null && typeof source === 'object' && 'value' in source) {
|
|
2199
|
+
source.value = value;
|
|
2200
|
+
}
|
|
2201
|
+
};
|
|
2202
|
+
(this._modelWriters ??= new WeakMap()).set(binding, write);
|
|
2161
2203
|
const lowerTag = tn.toLowerCase();
|
|
2162
2204
|
if (lowerTag === 'input' || lowerTag === 'select' || lowerTag === 'textarea') {
|
|
2163
2205
|
const writeBack = () => {
|
|
@@ -2165,35 +2207,7 @@
|
|
|
2165
2207
|
const el = this._component.element;
|
|
2166
2208
|
if (!el)
|
|
2167
2209
|
return;
|
|
2168
|
-
|
|
2169
|
-
const b = binding;
|
|
2170
|
-
if (typeof b.converterBack === 'function') {
|
|
2171
|
-
value = b.converterBack(value);
|
|
2172
|
-
}
|
|
2173
|
-
if (typeof b.setter === 'function') {
|
|
2174
|
-
b.setter(value);
|
|
2175
|
-
return;
|
|
2176
|
-
}
|
|
2177
|
-
const member = b.dataMember;
|
|
2178
|
-
const source = b.dataSource;
|
|
2179
|
-
if (member && source != null) {
|
|
2180
|
-
const path = member.split('.');
|
|
2181
|
-
let target = source;
|
|
2182
|
-
for (let i = 0; i < path.length && target != null; i++) {
|
|
2183
|
-
const key = path[i];
|
|
2184
|
-
if (!isWritablePathKey(target, key))
|
|
2185
|
-
return;
|
|
2186
|
-
if (i === path.length - 1) {
|
|
2187
|
-
target[key] = value;
|
|
2188
|
-
}
|
|
2189
|
-
else {
|
|
2190
|
-
target = target[key];
|
|
2191
|
-
}
|
|
2192
|
-
}
|
|
2193
|
-
}
|
|
2194
|
-
else if (source != null && typeof source === 'object' && 'value' in source) {
|
|
2195
|
-
source.value = value;
|
|
2196
|
-
}
|
|
2210
|
+
write(readModelValue(el));
|
|
2197
2211
|
}
|
|
2198
2212
|
catch { /* ignore */ }
|
|
2199
2213
|
};
|
|
@@ -2206,6 +2220,23 @@
|
|
|
2206
2220
|
}
|
|
2207
2221
|
return binding;
|
|
2208
2222
|
}
|
|
2223
|
+
writeModel(value) {
|
|
2224
|
+
const writers = this._modelWriters;
|
|
2225
|
+
if (!writers)
|
|
2226
|
+
return false;
|
|
2227
|
+
let written = false;
|
|
2228
|
+
for (const binding of this._items) {
|
|
2229
|
+
const write = writers.get(binding);
|
|
2230
|
+
if (!write)
|
|
2231
|
+
continue;
|
|
2232
|
+
try {
|
|
2233
|
+
write(value);
|
|
2234
|
+
written = true;
|
|
2235
|
+
}
|
|
2236
|
+
catch { /* ignore */ }
|
|
2237
|
+
}
|
|
2238
|
+
return written;
|
|
2239
|
+
}
|
|
2209
2240
|
deactivateAll() {
|
|
2210
2241
|
this._items.forEach(binding => binding.deactivate());
|
|
2211
2242
|
this._items = [];
|
|
@@ -2265,10 +2296,10 @@
|
|
|
2265
2296
|
]);
|
|
2266
2297
|
|
|
2267
2298
|
class Emitter {
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2299
|
+
constructor() {
|
|
2300
|
+
this._subscriptions = [];
|
|
2301
|
+
this._disposed = false;
|
|
2302
|
+
}
|
|
2272
2303
|
get event() {
|
|
2273
2304
|
if (!this._subscribe) {
|
|
2274
2305
|
this._subscribe = (listener, thisArgs, disposables) => {
|
|
@@ -2352,10 +2383,6 @@
|
|
|
2352
2383
|
}
|
|
2353
2384
|
|
|
2354
2385
|
class ComponentEmiter {
|
|
2355
|
-
component;
|
|
2356
|
-
_emitters;
|
|
2357
|
-
_sourceDisposables;
|
|
2358
|
-
_listenerDisposables;
|
|
2359
2386
|
constructor(component) {
|
|
2360
2387
|
this.component = component;
|
|
2361
2388
|
}
|
|
@@ -2506,9 +2533,6 @@
|
|
|
2506
2533
|
const ARGUMENT_METHODS = new Set(['setSelectionRange', 'setRangeText', 'setPointerCapture', 'releasePointerCapture', 'fastSeek']);
|
|
2507
2534
|
const PROPERTY_FIRST = new Set(['checked', 'selected', 'muted', 'indeterminate', 'srcObject']);
|
|
2508
2535
|
class controlAttribute {
|
|
2509
|
-
_parent;
|
|
2510
|
-
_attrMapStore;
|
|
2511
|
-
_watchersStore;
|
|
2512
2536
|
constructor(parent) {
|
|
2513
2537
|
this._parent = parent;
|
|
2514
2538
|
}
|
|
@@ -3040,14 +3064,10 @@
|
|
|
3040
3064
|
}
|
|
3041
3065
|
|
|
3042
3066
|
class controlClass {
|
|
3043
|
-
_parent;
|
|
3044
3067
|
constructor(parent) {
|
|
3068
|
+
this._watcherSeq = 0;
|
|
3045
3069
|
this._parent = parent;
|
|
3046
3070
|
}
|
|
3047
|
-
_countsStore;
|
|
3048
|
-
_staticSetStore;
|
|
3049
|
-
_watchersStore;
|
|
3050
|
-
_watcherSeq = 0;
|
|
3051
3071
|
get _counts() { return this._countsStore ??= new Map(); }
|
|
3052
3072
|
get _staticSet() { return this._staticSetStore ??= new Set(); }
|
|
3053
3073
|
get _watchers() { return this._watchersStore ??= new Map(); }
|
|
@@ -3063,13 +3083,7 @@
|
|
|
3063
3083
|
this._addStaticFromObject(value);
|
|
3064
3084
|
}
|
|
3065
3085
|
else {
|
|
3066
|
-
|
|
3067
|
-
if (valueStr.split(' ').length > 1) {
|
|
3068
|
-
this._addStaticFromArray(valueStr.split(' '));
|
|
3069
|
-
}
|
|
3070
|
-
else {
|
|
3071
|
-
this._addStaticFromString(valueStr);
|
|
3072
|
-
}
|
|
3086
|
+
this._addStaticNames(this._splitClasses(String(value ?? '')));
|
|
3073
3087
|
}
|
|
3074
3088
|
}
|
|
3075
3089
|
return this._parent;
|
|
@@ -3135,10 +3149,11 @@
|
|
|
3135
3149
|
return null;
|
|
3136
3150
|
}
|
|
3137
3151
|
_splitClasses(input) {
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3152
|
+
if (!input)
|
|
3153
|
+
return [];
|
|
3154
|
+
if (!/\s/.test(input))
|
|
3155
|
+
return [input];
|
|
3156
|
+
return input.split(/\s+/).filter(s => s.length > 0);
|
|
3142
3157
|
}
|
|
3143
3158
|
_normalizeToSet(values, key) {
|
|
3144
3159
|
const result = new Set();
|
|
@@ -3237,14 +3252,31 @@
|
|
|
3237
3252
|
}
|
|
3238
3253
|
}
|
|
3239
3254
|
}
|
|
3240
|
-
|
|
3241
|
-
if (
|
|
3255
|
+
_addStaticNames(names) {
|
|
3256
|
+
if (names.length === 0)
|
|
3242
3257
|
return;
|
|
3243
3258
|
const el = this._getElement();
|
|
3244
|
-
const
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3259
|
+
const staticSet = this._staticSet;
|
|
3260
|
+
const fresh = el && !el.hasAttribute('class') ? [] : null;
|
|
3261
|
+
for (const cls of names) {
|
|
3262
|
+
if (staticSet.has(cls))
|
|
3263
|
+
continue;
|
|
3264
|
+
staticSet.add(cls);
|
|
3265
|
+
const prevCount = this._counts.get(cls) || 0;
|
|
3266
|
+
this._counts.set(cls, prevCount + 1);
|
|
3267
|
+
if (prevCount === 0 && el) {
|
|
3268
|
+
if (fresh)
|
|
3269
|
+
fresh.push(cls);
|
|
3270
|
+
else {
|
|
3271
|
+
try {
|
|
3272
|
+
el.classList.add(cls);
|
|
3273
|
+
}
|
|
3274
|
+
catch { }
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
}
|
|
3278
|
+
if (fresh && fresh.length > 0)
|
|
3279
|
+
el.setAttribute('class', fresh.join(' '));
|
|
3248
3280
|
}
|
|
3249
3281
|
_addStaticFromArray(arr) {
|
|
3250
3282
|
const el = this._getElement();
|
|
@@ -3565,8 +3597,6 @@
|
|
|
3565
3597
|
}
|
|
3566
3598
|
|
|
3567
3599
|
class ComponentMotif {
|
|
3568
|
-
_component;
|
|
3569
|
-
options;
|
|
3570
3600
|
constructor(component, options) {
|
|
3571
3601
|
this._component = component;
|
|
3572
3602
|
this.options = options;
|
|
@@ -3609,15 +3639,11 @@
|
|
|
3609
3639
|
const SIGNAL_TARGET = Symbol('SignalTarget');
|
|
3610
3640
|
const SIGNAL_KEY = Symbol('SignalKey');
|
|
3611
3641
|
class Signal {
|
|
3612
|
-
_value;
|
|
3613
|
-
_target;
|
|
3614
|
-
_key;
|
|
3615
|
-
_equals;
|
|
3616
|
-
_disposed = false;
|
|
3617
3642
|
static create(initialValue, equals) {
|
|
3618
3643
|
return new Signal(initialValue, equals);
|
|
3619
3644
|
}
|
|
3620
3645
|
constructor(initialValue, equals = Object.is) {
|
|
3646
|
+
this._disposed = false;
|
|
3621
3647
|
this._value = initialValue;
|
|
3622
3648
|
this._target = { [SIGNAL_TARGET]: true };
|
|
3623
3649
|
this._key = SIGNAL_KEY;
|
|
@@ -3674,14 +3700,9 @@
|
|
|
3674
3700
|
}
|
|
3675
3701
|
}
|
|
3676
3702
|
class Computed {
|
|
3677
|
-
_value;
|
|
3678
|
-
_dirty = true;
|
|
3679
|
-
_computing = false;
|
|
3680
|
-
_target;
|
|
3681
|
-
_key;
|
|
3682
|
-
_getter;
|
|
3683
|
-
_cleanup;
|
|
3684
3703
|
constructor(getter) {
|
|
3704
|
+
this._dirty = true;
|
|
3705
|
+
this._computing = false;
|
|
3685
3706
|
this._getter = getter;
|
|
3686
3707
|
this._target = { [SIGNAL_TARGET]: true };
|
|
3687
3708
|
this._key = SIGNAL_KEY;
|
|
@@ -3746,14 +3767,9 @@
|
|
|
3746
3767
|
}
|
|
3747
3768
|
}
|
|
3748
3769
|
class LazyComputed {
|
|
3749
|
-
_value;
|
|
3750
|
-
_dirty = true;
|
|
3751
|
-
_disposed = false;
|
|
3752
|
-
_target;
|
|
3753
|
-
_key;
|
|
3754
|
-
_getter;
|
|
3755
|
-
_runner;
|
|
3756
3770
|
constructor(getter) {
|
|
3771
|
+
this._dirty = true;
|
|
3772
|
+
this._disposed = false;
|
|
3757
3773
|
this._getter = getter;
|
|
3758
3774
|
this._target = { [SIGNAL_TARGET]: true };
|
|
3759
3775
|
this._key = SIGNAL_KEY;
|
|
@@ -3917,24 +3933,25 @@
|
|
|
3917
3933
|
pins.set(owner, { scope: pinnedScopeOf(owner) ?? navigatingRoot._currentScope(), live: false });
|
|
3918
3934
|
}
|
|
3919
3935
|
class ServiceProvider {
|
|
3920
|
-
services;
|
|
3921
|
-
parent;
|
|
3922
|
-
root;
|
|
3923
|
-
scopeName;
|
|
3924
|
-
kind;
|
|
3925
|
-
singletonCache;
|
|
3926
|
-
scopedCache = new Map();
|
|
3927
|
-
transientSet = new Set();
|
|
3928
|
-
_autoDisposeTransients = false;
|
|
3929
|
-
pendingSingleton;
|
|
3930
|
-
pendingScoped = new Map();
|
|
3931
|
-
_navigation;
|
|
3932
|
-
_ownerlessSlot = { owner: null, ownerless: true };
|
|
3933
|
-
_navigationDisposed = false;
|
|
3934
|
-
_livePins = 0;
|
|
3935
|
-
_pending = false;
|
|
3936
3936
|
constructor(services, parent, root) {
|
|
3937
3937
|
this.services = services;
|
|
3938
|
+
this.scopedCache = new Map();
|
|
3939
|
+
this.transientSet = new Set();
|
|
3940
|
+
this._autoDisposeTransients = false;
|
|
3941
|
+
this.pendingScoped = new Map();
|
|
3942
|
+
this._ownerlessSlot = { owner: null, ownerless: true };
|
|
3943
|
+
this._navigationDisposed = false;
|
|
3944
|
+
this._livePins = 0;
|
|
3945
|
+
this._pending = false;
|
|
3946
|
+
this.describeToken = (t) => {
|
|
3947
|
+
if (typeof t === 'string')
|
|
3948
|
+
return t;
|
|
3949
|
+
if (typeof t === 'symbol')
|
|
3950
|
+
return t.toString();
|
|
3951
|
+
if (typeof t === 'function')
|
|
3952
|
+
return t.name || '[AnonymousClass]';
|
|
3953
|
+
return String(t);
|
|
3954
|
+
};
|
|
3938
3955
|
this.parent = parent;
|
|
3939
3956
|
this.root = root ?? this;
|
|
3940
3957
|
this.kind = this.root === this ? 'root' : 'user';
|
|
@@ -4318,15 +4335,6 @@
|
|
|
4318
4335
|
throw motifError('MJX404', chain);
|
|
4319
4336
|
}
|
|
4320
4337
|
}
|
|
4321
|
-
describeToken = (t) => {
|
|
4322
|
-
if (typeof t === 'string')
|
|
4323
|
-
return t;
|
|
4324
|
-
if (typeof t === 'symbol')
|
|
4325
|
-
return t.toString();
|
|
4326
|
-
if (typeof t === 'function')
|
|
4327
|
-
return t.name || '[AnonymousClass]';
|
|
4328
|
-
return String(t);
|
|
4329
|
-
};
|
|
4330
4338
|
describeTokenWithSource(t) {
|
|
4331
4339
|
const name = this.describeToken(t);
|
|
4332
4340
|
const d = this.services.getDescriptor(t);
|
|
@@ -4433,8 +4441,22 @@
|
|
|
4433
4441
|
return t.name || '[AnonymousClass]';
|
|
4434
4442
|
return String(t);
|
|
4435
4443
|
}
|
|
4444
|
+
const F_BUILT = 1;
|
|
4445
|
+
const F_INITIALIZED = 2;
|
|
4446
|
+
const F_DISPOSED = 4;
|
|
4447
|
+
const F_CONFIGURED = 8;
|
|
4448
|
+
const F_PAINTING = 16;
|
|
4449
|
+
const F_PAINTED = 32;
|
|
4450
|
+
const F_HIDDEN = 64;
|
|
4451
|
+
const F_WAIT = 128;
|
|
4452
|
+
const F_POSTCONFIG = 256;
|
|
4453
|
+
const F_PREBOUND = 512;
|
|
4454
|
+
const F_DISPOSED_FIRED = 1024;
|
|
4455
|
+
function optionsOf(c) {
|
|
4456
|
+
return c?._motif?.options;
|
|
4457
|
+
}
|
|
4436
4458
|
function peekTransition(c) {
|
|
4437
|
-
return c?.
|
|
4459
|
+
return c?._motif?.options?.[TRANSITION_SLOT];
|
|
4438
4460
|
}
|
|
4439
4461
|
/**WAAPI keyframe (transitionIn) YA DA CSS class transition (name/classes) tanımlı olarak enter animasyonu varmı */
|
|
4440
4462
|
function clearNavDirection(c) {
|
|
@@ -4456,15 +4478,15 @@
|
|
|
4456
4478
|
const node = c.element;
|
|
4457
4479
|
if (!node || node.nodeType !== Node.COMMENT_NODE)
|
|
4458
4480
|
break;
|
|
4459
|
-
c = c.parent ?? c.
|
|
4481
|
+
c = c.parent ?? c._leaveContainer;
|
|
4460
4482
|
}
|
|
4461
4483
|
return transitionSettings.mode;
|
|
4462
4484
|
}
|
|
4463
4485
|
function leaveModeOf(c) {
|
|
4464
|
-
return enterModeOf(c.parent ?? c.
|
|
4486
|
+
return enterModeOf(c.parent ?? c._leaveContainer);
|
|
4465
4487
|
}
|
|
4466
4488
|
function wantsEnterTransition(c) {
|
|
4467
|
-
const o = c?.
|
|
4489
|
+
const o = c?._motif?.options;
|
|
4468
4490
|
const t = o?.[TRANSITION_SLOT];
|
|
4469
4491
|
return !!(o?.transitionIn || (t && (t.classes || (t.name && t.name.length > 0))));
|
|
4470
4492
|
}
|
|
@@ -4619,8 +4641,6 @@
|
|
|
4619
4641
|
return t;
|
|
4620
4642
|
}
|
|
4621
4643
|
class ComponentOptionsImpl {
|
|
4622
|
-
[OPTIONS_OWNER];
|
|
4623
|
-
[TRANSITION_SLOT];
|
|
4624
4644
|
constructor(owner) {
|
|
4625
4645
|
this[OPTIONS_OWNER] = owner;
|
|
4626
4646
|
}
|
|
@@ -4660,24 +4680,44 @@
|
|
|
4660
4680
|
}
|
|
4661
4681
|
}
|
|
4662
4682
|
hasEvent(name) {
|
|
4663
|
-
return
|
|
4683
|
+
return hasEventKey(this[OPTIONS_OWNER], name);
|
|
4664
4684
|
}
|
|
4665
4685
|
}
|
|
4666
4686
|
lazyBindMethods(ComponentOptionsImpl.prototype, ['getInstance', 'hasEvent']);
|
|
4667
4687
|
function fireLifecycle(component, name, ev) {
|
|
4668
|
-
const base = component.
|
|
4688
|
+
const base = component._baseCtx;
|
|
4669
4689
|
if (base)
|
|
4670
|
-
base.
|
|
4690
|
+
base._emiters?.fire(name, ev);
|
|
4691
|
+
}
|
|
4692
|
+
function runHooks(base, listName, sender, ev, label) {
|
|
4693
|
+
if (!base)
|
|
4694
|
+
return;
|
|
4695
|
+
let slot = base[listName];
|
|
4696
|
+
if (!slot)
|
|
4697
|
+
return;
|
|
4698
|
+
let from = 0;
|
|
4699
|
+
if (typeof slot === 'function') {
|
|
4700
|
+
const fn = slot;
|
|
4701
|
+
callReported(() => fn(sender, ev), 'MJX122', label);
|
|
4702
|
+
slot = base[listName];
|
|
4703
|
+
if (!Array.isArray(slot))
|
|
4704
|
+
return;
|
|
4705
|
+
from = 1;
|
|
4706
|
+
}
|
|
4707
|
+
for (let i = from; i < slot.length; i++) {
|
|
4708
|
+
const fn = slot[i];
|
|
4709
|
+
callReported(() => fn(sender, ev), 'MJX122', label);
|
|
4710
|
+
}
|
|
4671
4711
|
}
|
|
4672
4712
|
function hasLifecycleHook(component, hook, listName, lowerName, legacyProp) {
|
|
4673
4713
|
if (component[hook])
|
|
4674
4714
|
return true;
|
|
4675
|
-
const
|
|
4676
|
-
if (
|
|
4715
|
+
const base = component._baseCtx;
|
|
4716
|
+
if (base?.[listName])
|
|
4677
4717
|
return true;
|
|
4678
4718
|
if (legacyProp && component[legacyProp])
|
|
4679
4719
|
return true;
|
|
4680
|
-
return
|
|
4720
|
+
return !!base?._emiters?.hasListeners(lowerName);
|
|
4681
4721
|
}
|
|
4682
4722
|
const RESERVED_METHODS = ['build', 'setState', 'reState', 'setText', 'style', 'dispose', 'disposeAsync', 'using', 'doWork', 'getService', '$', 'useModel', 'context', 'siblings', 'serviceProvider', 'isWait'];
|
|
4683
4723
|
const checkedComponentClasses = new WeakSet();
|
|
@@ -4746,21 +4786,17 @@
|
|
|
4746
4786
|
callReported(() => component.initializeComponent(sender, ev), 'MJX122', 'initializeComponent');
|
|
4747
4787
|
}
|
|
4748
4788
|
// 2) aggregated extra initializeComponent handlers (örn, from props)
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
}
|
|
4789
|
+
const compiled = component._init;
|
|
4790
|
+
if (compiled) {
|
|
4791
|
+
callReported(() => compiled(sender, ev), 'MJX122', 'initializeComponent');
|
|
4753
4792
|
}
|
|
4793
|
+
runHooks(component._baseCtx, '_initializeComponentHandlers', sender, ev, 'initializeComponent');
|
|
4754
4794
|
// 3) class method oninitializeComponent
|
|
4755
4795
|
if (typeof component.oninitializeComponent === 'function') {
|
|
4756
4796
|
callReported(() => component.oninitializeComponent(sender, ev), 'MJX122', 'oninitializeComponent');
|
|
4757
4797
|
}
|
|
4758
4798
|
// 4) aggregated extra oninitializeComponent handlers (örn, from props)
|
|
4759
|
-
|
|
4760
|
-
for (const fn of component._base._onInitializeComponentHandlers) {
|
|
4761
|
-
callReported(() => fn(sender, ev), 'MJX122', 'oninitializeComponent');
|
|
4762
|
-
}
|
|
4763
|
-
}
|
|
4799
|
+
runHooks(component._baseCtx, '_onInitializeComponentHandlers', sender, ev, 'oninitializeComponent');
|
|
4764
4800
|
},
|
|
4765
4801
|
callDisposing(component) {
|
|
4766
4802
|
if (!component || component.isDisposed) {
|
|
@@ -4773,11 +4809,7 @@
|
|
|
4773
4809
|
if (component.onDisposing) {
|
|
4774
4810
|
callReported(() => component.onDisposing(sender, ev), 'MJX122', 'onDisposing');
|
|
4775
4811
|
}
|
|
4776
|
-
|
|
4777
|
-
for (const fn of component._base._onDisposingHandlers) {
|
|
4778
|
-
callReported(() => fn(sender, ev), 'MJX122', 'onDisposing');
|
|
4779
|
-
}
|
|
4780
|
-
}
|
|
4812
|
+
runHooks(component._baseCtx, '_onDisposingHandlers', sender, ev, 'onDisposing');
|
|
4781
4813
|
if (component.ondisposing) {
|
|
4782
4814
|
callReported(() => component.ondisposing(sender, ev), 'MJX122', 'ondisposing');
|
|
4783
4815
|
}
|
|
@@ -4791,11 +4823,7 @@
|
|
|
4791
4823
|
if (component.onActivated) {
|
|
4792
4824
|
callReported(() => component.onActivated(sender, ev), 'MJX122', 'onActivated');
|
|
4793
4825
|
}
|
|
4794
|
-
|
|
4795
|
-
for (const fn of component._base._onActivatedHandlers) {
|
|
4796
|
-
callReported(() => fn(sender, ev), 'MJX122', 'onActivated');
|
|
4797
|
-
}
|
|
4798
|
-
}
|
|
4826
|
+
runHooks(component._baseCtx, '_onActivatedHandlers', sender, ev, 'onActivated');
|
|
4799
4827
|
fireLifecycle(component, 'onactivated', ev);
|
|
4800
4828
|
},
|
|
4801
4829
|
callDeactivated(component) {
|
|
@@ -4806,11 +4834,7 @@
|
|
|
4806
4834
|
if (component.onDeactivated) {
|
|
4807
4835
|
callReported(() => component.onDeactivated(sender, ev), 'MJX122', 'onDeactivated');
|
|
4808
4836
|
}
|
|
4809
|
-
|
|
4810
|
-
for (const fn of component._base._onDeactivatedHandlers) {
|
|
4811
|
-
callReported(() => fn(sender, ev), 'MJX122', 'onDeactivated');
|
|
4812
|
-
}
|
|
4813
|
-
}
|
|
4837
|
+
runHooks(component._baseCtx, '_onDeactivatedHandlers', sender, ev, 'onDeactivated');
|
|
4814
4838
|
fireLifecycle(component, 'ondeactivated', ev);
|
|
4815
4839
|
},
|
|
4816
4840
|
deactivateTree(component, deep = true) {
|
|
@@ -4822,7 +4846,7 @@
|
|
|
4822
4846
|
if (!deep || component.isDisposed) {
|
|
4823
4847
|
return;
|
|
4824
4848
|
}
|
|
4825
|
-
for (const c of component.
|
|
4849
|
+
for (const c of childrenOf(component).slice()) {
|
|
4826
4850
|
if (c && !c.isDisposed && c.isVisible && !c.isWait) {
|
|
4827
4851
|
ComponentHelper.deactivateTree(c, true);
|
|
4828
4852
|
}
|
|
@@ -4837,27 +4861,26 @@
|
|
|
4837
4861
|
if (!deep || component.isDisposed) {
|
|
4838
4862
|
return;
|
|
4839
4863
|
}
|
|
4840
|
-
for (const c of component.
|
|
4864
|
+
for (const c of childrenOf(component).slice()) {
|
|
4841
4865
|
if (c && !c.isDisposed && c.isVisible && !c.isWait) {
|
|
4842
4866
|
ComponentHelper.activateTree(c, true);
|
|
4843
4867
|
}
|
|
4844
4868
|
}
|
|
4845
4869
|
},
|
|
4846
4870
|
callDisposed(component) {
|
|
4847
|
-
if (!component ||
|
|
4871
|
+
if (!component || (component._flags & F_DISPOSED_FIRED) !== 0) {
|
|
4848
4872
|
return;
|
|
4849
4873
|
}
|
|
4850
|
-
component.
|
|
4874
|
+
if (component.isDisposed && !component.element && component._baseCtx === undefined) {
|
|
4875
|
+
return;
|
|
4876
|
+
}
|
|
4877
|
+
component._flags |= F_DISPOSED_FIRED;
|
|
4851
4878
|
if (hasLifecycleHook(component, 'onDisposed', '_onDisposedHandlers', 'ondisposed', 'ondisposed')) {
|
|
4852
4879
|
const sender = component, ev = { cancel: false };
|
|
4853
4880
|
if (component.onDisposed) {
|
|
4854
4881
|
callReported(() => component.onDisposed(sender, ev), 'MJX122', 'onDisposed');
|
|
4855
4882
|
}
|
|
4856
|
-
|
|
4857
|
-
for (const fn of component._base._onDisposedHandlers) {
|
|
4858
|
-
callReported(() => fn(sender, ev), 'MJX122', 'onDisposed');
|
|
4859
|
-
}
|
|
4860
|
-
}
|
|
4883
|
+
runHooks(component._baseCtx, '_onDisposedHandlers', sender, ev, 'onDisposed');
|
|
4861
4884
|
if (component.ondisposed) {
|
|
4862
4885
|
callReported(() => component.ondisposed(sender, ev), 'MJX122', 'ondisposed');
|
|
4863
4886
|
}
|
|
@@ -4877,11 +4900,7 @@
|
|
|
4877
4900
|
if (component.onBuilt) {
|
|
4878
4901
|
callReported(() => component.onBuilt(sender, ev), 'MJX122', 'onBuilt');
|
|
4879
4902
|
}
|
|
4880
|
-
|
|
4881
|
-
for (const fn of component._base._onBuiltHandlers) {
|
|
4882
|
-
callReported(() => fn(sender, ev), 'MJX122', 'onBuilt');
|
|
4883
|
-
}
|
|
4884
|
-
}
|
|
4903
|
+
runHooks(component._baseCtx, '_onBuiltHandlers', sender, ev, 'onBuilt');
|
|
4885
4904
|
if (component.onbuilt) {
|
|
4886
4905
|
callReported(() => component.onbuilt(sender, ev), 'MJX122', 'onbuilt');
|
|
4887
4906
|
}
|
|
@@ -4893,11 +4912,11 @@
|
|
|
4893
4912
|
catch { }
|
|
4894
4913
|
},
|
|
4895
4914
|
scheduleMounted(component) {
|
|
4896
|
-
if (!component || component.isDisposed || component.
|
|
4915
|
+
if (!component || component.isDisposed || component._baseCtx?._mountedScheduled) {
|
|
4897
4916
|
return;
|
|
4898
4917
|
}
|
|
4899
4918
|
const hasHook = typeof component.onMounted === 'function'
|
|
4900
|
-
||
|
|
4919
|
+
|| !!component._baseCtx?._onMountedHandlers
|
|
4901
4920
|
|| typeof component.onmounted === 'function';
|
|
4902
4921
|
if (!hasHook) {
|
|
4903
4922
|
return;
|
|
@@ -4926,11 +4945,7 @@
|
|
|
4926
4945
|
if (component.onMounted) {
|
|
4927
4946
|
callReported(() => component.onMounted(sender, ev), 'MJX122', 'onMounted');
|
|
4928
4947
|
}
|
|
4929
|
-
|
|
4930
|
-
for (const fn of component._base._onMountedHandlers) {
|
|
4931
|
-
callReported(() => fn(sender, ev), 'MJX122', 'onMounted');
|
|
4932
|
-
}
|
|
4933
|
-
}
|
|
4948
|
+
runHooks(component._baseCtx, '_onMountedHandlers', sender, ev, 'onMounted');
|
|
4934
4949
|
if (component.onmounted) {
|
|
4935
4950
|
callReported(() => component.onmounted(sender, ev), 'MJX122', 'onmounted');
|
|
4936
4951
|
}
|
|
@@ -4947,11 +4962,7 @@
|
|
|
4947
4962
|
if (component.onBuilding) {
|
|
4948
4963
|
callReported(() => component.onBuilding(sender, ev), 'MJX122', 'onBuilding');
|
|
4949
4964
|
}
|
|
4950
|
-
|
|
4951
|
-
for (const fn of component._base._onBuildingHandlers) {
|
|
4952
|
-
callReported(() => fn(sender, ev), 'MJX122', 'onBuilding');
|
|
4953
|
-
}
|
|
4954
|
-
}
|
|
4965
|
+
runHooks(component._baseCtx, '_onBuildingHandlers', sender, ev, 'onBuilding');
|
|
4955
4966
|
fireLifecycle(component, 'onbuilding', ev);
|
|
4956
4967
|
},
|
|
4957
4968
|
callConfig(component) {
|
|
@@ -4959,8 +4970,9 @@
|
|
|
4959
4970
|
return;
|
|
4960
4971
|
}
|
|
4961
4972
|
component.isConfigured = true;
|
|
4962
|
-
|
|
4963
|
-
|
|
4973
|
+
const preconfig = component._motif?.options?._preconfig;
|
|
4974
|
+
if (preconfig) {
|
|
4975
|
+
safeCallSilent(() => preconfig(component), 'Component._preconfig');
|
|
4964
4976
|
}
|
|
4965
4977
|
if (!hasLifecycleHook(component, 'onConfig', '_onConfigHandlers', 'onconfig')) {
|
|
4966
4978
|
return;
|
|
@@ -4969,21 +4981,17 @@
|
|
|
4969
4981
|
if (component.onConfig) {
|
|
4970
4982
|
callReported(() => component.onConfig(sender, ev), 'MJX122', 'onConfig');
|
|
4971
4983
|
}
|
|
4972
|
-
|
|
4973
|
-
for (const fn of component._base._onConfigHandlers) {
|
|
4974
|
-
callReported(() => fn(sender, ev), 'MJX122', 'onConfig');
|
|
4975
|
-
}
|
|
4976
|
-
}
|
|
4984
|
+
runHooks(component._baseCtx, '_onConfigHandlers', sender, ev, 'onConfig');
|
|
4977
4985
|
fireLifecycle(component, 'onconfig', ev);
|
|
4978
4986
|
},
|
|
4979
4987
|
callConfigured(component) {
|
|
4980
|
-
if (component.
|
|
4988
|
+
if ((component._flags & F_POSTCONFIG) !== 0) {
|
|
4981
4989
|
return;
|
|
4982
4990
|
}
|
|
4983
|
-
if (component?.
|
|
4991
|
+
if (component?._baseCtx?._configDeferred && !component.isConfigured) {
|
|
4984
4992
|
ComponentHelper.callConfig(component);
|
|
4985
4993
|
}
|
|
4986
|
-
component.
|
|
4994
|
+
component._flags |= F_POSTCONFIG;
|
|
4987
4995
|
if (!component || component.isDisposed) {
|
|
4988
4996
|
return;
|
|
4989
4997
|
}
|
|
@@ -4994,11 +5002,7 @@
|
|
|
4994
5002
|
if (component.onConfigured) {
|
|
4995
5003
|
callReported(() => component.onConfigured(sender, ev), 'MJX122', 'onConfigured');
|
|
4996
5004
|
}
|
|
4997
|
-
|
|
4998
|
-
for (const fn of component._base._onConfiguredHandlers) {
|
|
4999
|
-
callReported(() => fn(sender, ev), 'MJX122', 'onConfigured');
|
|
5000
|
-
}
|
|
5001
|
-
}
|
|
5005
|
+
runHooks(component._baseCtx, '_onConfiguredHandlers', sender, ev, 'onConfigured');
|
|
5002
5006
|
fireLifecycle(component, 'onconfigured', ev);
|
|
5003
5007
|
},
|
|
5004
5008
|
callOnInitialized(component) {
|
|
@@ -5013,11 +5017,7 @@
|
|
|
5013
5017
|
if (component.onInitialized) {
|
|
5014
5018
|
callReported(() => component.onInitialized(sender, ev), 'MJX122', 'onInitialized');
|
|
5015
5019
|
}
|
|
5016
|
-
|
|
5017
|
-
for (const fn of component._base._onInitializedHandlers) {
|
|
5018
|
-
callReported(() => fn(sender, ev), 'MJX122', 'onInitialized');
|
|
5019
|
-
}
|
|
5020
|
-
}
|
|
5020
|
+
runHooks(component._baseCtx, '_onInitializedHandlers', sender, ev, 'onInitialized');
|
|
5021
5021
|
fireLifecycle(component, 'oninitialized', ev);
|
|
5022
5022
|
},
|
|
5023
5023
|
callOnInitializing(component) {
|
|
@@ -5031,29 +5031,21 @@
|
|
|
5031
5031
|
if (component.onInitializing) {
|
|
5032
5032
|
callReported(() => component.onInitializing(sender, ev), 'MJX122', 'onInitializing');
|
|
5033
5033
|
}
|
|
5034
|
-
|
|
5035
|
-
for (const fn of component._base._onInitializingHandlers) {
|
|
5036
|
-
callReported(() => fn(sender, ev), 'MJX122', 'onInitializing');
|
|
5037
|
-
}
|
|
5038
|
-
}
|
|
5034
|
+
runHooks(component._baseCtx, '_onInitializingHandlers', sender, ev, 'onInitializing');
|
|
5039
5035
|
fireLifecycle(component, 'oninitializing', ev);
|
|
5040
5036
|
},
|
|
5041
|
-
callVisibilityChanged(component) {
|
|
5037
|
+
callVisibilityChanged(component, visible) {
|
|
5042
5038
|
if (!component || component.isDisposed) {
|
|
5043
5039
|
return;
|
|
5044
5040
|
}
|
|
5045
5041
|
if (!hasLifecycleHook(component, 'onVisibilityChanged', '_onVisibilityChangedHandlers', 'onvisibilitychanged')) {
|
|
5046
5042
|
return;
|
|
5047
5043
|
}
|
|
5048
|
-
const sender = component, ev = { cancel: false };
|
|
5044
|
+
const sender = component, ev = { cancel: false, visible };
|
|
5049
5045
|
if (component.onVisibilityChanged) {
|
|
5050
5046
|
callReported(() => component.onVisibilityChanged(sender, ev), 'MJX122', 'onVisibilityChanged');
|
|
5051
5047
|
}
|
|
5052
|
-
|
|
5053
|
-
for (const fn of component._base._onVisibilityChangedHandlers) {
|
|
5054
|
-
callReported(() => fn(sender, ev), 'MJX122', 'onVisibilityChanged');
|
|
5055
|
-
}
|
|
5056
|
-
}
|
|
5048
|
+
runHooks(component._baseCtx, '_onVisibilityChangedHandlers', sender, ev, 'onVisibilityChanged');
|
|
5057
5049
|
fireLifecycle(component, 'onvisibilitychanged', ev);
|
|
5058
5050
|
},
|
|
5059
5051
|
findFragmentContent(c) {
|
|
@@ -5082,9 +5074,12 @@
|
|
|
5082
5074
|
ComponentHelper.callConfigured(c);
|
|
5083
5075
|
if (c.isDisposed)
|
|
5084
5076
|
return;
|
|
5085
|
-
c
|
|
5086
|
-
if (c.isWait)
|
|
5077
|
+
activatePreBindings(c);
|
|
5078
|
+
if (c.isWait) {
|
|
5079
|
+
if (this.isBuilt)
|
|
5080
|
+
placeTrace(this, c);
|
|
5087
5081
|
return;
|
|
5082
|
+
}
|
|
5088
5083
|
const cisBuilt = c.isBuilt;
|
|
5089
5084
|
if (!this.isBuilt) {
|
|
5090
5085
|
return;
|
|
@@ -5092,7 +5087,7 @@
|
|
|
5092
5087
|
if (c.isWait) {
|
|
5093
5088
|
return;
|
|
5094
5089
|
}
|
|
5095
|
-
const enterSeq = c.
|
|
5090
|
+
const enterSeq = c._baseCtx?._enterSeq;
|
|
5096
5091
|
if (!c.isBuilt) {
|
|
5097
5092
|
c.build();
|
|
5098
5093
|
}
|
|
@@ -5121,40 +5116,12 @@
|
|
|
5121
5116
|
if (cisBuilt && c.element.nodeType == Node.COMMENT_NODE && controlElement?.childNodes.length == 0 && c.controls.length > 0) {
|
|
5122
5117
|
controlElement = ComponentHelper.getContent.call(c);
|
|
5123
5118
|
}
|
|
5124
|
-
let referenceNode = null;
|
|
5125
5119
|
const insertHost = appendableElement?.element;
|
|
5126
|
-
const
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
const candidate = n.isVisible
|
|
5130
|
-
? n.element
|
|
5131
|
-
: (n.motif.options?.placeholder ?? null);
|
|
5132
|
-
if (!candidate)
|
|
5133
|
-
return null;
|
|
5134
|
-
return (insertHost && candidate.parentNode === insertHost) ? candidate : null;
|
|
5135
|
-
};
|
|
5136
|
-
const siblings = this.controls.items;
|
|
5137
|
-
for (let i = currentIndex + 1; i < siblings.length; i++) {
|
|
5138
|
-
const candidate = domReferenceOf(siblings[i]);
|
|
5139
|
-
if (candidate) {
|
|
5140
|
-
referenceNode = candidate;
|
|
5141
|
-
break;
|
|
5142
|
-
}
|
|
5143
|
-
}
|
|
5144
|
-
if (!referenceNode) {
|
|
5145
|
-
if (this.element.nodeType === Node.COMMENT_NODE) {
|
|
5146
|
-
const close = this.motif.options.closeFragment;
|
|
5147
|
-
referenceNode = (close && insertHost && close.parentNode === insertHost) ? close : null;
|
|
5148
|
-
}
|
|
5149
|
-
else {
|
|
5150
|
-
referenceNode = null;
|
|
5151
|
-
}
|
|
5152
|
-
}
|
|
5120
|
+
const trace = c.motif.options.placeholder;
|
|
5121
|
+
const ownTrace = c.isVisible && trace && insertHost && trace.parentNode === insertHost ? trace : null;
|
|
5122
|
+
const referenceNode = ownTrace ?? (insertHost ? followingAnchor(this, currentIndex + 1, insertHost) : null);
|
|
5153
5123
|
if (!c.isVisible) {
|
|
5154
|
-
|
|
5155
|
-
const isFromListOrKeyed = !!(c.motif.options?.__fromList || typeof c.motif.options?.indexkey !== 'undefined' || typeof c.motif.options?.__key !== 'undefined');
|
|
5156
|
-
const strategy = cfg === 'placeholder' ? 'placeholder' : (cfg === 'detach' ? 'detach' : (isFromListOrKeyed ? 'detach' : 'placeholder'));
|
|
5157
|
-
if (strategy === 'placeholder') {
|
|
5124
|
+
if (keepsTrace(c)) {
|
|
5158
5125
|
if (!c.motif.options.placeholder) {
|
|
5159
5126
|
c.motif.options.placeholder = dom.createComment("h");
|
|
5160
5127
|
}
|
|
@@ -5192,9 +5159,11 @@
|
|
|
5192
5159
|
else {
|
|
5193
5160
|
appendableElement?.element.appendChild(controlElement);
|
|
5194
5161
|
}
|
|
5162
|
+
if (ownTrace && ownTrace.parentNode)
|
|
5163
|
+
ownTrace.parentNode.removeChild(ownTrace);
|
|
5195
5164
|
}
|
|
5196
5165
|
if (c.isVisible) {
|
|
5197
|
-
const enteredInBuild = !cisBuilt && c.
|
|
5166
|
+
const enteredInBuild = !cisBuilt && c._baseCtx?._enterSeq !== enterSeq;
|
|
5198
5167
|
!enteredInBuild && wantsEnterTransition(c) && c.motif.options.transition.enterTransition(() => { });
|
|
5199
5168
|
if (cisBuilt) {
|
|
5200
5169
|
ComponentHelper.activateTree(c);
|
|
@@ -5208,7 +5177,11 @@
|
|
|
5208
5177
|
if (this.element.nodeType == Node.COMMENT_NODE) {
|
|
5209
5178
|
this.motif.options.cache?.appendChild(this.element);
|
|
5210
5179
|
this.controls.forEach(child => {
|
|
5211
|
-
|
|
5180
|
+
const node = child.isWait || !child.isVisible
|
|
5181
|
+
? (keepsTrace(child) ? (child.motif.options.placeholder ??= dom.createComment("h")) : undefined)
|
|
5182
|
+
: ComponentHelper.getContent.call(child);
|
|
5183
|
+
if (node)
|
|
5184
|
+
this.motif.options.cache?.appendChild(node);
|
|
5212
5185
|
});
|
|
5213
5186
|
this.motif.options.cache?.appendChild(this.motif.options.closeFragment);
|
|
5214
5187
|
return this.motif.options.cache;
|
|
@@ -5257,34 +5230,72 @@
|
|
|
5257
5230
|
}
|
|
5258
5231
|
}
|
|
5259
5232
|
};
|
|
5233
|
+
function keepsTrace(c) {
|
|
5234
|
+
return optionsOf(c)?.hideStrategy !== 'detach';
|
|
5235
|
+
}
|
|
5236
|
+
function domAnchor(c, host) {
|
|
5237
|
+
const trace = optionsOf(c)?.placeholder;
|
|
5238
|
+
if (trace && trace.parentNode === host)
|
|
5239
|
+
return trace;
|
|
5240
|
+
const node = c.element;
|
|
5241
|
+
return node && node.parentNode === host ? node : null;
|
|
5242
|
+
}
|
|
5243
|
+
function followingAnchor(owner, start, host) {
|
|
5244
|
+
const siblings = owner.controls.items;
|
|
5245
|
+
for (let i = start; i < siblings.length; i++) {
|
|
5246
|
+
const anchor = siblings[i] ? domAnchor(siblings[i], host) : null;
|
|
5247
|
+
if (anchor)
|
|
5248
|
+
return anchor;
|
|
5249
|
+
}
|
|
5250
|
+
if (owner.element.nodeType === Node.COMMENT_NODE) {
|
|
5251
|
+
const close = optionsOf(owner)?.closeFragment;
|
|
5252
|
+
return close && close.parentNode === host ? close : null;
|
|
5253
|
+
}
|
|
5254
|
+
return null;
|
|
5255
|
+
}
|
|
5256
|
+
function placeTrace(owner, c) {
|
|
5257
|
+
if (!keepsTrace(c))
|
|
5258
|
+
return;
|
|
5259
|
+
const host = findAppendableComponent(owner)?.element;
|
|
5260
|
+
if (!host)
|
|
5261
|
+
return;
|
|
5262
|
+
const element = c.element;
|
|
5263
|
+
if (element && element.parentNode === host)
|
|
5264
|
+
return;
|
|
5265
|
+
const opts = c.motif.options;
|
|
5266
|
+
const trace = opts.placeholder ?? (opts.placeholder = dom.createComment("h"));
|
|
5267
|
+
if (trace.parentNode === host)
|
|
5268
|
+
return;
|
|
5269
|
+
host.insertBefore(trace, followingAnchor(owner, owner.controls.items.indexOf(c) + 1, host));
|
|
5270
|
+
}
|
|
5260
5271
|
function removeComponentDom(c, node, alsoPlaceholder) {
|
|
5261
|
-
const opts = c
|
|
5272
|
+
const opts = optionsOf(c);
|
|
5262
5273
|
const parent = node.parentNode;
|
|
5263
5274
|
if (node.nodeType === Node.COMMENT_NODE) {
|
|
5264
|
-
if (
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5275
|
+
if (parent) {
|
|
5276
|
+
const close = opts?.closeFragment || null;
|
|
5277
|
+
if (close) {
|
|
5278
|
+
let current = node;
|
|
5279
|
+
while (current) {
|
|
5280
|
+
const after = current.nextSibling;
|
|
5281
|
+
try {
|
|
5282
|
+
parent.removeChild(current);
|
|
5283
|
+
}
|
|
5284
|
+
catch { }
|
|
5285
|
+
if (current === close)
|
|
5286
|
+
break;
|
|
5287
|
+
current = after;
|
|
5288
|
+
}
|
|
5289
|
+
}
|
|
5290
|
+
else {
|
|
5271
5291
|
try {
|
|
5272
|
-
parent.removeChild(
|
|
5292
|
+
parent.removeChild(node);
|
|
5273
5293
|
}
|
|
5274
5294
|
catch { }
|
|
5275
|
-
if (current === close)
|
|
5276
|
-
break;
|
|
5277
|
-
current = after;
|
|
5278
5295
|
}
|
|
5296
|
+
if (!alsoPlaceholder)
|
|
5297
|
+
return;
|
|
5279
5298
|
}
|
|
5280
|
-
else {
|
|
5281
|
-
try {
|
|
5282
|
-
parent.removeChild(node);
|
|
5283
|
-
}
|
|
5284
|
-
catch { }
|
|
5285
|
-
}
|
|
5286
|
-
if (!alsoPlaceholder)
|
|
5287
|
-
return;
|
|
5288
5299
|
}
|
|
5289
5300
|
else if (parent) {
|
|
5290
5301
|
try {
|
|
@@ -5371,23 +5382,23 @@
|
|
|
5371
5382
|
return;
|
|
5372
5383
|
ComponentHelper.callDisposing.call(c, c);
|
|
5373
5384
|
try {
|
|
5374
|
-
c
|
|
5385
|
+
offAll(c);
|
|
5375
5386
|
}
|
|
5376
5387
|
catch {
|
|
5377
5388
|
}
|
|
5378
5389
|
c.motif.stopAnimations();
|
|
5379
|
-
c
|
|
5380
|
-
if (c.
|
|
5381
|
-
for (const child of c.
|
|
5390
|
+
deactivateBindings(c);
|
|
5391
|
+
if (childrenOf(c).length) {
|
|
5392
|
+
for (const child of c._controls.items) {
|
|
5382
5393
|
try {
|
|
5383
|
-
child
|
|
5394
|
+
disposeShallow(child);
|
|
5384
5395
|
}
|
|
5385
5396
|
catch {
|
|
5386
5397
|
}
|
|
5387
5398
|
}
|
|
5388
5399
|
}
|
|
5389
5400
|
ComponentHelper.callDisposed.call(c, c);
|
|
5390
|
-
safeCall(() => { c.
|
|
5401
|
+
safeCall(() => { c._baseCtx?._emiters?.clear(); }, 'disposeShallow.emiters');
|
|
5391
5402
|
c.isDisposed = true;
|
|
5392
5403
|
Disposable.prototype.dispose.call(c);
|
|
5393
5404
|
}
|
|
@@ -5396,33 +5407,29 @@
|
|
|
5396
5407
|
c.parent = null;
|
|
5397
5408
|
}
|
|
5398
5409
|
catch { }
|
|
5399
|
-
try {
|
|
5400
|
-
c._eventHandlers?.clear();
|
|
5401
|
-
}
|
|
5402
|
-
catch {
|
|
5403
|
-
}
|
|
5404
5410
|
c._eventHandlers = undefined;
|
|
5405
5411
|
try {
|
|
5406
|
-
c.
|
|
5412
|
+
c._class?._countsStore?.clear();
|
|
5407
5413
|
}
|
|
5408
5414
|
catch { }
|
|
5409
5415
|
try {
|
|
5410
|
-
c.
|
|
5416
|
+
c._class?._watchersStore?.clear();
|
|
5411
5417
|
}
|
|
5412
5418
|
catch { }
|
|
5413
5419
|
try {
|
|
5414
|
-
c.
|
|
5420
|
+
c._attr?._attrMapStore?.clear();
|
|
5415
5421
|
}
|
|
5416
5422
|
catch { }
|
|
5417
5423
|
try {
|
|
5418
|
-
c.
|
|
5424
|
+
c._attr?._watchersStore?.clear();
|
|
5419
5425
|
}
|
|
5420
5426
|
catch { }
|
|
5421
5427
|
try {
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5428
|
+
const opts = c._motif?.options;
|
|
5429
|
+
if (opts) {
|
|
5430
|
+
opts.cache = undefined;
|
|
5431
|
+
opts.closeFragment = undefined;
|
|
5432
|
+
opts.placeholder = undefined;
|
|
5426
5433
|
}
|
|
5427
5434
|
}
|
|
5428
5435
|
catch {
|
|
@@ -5452,20 +5459,22 @@
|
|
|
5452
5459
|
}
|
|
5453
5460
|
catch { }
|
|
5454
5461
|
try {
|
|
5455
|
-
c.
|
|
5462
|
+
if (c._motif)
|
|
5463
|
+
c._motif.options = undefined;
|
|
5456
5464
|
}
|
|
5457
5465
|
catch { }
|
|
5458
5466
|
const keys = Object.keys(c);
|
|
5459
5467
|
for (let i = 0; i < keys.length; i++) {
|
|
5460
5468
|
const key = keys[i];
|
|
5461
|
-
if (key === '
|
|
5469
|
+
if (key === '_motif' || key === '_flags')
|
|
5462
5470
|
continue;
|
|
5463
5471
|
try {
|
|
5464
5472
|
c[key] = undefined;
|
|
5465
5473
|
}
|
|
5466
5474
|
catch { }
|
|
5467
5475
|
}
|
|
5468
|
-
c.
|
|
5476
|
+
c._store = null;
|
|
5477
|
+
c._flags = F_DISPOSED | F_HIDDEN | F_DISPOSED_FIRED | F_POSTCONFIG | F_PREBOUND;
|
|
5469
5478
|
}
|
|
5470
5479
|
const DISPOSE_STARTED = Promise.resolve();
|
|
5471
5480
|
function subtreeDisposesSync(c, root) {
|
|
@@ -5473,7 +5482,7 @@
|
|
|
5473
5482
|
return false;
|
|
5474
5483
|
if (c.disposeAsync !== ComponentBase.prototype.disposeAsync)
|
|
5475
5484
|
return false;
|
|
5476
|
-
const opts = c
|
|
5485
|
+
const opts = optionsOf(c);
|
|
5477
5486
|
if (opts) {
|
|
5478
5487
|
if (opts.transitionOut)
|
|
5479
5488
|
return false;
|
|
@@ -5487,8 +5496,8 @@
|
|
|
5487
5496
|
return false;
|
|
5488
5497
|
}
|
|
5489
5498
|
}
|
|
5490
|
-
const items = c
|
|
5491
|
-
if (items) {
|
|
5499
|
+
const items = childrenOf(c);
|
|
5500
|
+
if (items.length) {
|
|
5492
5501
|
for (let i = 0; i < items.length; i++) {
|
|
5493
5502
|
const child = items[i];
|
|
5494
5503
|
if (child && !child.isDisposed && !subtreeDisposesSync(child, false))
|
|
@@ -5519,27 +5528,28 @@
|
|
|
5519
5528
|
c.motif.options.transition.skipNextLeave = true;
|
|
5520
5529
|
}
|
|
5521
5530
|
safeCall(() => { ComponentHelper.callDisposing.call(c, c); }, ctx + '.callDisposing');
|
|
5522
|
-
c
|
|
5523
|
-
c
|
|
5531
|
+
offAll(c);
|
|
5532
|
+
deactivateBindings(c);
|
|
5524
5533
|
safeCall(() => { c.parent?.controls?.silentDetach?.(c, true); }, ctx + '.silentDetach');
|
|
5525
5534
|
}
|
|
5526
5535
|
function disposeFinish(c, options, asChild) {
|
|
5527
5536
|
c.isDisposed = true;
|
|
5528
5537
|
Disposable.prototype.dispose.call(c);
|
|
5529
5538
|
if (asChild) {
|
|
5530
|
-
c.
|
|
5539
|
+
if (c._controls)
|
|
5540
|
+
c._controls.items = [];
|
|
5531
5541
|
safeCall(() => { ComponentHelper.callDisposed.call(c, c); }, 'disposeAsync.callDisposed');
|
|
5532
|
-
safeCall(() => { c.
|
|
5542
|
+
safeCall(() => { c._baseCtx?._emiters?.clear(); }, 'disposeAsync.emiters');
|
|
5533
5543
|
if (options?.deep) {
|
|
5534
|
-
c
|
|
5544
|
+
deepCleanup(c);
|
|
5535
5545
|
}
|
|
5536
5546
|
return;
|
|
5537
5547
|
}
|
|
5538
5548
|
c.element = null;
|
|
5539
5549
|
safeCall(() => { ComponentHelper.callDisposed.call(c, c); }, 'dispose.callDisposed');
|
|
5540
|
-
safeCall(() => { c.
|
|
5541
|
-
c
|
|
5542
|
-
c
|
|
5550
|
+
safeCall(() => { c._baseCtx?._emiters?.clear(); }, 'dispose.emiters');
|
|
5551
|
+
offAll(c);
|
|
5552
|
+
deepCleanup(c);
|
|
5543
5553
|
}
|
|
5544
5554
|
async function disposeRemainderAsync(c, options, asChild, leave) {
|
|
5545
5555
|
if (leave) {
|
|
@@ -5552,7 +5562,7 @@
|
|
|
5552
5562
|
else if (peekTransition(c)?.skipNextLeave) {
|
|
5553
5563
|
await c.motif.stopAnimations();
|
|
5554
5564
|
}
|
|
5555
|
-
await c
|
|
5565
|
+
await detachDomWithAnimationAsync(c);
|
|
5556
5566
|
}
|
|
5557
5567
|
if (!asChild && c.constructor.name !== 'TransportTo') {
|
|
5558
5568
|
await disposeContentBlocks(c);
|
|
@@ -5562,7 +5572,7 @@
|
|
|
5562
5572
|
if (c.isDisposed) {
|
|
5563
5573
|
return;
|
|
5564
5574
|
}
|
|
5565
|
-
const ctrls = Array.from(c
|
|
5575
|
+
const ctrls = Array.from(childrenOf(c));
|
|
5566
5576
|
if (ctrls.length) {
|
|
5567
5577
|
await Promise.all(ctrls.map(child => asChild
|
|
5568
5578
|
? safeCallAsync(async () => { await child.disposeAsync(childOptions); }, 'disposeAsync.disposeAsyncChildren.handler')
|
|
@@ -5592,8 +5602,8 @@
|
|
|
5592
5602
|
const node = nodes[n];
|
|
5593
5603
|
if (node.isDisposed)
|
|
5594
5604
|
continue;
|
|
5595
|
-
const items = node
|
|
5596
|
-
if (
|
|
5605
|
+
const items = childrenOf(node);
|
|
5606
|
+
if (items.length === 0)
|
|
5597
5607
|
continue;
|
|
5598
5608
|
const ctrls = Array.from(items);
|
|
5599
5609
|
for (let j = 0; j < ctrls.length; j++) {
|
|
@@ -5608,7 +5618,8 @@
|
|
|
5608
5618
|
retireServiceOwner(child);
|
|
5609
5619
|
child._disposing = root._disposing;
|
|
5610
5620
|
disposePrefix(child, childOptions, true);
|
|
5611
|
-
|
|
5621
|
+
if (child.element?.isConnected !== false)
|
|
5622
|
+
detachDomWithAnimation(child);
|
|
5612
5623
|
nodes.push(child);
|
|
5613
5624
|
parents.push(n);
|
|
5614
5625
|
}
|
|
@@ -5647,68 +5658,24 @@
|
|
|
5647
5658
|
return null;
|
|
5648
5659
|
}
|
|
5649
5660
|
const BASE_PROTO = {
|
|
5661
|
+
get emiters() {
|
|
5662
|
+
const base = this;
|
|
5663
|
+
return base._emiters ??= new ComponentEmiter(base.owner);
|
|
5664
|
+
},
|
|
5650
5665
|
_offAll() {
|
|
5651
|
-
|
|
5652
|
-
if (!c._eventHandlers)
|
|
5653
|
-
return;
|
|
5654
|
-
for (const [full, set] of c._eventHandlers) {
|
|
5655
|
-
const name = full.split(":")[0];
|
|
5656
|
-
const evt = name.startsWith("on") ? name.slice(2).toLowerCase() : name.toLowerCase();
|
|
5657
|
-
for (const rec of set) {
|
|
5658
|
-
if (!rec || !rec.wrapped) {
|
|
5659
|
-
continue;
|
|
5660
|
-
}
|
|
5661
|
-
if (rec.domEvent === false) {
|
|
5662
|
-
continue;
|
|
5663
|
-
}
|
|
5664
|
-
const cap = rec.capture === true;
|
|
5665
|
-
try {
|
|
5666
|
-
c.element.removeEventListener(evt, rec.wrapped, cap);
|
|
5667
|
-
}
|
|
5668
|
-
catch { }
|
|
5669
|
-
try {
|
|
5670
|
-
if (rec.capture === undefined) {
|
|
5671
|
-
c.element.removeEventListener(evt, rec.wrapped, !cap);
|
|
5672
|
-
}
|
|
5673
|
-
}
|
|
5674
|
-
catch { }
|
|
5675
|
-
}
|
|
5676
|
-
}
|
|
5677
|
-
c._eventHandlers.clear();
|
|
5678
|
-
c._eventHandlers = undefined;
|
|
5666
|
+
offAll(this.owner);
|
|
5679
5667
|
},
|
|
5680
5668
|
_deactivateBindings() {
|
|
5681
|
-
|
|
5682
|
-
try {
|
|
5683
|
-
c.bindings?.deactivateAll();
|
|
5684
|
-
}
|
|
5685
|
-
catch { }
|
|
5669
|
+
deactivateBindings(this.owner);
|
|
5686
5670
|
},
|
|
5687
5671
|
_activateBindings() {
|
|
5688
|
-
|
|
5689
|
-
try {
|
|
5690
|
-
c.bindings?.activateAll();
|
|
5691
|
-
}
|
|
5692
|
-
catch { }
|
|
5672
|
+
activateBindings(this.owner);
|
|
5693
5673
|
},
|
|
5694
5674
|
_reactivateBindings() {
|
|
5695
|
-
|
|
5696
|
-
try {
|
|
5697
|
-
c.bindings?.reActivateAll();
|
|
5698
|
-
}
|
|
5699
|
-
catch { }
|
|
5675
|
+
reactivateBindings(this.owner);
|
|
5700
5676
|
},
|
|
5701
5677
|
_activatePreBindings() {
|
|
5702
|
-
|
|
5703
|
-
return;
|
|
5704
|
-
const c = this.owner;
|
|
5705
|
-
const registered = c.bindings?._items;
|
|
5706
|
-
if (registered && registered.length > 0) {
|
|
5707
|
-
c.bindings.items.filter((x) => x.propertyName == "isWait" || x.propertyName == "display").forEach((b) => {
|
|
5708
|
-
b.activate();
|
|
5709
|
-
});
|
|
5710
|
-
}
|
|
5711
|
-
this.prebinding_Activated = true;
|
|
5678
|
+
activatePreBindings(this.owner);
|
|
5712
5679
|
},
|
|
5713
5680
|
_detachDomWithAnimation() {
|
|
5714
5681
|
detachDomWithAnimation(this.owner);
|
|
@@ -5723,13 +5690,184 @@
|
|
|
5723
5690
|
deepCleanup(this.owner);
|
|
5724
5691
|
},
|
|
5725
5692
|
};
|
|
5693
|
+
const EV_SELF = 1;
|
|
5694
|
+
const EV_TRUSTED = 2;
|
|
5695
|
+
const EV_PREVENT = 4;
|
|
5696
|
+
const EV_STOP = 8;
|
|
5697
|
+
const EV_CAPTURE = 16;
|
|
5698
|
+
const EV_DOM = 32;
|
|
5699
|
+
const EV_REMOVED = 64;
|
|
5700
|
+
const NO_MODS = [];
|
|
5701
|
+
let eventDispatchDepth = 0;
|
|
5702
|
+
class EventRecord {
|
|
5703
|
+
constructor(owner, key, original, type, flags) {
|
|
5704
|
+
this.owner = owner;
|
|
5705
|
+
this.key = key;
|
|
5706
|
+
this.original = original;
|
|
5707
|
+
this.type = type;
|
|
5708
|
+
this.flags = flags;
|
|
5709
|
+
this.next = undefined;
|
|
5710
|
+
}
|
|
5711
|
+
handleEvent(ev) {
|
|
5712
|
+
const flags = this.flags;
|
|
5713
|
+
const owner = this.owner;
|
|
5714
|
+
if ((flags & EV_SELF) !== 0 && ev.target !== owner.element)
|
|
5715
|
+
return;
|
|
5716
|
+
if ((flags & EV_TRUSTED) !== 0 && !ev.isTrusted)
|
|
5717
|
+
return;
|
|
5718
|
+
const cb = this.original;
|
|
5719
|
+
let res;
|
|
5720
|
+
try {
|
|
5721
|
+
if (cb && cb.length <= 1) {
|
|
5722
|
+
res = cb(ev);
|
|
5723
|
+
}
|
|
5724
|
+
else if (cb) {
|
|
5725
|
+
res = cb(owner, ev);
|
|
5726
|
+
}
|
|
5727
|
+
}
|
|
5728
|
+
catch (error) {
|
|
5729
|
+
reportError('MJX123', error, this.type);
|
|
5730
|
+
}
|
|
5731
|
+
if (res && typeof res.then === 'function') {
|
|
5732
|
+
const type = this.type;
|
|
5733
|
+
res.then(undefined, (error) => reportError('MJX123', error, type));
|
|
5734
|
+
}
|
|
5735
|
+
if ((flags & EV_PREVENT) !== 0) {
|
|
5736
|
+
preventEvent(ev);
|
|
5737
|
+
}
|
|
5738
|
+
if ((flags & EV_STOP) !== 0) {
|
|
5739
|
+
stopEvent(ev);
|
|
5740
|
+
}
|
|
5741
|
+
if (res && res.cancel === true) {
|
|
5742
|
+
preventEvent(ev);
|
|
5743
|
+
stopEvent(ev);
|
|
5744
|
+
}
|
|
5745
|
+
}
|
|
5746
|
+
}
|
|
5747
|
+
function preventEvent(ev) {
|
|
5748
|
+
if (typeof ev?.preventDefault === 'function')
|
|
5749
|
+
ev.preventDefault();
|
|
5750
|
+
}
|
|
5751
|
+
function stopEvent(ev) {
|
|
5752
|
+
if (typeof ev?.stopPropagation === 'function')
|
|
5753
|
+
ev.stopPropagation();
|
|
5754
|
+
}
|
|
5755
|
+
function addEventRecord(c, record) {
|
|
5756
|
+
let last = c._eventHandlers;
|
|
5757
|
+
if (last === undefined) {
|
|
5758
|
+
c._eventHandlers = record;
|
|
5759
|
+
return;
|
|
5760
|
+
}
|
|
5761
|
+
while (last.next !== undefined)
|
|
5762
|
+
last = last.next;
|
|
5763
|
+
last.next = record;
|
|
5764
|
+
}
|
|
5765
|
+
function compactEventRecords(c) {
|
|
5766
|
+
let head;
|
|
5767
|
+
let tail;
|
|
5768
|
+
for (let r = c._eventHandlers; r !== undefined; r = r.next) {
|
|
5769
|
+
if ((r.flags & EV_REMOVED) !== 0)
|
|
5770
|
+
continue;
|
|
5771
|
+
if (tail === undefined)
|
|
5772
|
+
head = r;
|
|
5773
|
+
else
|
|
5774
|
+
tail.next = r;
|
|
5775
|
+
tail = r;
|
|
5776
|
+
}
|
|
5777
|
+
if (tail !== undefined)
|
|
5778
|
+
tail.next = undefined;
|
|
5779
|
+
c._eventHandlers = head;
|
|
5780
|
+
}
|
|
5781
|
+
function hasEventKey(c, key) {
|
|
5782
|
+
for (let r = c._eventHandlers; r !== undefined; r = r.next) {
|
|
5783
|
+
if ((r.flags & EV_REMOVED) === 0 && r.key === key)
|
|
5784
|
+
return true;
|
|
5785
|
+
}
|
|
5786
|
+
return false;
|
|
5787
|
+
}
|
|
5788
|
+
function offAll(c) {
|
|
5789
|
+
const head = c._eventHandlers;
|
|
5790
|
+
if (head === undefined)
|
|
5791
|
+
return;
|
|
5792
|
+
for (let r = head; r !== undefined; r = r.next) {
|
|
5793
|
+
if ((r.flags & (EV_DOM | EV_REMOVED)) !== EV_DOM) {
|
|
5794
|
+
continue;
|
|
5795
|
+
}
|
|
5796
|
+
try {
|
|
5797
|
+
c.element.removeEventListener(r.type, r, (r.flags & EV_CAPTURE) !== 0);
|
|
5798
|
+
}
|
|
5799
|
+
catch { }
|
|
5800
|
+
}
|
|
5801
|
+
c._eventHandlers = undefined;
|
|
5802
|
+
}
|
|
5803
|
+
function deactivateBindings(c) {
|
|
5804
|
+
try {
|
|
5805
|
+
if (c._bindings?._items?.length)
|
|
5806
|
+
c._bindings.deactivateAll();
|
|
5807
|
+
}
|
|
5808
|
+
catch { }
|
|
5809
|
+
}
|
|
5810
|
+
function activateBindings(c) {
|
|
5811
|
+
try {
|
|
5812
|
+
c._bindings?.activateAll();
|
|
5813
|
+
}
|
|
5814
|
+
catch { }
|
|
5815
|
+
}
|
|
5816
|
+
function reactivateBindings(c) {
|
|
5817
|
+
try {
|
|
5818
|
+
c._bindings?.reActivateAll();
|
|
5819
|
+
}
|
|
5820
|
+
catch { }
|
|
5821
|
+
}
|
|
5822
|
+
function activatePreBindings(c) {
|
|
5823
|
+
if ((c._flags & F_PREBOUND) !== 0)
|
|
5824
|
+
return;
|
|
5825
|
+
const registered = c._bindings?._items;
|
|
5826
|
+
if (registered && registered.length > 0) {
|
|
5827
|
+
c._bindings.items.filter((x) => x.propertyName == "isWait" || x.propertyName == "display").forEach((b) => {
|
|
5828
|
+
b.activate();
|
|
5829
|
+
});
|
|
5830
|
+
}
|
|
5831
|
+
c._flags |= F_PREBOUND;
|
|
5832
|
+
}
|
|
5726
5833
|
function createBaseCtx(owner) {
|
|
5727
5834
|
const base = Object.create(BASE_PROTO);
|
|
5728
5835
|
base.owner = owner;
|
|
5729
|
-
base.prebinding_Activated = false;
|
|
5730
|
-
base.emiters = new ComponentEmiter(owner);
|
|
5731
5836
|
return base;
|
|
5732
5837
|
}
|
|
5838
|
+
function controlsOwner(collection) {
|
|
5839
|
+
return collection.owner;
|
|
5840
|
+
}
|
|
5841
|
+
const NO_CHILDREN = Object.freeze([]);
|
|
5842
|
+
const NO_BINDINGS = Object.freeze([]);
|
|
5843
|
+
function childrenOf(c) {
|
|
5844
|
+
return c._controls?.items ?? NO_CHILDREN;
|
|
5845
|
+
}
|
|
5846
|
+
function createOwnedControls(c) {
|
|
5847
|
+
const controls = new ControlCollection(c);
|
|
5848
|
+
controls.onAdd = ownerControlAdded;
|
|
5849
|
+
controls.onAddBeforeBuild = ownerControlAddedBeforeBuild;
|
|
5850
|
+
controls.onRemove = ownerControlRemoved;
|
|
5851
|
+
return controls;
|
|
5852
|
+
}
|
|
5853
|
+
function ownerControlAdded(c) {
|
|
5854
|
+
const owner = controlsOwner(this);
|
|
5855
|
+
if (hasEventKey(owner, 'controladded'))
|
|
5856
|
+
owner.motif.trigger('controladded', { control: c });
|
|
5857
|
+
if (!owner.isVisible && owner.element?.nodeType === Node.COMMENT_NODE)
|
|
5858
|
+
return;
|
|
5859
|
+
ComponentHelper.internalBuild.call(owner, c);
|
|
5860
|
+
}
|
|
5861
|
+
function ownerControlAddedBeforeBuild(c) {
|
|
5862
|
+
const owner = controlsOwner(this);
|
|
5863
|
+
if (hasEventKey(owner, 'controladded'))
|
|
5864
|
+
owner.motif.trigger('controladded', { control: c });
|
|
5865
|
+
}
|
|
5866
|
+
function ownerControlRemoved(c) {
|
|
5867
|
+
const owner = controlsOwner(this);
|
|
5868
|
+
if (hasEventKey(owner, 'controlremoved'))
|
|
5869
|
+
owner.motif.trigger('controlremoved', { control: c });
|
|
5870
|
+
}
|
|
5733
5871
|
const fragmentCloseMarkers = new WeakMap();
|
|
5734
5872
|
const LIFECYCLE_X_EVENTS = new Set([
|
|
5735
5873
|
'building', 'built', 'initializing', 'initialized', 'disposing', 'disposed',
|
|
@@ -5768,37 +5906,83 @@
|
|
|
5768
5906
|
});
|
|
5769
5907
|
}
|
|
5770
5908
|
class ComponentBase extends Disposable {
|
|
5771
|
-
motif
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5909
|
+
get motif() {
|
|
5910
|
+
return this._motif !== undefined ? this._motif : (this._motif = new ComponentMotif(this, (this.isDisposed && !this.element ? undefined : new ComponentOptionsImpl(this))));
|
|
5911
|
+
}
|
|
5912
|
+
set motif(value) {
|
|
5913
|
+
this._motif = value;
|
|
5914
|
+
}
|
|
5915
|
+
get isBuilt() {
|
|
5916
|
+
return (this._flags & F_BUILT) !== 0;
|
|
5917
|
+
}
|
|
5918
|
+
set isBuilt(value) {
|
|
5919
|
+
this._flags = value ? this._flags | F_BUILT : this._flags & ~F_BUILT;
|
|
5920
|
+
}
|
|
5921
|
+
get isInitialized() {
|
|
5922
|
+
return (this._flags & F_INITIALIZED) !== 0;
|
|
5923
|
+
}
|
|
5924
|
+
set isInitialized(value) {
|
|
5925
|
+
this._flags = value ? this._flags | F_INITIALIZED : this._flags & ~F_INITIALIZED;
|
|
5926
|
+
}
|
|
5927
|
+
get isDisposed() {
|
|
5928
|
+
return (this._flags & F_DISPOSED) !== 0;
|
|
5929
|
+
}
|
|
5930
|
+
set isDisposed(value) {
|
|
5931
|
+
this._flags = value ? this._flags | F_DISPOSED : this._flags & ~F_DISPOSED;
|
|
5932
|
+
}
|
|
5933
|
+
get isConfigured() {
|
|
5934
|
+
return (this._flags & F_CONFIGURED) !== 0;
|
|
5935
|
+
}
|
|
5936
|
+
set isConfigured(value) {
|
|
5937
|
+
this._flags = value ? this._flags | F_CONFIGURED : this._flags & ~F_CONFIGURED;
|
|
5938
|
+
}
|
|
5939
|
+
get isPainting() {
|
|
5940
|
+
return (this._flags & F_PAINTING) !== 0;
|
|
5941
|
+
}
|
|
5942
|
+
set isPainting(value) {
|
|
5943
|
+
this._flags = value ? this._flags | F_PAINTING : this._flags & ~F_PAINTING;
|
|
5944
|
+
}
|
|
5945
|
+
get isPainted() {
|
|
5946
|
+
return (this._flags & F_PAINTED) !== 0;
|
|
5947
|
+
}
|
|
5948
|
+
set isPainted(value) {
|
|
5949
|
+
this._flags = value ? this._flags | F_PAINTED : this._flags & ~F_PAINTED;
|
|
5950
|
+
}
|
|
5951
|
+
get isVisible() {
|
|
5952
|
+
return (this._flags & F_HIDDEN) === 0;
|
|
5953
|
+
}
|
|
5954
|
+
set isVisible(value) {
|
|
5955
|
+
this._flags = value ? this._flags & ~F_HIDDEN : this._flags | F_HIDDEN;
|
|
5956
|
+
}
|
|
5957
|
+
get controls() {
|
|
5958
|
+
return this._controls !== undefined || (this.isDisposed && !this.element) ? this._controls : (this._controls = createOwnedControls(this));
|
|
5959
|
+
}
|
|
5960
|
+
set controls(value) {
|
|
5961
|
+
this._controls = value;
|
|
5962
|
+
}
|
|
5963
|
+
get class() {
|
|
5964
|
+
return this._class !== undefined || (this.isDisposed && !this.element) ? this._class : (this._class = new controlClass(this));
|
|
5965
|
+
}
|
|
5966
|
+
set class(value) {
|
|
5967
|
+
this._class = value;
|
|
5968
|
+
}
|
|
5969
|
+
get attr() {
|
|
5970
|
+
return this._attr !== undefined || (this.isDisposed && !this.element) ? this._attr : (this._attr = new controlAttribute(this));
|
|
5971
|
+
}
|
|
5972
|
+
set attr(value) {
|
|
5973
|
+
this._attr = value;
|
|
5974
|
+
}
|
|
5975
|
+
get bindings() {
|
|
5976
|
+
return this._bindings !== undefined || (this.isDisposed && !this.element) ? this._bindings : (this._bindings = new BindingCollection(this));
|
|
5977
|
+
}
|
|
5978
|
+
set bindings(value) {
|
|
5979
|
+
this._bindings = value;
|
|
5980
|
+
}
|
|
5789
5981
|
useModel(modelCtor) {
|
|
5790
5982
|
return reactive(modelCtor);
|
|
5791
5983
|
}
|
|
5792
5984
|
_computeHideStrategy() {
|
|
5793
|
-
|
|
5794
|
-
if (cfg === 'placeholder')
|
|
5795
|
-
return 'placeholder';
|
|
5796
|
-
if (cfg === 'detach')
|
|
5797
|
-
return 'detach';
|
|
5798
|
-
if (this.motif.options?.__fromList || typeof this.motif.options?.indexkey !== 'undefined' || typeof this.motif.options?.__key !== 'undefined') {
|
|
5799
|
-
return 'detach';
|
|
5800
|
-
}
|
|
5801
|
-
return 'placeholder';
|
|
5985
|
+
return keepsTrace(this) ? 'placeholder' : 'detach';
|
|
5802
5986
|
}
|
|
5803
5987
|
_isInDom() {
|
|
5804
5988
|
try {
|
|
@@ -5815,7 +5999,7 @@
|
|
|
5815
5999
|
}
|
|
5816
6000
|
}
|
|
5817
6001
|
set isWait(value) {
|
|
5818
|
-
this.
|
|
6002
|
+
this._flags = value ? this._flags | F_WAIT : this._flags & ~F_WAIT;
|
|
5819
6003
|
if (this.isBuilt) {
|
|
5820
6004
|
if (value) {
|
|
5821
6005
|
this.motif.hide();
|
|
@@ -5830,10 +6014,22 @@
|
|
|
5830
6014
|
}
|
|
5831
6015
|
}
|
|
5832
6016
|
get isWait() {
|
|
5833
|
-
return this.
|
|
6017
|
+
return (this._flags & F_WAIT) !== 0;
|
|
5834
6018
|
}
|
|
5835
6019
|
constructor(element, props = {}) {
|
|
5836
6020
|
super();
|
|
6021
|
+
this._motif = undefined;
|
|
6022
|
+
this._flags = 0;
|
|
6023
|
+
this._controls = undefined;
|
|
6024
|
+
this._class = undefined;
|
|
6025
|
+
this._attr = undefined;
|
|
6026
|
+
this._bindings = undefined;
|
|
6027
|
+
this._baseCtx = undefined;
|
|
6028
|
+
this._init = undefined;
|
|
6029
|
+
this._leaveContainer = undefined;
|
|
6030
|
+
this.parent = null;
|
|
6031
|
+
const asComponentRoot = constructingComponentRoot;
|
|
6032
|
+
constructingComponentRoot = false;
|
|
5837
6033
|
recordServiceOwner(this);
|
|
5838
6034
|
if (this.onElementCreating) {
|
|
5839
6035
|
this.element = this.onElementCreating.call(this);
|
|
@@ -5844,44 +6040,38 @@
|
|
|
5844
6040
|
else {
|
|
5845
6041
|
this.element = element;
|
|
5846
6042
|
}
|
|
5847
|
-
if (
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
for (const fn of takePendingRefs(this, refs)) {
|
|
5851
|
-
callReported(() => fn(this), 'MJX122', 'ref');
|
|
5852
|
-
}
|
|
5853
|
-
}
|
|
6043
|
+
if (this.element?.nodeType !== 3) {
|
|
6044
|
+
if (this._controls === undefined)
|
|
6045
|
+
this._controls = new ControlCollection(this);
|
|
5854
6046
|
}
|
|
5855
|
-
props
|
|
6047
|
+
const refs = props ? extractRefs(props, this) : [];
|
|
6048
|
+
if (props && ParseProps(props, this))
|
|
6049
|
+
props = {};
|
|
5856
6050
|
applyComponentOptions(props?.options, this);
|
|
5857
6051
|
this.props = props;
|
|
5858
6052
|
// (class/style/id/tabindex/role/aria-*/data-*) kök düğüme (root node) düşer, prop'lar this.props'ta kalır.
|
|
5859
6053
|
if (props) {
|
|
5860
6054
|
const ctor0 = new.target;
|
|
5861
|
-
const plain = ctor0 === ComponentBase || Object.getPrototypeOf(ctor0) === ComponentBase;
|
|
6055
|
+
const plain = !asComponentRoot && (ctor0 === ComponentBase || Object.getPrototypeOf(ctor0) === ComponentBase);
|
|
5862
6056
|
if (plain)
|
|
5863
6057
|
applyPlainElementProps(props, this);
|
|
5864
6058
|
else
|
|
5865
6059
|
applyFallthroughProps(props, this);
|
|
5866
6060
|
}
|
|
6061
|
+
if (refs.length > 0) {
|
|
6062
|
+
for (const fn of takePendingRefs(this, refs)) {
|
|
6063
|
+
callReported(() => fn(this), 'MJX122', 'ref');
|
|
6064
|
+
}
|
|
6065
|
+
}
|
|
5867
6066
|
ComponentHelper.callOnInitializing(this);
|
|
5868
6067
|
if (this.isDisposed)
|
|
5869
6068
|
return;
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
};
|
|
5877
|
-
this.controls.onAddBeforeBuild = (c) => {
|
|
5878
|
-
if (this._eventHandlers?.has('controladded'))
|
|
5879
|
-
this.motif.trigger('controladded', { control: c });
|
|
5880
|
-
};
|
|
5881
|
-
this.controls.onRemove = (c) => {
|
|
5882
|
-
if (this._eventHandlers?.has('controlremoved'))
|
|
5883
|
-
this.motif.trigger('controlremoved', { control: c });
|
|
5884
|
-
};
|
|
6069
|
+
const controls = this._controls;
|
|
6070
|
+
if (controls) {
|
|
6071
|
+
controls.onAdd = ownerControlAdded;
|
|
6072
|
+
controls.onAddBeforeBuild = ownerControlAddedBeforeBuild;
|
|
6073
|
+
controls.onRemove = ownerControlRemoved;
|
|
6074
|
+
}
|
|
5885
6075
|
ComponentHelper.callOnInitialized(this);
|
|
5886
6076
|
const ctor = new.target;
|
|
5887
6077
|
const isBaseCtor = ctor === ComponentBase || Object.getPrototypeOf(ctor) === ComponentBase;
|
|
@@ -5892,10 +6082,9 @@
|
|
|
5892
6082
|
this._base._configDeferred = true;
|
|
5893
6083
|
}
|
|
5894
6084
|
}
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
_scopedContext;
|
|
6085
|
+
get _base() {
|
|
6086
|
+
return this._baseCtx !== undefined || (this.isDisposed && !this.element) ? this._baseCtx : (this._baseCtx = createBaseCtx(this));
|
|
6087
|
+
}
|
|
5899
6088
|
get context() {
|
|
5900
6089
|
const parentCtx = this.parent?.context;
|
|
5901
6090
|
const app = parentCtx?.[RAW_APPLICATION] ?? parentCtx ?? teardownApplications.get(this) ?? Application.main;
|
|
@@ -5922,7 +6111,7 @@
|
|
|
5922
6111
|
build(building = true) {
|
|
5923
6112
|
checkReservedMembers(this);
|
|
5924
6113
|
ComponentHelper.callConfigured(this);
|
|
5925
|
-
this
|
|
6114
|
+
activatePreBindings(this);
|
|
5926
6115
|
if (this.isDisposed || !this.element || this.isWait) {
|
|
5927
6116
|
return;
|
|
5928
6117
|
}
|
|
@@ -5959,7 +6148,7 @@
|
|
|
5959
6148
|
}
|
|
5960
6149
|
const deferredSelectValue = this.element?.nodeName === 'SELECT'
|
|
5961
6150
|
? this.bindings.items.filter(b => b.propertyName === 'value')
|
|
5962
|
-
:
|
|
6151
|
+
: NO_BINDINGS;
|
|
5963
6152
|
if (deferredSelectValue.length) {
|
|
5964
6153
|
try {
|
|
5965
6154
|
this.bindings.items.filter(b => !deferredSelectValue.includes(b)).forEach(b => b.activate());
|
|
@@ -5967,32 +6156,41 @@
|
|
|
5967
6156
|
catch { }
|
|
5968
6157
|
}
|
|
5969
6158
|
else {
|
|
5970
|
-
this
|
|
6159
|
+
activateBindings(this);
|
|
5971
6160
|
}
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
element
|
|
6161
|
+
const kids = childrenOf(this);
|
|
6162
|
+
for (const element of kids.length ? kids.slice() : kids) {
|
|
6163
|
+
var target = isFragment ? this.motif.options.cache : this.element;
|
|
6164
|
+
if (!element.isWait) {
|
|
6165
|
+
element.parent = this;
|
|
6166
|
+
element.build(false);
|
|
6167
|
+
}
|
|
5975
6168
|
if (element.isWait) {
|
|
6169
|
+
if (keepsTrace(element)) {
|
|
6170
|
+
const opts = element.motif.options;
|
|
6171
|
+
(building ? ph : target).appendChild(opts.placeholder ?? (opts.placeholder = dom.createComment("h")));
|
|
6172
|
+
}
|
|
5976
6173
|
continue;
|
|
5977
6174
|
}
|
|
5978
|
-
var target = isFragment ? this.motif.options.cache : this.element;
|
|
5979
6175
|
if (building) {
|
|
5980
|
-
|
|
5981
|
-
|
|
6176
|
+
const cache = optionsOf(element)?.cache;
|
|
6177
|
+
if (cache) {
|
|
6178
|
+
ph.appendChild(cache);
|
|
5982
6179
|
}
|
|
5983
6180
|
else {
|
|
5984
6181
|
ph.appendChild(element.element);
|
|
5985
6182
|
}
|
|
5986
6183
|
}
|
|
5987
6184
|
else {
|
|
5988
|
-
|
|
5989
|
-
|
|
6185
|
+
const cache = optionsOf(element)?.cache;
|
|
6186
|
+
if (cache) {
|
|
6187
|
+
target.appendChild(cache);
|
|
5990
6188
|
}
|
|
5991
6189
|
else {
|
|
5992
6190
|
target.appendChild(element.element);
|
|
5993
6191
|
}
|
|
5994
6192
|
}
|
|
5995
|
-
if (element.
|
|
6193
|
+
if (element._baseCtx?._inactive && element.isVisible) {
|
|
5996
6194
|
ComponentHelper.activateTree(element);
|
|
5997
6195
|
}
|
|
5998
6196
|
}
|
|
@@ -6055,10 +6253,10 @@
|
|
|
6055
6253
|
this.controls.forEach(c => {
|
|
6056
6254
|
c.setState();
|
|
6057
6255
|
});
|
|
6058
|
-
this
|
|
6256
|
+
reactivateBindings(this);
|
|
6059
6257
|
}
|
|
6060
6258
|
reState() {
|
|
6061
|
-
this
|
|
6259
|
+
reactivateBindings(this);
|
|
6062
6260
|
this.controls.forEach(c => {
|
|
6063
6261
|
c.reState();
|
|
6064
6262
|
});
|
|
@@ -6182,6 +6380,9 @@
|
|
|
6182
6380
|
if (this.isVisible) {
|
|
6183
6381
|
return;
|
|
6184
6382
|
} /* A*/
|
|
6383
|
+
if (this.isWait) {
|
|
6384
|
+
return;
|
|
6385
|
+
}
|
|
6185
6386
|
if (this.parent && enterModeOf(this.parent) === 'out-in') {
|
|
6186
6387
|
const showHost = (this.motif.options.placeholder?.parentNode)
|
|
6187
6388
|
?? findAppendableComponent(this.parent)?.element;
|
|
@@ -6203,7 +6404,7 @@
|
|
|
6203
6404
|
/** A*/
|
|
6204
6405
|
const strategy = this._computeHideStrategy();
|
|
6205
6406
|
if (strategy === 'detach') {
|
|
6206
|
-
ComponentHelper.callVisibilityChanged(this);
|
|
6407
|
+
ComponentHelper.callVisibilityChanged(this, true);
|
|
6207
6408
|
if (this.isDisposed) {
|
|
6208
6409
|
return;
|
|
6209
6410
|
}
|
|
@@ -6220,6 +6421,10 @@
|
|
|
6220
6421
|
const expectedParent = findAppendableComponent(this.parent)?.element;
|
|
6221
6422
|
if (this.motif.options.placeholder && placeholderParent && placeholderParent !== expectedParent) {
|
|
6222
6423
|
reportWarning('MJX106', []);
|
|
6424
|
+
ComponentHelper.callVisibilityChanged(this, true);
|
|
6425
|
+
if (this.isDisposed) {
|
|
6426
|
+
return;
|
|
6427
|
+
}
|
|
6223
6428
|
this.isVisible = true;
|
|
6224
6429
|
if (this.parent?.isBuilt) {
|
|
6225
6430
|
ComponentHelper.internalBuild.call(this.parent, this);
|
|
@@ -6228,11 +6433,12 @@
|
|
|
6228
6433
|
}
|
|
6229
6434
|
/** A*/
|
|
6230
6435
|
wantsEnterTransition(this) && this.motif.options.transition.enterTransition(() => { });
|
|
6231
|
-
ComponentHelper.callVisibilityChanged(this);
|
|
6436
|
+
ComponentHelper.callVisibilityChanged(this, true);
|
|
6232
6437
|
if (this.isDisposed) {
|
|
6233
6438
|
return;
|
|
6234
6439
|
}
|
|
6235
6440
|
if (this.element.nodeType === Node.COMMENT_NODE) {
|
|
6441
|
+
this.controls.items.filter(c => !c.isBuilt).forEach(c => ComponentHelper.internalBuild.call(this, c));
|
|
6236
6442
|
this.controls.forEach(c => {
|
|
6237
6443
|
c.motif.show();
|
|
6238
6444
|
});
|
|
@@ -6240,6 +6446,10 @@
|
|
|
6240
6446
|
ComponentHelper.activateTree(this, false);
|
|
6241
6447
|
return;
|
|
6242
6448
|
}
|
|
6449
|
+
if (!this.isBuilt) {
|
|
6450
|
+
this.isVisible = true;
|
|
6451
|
+
return;
|
|
6452
|
+
}
|
|
6243
6453
|
var parent = this.motif.options.placeholder?.parentElement;
|
|
6244
6454
|
if (parent) {
|
|
6245
6455
|
parent.replaceChild(this.element, this.motif.options.placeholder);
|
|
@@ -6258,7 +6468,7 @@
|
|
|
6258
6468
|
}
|
|
6259
6469
|
const strategy = this._computeHideStrategy();
|
|
6260
6470
|
if (strategy === 'detach') {
|
|
6261
|
-
ComponentHelper.callVisibilityChanged(this);
|
|
6471
|
+
ComponentHelper.callVisibilityChanged(this, false);
|
|
6262
6472
|
if (this.isDisposed) {
|
|
6263
6473
|
return;
|
|
6264
6474
|
}
|
|
@@ -6273,7 +6483,7 @@
|
|
|
6273
6483
|
if (skip)
|
|
6274
6484
|
transition.skipNextLeave = false;
|
|
6275
6485
|
const finish = () => {
|
|
6276
|
-
ComponentHelper.callVisibilityChanged(this);
|
|
6486
|
+
ComponentHelper.callVisibilityChanged(this, false);
|
|
6277
6487
|
if (this.isDisposed) {
|
|
6278
6488
|
return;
|
|
6279
6489
|
}
|
|
@@ -6356,61 +6566,36 @@
|
|
|
6356
6566
|
return this;
|
|
6357
6567
|
}
|
|
6358
6568
|
}
|
|
6359
|
-
const
|
|
6569
|
+
const colon = full.indexOf(":");
|
|
6570
|
+
const name = colon < 0 ? full : full.slice(0, colon);
|
|
6571
|
+
const mods = colon < 0 ? NO_MODS : full.slice(colon + 1).split(":");
|
|
6360
6572
|
const evt = name.startsWith("on") ? name.slice(2).toLowerCase() : name.toLowerCase();
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
if (mods.includes("
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
reportError('MJX123', error, evt);
|
|
6384
|
-
}
|
|
6385
|
-
if (res && typeof res.then === 'function') {
|
|
6386
|
-
res.then(undefined, (error) => reportError('MJX123', error, evt));
|
|
6387
|
-
}
|
|
6388
|
-
const prevent = () => { if (typeof ev?.preventDefault === 'function')
|
|
6389
|
-
ev.preventDefault(); };
|
|
6390
|
-
const stop = () => { if (typeof ev?.stopPropagation === 'function')
|
|
6391
|
-
ev.stopPropagation(); };
|
|
6392
|
-
if (mods.includes("prevent")) {
|
|
6393
|
-
prevent();
|
|
6394
|
-
}
|
|
6395
|
-
if (mods.includes("stop")) {
|
|
6396
|
-
stop();
|
|
6397
|
-
}
|
|
6398
|
-
if (res && res.cancel === true) {
|
|
6399
|
-
prevent();
|
|
6400
|
-
stop();
|
|
6401
|
-
}
|
|
6402
|
-
};
|
|
6573
|
+
let flags = domEvent ? EV_DOM : 0;
|
|
6574
|
+
let options;
|
|
6575
|
+
if (mods.length) {
|
|
6576
|
+
options = {};
|
|
6577
|
+
if (mods.includes("once"))
|
|
6578
|
+
options.once = true;
|
|
6579
|
+
if (mods.includes("passive"))
|
|
6580
|
+
options.passive = true;
|
|
6581
|
+
if (mods.includes("capture")) {
|
|
6582
|
+
options.capture = true;
|
|
6583
|
+
flags |= EV_CAPTURE;
|
|
6584
|
+
}
|
|
6585
|
+
if (mods.includes("self"))
|
|
6586
|
+
flags |= EV_SELF;
|
|
6587
|
+
if (mods.includes("trusted"))
|
|
6588
|
+
flags |= EV_TRUSTED;
|
|
6589
|
+
if (mods.includes("prevent"))
|
|
6590
|
+
flags |= EV_PREVENT;
|
|
6591
|
+
if (mods.includes("stop"))
|
|
6592
|
+
flags |= EV_STOP;
|
|
6593
|
+
}
|
|
6594
|
+
const record = new EventRecord(this, full.toLowerCase(), cb, evt, flags);
|
|
6403
6595
|
if (domEvent) {
|
|
6404
|
-
this.element.addEventListener(evt,
|
|
6405
|
-
}
|
|
6406
|
-
this
|
|
6407
|
-
const key = full.toLowerCase();
|
|
6408
|
-
const set = this._eventHandlers.get(key) ?? new Set();
|
|
6409
|
-
set.add({ original: cb, wrapped, capture: !!options.capture, domEvent: !!domEvent, type: evt });
|
|
6410
|
-
this._eventHandlers.set(key, set);
|
|
6411
|
-
this._register(disposableCore.toDisposable(() => {
|
|
6412
|
-
this.motif.off(event, cb);
|
|
6413
|
-
}));
|
|
6596
|
+
this.element.addEventListener(evt, record, options);
|
|
6597
|
+
}
|
|
6598
|
+
addEventRecord(this, record);
|
|
6414
6599
|
return this;
|
|
6415
6600
|
}
|
|
6416
6601
|
async _trigger(event, ev) {
|
|
@@ -6419,15 +6604,20 @@
|
|
|
6419
6604
|
}
|
|
6420
6605
|
const name = String(event).toLowerCase();
|
|
6421
6606
|
safeCall(() => {
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6607
|
+
eventDispatchDepth++;
|
|
6608
|
+
try {
|
|
6609
|
+
for (let r = this._eventHandlers; r !== undefined; r = r.next) {
|
|
6610
|
+
if ((r.flags & EV_REMOVED) !== 0 || r.key !== name)
|
|
6611
|
+
continue;
|
|
6425
6612
|
try {
|
|
6426
|
-
|
|
6613
|
+
r.handleEvent(ev);
|
|
6427
6614
|
}
|
|
6428
6615
|
catch {
|
|
6429
6616
|
}
|
|
6430
|
-
}
|
|
6617
|
+
}
|
|
6618
|
+
}
|
|
6619
|
+
finally {
|
|
6620
|
+
eventDispatchDepth--;
|
|
6431
6621
|
}
|
|
6432
6622
|
}, 'trigger');
|
|
6433
6623
|
return this;
|
|
@@ -6450,38 +6640,24 @@
|
|
|
6450
6640
|
return this;
|
|
6451
6641
|
}
|
|
6452
6642
|
if (LIFECYCLE_X_EVENTS.has(xName)) {
|
|
6453
|
-
this._base.
|
|
6643
|
+
this._base._emiters?.off("on" + xName, cb);
|
|
6454
6644
|
}
|
|
6455
6645
|
return this;
|
|
6456
6646
|
}
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
return this;
|
|
6464
|
-
for (const rec of Array.from(set)) {
|
|
6465
|
-
if (rec.original === cb) {
|
|
6466
|
-
if (rec.domEvent !== false) {
|
|
6467
|
-
const cap = rec.capture === true;
|
|
6468
|
-
safeCall(() => { this.element.removeEventListener(evt, rec.wrapped, cap); }, 'off.removeEventListener');
|
|
6469
|
-
safeCall(() => {
|
|
6470
|
-
if (rec.capture === undefined) {
|
|
6471
|
-
this.element.removeEventListener(evt, rec.wrapped, !cap);
|
|
6472
|
-
}
|
|
6473
|
-
}, 'off.removeEventListener.fallback');
|
|
6474
|
-
}
|
|
6475
|
-
set.delete(rec);
|
|
6476
|
-
break;
|
|
6647
|
+
for (let r = this._eventHandlers; r !== undefined; r = r.next) {
|
|
6648
|
+
if ((r.flags & EV_REMOVED) !== 0 || r.key !== full || r.original !== cb)
|
|
6649
|
+
continue;
|
|
6650
|
+
if ((r.flags & EV_DOM) !== 0) {
|
|
6651
|
+
const rec = r;
|
|
6652
|
+
safeCall(() => { this.element.removeEventListener(rec.type, rec, (rec.flags & EV_CAPTURE) !== 0); }, 'off.removeEventListener');
|
|
6477
6653
|
}
|
|
6654
|
+
r.flags |= EV_REMOVED;
|
|
6655
|
+
break;
|
|
6478
6656
|
}
|
|
6479
|
-
if (
|
|
6480
|
-
this
|
|
6657
|
+
if (eventDispatchDepth === 0)
|
|
6658
|
+
compactEventRecords(this);
|
|
6481
6659
|
return this;
|
|
6482
6660
|
}
|
|
6483
|
-
/** Süren bertaraf: ikinci bir dispose/disposeAsync çağrısı yenisini başlatmaz, bunu bekler. */
|
|
6484
|
-
_disposing;
|
|
6485
6661
|
dispose(options = { deep: true }) {
|
|
6486
6662
|
if (this.isDisposed) {
|
|
6487
6663
|
return Promise.resolve();
|
|
@@ -6552,8 +6728,6 @@
|
|
|
6552
6728
|
}
|
|
6553
6729
|
});
|
|
6554
6730
|
}
|
|
6555
|
-
_siblingsApi;
|
|
6556
|
-
_siblingsSet;
|
|
6557
6731
|
get siblings() {
|
|
6558
6732
|
if (this._siblingsSet) {
|
|
6559
6733
|
return this._siblingsApi;
|
|
@@ -6745,6 +6919,16 @@
|
|
|
6745
6919
|
}
|
|
6746
6920
|
return pending;
|
|
6747
6921
|
}
|
|
6922
|
+
function disposeUnplacedChilds(owner, kids) {
|
|
6923
|
+
if (!Array.isArray(kids) || !kids.some(kid => kid instanceof ComponentBase))
|
|
6924
|
+
return;
|
|
6925
|
+
owner.motif.setDisposable(() => {
|
|
6926
|
+
for (const kid of kids) {
|
|
6927
|
+
if (kid instanceof ComponentBase && !kid.isDisposed && !kid.parent)
|
|
6928
|
+
kid.dispose();
|
|
6929
|
+
}
|
|
6930
|
+
});
|
|
6931
|
+
}
|
|
6748
6932
|
const isCallableRef = (ref) => typeof ref === 'function' || Array.isArray(ref);
|
|
6749
6933
|
function extractRefs(props, component) {
|
|
6750
6934
|
const refs = [];
|
|
@@ -6796,26 +6980,38 @@
|
|
|
6796
6980
|
const fns = Array.isArray(value) ? value : [value];
|
|
6797
6981
|
if (fns.length === 0 || !fns.every(fn => typeof fn === 'function'))
|
|
6798
6982
|
return false;
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
if (!
|
|
6803
|
-
|
|
6983
|
+
const target = component;
|
|
6984
|
+
let from = 0;
|
|
6985
|
+
if (listName === '_initializeComponentHandlers') {
|
|
6986
|
+
if (target._init === undefined && !target._baseCtx?._initializeComponentHandlers) {
|
|
6987
|
+
target._init = fns[0];
|
|
6988
|
+
from = 1;
|
|
6989
|
+
}
|
|
6990
|
+
}
|
|
6991
|
+
if (from >= fns.length)
|
|
6992
|
+
return true;
|
|
6993
|
+
const base = target._base;
|
|
6994
|
+
for (let i = from; i < fns.length; i++) {
|
|
6995
|
+
const fn = fns[i];
|
|
6996
|
+
if (listName === '_initializeComponentHandlers' && fn === target._init)
|
|
6997
|
+
continue;
|
|
6998
|
+
const slot = base[listName];
|
|
6999
|
+
if (slot === undefined)
|
|
7000
|
+
base[listName] = fn;
|
|
7001
|
+
else if (typeof slot === 'function') {
|
|
7002
|
+
if (slot !== fn)
|
|
7003
|
+
base[listName] = [slot, fn];
|
|
7004
|
+
}
|
|
7005
|
+
else if (!slot.includes(fn))
|
|
7006
|
+
slot.push(fn);
|
|
6804
7007
|
}
|
|
6805
7008
|
return true;
|
|
6806
7009
|
}
|
|
6807
7010
|
function ParseProps(props, component) {
|
|
6808
7011
|
if (props) {
|
|
6809
|
-
if (component.motif.options.props) {
|
|
6810
|
-
Object.assign(component.motif.options.props, props);
|
|
6811
|
-
}
|
|
6812
|
-
else {
|
|
6813
|
-
component.motif.options.props = {};
|
|
6814
|
-
Object.assign(component.motif.options.props, props);
|
|
6815
|
-
}
|
|
6816
7012
|
var keys = Object.keys(props);
|
|
6817
7013
|
if (keys.length === 0)
|
|
6818
|
-
return;
|
|
7014
|
+
return false;
|
|
6819
7015
|
keys.forEach(key => {
|
|
6820
7016
|
if (key == 'initializeComponent' || key == 'oninitializeComponent' || key.startsWith('on')) {
|
|
6821
7017
|
if (collectLifecycleHandlers(component, key.toLowerCase(), props[key])) {
|
|
@@ -6826,6 +7022,7 @@
|
|
|
6826
7022
|
else if (key == 'childs') {
|
|
6827
7023
|
const flat = [].concat(...props[key]);
|
|
6828
7024
|
component.childs = flat;
|
|
7025
|
+
disposeUnplacedChilds(component, flat);
|
|
6829
7026
|
delete props[key];
|
|
6830
7027
|
}
|
|
6831
7028
|
else if (key === 'transition') {
|
|
@@ -6870,9 +7067,14 @@
|
|
|
6870
7067
|
component.motif.options._preconfig = props[key];
|
|
6871
7068
|
delete props[key];
|
|
6872
7069
|
}
|
|
7070
|
+
else if (key === '__childExpr') {
|
|
7071
|
+
delete props[key];
|
|
7072
|
+
}
|
|
6873
7073
|
else ;
|
|
6874
7074
|
});
|
|
7075
|
+
return typeof props === 'object' && Reflect.ownKeys(props).length === 0;
|
|
6875
7076
|
}
|
|
7077
|
+
return false;
|
|
6876
7078
|
}
|
|
6877
7079
|
const _transitionSources = new WeakMap();
|
|
6878
7080
|
function setTransition(component, value, live) {
|
|
@@ -7043,6 +7245,16 @@
|
|
|
7043
7245
|
function isFallthroughKey(key) {
|
|
7044
7246
|
return FALLTHROUGH_KEYS.has(key) || key.startsWith('aria-') || key.startsWith('data-');
|
|
7045
7247
|
}
|
|
7248
|
+
let constructingComponentRoot = false;
|
|
7249
|
+
function constructComponentRoot(make) {
|
|
7250
|
+
constructingComponentRoot = true;
|
|
7251
|
+
try {
|
|
7252
|
+
return make();
|
|
7253
|
+
}
|
|
7254
|
+
finally {
|
|
7255
|
+
constructingComponentRoot = false;
|
|
7256
|
+
}
|
|
7257
|
+
}
|
|
7046
7258
|
function applyFallthroughProps(props, component) {
|
|
7047
7259
|
if (!props || typeof props !== 'object' || component.isDisposed)
|
|
7048
7260
|
return;
|
|
@@ -7092,35 +7304,51 @@
|
|
|
7092
7304
|
return null;
|
|
7093
7305
|
}, 'findAppendableComponent', null);
|
|
7094
7306
|
}
|
|
7307
|
+
const attachWaiters = new Set();
|
|
7308
|
+
let attachObserver = null;
|
|
7309
|
+
function releaseAttachObserver() {
|
|
7310
|
+
if (attachWaiters.size || !attachObserver) {
|
|
7311
|
+
return;
|
|
7312
|
+
}
|
|
7313
|
+
try {
|
|
7314
|
+
attachObserver.disconnect();
|
|
7315
|
+
}
|
|
7316
|
+
catch { /* ignore */ }
|
|
7317
|
+
attachObserver = null;
|
|
7318
|
+
}
|
|
7319
|
+
function flushAttachWaiters() {
|
|
7320
|
+
for (const waiter of [...attachWaiters]) {
|
|
7321
|
+
if (!attachWaiters.has(waiter) || !document.contains(waiter.element)) {
|
|
7322
|
+
continue;
|
|
7323
|
+
}
|
|
7324
|
+
attachWaiters.delete(waiter);
|
|
7325
|
+
try {
|
|
7326
|
+
waiter.callback();
|
|
7327
|
+
}
|
|
7328
|
+
catch (error) {
|
|
7329
|
+
queueMicrotask(() => { throw error; });
|
|
7330
|
+
}
|
|
7331
|
+
}
|
|
7332
|
+
releaseAttachObserver();
|
|
7333
|
+
}
|
|
7095
7334
|
function onElementAttached(element, callback) {
|
|
7096
7335
|
if (document.contains(element)) {
|
|
7097
7336
|
callback();
|
|
7098
7337
|
return null;
|
|
7099
7338
|
}
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
}
|
|
7110
|
-
});
|
|
7111
|
-
observer.observe(document.documentElement, {
|
|
7112
|
-
childList: true,
|
|
7113
|
-
subtree: true,
|
|
7114
|
-
});
|
|
7339
|
+
const waiter = { element, callback };
|
|
7340
|
+
attachWaiters.add(waiter);
|
|
7341
|
+
if (!attachObserver) {
|
|
7342
|
+
attachObserver = new MutationObserver(flushAttachWaiters);
|
|
7343
|
+
attachObserver.observe(document.documentElement, {
|
|
7344
|
+
childList: true,
|
|
7345
|
+
subtree: true,
|
|
7346
|
+
});
|
|
7347
|
+
}
|
|
7115
7348
|
return () => {
|
|
7116
|
-
if (
|
|
7117
|
-
|
|
7349
|
+
if (attachWaiters.delete(waiter)) {
|
|
7350
|
+
releaseAttachObserver();
|
|
7118
7351
|
}
|
|
7119
|
-
done = true;
|
|
7120
|
-
try {
|
|
7121
|
-
observer.disconnect();
|
|
7122
|
-
}
|
|
7123
|
-
catch { /* ignore */ }
|
|
7124
7352
|
};
|
|
7125
7353
|
}
|
|
7126
7354
|
function notifyActivated(component) {
|
|
@@ -7176,8 +7404,6 @@
|
|
|
7176
7404
|
return dom.createElement(tag, props);
|
|
7177
7405
|
}
|
|
7178
7406
|
class Component extends ComponentBase {
|
|
7179
|
-
static elementTag;
|
|
7180
|
-
static elementNamespace;
|
|
7181
7407
|
constructor() {
|
|
7182
7408
|
const derivedCtor = new.target;
|
|
7183
7409
|
var args = arguments;
|
|
@@ -7257,9 +7483,11 @@
|
|
|
7257
7483
|
// Alt sınıflar initializeComponent'i ezdiği için FragmentNode.initializeComponent'e güvenilemez.
|
|
7258
7484
|
const kids = this.childs;
|
|
7259
7485
|
if (Array.isArray(kids) && kids.length) {
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7486
|
+
if (derivedCtor?._placesChilds !== true) {
|
|
7487
|
+
for (const kid of kids) {
|
|
7488
|
+
if (kid)
|
|
7489
|
+
this.controls.add(kid);
|
|
7490
|
+
}
|
|
7263
7491
|
}
|
|
7264
7492
|
}
|
|
7265
7493
|
}
|
|
@@ -7281,6 +7509,7 @@
|
|
|
7281
7509
|
if (!(target instanceof ComponentBase))
|
|
7282
7510
|
return target;
|
|
7283
7511
|
applyRefs(target, refs.concat(extractRefs(props)));
|
|
7512
|
+
disposeUnplacedChilds(target, props.childs);
|
|
7284
7513
|
// Fonksiyon bileşeni etiketindeki ortak öznitelikler (class/id/aria-*…) döndürülen köke düşer.
|
|
7285
7514
|
// Kök `<div {...props}/>` ise aynı değerler zaten uygulanmıştır; ikinci kez uygulanmaz.
|
|
7286
7515
|
applyFallthroughProps(props, target);
|
|
@@ -7291,8 +7520,7 @@
|
|
|
7291
7520
|
const runover = props.runover;
|
|
7292
7521
|
if (!runover || typeof runover !== 'object')
|
|
7293
7522
|
return target;
|
|
7294
|
-
const
|
|
7295
|
-
const configuredBefore = Array.isArray(handlers) ? handlers.length : 0;
|
|
7523
|
+
const configuredBefore = handlerCount(target, '_onConfigHandlers');
|
|
7296
7524
|
const initializingBefore = handlerCount(target, '_onInitializingHandlers');
|
|
7297
7525
|
const initializedBefore = handlerCount(target, '_onInitializedHandlers');
|
|
7298
7526
|
ParseProps(runover, target);
|
|
@@ -7306,12 +7534,9 @@
|
|
|
7306
7534
|
if (typeof pre === 'function') {
|
|
7307
7535
|
safeCallSilent(() => pre(target), 'motifComponent.preconfig');
|
|
7308
7536
|
}
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
const fn = after[i];
|
|
7313
|
-
callReported(() => fn(target, { cancel: false }), 'MJX122', 'onConfig');
|
|
7314
|
-
}
|
|
7537
|
+
for (let i = configuredBefore; i < handlerCount(target, '_onConfigHandlers'); i++) {
|
|
7538
|
+
const fn = hookList(target, '_onConfigHandlers')[i];
|
|
7539
|
+
callReported(() => fn(target, { cancel: false }), 'MJX122', 'onConfig');
|
|
7315
7540
|
}
|
|
7316
7541
|
}
|
|
7317
7542
|
return target;
|
|
@@ -7324,18 +7549,18 @@
|
|
|
7324
7549
|
}
|
|
7325
7550
|
return target;
|
|
7326
7551
|
}
|
|
7552
|
+
function hookList(target, listName) {
|
|
7553
|
+
const slot = target._base?.[listName];
|
|
7554
|
+
return !slot ? [] : typeof slot === 'function' ? [slot] : slot;
|
|
7555
|
+
}
|
|
7327
7556
|
function handlerCount(target, listName) {
|
|
7328
|
-
|
|
7329
|
-
return Array.isArray(list) ? list.length : 0;
|
|
7557
|
+
return hookList(target, listName).length;
|
|
7330
7558
|
}
|
|
7331
7559
|
function callAddedHandlers(target, listName, from, hook) {
|
|
7332
|
-
|
|
7333
|
-
if (!Array.isArray(list))
|
|
7334
|
-
return;
|
|
7335
|
-
for (let i = from; i < list.length; i++) {
|
|
7560
|
+
for (let i = from; i < handlerCount(target, listName); i++) {
|
|
7336
7561
|
if (target.isDisposed)
|
|
7337
7562
|
return;
|
|
7338
|
-
const fn =
|
|
7563
|
+
const fn = hookList(target, listName)[i];
|
|
7339
7564
|
callReported(() => fn(target, { cancel: false }), 'MJX122', hook);
|
|
7340
7565
|
}
|
|
7341
7566
|
}
|
|
@@ -7358,6 +7583,11 @@
|
|
|
7358
7583
|
function motifComponent(element, props) {
|
|
7359
7584
|
// Etiket adı: element yaratımı (HTML/SVG) ve spread prop uygulaması Component ctor'ının string parametresinde
|
|
7360
7585
|
if (typeof element === "string") {
|
|
7586
|
+
if (typeof props === "function") {
|
|
7587
|
+
const compiled = new Component(element);
|
|
7588
|
+
compiled._init = props;
|
|
7589
|
+
return compiled;
|
|
7590
|
+
}
|
|
7361
7591
|
if (element === "text" && props && props.__childExpr) {
|
|
7362
7592
|
const resolved = resolveChildExpression(props.__childExpr);
|
|
7363
7593
|
if (resolved !== undefined)
|
|
@@ -7419,7 +7649,9 @@
|
|
|
7419
7649
|
return resolved;
|
|
7420
7650
|
}
|
|
7421
7651
|
function materializeOptionsObject(spec, props) {
|
|
7422
|
-
const result =
|
|
7652
|
+
const result = typeof spec.el === 'string'
|
|
7653
|
+
? constructComponentRoot(() => motifComponent(spec.el, props))
|
|
7654
|
+
: motifComponent(spec.el, props);
|
|
7423
7655
|
Object.getOwnPropertyNames(spec).forEach(key => {
|
|
7424
7656
|
if (key !== 'el' && key !== 'ctor') {
|
|
7425
7657
|
result[key] = spec[key];
|
|
@@ -7455,7 +7687,7 @@
|
|
|
7455
7687
|
}
|
|
7456
7688
|
}
|
|
7457
7689
|
safeCallSilent(() => {
|
|
7458
|
-
const nodes = this.
|
|
7690
|
+
const nodes = this.props?.nodes;
|
|
7459
7691
|
if (Array.isArray(nodes) && nodes.length) {
|
|
7460
7692
|
for (const n of nodes) {
|
|
7461
7693
|
if (n)
|
|
@@ -7617,11 +7849,10 @@
|
|
|
7617
7849
|
|
|
7618
7850
|
// import { dom } from "../browser";
|
|
7619
7851
|
class ControlCollection {
|
|
7620
|
-
owner;
|
|
7621
7852
|
constructor(owner) {
|
|
7622
7853
|
this.owner = owner;
|
|
7854
|
+
this.items = [];
|
|
7623
7855
|
}
|
|
7624
|
-
items = [];
|
|
7625
7856
|
add() {
|
|
7626
7857
|
const count = arguments.length;
|
|
7627
7858
|
if (count === 0)
|
|
@@ -7701,7 +7932,7 @@
|
|
|
7701
7932
|
this.items.splice(index, 1);
|
|
7702
7933
|
if (control.isDisposed)
|
|
7703
7934
|
return Promise.resolve();
|
|
7704
|
-
control.
|
|
7935
|
+
control._leaveContainer = this.owner;
|
|
7705
7936
|
control.parent = null;
|
|
7706
7937
|
return runLeaveThenDetach(control, () => { if (this.onRemove)
|
|
7707
7938
|
this.onRemove(control); });
|
|
@@ -7731,7 +7962,7 @@
|
|
|
7731
7962
|
if (index === -1)
|
|
7732
7963
|
return;
|
|
7733
7964
|
this.items.splice(index, 1);
|
|
7734
|
-
control.
|
|
7965
|
+
control._leaveContainer = this.owner;
|
|
7735
7966
|
control.parent = null;
|
|
7736
7967
|
}
|
|
7737
7968
|
async clearAsync() {
|
|
@@ -7756,9 +7987,6 @@
|
|
|
7756
7987
|
map(callbackfn) {
|
|
7757
7988
|
return this.items.map(callbackfn);
|
|
7758
7989
|
}
|
|
7759
|
-
onAdd;
|
|
7760
|
-
onRemove;
|
|
7761
|
-
onAddBeforeBuild;
|
|
7762
7990
|
move(control, before) {
|
|
7763
7991
|
if (!control || control.isDisposed)
|
|
7764
7992
|
return;
|
|
@@ -7786,14 +8014,29 @@
|
|
|
7786
8014
|
const insertAt = newBeforeIndex >= 0 ? newBeforeIndex : this.items.length;
|
|
7787
8015
|
this.items.splice(insertAt, 0, control);
|
|
7788
8016
|
}
|
|
7789
|
-
if (control.isWait) {
|
|
7790
|
-
return;
|
|
7791
|
-
}
|
|
7792
8017
|
const container = findAppendableElement(this.owner);
|
|
7793
|
-
if (!container)
|
|
8018
|
+
if (!container || !domAnchor(control, container))
|
|
7794
8019
|
return;
|
|
7795
|
-
const
|
|
7796
|
-
moveComponentDomRange(control, container,
|
|
8020
|
+
const at = before ? this.items.indexOf(before) : -1;
|
|
8021
|
+
moveComponentDomRange(control, container, at >= 0 ? anchorFrom(this.owner, this.items, at, container) : computeAppendReference(this.owner));
|
|
8022
|
+
}
|
|
8023
|
+
_reorder(order, stable) {
|
|
8024
|
+
const container = findAppendableElement(this.owner);
|
|
8025
|
+
if (container) {
|
|
8026
|
+
let ref = computeAppendReference(this.owner);
|
|
8027
|
+
for (let i = order.length - 1; i >= 0; i--) {
|
|
8028
|
+
const control = order[i];
|
|
8029
|
+
const node = domAnchor(control, container);
|
|
8030
|
+
if (!node)
|
|
8031
|
+
continue;
|
|
8032
|
+
if (!stable.has(i))
|
|
8033
|
+
moveComponentDomRange(control, container, ref);
|
|
8034
|
+
ref = node;
|
|
8035
|
+
}
|
|
8036
|
+
}
|
|
8037
|
+
const items = this.items;
|
|
8038
|
+
for (let i = 0; i < order.length; i++)
|
|
8039
|
+
items[i] = order[i];
|
|
7797
8040
|
}
|
|
7798
8041
|
moveToIndex(control, index) {
|
|
7799
8042
|
if (!control || control.isDisposed)
|
|
@@ -7830,12 +8073,20 @@
|
|
|
7830
8073
|
}
|
|
7831
8074
|
return null;
|
|
7832
8075
|
}
|
|
8076
|
+
function anchorFrom(owner, items, start, container) {
|
|
8077
|
+
for (let i = start; i < items.length; i++) {
|
|
8078
|
+
const anchor = domAnchor(items[i], container);
|
|
8079
|
+
if (anchor)
|
|
8080
|
+
return anchor;
|
|
8081
|
+
}
|
|
8082
|
+
return computeAppendReference(owner);
|
|
8083
|
+
}
|
|
7833
8084
|
/** Bir component'in kök DOM aralığını (tek element veya fragment aralığı) referenceNode öncesine taşır. */
|
|
7834
8085
|
function moveComponentDomRange(control, container, referenceNode) {
|
|
7835
|
-
const node = control
|
|
8086
|
+
const node = domAnchor(control, container);
|
|
7836
8087
|
if (!node)
|
|
7837
8088
|
return;
|
|
7838
|
-
if (node.nodeType !== Node.COMMENT_NODE) {
|
|
8089
|
+
if (node.nodeType !== Node.COMMENT_NODE || node !== control.element) {
|
|
7839
8090
|
try {
|
|
7840
8091
|
container.insertBefore(node, referenceNode);
|
|
7841
8092
|
}
|
|
@@ -7918,9 +8169,7 @@
|
|
|
7918
8169
|
if (!node)
|
|
7919
8170
|
return;
|
|
7920
8171
|
const opts = control.motif.options;
|
|
7921
|
-
if (node.nodeType === Node.COMMENT_NODE) {
|
|
7922
|
-
if (!node.parentNode)
|
|
7923
|
-
return;
|
|
8172
|
+
if (node.nodeType === Node.COMMENT_NODE && node.parentNode) {
|
|
7924
8173
|
const close = opts?.closeFragment || null;
|
|
7925
8174
|
const cache = opts.cache ?? (opts.cache = dom.createDocumentFragment());
|
|
7926
8175
|
let current = node;
|
|
@@ -8393,13 +8642,12 @@
|
|
|
8393
8642
|
}
|
|
8394
8643
|
|
|
8395
8644
|
class Frame extends Component {
|
|
8396
|
-
current = null;
|
|
8397
|
-
_latestNavigateId = 0;
|
|
8398
|
-
_navLock = Promise.resolve();
|
|
8399
|
-
_navAbort;
|
|
8400
|
-
isBusy = false;
|
|
8401
8645
|
constructor(props) {
|
|
8402
8646
|
super(dom.createComment(''), props);
|
|
8647
|
+
this.current = null;
|
|
8648
|
+
this._latestNavigateId = 0;
|
|
8649
|
+
this._navLock = Promise.resolve();
|
|
8650
|
+
this.isBusy = false;
|
|
8403
8651
|
if (props && props.childs && Array.isArray(props.childs) && props.childs.length > 0) {
|
|
8404
8652
|
this.controls.add(props.childs);
|
|
8405
8653
|
}
|
|
@@ -8414,7 +8662,6 @@
|
|
|
8414
8662
|
async _clear() {
|
|
8415
8663
|
await disposeNavigationTarget(this.current);
|
|
8416
8664
|
}
|
|
8417
|
-
previouspage;
|
|
8418
8665
|
async navigate(page, keepOldControl = false) {
|
|
8419
8666
|
await navigateHost(this, page, keepOldControl);
|
|
8420
8667
|
}
|
|
@@ -8508,7 +8755,7 @@
|
|
|
8508
8755
|
const SLOT_REGISTERED_EVENT = Symbol('slotRegistered');
|
|
8509
8756
|
const SLOT_UNREGISTERED_EVENT = Symbol('slotUnregistered');
|
|
8510
8757
|
class TransportRegistry {
|
|
8511
|
-
static slots = new Map();
|
|
8758
|
+
static { this.slots = new Map(); }
|
|
8512
8759
|
static registerSlot(name, slot) {
|
|
8513
8760
|
this.slots.set(name, slot);
|
|
8514
8761
|
Application.main.fire(SLOT_REGISTERED_EVENT, { name, slot });
|
|
@@ -8525,7 +8772,6 @@
|
|
|
8525
8772
|
}
|
|
8526
8773
|
|
|
8527
8774
|
class Transport extends Component {
|
|
8528
|
-
mode;
|
|
8529
8775
|
constructor(props) {
|
|
8530
8776
|
super(props);
|
|
8531
8777
|
this.mode = props.mode || 'replace';
|
|
@@ -8613,28 +8859,34 @@
|
|
|
8613
8859
|
}
|
|
8614
8860
|
|
|
8615
8861
|
class TransportTo extends Component {
|
|
8616
|
-
_onAddRef;
|
|
8617
|
-
_onRemoveRef;
|
|
8618
|
-
_slotRegisteredListener;
|
|
8619
|
-
_slotUnregisteredListener;
|
|
8620
|
-
_transported = [];
|
|
8621
|
-
_countedLive = false;
|
|
8622
8862
|
constructor(props) {
|
|
8623
8863
|
super('div', props);
|
|
8864
|
+
this._transported = [];
|
|
8865
|
+
this._countedLive = false;
|
|
8866
|
+
this._handleSlotChange = (eventArgs) => {
|
|
8867
|
+
if (eventArgs.name === this.props.name) {
|
|
8868
|
+
const slot = eventArgs.slot;
|
|
8869
|
+
if (slot.mode !== 'merge') {
|
|
8870
|
+
slot.clearSlot?.();
|
|
8871
|
+
}
|
|
8872
|
+
const all = [...(this.childs || []), ...this.controls.items];
|
|
8873
|
+
Transporter.transportMany(all, slot);
|
|
8874
|
+
this._rememberTransported(all);
|
|
8875
|
+
}
|
|
8876
|
+
};
|
|
8877
|
+
this._clearChildrenFromSlot = (slot) => {
|
|
8878
|
+
(this.childs || []).forEach(child => {
|
|
8879
|
+
slot.controls.remove(child);
|
|
8880
|
+
child.dispose();
|
|
8881
|
+
});
|
|
8882
|
+
(this.controls.items || []).forEach(child => {
|
|
8883
|
+
slot.controls.remove(child);
|
|
8884
|
+
child.dispose();
|
|
8885
|
+
});
|
|
8886
|
+
};
|
|
8624
8887
|
contentBlocks.live++;
|
|
8625
8888
|
this._countedLive = true;
|
|
8626
8889
|
}
|
|
8627
|
-
_handleSlotChange = (eventArgs) => {
|
|
8628
|
-
if (eventArgs.name === this.props.name) {
|
|
8629
|
-
const slot = eventArgs.slot;
|
|
8630
|
-
if (slot.mode !== 'merge') {
|
|
8631
|
-
slot.clearSlot?.();
|
|
8632
|
-
}
|
|
8633
|
-
const all = [...(this.childs || []), ...this.controls.items];
|
|
8634
|
-
Transporter.transportMany(all, slot);
|
|
8635
|
-
this._rememberTransported(all);
|
|
8636
|
-
}
|
|
8637
|
-
};
|
|
8638
8890
|
_rememberTransported(children) {
|
|
8639
8891
|
const kept = this._transported.filter(c => !c.isDisposed);
|
|
8640
8892
|
for (const child of children) {
|
|
@@ -8643,16 +8895,6 @@
|
|
|
8643
8895
|
}
|
|
8644
8896
|
this._transported = kept;
|
|
8645
8897
|
}
|
|
8646
|
-
_clearChildrenFromSlot = (slot) => {
|
|
8647
|
-
(this.childs || []).forEach(child => {
|
|
8648
|
-
slot.controls.remove(child);
|
|
8649
|
-
child.dispose();
|
|
8650
|
-
});
|
|
8651
|
-
(this.controls.items || []).forEach(child => {
|
|
8652
|
-
slot.controls.remove(child);
|
|
8653
|
-
child.dispose();
|
|
8654
|
-
});
|
|
8655
|
-
};
|
|
8656
8898
|
initializeComponent(sender) {
|
|
8657
8899
|
let slot = TransportRegistry.getSlot(this.props.name);
|
|
8658
8900
|
if (slot) {
|
|
@@ -8852,11 +9094,10 @@
|
|
|
8852
9094
|
];
|
|
8853
9095
|
const isLookupMiss = (outcome) => outcome === false || outcome === -1;
|
|
8854
9096
|
class ArrayMethods {
|
|
8855
|
-
engine;
|
|
8856
9097
|
constructor(engine) {
|
|
8857
9098
|
this.engine = engine;
|
|
9099
|
+
this.get = this.createArrayMethods();
|
|
8858
9100
|
}
|
|
8859
|
-
get = this.createArrayMethods();
|
|
8860
9101
|
createArrayMethods() {
|
|
8861
9102
|
const table = {};
|
|
8862
9103
|
for (const [name, kind] of PATCHED_ARRAY_METHODS) {
|
|
@@ -9048,7 +9289,6 @@
|
|
|
9048
9289
|
const AllreactiveMap = new WeakMap();
|
|
9049
9290
|
function armgetter() { return AllreactiveMap; }
|
|
9050
9291
|
class ReactiveEngine {
|
|
9051
|
-
_gci;
|
|
9052
9292
|
startGc(_intervalMs = 10000) { }
|
|
9053
9293
|
stopGc() { if (this._gci) {
|
|
9054
9294
|
try {
|
|
@@ -9058,31 +9298,30 @@
|
|
|
9058
9298
|
this._gci = undefined;
|
|
9059
9299
|
} }
|
|
9060
9300
|
constructor() {
|
|
9301
|
+
this.DisposeMapper = new LinkedList();
|
|
9302
|
+
this.arrayTriggerCache = new Map();
|
|
9303
|
+
this.ReactiveMap = () => armgetter();
|
|
9304
|
+
this.isReadonly = false;
|
|
9305
|
+
this.superficial = false;
|
|
9306
|
+
this.arrayMethods = new ArrayMethods(this);
|
|
9307
|
+
this.arrayHandler = {
|
|
9308
|
+
get: createGetter(this),
|
|
9309
|
+
set: createSetter(this),
|
|
9310
|
+
has: createHas(),
|
|
9311
|
+
deleteProperty: createDelete(),
|
|
9312
|
+
ownKeys: createOwn()
|
|
9313
|
+
};
|
|
9314
|
+
this.deepHandler = {
|
|
9315
|
+
get: createGetter(this),
|
|
9316
|
+
set: createSetter(this),
|
|
9317
|
+
has: createHas(),
|
|
9318
|
+
deleteProperty: createDelete(),
|
|
9319
|
+
ownKeys: createOwn()
|
|
9320
|
+
};
|
|
9321
|
+
this.collectionHandler = createCollectionHandler(this);
|
|
9061
9322
|
ReactiveEngineMapper.add(this);
|
|
9062
9323
|
this.startGc();
|
|
9063
9324
|
}
|
|
9064
|
-
DisposeMapper = new LinkedList();
|
|
9065
|
-
arrayTriggerCache = new Map();
|
|
9066
|
-
ReactiveMap = () => armgetter();
|
|
9067
|
-
activeCallback;
|
|
9068
|
-
isReadonly = false;
|
|
9069
|
-
superficial = false;
|
|
9070
|
-
arrayMethods = new ArrayMethods(this);
|
|
9071
|
-
arrayHandler = {
|
|
9072
|
-
get: createGetter(this),
|
|
9073
|
-
set: createSetter(this),
|
|
9074
|
-
has: createHas(),
|
|
9075
|
-
deleteProperty: createDelete(),
|
|
9076
|
-
ownKeys: createOwn()
|
|
9077
|
-
};
|
|
9078
|
-
deepHandler = {
|
|
9079
|
-
get: createGetter(this),
|
|
9080
|
-
set: createSetter(this),
|
|
9081
|
-
has: createHas(),
|
|
9082
|
-
deleteProperty: createDelete(),
|
|
9083
|
-
ownKeys: createOwn()
|
|
9084
|
-
};
|
|
9085
|
-
collectionHandler = createCollectionHandler(this);
|
|
9086
9325
|
reactive(model) {
|
|
9087
9326
|
if (!isObject(model)) {
|
|
9088
9327
|
model = { value: model };
|
|
@@ -9145,7 +9384,6 @@
|
|
|
9145
9384
|
ArrayTrigger(target, key, ...args) {
|
|
9146
9385
|
this.trigger(target, key, args);
|
|
9147
9386
|
}
|
|
9148
|
-
onValueChanged;
|
|
9149
9387
|
toRaw(item) {
|
|
9150
9388
|
return JSON.parse(JSON.stringify(this.deepClone(item)));
|
|
9151
9389
|
}
|
|
@@ -9320,19 +9558,35 @@
|
|
|
9320
9558
|
}
|
|
9321
9559
|
|
|
9322
9560
|
class Virtualization extends Component {
|
|
9323
|
-
_state;
|
|
9324
|
-
_virtualContent;
|
|
9325
|
-
_topSpacer;
|
|
9326
|
-
_bottomSpacer;
|
|
9327
|
-
_cache = new Map();
|
|
9328
|
-
_view = [];
|
|
9329
|
-
_occurrence = [];
|
|
9330
|
-
_occurrenceKeys = new WeakMap();
|
|
9331
|
-
_isLoadingMore = false;
|
|
9332
|
-
_emptyRendered = false;
|
|
9333
|
-
_renderPending = false;
|
|
9334
9561
|
constructor(props) {
|
|
9335
9562
|
super('div', props);
|
|
9563
|
+
this._cache = new Map();
|
|
9564
|
+
this._view = [];
|
|
9565
|
+
this._occurrence = [];
|
|
9566
|
+
this._occurrenceKeys = new WeakMap();
|
|
9567
|
+
this._isLoadingMore = false;
|
|
9568
|
+
this._emptyRendered = false;
|
|
9569
|
+
this._renderPending = false;
|
|
9570
|
+
this.contentWrapper = new Component();
|
|
9571
|
+
this._initialLoadStarted = false;
|
|
9572
|
+
this._offsets = null;
|
|
9573
|
+
this._observedHeight = -1;
|
|
9574
|
+
this._loadSeq = 0;
|
|
9575
|
+
this._reloadScheduled = false;
|
|
9576
|
+
this._reloadTimes = [];
|
|
9577
|
+
this._handleScroll = (_sender, _event) => {
|
|
9578
|
+
this.renderViewport();
|
|
9579
|
+
if (this.props.autoLoad === false)
|
|
9580
|
+
return;
|
|
9581
|
+
if (!this._state.hasMore || this._isLoadingMore || !this._state.isInitialized)
|
|
9582
|
+
return;
|
|
9583
|
+
const el = this.wrapper.element;
|
|
9584
|
+
const fixed = this._fixedHeight();
|
|
9585
|
+
const loadedBottom = fixed !== null ? this._state.data.length * fixed : this._offsetOf(this._view.length);
|
|
9586
|
+
const distanceToLoaded = loadedBottom - (el.scrollTop + el.clientHeight);
|
|
9587
|
+
if (distanceToLoaded < (this.props.autoLoadThreshold ?? 100))
|
|
9588
|
+
void this._loadMore();
|
|
9589
|
+
};
|
|
9336
9590
|
if (props.className)
|
|
9337
9591
|
this.class.add(props.className);
|
|
9338
9592
|
if (props.style)
|
|
@@ -9354,8 +9608,6 @@
|
|
|
9354
9608
|
this.renderViewport = this.renderViewport.bind(this);
|
|
9355
9609
|
this._makeView();
|
|
9356
9610
|
}
|
|
9357
|
-
contentWrapper = new Component();
|
|
9358
|
-
wrapper;
|
|
9359
9611
|
_makeView() {
|
|
9360
9612
|
this._topSpacer = new Component('div');
|
|
9361
9613
|
this._topSpacer.element.style.cssText = 'height: 0px;';
|
|
@@ -9384,7 +9636,6 @@
|
|
|
9384
9636
|
this.motif.on('scroll', this._handleScroll);
|
|
9385
9637
|
}
|
|
9386
9638
|
}
|
|
9387
|
-
_initialLoadStarted = false;
|
|
9388
9639
|
onBuilding() {
|
|
9389
9640
|
if (this.props.mainTemplate || this._initialLoadStarted)
|
|
9390
9641
|
return;
|
|
@@ -9401,10 +9652,6 @@
|
|
|
9401
9652
|
this._stopDataWatch();
|
|
9402
9653
|
this._clearContent();
|
|
9403
9654
|
}
|
|
9404
|
-
_offsets = null;
|
|
9405
|
-
_resizeObserver;
|
|
9406
|
-
_observed;
|
|
9407
|
-
_observedHeight = -1;
|
|
9408
9655
|
_fixedHeight() {
|
|
9409
9656
|
const h = this.props.itemHeight;
|
|
9410
9657
|
return typeof h === 'function' ? null : h;
|
|
@@ -9486,10 +9733,6 @@
|
|
|
9486
9733
|
this._resizeObserver = undefined;
|
|
9487
9734
|
this._observed = undefined;
|
|
9488
9735
|
}
|
|
9489
|
-
_loadSeq = 0;
|
|
9490
|
-
_dataWatchStop;
|
|
9491
|
-
_reloadScheduled = false;
|
|
9492
|
-
_reloadTimes = [];
|
|
9493
9736
|
_stopDataWatch() {
|
|
9494
9737
|
this._dataWatchStop?.();
|
|
9495
9738
|
this._dataWatchStop = undefined;
|
|
@@ -9588,19 +9831,6 @@
|
|
|
9588
9831
|
this._renderErrorState(error);
|
|
9589
9832
|
}
|
|
9590
9833
|
}
|
|
9591
|
-
_handleScroll = (_sender, _event) => {
|
|
9592
|
-
this.renderViewport();
|
|
9593
|
-
if (this.props.autoLoad === false)
|
|
9594
|
-
return;
|
|
9595
|
-
if (!this._state.hasMore || this._isLoadingMore || !this._state.isInitialized)
|
|
9596
|
-
return;
|
|
9597
|
-
const el = this.wrapper.element;
|
|
9598
|
-
const fixed = this._fixedHeight();
|
|
9599
|
-
const loadedBottom = fixed !== null ? this._state.data.length * fixed : this._offsetOf(this._view.length);
|
|
9600
|
-
const distanceToLoaded = loadedBottom - (el.scrollTop + el.clientHeight);
|
|
9601
|
-
if (distanceToLoaded < (this.props.autoLoadThreshold ?? 100))
|
|
9602
|
-
void this._loadMore();
|
|
9603
|
-
};
|
|
9604
9834
|
async _loadInitial() {
|
|
9605
9835
|
const seq = ++this._loadSeq;
|
|
9606
9836
|
this._state.isLoading = true;
|
|
@@ -9919,7 +10149,9 @@
|
|
|
9919
10149
|
}
|
|
9920
10150
|
}
|
|
9921
10151
|
class ServiceCollection {
|
|
9922
|
-
|
|
10152
|
+
constructor() {
|
|
10153
|
+
this.descriptors = new Map();
|
|
10154
|
+
}
|
|
9923
10155
|
reset() {
|
|
9924
10156
|
this.descriptors.clear();
|
|
9925
10157
|
}
|
|
@@ -10176,7 +10408,7 @@
|
|
|
10176
10408
|
}
|
|
10177
10409
|
|
|
10178
10410
|
class RouterViewRegistry {
|
|
10179
|
-
static outlets = new Map();
|
|
10411
|
+
static { this.outlets = new Map(); }
|
|
10180
10412
|
static register(name, scopeId, instance) {
|
|
10181
10413
|
if (!this.outlets.has(name))
|
|
10182
10414
|
this.outlets.set(name, new Map());
|
|
@@ -10205,9 +10437,12 @@
|
|
|
10205
10437
|
class RouterView extends Component {
|
|
10206
10438
|
constructor(props) {
|
|
10207
10439
|
super(props);
|
|
10440
|
+
this._navLock = Promise.resolve();
|
|
10441
|
+
this.disposingChilds = false;
|
|
10442
|
+
this.current = null;
|
|
10443
|
+
this._latestNavigateId = 0;
|
|
10444
|
+
this.isBusy = false;
|
|
10208
10445
|
}
|
|
10209
|
-
_navLock = Promise.resolve();
|
|
10210
|
-
_navAbort;
|
|
10211
10446
|
get __isRouterView() {
|
|
10212
10447
|
return true;
|
|
10213
10448
|
}
|
|
@@ -10219,11 +10454,6 @@
|
|
|
10219
10454
|
}
|
|
10220
10455
|
return ids.join('>');
|
|
10221
10456
|
}
|
|
10222
|
-
disposingChilds = false;
|
|
10223
|
-
previouspage;
|
|
10224
|
-
current = null;
|
|
10225
|
-
_latestNavigateId = 0;
|
|
10226
|
-
isBusy = false;
|
|
10227
10457
|
async navigate(page, keepOldControl = false) {
|
|
10228
10458
|
await navigateHost(this, page, keepOldControl);
|
|
10229
10459
|
}
|
|
@@ -10254,17 +10484,16 @@
|
|
|
10254
10484
|
const DEFAULT_SETTLE_MS = 1200;
|
|
10255
10485
|
const USER_INPUT = ['wheel', 'touchstart', 'keydown', 'mousedown'];
|
|
10256
10486
|
class ScrollMemory {
|
|
10257
|
-
options;
|
|
10258
|
-
viewport;
|
|
10259
|
-
positions = new Map();
|
|
10260
|
-
currentKey = '';
|
|
10261
|
-
visited = false;
|
|
10262
|
-
restoring = false;
|
|
10263
|
-
cancelFrame = null;
|
|
10264
|
-
disarmAbort = null;
|
|
10265
|
-
offs = [];
|
|
10266
|
-
locationAnchor = true;
|
|
10267
10487
|
constructor(options = {}, viewport) {
|
|
10488
|
+
this.positions = new Map();
|
|
10489
|
+
this.currentKey = '';
|
|
10490
|
+
this.currentPath = null;
|
|
10491
|
+
this.visited = false;
|
|
10492
|
+
this.restoring = false;
|
|
10493
|
+
this.cancelFrame = null;
|
|
10494
|
+
this.disarmAbort = null;
|
|
10495
|
+
this.offs = [];
|
|
10496
|
+
this.locationAnchor = true;
|
|
10268
10497
|
this.options = options;
|
|
10269
10498
|
this.viewport = viewport ?? (options.container ? containerViewport(options.container) : windowViewport());
|
|
10270
10499
|
this.load();
|
|
@@ -10289,11 +10518,13 @@
|
|
|
10289
10518
|
this.remember(this.currentKey, this.viewport.scrollTop());
|
|
10290
10519
|
this.persist();
|
|
10291
10520
|
}
|
|
10292
|
-
arrived(uri) {
|
|
10521
|
+
arrived(uri, direction) {
|
|
10293
10522
|
this.visited = true;
|
|
10294
10523
|
const { path, hash } = splitUri(uri);
|
|
10524
|
+
const inPage = !!hash && path === this.currentPath && (direction === 'push' || direction === 'replace' || direction === 'traverse');
|
|
10525
|
+
this.currentPath = path;
|
|
10295
10526
|
this.currentKey = this.keyOf(path);
|
|
10296
|
-
this.restore(this.currentKey, this.options.anchor === false ? '' : hash || (this.locationAnchor ? locationHash() : ''));
|
|
10527
|
+
this.restore(this.currentKey, this.options.anchor === false ? '' : hash || (this.locationAnchor ? locationHash() : ''), inPage);
|
|
10297
10528
|
}
|
|
10298
10529
|
saved(key) {
|
|
10299
10530
|
return this.positions.get(this.keyOf(splitUri(key).path)) ?? 0;
|
|
@@ -10320,7 +10551,7 @@
|
|
|
10320
10551
|
this.positions.delete(oldest.value);
|
|
10321
10552
|
}
|
|
10322
10553
|
}
|
|
10323
|
-
restore(key, anchor) {
|
|
10554
|
+
restore(key, anchor, follow) {
|
|
10324
10555
|
this.cancelRestore();
|
|
10325
10556
|
const target = this.positions.get(key) ?? 0;
|
|
10326
10557
|
if (!anchor && target <= 0) {
|
|
@@ -10333,7 +10564,7 @@
|
|
|
10333
10564
|
const startedAt = Date.now();
|
|
10334
10565
|
const attempt = () => {
|
|
10335
10566
|
this.cancelFrame = null;
|
|
10336
|
-
const done = anchor ? this.viewport.scrollToAnchor(anchor) : this.reached(target);
|
|
10567
|
+
const done = anchor ? this.viewport.scrollToAnchor(anchor, follow) : this.reached(target);
|
|
10337
10568
|
if (done || Date.now() - startedAt >= settleMs) {
|
|
10338
10569
|
this.cancelRestore();
|
|
10339
10570
|
this.remember(key, this.viewport.scrollTop());
|
|
@@ -10425,16 +10656,30 @@
|
|
|
10425
10656
|
},
|
|
10426
10657
|
scrollTo: (top) => {
|
|
10427
10658
|
try {
|
|
10428
|
-
window.scrollTo(
|
|
10659
|
+
window.scrollTo({ top, behavior: 'instant' });
|
|
10660
|
+
}
|
|
10661
|
+
catch {
|
|
10662
|
+
try {
|
|
10663
|
+
window.scrollTo(0, top);
|
|
10664
|
+
}
|
|
10665
|
+
catch { }
|
|
10429
10666
|
}
|
|
10430
|
-
catch { }
|
|
10431
10667
|
},
|
|
10432
|
-
scrollToAnchor: (id) => {
|
|
10668
|
+
scrollToAnchor: (id, follow) => {
|
|
10433
10669
|
try {
|
|
10434
10670
|
const node = document.getElementById(id);
|
|
10435
10671
|
if (!node)
|
|
10436
10672
|
return false;
|
|
10437
|
-
|
|
10673
|
+
if (follow)
|
|
10674
|
+
node.scrollIntoView();
|
|
10675
|
+
else {
|
|
10676
|
+
try {
|
|
10677
|
+
node.scrollIntoView({ behavior: 'instant' });
|
|
10678
|
+
}
|
|
10679
|
+
catch {
|
|
10680
|
+
node.scrollIntoView();
|
|
10681
|
+
}
|
|
10682
|
+
}
|
|
10438
10683
|
return true;
|
|
10439
10684
|
}
|
|
10440
10685
|
catch {
|
|
@@ -10471,11 +10716,16 @@
|
|
|
10471
10716
|
return;
|
|
10472
10717
|
}
|
|
10473
10718
|
try {
|
|
10474
|
-
el.
|
|
10719
|
+
el.scrollTo({ top, behavior: 'instant' });
|
|
10720
|
+
}
|
|
10721
|
+
catch {
|
|
10722
|
+
try {
|
|
10723
|
+
el.scrollTop = top;
|
|
10724
|
+
}
|
|
10725
|
+
catch { }
|
|
10475
10726
|
}
|
|
10476
|
-
catch { }
|
|
10477
10727
|
},
|
|
10478
|
-
scrollToAnchor: (id) => fallback.scrollToAnchor(id),
|
|
10728
|
+
scrollToAnchor: (id, follow) => fallback.scrollToAnchor(id, follow),
|
|
10479
10729
|
};
|
|
10480
10730
|
}
|
|
10481
10731
|
/** `/docs/x#bolum` → `{ path: '/docs/x', hash: 'bolum' }`. */
|
|
@@ -10646,24 +10896,18 @@
|
|
|
10646
10896
|
}
|
|
10647
10897
|
}
|
|
10648
10898
|
class NavigationStack {
|
|
10649
|
-
retainAttached;
|
|
10650
|
-
depth;
|
|
10651
|
-
persist;
|
|
10652
|
-
animation;
|
|
10653
|
-
duration;
|
|
10654
|
-
swipe;
|
|
10655
|
-
session = null;
|
|
10656
|
-
entries = new Map();
|
|
10657
|
-
uris = new Map();
|
|
10658
|
-
loaded = null;
|
|
10659
|
-
current = null;
|
|
10660
|
-
currentTop = null;
|
|
10661
|
-
offs = [];
|
|
10662
|
-
gesture = null;
|
|
10663
|
-
gestureCommitted = false;
|
|
10664
|
-
awaitingGestureResult = false;
|
|
10665
|
-
disposed = false;
|
|
10666
10899
|
constructor(options) {
|
|
10900
|
+
this.session = null;
|
|
10901
|
+
this.entries = new Map();
|
|
10902
|
+
this.uris = new Map();
|
|
10903
|
+
this.loaded = null;
|
|
10904
|
+
this.current = null;
|
|
10905
|
+
this.currentTop = null;
|
|
10906
|
+
this.offs = [];
|
|
10907
|
+
this.gesture = null;
|
|
10908
|
+
this.gestureCommitted = false;
|
|
10909
|
+
this.awaitingGestureResult = false;
|
|
10910
|
+
this.disposed = false;
|
|
10667
10911
|
const o = options === true ? {} : options;
|
|
10668
10912
|
this.retainAttached = o.retain === true;
|
|
10669
10913
|
this.depth = Math.max(0, Math.floor(o.depth ?? 5));
|
|
@@ -11172,13 +11416,28 @@
|
|
|
11172
11416
|
}
|
|
11173
11417
|
|
|
11174
11418
|
class Scanner {
|
|
11175
|
-
source;
|
|
11176
11419
|
constructor(source) {
|
|
11177
11420
|
this.source = source;
|
|
11421
|
+
this.currentColumn = 0;
|
|
11422
|
+
this.tokens = [];
|
|
11423
|
+
this.parameters = {};
|
|
11424
|
+
this.codePointAt = String.prototype.codePointAt ?
|
|
11425
|
+
(s, i) => s.codePointAt(i) : function codePointAt(str, i) {
|
|
11426
|
+
const size = str.length;
|
|
11427
|
+
if (i < 0 || i >= size) {
|
|
11428
|
+
return undefined;
|
|
11429
|
+
}
|
|
11430
|
+
const first = str.charCodeAt(i);
|
|
11431
|
+
if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) {
|
|
11432
|
+
const second = str.charCodeAt(i + 1);
|
|
11433
|
+
if (second >= 0xDC00 && second <= 0xDFFF) {
|
|
11434
|
+
return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
|
|
11435
|
+
}
|
|
11436
|
+
}
|
|
11437
|
+
return first;
|
|
11438
|
+
};
|
|
11178
11439
|
this.tokens = [];
|
|
11179
11440
|
}
|
|
11180
|
-
currentColumn = 0;
|
|
11181
|
-
tokens = [];
|
|
11182
11441
|
addToken(token) {
|
|
11183
11442
|
this.tokens.push(token);
|
|
11184
11443
|
}
|
|
@@ -11406,7 +11665,6 @@
|
|
|
11406
11665
|
pattern += '$';
|
|
11407
11666
|
return new RegExp(pattern, "i");
|
|
11408
11667
|
}
|
|
11409
|
-
parameters = {};
|
|
11410
11668
|
exist(input, pageSearch) {
|
|
11411
11669
|
const hashIdx = input.indexOf('#');
|
|
11412
11670
|
const withoutHash = hashIdx >= 0 ? input.substring(0, hashIdx) : input;
|
|
@@ -11490,21 +11748,6 @@
|
|
|
11490
11748
|
}
|
|
11491
11749
|
return false;
|
|
11492
11750
|
}
|
|
11493
|
-
codePointAt = String.prototype.codePointAt ?
|
|
11494
|
-
(s, i) => s.codePointAt(i) : function codePointAt(str, i) {
|
|
11495
|
-
const size = str.length;
|
|
11496
|
-
if (i < 0 || i >= size) {
|
|
11497
|
-
return undefined;
|
|
11498
|
-
}
|
|
11499
|
-
const first = str.charCodeAt(i);
|
|
11500
|
-
if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) {
|
|
11501
|
-
const second = str.charCodeAt(i + 1);
|
|
11502
|
-
if (second >= 0xDC00 && second <= 0xDFFF) {
|
|
11503
|
-
return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
|
|
11504
|
-
}
|
|
11505
|
-
}
|
|
11506
|
-
return first;
|
|
11507
|
-
};
|
|
11508
11751
|
}
|
|
11509
11752
|
|
|
11510
11753
|
/** Bir fullPath'in statik (parametresiz) ve parametreli segment sayıları. */
|
|
@@ -11532,11 +11775,41 @@
|
|
|
11532
11775
|
return b.fullPath.length - a.fullPath.length;
|
|
11533
11776
|
}
|
|
11534
11777
|
class RouteCollection {
|
|
11535
|
-
routes;
|
|
11536
|
-
records = [];
|
|
11537
|
-
routesMap = new Map();
|
|
11538
11778
|
constructor(routes) {
|
|
11539
11779
|
this.routes = routes;
|
|
11780
|
+
this.records = [];
|
|
11781
|
+
this.routesMap = new Map();
|
|
11782
|
+
this.walk = (chain, parentPath, node, viaAlias = false) => {
|
|
11783
|
+
const fullPath = this.joinPaths(parentPath, node.path);
|
|
11784
|
+
if (!viaAlias) {
|
|
11785
|
+
const existing = node.fullPath;
|
|
11786
|
+
if (existing == null || (typeof existing === 'string' && existing.trim() === '')) {
|
|
11787
|
+
node.fullPath = fullPath;
|
|
11788
|
+
}
|
|
11789
|
+
if (node.name != null) {
|
|
11790
|
+
this.routesMap.set(node.name, node);
|
|
11791
|
+
}
|
|
11792
|
+
}
|
|
11793
|
+
const nextChain = [...chain, node];
|
|
11794
|
+
const aliases = node.alias == null ? [] : (Array.isArray(node.alias) ? node.alias : [node.alias]);
|
|
11795
|
+
const variants = [
|
|
11796
|
+
{ path: fullPath, isAlias: viaAlias },
|
|
11797
|
+
...aliases.map(a => ({ path: this.joinPaths(parentPath, a), isAlias: true }))
|
|
11798
|
+
];
|
|
11799
|
+
for (const variant of variants) {
|
|
11800
|
+
this.records.push({
|
|
11801
|
+
fullPath: variant.path,
|
|
11802
|
+
chain: nextChain,
|
|
11803
|
+
leaf: node,
|
|
11804
|
+
scanner: new Scanner(variant.path),
|
|
11805
|
+
aliasOf: variant.isAlias ? (node.fullPath ?? null) : null
|
|
11806
|
+
});
|
|
11807
|
+
if (node.childs && node.childs.length) {
|
|
11808
|
+
for (const child of node.childs)
|
|
11809
|
+
this.walk(nextChain, variant.path, child, variant.isAlias);
|
|
11810
|
+
}
|
|
11811
|
+
}
|
|
11812
|
+
};
|
|
11540
11813
|
this.build();
|
|
11541
11814
|
}
|
|
11542
11815
|
build() {
|
|
@@ -11546,37 +11819,6 @@
|
|
|
11546
11819
|
this.walk([], "", r);
|
|
11547
11820
|
this.records.sort(compareRouteRecords);
|
|
11548
11821
|
}
|
|
11549
|
-
walk = (chain, parentPath, node, viaAlias = false) => {
|
|
11550
|
-
const fullPath = this.joinPaths(parentPath, node.path);
|
|
11551
|
-
if (!viaAlias) {
|
|
11552
|
-
const existing = node.fullPath;
|
|
11553
|
-
if (existing == null || (typeof existing === 'string' && existing.trim() === '')) {
|
|
11554
|
-
node.fullPath = fullPath;
|
|
11555
|
-
}
|
|
11556
|
-
if (node.name != null) {
|
|
11557
|
-
this.routesMap.set(node.name, node);
|
|
11558
|
-
}
|
|
11559
|
-
}
|
|
11560
|
-
const nextChain = [...chain, node];
|
|
11561
|
-
const aliases = node.alias == null ? [] : (Array.isArray(node.alias) ? node.alias : [node.alias]);
|
|
11562
|
-
const variants = [
|
|
11563
|
-
{ path: fullPath, isAlias: viaAlias },
|
|
11564
|
-
...aliases.map(a => ({ path: this.joinPaths(parentPath, a), isAlias: true }))
|
|
11565
|
-
];
|
|
11566
|
-
for (const variant of variants) {
|
|
11567
|
-
this.records.push({
|
|
11568
|
-
fullPath: variant.path,
|
|
11569
|
-
chain: nextChain,
|
|
11570
|
-
leaf: node,
|
|
11571
|
-
scanner: new Scanner(variant.path),
|
|
11572
|
-
aliasOf: variant.isAlias ? (node.fullPath ?? null) : null
|
|
11573
|
-
});
|
|
11574
|
-
if (node.childs && node.childs.length) {
|
|
11575
|
-
for (const child of node.childs)
|
|
11576
|
-
this.walk(nextChain, variant.path, child, variant.isAlias);
|
|
11577
|
-
}
|
|
11578
|
-
}
|
|
11579
|
-
};
|
|
11580
11822
|
joinPaths(parent, child) {
|
|
11581
11823
|
parent = parent || "";
|
|
11582
11824
|
child = child || "";
|
|
@@ -11593,19 +11835,22 @@
|
|
|
11593
11835
|
}
|
|
11594
11836
|
|
|
11595
11837
|
class RoutingEngine {
|
|
11596
|
-
|
|
11597
|
-
|
|
11598
|
-
|
|
11599
|
-
|
|
11600
|
-
|
|
11601
|
-
|
|
11602
|
-
|
|
11838
|
+
constructor() {
|
|
11839
|
+
this.stack = null;
|
|
11840
|
+
this._revealed = new Set();
|
|
11841
|
+
this._previousPath = null;
|
|
11842
|
+
this._previousInstances = [];
|
|
11843
|
+
this.controlCache = new Map();
|
|
11844
|
+
this._navVersion = 0;
|
|
11845
|
+
this._pendingActivate = new Set();
|
|
11846
|
+
this.pendingMount = new WeakMap();
|
|
11847
|
+
this.pendingListeners = new WeakMap();
|
|
11848
|
+
}
|
|
11603
11849
|
register(mainApp, application, routingModule) {
|
|
11604
11850
|
this.root = mainApp;
|
|
11605
11851
|
this.application = application;
|
|
11606
11852
|
this.routingModule = routingModule;
|
|
11607
11853
|
}
|
|
11608
|
-
controlCache = new Map();
|
|
11609
11854
|
async evict(route) {
|
|
11610
11855
|
const targets = route ? [route] : Array.from(this.controlCache.keys());
|
|
11611
11856
|
for (const r of targets) {
|
|
@@ -11667,8 +11912,6 @@
|
|
|
11667
11912
|
}
|
|
11668
11913
|
return result;
|
|
11669
11914
|
}
|
|
11670
|
-
_navVersion = 0;
|
|
11671
|
-
_pendingActivate = new Set();
|
|
11672
11915
|
async execute(path, nav, route) {
|
|
11673
11916
|
route ??= {
|
|
11674
11917
|
target: path,
|
|
@@ -12139,9 +12382,7 @@
|
|
|
12139
12382
|
}
|
|
12140
12383
|
async activator(container) {
|
|
12141
12384
|
}
|
|
12142
|
-
|
|
12143
|
-
pendingListeners = new WeakMap();
|
|
12144
|
-
static OUTLET_WARN_MS = 3000;
|
|
12385
|
+
static { this.OUTLET_WARN_MS = 3000; }
|
|
12145
12386
|
async mountChain(instances, chain, container, navVersion) {
|
|
12146
12387
|
for (let index = 0; index < instances.length;) {
|
|
12147
12388
|
if (navVersion !== this._navVersion)
|
|
@@ -12313,17 +12554,20 @@
|
|
|
12313
12554
|
const pathOf = (uri) => uri.split('#')[0].split('?')[0];
|
|
12314
12555
|
const newHistorySession = () => Math.random().toString(36).slice(2, 10) + Date.now().toString(36);
|
|
12315
12556
|
class UrlRoutingModule {
|
|
12316
|
-
static MAX_REDIRECTS = 10;
|
|
12317
|
-
_routerOptions;
|
|
12318
|
-
routingEngine;
|
|
12319
|
-
routeCollection;
|
|
12320
|
-
routesMap = new Map();
|
|
12321
|
-
mainApp;
|
|
12322
|
-
application;
|
|
12323
|
-
_suppressBeforeEachOnce = false;
|
|
12324
|
-
_suppressMiddlewaresOnce = false;
|
|
12325
|
-
_scroll = null;
|
|
12557
|
+
static { this.MAX_REDIRECTS = 10; }
|
|
12326
12558
|
constructor(options, application) {
|
|
12559
|
+
this.routesMap = new Map();
|
|
12560
|
+
this._suppressBeforeEachOnce = false;
|
|
12561
|
+
this._suppressMiddlewaresOnce = false;
|
|
12562
|
+
this._scroll = null;
|
|
12563
|
+
this._stack = null;
|
|
12564
|
+
this._windowNavListener = null;
|
|
12565
|
+
this._historyStamp = null;
|
|
12566
|
+
this._pendingTraversal = null;
|
|
12567
|
+
this._currentUri = '___startup___';
|
|
12568
|
+
this._previousRoute = null;
|
|
12569
|
+
this._fallbackRoutes = {};
|
|
12570
|
+
this._navHandler = null;
|
|
12327
12571
|
this._routerOptions = options;
|
|
12328
12572
|
this.routeCollection = new RouteCollection(options.RouteItems);
|
|
12329
12573
|
this.routingEngine = new RoutingEngine();
|
|
@@ -12339,11 +12583,9 @@
|
|
|
12339
12583
|
this.routingEngine.stack = this._stack;
|
|
12340
12584
|
}
|
|
12341
12585
|
}
|
|
12342
|
-
_stack = null;
|
|
12343
12586
|
getHooks() {
|
|
12344
12587
|
return this._routerOptions.hooks;
|
|
12345
12588
|
}
|
|
12346
|
-
_windowNavListener = null;
|
|
12347
12589
|
start(mainApp, shellUri) {
|
|
12348
12590
|
this.mainApp = mainApp;
|
|
12349
12591
|
this.routingEngine.register(this.mainApp, this.application, this);
|
|
@@ -12369,14 +12611,13 @@
|
|
|
12369
12611
|
const h = w?.location?.hash || '';
|
|
12370
12612
|
return h && h.startsWith('#') ? h.slice(1) || '/' : '/';
|
|
12371
12613
|
}
|
|
12372
|
-
return (w?.location?.pathname || '/') + (w?.location?.search || '');
|
|
12614
|
+
return (w?.location?.pathname || '/') + (w?.location?.search || '') + (w?.location?.hash || '');
|
|
12373
12615
|
}
|
|
12374
12616
|
catch {
|
|
12375
12617
|
return '/';
|
|
12376
12618
|
}
|
|
12377
12619
|
}
|
|
12378
|
-
static HISTORY_STAMP_KEY = '__motifHistory';
|
|
12379
|
-
_historyStamp = null;
|
|
12620
|
+
static { this.HISTORY_STAMP_KEY = '__motifHistory'; }
|
|
12380
12621
|
_addressMode() {
|
|
12381
12622
|
const w = window;
|
|
12382
12623
|
return this._routerOptions.mode || (w?.location?.protocol === 'file:' ? 'hash' : 'history');
|
|
@@ -12472,7 +12713,6 @@
|
|
|
12472
12713
|
this._stampCurrentEntry(stamp);
|
|
12473
12714
|
this._historyStamp = stamp;
|
|
12474
12715
|
}
|
|
12475
|
-
_pendingTraversal = null;
|
|
12476
12716
|
async _onHistoryTraversal() {
|
|
12477
12717
|
const shown = this._historyStamp;
|
|
12478
12718
|
const arrived = this._readHistoryStamp();
|
|
@@ -12508,8 +12748,6 @@
|
|
|
12508
12748
|
}
|
|
12509
12749
|
catch { }
|
|
12510
12750
|
}
|
|
12511
|
-
_currentUri = '___startup___';
|
|
12512
|
-
_previousRoute = null;
|
|
12513
12751
|
get currentUri() {
|
|
12514
12752
|
return this._currentUri;
|
|
12515
12753
|
}
|
|
@@ -12644,7 +12882,7 @@
|
|
|
12644
12882
|
}
|
|
12645
12883
|
const snapshotOf = (result) => ({
|
|
12646
12884
|
target: result,
|
|
12647
|
-
chain:
|
|
12885
|
+
chain: this.chainOf(result),
|
|
12648
12886
|
direction,
|
|
12649
12887
|
state: entryState,
|
|
12650
12888
|
});
|
|
@@ -12688,7 +12926,7 @@
|
|
|
12688
12926
|
this._handleScrollBehavior(navOptions.scroll);
|
|
12689
12927
|
}
|
|
12690
12928
|
else {
|
|
12691
|
-
this._scroll?.arrived(this._uriWithHash(appliedPath, uri));
|
|
12929
|
+
this._scroll?.arrived(this._uriWithHash(appliedPath, uri), direction);
|
|
12692
12930
|
}
|
|
12693
12931
|
this.application.fire?.('motifjs-router-navigated', {
|
|
12694
12932
|
uri: appliedPath,
|
|
@@ -12748,7 +12986,6 @@
|
|
|
12748
12986
|
}
|
|
12749
12987
|
await this.routingEngine.evict(item);
|
|
12750
12988
|
}
|
|
12751
|
-
_fallbackRoutes = {};
|
|
12752
12989
|
_getFallbackRoute(kind) {
|
|
12753
12990
|
const existing = this._fallbackRoutes[kind];
|
|
12754
12991
|
if (existing)
|
|
@@ -12821,7 +13058,7 @@
|
|
|
12821
13058
|
}
|
|
12822
13059
|
return best ? { chain: best.rec.chain, params: best.params } : null;
|
|
12823
13060
|
}
|
|
12824
|
-
static _builtinNotFound = () => new Component('div', {
|
|
13061
|
+
static { this._builtinNotFound = () => new Component('div', {
|
|
12825
13062
|
initializeComponent(sender) {
|
|
12826
13063
|
sender.style({
|
|
12827
13064
|
padding: '20px', fontFamily: 'Arial, sans-serif', display: 'flex', 'flex-direction': 'column', 'align-items': 'center'
|
|
@@ -12829,8 +13066,8 @@
|
|
|
12829
13066
|
sender.element.appendChild($('h2', {}, ...['404 - Not Found']));
|
|
12830
13067
|
sender.element.appendChild($('p', {}, ...['The requested page was not found.']));
|
|
12831
13068
|
},
|
|
12832
|
-
});
|
|
12833
|
-
static _builtinError = () => new Component('div', {
|
|
13069
|
+
}); }
|
|
13070
|
+
static { this._builtinError = () => new Component('div', {
|
|
12834
13071
|
initializeComponent(sender) {
|
|
12835
13072
|
sender.style({
|
|
12836
13073
|
padding: '20px', fontFamily: 'Arial, sans-serif', display: 'flex', 'flex-direction': 'column', 'align-items': 'center'
|
|
@@ -12838,7 +13075,7 @@
|
|
|
12838
13075
|
sender.element.appendChild($('h2', {}, ...['Error']));
|
|
12839
13076
|
sender.element.appendChild($('p', {}, ...['The requested page could not be loaded.']));
|
|
12840
13077
|
},
|
|
12841
|
-
});
|
|
13078
|
+
}); }
|
|
12842
13079
|
async navigateByName(name, params, options) {
|
|
12843
13080
|
return await this.navigate(this.href(name, params), options);
|
|
12844
13081
|
}
|
|
@@ -12870,6 +13107,9 @@
|
|
|
12870
13107
|
}
|
|
12871
13108
|
return { proceed, uri: urix };
|
|
12872
13109
|
}
|
|
13110
|
+
chainOf(result) {
|
|
13111
|
+
return result.chain.map(r => this.routingEngine.generatePathString(r.path, result.params) || '');
|
|
13112
|
+
}
|
|
12873
13113
|
resolve(uri) {
|
|
12874
13114
|
const candidates = [];
|
|
12875
13115
|
const pageSearch = this._pageSearch();
|
|
@@ -12991,7 +13231,6 @@
|
|
|
12991
13231
|
}
|
|
12992
13232
|
return true;
|
|
12993
13233
|
}
|
|
12994
|
-
_navHandler = null;
|
|
12995
13234
|
_installLinkInterceptor() {
|
|
12996
13235
|
try {
|
|
12997
13236
|
if (this._navHandler)
|
|
@@ -13067,8 +13306,14 @@
|
|
|
13067
13306
|
return;
|
|
13068
13307
|
}
|
|
13069
13308
|
if (w?.history && typeof w.history.pushState === 'function') {
|
|
13070
|
-
const current = (w.location.pathname || '/') + (w.location.search || '');
|
|
13071
|
-
|
|
13309
|
+
const current = (w.location.pathname || '/') + (w.location.search || '') + (w.location.hash || '');
|
|
13310
|
+
let wanted = uri;
|
|
13311
|
+
try {
|
|
13312
|
+
const url = new URL(uri, w.location.href);
|
|
13313
|
+
wanted = url.pathname + url.search + url.hash;
|
|
13314
|
+
}
|
|
13315
|
+
catch { }
|
|
13316
|
+
if (current !== wanted) {
|
|
13072
13317
|
if (options.replace) {
|
|
13073
13318
|
const stamp = this._nextHistoryStamp(false);
|
|
13074
13319
|
w.history.replaceState(this._routerState(options.state, stamp), '', uri);
|
|
@@ -13190,9 +13435,11 @@
|
|
|
13190
13435
|
}
|
|
13191
13436
|
|
|
13192
13437
|
class RouterState {
|
|
13193
|
-
|
|
13194
|
-
|
|
13195
|
-
|
|
13438
|
+
constructor() {
|
|
13439
|
+
this.version = new Signal(0);
|
|
13440
|
+
this._current = null;
|
|
13441
|
+
this._constructing = null;
|
|
13442
|
+
}
|
|
13196
13443
|
read() {
|
|
13197
13444
|
this.version.value;
|
|
13198
13445
|
return this._constructing ?? this._current;
|
|
@@ -13253,15 +13500,19 @@
|
|
|
13253
13500
|
return module()?.routeInfos() ?? [];
|
|
13254
13501
|
},
|
|
13255
13502
|
navigate: async (uri, options) => {
|
|
13256
|
-
await required().navigate(uri, options);
|
|
13503
|
+
return await required().navigate(uri, options);
|
|
13257
13504
|
},
|
|
13258
13505
|
navigateByName: async (name, params, options) => {
|
|
13259
|
-
await required().navigateByName(name, params, options);
|
|
13506
|
+
return await required().navigateByName(name, params, options);
|
|
13260
13507
|
},
|
|
13261
13508
|
evict: async (route) => {
|
|
13262
13509
|
await required().evict(route);
|
|
13263
13510
|
},
|
|
13264
|
-
resolve: (uri) =>
|
|
13511
|
+
resolve: (uri) => {
|
|
13512
|
+
const current = required();
|
|
13513
|
+
const result = current.resolve(uri);
|
|
13514
|
+
return { chain: current.chainOf(result), result };
|
|
13515
|
+
},
|
|
13265
13516
|
href: (name, params) => required().href(name, params),
|
|
13266
13517
|
};
|
|
13267
13518
|
}
|
|
@@ -13269,8 +13520,8 @@
|
|
|
13269
13520
|
let _globalApplication = null;
|
|
13270
13521
|
let startedApplicationBuilder = false;
|
|
13271
13522
|
class ApplicationBuilder {
|
|
13272
|
-
services = new ServiceCollection();
|
|
13273
13523
|
constructor() {
|
|
13524
|
+
this.services = new ServiceCollection();
|
|
13274
13525
|
if ((_globalApplication && _globalApplication.state !== 'disposing') || startedApplicationBuilder) {
|
|
13275
13526
|
throw new MotifError('MJX405', formatMotifMessage('MJX405'), { cause: _globalApplication });
|
|
13276
13527
|
}
|
|
@@ -13297,28 +13548,31 @@
|
|
|
13297
13548
|
}
|
|
13298
13549
|
}
|
|
13299
13550
|
class Application {
|
|
13300
|
-
provider;
|
|
13301
13551
|
static get main() {
|
|
13302
13552
|
return _globalApplication;
|
|
13303
13553
|
}
|
|
13304
13554
|
constructor(provider) {
|
|
13305
13555
|
this.provider = provider;
|
|
13556
|
+
this._state = 'initializing';
|
|
13557
|
+
this._middlewares = [];
|
|
13558
|
+
this._beforeEachGuards = [];
|
|
13559
|
+
this._routerState = new RouterState();
|
|
13560
|
+
this.router = createRouter(this._routerState, () => this.urlRoutingModule);
|
|
13561
|
+
this.events = new Map();
|
|
13562
|
+
this._routerConfig = null;
|
|
13563
|
+
this._routerRoot = null;
|
|
13564
|
+
this._startedRouter = null;
|
|
13565
|
+
this._lifecycleOff = null;
|
|
13566
|
+
this._isDevelopment = false;
|
|
13567
|
+
this._enableErrorLogging = true;
|
|
13306
13568
|
}
|
|
13307
|
-
static _disposingCount = 0;
|
|
13308
|
-
_state = 'initializing';
|
|
13309
|
-
_disposing;
|
|
13569
|
+
static { this._disposingCount = 0; }
|
|
13310
13570
|
get state() {
|
|
13311
13571
|
return this._state;
|
|
13312
13572
|
}
|
|
13313
|
-
_middlewares = [];
|
|
13314
|
-
_beforeEachGuards = [];
|
|
13315
|
-
_routerState = new RouterState();
|
|
13316
|
-
router = createRouter(this._routerState, () => this.urlRoutingModule);
|
|
13317
|
-
events = new Map();
|
|
13318
13573
|
static CreateBuilder() {
|
|
13319
13574
|
return new ApplicationBuilder();
|
|
13320
13575
|
}
|
|
13321
|
-
appShell;
|
|
13322
13576
|
getAppShell() {
|
|
13323
13577
|
return this.appShell;
|
|
13324
13578
|
}
|
|
@@ -13462,10 +13716,6 @@
|
|
|
13462
13716
|
}
|
|
13463
13717
|
return true;
|
|
13464
13718
|
}
|
|
13465
|
-
urlRoutingModule;
|
|
13466
|
-
_routerConfig = null;
|
|
13467
|
-
_routerRoot = null;
|
|
13468
|
-
_startedRouter = null;
|
|
13469
13719
|
useRouter(options) {
|
|
13470
13720
|
let routes;
|
|
13471
13721
|
let mode;
|
|
@@ -13585,7 +13835,6 @@
|
|
|
13585
13835
|
return true;
|
|
13586
13836
|
}
|
|
13587
13837
|
}
|
|
13588
|
-
_lifecycleOff = null;
|
|
13589
13838
|
onLifecycle(handler) {
|
|
13590
13839
|
this._installLifecycleListeners();
|
|
13591
13840
|
return this.on('motifjs-app-lifecycle', handler);
|
|
@@ -13627,8 +13876,6 @@
|
|
|
13627
13876
|
for (const off of offs)
|
|
13628
13877
|
off();
|
|
13629
13878
|
}
|
|
13630
|
-
_isDevelopment = false;
|
|
13631
|
-
_enableErrorLogging = true;
|
|
13632
13879
|
get isDevelopmentModeEnabled() {
|
|
13633
13880
|
return this._isDevelopment;
|
|
13634
13881
|
}
|
|
@@ -13708,12 +13955,6 @@
|
|
|
13708
13955
|
class Policy {
|
|
13709
13956
|
}
|
|
13710
13957
|
class RetryPolicy extends Policy {
|
|
13711
|
-
retries;
|
|
13712
|
-
backoff;
|
|
13713
|
-
delayMs;
|
|
13714
|
-
jitter;
|
|
13715
|
-
shouldHandle;
|
|
13716
|
-
onRetry;
|
|
13717
13958
|
constructor(options = {}) {
|
|
13718
13959
|
super();
|
|
13719
13960
|
this.retries = options.retries ?? 3;
|
|
@@ -13752,7 +13993,6 @@
|
|
|
13752
13993
|
}
|
|
13753
13994
|
}
|
|
13754
13995
|
class TimeoutPolicy extends Policy {
|
|
13755
|
-
timeoutMs;
|
|
13756
13996
|
constructor(opts) {
|
|
13757
13997
|
super();
|
|
13758
13998
|
this.timeoutMs = opts.timeoutMs;
|
|
@@ -13772,17 +14012,12 @@
|
|
|
13772
14012
|
}
|
|
13773
14013
|
}
|
|
13774
14014
|
class CircuitBreakerPolicy extends Policy {
|
|
13775
|
-
failureThreshold;
|
|
13776
|
-
successThreshold;
|
|
13777
|
-
durationOfBreakMs;
|
|
13778
|
-
shouldHandle;
|
|
13779
|
-
onStateChange;
|
|
13780
|
-
state = 'CLOSED';
|
|
13781
|
-
failureCount = 0;
|
|
13782
|
-
successCount = 0;
|
|
13783
|
-
nextAttemptTime = 0;
|
|
13784
14015
|
constructor(opts = {}) {
|
|
13785
14016
|
super();
|
|
14017
|
+
this.state = 'CLOSED';
|
|
14018
|
+
this.failureCount = 0;
|
|
14019
|
+
this.successCount = 0;
|
|
14020
|
+
this.nextAttemptTime = 0;
|
|
13786
14021
|
this.failureThreshold = opts.failureThreshold ?? 5;
|
|
13787
14022
|
this.successThreshold = opts.successThreshold ?? 2;
|
|
13788
14023
|
this.durationOfBreakMs = opts.durationOfBreakMs ?? 60000;
|
|
@@ -13835,12 +14070,10 @@
|
|
|
13835
14070
|
}
|
|
13836
14071
|
}
|
|
13837
14072
|
class BulkheadPolicy extends Policy {
|
|
13838
|
-
maxConcurrent;
|
|
13839
|
-
maxQueue;
|
|
13840
|
-
active = 0;
|
|
13841
|
-
queue = [];
|
|
13842
14073
|
constructor(opts = {}) {
|
|
13843
14074
|
super();
|
|
14075
|
+
this.active = 0;
|
|
14076
|
+
this.queue = [];
|
|
13844
14077
|
this.maxConcurrent = opts.maxConcurrent ?? 10;
|
|
13845
14078
|
this.maxQueue = opts.maxQueue ?? 50;
|
|
13846
14079
|
}
|
|
@@ -13873,11 +14106,6 @@
|
|
|
13873
14106
|
}
|
|
13874
14107
|
}
|
|
13875
14108
|
class RateLimiterPolicy extends Policy {
|
|
13876
|
-
tokensPerInterval;
|
|
13877
|
-
intervalMs;
|
|
13878
|
-
capacity;
|
|
13879
|
-
tokens;
|
|
13880
|
-
lastRefill;
|
|
13881
14109
|
constructor(opts = {}) {
|
|
13882
14110
|
super();
|
|
13883
14111
|
this.tokensPerInterval = opts.tokensPerInterval ?? 1;
|
|
@@ -13907,8 +14135,6 @@
|
|
|
13907
14135
|
}
|
|
13908
14136
|
}
|
|
13909
14137
|
class FallbackPolicy extends Policy {
|
|
13910
|
-
fallback;
|
|
13911
|
-
shouldHandle;
|
|
13912
14138
|
constructor(opts) {
|
|
13913
14139
|
super();
|
|
13914
14140
|
this.fallback = opts.fallback;
|
|
@@ -13926,7 +14152,6 @@
|
|
|
13926
14152
|
}
|
|
13927
14153
|
}
|
|
13928
14154
|
class PolicyWrap extends Policy {
|
|
13929
|
-
policies;
|
|
13930
14155
|
constructor(...policies) {
|
|
13931
14156
|
super();
|
|
13932
14157
|
this.policies = policies;
|
|
@@ -13951,34 +14176,36 @@
|
|
|
13951
14176
|
return (ctx) => policy.execute(fn, ctx);
|
|
13952
14177
|
}
|
|
13953
14178
|
class Resilience {
|
|
14179
|
+
constructor() {
|
|
14180
|
+
this.resiliences = [];
|
|
14181
|
+
this.retry = (opts) => {
|
|
14182
|
+
this.resiliences.push(resilience.retry(opts));
|
|
14183
|
+
return this;
|
|
14184
|
+
};
|
|
14185
|
+
this.timeout = (opts) => {
|
|
14186
|
+
this.resiliences.push(resilience.timeout(opts));
|
|
14187
|
+
return this;
|
|
14188
|
+
};
|
|
14189
|
+
this.circuitBreaker = (opts) => {
|
|
14190
|
+
this.resiliences.push(resilience.circuitBreaker(opts));
|
|
14191
|
+
return this;
|
|
14192
|
+
};
|
|
14193
|
+
this.bulkhead = (opts) => {
|
|
14194
|
+
this.resiliences.push(resilience.bulkhead(opts));
|
|
14195
|
+
return this;
|
|
14196
|
+
};
|
|
14197
|
+
this.rateLimiter = (opts) => {
|
|
14198
|
+
this.resiliences.push(resilience.rateLimiter(opts));
|
|
14199
|
+
return this;
|
|
14200
|
+
};
|
|
14201
|
+
this.fallback = (opts) => {
|
|
14202
|
+
this.resiliences.push(resilience.fallback(opts));
|
|
14203
|
+
return this;
|
|
14204
|
+
};
|
|
14205
|
+
}
|
|
13954
14206
|
static get create() {
|
|
13955
14207
|
return new Resilience();
|
|
13956
14208
|
}
|
|
13957
|
-
resiliences = [];
|
|
13958
|
-
retry = (opts) => {
|
|
13959
|
-
this.resiliences.push(resilience.retry(opts));
|
|
13960
|
-
return this;
|
|
13961
|
-
};
|
|
13962
|
-
timeout = (opts) => {
|
|
13963
|
-
this.resiliences.push(resilience.timeout(opts));
|
|
13964
|
-
return this;
|
|
13965
|
-
};
|
|
13966
|
-
circuitBreaker = (opts) => {
|
|
13967
|
-
this.resiliences.push(resilience.circuitBreaker(opts));
|
|
13968
|
-
return this;
|
|
13969
|
-
};
|
|
13970
|
-
bulkhead = (opts) => {
|
|
13971
|
-
this.resiliences.push(resilience.bulkhead(opts));
|
|
13972
|
-
return this;
|
|
13973
|
-
};
|
|
13974
|
-
rateLimiter = (opts) => {
|
|
13975
|
-
this.resiliences.push(resilience.rateLimiter(opts));
|
|
13976
|
-
return this;
|
|
13977
|
-
};
|
|
13978
|
-
fallback = (opts) => {
|
|
13979
|
-
this.resiliences.push(resilience.fallback(opts));
|
|
13980
|
-
return this;
|
|
13981
|
-
};
|
|
13982
14209
|
async execute(action, ctx) {
|
|
13983
14210
|
return resilience.wrap(...this.resiliences).execute(action, ctx);
|
|
13984
14211
|
}
|