@motifx/core 1.2.0-rc.2 → 1.2.0-rc.4

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/dist/index.umd.js CHANGED
@@ -8,10 +8,12 @@
8
8
  setTimeout(() => { throw error; }, 0);
9
9
  }
10
10
  class ErrorHandler {
11
- unexpectedErrorHandler = rethrowLater;
12
- listeners = [];
13
- _isDevelopment = false;
14
- _enableConsoleLogging = true;
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
- disposableTracker = null;
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.delete(item);
449
+ this._items?.delete(item);
448
450
  item.dispose();
449
451
  }
450
452
  detach(item) {
451
- if (item && this._items.delete(item)) {
453
+ if (item && this._items?.delete(item)) {
452
454
  disposableCore.notifyOwner(item, null);
453
455
  }
454
456
  }
455
457
  clear() {
456
- if (this._items.size === 0) {
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 this._items) {
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
- this._items.clear();
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 = new DisposableStore();
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._disposables;
495
- if (owned && typeof owned.dispose === 'function') {
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
- ItemAdded;
971
- ItemAddedBefore;
972
- ItemSplice;
973
- __list = [];
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
- __values = new List();
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
- _ring = createRing();
1199
- _count = 0;
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
  }
@@ -1335,10 +1359,11 @@
1335
1359
  }
1336
1360
 
1337
1361
  const COMPILER_CONTRACT = 1;
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 === COMPILER_CONTRACT || reported.has(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
- let value = readModelValue(el);
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
- _subscriptions = [];
2269
- _delivery;
2270
- _subscribe;
2271
- _disposed = false;
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
- var valueStr = String(value ?? '').trim();
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
- return (input || '')
3139
- .split(/\s+/)
3140
- .map(s => s.trim())
3141
- .filter(s => s.length > 0);
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
- _addStaticFromString(s) {
3241
- if (!s)
3255
+ _addStaticNames(names) {
3256
+ if (names.length === 0)
3242
3257
  return;
3243
3258
  const el = this._getElement();
3244
- const prev = new Set(this._staticSet);
3245
- for (const cls of this._splitClasses(s))
3246
- this._staticSet.add(cls);
3247
- this._applySourceDiff('static', prev, new Set(this._staticSet), el);
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?.motif?.options?.[TRANSITION_SLOT];
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._base?._leaveContainer;
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._base?._leaveContainer);
4486
+ return enterModeOf(c.parent ?? c._leaveContainer);
4465
4487
  }
4466
4488
  function wantsEnterTransition(c) {
4467
- const o = c?.motif?.options;
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 !!this[OPTIONS_OWNER]._eventHandlers?.has(name);
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._base;
4688
+ const base = component._baseCtx;
4669
4689
  if (base)
4670
- base.emiters.fire(name, ev);
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 list = component._base[listName];
4676
- if (Array.isArray(list) && list.length > 0)
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 component._base.emiters.hasListeners(lowerName);
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
- if (Array.isArray(component._base._initializeComponentHandlers) && component._base._initializeComponentHandlers.length) {
4750
- for (const fn of component._base._initializeComponentHandlers) {
4751
- callReported(() => fn(sender, ev), 'MJX122', 'initializeComponent');
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
- if (Array.isArray(component._base._onInitializeComponentHandlers) && component._base._onInitializeComponentHandlers.length) {
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
- if (Array.isArray(component._base._onDisposingHandlers)) {
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
- if (Array.isArray(component._base._onActivatedHandlers)) {
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
- if (Array.isArray(component._base._onDeactivatedHandlers)) {
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.controls.items.slice()) {
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.controls.items.slice()) {
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 || !component._base || component._base._disposedFired) {
4871
+ if (!component || (component._flags & F_DISPOSED_FIRED) !== 0) {
4872
+ return;
4873
+ }
4874
+ if (component.isDisposed && !component.element && component._baseCtx === undefined) {
4848
4875
  return;
4849
4876
  }
4850
- component._base._disposedFired = true;
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
- if (Array.isArray(component._base._onDisposedHandlers)) {
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
- if (Array.isArray(component._base._onBuiltHandlers)) {
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._base._mountedScheduled) {
4915
+ if (!component || component.isDisposed || component._baseCtx?._mountedScheduled) {
4897
4916
  return;
4898
4917
  }
4899
4918
  const hasHook = typeof component.onMounted === 'function'
4900
- || (Array.isArray(component._base._onMountedHandlers) && component._base._onMountedHandlers.length > 0)
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
- if (Array.isArray(component._base._onMountedHandlers)) {
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
- if (Array.isArray(component._base._onBuildingHandlers)) {
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
- if (component.motif.options._preconfig) {
4963
- safeCallSilent(() => component.motif.options._preconfig(component), 'Component._preconfig');
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
- if (Array.isArray(component._base._onConfigHandlers)) {
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.motif.options && component.motif.options._postconfigdone) {
4988
+ if ((component._flags & F_POSTCONFIG) !== 0) {
4981
4989
  return;
4982
4990
  }
4983
- if (component?._base?._configDeferred && !component.isConfigured) {
4991
+ if (component?._baseCtx?._configDeferred && !component.isConfigured) {
4984
4992
  ComponentHelper.callConfig(component);
4985
4993
  }
4986
- component.motif.options._postconfigdone = true;
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
- if (Array.isArray(component._base._onConfiguredHandlers)) {
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
- if (Array.isArray(component._base._onInitializedHandlers)) {
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
- if (Array.isArray(component._base._onInitializingHandlers)) {
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
- if (Array.isArray(component._base._onVisibilityChangedHandlers)) {
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._base._activatePreBindings();
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._base._enterSeq;
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 domReferenceOf = (n) => {
5127
- if (!n || !n.isBuilt)
5128
- return null;
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
- const cfg = c.motif.options?.hideStrategy ?? 'auto';
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._base._enterSeq !== enterSeq;
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
- this.motif.options.cache?.appendChild(ComponentHelper.getContent.call(child));
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.motif?.options;
5272
+ const opts = optionsOf(c);
5262
5273
  const parent = node.parentNode;
5263
5274
  if (node.nodeType === Node.COMMENT_NODE) {
5264
- if (!parent)
5265
- return;
5266
- const close = opts?.closeFragment || null;
5267
- if (close) {
5268
- let current = node;
5269
- while (current) {
5270
- const after = current.nextSibling;
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(current);
5292
+ parent.removeChild(node);
5273
5293
  }
5274
5294
  catch { }
5275
- if (current === close)
5276
- break;
5277
- current = after;
5278
- }
5279
- }
5280
- else {
5281
- try {
5282
- parent.removeChild(node);
5283
5295
  }
5284
- catch { }
5296
+ if (!alsoPlaceholder)
5297
+ return;
5285
5298
  }
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._base._offAll();
5385
+ offAll(c);
5375
5386
  }
5376
5387
  catch {
5377
5388
  }
5378
5389
  c.motif.stopAnimations();
5379
- c._base._deactivateBindings();
5380
- if (c.controls?.items?.length) {
5381
- for (const child of c.controls.items) {
5390
+ deactivateBindings(c);
5391
+ if (childrenOf(c).length) {
5392
+ for (const child of c._controls.items) {
5382
5393
  try {
5383
- child._base._disposeShallow();
5394
+ disposeShallow(child);
5384
5395
  }
5385
5396
  catch {
5386
5397
  }
5387
5398
  }
5388
5399
  }
5389
5400
  ComponentHelper.callDisposed.call(c, c);
5390
- safeCall(() => { c._base.emiters.clear(); }, 'disposeShallow.emiters');
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.class?._countsStore?.clear();
5412
+ c._class?._countsStore?.clear();
5407
5413
  }
5408
5414
  catch { }
5409
5415
  try {
5410
- c.class?._watchersStore?.clear();
5416
+ c._class?._watchersStore?.clear();
5411
5417
  }
5412
5418
  catch { }
5413
5419
  try {
5414
- c.attr?._attrMapStore?.clear();
5420
+ c._attr?._attrMapStore?.clear();
5415
5421
  }
5416
5422
  catch { }
5417
5423
  try {
5418
- c.attr?._watchersStore?.clear();
5424
+ c._attr?._watchersStore?.clear();
5419
5425
  }
5420
5426
  catch { }
5421
5427
  try {
5422
- if (c.motif.options) {
5423
- c.motif.options.cache = undefined;
5424
- c.motif.options.closeFragment = undefined;
5425
- c.motif.options.placeholder = undefined;
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.motif.options = undefined;
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 === 'motif')
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.isDisposed = true;
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.motif?.options;
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.controls?.items;
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._base._offAll();
5523
- c._base._deactivateBindings();
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.controls.items = [];
5539
+ if (c._controls)
5540
+ c._controls.items = [];
5531
5541
  safeCall(() => { ComponentHelper.callDisposed.call(c, c); }, 'disposeAsync.callDisposed');
5532
- safeCall(() => { c._base.emiters.clear(); }, 'disposeAsync.emiters');
5542
+ safeCall(() => { c._baseCtx?._emiters?.clear(); }, 'disposeAsync.emiters');
5533
5543
  if (options?.deep) {
5534
- c._base._deepCleanup();
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._base.emiters.clear(); }, 'dispose.emiters');
5541
- c._base._offAll();
5542
- c._base._deepCleanup();
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._base._detachDomWithAnimationAsync();
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.controls.items);
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.controls?.items;
5596
- if (!items || items.length === 0)
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
- detachDomWithAnimation(child);
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
- const c = this.owner;
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
- const c = this.owner;
5682
- try {
5683
- c.bindings?.deactivateAll();
5684
- }
5685
- catch { }
5669
+ deactivateBindings(this.owner);
5686
5670
  },
5687
5671
  _activateBindings() {
5688
- const c = this.owner;
5689
- try {
5690
- c.bindings?.activateAll();
5691
- }
5692
- catch { }
5672
+ activateBindings(this.owner);
5693
5673
  },
5694
5674
  _reactivateBindings() {
5695
- const c = this.owner;
5696
- try {
5697
- c.bindings?.reActivateAll();
5698
- }
5699
- catch { }
5675
+ reactivateBindings(this.owner);
5700
5676
  },
5701
5677
  _activatePreBindings() {
5702
- if (this.prebinding_Activated)
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,80 @@
5768
5906
  });
5769
5907
  }
5770
5908
  class ComponentBase extends Disposable {
5771
- motif = new ComponentMotif(this, new ComponentOptionsImpl(this));
5772
- element;
5773
- props;
5774
- isBuilt = false;
5775
- isInitialized = false;
5776
- isDisposed = false;
5777
- isConfigured = false;
5778
- isPainting = false;
5779
- isPainted = false;
5780
- isVisible = true;
5781
- controls = new ControlCollection(this);
5782
- _eventHandlers;
5783
- _isWait = false;
5784
- class = new controlClass(this);
5785
- attr = new controlAttribute(this);
5786
- bindings = new BindingCollection(this);
5787
- /** style(fn) izleyicisi: tek tek tutulur, yeniden çağrıda önceki durdurulur. */
5788
- _styleFx;
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
+ get isBuilt() {
5913
+ return (this._flags & F_BUILT) !== 0;
5914
+ }
5915
+ set isBuilt(value) {
5916
+ this._flags = value ? this._flags | F_BUILT : this._flags & ~F_BUILT;
5917
+ }
5918
+ get isInitialized() {
5919
+ return (this._flags & F_INITIALIZED) !== 0;
5920
+ }
5921
+ set isInitialized(value) {
5922
+ this._flags = value ? this._flags | F_INITIALIZED : this._flags & ~F_INITIALIZED;
5923
+ }
5924
+ get isDisposed() {
5925
+ return (this._flags & F_DISPOSED) !== 0;
5926
+ }
5927
+ set isDisposed(value) {
5928
+ this._flags = value ? this._flags | F_DISPOSED : this._flags & ~F_DISPOSED;
5929
+ }
5930
+ get isConfigured() {
5931
+ return (this._flags & F_CONFIGURED) !== 0;
5932
+ }
5933
+ set isConfigured(value) {
5934
+ this._flags = value ? this._flags | F_CONFIGURED : this._flags & ~F_CONFIGURED;
5935
+ }
5936
+ get isPainting() {
5937
+ return (this._flags & F_PAINTING) !== 0;
5938
+ }
5939
+ set isPainting(value) {
5940
+ this._flags = value ? this._flags | F_PAINTING : this._flags & ~F_PAINTING;
5941
+ }
5942
+ get isPainted() {
5943
+ return (this._flags & F_PAINTED) !== 0;
5944
+ }
5945
+ set isPainted(value) {
5946
+ this._flags = value ? this._flags | F_PAINTED : this._flags & ~F_PAINTED;
5947
+ }
5948
+ get isVisible() {
5949
+ return (this._flags & F_HIDDEN) === 0;
5950
+ }
5951
+ set isVisible(value) {
5952
+ this._flags = value ? this._flags & ~F_HIDDEN : this._flags | F_HIDDEN;
5953
+ }
5954
+ get controls() {
5955
+ return this._controls !== undefined || (this.isDisposed && !this.element) ? this._controls : (this._controls = createOwnedControls(this));
5956
+ }
5957
+ set controls(value) {
5958
+ this._controls = value;
5959
+ }
5960
+ get class() {
5961
+ return this._class !== undefined || (this.isDisposed && !this.element) ? this._class : (this._class = new controlClass(this));
5962
+ }
5963
+ set class(value) {
5964
+ this._class = value;
5965
+ }
5966
+ get attr() {
5967
+ return this._attr !== undefined || (this.isDisposed && !this.element) ? this._attr : (this._attr = new controlAttribute(this));
5968
+ }
5969
+ set attr(value) {
5970
+ this._attr = value;
5971
+ }
5972
+ get bindings() {
5973
+ return this._bindings !== undefined || (this.isDisposed && !this.element) ? this._bindings : (this._bindings = new BindingCollection(this));
5974
+ }
5975
+ set bindings(value) {
5976
+ this._bindings = value;
5977
+ }
5789
5978
  useModel(modelCtor) {
5790
5979
  return reactive(modelCtor);
5791
5980
  }
5792
5981
  _computeHideStrategy() {
5793
- const cfg = this.motif.options?.hideStrategy ?? 'auto';
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';
5982
+ return keepsTrace(this) ? 'placeholder' : 'detach';
5802
5983
  }
5803
5984
  _isInDom() {
5804
5985
  try {
@@ -5815,7 +5996,7 @@
5815
5996
  }
5816
5997
  }
5817
5998
  set isWait(value) {
5818
- this._isWait = value;
5999
+ this._flags = value ? this._flags | F_WAIT : this._flags & ~F_WAIT;
5819
6000
  if (this.isBuilt) {
5820
6001
  if (value) {
5821
6002
  this.motif.hide();
@@ -5830,10 +6011,22 @@
5830
6011
  }
5831
6012
  }
5832
6013
  get isWait() {
5833
- return this._isWait;
6014
+ return (this._flags & F_WAIT) !== 0;
5834
6015
  }
5835
6016
  constructor(element, props = {}) {
5836
6017
  super();
6018
+ this._motif = undefined;
6019
+ this._flags = 0;
6020
+ this._controls = undefined;
6021
+ this._class = undefined;
6022
+ this._attr = undefined;
6023
+ this._bindings = undefined;
6024
+ this._baseCtx = undefined;
6025
+ this._init = undefined;
6026
+ this._leaveContainer = undefined;
6027
+ this.parent = null;
6028
+ const asComponentRoot = constructingComponentRoot;
6029
+ constructingComponentRoot = false;
5837
6030
  recordServiceOwner(this);
5838
6031
  if (this.onElementCreating) {
5839
6032
  this.element = this.onElementCreating.call(this);
@@ -5844,44 +6037,38 @@
5844
6037
  else {
5845
6038
  this.element = element;
5846
6039
  }
5847
- if (props) {
5848
- const refs = extractRefs(props, this);
5849
- if (refs.length > 0) {
5850
- for (const fn of takePendingRefs(this, refs)) {
5851
- callReported(() => fn(this), 'MJX122', 'ref');
5852
- }
5853
- }
6040
+ if (this.element?.nodeType !== 3) {
6041
+ if (this._controls === undefined)
6042
+ this._controls = new ControlCollection(this);
5854
6043
  }
5855
- props && ParseProps(props, this);
6044
+ const refs = props ? extractRefs(props, this) : [];
6045
+ if (props && ParseProps(props, this))
6046
+ props = {};
5856
6047
  applyComponentOptions(props?.options, this);
5857
6048
  this.props = props;
5858
6049
  // (class/style/id/tabindex/role/aria-*/data-*) kök düğüme (root node) düşer, prop'lar this.props'ta kalır.
5859
6050
  if (props) {
5860
6051
  const ctor0 = new.target;
5861
- const plain = ctor0 === ComponentBase || Object.getPrototypeOf(ctor0) === ComponentBase;
6052
+ const plain = !asComponentRoot && (ctor0 === ComponentBase || Object.getPrototypeOf(ctor0) === ComponentBase);
5862
6053
  if (plain)
5863
6054
  applyPlainElementProps(props, this);
5864
6055
  else
5865
6056
  applyFallthroughProps(props, this);
5866
6057
  }
6058
+ if (refs.length > 0) {
6059
+ for (const fn of takePendingRefs(this, refs)) {
6060
+ callReported(() => fn(this), 'MJX122', 'ref');
6061
+ }
6062
+ }
5867
6063
  ComponentHelper.callOnInitializing(this);
5868
6064
  if (this.isDisposed)
5869
6065
  return;
5870
- this.controls.onAdd = (c) => {
5871
- if (this._eventHandlers?.has('controladded'))
5872
- this.motif.trigger('controladded', { control: c });
5873
- if (this.isWait || this.parent?.isWait)
5874
- return;
5875
- ComponentHelper.internalBuild.call(this, c);
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
- };
6066
+ const controls = this._controls;
6067
+ if (controls) {
6068
+ controls.onAdd = ownerControlAdded;
6069
+ controls.onAddBeforeBuild = ownerControlAddedBeforeBuild;
6070
+ controls.onRemove = ownerControlRemoved;
6071
+ }
5885
6072
  ComponentHelper.callOnInitialized(this);
5886
6073
  const ctor = new.target;
5887
6074
  const isBaseCtor = ctor === ComponentBase || Object.getPrototypeOf(ctor) === ComponentBase;
@@ -5892,10 +6079,9 @@
5892
6079
  this._base._configDeferred = true;
5893
6080
  }
5894
6081
  }
5895
- childs;
5896
- _base = createBaseCtx(this);
5897
- parent = null;
5898
- _scopedContext;
6082
+ get _base() {
6083
+ return this._baseCtx !== undefined || (this.isDisposed && !this.element) ? this._baseCtx : (this._baseCtx = createBaseCtx(this));
6084
+ }
5899
6085
  get context() {
5900
6086
  const parentCtx = this.parent?.context;
5901
6087
  const app = parentCtx?.[RAW_APPLICATION] ?? parentCtx ?? teardownApplications.get(this) ?? Application.main;
@@ -5922,7 +6108,7 @@
5922
6108
  build(building = true) {
5923
6109
  checkReservedMembers(this);
5924
6110
  ComponentHelper.callConfigured(this);
5925
- this._base._activatePreBindings();
6111
+ activatePreBindings(this);
5926
6112
  if (this.isDisposed || !this.element || this.isWait) {
5927
6113
  return;
5928
6114
  }
@@ -5959,7 +6145,7 @@
5959
6145
  }
5960
6146
  const deferredSelectValue = this.element?.nodeName === 'SELECT'
5961
6147
  ? this.bindings.items.filter(b => b.propertyName === 'value')
5962
- : [];
6148
+ : NO_BINDINGS;
5963
6149
  if (deferredSelectValue.length) {
5964
6150
  try {
5965
6151
  this.bindings.items.filter(b => !deferredSelectValue.includes(b)).forEach(b => b.activate());
@@ -5967,32 +6153,41 @@
5967
6153
  catch { }
5968
6154
  }
5969
6155
  else {
5970
- this._base._activateBindings();
6156
+ activateBindings(this);
5971
6157
  }
5972
- for (const element of this.controls.items.filter(c => !c.isWait)) {
5973
- element.parent = this;
5974
- element.build(false);
6158
+ const kids = childrenOf(this);
6159
+ for (const element of kids.length ? kids.slice() : kids) {
6160
+ var target = isFragment ? this.motif.options.cache : this.element;
6161
+ if (!element.isWait) {
6162
+ element.parent = this;
6163
+ element.build(false);
6164
+ }
5975
6165
  if (element.isWait) {
6166
+ if (keepsTrace(element)) {
6167
+ const opts = element.motif.options;
6168
+ (building ? ph : target).appendChild(opts.placeholder ?? (opts.placeholder = dom.createComment("h")));
6169
+ }
5976
6170
  continue;
5977
6171
  }
5978
- var target = isFragment ? this.motif.options.cache : this.element;
5979
6172
  if (building) {
5980
- if (element.motif.options.cache) {
5981
- ph.appendChild(element.motif.options.cache);
6173
+ const cache = optionsOf(element)?.cache;
6174
+ if (cache) {
6175
+ ph.appendChild(cache);
5982
6176
  }
5983
6177
  else {
5984
6178
  ph.appendChild(element.element);
5985
6179
  }
5986
6180
  }
5987
6181
  else {
5988
- if (element.motif.options.cache) {
5989
- target.appendChild(element.motif.options.cache);
6182
+ const cache = optionsOf(element)?.cache;
6183
+ if (cache) {
6184
+ target.appendChild(cache);
5990
6185
  }
5991
6186
  else {
5992
6187
  target.appendChild(element.element);
5993
6188
  }
5994
6189
  }
5995
- if (element._base?._inactive && element.isVisible) {
6190
+ if (element._baseCtx?._inactive && element.isVisible) {
5996
6191
  ComponentHelper.activateTree(element);
5997
6192
  }
5998
6193
  }
@@ -6055,10 +6250,10 @@
6055
6250
  this.controls.forEach(c => {
6056
6251
  c.setState();
6057
6252
  });
6058
- this._base._reactivateBindings();
6253
+ reactivateBindings(this);
6059
6254
  }
6060
6255
  reState() {
6061
- this._base._reactivateBindings();
6256
+ reactivateBindings(this);
6062
6257
  this.controls.forEach(c => {
6063
6258
  c.reState();
6064
6259
  });
@@ -6182,6 +6377,9 @@
6182
6377
  if (this.isVisible) {
6183
6378
  return;
6184
6379
  } /* A*/
6380
+ if (this.isWait) {
6381
+ return;
6382
+ }
6185
6383
  if (this.parent && enterModeOf(this.parent) === 'out-in') {
6186
6384
  const showHost = (this.motif.options.placeholder?.parentNode)
6187
6385
  ?? findAppendableComponent(this.parent)?.element;
@@ -6203,7 +6401,7 @@
6203
6401
  /** A*/
6204
6402
  const strategy = this._computeHideStrategy();
6205
6403
  if (strategy === 'detach') {
6206
- ComponentHelper.callVisibilityChanged(this);
6404
+ ComponentHelper.callVisibilityChanged(this, true);
6207
6405
  if (this.isDisposed) {
6208
6406
  return;
6209
6407
  }
@@ -6220,6 +6418,10 @@
6220
6418
  const expectedParent = findAppendableComponent(this.parent)?.element;
6221
6419
  if (this.motif.options.placeholder && placeholderParent && placeholderParent !== expectedParent) {
6222
6420
  reportWarning('MJX106', []);
6421
+ ComponentHelper.callVisibilityChanged(this, true);
6422
+ if (this.isDisposed) {
6423
+ return;
6424
+ }
6223
6425
  this.isVisible = true;
6224
6426
  if (this.parent?.isBuilt) {
6225
6427
  ComponentHelper.internalBuild.call(this.parent, this);
@@ -6228,11 +6430,12 @@
6228
6430
  }
6229
6431
  /** A*/
6230
6432
  wantsEnterTransition(this) && this.motif.options.transition.enterTransition(() => { });
6231
- ComponentHelper.callVisibilityChanged(this);
6433
+ ComponentHelper.callVisibilityChanged(this, true);
6232
6434
  if (this.isDisposed) {
6233
6435
  return;
6234
6436
  }
6235
6437
  if (this.element.nodeType === Node.COMMENT_NODE) {
6438
+ this.controls.items.filter(c => !c.isBuilt).forEach(c => ComponentHelper.internalBuild.call(this, c));
6236
6439
  this.controls.forEach(c => {
6237
6440
  c.motif.show();
6238
6441
  });
@@ -6240,6 +6443,10 @@
6240
6443
  ComponentHelper.activateTree(this, false);
6241
6444
  return;
6242
6445
  }
6446
+ if (!this.isBuilt) {
6447
+ this.isVisible = true;
6448
+ return;
6449
+ }
6243
6450
  var parent = this.motif.options.placeholder?.parentElement;
6244
6451
  if (parent) {
6245
6452
  parent.replaceChild(this.element, this.motif.options.placeholder);
@@ -6258,7 +6465,7 @@
6258
6465
  }
6259
6466
  const strategy = this._computeHideStrategy();
6260
6467
  if (strategy === 'detach') {
6261
- ComponentHelper.callVisibilityChanged(this);
6468
+ ComponentHelper.callVisibilityChanged(this, false);
6262
6469
  if (this.isDisposed) {
6263
6470
  return;
6264
6471
  }
@@ -6273,7 +6480,7 @@
6273
6480
  if (skip)
6274
6481
  transition.skipNextLeave = false;
6275
6482
  const finish = () => {
6276
- ComponentHelper.callVisibilityChanged(this);
6483
+ ComponentHelper.callVisibilityChanged(this, false);
6277
6484
  if (this.isDisposed) {
6278
6485
  return;
6279
6486
  }
@@ -6356,61 +6563,36 @@
6356
6563
  return this;
6357
6564
  }
6358
6565
  }
6359
- const [name, ...mods] = full.split(":");
6566
+ const colon = full.indexOf(":");
6567
+ const name = colon < 0 ? full : full.slice(0, colon);
6568
+ const mods = colon < 0 ? NO_MODS : full.slice(colon + 1).split(":");
6360
6569
  const evt = name.startsWith("on") ? name.slice(2).toLowerCase() : name.toLowerCase();
6361
- const options = {};
6362
- if (mods.includes("once"))
6363
- options.once = true;
6364
- if (mods.includes("passive"))
6365
- options.passive = true;
6366
- if (mods.includes("capture"))
6367
- options.capture = true;
6368
- const wrapped = (ev) => {
6369
- if (mods.includes("self") && ev.target !== this.element)
6370
- return;
6371
- if (mods.includes("trusted") && !ev.isTrusted)
6372
- return;
6373
- let res;
6374
- try {
6375
- if (cb && cb.length <= 1) {
6376
- res = cb(ev);
6377
- }
6378
- else if (cb) {
6379
- res = cb(this, ev);
6380
- }
6381
- }
6382
- catch (error) {
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
- };
6570
+ let flags = domEvent ? EV_DOM : 0;
6571
+ let options;
6572
+ if (mods.length) {
6573
+ options = {};
6574
+ if (mods.includes("once"))
6575
+ options.once = true;
6576
+ if (mods.includes("passive"))
6577
+ options.passive = true;
6578
+ if (mods.includes("capture")) {
6579
+ options.capture = true;
6580
+ flags |= EV_CAPTURE;
6581
+ }
6582
+ if (mods.includes("self"))
6583
+ flags |= EV_SELF;
6584
+ if (mods.includes("trusted"))
6585
+ flags |= EV_TRUSTED;
6586
+ if (mods.includes("prevent"))
6587
+ flags |= EV_PREVENT;
6588
+ if (mods.includes("stop"))
6589
+ flags |= EV_STOP;
6590
+ }
6591
+ const record = new EventRecord(this, full.toLowerCase(), cb, evt, flags);
6403
6592
  if (domEvent) {
6404
- this.element.addEventListener(evt, wrapped, options);
6405
- }
6406
- this._eventHandlers ??= new Map();
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
- }));
6593
+ this.element.addEventListener(evt, record, options);
6594
+ }
6595
+ addEventRecord(this, record);
6414
6596
  return this;
6415
6597
  }
6416
6598
  async _trigger(event, ev) {
@@ -6419,15 +6601,20 @@
6419
6601
  }
6420
6602
  const name = String(event).toLowerCase();
6421
6603
  safeCall(() => {
6422
- var eh = this._eventHandlers?.get(name);
6423
- if (eh) {
6424
- eh.forEach(rec => {
6604
+ eventDispatchDepth++;
6605
+ try {
6606
+ for (let r = this._eventHandlers; r !== undefined; r = r.next) {
6607
+ if ((r.flags & EV_REMOVED) !== 0 || r.key !== name)
6608
+ continue;
6425
6609
  try {
6426
- rec.wrapped(ev);
6610
+ r.handleEvent(ev);
6427
6611
  }
6428
6612
  catch {
6429
6613
  }
6430
- });
6614
+ }
6615
+ }
6616
+ finally {
6617
+ eventDispatchDepth--;
6431
6618
  }
6432
6619
  }, 'trigger');
6433
6620
  return this;
@@ -6450,38 +6637,24 @@
6450
6637
  return this;
6451
6638
  }
6452
6639
  if (LIFECYCLE_X_EVENTS.has(xName)) {
6453
- this._base.emiters.off("on" + xName, cb);
6640
+ this._base._emiters?.off("on" + xName, cb);
6454
6641
  }
6455
6642
  return this;
6456
6643
  }
6457
- const name = full.split(":")[0];
6458
- const evt = name.startsWith("on") ? name.slice(2).toLowerCase() : name.toLowerCase();
6459
- if (!this._eventHandlers)
6460
- return this;
6461
- const set = this._eventHandlers.get(full);
6462
- if (!set)
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;
6644
+ for (let r = this._eventHandlers; r !== undefined; r = r.next) {
6645
+ if ((r.flags & EV_REMOVED) !== 0 || r.key !== full || r.original !== cb)
6646
+ continue;
6647
+ if ((r.flags & EV_DOM) !== 0) {
6648
+ const rec = r;
6649
+ safeCall(() => { this.element.removeEventListener(rec.type, rec, (rec.flags & EV_CAPTURE) !== 0); }, 'off.removeEventListener');
6477
6650
  }
6651
+ r.flags |= EV_REMOVED;
6652
+ break;
6478
6653
  }
6479
- if (set.size === 0)
6480
- this._eventHandlers.delete(full);
6654
+ if (eventDispatchDepth === 0)
6655
+ compactEventRecords(this);
6481
6656
  return this;
6482
6657
  }
6483
- /** Süren bertaraf: ikinci bir dispose/disposeAsync çağrısı yenisini başlatmaz, bunu bekler. */
6484
- _disposing;
6485
6658
  dispose(options = { deep: true }) {
6486
6659
  if (this.isDisposed) {
6487
6660
  return Promise.resolve();
@@ -6552,8 +6725,6 @@
6552
6725
  }
6553
6726
  });
6554
6727
  }
6555
- _siblingsApi;
6556
- _siblingsSet;
6557
6728
  get siblings() {
6558
6729
  if (this._siblingsSet) {
6559
6730
  return this._siblingsApi;
@@ -6701,6 +6872,12 @@
6701
6872
  t.activeAnimations = [];
6702
6873
  }
6703
6874
  }
6875
+ Object.defineProperty(ComponentBase.prototype, 'motif', {
6876
+ ...Object.getOwnPropertyDescriptor(ComponentBase.prototype, 'motif'),
6877
+ set(value) {
6878
+ this._motif = value;
6879
+ },
6880
+ });
6704
6881
  function findContentBlocks(root, results = []) {
6705
6882
  if (!root || root.isDisposed)
6706
6883
  return results;
@@ -6745,6 +6922,16 @@
6745
6922
  }
6746
6923
  return pending;
6747
6924
  }
6925
+ function disposeUnplacedChilds(owner, kids) {
6926
+ if (!Array.isArray(kids) || !kids.some(kid => kid instanceof ComponentBase))
6927
+ return;
6928
+ owner.motif.setDisposable(() => {
6929
+ for (const kid of kids) {
6930
+ if (kid instanceof ComponentBase && !kid.isDisposed && !kid.parent)
6931
+ kid.dispose();
6932
+ }
6933
+ });
6934
+ }
6748
6935
  const isCallableRef = (ref) => typeof ref === 'function' || Array.isArray(ref);
6749
6936
  function extractRefs(props, component) {
6750
6937
  const refs = [];
@@ -6796,26 +6983,38 @@
6796
6983
  const fns = Array.isArray(value) ? value : [value];
6797
6984
  if (fns.length === 0 || !fns.every(fn => typeof fn === 'function'))
6798
6985
  return false;
6799
- component._base[listName] ??= [];
6800
- const list = component._base[listName];
6801
- for (const fn of fns) {
6802
- if (!list.includes(fn))
6803
- list.push(fn);
6986
+ const target = component;
6987
+ let from = 0;
6988
+ if (listName === '_initializeComponentHandlers') {
6989
+ if (target._init === undefined && !target._baseCtx?._initializeComponentHandlers) {
6990
+ target._init = fns[0];
6991
+ from = 1;
6992
+ }
6993
+ }
6994
+ if (from >= fns.length)
6995
+ return true;
6996
+ const base = target._base;
6997
+ for (let i = from; i < fns.length; i++) {
6998
+ const fn = fns[i];
6999
+ if (listName === '_initializeComponentHandlers' && fn === target._init)
7000
+ continue;
7001
+ const slot = base[listName];
7002
+ if (slot === undefined)
7003
+ base[listName] = fn;
7004
+ else if (typeof slot === 'function') {
7005
+ if (slot !== fn)
7006
+ base[listName] = [slot, fn];
7007
+ }
7008
+ else if (!slot.includes(fn))
7009
+ slot.push(fn);
6804
7010
  }
6805
7011
  return true;
6806
7012
  }
6807
7013
  function ParseProps(props, component) {
6808
7014
  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
7015
  var keys = Object.keys(props);
6817
7016
  if (keys.length === 0)
6818
- return;
7017
+ return false;
6819
7018
  keys.forEach(key => {
6820
7019
  if (key == 'initializeComponent' || key == 'oninitializeComponent' || key.startsWith('on')) {
6821
7020
  if (collectLifecycleHandlers(component, key.toLowerCase(), props[key])) {
@@ -6826,6 +7025,7 @@
6826
7025
  else if (key == 'childs') {
6827
7026
  const flat = [].concat(...props[key]);
6828
7027
  component.childs = flat;
7028
+ disposeUnplacedChilds(component, flat);
6829
7029
  delete props[key];
6830
7030
  }
6831
7031
  else if (key === 'transition') {
@@ -6870,9 +7070,14 @@
6870
7070
  component.motif.options._preconfig = props[key];
6871
7071
  delete props[key];
6872
7072
  }
7073
+ else if (key === '__childExpr') {
7074
+ delete props[key];
7075
+ }
6873
7076
  else ;
6874
7077
  });
7078
+ return typeof props === 'object' && Reflect.ownKeys(props).length === 0;
6875
7079
  }
7080
+ return false;
6876
7081
  }
6877
7082
  const _transitionSources = new WeakMap();
6878
7083
  function setTransition(component, value, live) {
@@ -7043,6 +7248,16 @@
7043
7248
  function isFallthroughKey(key) {
7044
7249
  return FALLTHROUGH_KEYS.has(key) || key.startsWith('aria-') || key.startsWith('data-');
7045
7250
  }
7251
+ let constructingComponentRoot = false;
7252
+ function constructComponentRoot(make) {
7253
+ constructingComponentRoot = true;
7254
+ try {
7255
+ return make();
7256
+ }
7257
+ finally {
7258
+ constructingComponentRoot = false;
7259
+ }
7260
+ }
7046
7261
  function applyFallthroughProps(props, component) {
7047
7262
  if (!props || typeof props !== 'object' || component.isDisposed)
7048
7263
  return;
@@ -7092,35 +7307,51 @@
7092
7307
  return null;
7093
7308
  }, 'findAppendableComponent', null);
7094
7309
  }
7310
+ const attachWaiters = new Set();
7311
+ let attachObserver = null;
7312
+ function releaseAttachObserver() {
7313
+ if (attachWaiters.size || !attachObserver) {
7314
+ return;
7315
+ }
7316
+ try {
7317
+ attachObserver.disconnect();
7318
+ }
7319
+ catch { /* ignore */ }
7320
+ attachObserver = null;
7321
+ }
7322
+ function flushAttachWaiters() {
7323
+ for (const waiter of [...attachWaiters]) {
7324
+ if (!attachWaiters.has(waiter) || !document.contains(waiter.element)) {
7325
+ continue;
7326
+ }
7327
+ attachWaiters.delete(waiter);
7328
+ try {
7329
+ waiter.callback();
7330
+ }
7331
+ catch (error) {
7332
+ queueMicrotask(() => { throw error; });
7333
+ }
7334
+ }
7335
+ releaseAttachObserver();
7336
+ }
7095
7337
  function onElementAttached(element, callback) {
7096
7338
  if (document.contains(element)) {
7097
7339
  callback();
7098
7340
  return null;
7099
7341
  }
7100
- let done = false;
7101
- const observer = new MutationObserver(() => {
7102
- if (done) {
7103
- return;
7104
- }
7105
- if (document.contains(element)) {
7106
- done = true;
7107
- observer.disconnect();
7108
- callback();
7109
- }
7110
- });
7111
- observer.observe(document.documentElement, {
7112
- childList: true,
7113
- subtree: true,
7114
- });
7342
+ const waiter = { element, callback };
7343
+ attachWaiters.add(waiter);
7344
+ if (!attachObserver) {
7345
+ attachObserver = new MutationObserver(flushAttachWaiters);
7346
+ attachObserver.observe(document.documentElement, {
7347
+ childList: true,
7348
+ subtree: true,
7349
+ });
7350
+ }
7115
7351
  return () => {
7116
- if (done) {
7117
- return;
7118
- }
7119
- done = true;
7120
- try {
7121
- observer.disconnect();
7352
+ if (attachWaiters.delete(waiter)) {
7353
+ releaseAttachObserver();
7122
7354
  }
7123
- catch { /* ignore */ }
7124
7355
  };
7125
7356
  }
7126
7357
  function notifyActivated(component) {
@@ -7176,8 +7407,6 @@
7176
7407
  return dom.createElement(tag, props);
7177
7408
  }
7178
7409
  class Component extends ComponentBase {
7179
- static elementTag;
7180
- static elementNamespace;
7181
7410
  constructor() {
7182
7411
  const derivedCtor = new.target;
7183
7412
  var args = arguments;
@@ -7257,9 +7486,11 @@
7257
7486
  // Alt sınıflar initializeComponent'i ezdiği için FragmentNode.initializeComponent'e güvenilemez.
7258
7487
  const kids = this.childs;
7259
7488
  if (Array.isArray(kids) && kids.length) {
7260
- for (const kid of kids) {
7261
- if (kid)
7262
- this.controls.add(kid);
7489
+ if (derivedCtor?._placesChilds !== true) {
7490
+ for (const kid of kids) {
7491
+ if (kid)
7492
+ this.controls.add(kid);
7493
+ }
7263
7494
  }
7264
7495
  }
7265
7496
  }
@@ -7281,6 +7512,7 @@
7281
7512
  if (!(target instanceof ComponentBase))
7282
7513
  return target;
7283
7514
  applyRefs(target, refs.concat(extractRefs(props)));
7515
+ disposeUnplacedChilds(target, props.childs);
7284
7516
  // Fonksiyon bileşeni etiketindeki ortak öznitelikler (class/id/aria-*…) döndürülen köke düşer.
7285
7517
  // Kök `<div {...props}/>` ise aynı değerler zaten uygulanmıştır; ikinci kez uygulanmaz.
7286
7518
  applyFallthroughProps(props, target);
@@ -7291,8 +7523,7 @@
7291
7523
  const runover = props.runover;
7292
7524
  if (!runover || typeof runover !== 'object')
7293
7525
  return target;
7294
- const handlers = target._base?._onConfigHandlers;
7295
- const configuredBefore = Array.isArray(handlers) ? handlers.length : 0;
7526
+ const configuredBefore = handlerCount(target, '_onConfigHandlers');
7296
7527
  const initializingBefore = handlerCount(target, '_onInitializingHandlers');
7297
7528
  const initializedBefore = handlerCount(target, '_onInitializedHandlers');
7298
7529
  ParseProps(runover, target);
@@ -7306,12 +7537,9 @@
7306
7537
  if (typeof pre === 'function') {
7307
7538
  safeCallSilent(() => pre(target), 'motifComponent.preconfig');
7308
7539
  }
7309
- const after = target._base?._onConfigHandlers;
7310
- if (Array.isArray(after)) {
7311
- for (let i = configuredBefore; i < after.length; i++) {
7312
- const fn = after[i];
7313
- callReported(() => fn(target, { cancel: false }), 'MJX122', 'onConfig');
7314
- }
7540
+ for (let i = configuredBefore; i < handlerCount(target, '_onConfigHandlers'); i++) {
7541
+ const fn = hookList(target, '_onConfigHandlers')[i];
7542
+ callReported(() => fn(target, { cancel: false }), 'MJX122', 'onConfig');
7315
7543
  }
7316
7544
  }
7317
7545
  return target;
@@ -7324,18 +7552,18 @@
7324
7552
  }
7325
7553
  return target;
7326
7554
  }
7555
+ function hookList(target, listName) {
7556
+ const slot = target._base?.[listName];
7557
+ return !slot ? [] : typeof slot === 'function' ? [slot] : slot;
7558
+ }
7327
7559
  function handlerCount(target, listName) {
7328
- const list = target._base?.[listName];
7329
- return Array.isArray(list) ? list.length : 0;
7560
+ return hookList(target, listName).length;
7330
7561
  }
7331
7562
  function callAddedHandlers(target, listName, from, hook) {
7332
- const list = target._base?.[listName];
7333
- if (!Array.isArray(list))
7334
- return;
7335
- for (let i = from; i < list.length; i++) {
7563
+ for (let i = from; i < handlerCount(target, listName); i++) {
7336
7564
  if (target.isDisposed)
7337
7565
  return;
7338
- const fn = list[i];
7566
+ const fn = hookList(target, listName)[i];
7339
7567
  callReported(() => fn(target, { cancel: false }), 'MJX122', hook);
7340
7568
  }
7341
7569
  }
@@ -7355,9 +7583,22 @@
7355
7583
  return value;
7356
7584
  return undefined;
7357
7585
  }
7358
- function motifComponent(element, props) {
7586
+ function motifComponent(element, props, lone) {
7359
7587
  // Etiket adı: element yaratımı (HTML/SVG) ve spread prop uygulaması Component ctor'ının string parametresinde
7360
7588
  if (typeof element === "string") {
7589
+ if (typeof props === "function") {
7590
+ const compiled = new Component(element);
7591
+ compiled._init = props;
7592
+ return compiled;
7593
+ }
7594
+ if (lone === 1 && props !== null && typeof props === "object") {
7595
+ const init = props.initializeComponent;
7596
+ if (typeof init === "function") {
7597
+ const compiled = new Component(element);
7598
+ compiled._init = init;
7599
+ return compiled;
7600
+ }
7601
+ }
7361
7602
  if (element === "text" && props && props.__childExpr) {
7362
7603
  const resolved = resolveChildExpression(props.__childExpr);
7363
7604
  if (resolved !== undefined)
@@ -7419,7 +7660,9 @@
7419
7660
  return resolved;
7420
7661
  }
7421
7662
  function materializeOptionsObject(spec, props) {
7422
- const result = motifComponent(spec.el, props);
7663
+ const result = typeof spec.el === 'string'
7664
+ ? constructComponentRoot(() => motifComponent(spec.el, props))
7665
+ : motifComponent(spec.el, props);
7423
7666
  Object.getOwnPropertyNames(spec).forEach(key => {
7424
7667
  if (key !== 'el' && key !== 'ctor') {
7425
7668
  result[key] = spec[key];
@@ -7455,7 +7698,7 @@
7455
7698
  }
7456
7699
  }
7457
7700
  safeCallSilent(() => {
7458
- const nodes = this.motif.options?.props?.nodes;
7701
+ const nodes = this.props?.nodes;
7459
7702
  if (Array.isArray(nodes) && nodes.length) {
7460
7703
  for (const n of nodes) {
7461
7704
  if (n)
@@ -7617,11 +7860,10 @@
7617
7860
 
7618
7861
  // import { dom } from "../browser";
7619
7862
  class ControlCollection {
7620
- owner;
7621
7863
  constructor(owner) {
7622
7864
  this.owner = owner;
7865
+ this.items = [];
7623
7866
  }
7624
- items = [];
7625
7867
  add() {
7626
7868
  const count = arguments.length;
7627
7869
  if (count === 0)
@@ -7701,7 +7943,7 @@
7701
7943
  this.items.splice(index, 1);
7702
7944
  if (control.isDisposed)
7703
7945
  return Promise.resolve();
7704
- control._base && (control._base._leaveContainer = this.owner);
7946
+ control._leaveContainer = this.owner;
7705
7947
  control.parent = null;
7706
7948
  return runLeaveThenDetach(control, () => { if (this.onRemove)
7707
7949
  this.onRemove(control); });
@@ -7731,7 +7973,7 @@
7731
7973
  if (index === -1)
7732
7974
  return;
7733
7975
  this.items.splice(index, 1);
7734
- control._base && (control._base._leaveContainer = this.owner);
7976
+ control._leaveContainer = this.owner;
7735
7977
  control.parent = null;
7736
7978
  }
7737
7979
  async clearAsync() {
@@ -7756,9 +7998,6 @@
7756
7998
  map(callbackfn) {
7757
7999
  return this.items.map(callbackfn);
7758
8000
  }
7759
- onAdd;
7760
- onRemove;
7761
- onAddBeforeBuild;
7762
8001
  move(control, before) {
7763
8002
  if (!control || control.isDisposed)
7764
8003
  return;
@@ -7786,14 +8025,29 @@
7786
8025
  const insertAt = newBeforeIndex >= 0 ? newBeforeIndex : this.items.length;
7787
8026
  this.items.splice(insertAt, 0, control);
7788
8027
  }
7789
- if (control.isWait) {
7790
- return;
7791
- }
7792
8028
  const container = findAppendableElement(this.owner);
7793
- if (!container)
8029
+ if (!container || !domAnchor(control, container))
7794
8030
  return;
7795
- const referenceNode = before ? before.element : computeAppendReference(this.owner);
7796
- moveComponentDomRange(control, container, referenceNode);
8031
+ const at = before ? this.items.indexOf(before) : -1;
8032
+ moveComponentDomRange(control, container, at >= 0 ? anchorFrom(this.owner, this.items, at, container) : computeAppendReference(this.owner));
8033
+ }
8034
+ _reorder(order, stable) {
8035
+ const container = findAppendableElement(this.owner);
8036
+ if (container) {
8037
+ let ref = computeAppendReference(this.owner);
8038
+ for (let i = order.length - 1; i >= 0; i--) {
8039
+ const control = order[i];
8040
+ const node = domAnchor(control, container);
8041
+ if (!node)
8042
+ continue;
8043
+ if (!stable.has(i))
8044
+ moveComponentDomRange(control, container, ref);
8045
+ ref = node;
8046
+ }
8047
+ }
8048
+ const items = this.items;
8049
+ for (let i = 0; i < order.length; i++)
8050
+ items[i] = order[i];
7797
8051
  }
7798
8052
  moveToIndex(control, index) {
7799
8053
  if (!control || control.isDisposed)
@@ -7830,12 +8084,20 @@
7830
8084
  }
7831
8085
  return null;
7832
8086
  }
8087
+ function anchorFrom(owner, items, start, container) {
8088
+ for (let i = start; i < items.length; i++) {
8089
+ const anchor = domAnchor(items[i], container);
8090
+ if (anchor)
8091
+ return anchor;
8092
+ }
8093
+ return computeAppendReference(owner);
8094
+ }
7833
8095
  /** Bir component'in kök DOM aralığını (tek element veya fragment aralığı) referenceNode öncesine taşır. */
7834
8096
  function moveComponentDomRange(control, container, referenceNode) {
7835
- const node = control.element;
8097
+ const node = domAnchor(control, container);
7836
8098
  if (!node)
7837
8099
  return;
7838
- if (node.nodeType !== Node.COMMENT_NODE) {
8100
+ if (node.nodeType !== Node.COMMENT_NODE || node !== control.element) {
7839
8101
  try {
7840
8102
  container.insertBefore(node, referenceNode);
7841
8103
  }
@@ -7918,9 +8180,7 @@
7918
8180
  if (!node)
7919
8181
  return;
7920
8182
  const opts = control.motif.options;
7921
- if (node.nodeType === Node.COMMENT_NODE) {
7922
- if (!node.parentNode)
7923
- return;
8183
+ if (node.nodeType === Node.COMMENT_NODE && node.parentNode) {
7924
8184
  const close = opts?.closeFragment || null;
7925
8185
  const cache = opts.cache ?? (opts.cache = dom.createDocumentFragment());
7926
8186
  let current = node;
@@ -8393,13 +8653,12 @@
8393
8653
  }
8394
8654
 
8395
8655
  class Frame extends Component {
8396
- current = null;
8397
- _latestNavigateId = 0;
8398
- _navLock = Promise.resolve();
8399
- _navAbort;
8400
- isBusy = false;
8401
8656
  constructor(props) {
8402
8657
  super(dom.createComment(''), props);
8658
+ this.current = null;
8659
+ this._latestNavigateId = 0;
8660
+ this._navLock = Promise.resolve();
8661
+ this.isBusy = false;
8403
8662
  if (props && props.childs && Array.isArray(props.childs) && props.childs.length > 0) {
8404
8663
  this.controls.add(props.childs);
8405
8664
  }
@@ -8414,7 +8673,6 @@
8414
8673
  async _clear() {
8415
8674
  await disposeNavigationTarget(this.current);
8416
8675
  }
8417
- previouspage;
8418
8676
  async navigate(page, keepOldControl = false) {
8419
8677
  await navigateHost(this, page, keepOldControl);
8420
8678
  }
@@ -8508,7 +8766,7 @@
8508
8766
  const SLOT_REGISTERED_EVENT = Symbol('slotRegistered');
8509
8767
  const SLOT_UNREGISTERED_EVENT = Symbol('slotUnregistered');
8510
8768
  class TransportRegistry {
8511
- static slots = new Map();
8769
+ static { this.slots = new Map(); }
8512
8770
  static registerSlot(name, slot) {
8513
8771
  this.slots.set(name, slot);
8514
8772
  Application.main.fire(SLOT_REGISTERED_EVENT, { name, slot });
@@ -8525,7 +8783,6 @@
8525
8783
  }
8526
8784
 
8527
8785
  class Transport extends Component {
8528
- mode;
8529
8786
  constructor(props) {
8530
8787
  super(props);
8531
8788
  this.mode = props.mode || 'replace';
@@ -8613,28 +8870,34 @@
8613
8870
  }
8614
8871
 
8615
8872
  class TransportTo extends Component {
8616
- _onAddRef;
8617
- _onRemoveRef;
8618
- _slotRegisteredListener;
8619
- _slotUnregisteredListener;
8620
- _transported = [];
8621
- _countedLive = false;
8622
8873
  constructor(props) {
8623
8874
  super('div', props);
8875
+ this._transported = [];
8876
+ this._countedLive = false;
8877
+ this._handleSlotChange = (eventArgs) => {
8878
+ if (eventArgs.name === this.props.name) {
8879
+ const slot = eventArgs.slot;
8880
+ if (slot.mode !== 'merge') {
8881
+ slot.clearSlot?.();
8882
+ }
8883
+ const all = [...(this.childs || []), ...this.controls.items];
8884
+ Transporter.transportMany(all, slot);
8885
+ this._rememberTransported(all);
8886
+ }
8887
+ };
8888
+ this._clearChildrenFromSlot = (slot) => {
8889
+ (this.childs || []).forEach(child => {
8890
+ slot.controls.remove(child);
8891
+ child.dispose();
8892
+ });
8893
+ (this.controls.items || []).forEach(child => {
8894
+ slot.controls.remove(child);
8895
+ child.dispose();
8896
+ });
8897
+ };
8624
8898
  contentBlocks.live++;
8625
8899
  this._countedLive = true;
8626
8900
  }
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
8901
  _rememberTransported(children) {
8639
8902
  const kept = this._transported.filter(c => !c.isDisposed);
8640
8903
  for (const child of children) {
@@ -8643,16 +8906,6 @@
8643
8906
  }
8644
8907
  this._transported = kept;
8645
8908
  }
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
8909
  initializeComponent(sender) {
8657
8910
  let slot = TransportRegistry.getSlot(this.props.name);
8658
8911
  if (slot) {
@@ -8852,11 +9105,10 @@
8852
9105
  ];
8853
9106
  const isLookupMiss = (outcome) => outcome === false || outcome === -1;
8854
9107
  class ArrayMethods {
8855
- engine;
8856
9108
  constructor(engine) {
8857
9109
  this.engine = engine;
9110
+ this.get = this.createArrayMethods();
8858
9111
  }
8859
- get = this.createArrayMethods();
8860
9112
  createArrayMethods() {
8861
9113
  const table = {};
8862
9114
  for (const [name, kind] of PATCHED_ARRAY_METHODS) {
@@ -9048,7 +9300,6 @@
9048
9300
  const AllreactiveMap = new WeakMap();
9049
9301
  function armgetter() { return AllreactiveMap; }
9050
9302
  class ReactiveEngine {
9051
- _gci;
9052
9303
  startGc(_intervalMs = 10000) { }
9053
9304
  stopGc() { if (this._gci) {
9054
9305
  try {
@@ -9058,31 +9309,30 @@
9058
9309
  this._gci = undefined;
9059
9310
  } }
9060
9311
  constructor() {
9312
+ this.DisposeMapper = new LinkedList();
9313
+ this.arrayTriggerCache = new Map();
9314
+ this.ReactiveMap = () => armgetter();
9315
+ this.isReadonly = false;
9316
+ this.superficial = false;
9317
+ this.arrayMethods = new ArrayMethods(this);
9318
+ this.arrayHandler = {
9319
+ get: createGetter(this),
9320
+ set: createSetter(this),
9321
+ has: createHas(),
9322
+ deleteProperty: createDelete(),
9323
+ ownKeys: createOwn()
9324
+ };
9325
+ this.deepHandler = {
9326
+ get: createGetter(this),
9327
+ set: createSetter(this),
9328
+ has: createHas(),
9329
+ deleteProperty: createDelete(),
9330
+ ownKeys: createOwn()
9331
+ };
9332
+ this.collectionHandler = createCollectionHandler(this);
9061
9333
  ReactiveEngineMapper.add(this);
9062
9334
  this.startGc();
9063
9335
  }
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
9336
  reactive(model) {
9087
9337
  if (!isObject(model)) {
9088
9338
  model = { value: model };
@@ -9145,7 +9395,6 @@
9145
9395
  ArrayTrigger(target, key, ...args) {
9146
9396
  this.trigger(target, key, args);
9147
9397
  }
9148
- onValueChanged;
9149
9398
  toRaw(item) {
9150
9399
  return JSON.parse(JSON.stringify(this.deepClone(item)));
9151
9400
  }
@@ -9320,19 +9569,35 @@
9320
9569
  }
9321
9570
 
9322
9571
  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
9572
  constructor(props) {
9335
9573
  super('div', props);
9574
+ this._cache = new Map();
9575
+ this._view = [];
9576
+ this._occurrence = [];
9577
+ this._occurrenceKeys = new WeakMap();
9578
+ this._isLoadingMore = false;
9579
+ this._emptyRendered = false;
9580
+ this._renderPending = false;
9581
+ this.contentWrapper = new Component();
9582
+ this._initialLoadStarted = false;
9583
+ this._offsets = null;
9584
+ this._observedHeight = -1;
9585
+ this._loadSeq = 0;
9586
+ this._reloadScheduled = false;
9587
+ this._reloadTimes = [];
9588
+ this._handleScroll = (_sender, _event) => {
9589
+ this.renderViewport();
9590
+ if (this.props.autoLoad === false)
9591
+ return;
9592
+ if (!this._state.hasMore || this._isLoadingMore || !this._state.isInitialized)
9593
+ return;
9594
+ const el = this.wrapper.element;
9595
+ const fixed = this._fixedHeight();
9596
+ const loadedBottom = fixed !== null ? this._state.data.length * fixed : this._offsetOf(this._view.length);
9597
+ const distanceToLoaded = loadedBottom - (el.scrollTop + el.clientHeight);
9598
+ if (distanceToLoaded < (this.props.autoLoadThreshold ?? 100))
9599
+ void this._loadMore();
9600
+ };
9336
9601
  if (props.className)
9337
9602
  this.class.add(props.className);
9338
9603
  if (props.style)
@@ -9354,8 +9619,6 @@
9354
9619
  this.renderViewport = this.renderViewport.bind(this);
9355
9620
  this._makeView();
9356
9621
  }
9357
- contentWrapper = new Component();
9358
- wrapper;
9359
9622
  _makeView() {
9360
9623
  this._topSpacer = new Component('div');
9361
9624
  this._topSpacer.element.style.cssText = 'height: 0px;';
@@ -9384,7 +9647,6 @@
9384
9647
  this.motif.on('scroll', this._handleScroll);
9385
9648
  }
9386
9649
  }
9387
- _initialLoadStarted = false;
9388
9650
  onBuilding() {
9389
9651
  if (this.props.mainTemplate || this._initialLoadStarted)
9390
9652
  return;
@@ -9401,10 +9663,6 @@
9401
9663
  this._stopDataWatch();
9402
9664
  this._clearContent();
9403
9665
  }
9404
- _offsets = null;
9405
- _resizeObserver;
9406
- _observed;
9407
- _observedHeight = -1;
9408
9666
  _fixedHeight() {
9409
9667
  const h = this.props.itemHeight;
9410
9668
  return typeof h === 'function' ? null : h;
@@ -9486,10 +9744,6 @@
9486
9744
  this._resizeObserver = undefined;
9487
9745
  this._observed = undefined;
9488
9746
  }
9489
- _loadSeq = 0;
9490
- _dataWatchStop;
9491
- _reloadScheduled = false;
9492
- _reloadTimes = [];
9493
9747
  _stopDataWatch() {
9494
9748
  this._dataWatchStop?.();
9495
9749
  this._dataWatchStop = undefined;
@@ -9588,19 +9842,6 @@
9588
9842
  this._renderErrorState(error);
9589
9843
  }
9590
9844
  }
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
9845
  async _loadInitial() {
9605
9846
  const seq = ++this._loadSeq;
9606
9847
  this._state.isLoading = true;
@@ -9919,7 +10160,9 @@
9919
10160
  }
9920
10161
  }
9921
10162
  class ServiceCollection {
9922
- descriptors = new Map();
10163
+ constructor() {
10164
+ this.descriptors = new Map();
10165
+ }
9923
10166
  reset() {
9924
10167
  this.descriptors.clear();
9925
10168
  }
@@ -10176,7 +10419,7 @@
10176
10419
  }
10177
10420
 
10178
10421
  class RouterViewRegistry {
10179
- static outlets = new Map();
10422
+ static { this.outlets = new Map(); }
10180
10423
  static register(name, scopeId, instance) {
10181
10424
  if (!this.outlets.has(name))
10182
10425
  this.outlets.set(name, new Map());
@@ -10205,9 +10448,12 @@
10205
10448
  class RouterView extends Component {
10206
10449
  constructor(props) {
10207
10450
  super(props);
10451
+ this._navLock = Promise.resolve();
10452
+ this.disposingChilds = false;
10453
+ this.current = null;
10454
+ this._latestNavigateId = 0;
10455
+ this.isBusy = false;
10208
10456
  }
10209
- _navLock = Promise.resolve();
10210
- _navAbort;
10211
10457
  get __isRouterView() {
10212
10458
  return true;
10213
10459
  }
@@ -10219,11 +10465,6 @@
10219
10465
  }
10220
10466
  return ids.join('>');
10221
10467
  }
10222
- disposingChilds = false;
10223
- previouspage;
10224
- current = null;
10225
- _latestNavigateId = 0;
10226
- isBusy = false;
10227
10468
  async navigate(page, keepOldControl = false) {
10228
10469
  await navigateHost(this, page, keepOldControl);
10229
10470
  }
@@ -10254,18 +10495,16 @@
10254
10495
  const DEFAULT_SETTLE_MS = 1200;
10255
10496
  const USER_INPUT = ['wheel', 'touchstart', 'keydown', 'mousedown'];
10256
10497
  class ScrollMemory {
10257
- options;
10258
- viewport;
10259
- positions = new Map();
10260
- currentKey = '';
10261
- currentPath = null;
10262
- visited = false;
10263
- restoring = false;
10264
- cancelFrame = null;
10265
- disarmAbort = null;
10266
- offs = [];
10267
- locationAnchor = true;
10268
10498
  constructor(options = {}, viewport) {
10499
+ this.positions = new Map();
10500
+ this.currentKey = '';
10501
+ this.currentPath = null;
10502
+ this.visited = false;
10503
+ this.restoring = false;
10504
+ this.cancelFrame = null;
10505
+ this.disarmAbort = null;
10506
+ this.offs = [];
10507
+ this.locationAnchor = true;
10269
10508
  this.options = options;
10270
10509
  this.viewport = viewport ?? (options.container ? containerViewport(options.container) : windowViewport());
10271
10510
  this.load();
@@ -10668,24 +10907,18 @@
10668
10907
  }
10669
10908
  }
10670
10909
  class NavigationStack {
10671
- retainAttached;
10672
- depth;
10673
- persist;
10674
- animation;
10675
- duration;
10676
- swipe;
10677
- session = null;
10678
- entries = new Map();
10679
- uris = new Map();
10680
- loaded = null;
10681
- current = null;
10682
- currentTop = null;
10683
- offs = [];
10684
- gesture = null;
10685
- gestureCommitted = false;
10686
- awaitingGestureResult = false;
10687
- disposed = false;
10688
10910
  constructor(options) {
10911
+ this.session = null;
10912
+ this.entries = new Map();
10913
+ this.uris = new Map();
10914
+ this.loaded = null;
10915
+ this.current = null;
10916
+ this.currentTop = null;
10917
+ this.offs = [];
10918
+ this.gesture = null;
10919
+ this.gestureCommitted = false;
10920
+ this.awaitingGestureResult = false;
10921
+ this.disposed = false;
10689
10922
  const o = options === true ? {} : options;
10690
10923
  this.retainAttached = o.retain === true;
10691
10924
  this.depth = Math.max(0, Math.floor(o.depth ?? 5));
@@ -11194,13 +11427,28 @@
11194
11427
  }
11195
11428
 
11196
11429
  class Scanner {
11197
- source;
11198
11430
  constructor(source) {
11199
11431
  this.source = source;
11432
+ this.currentColumn = 0;
11433
+ this.tokens = [];
11434
+ this.parameters = {};
11435
+ this.codePointAt = String.prototype.codePointAt ?
11436
+ (s, i) => s.codePointAt(i) : function codePointAt(str, i) {
11437
+ const size = str.length;
11438
+ if (i < 0 || i >= size) {
11439
+ return undefined;
11440
+ }
11441
+ const first = str.charCodeAt(i);
11442
+ if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) {
11443
+ const second = str.charCodeAt(i + 1);
11444
+ if (second >= 0xDC00 && second <= 0xDFFF) {
11445
+ return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
11446
+ }
11447
+ }
11448
+ return first;
11449
+ };
11200
11450
  this.tokens = [];
11201
11451
  }
11202
- currentColumn = 0;
11203
- tokens = [];
11204
11452
  addToken(token) {
11205
11453
  this.tokens.push(token);
11206
11454
  }
@@ -11428,7 +11676,6 @@
11428
11676
  pattern += '$';
11429
11677
  return new RegExp(pattern, "i");
11430
11678
  }
11431
- parameters = {};
11432
11679
  exist(input, pageSearch) {
11433
11680
  const hashIdx = input.indexOf('#');
11434
11681
  const withoutHash = hashIdx >= 0 ? input.substring(0, hashIdx) : input;
@@ -11512,21 +11759,6 @@
11512
11759
  }
11513
11760
  return false;
11514
11761
  }
11515
- codePointAt = String.prototype.codePointAt ?
11516
- (s, i) => s.codePointAt(i) : function codePointAt(str, i) {
11517
- const size = str.length;
11518
- if (i < 0 || i >= size) {
11519
- return undefined;
11520
- }
11521
- const first = str.charCodeAt(i);
11522
- if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) {
11523
- const second = str.charCodeAt(i + 1);
11524
- if (second >= 0xDC00 && second <= 0xDFFF) {
11525
- return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
11526
- }
11527
- }
11528
- return first;
11529
- };
11530
11762
  }
11531
11763
 
11532
11764
  /** Bir fullPath'in statik (parametresiz) ve parametreli segment sayıları. */
@@ -11554,11 +11786,41 @@
11554
11786
  return b.fullPath.length - a.fullPath.length;
11555
11787
  }
11556
11788
  class RouteCollection {
11557
- routes;
11558
- records = [];
11559
- routesMap = new Map();
11560
11789
  constructor(routes) {
11561
11790
  this.routes = routes;
11791
+ this.records = [];
11792
+ this.routesMap = new Map();
11793
+ this.walk = (chain, parentPath, node, viaAlias = false) => {
11794
+ const fullPath = this.joinPaths(parentPath, node.path);
11795
+ if (!viaAlias) {
11796
+ const existing = node.fullPath;
11797
+ if (existing == null || (typeof existing === 'string' && existing.trim() === '')) {
11798
+ node.fullPath = fullPath;
11799
+ }
11800
+ if (node.name != null) {
11801
+ this.routesMap.set(node.name, node);
11802
+ }
11803
+ }
11804
+ const nextChain = [...chain, node];
11805
+ const aliases = node.alias == null ? [] : (Array.isArray(node.alias) ? node.alias : [node.alias]);
11806
+ const variants = [
11807
+ { path: fullPath, isAlias: viaAlias },
11808
+ ...aliases.map(a => ({ path: this.joinPaths(parentPath, a), isAlias: true }))
11809
+ ];
11810
+ for (const variant of variants) {
11811
+ this.records.push({
11812
+ fullPath: variant.path,
11813
+ chain: nextChain,
11814
+ leaf: node,
11815
+ scanner: new Scanner(variant.path),
11816
+ aliasOf: variant.isAlias ? (node.fullPath ?? null) : null
11817
+ });
11818
+ if (node.childs && node.childs.length) {
11819
+ for (const child of node.childs)
11820
+ this.walk(nextChain, variant.path, child, variant.isAlias);
11821
+ }
11822
+ }
11823
+ };
11562
11824
  this.build();
11563
11825
  }
11564
11826
  build() {
@@ -11568,37 +11830,6 @@
11568
11830
  this.walk([], "", r);
11569
11831
  this.records.sort(compareRouteRecords);
11570
11832
  }
11571
- walk = (chain, parentPath, node, viaAlias = false) => {
11572
- const fullPath = this.joinPaths(parentPath, node.path);
11573
- if (!viaAlias) {
11574
- const existing = node.fullPath;
11575
- if (existing == null || (typeof existing === 'string' && existing.trim() === '')) {
11576
- node.fullPath = fullPath;
11577
- }
11578
- if (node.name != null) {
11579
- this.routesMap.set(node.name, node);
11580
- }
11581
- }
11582
- const nextChain = [...chain, node];
11583
- const aliases = node.alias == null ? [] : (Array.isArray(node.alias) ? node.alias : [node.alias]);
11584
- const variants = [
11585
- { path: fullPath, isAlias: viaAlias },
11586
- ...aliases.map(a => ({ path: this.joinPaths(parentPath, a), isAlias: true }))
11587
- ];
11588
- for (const variant of variants) {
11589
- this.records.push({
11590
- fullPath: variant.path,
11591
- chain: nextChain,
11592
- leaf: node,
11593
- scanner: new Scanner(variant.path),
11594
- aliasOf: variant.isAlias ? (node.fullPath ?? null) : null
11595
- });
11596
- if (node.childs && node.childs.length) {
11597
- for (const child of node.childs)
11598
- this.walk(nextChain, variant.path, child, variant.isAlias);
11599
- }
11600
- }
11601
- };
11602
11833
  joinPaths(parent, child) {
11603
11834
  parent = parent || "";
11604
11835
  child = child || "";
@@ -11615,19 +11846,22 @@
11615
11846
  }
11616
11847
 
11617
11848
  class RoutingEngine {
11618
- stack = null;
11619
- _revealed = new Set();
11620
- root;
11621
- application;
11622
- routingModule;
11623
- _previousPath = null;
11624
- _previousInstances = [];
11849
+ constructor() {
11850
+ this.stack = null;
11851
+ this._revealed = new Set();
11852
+ this._previousPath = null;
11853
+ this._previousInstances = [];
11854
+ this.controlCache = new Map();
11855
+ this._navVersion = 0;
11856
+ this._pendingActivate = new Set();
11857
+ this.pendingMount = new WeakMap();
11858
+ this.pendingListeners = new WeakMap();
11859
+ }
11625
11860
  register(mainApp, application, routingModule) {
11626
11861
  this.root = mainApp;
11627
11862
  this.application = application;
11628
11863
  this.routingModule = routingModule;
11629
11864
  }
11630
- controlCache = new Map();
11631
11865
  async evict(route) {
11632
11866
  const targets = route ? [route] : Array.from(this.controlCache.keys());
11633
11867
  for (const r of targets) {
@@ -11689,8 +11923,6 @@
11689
11923
  }
11690
11924
  return result;
11691
11925
  }
11692
- _navVersion = 0;
11693
- _pendingActivate = new Set();
11694
11926
  async execute(path, nav, route) {
11695
11927
  route ??= {
11696
11928
  target: path,
@@ -12161,9 +12393,7 @@
12161
12393
  }
12162
12394
  async activator(container) {
12163
12395
  }
12164
- pendingMount = new WeakMap();
12165
- pendingListeners = new WeakMap();
12166
- static OUTLET_WARN_MS = 3000;
12396
+ static { this.OUTLET_WARN_MS = 3000; }
12167
12397
  async mountChain(instances, chain, container, navVersion) {
12168
12398
  for (let index = 0; index < instances.length;) {
12169
12399
  if (navVersion !== this._navVersion)
@@ -12335,17 +12565,20 @@
12335
12565
  const pathOf = (uri) => uri.split('#')[0].split('?')[0];
12336
12566
  const newHistorySession = () => Math.random().toString(36).slice(2, 10) + Date.now().toString(36);
12337
12567
  class UrlRoutingModule {
12338
- static MAX_REDIRECTS = 10;
12339
- _routerOptions;
12340
- routingEngine;
12341
- routeCollection;
12342
- routesMap = new Map();
12343
- mainApp;
12344
- application;
12345
- _suppressBeforeEachOnce = false;
12346
- _suppressMiddlewaresOnce = false;
12347
- _scroll = null;
12568
+ static { this.MAX_REDIRECTS = 10; }
12348
12569
  constructor(options, application) {
12570
+ this.routesMap = new Map();
12571
+ this._suppressBeforeEachOnce = false;
12572
+ this._suppressMiddlewaresOnce = false;
12573
+ this._scroll = null;
12574
+ this._stack = null;
12575
+ this._windowNavListener = null;
12576
+ this._historyStamp = null;
12577
+ this._pendingTraversal = null;
12578
+ this._currentUri = '___startup___';
12579
+ this._previousRoute = null;
12580
+ this._fallbackRoutes = {};
12581
+ this._navHandler = null;
12349
12582
  this._routerOptions = options;
12350
12583
  this.routeCollection = new RouteCollection(options.RouteItems);
12351
12584
  this.routingEngine = new RoutingEngine();
@@ -12361,11 +12594,9 @@
12361
12594
  this.routingEngine.stack = this._stack;
12362
12595
  }
12363
12596
  }
12364
- _stack = null;
12365
12597
  getHooks() {
12366
12598
  return this._routerOptions.hooks;
12367
12599
  }
12368
- _windowNavListener = null;
12369
12600
  start(mainApp, shellUri) {
12370
12601
  this.mainApp = mainApp;
12371
12602
  this.routingEngine.register(this.mainApp, this.application, this);
@@ -12397,8 +12628,7 @@
12397
12628
  return '/';
12398
12629
  }
12399
12630
  }
12400
- static HISTORY_STAMP_KEY = '__motifHistory';
12401
- _historyStamp = null;
12631
+ static { this.HISTORY_STAMP_KEY = '__motifHistory'; }
12402
12632
  _addressMode() {
12403
12633
  const w = window;
12404
12634
  return this._routerOptions.mode || (w?.location?.protocol === 'file:' ? 'hash' : 'history');
@@ -12494,7 +12724,6 @@
12494
12724
  this._stampCurrentEntry(stamp);
12495
12725
  this._historyStamp = stamp;
12496
12726
  }
12497
- _pendingTraversal = null;
12498
12727
  async _onHistoryTraversal() {
12499
12728
  const shown = this._historyStamp;
12500
12729
  const arrived = this._readHistoryStamp();
@@ -12530,8 +12759,6 @@
12530
12759
  }
12531
12760
  catch { }
12532
12761
  }
12533
- _currentUri = '___startup___';
12534
- _previousRoute = null;
12535
12762
  get currentUri() {
12536
12763
  return this._currentUri;
12537
12764
  }
@@ -12770,7 +12997,6 @@
12770
12997
  }
12771
12998
  await this.routingEngine.evict(item);
12772
12999
  }
12773
- _fallbackRoutes = {};
12774
13000
  _getFallbackRoute(kind) {
12775
13001
  const existing = this._fallbackRoutes[kind];
12776
13002
  if (existing)
@@ -12843,7 +13069,7 @@
12843
13069
  }
12844
13070
  return best ? { chain: best.rec.chain, params: best.params } : null;
12845
13071
  }
12846
- static _builtinNotFound = () => new Component('div', {
13072
+ static { this._builtinNotFound = () => new Component('div', {
12847
13073
  initializeComponent(sender) {
12848
13074
  sender.style({
12849
13075
  padding: '20px', fontFamily: 'Arial, sans-serif', display: 'flex', 'flex-direction': 'column', 'align-items': 'center'
@@ -12851,8 +13077,8 @@
12851
13077
  sender.element.appendChild($('h2', {}, ...['404 - Not Found']));
12852
13078
  sender.element.appendChild($('p', {}, ...['The requested page was not found.']));
12853
13079
  },
12854
- });
12855
- static _builtinError = () => new Component('div', {
13080
+ }); }
13081
+ static { this._builtinError = () => new Component('div', {
12856
13082
  initializeComponent(sender) {
12857
13083
  sender.style({
12858
13084
  padding: '20px', fontFamily: 'Arial, sans-serif', display: 'flex', 'flex-direction': 'column', 'align-items': 'center'
@@ -12860,7 +13086,7 @@
12860
13086
  sender.element.appendChild($('h2', {}, ...['Error']));
12861
13087
  sender.element.appendChild($('p', {}, ...['The requested page could not be loaded.']));
12862
13088
  },
12863
- });
13089
+ }); }
12864
13090
  async navigateByName(name, params, options) {
12865
13091
  return await this.navigate(this.href(name, params), options);
12866
13092
  }
@@ -13016,7 +13242,6 @@
13016
13242
  }
13017
13243
  return true;
13018
13244
  }
13019
- _navHandler = null;
13020
13245
  _installLinkInterceptor() {
13021
13246
  try {
13022
13247
  if (this._navHandler)
@@ -13221,9 +13446,11 @@
13221
13446
  }
13222
13447
 
13223
13448
  class RouterState {
13224
- version = new Signal(0);
13225
- _current = null;
13226
- _constructing = null;
13449
+ constructor() {
13450
+ this.version = new Signal(0);
13451
+ this._current = null;
13452
+ this._constructing = null;
13453
+ }
13227
13454
  read() {
13228
13455
  this.version.value;
13229
13456
  return this._constructing ?? this._current;
@@ -13304,8 +13531,8 @@
13304
13531
  let _globalApplication = null;
13305
13532
  let startedApplicationBuilder = false;
13306
13533
  class ApplicationBuilder {
13307
- services = new ServiceCollection();
13308
13534
  constructor() {
13535
+ this.services = new ServiceCollection();
13309
13536
  if ((_globalApplication && _globalApplication.state !== 'disposing') || startedApplicationBuilder) {
13310
13537
  throw new MotifError('MJX405', formatMotifMessage('MJX405'), { cause: _globalApplication });
13311
13538
  }
@@ -13332,28 +13559,31 @@
13332
13559
  }
13333
13560
  }
13334
13561
  class Application {
13335
- provider;
13336
13562
  static get main() {
13337
13563
  return _globalApplication;
13338
13564
  }
13339
13565
  constructor(provider) {
13340
13566
  this.provider = provider;
13567
+ this._state = 'initializing';
13568
+ this._middlewares = [];
13569
+ this._beforeEachGuards = [];
13570
+ this._routerState = new RouterState();
13571
+ this.router = createRouter(this._routerState, () => this.urlRoutingModule);
13572
+ this.events = new Map();
13573
+ this._routerConfig = null;
13574
+ this._routerRoot = null;
13575
+ this._startedRouter = null;
13576
+ this._lifecycleOff = null;
13577
+ this._isDevelopment = false;
13578
+ this._enableErrorLogging = true;
13341
13579
  }
13342
- static _disposingCount = 0;
13343
- _state = 'initializing';
13344
- _disposing;
13580
+ static { this._disposingCount = 0; }
13345
13581
  get state() {
13346
13582
  return this._state;
13347
13583
  }
13348
- _middlewares = [];
13349
- _beforeEachGuards = [];
13350
- _routerState = new RouterState();
13351
- router = createRouter(this._routerState, () => this.urlRoutingModule);
13352
- events = new Map();
13353
13584
  static CreateBuilder() {
13354
13585
  return new ApplicationBuilder();
13355
13586
  }
13356
- appShell;
13357
13587
  getAppShell() {
13358
13588
  return this.appShell;
13359
13589
  }
@@ -13497,10 +13727,6 @@
13497
13727
  }
13498
13728
  return true;
13499
13729
  }
13500
- urlRoutingModule;
13501
- _routerConfig = null;
13502
- _routerRoot = null;
13503
- _startedRouter = null;
13504
13730
  useRouter(options) {
13505
13731
  let routes;
13506
13732
  let mode;
@@ -13620,7 +13846,6 @@
13620
13846
  return true;
13621
13847
  }
13622
13848
  }
13623
- _lifecycleOff = null;
13624
13849
  onLifecycle(handler) {
13625
13850
  this._installLifecycleListeners();
13626
13851
  return this.on('motifjs-app-lifecycle', handler);
@@ -13662,8 +13887,6 @@
13662
13887
  for (const off of offs)
13663
13888
  off();
13664
13889
  }
13665
- _isDevelopment = false;
13666
- _enableErrorLogging = true;
13667
13890
  get isDevelopmentModeEnabled() {
13668
13891
  return this._isDevelopment;
13669
13892
  }
@@ -13743,12 +13966,6 @@
13743
13966
  class Policy {
13744
13967
  }
13745
13968
  class RetryPolicy extends Policy {
13746
- retries;
13747
- backoff;
13748
- delayMs;
13749
- jitter;
13750
- shouldHandle;
13751
- onRetry;
13752
13969
  constructor(options = {}) {
13753
13970
  super();
13754
13971
  this.retries = options.retries ?? 3;
@@ -13787,7 +14004,6 @@
13787
14004
  }
13788
14005
  }
13789
14006
  class TimeoutPolicy extends Policy {
13790
- timeoutMs;
13791
14007
  constructor(opts) {
13792
14008
  super();
13793
14009
  this.timeoutMs = opts.timeoutMs;
@@ -13807,17 +14023,12 @@
13807
14023
  }
13808
14024
  }
13809
14025
  class CircuitBreakerPolicy extends Policy {
13810
- failureThreshold;
13811
- successThreshold;
13812
- durationOfBreakMs;
13813
- shouldHandle;
13814
- onStateChange;
13815
- state = 'CLOSED';
13816
- failureCount = 0;
13817
- successCount = 0;
13818
- nextAttemptTime = 0;
13819
14026
  constructor(opts = {}) {
13820
14027
  super();
14028
+ this.state = 'CLOSED';
14029
+ this.failureCount = 0;
14030
+ this.successCount = 0;
14031
+ this.nextAttemptTime = 0;
13821
14032
  this.failureThreshold = opts.failureThreshold ?? 5;
13822
14033
  this.successThreshold = opts.successThreshold ?? 2;
13823
14034
  this.durationOfBreakMs = opts.durationOfBreakMs ?? 60000;
@@ -13870,12 +14081,10 @@
13870
14081
  }
13871
14082
  }
13872
14083
  class BulkheadPolicy extends Policy {
13873
- maxConcurrent;
13874
- maxQueue;
13875
- active = 0;
13876
- queue = [];
13877
14084
  constructor(opts = {}) {
13878
14085
  super();
14086
+ this.active = 0;
14087
+ this.queue = [];
13879
14088
  this.maxConcurrent = opts.maxConcurrent ?? 10;
13880
14089
  this.maxQueue = opts.maxQueue ?? 50;
13881
14090
  }
@@ -13908,11 +14117,6 @@
13908
14117
  }
13909
14118
  }
13910
14119
  class RateLimiterPolicy extends Policy {
13911
- tokensPerInterval;
13912
- intervalMs;
13913
- capacity;
13914
- tokens;
13915
- lastRefill;
13916
14120
  constructor(opts = {}) {
13917
14121
  super();
13918
14122
  this.tokensPerInterval = opts.tokensPerInterval ?? 1;
@@ -13942,8 +14146,6 @@
13942
14146
  }
13943
14147
  }
13944
14148
  class FallbackPolicy extends Policy {
13945
- fallback;
13946
- shouldHandle;
13947
14149
  constructor(opts) {
13948
14150
  super();
13949
14151
  this.fallback = opts.fallback;
@@ -13961,7 +14163,6 @@
13961
14163
  }
13962
14164
  }
13963
14165
  class PolicyWrap extends Policy {
13964
- policies;
13965
14166
  constructor(...policies) {
13966
14167
  super();
13967
14168
  this.policies = policies;
@@ -13986,34 +14187,36 @@
13986
14187
  return (ctx) => policy.execute(fn, ctx);
13987
14188
  }
13988
14189
  class Resilience {
14190
+ constructor() {
14191
+ this.resiliences = [];
14192
+ this.retry = (opts) => {
14193
+ this.resiliences.push(resilience.retry(opts));
14194
+ return this;
14195
+ };
14196
+ this.timeout = (opts) => {
14197
+ this.resiliences.push(resilience.timeout(opts));
14198
+ return this;
14199
+ };
14200
+ this.circuitBreaker = (opts) => {
14201
+ this.resiliences.push(resilience.circuitBreaker(opts));
14202
+ return this;
14203
+ };
14204
+ this.bulkhead = (opts) => {
14205
+ this.resiliences.push(resilience.bulkhead(opts));
14206
+ return this;
14207
+ };
14208
+ this.rateLimiter = (opts) => {
14209
+ this.resiliences.push(resilience.rateLimiter(opts));
14210
+ return this;
14211
+ };
14212
+ this.fallback = (opts) => {
14213
+ this.resiliences.push(resilience.fallback(opts));
14214
+ return this;
14215
+ };
14216
+ }
13989
14217
  static get create() {
13990
14218
  return new Resilience();
13991
14219
  }
13992
- resiliences = [];
13993
- retry = (opts) => {
13994
- this.resiliences.push(resilience.retry(opts));
13995
- return this;
13996
- };
13997
- timeout = (opts) => {
13998
- this.resiliences.push(resilience.timeout(opts));
13999
- return this;
14000
- };
14001
- circuitBreaker = (opts) => {
14002
- this.resiliences.push(resilience.circuitBreaker(opts));
14003
- return this;
14004
- };
14005
- bulkhead = (opts) => {
14006
- this.resiliences.push(resilience.bulkhead(opts));
14007
- return this;
14008
- };
14009
- rateLimiter = (opts) => {
14010
- this.resiliences.push(resilience.rateLimiter(opts));
14011
- return this;
14012
- };
14013
- fallback = (opts) => {
14014
- this.resiliences.push(resilience.fallback(opts));
14015
- return this;
14016
- };
14017
14220
  async execute(action, ctx) {
14018
14221
  return resilience.wrap(...this.resiliences).execute(action, ctx);
14019
14222
  }