@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.
@@ -4,10 +4,12 @@ function rethrowLater(error) {
4
4
  setTimeout(() => { throw error; }, 0);
5
5
  }
6
6
  class ErrorHandler {
7
- unexpectedErrorHandler = rethrowLater;
8
- listeners = [];
9
- _isDevelopment = false;
10
- _enableConsoleLogging = true;
7
+ constructor() {
8
+ this.unexpectedErrorHandler = rethrowLater;
9
+ this.listeners = [];
10
+ this._isDevelopment = false;
11
+ this._enableConsoleLogging = true;
12
+ }
11
13
  setDevelopmentMode(isDev) {
12
14
  this._isDevelopment = isDev;
13
15
  }
@@ -348,7 +350,6 @@ const motifMessages = {
348
350
  MJX611: () => `The devtools panel failed to load.`,
349
351
  };
350
352
  class MotifError extends Error {
351
- code;
352
353
  constructor(code, message, options) {
353
354
  super(message, options);
354
355
  this.name = 'MotifError';
@@ -380,7 +381,9 @@ function reportWarning(code, args, details) {
380
381
  }
381
382
 
382
383
  class DisposableCore {
383
- disposableTracker = null;
384
+ constructor() {
385
+ this.disposableTracker = null;
386
+ }
384
387
  notifyCreated(target) {
385
388
  this.disposableTracker?.trackDisposable(target);
386
389
  return target;
@@ -409,9 +412,8 @@ class DisposableCore {
409
412
  const disposableCore = new DisposableCore();
410
413
 
411
414
  class DisposableStore {
412
- _items = new Set();
413
- _closed = false;
414
415
  constructor() {
416
+ this._closed = false;
415
417
  disposableCore.notifyCreated(this);
416
418
  }
417
419
  get isDisposed() {
@@ -429,7 +431,7 @@ class DisposableStore {
429
431
  reportWarning('MJX504', [], new Error().stack);
430
432
  }
431
433
  else {
432
- this._items.add(item);
434
+ (this._items ??= new Set()).add(item);
433
435
  }
434
436
  return item;
435
437
  }
@@ -440,20 +442,21 @@ class DisposableStore {
440
442
  if (item === this) {
441
443
  throw motifError('MJX505');
442
444
  }
443
- this._items.delete(item);
445
+ this._items?.delete(item);
444
446
  item.dispose();
445
447
  }
446
448
  detach(item) {
447
- if (item && this._items.delete(item)) {
449
+ if (item && this._items?.delete(item)) {
448
450
  disposableCore.notifyOwner(item, null);
449
451
  }
450
452
  }
451
453
  clear() {
452
- if (this._items.size === 0) {
454
+ const items = this._items;
455
+ if (!items || items.size === 0) {
453
456
  return;
454
457
  }
455
458
  const failures = [];
456
- for (const item of this._items) {
459
+ for (const item of items) {
457
460
  try {
458
461
  item?.dispose();
459
462
  }
@@ -461,7 +464,7 @@ class DisposableStore {
461
464
  failures.push(error);
462
465
  }
463
466
  }
464
- this._items.clear();
467
+ items.clear();
465
468
  if (failures.length === 1) {
466
469
  throw failures[0];
467
470
  }
@@ -479,16 +482,34 @@ class DisposableStore {
479
482
  }
480
483
  }
481
484
 
485
+ let closedStore;
486
+ function sharedClosedStore() {
487
+ if (closedStore === undefined) {
488
+ closedStore = new DisposableStore();
489
+ closedStore.dispose();
490
+ }
491
+ return closedStore;
492
+ }
482
493
  class Disposable {
483
- _disposables = new DisposableStore();
494
+ get _disposables() {
495
+ let store = this._store;
496
+ if (store === undefined) {
497
+ store = this._store = new DisposableStore();
498
+ disposableCore.notifyOwner(store, this);
499
+ }
500
+ return store;
501
+ }
484
502
  constructor() {
503
+ this._store = undefined;
485
504
  disposableCore.notifyCreated(this);
486
- disposableCore.notifyOwner(this._disposables, this);
487
505
  }
488
506
  dispose() {
489
507
  disposableCore.notifyDisposed(this);
490
- const owned = this._disposables;
491
- if (owned && typeof owned.dispose === 'function') {
508
+ const owned = this._store;
509
+ if (owned === undefined) {
510
+ this._store = sharedClosedStore();
511
+ }
512
+ else if (owned && typeof owned.dispose === 'function') {
492
513
  owned.dispose();
493
514
  }
494
515
  else {
@@ -593,27 +614,17 @@ function removeArrayStack() {
593
614
  }
594
615
 
595
616
  class ListBinding {
596
- component;
597
- itemsFn;
598
- renderFn;
599
- options;
600
- propertyName = "__list__";
601
- dataSource;
602
- dataMember;
603
- formatString;
604
- converter;
605
- converterBack;
606
- updateMode;
607
- _isActive = false;
608
- _effectCleanup;
609
- _rendered = [];
610
- _identityMap = new WeakMap();
611
- container = motifFragment('list-container');
612
617
  constructor(component, itemsFn, renderFn, options) {
613
618
  this.component = component;
614
619
  this.itemsFn = itemsFn;
615
620
  this.renderFn = renderFn;
616
621
  this.options = options;
622
+ this.propertyName = "__list__";
623
+ this._isActive = false;
624
+ this._rendered = [];
625
+ this._identityMap = new WeakMap();
626
+ this.container = motifFragment('list-container');
627
+ this.olditems = [];
617
628
  this.component.controls.add(this.container);
618
629
  }
619
630
  activate() { if (this._isActive)
@@ -697,7 +708,6 @@ class ListBinding {
697
708
  }
698
709
  return component;
699
710
  }
700
- olditems = [];
701
711
  get _indexSensitive() {
702
712
  try {
703
713
  return this.renderFn.length >= 2;
@@ -901,6 +911,10 @@ class ListBinding {
901
911
  return oi === undefined ? -1 : oi;
902
912
  });
903
913
  const stable = new Set(longestIncreasingIndices(sources));
914
+ if (newComponents.length === items.length && isPermutation(sources, newComponents, this.container)) {
915
+ controls._reorder(newComponents, stable);
916
+ return;
917
+ }
904
918
  let anchor = null;
905
919
  for (let i = newComponents.length - 1; i >= 0; i--) {
906
920
  const comp = newComponents[i];
@@ -923,6 +937,19 @@ class ListBinding {
923
937
  }
924
938
  }
925
939
  }
940
+ function isPermutation(sources, components, owner) {
941
+ const seen = new Uint8Array(sources.length);
942
+ for (let i = 0; i < sources.length; i++) {
943
+ const s = sources[i];
944
+ if (s === -1 || seen[s])
945
+ return false;
946
+ seen[s] = 1;
947
+ const c = components[i];
948
+ if (c.isDisposed || c.parent !== owner)
949
+ return false;
950
+ }
951
+ return true;
952
+ }
926
953
  function longestIncreasingIndices(sources) {
927
954
  const predecessors = new Array(sources.length).fill(-1);
928
955
  const tails = [];
@@ -1010,13 +1037,11 @@ function findAppendableComponent$1(component) {
1010
1037
  }
1011
1038
 
1012
1039
  class LeakMonitor {
1013
- threshold;
1014
- name;
1015
- _origins = new Map();
1016
- _quietChecks = 0;
1017
1040
  constructor(threshold, name) {
1018
1041
  this.threshold = threshold;
1019
1042
  this.name = name;
1043
+ this._origins = new Map();
1044
+ this._quietChecks = 0;
1020
1045
  }
1021
1046
  check(size) {
1022
1047
  if (this.threshold <= 0 || size < this.threshold) {
@@ -1052,8 +1077,10 @@ function createRing() {
1052
1077
  return ring;
1053
1078
  }
1054
1079
  class LinkedList {
1055
- _ring = createRing();
1056
- _count = 0;
1080
+ constructor() {
1081
+ this._ring = createRing();
1082
+ this._count = 0;
1083
+ }
1057
1084
  get size() {
1058
1085
  return this._count;
1059
1086
  }
@@ -1112,10 +1139,11 @@ class LinkedList {
1112
1139
  }
1113
1140
 
1114
1141
  const COMPILER_CONTRACT = 1;
1142
+ const SUPPORTED_CONTRACTS = [1, 2];
1115
1143
  const reported = new Set();
1116
1144
  const pending = new Set();
1117
1145
  function motifCompiled(contract) {
1118
- if (contract === COMPILER_CONTRACT || reported.has(contract))
1146
+ if (SUPPORTED_CONTRACTS.includes(contract) || reported.has(contract))
1119
1147
  return;
1120
1148
  if (!isDevLike()) {
1121
1149
  pending.add(contract);
@@ -1150,15 +1178,12 @@ exports.NodeTypes = void 0;
1150
1178
  })(exports.NodeTypes || (exports.NodeTypes = {}));
1151
1179
 
1152
1180
  class Effect {
1153
- fn;
1154
- callback;
1155
- deps = [];
1156
- active = true;
1157
- running = false;
1158
- scheduler;
1159
1181
  constructor(fn, callback) {
1160
1182
  this.fn = fn;
1161
1183
  this.callback = callback;
1184
+ this.deps = [];
1185
+ this.active = true;
1186
+ this.running = false;
1162
1187
  }
1163
1188
  run() {
1164
1189
  let value;
@@ -1404,21 +1429,10 @@ function readModelValue(el) {
1404
1429
  return el.value;
1405
1430
  }
1406
1431
  class Binding {
1407
- propertyName;
1408
- dataSource;
1409
- dataMember;
1410
- formatString;
1411
- converter;
1412
- converterBack;
1413
- setter;
1414
- formatInfo;
1415
- updateMode = 'onPropertyChanged';
1416
- _isActive = false;
1417
- _component;
1418
- _effectCleanup;
1419
- _memberPath = null;
1420
- _memberPathSource;
1421
1432
  constructor(component, propertyName, dataSource, dataMember, formatString, formatInfo) {
1433
+ this.updateMode = 'onPropertyChanged';
1434
+ this._isActive = false;
1435
+ this._memberPath = null;
1422
1436
  this._component = component;
1423
1437
  this.propertyName = propertyName;
1424
1438
  this.dataSource = dataSource;
@@ -1670,10 +1684,9 @@ function isWritablePathKey(target, key) {
1670
1684
  return true;
1671
1685
  }
1672
1686
  class BindingCollection {
1673
- _items = [];
1674
- _component;
1675
- _branchScope = null;
1676
1687
  constructor(component) {
1688
+ this._items = [];
1689
+ this._branchScope = null;
1677
1690
  this._component = component;
1678
1691
  }
1679
1692
  _own(stop) {
@@ -1942,6 +1955,38 @@ class BindingCollection {
1942
1955
  const [dataSource, dataMember, formatString, formatInfo] = args;
1943
1956
  binding = new Binding(this._component, propertyName, dataSource, dataMember, formatString, formatInfo);
1944
1957
  }
1958
+ const write = (raw) => {
1959
+ let value = raw;
1960
+ const b = binding;
1961
+ if (typeof b.converterBack === 'function') {
1962
+ value = b.converterBack(value);
1963
+ }
1964
+ if (typeof b.setter === 'function') {
1965
+ b.setter(value);
1966
+ return;
1967
+ }
1968
+ const member = b.dataMember;
1969
+ const source = b.dataSource;
1970
+ if (member && source != null) {
1971
+ const path = member.split('.');
1972
+ let target = source;
1973
+ for (let i = 0; i < path.length && target != null; i++) {
1974
+ const key = path[i];
1975
+ if (!isWritablePathKey(target, key))
1976
+ return;
1977
+ if (i === path.length - 1) {
1978
+ target[key] = value;
1979
+ }
1980
+ else {
1981
+ target = target[key];
1982
+ }
1983
+ }
1984
+ }
1985
+ else if (source != null && typeof source === 'object' && 'value' in source) {
1986
+ source.value = value;
1987
+ }
1988
+ };
1989
+ (this._modelWriters ??= new WeakMap()).set(binding, write);
1945
1990
  const lowerTag = tn.toLowerCase();
1946
1991
  if (lowerTag === 'input' || lowerTag === 'select' || lowerTag === 'textarea') {
1947
1992
  const writeBack = () => {
@@ -1949,35 +1994,7 @@ class BindingCollection {
1949
1994
  const el = this._component.element;
1950
1995
  if (!el)
1951
1996
  return;
1952
- let value = readModelValue(el);
1953
- const b = binding;
1954
- if (typeof b.converterBack === 'function') {
1955
- value = b.converterBack(value);
1956
- }
1957
- if (typeof b.setter === 'function') {
1958
- b.setter(value);
1959
- return;
1960
- }
1961
- const member = b.dataMember;
1962
- const source = b.dataSource;
1963
- if (member && source != null) {
1964
- const path = member.split('.');
1965
- let target = source;
1966
- for (let i = 0; i < path.length && target != null; i++) {
1967
- const key = path[i];
1968
- if (!isWritablePathKey(target, key))
1969
- return;
1970
- if (i === path.length - 1) {
1971
- target[key] = value;
1972
- }
1973
- else {
1974
- target = target[key];
1975
- }
1976
- }
1977
- }
1978
- else if (source != null && typeof source === 'object' && 'value' in source) {
1979
- source.value = value;
1980
- }
1997
+ write(readModelValue(el));
1981
1998
  }
1982
1999
  catch { /* ignore */ }
1983
2000
  };
@@ -1990,6 +2007,23 @@ class BindingCollection {
1990
2007
  }
1991
2008
  return binding;
1992
2009
  }
2010
+ writeModel(value) {
2011
+ const writers = this._modelWriters;
2012
+ if (!writers)
2013
+ return false;
2014
+ let written = false;
2015
+ for (const binding of this._items) {
2016
+ const write = writers.get(binding);
2017
+ if (!write)
2018
+ continue;
2019
+ try {
2020
+ write(value);
2021
+ written = true;
2022
+ }
2023
+ catch { /* ignore */ }
2024
+ }
2025
+ return written;
2026
+ }
1993
2027
  deactivateAll() {
1994
2028
  this._items.forEach(binding => binding.deactivate());
1995
2029
  this._items = [];
@@ -2049,10 +2083,10 @@ lazyBindMethods(BindingCollection.prototype, [
2049
2083
  ]);
2050
2084
 
2051
2085
  class Emitter {
2052
- _subscriptions = [];
2053
- _delivery;
2054
- _subscribe;
2055
- _disposed = false;
2086
+ constructor() {
2087
+ this._subscriptions = [];
2088
+ this._disposed = false;
2089
+ }
2056
2090
  get event() {
2057
2091
  if (!this._subscribe) {
2058
2092
  this._subscribe = (listener, thisArgs, disposables) => {
@@ -2136,10 +2170,6 @@ class Emitter {
2136
2170
  }
2137
2171
 
2138
2172
  class ComponentEmiter {
2139
- component;
2140
- _emitters;
2141
- _sourceDisposables;
2142
- _listenerDisposables;
2143
2173
  constructor(component) {
2144
2174
  this.component = component;
2145
2175
  }
@@ -2290,9 +2320,6 @@ const WHEN_TRUTHY_METHODS = new Set(['close', 'hidePopover', 'requestSubmit', 'c
2290
2320
  const ARGUMENT_METHODS = new Set(['setSelectionRange', 'setRangeText', 'setPointerCapture', 'releasePointerCapture', 'fastSeek']);
2291
2321
  const PROPERTY_FIRST = new Set(['checked', 'selected', 'muted', 'indeterminate', 'srcObject']);
2292
2322
  class controlAttribute {
2293
- _parent;
2294
- _attrMapStore;
2295
- _watchersStore;
2296
2323
  constructor(parent) {
2297
2324
  this._parent = parent;
2298
2325
  }
@@ -2824,14 +2851,10 @@ class controlAttribute {
2824
2851
  }
2825
2852
 
2826
2853
  class controlClass {
2827
- _parent;
2828
2854
  constructor(parent) {
2855
+ this._watcherSeq = 0;
2829
2856
  this._parent = parent;
2830
2857
  }
2831
- _countsStore;
2832
- _staticSetStore;
2833
- _watchersStore;
2834
- _watcherSeq = 0;
2835
2858
  get _counts() { return this._countsStore ??= new Map(); }
2836
2859
  get _staticSet() { return this._staticSetStore ??= new Set(); }
2837
2860
  get _watchers() { return this._watchersStore ??= new Map(); }
@@ -2847,13 +2870,7 @@ class controlClass {
2847
2870
  this._addStaticFromObject(value);
2848
2871
  }
2849
2872
  else {
2850
- var valueStr = String(value ?? '').trim();
2851
- if (valueStr.split(' ').length > 1) {
2852
- this._addStaticFromArray(valueStr.split(' '));
2853
- }
2854
- else {
2855
- this._addStaticFromString(valueStr);
2856
- }
2873
+ this._addStaticNames(this._splitClasses(String(value ?? '')));
2857
2874
  }
2858
2875
  }
2859
2876
  return this._parent;
@@ -2919,10 +2936,11 @@ class controlClass {
2919
2936
  return null;
2920
2937
  }
2921
2938
  _splitClasses(input) {
2922
- return (input || '')
2923
- .split(/\s+/)
2924
- .map(s => s.trim())
2925
- .filter(s => s.length > 0);
2939
+ if (!input)
2940
+ return [];
2941
+ if (!/\s/.test(input))
2942
+ return [input];
2943
+ return input.split(/\s+/).filter(s => s.length > 0);
2926
2944
  }
2927
2945
  _normalizeToSet(values, key) {
2928
2946
  const result = new Set();
@@ -3021,14 +3039,31 @@ class controlClass {
3021
3039
  }
3022
3040
  }
3023
3041
  }
3024
- _addStaticFromString(s) {
3025
- if (!s)
3042
+ _addStaticNames(names) {
3043
+ if (names.length === 0)
3026
3044
  return;
3027
3045
  const el = this._getElement();
3028
- const prev = new Set(this._staticSet);
3029
- for (const cls of this._splitClasses(s))
3030
- this._staticSet.add(cls);
3031
- this._applySourceDiff('static', prev, new Set(this._staticSet), el);
3046
+ const staticSet = this._staticSet;
3047
+ const fresh = el && !el.hasAttribute('class') ? [] : null;
3048
+ for (const cls of names) {
3049
+ if (staticSet.has(cls))
3050
+ continue;
3051
+ staticSet.add(cls);
3052
+ const prevCount = this._counts.get(cls) || 0;
3053
+ this._counts.set(cls, prevCount + 1);
3054
+ if (prevCount === 0 && el) {
3055
+ if (fresh)
3056
+ fresh.push(cls);
3057
+ else {
3058
+ try {
3059
+ el.classList.add(cls);
3060
+ }
3061
+ catch { }
3062
+ }
3063
+ }
3064
+ }
3065
+ if (fresh && fresh.length > 0)
3066
+ el.setAttribute('class', fresh.join(' '));
3032
3067
  }
3033
3068
  _addStaticFromArray(arr) {
3034
3069
  const el = this._getElement();
@@ -3349,8 +3384,6 @@ function runCssTransition(el, props, phase, done, appear = false) {
3349
3384
  }
3350
3385
 
3351
3386
  class ComponentMotif {
3352
- _component;
3353
- options;
3354
3387
  constructor(component, options) {
3355
3388
  this._component = component;
3356
3389
  this.options = options;
@@ -3393,15 +3426,11 @@ class ComponentMotif {
3393
3426
  const SIGNAL_TARGET = Symbol('SignalTarget');
3394
3427
  const SIGNAL_KEY = Symbol('SignalKey');
3395
3428
  class Signal {
3396
- _value;
3397
- _target;
3398
- _key;
3399
- _equals;
3400
- _disposed = false;
3401
3429
  static create(initialValue, equals) {
3402
3430
  return new Signal(initialValue, equals);
3403
3431
  }
3404
3432
  constructor(initialValue, equals = Object.is) {
3433
+ this._disposed = false;
3405
3434
  this._value = initialValue;
3406
3435
  this._target = { [SIGNAL_TARGET]: true };
3407
3436
  this._key = SIGNAL_KEY;
@@ -3458,14 +3487,9 @@ class Signal {
3458
3487
  }
3459
3488
  }
3460
3489
  class Computed {
3461
- _value;
3462
- _dirty = true;
3463
- _computing = false;
3464
- _target;
3465
- _key;
3466
- _getter;
3467
- _cleanup;
3468
3490
  constructor(getter) {
3491
+ this._dirty = true;
3492
+ this._computing = false;
3469
3493
  this._getter = getter;
3470
3494
  this._target = { [SIGNAL_TARGET]: true };
3471
3495
  this._key = SIGNAL_KEY;
@@ -3530,14 +3554,9 @@ class Computed {
3530
3554
  }
3531
3555
  }
3532
3556
  class LazyComputed {
3533
- _value;
3534
- _dirty = true;
3535
- _disposed = false;
3536
- _target;
3537
- _key;
3538
- _getter;
3539
- _runner;
3540
3557
  constructor(getter) {
3558
+ this._dirty = true;
3559
+ this._disposed = false;
3541
3560
  this._getter = getter;
3542
3561
  this._target = { [SIGNAL_TARGET]: true };
3543
3562
  this._key = SIGNAL_KEY;
@@ -3701,24 +3720,25 @@ function retireServiceOwner(owner) {
3701
3720
  pins.set(owner, { scope: pinnedScopeOf(owner) ?? navigatingRoot._currentScope(), live: false });
3702
3721
  }
3703
3722
  class ServiceProvider {
3704
- services;
3705
- parent;
3706
- root;
3707
- scopeName;
3708
- kind;
3709
- singletonCache;
3710
- scopedCache = new Map();
3711
- transientSet = new Set();
3712
- _autoDisposeTransients = false;
3713
- pendingSingleton;
3714
- pendingScoped = new Map();
3715
- _navigation;
3716
- _ownerlessSlot = { owner: null, ownerless: true };
3717
- _navigationDisposed = false;
3718
- _livePins = 0;
3719
- _pending = false;
3720
3723
  constructor(services, parent, root) {
3721
3724
  this.services = services;
3725
+ this.scopedCache = new Map();
3726
+ this.transientSet = new Set();
3727
+ this._autoDisposeTransients = false;
3728
+ this.pendingScoped = new Map();
3729
+ this._ownerlessSlot = { owner: null, ownerless: true };
3730
+ this._navigationDisposed = false;
3731
+ this._livePins = 0;
3732
+ this._pending = false;
3733
+ this.describeToken = (t) => {
3734
+ if (typeof t === 'string')
3735
+ return t;
3736
+ if (typeof t === 'symbol')
3737
+ return t.toString();
3738
+ if (typeof t === 'function')
3739
+ return t.name || '[AnonymousClass]';
3740
+ return String(t);
3741
+ };
3722
3742
  this.parent = parent;
3723
3743
  this.root = root ?? this;
3724
3744
  this.kind = this.root === this ? 'root' : 'user';
@@ -4102,15 +4122,6 @@ class ServiceProvider {
4102
4122
  throw motifError('MJX404', chain);
4103
4123
  }
4104
4124
  }
4105
- describeToken = (t) => {
4106
- if (typeof t === 'string')
4107
- return t;
4108
- if (typeof t === 'symbol')
4109
- return t.toString();
4110
- if (typeof t === 'function')
4111
- return t.name || '[AnonymousClass]';
4112
- return String(t);
4113
- };
4114
4125
  describeTokenWithSource(t) {
4115
4126
  const name = this.describeToken(t);
4116
4127
  const d = this.services.getDescriptor(t);
@@ -4217,8 +4228,22 @@ function describeServiceToken(t) {
4217
4228
  return t.name || '[AnonymousClass]';
4218
4229
  return String(t);
4219
4230
  }
4231
+ const F_BUILT = 1;
4232
+ const F_INITIALIZED = 2;
4233
+ const F_DISPOSED = 4;
4234
+ const F_CONFIGURED = 8;
4235
+ const F_PAINTING = 16;
4236
+ const F_PAINTED = 32;
4237
+ const F_HIDDEN = 64;
4238
+ const F_WAIT = 128;
4239
+ const F_POSTCONFIG = 256;
4240
+ const F_PREBOUND = 512;
4241
+ const F_DISPOSED_FIRED = 1024;
4242
+ function optionsOf(c) {
4243
+ return c?._motif?.options;
4244
+ }
4220
4245
  function peekTransition(c) {
4221
- return c?.motif?.options?.[TRANSITION_SLOT];
4246
+ return c?._motif?.options?.[TRANSITION_SLOT];
4222
4247
  }
4223
4248
  /**WAAPI keyframe (transitionIn) YA DA CSS class transition (name/classes) tanımlı olarak enter animasyonu varmı */
4224
4249
  function clearNavDirection(c) {
@@ -4240,15 +4265,15 @@ function enterModeOf(container) {
4240
4265
  const node = c.element;
4241
4266
  if (!node || node.nodeType !== Node.COMMENT_NODE)
4242
4267
  break;
4243
- c = c.parent ?? c._base?._leaveContainer;
4268
+ c = c.parent ?? c._leaveContainer;
4244
4269
  }
4245
4270
  return transitionSettings.mode;
4246
4271
  }
4247
4272
  function leaveModeOf(c) {
4248
- return enterModeOf(c.parent ?? c._base?._leaveContainer);
4273
+ return enterModeOf(c.parent ?? c._leaveContainer);
4249
4274
  }
4250
4275
  function wantsEnterTransition(c) {
4251
- const o = c?.motif?.options;
4276
+ const o = c?._motif?.options;
4252
4277
  const t = o?.[TRANSITION_SLOT];
4253
4278
  return !!(o?.transitionIn || (t && (t.classes || (t.name && t.name.length > 0))));
4254
4279
  }
@@ -4403,8 +4428,6 @@ function createTransitionApi(owner) {
4403
4428
  return t;
4404
4429
  }
4405
4430
  class ComponentOptionsImpl {
4406
- [OPTIONS_OWNER];
4407
- [TRANSITION_SLOT];
4408
4431
  constructor(owner) {
4409
4432
  this[OPTIONS_OWNER] = owner;
4410
4433
  }
@@ -4444,24 +4467,44 @@ class ComponentOptionsImpl {
4444
4467
  }
4445
4468
  }
4446
4469
  hasEvent(name) {
4447
- return !!this[OPTIONS_OWNER]._eventHandlers?.has(name);
4470
+ return hasEventKey(this[OPTIONS_OWNER], name);
4448
4471
  }
4449
4472
  }
4450
4473
  lazyBindMethods(ComponentOptionsImpl.prototype, ['getInstance', 'hasEvent']);
4451
4474
  function fireLifecycle(component, name, ev) {
4452
- const base = component._base;
4475
+ const base = component._baseCtx;
4453
4476
  if (base)
4454
- base.emiters.fire(name, ev);
4477
+ base._emiters?.fire(name, ev);
4478
+ }
4479
+ function runHooks(base, listName, sender, ev, label) {
4480
+ if (!base)
4481
+ return;
4482
+ let slot = base[listName];
4483
+ if (!slot)
4484
+ return;
4485
+ let from = 0;
4486
+ if (typeof slot === 'function') {
4487
+ const fn = slot;
4488
+ callReported(() => fn(sender, ev), 'MJX122', label);
4489
+ slot = base[listName];
4490
+ if (!Array.isArray(slot))
4491
+ return;
4492
+ from = 1;
4493
+ }
4494
+ for (let i = from; i < slot.length; i++) {
4495
+ const fn = slot[i];
4496
+ callReported(() => fn(sender, ev), 'MJX122', label);
4497
+ }
4455
4498
  }
4456
4499
  function hasLifecycleHook(component, hook, listName, lowerName, legacyProp) {
4457
4500
  if (component[hook])
4458
4501
  return true;
4459
- const list = component._base[listName];
4460
- if (Array.isArray(list) && list.length > 0)
4502
+ const base = component._baseCtx;
4503
+ if (base?.[listName])
4461
4504
  return true;
4462
4505
  if (legacyProp && component[legacyProp])
4463
4506
  return true;
4464
- return component._base.emiters.hasListeners(lowerName);
4507
+ return !!base?._emiters?.hasListeners(lowerName);
4465
4508
  }
4466
4509
  const RESERVED_METHODS = ['build', 'setState', 'reState', 'setText', 'style', 'dispose', 'disposeAsync', 'using', 'doWork', 'getService', '$', 'useModel', 'context', 'siblings', 'serviceProvider', 'isWait'];
4467
4510
  const checkedComponentClasses = new WeakSet();
@@ -4530,21 +4573,17 @@ const ComponentHelper = {
4530
4573
  callReported(() => component.initializeComponent(sender, ev), 'MJX122', 'initializeComponent');
4531
4574
  }
4532
4575
  // 2) aggregated extra initializeComponent handlers (örn, from props)
4533
- if (Array.isArray(component._base._initializeComponentHandlers) && component._base._initializeComponentHandlers.length) {
4534
- for (const fn of component._base._initializeComponentHandlers) {
4535
- callReported(() => fn(sender, ev), 'MJX122', 'initializeComponent');
4536
- }
4576
+ const compiled = component._init;
4577
+ if (compiled) {
4578
+ callReported(() => compiled(sender, ev), 'MJX122', 'initializeComponent');
4537
4579
  }
4580
+ runHooks(component._baseCtx, '_initializeComponentHandlers', sender, ev, 'initializeComponent');
4538
4581
  // 3) class method oninitializeComponent
4539
4582
  if (typeof component.oninitializeComponent === 'function') {
4540
4583
  callReported(() => component.oninitializeComponent(sender, ev), 'MJX122', 'oninitializeComponent');
4541
4584
  }
4542
4585
  // 4) aggregated extra oninitializeComponent handlers (örn, from props)
4543
- if (Array.isArray(component._base._onInitializeComponentHandlers) && component._base._onInitializeComponentHandlers.length) {
4544
- for (const fn of component._base._onInitializeComponentHandlers) {
4545
- callReported(() => fn(sender, ev), 'MJX122', 'oninitializeComponent');
4546
- }
4547
- }
4586
+ runHooks(component._baseCtx, '_onInitializeComponentHandlers', sender, ev, 'oninitializeComponent');
4548
4587
  },
4549
4588
  callDisposing(component) {
4550
4589
  if (!component || component.isDisposed) {
@@ -4557,11 +4596,7 @@ const ComponentHelper = {
4557
4596
  if (component.onDisposing) {
4558
4597
  callReported(() => component.onDisposing(sender, ev), 'MJX122', 'onDisposing');
4559
4598
  }
4560
- if (Array.isArray(component._base._onDisposingHandlers)) {
4561
- for (const fn of component._base._onDisposingHandlers) {
4562
- callReported(() => fn(sender, ev), 'MJX122', 'onDisposing');
4563
- }
4564
- }
4599
+ runHooks(component._baseCtx, '_onDisposingHandlers', sender, ev, 'onDisposing');
4565
4600
  if (component.ondisposing) {
4566
4601
  callReported(() => component.ondisposing(sender, ev), 'MJX122', 'ondisposing');
4567
4602
  }
@@ -4575,11 +4610,7 @@ const ComponentHelper = {
4575
4610
  if (component.onActivated) {
4576
4611
  callReported(() => component.onActivated(sender, ev), 'MJX122', 'onActivated');
4577
4612
  }
4578
- if (Array.isArray(component._base._onActivatedHandlers)) {
4579
- for (const fn of component._base._onActivatedHandlers) {
4580
- callReported(() => fn(sender, ev), 'MJX122', 'onActivated');
4581
- }
4582
- }
4613
+ runHooks(component._baseCtx, '_onActivatedHandlers', sender, ev, 'onActivated');
4583
4614
  fireLifecycle(component, 'onactivated', ev);
4584
4615
  },
4585
4616
  callDeactivated(component) {
@@ -4590,11 +4621,7 @@ const ComponentHelper = {
4590
4621
  if (component.onDeactivated) {
4591
4622
  callReported(() => component.onDeactivated(sender, ev), 'MJX122', 'onDeactivated');
4592
4623
  }
4593
- if (Array.isArray(component._base._onDeactivatedHandlers)) {
4594
- for (const fn of component._base._onDeactivatedHandlers) {
4595
- callReported(() => fn(sender, ev), 'MJX122', 'onDeactivated');
4596
- }
4597
- }
4624
+ runHooks(component._baseCtx, '_onDeactivatedHandlers', sender, ev, 'onDeactivated');
4598
4625
  fireLifecycle(component, 'ondeactivated', ev);
4599
4626
  },
4600
4627
  deactivateTree(component, deep = true) {
@@ -4606,7 +4633,7 @@ const ComponentHelper = {
4606
4633
  if (!deep || component.isDisposed) {
4607
4634
  return;
4608
4635
  }
4609
- for (const c of component.controls.items.slice()) {
4636
+ for (const c of childrenOf(component).slice()) {
4610
4637
  if (c && !c.isDisposed && c.isVisible && !c.isWait) {
4611
4638
  ComponentHelper.deactivateTree(c, true);
4612
4639
  }
@@ -4621,27 +4648,26 @@ const ComponentHelper = {
4621
4648
  if (!deep || component.isDisposed) {
4622
4649
  return;
4623
4650
  }
4624
- for (const c of component.controls.items.slice()) {
4651
+ for (const c of childrenOf(component).slice()) {
4625
4652
  if (c && !c.isDisposed && c.isVisible && !c.isWait) {
4626
4653
  ComponentHelper.activateTree(c, true);
4627
4654
  }
4628
4655
  }
4629
4656
  },
4630
4657
  callDisposed(component) {
4631
- if (!component || !component._base || component._base._disposedFired) {
4658
+ if (!component || (component._flags & F_DISPOSED_FIRED) !== 0) {
4659
+ return;
4660
+ }
4661
+ if (component.isDisposed && !component.element && component._baseCtx === undefined) {
4632
4662
  return;
4633
4663
  }
4634
- component._base._disposedFired = true;
4664
+ component._flags |= F_DISPOSED_FIRED;
4635
4665
  if (hasLifecycleHook(component, 'onDisposed', '_onDisposedHandlers', 'ondisposed', 'ondisposed')) {
4636
4666
  const sender = component, ev = { cancel: false };
4637
4667
  if (component.onDisposed) {
4638
4668
  callReported(() => component.onDisposed(sender, ev), 'MJX122', 'onDisposed');
4639
4669
  }
4640
- if (Array.isArray(component._base._onDisposedHandlers)) {
4641
- for (const fn of component._base._onDisposedHandlers) {
4642
- callReported(() => fn(sender, ev), 'MJX122', 'onDisposed');
4643
- }
4644
- }
4670
+ runHooks(component._baseCtx, '_onDisposedHandlers', sender, ev, 'onDisposed');
4645
4671
  if (component.ondisposed) {
4646
4672
  callReported(() => component.ondisposed(sender, ev), 'MJX122', 'ondisposed');
4647
4673
  }
@@ -4661,11 +4687,7 @@ const ComponentHelper = {
4661
4687
  if (component.onBuilt) {
4662
4688
  callReported(() => component.onBuilt(sender, ev), 'MJX122', 'onBuilt');
4663
4689
  }
4664
- if (Array.isArray(component._base._onBuiltHandlers)) {
4665
- for (const fn of component._base._onBuiltHandlers) {
4666
- callReported(() => fn(sender, ev), 'MJX122', 'onBuilt');
4667
- }
4668
- }
4690
+ runHooks(component._baseCtx, '_onBuiltHandlers', sender, ev, 'onBuilt');
4669
4691
  if (component.onbuilt) {
4670
4692
  callReported(() => component.onbuilt(sender, ev), 'MJX122', 'onbuilt');
4671
4693
  }
@@ -4677,11 +4699,11 @@ const ComponentHelper = {
4677
4699
  catch { }
4678
4700
  },
4679
4701
  scheduleMounted(component) {
4680
- if (!component || component.isDisposed || component._base._mountedScheduled) {
4702
+ if (!component || component.isDisposed || component._baseCtx?._mountedScheduled) {
4681
4703
  return;
4682
4704
  }
4683
4705
  const hasHook = typeof component.onMounted === 'function'
4684
- || (Array.isArray(component._base._onMountedHandlers) && component._base._onMountedHandlers.length > 0)
4706
+ || !!component._baseCtx?._onMountedHandlers
4685
4707
  || typeof component.onmounted === 'function';
4686
4708
  if (!hasHook) {
4687
4709
  return;
@@ -4710,11 +4732,7 @@ const ComponentHelper = {
4710
4732
  if (component.onMounted) {
4711
4733
  callReported(() => component.onMounted(sender, ev), 'MJX122', 'onMounted');
4712
4734
  }
4713
- if (Array.isArray(component._base._onMountedHandlers)) {
4714
- for (const fn of component._base._onMountedHandlers) {
4715
- callReported(() => fn(sender, ev), 'MJX122', 'onMounted');
4716
- }
4717
- }
4735
+ runHooks(component._baseCtx, '_onMountedHandlers', sender, ev, 'onMounted');
4718
4736
  if (component.onmounted) {
4719
4737
  callReported(() => component.onmounted(sender, ev), 'MJX122', 'onmounted');
4720
4738
  }
@@ -4731,11 +4749,7 @@ const ComponentHelper = {
4731
4749
  if (component.onBuilding) {
4732
4750
  callReported(() => component.onBuilding(sender, ev), 'MJX122', 'onBuilding');
4733
4751
  }
4734
- if (Array.isArray(component._base._onBuildingHandlers)) {
4735
- for (const fn of component._base._onBuildingHandlers) {
4736
- callReported(() => fn(sender, ev), 'MJX122', 'onBuilding');
4737
- }
4738
- }
4752
+ runHooks(component._baseCtx, '_onBuildingHandlers', sender, ev, 'onBuilding');
4739
4753
  fireLifecycle(component, 'onbuilding', ev);
4740
4754
  },
4741
4755
  callConfig(component) {
@@ -4743,8 +4757,9 @@ const ComponentHelper = {
4743
4757
  return;
4744
4758
  }
4745
4759
  component.isConfigured = true;
4746
- if (component.motif.options._preconfig) {
4747
- safeCallSilent(() => component.motif.options._preconfig(component), 'Component._preconfig');
4760
+ const preconfig = component._motif?.options?._preconfig;
4761
+ if (preconfig) {
4762
+ safeCallSilent(() => preconfig(component), 'Component._preconfig');
4748
4763
  }
4749
4764
  if (!hasLifecycleHook(component, 'onConfig', '_onConfigHandlers', 'onconfig')) {
4750
4765
  return;
@@ -4753,21 +4768,17 @@ const ComponentHelper = {
4753
4768
  if (component.onConfig) {
4754
4769
  callReported(() => component.onConfig(sender, ev), 'MJX122', 'onConfig');
4755
4770
  }
4756
- if (Array.isArray(component._base._onConfigHandlers)) {
4757
- for (const fn of component._base._onConfigHandlers) {
4758
- callReported(() => fn(sender, ev), 'MJX122', 'onConfig');
4759
- }
4760
- }
4771
+ runHooks(component._baseCtx, '_onConfigHandlers', sender, ev, 'onConfig');
4761
4772
  fireLifecycle(component, 'onconfig', ev);
4762
4773
  },
4763
4774
  callConfigured(component) {
4764
- if (component.motif.options && component.motif.options._postconfigdone) {
4775
+ if ((component._flags & F_POSTCONFIG) !== 0) {
4765
4776
  return;
4766
4777
  }
4767
- if (component?._base?._configDeferred && !component.isConfigured) {
4778
+ if (component?._baseCtx?._configDeferred && !component.isConfigured) {
4768
4779
  ComponentHelper.callConfig(component);
4769
4780
  }
4770
- component.motif.options._postconfigdone = true;
4781
+ component._flags |= F_POSTCONFIG;
4771
4782
  if (!component || component.isDisposed) {
4772
4783
  return;
4773
4784
  }
@@ -4778,11 +4789,7 @@ const ComponentHelper = {
4778
4789
  if (component.onConfigured) {
4779
4790
  callReported(() => component.onConfigured(sender, ev), 'MJX122', 'onConfigured');
4780
4791
  }
4781
- if (Array.isArray(component._base._onConfiguredHandlers)) {
4782
- for (const fn of component._base._onConfiguredHandlers) {
4783
- callReported(() => fn(sender, ev), 'MJX122', 'onConfigured');
4784
- }
4785
- }
4792
+ runHooks(component._baseCtx, '_onConfiguredHandlers', sender, ev, 'onConfigured');
4786
4793
  fireLifecycle(component, 'onconfigured', ev);
4787
4794
  },
4788
4795
  callOnInitialized(component) {
@@ -4797,11 +4804,7 @@ const ComponentHelper = {
4797
4804
  if (component.onInitialized) {
4798
4805
  callReported(() => component.onInitialized(sender, ev), 'MJX122', 'onInitialized');
4799
4806
  }
4800
- if (Array.isArray(component._base._onInitializedHandlers)) {
4801
- for (const fn of component._base._onInitializedHandlers) {
4802
- callReported(() => fn(sender, ev), 'MJX122', 'onInitialized');
4803
- }
4804
- }
4807
+ runHooks(component._baseCtx, '_onInitializedHandlers', sender, ev, 'onInitialized');
4805
4808
  fireLifecycle(component, 'oninitialized', ev);
4806
4809
  },
4807
4810
  callOnInitializing(component) {
@@ -4815,29 +4818,21 @@ const ComponentHelper = {
4815
4818
  if (component.onInitializing) {
4816
4819
  callReported(() => component.onInitializing(sender, ev), 'MJX122', 'onInitializing');
4817
4820
  }
4818
- if (Array.isArray(component._base._onInitializingHandlers)) {
4819
- for (const fn of component._base._onInitializingHandlers) {
4820
- callReported(() => fn(sender, ev), 'MJX122', 'onInitializing');
4821
- }
4822
- }
4821
+ runHooks(component._baseCtx, '_onInitializingHandlers', sender, ev, 'onInitializing');
4823
4822
  fireLifecycle(component, 'oninitializing', ev);
4824
4823
  },
4825
- callVisibilityChanged(component) {
4824
+ callVisibilityChanged(component, visible) {
4826
4825
  if (!component || component.isDisposed) {
4827
4826
  return;
4828
4827
  }
4829
4828
  if (!hasLifecycleHook(component, 'onVisibilityChanged', '_onVisibilityChangedHandlers', 'onvisibilitychanged')) {
4830
4829
  return;
4831
4830
  }
4832
- const sender = component, ev = { cancel: false };
4831
+ const sender = component, ev = { cancel: false, visible };
4833
4832
  if (component.onVisibilityChanged) {
4834
4833
  callReported(() => component.onVisibilityChanged(sender, ev), 'MJX122', 'onVisibilityChanged');
4835
4834
  }
4836
- if (Array.isArray(component._base._onVisibilityChangedHandlers)) {
4837
- for (const fn of component._base._onVisibilityChangedHandlers) {
4838
- callReported(() => fn(sender, ev), 'MJX122', 'onVisibilityChanged');
4839
- }
4840
- }
4835
+ runHooks(component._baseCtx, '_onVisibilityChangedHandlers', sender, ev, 'onVisibilityChanged');
4841
4836
  fireLifecycle(component, 'onvisibilitychanged', ev);
4842
4837
  },
4843
4838
  findFragmentContent(c) {
@@ -4866,9 +4861,12 @@ const ComponentHelper = {
4866
4861
  ComponentHelper.callConfigured(c);
4867
4862
  if (c.isDisposed)
4868
4863
  return;
4869
- c._base._activatePreBindings();
4870
- if (c.isWait)
4864
+ activatePreBindings(c);
4865
+ if (c.isWait) {
4866
+ if (this.isBuilt)
4867
+ placeTrace(this, c);
4871
4868
  return;
4869
+ }
4872
4870
  const cisBuilt = c.isBuilt;
4873
4871
  if (!this.isBuilt) {
4874
4872
  return;
@@ -4876,7 +4874,7 @@ const ComponentHelper = {
4876
4874
  if (c.isWait) {
4877
4875
  return;
4878
4876
  }
4879
- const enterSeq = c._base._enterSeq;
4877
+ const enterSeq = c._baseCtx?._enterSeq;
4880
4878
  if (!c.isBuilt) {
4881
4879
  c.build();
4882
4880
  }
@@ -4905,40 +4903,12 @@ const ComponentHelper = {
4905
4903
  if (cisBuilt && c.element.nodeType == Node.COMMENT_NODE && controlElement?.childNodes.length == 0 && c.controls.length > 0) {
4906
4904
  controlElement = ComponentHelper.getContent.call(c);
4907
4905
  }
4908
- let referenceNode = null;
4909
4906
  const insertHost = appendableElement?.element;
4910
- const domReferenceOf = (n) => {
4911
- if (!n || !n.isBuilt)
4912
- return null;
4913
- const candidate = n.isVisible
4914
- ? n.element
4915
- : (n.motif.options?.placeholder ?? null);
4916
- if (!candidate)
4917
- return null;
4918
- return (insertHost && candidate.parentNode === insertHost) ? candidate : null;
4919
- };
4920
- const siblings = this.controls.items;
4921
- for (let i = currentIndex + 1; i < siblings.length; i++) {
4922
- const candidate = domReferenceOf(siblings[i]);
4923
- if (candidate) {
4924
- referenceNode = candidate;
4925
- break;
4926
- }
4927
- }
4928
- if (!referenceNode) {
4929
- if (this.element.nodeType === Node.COMMENT_NODE) {
4930
- const close = this.motif.options.closeFragment;
4931
- referenceNode = (close && insertHost && close.parentNode === insertHost) ? close : null;
4932
- }
4933
- else {
4934
- referenceNode = null;
4935
- }
4936
- }
4907
+ const trace = c.motif.options.placeholder;
4908
+ const ownTrace = c.isVisible && trace && insertHost && trace.parentNode === insertHost ? trace : null;
4909
+ const referenceNode = ownTrace ?? (insertHost ? followingAnchor(this, currentIndex + 1, insertHost) : null);
4937
4910
  if (!c.isVisible) {
4938
- const cfg = c.motif.options?.hideStrategy ?? 'auto';
4939
- const isFromListOrKeyed = !!(c.motif.options?.__fromList || typeof c.motif.options?.indexkey !== 'undefined' || typeof c.motif.options?.__key !== 'undefined');
4940
- const strategy = cfg === 'placeholder' ? 'placeholder' : (cfg === 'detach' ? 'detach' : (isFromListOrKeyed ? 'detach' : 'placeholder'));
4941
- if (strategy === 'placeholder') {
4911
+ if (keepsTrace(c)) {
4942
4912
  if (!c.motif.options.placeholder) {
4943
4913
  c.motif.options.placeholder = dom.createComment("h");
4944
4914
  }
@@ -4976,9 +4946,11 @@ const ComponentHelper = {
4976
4946
  else {
4977
4947
  appendableElement?.element.appendChild(controlElement);
4978
4948
  }
4949
+ if (ownTrace && ownTrace.parentNode)
4950
+ ownTrace.parentNode.removeChild(ownTrace);
4979
4951
  }
4980
4952
  if (c.isVisible) {
4981
- const enteredInBuild = !cisBuilt && c._base._enterSeq !== enterSeq;
4953
+ const enteredInBuild = !cisBuilt && c._baseCtx?._enterSeq !== enterSeq;
4982
4954
  !enteredInBuild && wantsEnterTransition(c) && c.motif.options.transition.enterTransition(() => { });
4983
4955
  if (cisBuilt) {
4984
4956
  ComponentHelper.activateTree(c);
@@ -4992,7 +4964,11 @@ const ComponentHelper = {
4992
4964
  if (this.element.nodeType == Node.COMMENT_NODE) {
4993
4965
  this.motif.options.cache?.appendChild(this.element);
4994
4966
  this.controls.forEach(child => {
4995
- this.motif.options.cache?.appendChild(ComponentHelper.getContent.call(child));
4967
+ const node = child.isWait || !child.isVisible
4968
+ ? (keepsTrace(child) ? (child.motif.options.placeholder ??= dom.createComment("h")) : undefined)
4969
+ : ComponentHelper.getContent.call(child);
4970
+ if (node)
4971
+ this.motif.options.cache?.appendChild(node);
4996
4972
  });
4997
4973
  this.motif.options.cache?.appendChild(this.motif.options.closeFragment);
4998
4974
  return this.motif.options.cache;
@@ -5041,34 +5017,72 @@ const ComponentHelper = {
5041
5017
  }
5042
5018
  }
5043
5019
  };
5020
+ function keepsTrace(c) {
5021
+ return optionsOf(c)?.hideStrategy !== 'detach';
5022
+ }
5023
+ function domAnchor(c, host) {
5024
+ const trace = optionsOf(c)?.placeholder;
5025
+ if (trace && trace.parentNode === host)
5026
+ return trace;
5027
+ const node = c.element;
5028
+ return node && node.parentNode === host ? node : null;
5029
+ }
5030
+ function followingAnchor(owner, start, host) {
5031
+ const siblings = owner.controls.items;
5032
+ for (let i = start; i < siblings.length; i++) {
5033
+ const anchor = siblings[i] ? domAnchor(siblings[i], host) : null;
5034
+ if (anchor)
5035
+ return anchor;
5036
+ }
5037
+ if (owner.element.nodeType === Node.COMMENT_NODE) {
5038
+ const close = optionsOf(owner)?.closeFragment;
5039
+ return close && close.parentNode === host ? close : null;
5040
+ }
5041
+ return null;
5042
+ }
5043
+ function placeTrace(owner, c) {
5044
+ if (!keepsTrace(c))
5045
+ return;
5046
+ const host = findAppendableComponent(owner)?.element;
5047
+ if (!host)
5048
+ return;
5049
+ const element = c.element;
5050
+ if (element && element.parentNode === host)
5051
+ return;
5052
+ const opts = c.motif.options;
5053
+ const trace = opts.placeholder ?? (opts.placeholder = dom.createComment("h"));
5054
+ if (trace.parentNode === host)
5055
+ return;
5056
+ host.insertBefore(trace, followingAnchor(owner, owner.controls.items.indexOf(c) + 1, host));
5057
+ }
5044
5058
  function removeComponentDom(c, node, alsoPlaceholder) {
5045
- const opts = c.motif?.options;
5059
+ const opts = optionsOf(c);
5046
5060
  const parent = node.parentNode;
5047
5061
  if (node.nodeType === Node.COMMENT_NODE) {
5048
- if (!parent)
5049
- return;
5050
- const close = opts?.closeFragment || null;
5051
- if (close) {
5052
- let current = node;
5053
- while (current) {
5054
- const after = current.nextSibling;
5062
+ if (parent) {
5063
+ const close = opts?.closeFragment || null;
5064
+ if (close) {
5065
+ let current = node;
5066
+ while (current) {
5067
+ const after = current.nextSibling;
5068
+ try {
5069
+ parent.removeChild(current);
5070
+ }
5071
+ catch { }
5072
+ if (current === close)
5073
+ break;
5074
+ current = after;
5075
+ }
5076
+ }
5077
+ else {
5055
5078
  try {
5056
- parent.removeChild(current);
5079
+ parent.removeChild(node);
5057
5080
  }
5058
5081
  catch { }
5059
- if (current === close)
5060
- break;
5061
- current = after;
5062
- }
5063
- }
5064
- else {
5065
- try {
5066
- parent.removeChild(node);
5067
5082
  }
5068
- catch { }
5083
+ if (!alsoPlaceholder)
5084
+ return;
5069
5085
  }
5070
- if (!alsoPlaceholder)
5071
- return;
5072
5086
  }
5073
5087
  else if (parent) {
5074
5088
  try {
@@ -5155,23 +5169,23 @@ function disposeShallow(c) {
5155
5169
  return;
5156
5170
  ComponentHelper.callDisposing.call(c, c);
5157
5171
  try {
5158
- c._base._offAll();
5172
+ offAll(c);
5159
5173
  }
5160
5174
  catch {
5161
5175
  }
5162
5176
  c.motif.stopAnimations();
5163
- c._base._deactivateBindings();
5164
- if (c.controls?.items?.length) {
5165
- for (const child of c.controls.items) {
5177
+ deactivateBindings(c);
5178
+ if (childrenOf(c).length) {
5179
+ for (const child of c._controls.items) {
5166
5180
  try {
5167
- child._base._disposeShallow();
5181
+ disposeShallow(child);
5168
5182
  }
5169
5183
  catch {
5170
5184
  }
5171
5185
  }
5172
5186
  }
5173
5187
  ComponentHelper.callDisposed.call(c, c);
5174
- safeCall(() => { c._base.emiters.clear(); }, 'disposeShallow.emiters');
5188
+ safeCall(() => { c._baseCtx?._emiters?.clear(); }, 'disposeShallow.emiters');
5175
5189
  c.isDisposed = true;
5176
5190
  Disposable.prototype.dispose.call(c);
5177
5191
  }
@@ -5180,33 +5194,29 @@ function deepCleanup(c) {
5180
5194
  c.parent = null;
5181
5195
  }
5182
5196
  catch { }
5183
- try {
5184
- c._eventHandlers?.clear();
5185
- }
5186
- catch {
5187
- }
5188
5197
  c._eventHandlers = undefined;
5189
5198
  try {
5190
- c.class?._countsStore?.clear();
5199
+ c._class?._countsStore?.clear();
5191
5200
  }
5192
5201
  catch { }
5193
5202
  try {
5194
- c.class?._watchersStore?.clear();
5203
+ c._class?._watchersStore?.clear();
5195
5204
  }
5196
5205
  catch { }
5197
5206
  try {
5198
- c.attr?._attrMapStore?.clear();
5207
+ c._attr?._attrMapStore?.clear();
5199
5208
  }
5200
5209
  catch { }
5201
5210
  try {
5202
- c.attr?._watchersStore?.clear();
5211
+ c._attr?._watchersStore?.clear();
5203
5212
  }
5204
5213
  catch { }
5205
5214
  try {
5206
- if (c.motif.options) {
5207
- c.motif.options.cache = undefined;
5208
- c.motif.options.closeFragment = undefined;
5209
- c.motif.options.placeholder = undefined;
5215
+ const opts = c._motif?.options;
5216
+ if (opts) {
5217
+ opts.cache = undefined;
5218
+ opts.closeFragment = undefined;
5219
+ opts.placeholder = undefined;
5210
5220
  }
5211
5221
  }
5212
5222
  catch {
@@ -5236,20 +5246,22 @@ function deepCleanup(c) {
5236
5246
  }
5237
5247
  catch { }
5238
5248
  try {
5239
- c.motif.options = undefined;
5249
+ if (c._motif)
5250
+ c._motif.options = undefined;
5240
5251
  }
5241
5252
  catch { }
5242
5253
  const keys = Object.keys(c);
5243
5254
  for (let i = 0; i < keys.length; i++) {
5244
5255
  const key = keys[i];
5245
- if (key === 'motif')
5256
+ if (key === '_motif' || key === '_flags')
5246
5257
  continue;
5247
5258
  try {
5248
5259
  c[key] = undefined;
5249
5260
  }
5250
5261
  catch { }
5251
5262
  }
5252
- c.isDisposed = true;
5263
+ c._store = null;
5264
+ c._flags = F_DISPOSED | F_HIDDEN | F_DISPOSED_FIRED | F_POSTCONFIG | F_PREBOUND;
5253
5265
  }
5254
5266
  const DISPOSE_STARTED = Promise.resolve();
5255
5267
  function subtreeDisposesSync(c, root) {
@@ -5257,7 +5269,7 @@ function subtreeDisposesSync(c, root) {
5257
5269
  return false;
5258
5270
  if (c.disposeAsync !== ComponentBase.prototype.disposeAsync)
5259
5271
  return false;
5260
- const opts = c.motif?.options;
5272
+ const opts = optionsOf(c);
5261
5273
  if (opts) {
5262
5274
  if (opts.transitionOut)
5263
5275
  return false;
@@ -5271,8 +5283,8 @@ function subtreeDisposesSync(c, root) {
5271
5283
  return false;
5272
5284
  }
5273
5285
  }
5274
- const items = c.controls?.items;
5275
- if (items) {
5286
+ const items = childrenOf(c);
5287
+ if (items.length) {
5276
5288
  for (let i = 0; i < items.length; i++) {
5277
5289
  const child = items[i];
5278
5290
  if (child && !child.isDisposed && !subtreeDisposesSync(child, false))
@@ -5303,27 +5315,28 @@ function disposePrefix(c, options, asChild) {
5303
5315
  c.motif.options.transition.skipNextLeave = true;
5304
5316
  }
5305
5317
  safeCall(() => { ComponentHelper.callDisposing.call(c, c); }, ctx + '.callDisposing');
5306
- c._base._offAll();
5307
- c._base._deactivateBindings();
5318
+ offAll(c);
5319
+ deactivateBindings(c);
5308
5320
  safeCall(() => { c.parent?.controls?.silentDetach?.(c, true); }, ctx + '.silentDetach');
5309
5321
  }
5310
5322
  function disposeFinish(c, options, asChild) {
5311
5323
  c.isDisposed = true;
5312
5324
  Disposable.prototype.dispose.call(c);
5313
5325
  if (asChild) {
5314
- c.controls.items = [];
5326
+ if (c._controls)
5327
+ c._controls.items = [];
5315
5328
  safeCall(() => { ComponentHelper.callDisposed.call(c, c); }, 'disposeAsync.callDisposed');
5316
- safeCall(() => { c._base.emiters.clear(); }, 'disposeAsync.emiters');
5329
+ safeCall(() => { c._baseCtx?._emiters?.clear(); }, 'disposeAsync.emiters');
5317
5330
  if (options?.deep) {
5318
- c._base._deepCleanup();
5331
+ deepCleanup(c);
5319
5332
  }
5320
5333
  return;
5321
5334
  }
5322
5335
  c.element = null;
5323
5336
  safeCall(() => { ComponentHelper.callDisposed.call(c, c); }, 'dispose.callDisposed');
5324
- safeCall(() => { c._base.emiters.clear(); }, 'dispose.emiters');
5325
- c._base._offAll();
5326
- c._base._deepCleanup();
5337
+ safeCall(() => { c._baseCtx?._emiters?.clear(); }, 'dispose.emiters');
5338
+ offAll(c);
5339
+ deepCleanup(c);
5327
5340
  }
5328
5341
  async function disposeRemainderAsync(c, options, asChild, leave) {
5329
5342
  if (leave) {
@@ -5336,7 +5349,7 @@ async function disposeRemainderAsync(c, options, asChild, leave) {
5336
5349
  else if (peekTransition(c)?.skipNextLeave) {
5337
5350
  await c.motif.stopAnimations();
5338
5351
  }
5339
- await c._base._detachDomWithAnimationAsync();
5352
+ await detachDomWithAnimationAsync(c);
5340
5353
  }
5341
5354
  if (!asChild && c.constructor.name !== 'TransportTo') {
5342
5355
  await disposeContentBlocks(c);
@@ -5346,7 +5359,7 @@ async function disposeRemainderAsync(c, options, asChild, leave) {
5346
5359
  if (c.isDisposed) {
5347
5360
  return;
5348
5361
  }
5349
- const ctrls = Array.from(c.controls.items);
5362
+ const ctrls = Array.from(childrenOf(c));
5350
5363
  if (ctrls.length) {
5351
5364
  await Promise.all(ctrls.map(child => asChild
5352
5365
  ? safeCallAsync(async () => { await child.disposeAsync(childOptions); }, 'disposeAsync.disposeAsyncChildren.handler')
@@ -5376,8 +5389,8 @@ function disposeRemainderSync(root, options, asChild, rootDetached) {
5376
5389
  const node = nodes[n];
5377
5390
  if (node.isDisposed)
5378
5391
  continue;
5379
- const items = node.controls?.items;
5380
- if (!items || items.length === 0)
5392
+ const items = childrenOf(node);
5393
+ if (items.length === 0)
5381
5394
  continue;
5382
5395
  const ctrls = Array.from(items);
5383
5396
  for (let j = 0; j < ctrls.length; j++) {
@@ -5392,7 +5405,8 @@ function disposeRemainderSync(root, options, asChild, rootDetached) {
5392
5405
  retireServiceOwner(child);
5393
5406
  child._disposing = root._disposing;
5394
5407
  disposePrefix(child, childOptions, true);
5395
- detachDomWithAnimation(child);
5408
+ if (child.element?.isConnected !== false)
5409
+ detachDomWithAnimation(child);
5396
5410
  nodes.push(child);
5397
5411
  parents.push(n);
5398
5412
  }
@@ -5431,68 +5445,24 @@ function disposeRemainderSync(root, options, asChild, rootDetached) {
5431
5445
  return null;
5432
5446
  }
5433
5447
  const BASE_PROTO = {
5448
+ get emiters() {
5449
+ const base = this;
5450
+ return base._emiters ??= new ComponentEmiter(base.owner);
5451
+ },
5434
5452
  _offAll() {
5435
- const c = this.owner;
5436
- if (!c._eventHandlers)
5437
- return;
5438
- for (const [full, set] of c._eventHandlers) {
5439
- const name = full.split(":")[0];
5440
- const evt = name.startsWith("on") ? name.slice(2).toLowerCase() : name.toLowerCase();
5441
- for (const rec of set) {
5442
- if (!rec || !rec.wrapped) {
5443
- continue;
5444
- }
5445
- if (rec.domEvent === false) {
5446
- continue;
5447
- }
5448
- const cap = rec.capture === true;
5449
- try {
5450
- c.element.removeEventListener(evt, rec.wrapped, cap);
5451
- }
5452
- catch { }
5453
- try {
5454
- if (rec.capture === undefined) {
5455
- c.element.removeEventListener(evt, rec.wrapped, !cap);
5456
- }
5457
- }
5458
- catch { }
5459
- }
5460
- }
5461
- c._eventHandlers.clear();
5462
- c._eventHandlers = undefined;
5453
+ offAll(this.owner);
5463
5454
  },
5464
5455
  _deactivateBindings() {
5465
- const c = this.owner;
5466
- try {
5467
- c.bindings?.deactivateAll();
5468
- }
5469
- catch { }
5456
+ deactivateBindings(this.owner);
5470
5457
  },
5471
5458
  _activateBindings() {
5472
- const c = this.owner;
5473
- try {
5474
- c.bindings?.activateAll();
5475
- }
5476
- catch { }
5459
+ activateBindings(this.owner);
5477
5460
  },
5478
5461
  _reactivateBindings() {
5479
- const c = this.owner;
5480
- try {
5481
- c.bindings?.reActivateAll();
5482
- }
5483
- catch { }
5462
+ reactivateBindings(this.owner);
5484
5463
  },
5485
5464
  _activatePreBindings() {
5486
- if (this.prebinding_Activated)
5487
- return;
5488
- const c = this.owner;
5489
- const registered = c.bindings?._items;
5490
- if (registered && registered.length > 0) {
5491
- c.bindings.items.filter((x) => x.propertyName == "isWait" || x.propertyName == "display").forEach((b) => {
5492
- b.activate();
5493
- });
5494
- }
5495
- this.prebinding_Activated = true;
5465
+ activatePreBindings(this.owner);
5496
5466
  },
5497
5467
  _detachDomWithAnimation() {
5498
5468
  detachDomWithAnimation(this.owner);
@@ -5507,13 +5477,184 @@ const BASE_PROTO = {
5507
5477
  deepCleanup(this.owner);
5508
5478
  },
5509
5479
  };
5480
+ const EV_SELF = 1;
5481
+ const EV_TRUSTED = 2;
5482
+ const EV_PREVENT = 4;
5483
+ const EV_STOP = 8;
5484
+ const EV_CAPTURE = 16;
5485
+ const EV_DOM = 32;
5486
+ const EV_REMOVED = 64;
5487
+ const NO_MODS = [];
5488
+ let eventDispatchDepth = 0;
5489
+ class EventRecord {
5490
+ constructor(owner, key, original, type, flags) {
5491
+ this.owner = owner;
5492
+ this.key = key;
5493
+ this.original = original;
5494
+ this.type = type;
5495
+ this.flags = flags;
5496
+ this.next = undefined;
5497
+ }
5498
+ handleEvent(ev) {
5499
+ const flags = this.flags;
5500
+ const owner = this.owner;
5501
+ if ((flags & EV_SELF) !== 0 && ev.target !== owner.element)
5502
+ return;
5503
+ if ((flags & EV_TRUSTED) !== 0 && !ev.isTrusted)
5504
+ return;
5505
+ const cb = this.original;
5506
+ let res;
5507
+ try {
5508
+ if (cb && cb.length <= 1) {
5509
+ res = cb(ev);
5510
+ }
5511
+ else if (cb) {
5512
+ res = cb(owner, ev);
5513
+ }
5514
+ }
5515
+ catch (error) {
5516
+ reportError('MJX123', error, this.type);
5517
+ }
5518
+ if (res && typeof res.then === 'function') {
5519
+ const type = this.type;
5520
+ res.then(undefined, (error) => reportError('MJX123', error, type));
5521
+ }
5522
+ if ((flags & EV_PREVENT) !== 0) {
5523
+ preventEvent(ev);
5524
+ }
5525
+ if ((flags & EV_STOP) !== 0) {
5526
+ stopEvent(ev);
5527
+ }
5528
+ if (res && res.cancel === true) {
5529
+ preventEvent(ev);
5530
+ stopEvent(ev);
5531
+ }
5532
+ }
5533
+ }
5534
+ function preventEvent(ev) {
5535
+ if (typeof ev?.preventDefault === 'function')
5536
+ ev.preventDefault();
5537
+ }
5538
+ function stopEvent(ev) {
5539
+ if (typeof ev?.stopPropagation === 'function')
5540
+ ev.stopPropagation();
5541
+ }
5542
+ function addEventRecord(c, record) {
5543
+ let last = c._eventHandlers;
5544
+ if (last === undefined) {
5545
+ c._eventHandlers = record;
5546
+ return;
5547
+ }
5548
+ while (last.next !== undefined)
5549
+ last = last.next;
5550
+ last.next = record;
5551
+ }
5552
+ function compactEventRecords(c) {
5553
+ let head;
5554
+ let tail;
5555
+ for (let r = c._eventHandlers; r !== undefined; r = r.next) {
5556
+ if ((r.flags & EV_REMOVED) !== 0)
5557
+ continue;
5558
+ if (tail === undefined)
5559
+ head = r;
5560
+ else
5561
+ tail.next = r;
5562
+ tail = r;
5563
+ }
5564
+ if (tail !== undefined)
5565
+ tail.next = undefined;
5566
+ c._eventHandlers = head;
5567
+ }
5568
+ function hasEventKey(c, key) {
5569
+ for (let r = c._eventHandlers; r !== undefined; r = r.next) {
5570
+ if ((r.flags & EV_REMOVED) === 0 && r.key === key)
5571
+ return true;
5572
+ }
5573
+ return false;
5574
+ }
5575
+ function offAll(c) {
5576
+ const head = c._eventHandlers;
5577
+ if (head === undefined)
5578
+ return;
5579
+ for (let r = head; r !== undefined; r = r.next) {
5580
+ if ((r.flags & (EV_DOM | EV_REMOVED)) !== EV_DOM) {
5581
+ continue;
5582
+ }
5583
+ try {
5584
+ c.element.removeEventListener(r.type, r, (r.flags & EV_CAPTURE) !== 0);
5585
+ }
5586
+ catch { }
5587
+ }
5588
+ c._eventHandlers = undefined;
5589
+ }
5590
+ function deactivateBindings(c) {
5591
+ try {
5592
+ if (c._bindings?._items?.length)
5593
+ c._bindings.deactivateAll();
5594
+ }
5595
+ catch { }
5596
+ }
5597
+ function activateBindings(c) {
5598
+ try {
5599
+ c._bindings?.activateAll();
5600
+ }
5601
+ catch { }
5602
+ }
5603
+ function reactivateBindings(c) {
5604
+ try {
5605
+ c._bindings?.reActivateAll();
5606
+ }
5607
+ catch { }
5608
+ }
5609
+ function activatePreBindings(c) {
5610
+ if ((c._flags & F_PREBOUND) !== 0)
5611
+ return;
5612
+ const registered = c._bindings?._items;
5613
+ if (registered && registered.length > 0) {
5614
+ c._bindings.items.filter((x) => x.propertyName == "isWait" || x.propertyName == "display").forEach((b) => {
5615
+ b.activate();
5616
+ });
5617
+ }
5618
+ c._flags |= F_PREBOUND;
5619
+ }
5510
5620
  function createBaseCtx(owner) {
5511
5621
  const base = Object.create(BASE_PROTO);
5512
5622
  base.owner = owner;
5513
- base.prebinding_Activated = false;
5514
- base.emiters = new ComponentEmiter(owner);
5515
5623
  return base;
5516
5624
  }
5625
+ function controlsOwner(collection) {
5626
+ return collection.owner;
5627
+ }
5628
+ const NO_CHILDREN = Object.freeze([]);
5629
+ const NO_BINDINGS = Object.freeze([]);
5630
+ function childrenOf(c) {
5631
+ return c._controls?.items ?? NO_CHILDREN;
5632
+ }
5633
+ function createOwnedControls(c) {
5634
+ const controls = new ControlCollection(c);
5635
+ controls.onAdd = ownerControlAdded;
5636
+ controls.onAddBeforeBuild = ownerControlAddedBeforeBuild;
5637
+ controls.onRemove = ownerControlRemoved;
5638
+ return controls;
5639
+ }
5640
+ function ownerControlAdded(c) {
5641
+ const owner = controlsOwner(this);
5642
+ if (hasEventKey(owner, 'controladded'))
5643
+ owner.motif.trigger('controladded', { control: c });
5644
+ if (!owner.isVisible && owner.element?.nodeType === Node.COMMENT_NODE)
5645
+ return;
5646
+ ComponentHelper.internalBuild.call(owner, c);
5647
+ }
5648
+ function ownerControlAddedBeforeBuild(c) {
5649
+ const owner = controlsOwner(this);
5650
+ if (hasEventKey(owner, 'controladded'))
5651
+ owner.motif.trigger('controladded', { control: c });
5652
+ }
5653
+ function ownerControlRemoved(c) {
5654
+ const owner = controlsOwner(this);
5655
+ if (hasEventKey(owner, 'controlremoved'))
5656
+ owner.motif.trigger('controlremoved', { control: c });
5657
+ }
5517
5658
  const fragmentCloseMarkers = new WeakMap();
5518
5659
  const LIFECYCLE_X_EVENTS = new Set([
5519
5660
  'building', 'built', 'initializing', 'initialized', 'disposing', 'disposed',
@@ -5552,37 +5693,80 @@ function createScopedContext(app, owner) {
5552
5693
  });
5553
5694
  }
5554
5695
  class ComponentBase extends Disposable {
5555
- motif = new ComponentMotif(this, new ComponentOptionsImpl(this));
5556
- element;
5557
- props;
5558
- isBuilt = false;
5559
- isInitialized = false;
5560
- isDisposed = false;
5561
- isConfigured = false;
5562
- isPainting = false;
5563
- isPainted = false;
5564
- isVisible = true;
5565
- controls = new ControlCollection(this);
5566
- _eventHandlers;
5567
- _isWait = false;
5568
- class = new controlClass(this);
5569
- attr = new controlAttribute(this);
5570
- bindings = new BindingCollection(this);
5571
- /** style(fn) izleyicisi: tek tek tutulur, yeniden çağrıda önceki durdurulur. */
5572
- _styleFx;
5696
+ get motif() {
5697
+ return this._motif !== undefined ? this._motif : (this._motif = new ComponentMotif(this, (this.isDisposed && !this.element ? undefined : new ComponentOptionsImpl(this))));
5698
+ }
5699
+ get isBuilt() {
5700
+ return (this._flags & F_BUILT) !== 0;
5701
+ }
5702
+ set isBuilt(value) {
5703
+ this._flags = value ? this._flags | F_BUILT : this._flags & ~F_BUILT;
5704
+ }
5705
+ get isInitialized() {
5706
+ return (this._flags & F_INITIALIZED) !== 0;
5707
+ }
5708
+ set isInitialized(value) {
5709
+ this._flags = value ? this._flags | F_INITIALIZED : this._flags & ~F_INITIALIZED;
5710
+ }
5711
+ get isDisposed() {
5712
+ return (this._flags & F_DISPOSED) !== 0;
5713
+ }
5714
+ set isDisposed(value) {
5715
+ this._flags = value ? this._flags | F_DISPOSED : this._flags & ~F_DISPOSED;
5716
+ }
5717
+ get isConfigured() {
5718
+ return (this._flags & F_CONFIGURED) !== 0;
5719
+ }
5720
+ set isConfigured(value) {
5721
+ this._flags = value ? this._flags | F_CONFIGURED : this._flags & ~F_CONFIGURED;
5722
+ }
5723
+ get isPainting() {
5724
+ return (this._flags & F_PAINTING) !== 0;
5725
+ }
5726
+ set isPainting(value) {
5727
+ this._flags = value ? this._flags | F_PAINTING : this._flags & ~F_PAINTING;
5728
+ }
5729
+ get isPainted() {
5730
+ return (this._flags & F_PAINTED) !== 0;
5731
+ }
5732
+ set isPainted(value) {
5733
+ this._flags = value ? this._flags | F_PAINTED : this._flags & ~F_PAINTED;
5734
+ }
5735
+ get isVisible() {
5736
+ return (this._flags & F_HIDDEN) === 0;
5737
+ }
5738
+ set isVisible(value) {
5739
+ this._flags = value ? this._flags & ~F_HIDDEN : this._flags | F_HIDDEN;
5740
+ }
5741
+ get controls() {
5742
+ return this._controls !== undefined || (this.isDisposed && !this.element) ? this._controls : (this._controls = createOwnedControls(this));
5743
+ }
5744
+ set controls(value) {
5745
+ this._controls = value;
5746
+ }
5747
+ get class() {
5748
+ return this._class !== undefined || (this.isDisposed && !this.element) ? this._class : (this._class = new controlClass(this));
5749
+ }
5750
+ set class(value) {
5751
+ this._class = value;
5752
+ }
5753
+ get attr() {
5754
+ return this._attr !== undefined || (this.isDisposed && !this.element) ? this._attr : (this._attr = new controlAttribute(this));
5755
+ }
5756
+ set attr(value) {
5757
+ this._attr = value;
5758
+ }
5759
+ get bindings() {
5760
+ return this._bindings !== undefined || (this.isDisposed && !this.element) ? this._bindings : (this._bindings = new BindingCollection(this));
5761
+ }
5762
+ set bindings(value) {
5763
+ this._bindings = value;
5764
+ }
5573
5765
  useModel(modelCtor) {
5574
5766
  return reactive(modelCtor);
5575
5767
  }
5576
5768
  _computeHideStrategy() {
5577
- const cfg = this.motif.options?.hideStrategy ?? 'auto';
5578
- if (cfg === 'placeholder')
5579
- return 'placeholder';
5580
- if (cfg === 'detach')
5581
- return 'detach';
5582
- if (this.motif.options?.__fromList || typeof this.motif.options?.indexkey !== 'undefined' || typeof this.motif.options?.__key !== 'undefined') {
5583
- return 'detach';
5584
- }
5585
- return 'placeholder';
5769
+ return keepsTrace(this) ? 'placeholder' : 'detach';
5586
5770
  }
5587
5771
  _isInDom() {
5588
5772
  try {
@@ -5599,7 +5783,7 @@ class ComponentBase extends Disposable {
5599
5783
  }
5600
5784
  }
5601
5785
  set isWait(value) {
5602
- this._isWait = value;
5786
+ this._flags = value ? this._flags | F_WAIT : this._flags & ~F_WAIT;
5603
5787
  if (this.isBuilt) {
5604
5788
  if (value) {
5605
5789
  this.motif.hide();
@@ -5614,10 +5798,22 @@ class ComponentBase extends Disposable {
5614
5798
  }
5615
5799
  }
5616
5800
  get isWait() {
5617
- return this._isWait;
5801
+ return (this._flags & F_WAIT) !== 0;
5618
5802
  }
5619
5803
  constructor(element, props = {}) {
5620
5804
  super();
5805
+ this._motif = undefined;
5806
+ this._flags = 0;
5807
+ this._controls = undefined;
5808
+ this._class = undefined;
5809
+ this._attr = undefined;
5810
+ this._bindings = undefined;
5811
+ this._baseCtx = undefined;
5812
+ this._init = undefined;
5813
+ this._leaveContainer = undefined;
5814
+ this.parent = null;
5815
+ const asComponentRoot = constructingComponentRoot;
5816
+ constructingComponentRoot = false;
5621
5817
  recordServiceOwner(this);
5622
5818
  if (this.onElementCreating) {
5623
5819
  this.element = this.onElementCreating.call(this);
@@ -5628,44 +5824,38 @@ class ComponentBase extends Disposable {
5628
5824
  else {
5629
5825
  this.element = element;
5630
5826
  }
5631
- if (props) {
5632
- const refs = extractRefs(props, this);
5633
- if (refs.length > 0) {
5634
- for (const fn of takePendingRefs(this, refs)) {
5635
- callReported(() => fn(this), 'MJX122', 'ref');
5636
- }
5637
- }
5827
+ if (this.element?.nodeType !== 3) {
5828
+ if (this._controls === undefined)
5829
+ this._controls = new ControlCollection(this);
5638
5830
  }
5639
- props && ParseProps(props, this);
5831
+ const refs = props ? extractRefs(props, this) : [];
5832
+ if (props && ParseProps(props, this))
5833
+ props = {};
5640
5834
  applyComponentOptions(props?.options, this);
5641
5835
  this.props = props;
5642
5836
  // (class/style/id/tabindex/role/aria-*/data-*) kök düğüme (root node) düşer, prop'lar this.props'ta kalır.
5643
5837
  if (props) {
5644
5838
  const ctor0 = new.target;
5645
- const plain = ctor0 === ComponentBase || Object.getPrototypeOf(ctor0) === ComponentBase;
5839
+ const plain = !asComponentRoot && (ctor0 === ComponentBase || Object.getPrototypeOf(ctor0) === ComponentBase);
5646
5840
  if (plain)
5647
5841
  applyPlainElementProps(props, this);
5648
5842
  else
5649
5843
  applyFallthroughProps(props, this);
5650
5844
  }
5845
+ if (refs.length > 0) {
5846
+ for (const fn of takePendingRefs(this, refs)) {
5847
+ callReported(() => fn(this), 'MJX122', 'ref');
5848
+ }
5849
+ }
5651
5850
  ComponentHelper.callOnInitializing(this);
5652
5851
  if (this.isDisposed)
5653
5852
  return;
5654
- this.controls.onAdd = (c) => {
5655
- if (this._eventHandlers?.has('controladded'))
5656
- this.motif.trigger('controladded', { control: c });
5657
- if (this.isWait || this.parent?.isWait)
5658
- return;
5659
- ComponentHelper.internalBuild.call(this, c);
5660
- };
5661
- this.controls.onAddBeforeBuild = (c) => {
5662
- if (this._eventHandlers?.has('controladded'))
5663
- this.motif.trigger('controladded', { control: c });
5664
- };
5665
- this.controls.onRemove = (c) => {
5666
- if (this._eventHandlers?.has('controlremoved'))
5667
- this.motif.trigger('controlremoved', { control: c });
5668
- };
5853
+ const controls = this._controls;
5854
+ if (controls) {
5855
+ controls.onAdd = ownerControlAdded;
5856
+ controls.onAddBeforeBuild = ownerControlAddedBeforeBuild;
5857
+ controls.onRemove = ownerControlRemoved;
5858
+ }
5669
5859
  ComponentHelper.callOnInitialized(this);
5670
5860
  const ctor = new.target;
5671
5861
  const isBaseCtor = ctor === ComponentBase || Object.getPrototypeOf(ctor) === ComponentBase;
@@ -5676,10 +5866,9 @@ class ComponentBase extends Disposable {
5676
5866
  this._base._configDeferred = true;
5677
5867
  }
5678
5868
  }
5679
- childs;
5680
- _base = createBaseCtx(this);
5681
- parent = null;
5682
- _scopedContext;
5869
+ get _base() {
5870
+ return this._baseCtx !== undefined || (this.isDisposed && !this.element) ? this._baseCtx : (this._baseCtx = createBaseCtx(this));
5871
+ }
5683
5872
  get context() {
5684
5873
  const parentCtx = this.parent?.context;
5685
5874
  const app = parentCtx?.[RAW_APPLICATION] ?? parentCtx ?? teardownApplications.get(this) ?? Application.main;
@@ -5706,7 +5895,7 @@ class ComponentBase extends Disposable {
5706
5895
  build(building = true) {
5707
5896
  checkReservedMembers(this);
5708
5897
  ComponentHelper.callConfigured(this);
5709
- this._base._activatePreBindings();
5898
+ activatePreBindings(this);
5710
5899
  if (this.isDisposed || !this.element || this.isWait) {
5711
5900
  return;
5712
5901
  }
@@ -5743,7 +5932,7 @@ class ComponentBase extends Disposable {
5743
5932
  }
5744
5933
  const deferredSelectValue = this.element?.nodeName === 'SELECT'
5745
5934
  ? this.bindings.items.filter(b => b.propertyName === 'value')
5746
- : [];
5935
+ : NO_BINDINGS;
5747
5936
  if (deferredSelectValue.length) {
5748
5937
  try {
5749
5938
  this.bindings.items.filter(b => !deferredSelectValue.includes(b)).forEach(b => b.activate());
@@ -5751,32 +5940,41 @@ class ComponentBase extends Disposable {
5751
5940
  catch { }
5752
5941
  }
5753
5942
  else {
5754
- this._base._activateBindings();
5943
+ activateBindings(this);
5755
5944
  }
5756
- for (const element of this.controls.items.filter(c => !c.isWait)) {
5757
- element.parent = this;
5758
- element.build(false);
5945
+ const kids = childrenOf(this);
5946
+ for (const element of kids.length ? kids.slice() : kids) {
5947
+ var target = isFragment ? this.motif.options.cache : this.element;
5948
+ if (!element.isWait) {
5949
+ element.parent = this;
5950
+ element.build(false);
5951
+ }
5759
5952
  if (element.isWait) {
5953
+ if (keepsTrace(element)) {
5954
+ const opts = element.motif.options;
5955
+ (building ? ph : target).appendChild(opts.placeholder ?? (opts.placeholder = dom.createComment("h")));
5956
+ }
5760
5957
  continue;
5761
5958
  }
5762
- var target = isFragment ? this.motif.options.cache : this.element;
5763
5959
  if (building) {
5764
- if (element.motif.options.cache) {
5765
- ph.appendChild(element.motif.options.cache);
5960
+ const cache = optionsOf(element)?.cache;
5961
+ if (cache) {
5962
+ ph.appendChild(cache);
5766
5963
  }
5767
5964
  else {
5768
5965
  ph.appendChild(element.element);
5769
5966
  }
5770
5967
  }
5771
5968
  else {
5772
- if (element.motif.options.cache) {
5773
- target.appendChild(element.motif.options.cache);
5969
+ const cache = optionsOf(element)?.cache;
5970
+ if (cache) {
5971
+ target.appendChild(cache);
5774
5972
  }
5775
5973
  else {
5776
5974
  target.appendChild(element.element);
5777
5975
  }
5778
5976
  }
5779
- if (element._base?._inactive && element.isVisible) {
5977
+ if (element._baseCtx?._inactive && element.isVisible) {
5780
5978
  ComponentHelper.activateTree(element);
5781
5979
  }
5782
5980
  }
@@ -5839,10 +6037,10 @@ class ComponentBase extends Disposable {
5839
6037
  this.controls.forEach(c => {
5840
6038
  c.setState();
5841
6039
  });
5842
- this._base._reactivateBindings();
6040
+ reactivateBindings(this);
5843
6041
  }
5844
6042
  reState() {
5845
- this._base._reactivateBindings();
6043
+ reactivateBindings(this);
5846
6044
  this.controls.forEach(c => {
5847
6045
  c.reState();
5848
6046
  });
@@ -5966,6 +6164,9 @@ class ComponentBase extends Disposable {
5966
6164
  if (this.isVisible) {
5967
6165
  return;
5968
6166
  } /* A*/
6167
+ if (this.isWait) {
6168
+ return;
6169
+ }
5969
6170
  if (this.parent && enterModeOf(this.parent) === 'out-in') {
5970
6171
  const showHost = (this.motif.options.placeholder?.parentNode)
5971
6172
  ?? findAppendableComponent(this.parent)?.element;
@@ -5987,7 +6188,7 @@ class ComponentBase extends Disposable {
5987
6188
  /** A*/
5988
6189
  const strategy = this._computeHideStrategy();
5989
6190
  if (strategy === 'detach') {
5990
- ComponentHelper.callVisibilityChanged(this);
6191
+ ComponentHelper.callVisibilityChanged(this, true);
5991
6192
  if (this.isDisposed) {
5992
6193
  return;
5993
6194
  }
@@ -6004,6 +6205,10 @@ class ComponentBase extends Disposable {
6004
6205
  const expectedParent = findAppendableComponent(this.parent)?.element;
6005
6206
  if (this.motif.options.placeholder && placeholderParent && placeholderParent !== expectedParent) {
6006
6207
  reportWarning('MJX106', []);
6208
+ ComponentHelper.callVisibilityChanged(this, true);
6209
+ if (this.isDisposed) {
6210
+ return;
6211
+ }
6007
6212
  this.isVisible = true;
6008
6213
  if (this.parent?.isBuilt) {
6009
6214
  ComponentHelper.internalBuild.call(this.parent, this);
@@ -6012,11 +6217,12 @@ class ComponentBase extends Disposable {
6012
6217
  }
6013
6218
  /** A*/
6014
6219
  wantsEnterTransition(this) && this.motif.options.transition.enterTransition(() => { });
6015
- ComponentHelper.callVisibilityChanged(this);
6220
+ ComponentHelper.callVisibilityChanged(this, true);
6016
6221
  if (this.isDisposed) {
6017
6222
  return;
6018
6223
  }
6019
6224
  if (this.element.nodeType === Node.COMMENT_NODE) {
6225
+ this.controls.items.filter(c => !c.isBuilt).forEach(c => ComponentHelper.internalBuild.call(this, c));
6020
6226
  this.controls.forEach(c => {
6021
6227
  c.motif.show();
6022
6228
  });
@@ -6024,6 +6230,10 @@ class ComponentBase extends Disposable {
6024
6230
  ComponentHelper.activateTree(this, false);
6025
6231
  return;
6026
6232
  }
6233
+ if (!this.isBuilt) {
6234
+ this.isVisible = true;
6235
+ return;
6236
+ }
6027
6237
  var parent = this.motif.options.placeholder?.parentElement;
6028
6238
  if (parent) {
6029
6239
  parent.replaceChild(this.element, this.motif.options.placeholder);
@@ -6042,7 +6252,7 @@ class ComponentBase extends Disposable {
6042
6252
  }
6043
6253
  const strategy = this._computeHideStrategy();
6044
6254
  if (strategy === 'detach') {
6045
- ComponentHelper.callVisibilityChanged(this);
6255
+ ComponentHelper.callVisibilityChanged(this, false);
6046
6256
  if (this.isDisposed) {
6047
6257
  return;
6048
6258
  }
@@ -6057,7 +6267,7 @@ class ComponentBase extends Disposable {
6057
6267
  if (skip)
6058
6268
  transition.skipNextLeave = false;
6059
6269
  const finish = () => {
6060
- ComponentHelper.callVisibilityChanged(this);
6270
+ ComponentHelper.callVisibilityChanged(this, false);
6061
6271
  if (this.isDisposed) {
6062
6272
  return;
6063
6273
  }
@@ -6140,61 +6350,36 @@ class ComponentBase extends Disposable {
6140
6350
  return this;
6141
6351
  }
6142
6352
  }
6143
- const [name, ...mods] = full.split(":");
6353
+ const colon = full.indexOf(":");
6354
+ const name = colon < 0 ? full : full.slice(0, colon);
6355
+ const mods = colon < 0 ? NO_MODS : full.slice(colon + 1).split(":");
6144
6356
  const evt = name.startsWith("on") ? name.slice(2).toLowerCase() : name.toLowerCase();
6145
- const options = {};
6146
- if (mods.includes("once"))
6147
- options.once = true;
6148
- if (mods.includes("passive"))
6149
- options.passive = true;
6150
- if (mods.includes("capture"))
6151
- options.capture = true;
6152
- const wrapped = (ev) => {
6153
- if (mods.includes("self") && ev.target !== this.element)
6154
- return;
6155
- if (mods.includes("trusted") && !ev.isTrusted)
6156
- return;
6157
- let res;
6158
- try {
6159
- if (cb && cb.length <= 1) {
6160
- res = cb(ev);
6161
- }
6162
- else if (cb) {
6163
- res = cb(this, ev);
6164
- }
6165
- }
6166
- catch (error) {
6167
- reportError('MJX123', error, evt);
6168
- }
6169
- if (res && typeof res.then === 'function') {
6170
- res.then(undefined, (error) => reportError('MJX123', error, evt));
6171
- }
6172
- const prevent = () => { if (typeof ev?.preventDefault === 'function')
6173
- ev.preventDefault(); };
6174
- const stop = () => { if (typeof ev?.stopPropagation === 'function')
6175
- ev.stopPropagation(); };
6176
- if (mods.includes("prevent")) {
6177
- prevent();
6178
- }
6179
- if (mods.includes("stop")) {
6180
- stop();
6181
- }
6182
- if (res && res.cancel === true) {
6183
- prevent();
6184
- stop();
6185
- }
6186
- };
6357
+ let flags = domEvent ? EV_DOM : 0;
6358
+ let options;
6359
+ if (mods.length) {
6360
+ options = {};
6361
+ if (mods.includes("once"))
6362
+ options.once = true;
6363
+ if (mods.includes("passive"))
6364
+ options.passive = true;
6365
+ if (mods.includes("capture")) {
6366
+ options.capture = true;
6367
+ flags |= EV_CAPTURE;
6368
+ }
6369
+ if (mods.includes("self"))
6370
+ flags |= EV_SELF;
6371
+ if (mods.includes("trusted"))
6372
+ flags |= EV_TRUSTED;
6373
+ if (mods.includes("prevent"))
6374
+ flags |= EV_PREVENT;
6375
+ if (mods.includes("stop"))
6376
+ flags |= EV_STOP;
6377
+ }
6378
+ const record = new EventRecord(this, full.toLowerCase(), cb, evt, flags);
6187
6379
  if (domEvent) {
6188
- this.element.addEventListener(evt, wrapped, options);
6189
- }
6190
- this._eventHandlers ??= new Map();
6191
- const key = full.toLowerCase();
6192
- const set = this._eventHandlers.get(key) ?? new Set();
6193
- set.add({ original: cb, wrapped, capture: !!options.capture, domEvent: !!domEvent, type: evt });
6194
- this._eventHandlers.set(key, set);
6195
- this._register(disposableCore.toDisposable(() => {
6196
- this.motif.off(event, cb);
6197
- }));
6380
+ this.element.addEventListener(evt, record, options);
6381
+ }
6382
+ addEventRecord(this, record);
6198
6383
  return this;
6199
6384
  }
6200
6385
  async _trigger(event, ev) {
@@ -6203,15 +6388,20 @@ class ComponentBase extends Disposable {
6203
6388
  }
6204
6389
  const name = String(event).toLowerCase();
6205
6390
  safeCall(() => {
6206
- var eh = this._eventHandlers?.get(name);
6207
- if (eh) {
6208
- eh.forEach(rec => {
6391
+ eventDispatchDepth++;
6392
+ try {
6393
+ for (let r = this._eventHandlers; r !== undefined; r = r.next) {
6394
+ if ((r.flags & EV_REMOVED) !== 0 || r.key !== name)
6395
+ continue;
6209
6396
  try {
6210
- rec.wrapped(ev);
6397
+ r.handleEvent(ev);
6211
6398
  }
6212
6399
  catch {
6213
6400
  }
6214
- });
6401
+ }
6402
+ }
6403
+ finally {
6404
+ eventDispatchDepth--;
6215
6405
  }
6216
6406
  }, 'trigger');
6217
6407
  return this;
@@ -6234,38 +6424,24 @@ class ComponentBase extends Disposable {
6234
6424
  return this;
6235
6425
  }
6236
6426
  if (LIFECYCLE_X_EVENTS.has(xName)) {
6237
- this._base.emiters.off("on" + xName, cb);
6427
+ this._base._emiters?.off("on" + xName, cb);
6238
6428
  }
6239
6429
  return this;
6240
6430
  }
6241
- const name = full.split(":")[0];
6242
- const evt = name.startsWith("on") ? name.slice(2).toLowerCase() : name.toLowerCase();
6243
- if (!this._eventHandlers)
6244
- return this;
6245
- const set = this._eventHandlers.get(full);
6246
- if (!set)
6247
- return this;
6248
- for (const rec of Array.from(set)) {
6249
- if (rec.original === cb) {
6250
- if (rec.domEvent !== false) {
6251
- const cap = rec.capture === true;
6252
- safeCall(() => { this.element.removeEventListener(evt, rec.wrapped, cap); }, 'off.removeEventListener');
6253
- safeCall(() => {
6254
- if (rec.capture === undefined) {
6255
- this.element.removeEventListener(evt, rec.wrapped, !cap);
6256
- }
6257
- }, 'off.removeEventListener.fallback');
6258
- }
6259
- set.delete(rec);
6260
- break;
6431
+ for (let r = this._eventHandlers; r !== undefined; r = r.next) {
6432
+ if ((r.flags & EV_REMOVED) !== 0 || r.key !== full || r.original !== cb)
6433
+ continue;
6434
+ if ((r.flags & EV_DOM) !== 0) {
6435
+ const rec = r;
6436
+ safeCall(() => { this.element.removeEventListener(rec.type, rec, (rec.flags & EV_CAPTURE) !== 0); }, 'off.removeEventListener');
6261
6437
  }
6438
+ r.flags |= EV_REMOVED;
6439
+ break;
6262
6440
  }
6263
- if (set.size === 0)
6264
- this._eventHandlers.delete(full);
6441
+ if (eventDispatchDepth === 0)
6442
+ compactEventRecords(this);
6265
6443
  return this;
6266
6444
  }
6267
- /** Süren bertaraf: ikinci bir dispose/disposeAsync çağrısı yenisini başlatmaz, bunu bekler. */
6268
- _disposing;
6269
6445
  dispose(options = { deep: true }) {
6270
6446
  if (this.isDisposed) {
6271
6447
  return Promise.resolve();
@@ -6336,8 +6512,6 @@ class ComponentBase extends Disposable {
6336
6512
  }
6337
6513
  });
6338
6514
  }
6339
- _siblingsApi;
6340
- _siblingsSet;
6341
6515
  get siblings() {
6342
6516
  if (this._siblingsSet) {
6343
6517
  return this._siblingsApi;
@@ -6485,6 +6659,12 @@ class ComponentBase extends Disposable {
6485
6659
  t.activeAnimations = [];
6486
6660
  }
6487
6661
  }
6662
+ Object.defineProperty(ComponentBase.prototype, 'motif', {
6663
+ ...Object.getOwnPropertyDescriptor(ComponentBase.prototype, 'motif'),
6664
+ set(value) {
6665
+ this._motif = value;
6666
+ },
6667
+ });
6488
6668
  function findContentBlocks(root, results = []) {
6489
6669
  if (!root || root.isDisposed)
6490
6670
  return results;
@@ -6529,6 +6709,16 @@ function takePendingRefs(component, ref) {
6529
6709
  }
6530
6710
  return pending;
6531
6711
  }
6712
+ function disposeUnplacedChilds(owner, kids) {
6713
+ if (!Array.isArray(kids) || !kids.some(kid => kid instanceof ComponentBase))
6714
+ return;
6715
+ owner.motif.setDisposable(() => {
6716
+ for (const kid of kids) {
6717
+ if (kid instanceof ComponentBase && !kid.isDisposed && !kid.parent)
6718
+ kid.dispose();
6719
+ }
6720
+ });
6721
+ }
6532
6722
  const isCallableRef = (ref) => typeof ref === 'function' || Array.isArray(ref);
6533
6723
  function extractRefs(props, component) {
6534
6724
  const refs = [];
@@ -6580,26 +6770,38 @@ function collectLifecycleHandlers(component, lowerKey, value) {
6580
6770
  const fns = Array.isArray(value) ? value : [value];
6581
6771
  if (fns.length === 0 || !fns.every(fn => typeof fn === 'function'))
6582
6772
  return false;
6583
- component._base[listName] ??= [];
6584
- const list = component._base[listName];
6585
- for (const fn of fns) {
6586
- if (!list.includes(fn))
6587
- list.push(fn);
6773
+ const target = component;
6774
+ let from = 0;
6775
+ if (listName === '_initializeComponentHandlers') {
6776
+ if (target._init === undefined && !target._baseCtx?._initializeComponentHandlers) {
6777
+ target._init = fns[0];
6778
+ from = 1;
6779
+ }
6780
+ }
6781
+ if (from >= fns.length)
6782
+ return true;
6783
+ const base = target._base;
6784
+ for (let i = from; i < fns.length; i++) {
6785
+ const fn = fns[i];
6786
+ if (listName === '_initializeComponentHandlers' && fn === target._init)
6787
+ continue;
6788
+ const slot = base[listName];
6789
+ if (slot === undefined)
6790
+ base[listName] = fn;
6791
+ else if (typeof slot === 'function') {
6792
+ if (slot !== fn)
6793
+ base[listName] = [slot, fn];
6794
+ }
6795
+ else if (!slot.includes(fn))
6796
+ slot.push(fn);
6588
6797
  }
6589
6798
  return true;
6590
6799
  }
6591
6800
  function ParseProps(props, component) {
6592
6801
  if (props) {
6593
- if (component.motif.options.props) {
6594
- Object.assign(component.motif.options.props, props);
6595
- }
6596
- else {
6597
- component.motif.options.props = {};
6598
- Object.assign(component.motif.options.props, props);
6599
- }
6600
6802
  var keys = Object.keys(props);
6601
6803
  if (keys.length === 0)
6602
- return;
6804
+ return false;
6603
6805
  keys.forEach(key => {
6604
6806
  if (key == 'initializeComponent' || key == 'oninitializeComponent' || key.startsWith('on')) {
6605
6807
  if (collectLifecycleHandlers(component, key.toLowerCase(), props[key])) {
@@ -6610,6 +6812,7 @@ function ParseProps(props, component) {
6610
6812
  else if (key == 'childs') {
6611
6813
  const flat = [].concat(...props[key]);
6612
6814
  component.childs = flat;
6815
+ disposeUnplacedChilds(component, flat);
6613
6816
  delete props[key];
6614
6817
  }
6615
6818
  else if (key === 'transition') {
@@ -6654,9 +6857,14 @@ function ParseProps(props, component) {
6654
6857
  component.motif.options._preconfig = props[key];
6655
6858
  delete props[key];
6656
6859
  }
6860
+ else if (key === '__childExpr') {
6861
+ delete props[key];
6862
+ }
6657
6863
  else ;
6658
6864
  });
6865
+ return typeof props === 'object' && Reflect.ownKeys(props).length === 0;
6659
6866
  }
6867
+ return false;
6660
6868
  }
6661
6869
  const _transitionSources = new WeakMap();
6662
6870
  function setTransition(component, value, live) {
@@ -6827,6 +7035,16 @@ const FALLTHROUGH_KEYS = new Set(['class', 'className', 'style', 'id', 'tabindex
6827
7035
  function isFallthroughKey(key) {
6828
7036
  return FALLTHROUGH_KEYS.has(key) || key.startsWith('aria-') || key.startsWith('data-');
6829
7037
  }
7038
+ let constructingComponentRoot = false;
7039
+ function constructComponentRoot(make) {
7040
+ constructingComponentRoot = true;
7041
+ try {
7042
+ return make();
7043
+ }
7044
+ finally {
7045
+ constructingComponentRoot = false;
7046
+ }
7047
+ }
6830
7048
  function applyFallthroughProps(props, component) {
6831
7049
  if (!props || typeof props !== 'object' || component.isDisposed)
6832
7050
  return;
@@ -6876,35 +7094,51 @@ function findAppendableComponent(component) {
6876
7094
  return null;
6877
7095
  }, 'findAppendableComponent', null);
6878
7096
  }
7097
+ const attachWaiters = new Set();
7098
+ let attachObserver = null;
7099
+ function releaseAttachObserver() {
7100
+ if (attachWaiters.size || !attachObserver) {
7101
+ return;
7102
+ }
7103
+ try {
7104
+ attachObserver.disconnect();
7105
+ }
7106
+ catch { /* ignore */ }
7107
+ attachObserver = null;
7108
+ }
7109
+ function flushAttachWaiters() {
7110
+ for (const waiter of [...attachWaiters]) {
7111
+ if (!attachWaiters.has(waiter) || !document.contains(waiter.element)) {
7112
+ continue;
7113
+ }
7114
+ attachWaiters.delete(waiter);
7115
+ try {
7116
+ waiter.callback();
7117
+ }
7118
+ catch (error) {
7119
+ queueMicrotask(() => { throw error; });
7120
+ }
7121
+ }
7122
+ releaseAttachObserver();
7123
+ }
6879
7124
  function onElementAttached(element, callback) {
6880
7125
  if (document.contains(element)) {
6881
7126
  callback();
6882
7127
  return null;
6883
7128
  }
6884
- let done = false;
6885
- const observer = new MutationObserver(() => {
6886
- if (done) {
6887
- return;
6888
- }
6889
- if (document.contains(element)) {
6890
- done = true;
6891
- observer.disconnect();
6892
- callback();
6893
- }
6894
- });
6895
- observer.observe(document.documentElement, {
6896
- childList: true,
6897
- subtree: true,
6898
- });
7129
+ const waiter = { element, callback };
7130
+ attachWaiters.add(waiter);
7131
+ if (!attachObserver) {
7132
+ attachObserver = new MutationObserver(flushAttachWaiters);
7133
+ attachObserver.observe(document.documentElement, {
7134
+ childList: true,
7135
+ subtree: true,
7136
+ });
7137
+ }
6899
7138
  return () => {
6900
- if (done) {
6901
- return;
6902
- }
6903
- done = true;
6904
- try {
6905
- observer.disconnect();
7139
+ if (attachWaiters.delete(waiter)) {
7140
+ releaseAttachObserver();
6906
7141
  }
6907
- catch { /* ignore */ }
6908
7142
  };
6909
7143
  }
6910
7144
  function notifyActivated(component) {
@@ -6960,8 +7194,6 @@ function createDeclaredElement(tag, ctor, props) {
6960
7194
  return dom.createElement(tag, props);
6961
7195
  }
6962
7196
  class Component extends ComponentBase {
6963
- static elementTag;
6964
- static elementNamespace;
6965
7197
  constructor() {
6966
7198
  const derivedCtor = new.target;
6967
7199
  var args = arguments;
@@ -7041,9 +7273,11 @@ class Component extends ComponentBase {
7041
7273
  // Alt sınıflar initializeComponent'i ezdiği için FragmentNode.initializeComponent'e güvenilemez.
7042
7274
  const kids = this.childs;
7043
7275
  if (Array.isArray(kids) && kids.length) {
7044
- for (const kid of kids) {
7045
- if (kid)
7046
- this.controls.add(kid);
7276
+ if (derivedCtor?._placesChilds !== true) {
7277
+ for (const kid of kids) {
7278
+ if (kid)
7279
+ this.controls.add(kid);
7280
+ }
7047
7281
  }
7048
7282
  }
7049
7283
  }
@@ -7065,6 +7299,7 @@ function applyJsxFrameworkProps(target, props, refs) {
7065
7299
  if (!(target instanceof ComponentBase))
7066
7300
  return target;
7067
7301
  applyRefs(target, refs.concat(extractRefs(props)));
7302
+ disposeUnplacedChilds(target, props.childs);
7068
7303
  // Fonksiyon bileşeni etiketindeki ortak öznitelikler (class/id/aria-*…) döndürülen köke düşer.
7069
7304
  // Kök `<div {...props}/>` ise aynı değerler zaten uygulanmıştır; ikinci kez uygulanmaz.
7070
7305
  applyFallthroughProps(props, target);
@@ -7075,8 +7310,7 @@ function applyJsxFrameworkProps(target, props, refs) {
7075
7310
  const runover = props.runover;
7076
7311
  if (!runover || typeof runover !== 'object')
7077
7312
  return target;
7078
- const handlers = target._base?._onConfigHandlers;
7079
- const configuredBefore = Array.isArray(handlers) ? handlers.length : 0;
7313
+ const configuredBefore = handlerCount(target, '_onConfigHandlers');
7080
7314
  const initializingBefore = handlerCount(target, '_onInitializingHandlers');
7081
7315
  const initializedBefore = handlerCount(target, '_onInitializedHandlers');
7082
7316
  ParseProps(runover, target);
@@ -7090,12 +7324,9 @@ function applyJsxFrameworkProps(target, props, refs) {
7090
7324
  if (typeof pre === 'function') {
7091
7325
  safeCallSilent(() => pre(target), 'motifComponent.preconfig');
7092
7326
  }
7093
- const after = target._base?._onConfigHandlers;
7094
- if (Array.isArray(after)) {
7095
- for (let i = configuredBefore; i < after.length; i++) {
7096
- const fn = after[i];
7097
- callReported(() => fn(target, { cancel: false }), 'MJX122', 'onConfig');
7098
- }
7327
+ for (let i = configuredBefore; i < handlerCount(target, '_onConfigHandlers'); i++) {
7328
+ const fn = hookList(target, '_onConfigHandlers')[i];
7329
+ callReported(() => fn(target, { cancel: false }), 'MJX122', 'onConfig');
7099
7330
  }
7100
7331
  }
7101
7332
  return target;
@@ -7108,18 +7339,18 @@ function applyRefs(target, refs) {
7108
7339
  }
7109
7340
  return target;
7110
7341
  }
7342
+ function hookList(target, listName) {
7343
+ const slot = target._base?.[listName];
7344
+ return !slot ? [] : typeof slot === 'function' ? [slot] : slot;
7345
+ }
7111
7346
  function handlerCount(target, listName) {
7112
- const list = target._base?.[listName];
7113
- return Array.isArray(list) ? list.length : 0;
7347
+ return hookList(target, listName).length;
7114
7348
  }
7115
7349
  function callAddedHandlers(target, listName, from, hook) {
7116
- const list = target._base?.[listName];
7117
- if (!Array.isArray(list))
7118
- return;
7119
- for (let i = from; i < list.length; i++) {
7350
+ for (let i = from; i < handlerCount(target, listName); i++) {
7120
7351
  if (target.isDisposed)
7121
7352
  return;
7122
- const fn = list[i];
7353
+ const fn = hookList(target, listName)[i];
7123
7354
  callReported(() => fn(target, { cancel: false }), 'MJX122', hook);
7124
7355
  }
7125
7356
  }
@@ -7139,9 +7370,22 @@ function resolveChildExpression(probe) {
7139
7370
  return value;
7140
7371
  return undefined;
7141
7372
  }
7142
- function motifComponent(element, props) {
7373
+ function motifComponent(element, props, lone) {
7143
7374
  // Etiket adı: element yaratımı (HTML/SVG) ve spread prop uygulaması Component ctor'ının string parametresinde
7144
7375
  if (typeof element === "string") {
7376
+ if (typeof props === "function") {
7377
+ const compiled = new Component(element);
7378
+ compiled._init = props;
7379
+ return compiled;
7380
+ }
7381
+ if (lone === 1 && props !== null && typeof props === "object") {
7382
+ const init = props.initializeComponent;
7383
+ if (typeof init === "function") {
7384
+ const compiled = new Component(element);
7385
+ compiled._init = init;
7386
+ return compiled;
7387
+ }
7388
+ }
7145
7389
  if (element === "text" && props && props.__childExpr) {
7146
7390
  const resolved = resolveChildExpression(props.__childExpr);
7147
7391
  if (resolved !== undefined)
@@ -7203,7 +7447,9 @@ function resolveToComponent(input, props) {
7203
7447
  return resolved;
7204
7448
  }
7205
7449
  function materializeOptionsObject(spec, props) {
7206
- const result = motifComponent(spec.el, props);
7450
+ const result = typeof spec.el === 'string'
7451
+ ? constructComponentRoot(() => motifComponent(spec.el, props))
7452
+ : motifComponent(spec.el, props);
7207
7453
  Object.getOwnPropertyNames(spec).forEach(key => {
7208
7454
  if (key !== 'el' && key !== 'ctor') {
7209
7455
  result[key] = spec[key];
@@ -7239,7 +7485,7 @@ class FragmentNode extends Component {
7239
7485
  }
7240
7486
  }
7241
7487
  safeCallSilent(() => {
7242
- const nodes = this.motif.options?.props?.nodes;
7488
+ const nodes = this.props?.nodes;
7243
7489
  if (Array.isArray(nodes) && nodes.length) {
7244
7490
  for (const n of nodes) {
7245
7491
  if (n)
@@ -7401,11 +7647,10 @@ function $(description, attrs, ...children) {
7401
7647
 
7402
7648
  // import { dom } from "../browser";
7403
7649
  class ControlCollection {
7404
- owner;
7405
7650
  constructor(owner) {
7406
7651
  this.owner = owner;
7652
+ this.items = [];
7407
7653
  }
7408
- items = [];
7409
7654
  add() {
7410
7655
  const count = arguments.length;
7411
7656
  if (count === 0)
@@ -7485,7 +7730,7 @@ class ControlCollection {
7485
7730
  this.items.splice(index, 1);
7486
7731
  if (control.isDisposed)
7487
7732
  return Promise.resolve();
7488
- control._base && (control._base._leaveContainer = this.owner);
7733
+ control._leaveContainer = this.owner;
7489
7734
  control.parent = null;
7490
7735
  return runLeaveThenDetach(control, () => { if (this.onRemove)
7491
7736
  this.onRemove(control); });
@@ -7515,7 +7760,7 @@ class ControlCollection {
7515
7760
  if (index === -1)
7516
7761
  return;
7517
7762
  this.items.splice(index, 1);
7518
- control._base && (control._base._leaveContainer = this.owner);
7763
+ control._leaveContainer = this.owner;
7519
7764
  control.parent = null;
7520
7765
  }
7521
7766
  async clearAsync() {
@@ -7540,9 +7785,6 @@ class ControlCollection {
7540
7785
  map(callbackfn) {
7541
7786
  return this.items.map(callbackfn);
7542
7787
  }
7543
- onAdd;
7544
- onRemove;
7545
- onAddBeforeBuild;
7546
7788
  move(control, before) {
7547
7789
  if (!control || control.isDisposed)
7548
7790
  return;
@@ -7570,14 +7812,29 @@ class ControlCollection {
7570
7812
  const insertAt = newBeforeIndex >= 0 ? newBeforeIndex : this.items.length;
7571
7813
  this.items.splice(insertAt, 0, control);
7572
7814
  }
7573
- if (control.isWait) {
7574
- return;
7575
- }
7576
7815
  const container = findAppendableElement(this.owner);
7577
- if (!container)
7816
+ if (!container || !domAnchor(control, container))
7578
7817
  return;
7579
- const referenceNode = before ? before.element : computeAppendReference(this.owner);
7580
- moveComponentDomRange(control, container, referenceNode);
7818
+ const at = before ? this.items.indexOf(before) : -1;
7819
+ moveComponentDomRange(control, container, at >= 0 ? anchorFrom(this.owner, this.items, at, container) : computeAppendReference(this.owner));
7820
+ }
7821
+ _reorder(order, stable) {
7822
+ const container = findAppendableElement(this.owner);
7823
+ if (container) {
7824
+ let ref = computeAppendReference(this.owner);
7825
+ for (let i = order.length - 1; i >= 0; i--) {
7826
+ const control = order[i];
7827
+ const node = domAnchor(control, container);
7828
+ if (!node)
7829
+ continue;
7830
+ if (!stable.has(i))
7831
+ moveComponentDomRange(control, container, ref);
7832
+ ref = node;
7833
+ }
7834
+ }
7835
+ const items = this.items;
7836
+ for (let i = 0; i < order.length; i++)
7837
+ items[i] = order[i];
7581
7838
  }
7582
7839
  moveToIndex(control, index) {
7583
7840
  if (!control || control.isDisposed)
@@ -7614,12 +7871,20 @@ function computeAppendReference(owner) {
7614
7871
  }
7615
7872
  return null;
7616
7873
  }
7874
+ function anchorFrom(owner, items, start, container) {
7875
+ for (let i = start; i < items.length; i++) {
7876
+ const anchor = domAnchor(items[i], container);
7877
+ if (anchor)
7878
+ return anchor;
7879
+ }
7880
+ return computeAppendReference(owner);
7881
+ }
7617
7882
  /** Bir component'in kök DOM aralığını (tek element veya fragment aralığı) referenceNode öncesine taşır. */
7618
7883
  function moveComponentDomRange(control, container, referenceNode) {
7619
- const node = control.element;
7884
+ const node = domAnchor(control, container);
7620
7885
  if (!node)
7621
7886
  return;
7622
- if (node.nodeType !== Node.COMMENT_NODE) {
7887
+ if (node.nodeType !== Node.COMMENT_NODE || node !== control.element) {
7623
7888
  try {
7624
7889
  container.insertBefore(node, referenceNode);
7625
7890
  }
@@ -7702,9 +7967,7 @@ function detachComponentDom(control) {
7702
7967
  if (!node)
7703
7968
  return;
7704
7969
  const opts = control.motif.options;
7705
- if (node.nodeType === Node.COMMENT_NODE) {
7706
- if (!node.parentNode)
7707
- return;
7970
+ if (node.nodeType === Node.COMMENT_NODE && node.parentNode) {
7708
7971
  const close = opts?.closeFragment || null;
7709
7972
  const cache = opts.cache ?? (opts.cache = dom.createDocumentFragment());
7710
7973
  let current = node;
@@ -8177,13 +8440,12 @@ async function navigateHost(host, page, keepOldControl = false) {
8177
8440
  }
8178
8441
 
8179
8442
  class Frame extends Component {
8180
- current = null;
8181
- _latestNavigateId = 0;
8182
- _navLock = Promise.resolve();
8183
- _navAbort;
8184
- isBusy = false;
8185
8443
  constructor(props) {
8186
8444
  super(dom.createComment(''), props);
8445
+ this.current = null;
8446
+ this._latestNavigateId = 0;
8447
+ this._navLock = Promise.resolve();
8448
+ this.isBusy = false;
8187
8449
  if (props && props.childs && Array.isArray(props.childs) && props.childs.length > 0) {
8188
8450
  this.controls.add(props.childs);
8189
8451
  }
@@ -8198,7 +8460,6 @@ class Frame extends Component {
8198
8460
  async _clear() {
8199
8461
  await disposeNavigationTarget(this.current);
8200
8462
  }
8201
- previouspage;
8202
8463
  async navigate(page, keepOldControl = false) {
8203
8464
  await navigateHost(this, page, keepOldControl);
8204
8465
  }
@@ -8208,6 +8469,25 @@ class Frame extends Component {
8208
8469
  }
8209
8470
  }
8210
8471
 
8472
+ const SLOT_REGISTERED_EVENT = Symbol('slotRegistered');
8473
+ const SLOT_UNREGISTERED_EVENT = Symbol('slotUnregistered');
8474
+ class TransportRegistry {
8475
+ static { this.slots = new Map(); }
8476
+ static registerSlot(name, slot) {
8477
+ this.slots.set(name, slot);
8478
+ Application.main.fire(SLOT_REGISTERED_EVENT, { name, slot });
8479
+ }
8480
+ static unregisterSlot(name, slot) {
8481
+ if (this.slots.get(name) === slot) {
8482
+ this.slots.delete(name);
8483
+ Application.main.fire(SLOT_UNREGISTERED_EVENT, { name, slot });
8484
+ }
8485
+ }
8486
+ static getSlot(name) {
8487
+ return this.slots.get(name);
8488
+ }
8489
+ }
8490
+
8211
8491
  const ARRAY_MUTATORS = new Set(['push', 'pop', 'shift', 'unshift', 'splice', 'reverse', 'sort']);
8212
8492
  const NOT_META = Symbol('');
8213
8493
  const metaReaders = new Map([
@@ -8345,11 +8625,10 @@ const PATCHED_ARRAY_METHODS = [
8345
8625
  ];
8346
8626
  const isLookupMiss = (outcome) => outcome === false || outcome === -1;
8347
8627
  class ArrayMethods {
8348
- engine;
8349
8628
  constructor(engine) {
8350
8629
  this.engine = engine;
8630
+ this.get = this.createArrayMethods();
8351
8631
  }
8352
- get = this.createArrayMethods();
8353
8632
  createArrayMethods() {
8354
8633
  const table = {};
8355
8634
  for (const [name, kind] of PATCHED_ARRAY_METHODS) {
@@ -8541,7 +8820,6 @@ const ReactiveEngineMapper = new WeakSet();
8541
8820
  const AllreactiveMap = new WeakMap();
8542
8821
  function armgetter() { return AllreactiveMap; }
8543
8822
  class ReactiveEngine {
8544
- _gci;
8545
8823
  startGc(_intervalMs = 10000) { }
8546
8824
  stopGc() { if (this._gci) {
8547
8825
  try {
@@ -8551,31 +8829,30 @@ class ReactiveEngine {
8551
8829
  this._gci = undefined;
8552
8830
  } }
8553
8831
  constructor() {
8832
+ this.DisposeMapper = new LinkedList();
8833
+ this.arrayTriggerCache = new Map();
8834
+ this.ReactiveMap = () => armgetter();
8835
+ this.isReadonly = false;
8836
+ this.superficial = false;
8837
+ this.arrayMethods = new ArrayMethods(this);
8838
+ this.arrayHandler = {
8839
+ get: createGetter(this),
8840
+ set: createSetter(this),
8841
+ has: createHas(),
8842
+ deleteProperty: createDelete(),
8843
+ ownKeys: createOwn()
8844
+ };
8845
+ this.deepHandler = {
8846
+ get: createGetter(this),
8847
+ set: createSetter(this),
8848
+ has: createHas(),
8849
+ deleteProperty: createDelete(),
8850
+ ownKeys: createOwn()
8851
+ };
8852
+ this.collectionHandler = createCollectionHandler(this);
8554
8853
  ReactiveEngineMapper.add(this);
8555
8854
  this.startGc();
8556
8855
  }
8557
- DisposeMapper = new LinkedList();
8558
- arrayTriggerCache = new Map();
8559
- ReactiveMap = () => armgetter();
8560
- activeCallback;
8561
- isReadonly = false;
8562
- superficial = false;
8563
- arrayMethods = new ArrayMethods(this);
8564
- arrayHandler = {
8565
- get: createGetter(this),
8566
- set: createSetter(this),
8567
- has: createHas(),
8568
- deleteProperty: createDelete(),
8569
- ownKeys: createOwn()
8570
- };
8571
- deepHandler = {
8572
- get: createGetter(this),
8573
- set: createSetter(this),
8574
- has: createHas(),
8575
- deleteProperty: createDelete(),
8576
- ownKeys: createOwn()
8577
- };
8578
- collectionHandler = createCollectionHandler(this);
8579
8856
  reactive(model) {
8580
8857
  if (!isObject(model)) {
8581
8858
  model = { value: model };
@@ -8638,7 +8915,6 @@ class ReactiveEngine {
8638
8915
  ArrayTrigger(target, key, ...args) {
8639
8916
  this.trigger(target, key, args);
8640
8917
  }
8641
- onValueChanged;
8642
8918
  toRaw(item) {
8643
8919
  return JSON.parse(JSON.stringify(this.deepClone(item)));
8644
8920
  }
@@ -8824,7 +9100,9 @@ function isConstructor(fn) {
8824
9100
  }
8825
9101
  }
8826
9102
  class ServiceCollection {
8827
- descriptors = new Map();
9103
+ constructor() {
9104
+ this.descriptors = new Map();
9105
+ }
8828
9106
  reset() {
8829
9107
  this.descriptors.clear();
8830
9108
  }
@@ -9081,7 +9359,7 @@ function initOverlayIfEnabled() {
9081
9359
  }
9082
9360
 
9083
9361
  class RouterViewRegistry {
9084
- static outlets = new Map();
9362
+ static { this.outlets = new Map(); }
9085
9363
  static register(name, scopeId, instance) {
9086
9364
  if (!this.outlets.has(name))
9087
9365
  this.outlets.set(name, new Map());
@@ -9110,9 +9388,12 @@ const RouterViewBuilt = Symbol.for("RouterView.built");
9110
9388
  class RouterView extends Component {
9111
9389
  constructor(props) {
9112
9390
  super(props);
9391
+ this._navLock = Promise.resolve();
9392
+ this.disposingChilds = false;
9393
+ this.current = null;
9394
+ this._latestNavigateId = 0;
9395
+ this.isBusy = false;
9113
9396
  }
9114
- _navLock = Promise.resolve();
9115
- _navAbort;
9116
9397
  get __isRouterView() {
9117
9398
  return true;
9118
9399
  }
@@ -9124,11 +9405,6 @@ class RouterView extends Component {
9124
9405
  }
9125
9406
  return ids.join('>');
9126
9407
  }
9127
- disposingChilds = false;
9128
- previouspage;
9129
- current = null;
9130
- _latestNavigateId = 0;
9131
- isBusy = false;
9132
9408
  async navigate(page, keepOldControl = false) {
9133
9409
  await navigateHost(this, page, keepOldControl);
9134
9410
  }
@@ -9159,18 +9435,16 @@ const DEFAULT_LIMIT = 60;
9159
9435
  const DEFAULT_SETTLE_MS = 1200;
9160
9436
  const USER_INPUT = ['wheel', 'touchstart', 'keydown', 'mousedown'];
9161
9437
  class ScrollMemory {
9162
- options;
9163
- viewport;
9164
- positions = new Map();
9165
- currentKey = '';
9166
- currentPath = null;
9167
- visited = false;
9168
- restoring = false;
9169
- cancelFrame = null;
9170
- disarmAbort = null;
9171
- offs = [];
9172
- locationAnchor = true;
9173
9438
  constructor(options = {}, viewport) {
9439
+ this.positions = new Map();
9440
+ this.currentKey = '';
9441
+ this.currentPath = null;
9442
+ this.visited = false;
9443
+ this.restoring = false;
9444
+ this.cancelFrame = null;
9445
+ this.disarmAbort = null;
9446
+ this.offs = [];
9447
+ this.locationAnchor = true;
9174
9448
  this.options = options;
9175
9449
  this.viewport = viewport ?? (options.container ? containerViewport(options.container) : windowViewport());
9176
9450
  this.load();
@@ -9573,24 +9847,18 @@ function overlay(floating, anchor, above) {
9573
9847
  }
9574
9848
  }
9575
9849
  class NavigationStack {
9576
- retainAttached;
9577
- depth;
9578
- persist;
9579
- animation;
9580
- duration;
9581
- swipe;
9582
- session = null;
9583
- entries = new Map();
9584
- uris = new Map();
9585
- loaded = null;
9586
- current = null;
9587
- currentTop = null;
9588
- offs = [];
9589
- gesture = null;
9590
- gestureCommitted = false;
9591
- awaitingGestureResult = false;
9592
- disposed = false;
9593
9850
  constructor(options) {
9851
+ this.session = null;
9852
+ this.entries = new Map();
9853
+ this.uris = new Map();
9854
+ this.loaded = null;
9855
+ this.current = null;
9856
+ this.currentTop = null;
9857
+ this.offs = [];
9858
+ this.gesture = null;
9859
+ this.gestureCommitted = false;
9860
+ this.awaitingGestureResult = false;
9861
+ this.disposed = false;
9594
9862
  const o = options === true ? {} : options;
9595
9863
  this.retainAttached = o.retain === true;
9596
9864
  this.depth = Math.max(0, Math.floor(o.depth ?? 5));
@@ -10099,13 +10367,28 @@ class NavigationStack {
10099
10367
  }
10100
10368
 
10101
10369
  class Scanner {
10102
- source;
10103
10370
  constructor(source) {
10104
10371
  this.source = source;
10372
+ this.currentColumn = 0;
10373
+ this.tokens = [];
10374
+ this.parameters = {};
10375
+ this.codePointAt = String.prototype.codePointAt ?
10376
+ (s, i) => s.codePointAt(i) : function codePointAt(str, i) {
10377
+ const size = str.length;
10378
+ if (i < 0 || i >= size) {
10379
+ return undefined;
10380
+ }
10381
+ const first = str.charCodeAt(i);
10382
+ if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) {
10383
+ const second = str.charCodeAt(i + 1);
10384
+ if (second >= 0xDC00 && second <= 0xDFFF) {
10385
+ return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
10386
+ }
10387
+ }
10388
+ return first;
10389
+ };
10105
10390
  this.tokens = [];
10106
10391
  }
10107
- currentColumn = 0;
10108
- tokens = [];
10109
10392
  addToken(token) {
10110
10393
  this.tokens.push(token);
10111
10394
  }
@@ -10333,7 +10616,6 @@ class Scanner {
10333
10616
  pattern += '$';
10334
10617
  return new RegExp(pattern, "i");
10335
10618
  }
10336
- parameters = {};
10337
10619
  exist(input, pageSearch) {
10338
10620
  const hashIdx = input.indexOf('#');
10339
10621
  const withoutHash = hashIdx >= 0 ? input.substring(0, hashIdx) : input;
@@ -10417,21 +10699,6 @@ class Scanner {
10417
10699
  }
10418
10700
  return false;
10419
10701
  }
10420
- codePointAt = String.prototype.codePointAt ?
10421
- (s, i) => s.codePointAt(i) : function codePointAt(str, i) {
10422
- const size = str.length;
10423
- if (i < 0 || i >= size) {
10424
- return undefined;
10425
- }
10426
- const first = str.charCodeAt(i);
10427
- if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) {
10428
- const second = str.charCodeAt(i + 1);
10429
- if (second >= 0xDC00 && second <= 0xDFFF) {
10430
- return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
10431
- }
10432
- }
10433
- return first;
10434
- };
10435
10702
  }
10436
10703
 
10437
10704
  /** Bir fullPath'in statik (parametresiz) ve parametreli segment sayıları. */
@@ -10459,11 +10726,41 @@ function compareRouteRecords(a, b) {
10459
10726
  return b.fullPath.length - a.fullPath.length;
10460
10727
  }
10461
10728
  class RouteCollection {
10462
- routes;
10463
- records = [];
10464
- routesMap = new Map();
10465
10729
  constructor(routes) {
10466
10730
  this.routes = routes;
10731
+ this.records = [];
10732
+ this.routesMap = new Map();
10733
+ this.walk = (chain, parentPath, node, viaAlias = false) => {
10734
+ const fullPath = this.joinPaths(parentPath, node.path);
10735
+ if (!viaAlias) {
10736
+ const existing = node.fullPath;
10737
+ if (existing == null || (typeof existing === 'string' && existing.trim() === '')) {
10738
+ node.fullPath = fullPath;
10739
+ }
10740
+ if (node.name != null) {
10741
+ this.routesMap.set(node.name, node);
10742
+ }
10743
+ }
10744
+ const nextChain = [...chain, node];
10745
+ const aliases = node.alias == null ? [] : (Array.isArray(node.alias) ? node.alias : [node.alias]);
10746
+ const variants = [
10747
+ { path: fullPath, isAlias: viaAlias },
10748
+ ...aliases.map(a => ({ path: this.joinPaths(parentPath, a), isAlias: true }))
10749
+ ];
10750
+ for (const variant of variants) {
10751
+ this.records.push({
10752
+ fullPath: variant.path,
10753
+ chain: nextChain,
10754
+ leaf: node,
10755
+ scanner: new Scanner(variant.path),
10756
+ aliasOf: variant.isAlias ? (node.fullPath ?? null) : null
10757
+ });
10758
+ if (node.childs && node.childs.length) {
10759
+ for (const child of node.childs)
10760
+ this.walk(nextChain, variant.path, child, variant.isAlias);
10761
+ }
10762
+ }
10763
+ };
10467
10764
  this.build();
10468
10765
  }
10469
10766
  build() {
@@ -10473,37 +10770,6 @@ class RouteCollection {
10473
10770
  this.walk([], "", r);
10474
10771
  this.records.sort(compareRouteRecords);
10475
10772
  }
10476
- walk = (chain, parentPath, node, viaAlias = false) => {
10477
- const fullPath = this.joinPaths(parentPath, node.path);
10478
- if (!viaAlias) {
10479
- const existing = node.fullPath;
10480
- if (existing == null || (typeof existing === 'string' && existing.trim() === '')) {
10481
- node.fullPath = fullPath;
10482
- }
10483
- if (node.name != null) {
10484
- this.routesMap.set(node.name, node);
10485
- }
10486
- }
10487
- const nextChain = [...chain, node];
10488
- const aliases = node.alias == null ? [] : (Array.isArray(node.alias) ? node.alias : [node.alias]);
10489
- const variants = [
10490
- { path: fullPath, isAlias: viaAlias },
10491
- ...aliases.map(a => ({ path: this.joinPaths(parentPath, a), isAlias: true }))
10492
- ];
10493
- for (const variant of variants) {
10494
- this.records.push({
10495
- fullPath: variant.path,
10496
- chain: nextChain,
10497
- leaf: node,
10498
- scanner: new Scanner(variant.path),
10499
- aliasOf: variant.isAlias ? (node.fullPath ?? null) : null
10500
- });
10501
- if (node.childs && node.childs.length) {
10502
- for (const child of node.childs)
10503
- this.walk(nextChain, variant.path, child, variant.isAlias);
10504
- }
10505
- }
10506
- };
10507
10773
  joinPaths(parent, child) {
10508
10774
  parent = parent || "";
10509
10775
  child = child || "";
@@ -10520,19 +10786,22 @@ class RouteCollection {
10520
10786
  }
10521
10787
 
10522
10788
  class RoutingEngine {
10523
- stack = null;
10524
- _revealed = new Set();
10525
- root;
10526
- application;
10527
- routingModule;
10528
- _previousPath = null;
10529
- _previousInstances = [];
10789
+ constructor() {
10790
+ this.stack = null;
10791
+ this._revealed = new Set();
10792
+ this._previousPath = null;
10793
+ this._previousInstances = [];
10794
+ this.controlCache = new Map();
10795
+ this._navVersion = 0;
10796
+ this._pendingActivate = new Set();
10797
+ this.pendingMount = new WeakMap();
10798
+ this.pendingListeners = new WeakMap();
10799
+ }
10530
10800
  register(mainApp, application, routingModule) {
10531
10801
  this.root = mainApp;
10532
10802
  this.application = application;
10533
10803
  this.routingModule = routingModule;
10534
10804
  }
10535
- controlCache = new Map();
10536
10805
  async evict(route) {
10537
10806
  const targets = route ? [route] : Array.from(this.controlCache.keys());
10538
10807
  for (const r of targets) {
@@ -10594,8 +10863,6 @@ class RoutingEngine {
10594
10863
  }
10595
10864
  return result;
10596
10865
  }
10597
- _navVersion = 0;
10598
- _pendingActivate = new Set();
10599
10866
  async execute(path, nav, route) {
10600
10867
  route ??= {
10601
10868
  target: path,
@@ -11066,9 +11333,7 @@ class RoutingEngine {
11066
11333
  }
11067
11334
  async activator(container) {
11068
11335
  }
11069
- pendingMount = new WeakMap();
11070
- pendingListeners = new WeakMap();
11071
- static OUTLET_WARN_MS = 3000;
11336
+ static { this.OUTLET_WARN_MS = 3000; }
11072
11337
  async mountChain(instances, chain, container, navVersion) {
11073
11338
  for (let index = 0; index < instances.length;) {
11074
11339
  if (navVersion !== this._navVersion)
@@ -11200,17 +11465,20 @@ class RoutingEngine {
11200
11465
  const pathOf = (uri) => uri.split('#')[0].split('?')[0];
11201
11466
  const newHistorySession = () => Math.random().toString(36).slice(2, 10) + Date.now().toString(36);
11202
11467
  class UrlRoutingModule {
11203
- static MAX_REDIRECTS = 10;
11204
- _routerOptions;
11205
- routingEngine;
11206
- routeCollection;
11207
- routesMap = new Map();
11208
- mainApp;
11209
- application;
11210
- _suppressBeforeEachOnce = false;
11211
- _suppressMiddlewaresOnce = false;
11212
- _scroll = null;
11468
+ static { this.MAX_REDIRECTS = 10; }
11213
11469
  constructor(options, application) {
11470
+ this.routesMap = new Map();
11471
+ this._suppressBeforeEachOnce = false;
11472
+ this._suppressMiddlewaresOnce = false;
11473
+ this._scroll = null;
11474
+ this._stack = null;
11475
+ this._windowNavListener = null;
11476
+ this._historyStamp = null;
11477
+ this._pendingTraversal = null;
11478
+ this._currentUri = '___startup___';
11479
+ this._previousRoute = null;
11480
+ this._fallbackRoutes = {};
11481
+ this._navHandler = null;
11214
11482
  this._routerOptions = options;
11215
11483
  this.routeCollection = new RouteCollection(options.RouteItems);
11216
11484
  this.routingEngine = new RoutingEngine();
@@ -11226,11 +11494,9 @@ class UrlRoutingModule {
11226
11494
  this.routingEngine.stack = this._stack;
11227
11495
  }
11228
11496
  }
11229
- _stack = null;
11230
11497
  getHooks() {
11231
11498
  return this._routerOptions.hooks;
11232
11499
  }
11233
- _windowNavListener = null;
11234
11500
  start(mainApp, shellUri) {
11235
11501
  this.mainApp = mainApp;
11236
11502
  this.routingEngine.register(this.mainApp, this.application, this);
@@ -11262,8 +11528,7 @@ class UrlRoutingModule {
11262
11528
  return '/';
11263
11529
  }
11264
11530
  }
11265
- static HISTORY_STAMP_KEY = '__motifHistory';
11266
- _historyStamp = null;
11531
+ static { this.HISTORY_STAMP_KEY = '__motifHistory'; }
11267
11532
  _addressMode() {
11268
11533
  const w = window;
11269
11534
  return this._routerOptions.mode || (w?.location?.protocol === 'file:' ? 'hash' : 'history');
@@ -11359,7 +11624,6 @@ class UrlRoutingModule {
11359
11624
  this._stampCurrentEntry(stamp);
11360
11625
  this._historyStamp = stamp;
11361
11626
  }
11362
- _pendingTraversal = null;
11363
11627
  async _onHistoryTraversal() {
11364
11628
  const shown = this._historyStamp;
11365
11629
  const arrived = this._readHistoryStamp();
@@ -11395,8 +11659,6 @@ class UrlRoutingModule {
11395
11659
  }
11396
11660
  catch { }
11397
11661
  }
11398
- _currentUri = '___startup___';
11399
- _previousRoute = null;
11400
11662
  get currentUri() {
11401
11663
  return this._currentUri;
11402
11664
  }
@@ -11635,7 +11897,6 @@ class UrlRoutingModule {
11635
11897
  }
11636
11898
  await this.routingEngine.evict(item);
11637
11899
  }
11638
- _fallbackRoutes = {};
11639
11900
  _getFallbackRoute(kind) {
11640
11901
  const existing = this._fallbackRoutes[kind];
11641
11902
  if (existing)
@@ -11708,7 +11969,7 @@ class UrlRoutingModule {
11708
11969
  }
11709
11970
  return best ? { chain: best.rec.chain, params: best.params } : null;
11710
11971
  }
11711
- static _builtinNotFound = () => new Component('div', {
11972
+ static { this._builtinNotFound = () => new Component('div', {
11712
11973
  initializeComponent(sender) {
11713
11974
  sender.style({
11714
11975
  padding: '20px', fontFamily: 'Arial, sans-serif', display: 'flex', 'flex-direction': 'column', 'align-items': 'center'
@@ -11716,8 +11977,8 @@ class UrlRoutingModule {
11716
11977
  sender.element.appendChild($('h2', {}, ...['404 - Not Found']));
11717
11978
  sender.element.appendChild($('p', {}, ...['The requested page was not found.']));
11718
11979
  },
11719
- });
11720
- static _builtinError = () => new Component('div', {
11980
+ }); }
11981
+ static { this._builtinError = () => new Component('div', {
11721
11982
  initializeComponent(sender) {
11722
11983
  sender.style({
11723
11984
  padding: '20px', fontFamily: 'Arial, sans-serif', display: 'flex', 'flex-direction': 'column', 'align-items': 'center'
@@ -11725,7 +11986,7 @@ class UrlRoutingModule {
11725
11986
  sender.element.appendChild($('h2', {}, ...['Error']));
11726
11987
  sender.element.appendChild($('p', {}, ...['The requested page could not be loaded.']));
11727
11988
  },
11728
- });
11989
+ }); }
11729
11990
  async navigateByName(name, params, options) {
11730
11991
  return await this.navigate(this.href(name, params), options);
11731
11992
  }
@@ -11881,7 +12142,6 @@ class UrlRoutingModule {
11881
12142
  }
11882
12143
  return true;
11883
12144
  }
11884
- _navHandler = null;
11885
12145
  _installLinkInterceptor() {
11886
12146
  try {
11887
12147
  if (this._navHandler)
@@ -12086,9 +12346,11 @@ class UrlRoutingModule {
12086
12346
  }
12087
12347
 
12088
12348
  class RouterState {
12089
- version = new Signal(0);
12090
- _current = null;
12091
- _constructing = null;
12349
+ constructor() {
12350
+ this.version = new Signal(0);
12351
+ this._current = null;
12352
+ this._constructing = null;
12353
+ }
12092
12354
  read() {
12093
12355
  this.version.value;
12094
12356
  return this._constructing ?? this._current;
@@ -12169,8 +12431,8 @@ function createRouter(state, module) {
12169
12431
  let _globalApplication = null;
12170
12432
  let startedApplicationBuilder = false;
12171
12433
  class ApplicationBuilder {
12172
- services = new ServiceCollection();
12173
12434
  constructor() {
12435
+ this.services = new ServiceCollection();
12174
12436
  if ((_globalApplication && _globalApplication.state !== 'disposing') || startedApplicationBuilder) {
12175
12437
  throw new MotifError('MJX405', formatMotifMessage('MJX405'), { cause: _globalApplication });
12176
12438
  }
@@ -12197,28 +12459,31 @@ class ApplicationBuilder {
12197
12459
  }
12198
12460
  }
12199
12461
  class Application {
12200
- provider;
12201
12462
  static get main() {
12202
12463
  return _globalApplication;
12203
12464
  }
12204
12465
  constructor(provider) {
12205
12466
  this.provider = provider;
12467
+ this._state = 'initializing';
12468
+ this._middlewares = [];
12469
+ this._beforeEachGuards = [];
12470
+ this._routerState = new RouterState();
12471
+ this.router = createRouter(this._routerState, () => this.urlRoutingModule);
12472
+ this.events = new Map();
12473
+ this._routerConfig = null;
12474
+ this._routerRoot = null;
12475
+ this._startedRouter = null;
12476
+ this._lifecycleOff = null;
12477
+ this._isDevelopment = false;
12478
+ this._enableErrorLogging = true;
12206
12479
  }
12207
- static _disposingCount = 0;
12208
- _state = 'initializing';
12209
- _disposing;
12480
+ static { this._disposingCount = 0; }
12210
12481
  get state() {
12211
12482
  return this._state;
12212
12483
  }
12213
- _middlewares = [];
12214
- _beforeEachGuards = [];
12215
- _routerState = new RouterState();
12216
- router = createRouter(this._routerState, () => this.urlRoutingModule);
12217
- events = new Map();
12218
12484
  static CreateBuilder() {
12219
12485
  return new ApplicationBuilder();
12220
12486
  }
12221
- appShell;
12222
12487
  getAppShell() {
12223
12488
  return this.appShell;
12224
12489
  }
@@ -12362,10 +12627,6 @@ class Application {
12362
12627
  }
12363
12628
  return true;
12364
12629
  }
12365
- urlRoutingModule;
12366
- _routerConfig = null;
12367
- _routerRoot = null;
12368
- _startedRouter = null;
12369
12630
  useRouter(options) {
12370
12631
  let routes;
12371
12632
  let mode;
@@ -12485,7 +12746,6 @@ class Application {
12485
12746
  return true;
12486
12747
  }
12487
12748
  }
12488
- _lifecycleOff = null;
12489
12749
  onLifecycle(handler) {
12490
12750
  this._installLifecycleListeners();
12491
12751
  return this.on('motifjs-app-lifecycle', handler);
@@ -12527,8 +12787,6 @@ class Application {
12527
12787
  for (const off of offs)
12528
12788
  off();
12529
12789
  }
12530
- _isDevelopment = false;
12531
- _enableErrorLogging = true;
12532
12790
  get isDevelopmentModeEnabled() {
12533
12791
  return this._isDevelopment;
12534
12792
  }
@@ -12588,10 +12846,13 @@ exports.RouteCollection = RouteCollection;
12588
12846
  exports.RouterState = RouterState;
12589
12847
  exports.RouterView = RouterView;
12590
12848
  exports.RoutingEngine = RoutingEngine;
12849
+ exports.SLOT_REGISTERED_EVENT = SLOT_REGISTERED_EVENT;
12850
+ exports.SLOT_UNREGISTERED_EVENT = SLOT_UNREGISTERED_EVENT;
12591
12851
  exports.Scanner = Scanner;
12592
12852
  exports.ServiceCollection = ServiceCollection;
12593
12853
  exports.ServiceProvider = ServiceProvider;
12594
12854
  exports.Signal = Signal;
12855
+ exports.TransportRegistry = TransportRegistry;
12595
12856
  exports.UrlRoutingModule = UrlRoutingModule;
12596
12857
  exports.asyncTracking = asyncTracking;
12597
12858
  exports.autoRegistry = autoRegistry;
@@ -12629,4 +12890,4 @@ exports.untracked = untracked;
12629
12890
  exports.useApplication = useApplication;
12630
12891
  exports.useModel = useModel;
12631
12892
  exports.useNavigation = useNavigation;
12632
- //# sourceMappingURL=core-CX1Sz73P.cjs.map
12893
+ //# sourceMappingURL=core-ZMoM1273.cjs.map