@motifx/core 1.2.0-rc.2 → 1.2.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/chunks/{core-CX1Sz73P.cjs → core-DD3SssnS.cjs} +1083 -833
- package/dist/chunks/core-DD3SssnS.cjs.map +1 -0
- package/dist/chunks/{core-C5z0P3iY.esm.js → core-W7wNt8bq.esm.js} +1081 -834
- package/dist/chunks/core-W7wNt8bq.esm.js.map +1 -0
- package/dist/devtools.cjs +1 -1
- package/dist/devtools.esm.js +1 -1
- package/dist/index.cjs +101 -156
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -18
- package/dist/index.d.ts +46 -18
- package/dist/index.esm.js +92 -147
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.umd.js +1151 -959
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/core-C5z0P3iY.esm.js.map +0 -1
- package/dist/chunks/core-CX1Sz73P.cjs.map +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { m as motifError, C as Component, r as reportWarning, A as Application, c as contentBlocks, f as findAppendableComponent, u as untracked, e as effect,
|
|
2
|
-
export {
|
|
1
|
+
import { m as motifError, C as Component, r as reportWarning, T as TransportRegistry, A as Application, S as SLOT_REGISTERED_EVENT, a as SLOT_UNREGISTERED_EVENT, c as contentBlocks, f as findAppendableComponent, u as untracked, e as effect, b as reportError, d as ComponentBase, n as notifyDeactivated, g as autoRegistry, M as MotifError, h as formatMotifMessage } from './chunks/core-W7wNt8bq.esm.js';
|
|
2
|
+
export { i as ApplicationBuilder, l as ComponentMotif, o as Computed, q as ControlCollection, D as Disposable, y as DisposableStore, E as Emitter, F as ErrorHandler, G as FNComponent, H as FragmentNode, I as Frame, L as Lazy, K as LazyComputed, N as LinkedList, R as NodeTypes, V as RouterView, Z as ServiceCollection, _ as ServiceProvider, a0 as Signal, j as asyncTracking, k as clearModel, p as configureReactivityLeakMonitor, s as createComputed, t as createLazyComputed, v as createSignal, w as deepClone, x as disposableCore, z as dom, B as errorHandler, J as inject, O as motifCompiled, P as motifComponent, Q as motifFragment, U as reactive, W as safeCall, X as safeCallAsync, Y as safeCallSilent, $ as setUnexpectedErrorHandler, a1 as toDisposable, a2 as useApplication, a3 as useModel, a4 as useNavigation } from './chunks/core-W7wNt8bq.esm.js';
|
|
3
3
|
|
|
4
4
|
class NameValuePair {
|
|
5
|
-
Key;
|
|
6
|
-
value;
|
|
7
5
|
}
|
|
8
6
|
|
|
9
7
|
class List {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
_map = new Set();
|
|
8
|
+
constructor() {
|
|
9
|
+
this.__list = [];
|
|
10
|
+
this._map = new Set();
|
|
11
|
+
}
|
|
15
12
|
Dispose() {
|
|
16
13
|
this.__list = [];
|
|
17
14
|
}
|
|
@@ -93,7 +90,9 @@ class List {
|
|
|
93
90
|
}
|
|
94
91
|
|
|
95
92
|
class Dictionary {
|
|
96
|
-
|
|
93
|
+
constructor() {
|
|
94
|
+
this.__values = new List();
|
|
95
|
+
}
|
|
97
96
|
Add(Key, Value) {
|
|
98
97
|
var item = new NameValuePair();
|
|
99
98
|
item.Key = Key;
|
|
@@ -110,7 +109,6 @@ class Dictionary {
|
|
|
110
109
|
item(key) {
|
|
111
110
|
return this.filter(t => t.Key == key)[0];
|
|
112
111
|
}
|
|
113
|
-
OnItemAdded;
|
|
114
112
|
removeIndex(index) {
|
|
115
113
|
return this.__values.removeIndex(index);
|
|
116
114
|
}
|
|
@@ -151,7 +149,6 @@ function compareKeys(a, b) {
|
|
|
151
149
|
return a > b ? 1 : a < b ? -1 : 0;
|
|
152
150
|
}
|
|
153
151
|
class Query {
|
|
154
|
-
source;
|
|
155
152
|
constructor(source) {
|
|
156
153
|
this.source = Array.isArray(source) ? source : Array.from(source);
|
|
157
154
|
}
|
|
@@ -301,27 +298,7 @@ class ContentBody extends Component {
|
|
|
301
298
|
}
|
|
302
299
|
}
|
|
303
300
|
|
|
304
|
-
const SLOT_REGISTERED_EVENT = Symbol('slotRegistered');
|
|
305
|
-
const SLOT_UNREGISTERED_EVENT = Symbol('slotUnregistered');
|
|
306
|
-
class TransportRegistry {
|
|
307
|
-
static slots = new Map();
|
|
308
|
-
static registerSlot(name, slot) {
|
|
309
|
-
this.slots.set(name, slot);
|
|
310
|
-
Application.main.fire(SLOT_REGISTERED_EVENT, { name, slot });
|
|
311
|
-
}
|
|
312
|
-
static unregisterSlot(name, slot) {
|
|
313
|
-
if (this.slots.get(name) === slot) {
|
|
314
|
-
this.slots.delete(name);
|
|
315
|
-
Application.main.fire(SLOT_UNREGISTERED_EVENT, { name, slot });
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
static getSlot(name) {
|
|
319
|
-
return this.slots.get(name);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
301
|
class Transport extends Component {
|
|
324
|
-
mode;
|
|
325
302
|
constructor(props) {
|
|
326
303
|
super(props);
|
|
327
304
|
this.mode = props.mode || 'replace';
|
|
@@ -409,28 +386,34 @@ class Transporter {
|
|
|
409
386
|
}
|
|
410
387
|
|
|
411
388
|
class TransportTo extends Component {
|
|
412
|
-
_onAddRef;
|
|
413
|
-
_onRemoveRef;
|
|
414
|
-
_slotRegisteredListener;
|
|
415
|
-
_slotUnregisteredListener;
|
|
416
|
-
_transported = [];
|
|
417
|
-
_countedLive = false;
|
|
418
389
|
constructor(props) {
|
|
419
390
|
super('div', props);
|
|
391
|
+
this._transported = [];
|
|
392
|
+
this._countedLive = false;
|
|
393
|
+
this._handleSlotChange = (eventArgs) => {
|
|
394
|
+
if (eventArgs.name === this.props.name) {
|
|
395
|
+
const slot = eventArgs.slot;
|
|
396
|
+
if (slot.mode !== 'merge') {
|
|
397
|
+
slot.clearSlot?.();
|
|
398
|
+
}
|
|
399
|
+
const all = [...(this.childs || []), ...this.controls.items];
|
|
400
|
+
Transporter.transportMany(all, slot);
|
|
401
|
+
this._rememberTransported(all);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
this._clearChildrenFromSlot = (slot) => {
|
|
405
|
+
(this.childs || []).forEach(child => {
|
|
406
|
+
slot.controls.remove(child);
|
|
407
|
+
child.dispose();
|
|
408
|
+
});
|
|
409
|
+
(this.controls.items || []).forEach(child => {
|
|
410
|
+
slot.controls.remove(child);
|
|
411
|
+
child.dispose();
|
|
412
|
+
});
|
|
413
|
+
};
|
|
420
414
|
contentBlocks.live++;
|
|
421
415
|
this._countedLive = true;
|
|
422
416
|
}
|
|
423
|
-
_handleSlotChange = (eventArgs) => {
|
|
424
|
-
if (eventArgs.name === this.props.name) {
|
|
425
|
-
const slot = eventArgs.slot;
|
|
426
|
-
if (slot.mode !== 'merge') {
|
|
427
|
-
slot.clearSlot?.();
|
|
428
|
-
}
|
|
429
|
-
const all = [...(this.childs || []), ...this.controls.items];
|
|
430
|
-
Transporter.transportMany(all, slot);
|
|
431
|
-
this._rememberTransported(all);
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
417
|
_rememberTransported(children) {
|
|
435
418
|
const kept = this._transported.filter(c => !c.isDisposed);
|
|
436
419
|
for (const child of children) {
|
|
@@ -439,16 +422,6 @@ class TransportTo extends Component {
|
|
|
439
422
|
}
|
|
440
423
|
this._transported = kept;
|
|
441
424
|
}
|
|
442
|
-
_clearChildrenFromSlot = (slot) => {
|
|
443
|
-
(this.childs || []).forEach(child => {
|
|
444
|
-
slot.controls.remove(child);
|
|
445
|
-
child.dispose();
|
|
446
|
-
});
|
|
447
|
-
(this.controls.items || []).forEach(child => {
|
|
448
|
-
slot.controls.remove(child);
|
|
449
|
-
child.dispose();
|
|
450
|
-
});
|
|
451
|
-
};
|
|
452
425
|
initializeComponent(sender) {
|
|
453
426
|
let slot = TransportRegistry.getSlot(this.props.name);
|
|
454
427
|
if (slot) {
|
|
@@ -512,19 +485,35 @@ class TransportTo extends Component {
|
|
|
512
485
|
}
|
|
513
486
|
|
|
514
487
|
class Virtualization extends Component {
|
|
515
|
-
_state;
|
|
516
|
-
_virtualContent;
|
|
517
|
-
_topSpacer;
|
|
518
|
-
_bottomSpacer;
|
|
519
|
-
_cache = new Map();
|
|
520
|
-
_view = [];
|
|
521
|
-
_occurrence = [];
|
|
522
|
-
_occurrenceKeys = new WeakMap();
|
|
523
|
-
_isLoadingMore = false;
|
|
524
|
-
_emptyRendered = false;
|
|
525
|
-
_renderPending = false;
|
|
526
488
|
constructor(props) {
|
|
527
489
|
super('div', props);
|
|
490
|
+
this._cache = new Map();
|
|
491
|
+
this._view = [];
|
|
492
|
+
this._occurrence = [];
|
|
493
|
+
this._occurrenceKeys = new WeakMap();
|
|
494
|
+
this._isLoadingMore = false;
|
|
495
|
+
this._emptyRendered = false;
|
|
496
|
+
this._renderPending = false;
|
|
497
|
+
this.contentWrapper = new Component();
|
|
498
|
+
this._initialLoadStarted = false;
|
|
499
|
+
this._offsets = null;
|
|
500
|
+
this._observedHeight = -1;
|
|
501
|
+
this._loadSeq = 0;
|
|
502
|
+
this._reloadScheduled = false;
|
|
503
|
+
this._reloadTimes = [];
|
|
504
|
+
this._handleScroll = (_sender, _event) => {
|
|
505
|
+
this.renderViewport();
|
|
506
|
+
if (this.props.autoLoad === false)
|
|
507
|
+
return;
|
|
508
|
+
if (!this._state.hasMore || this._isLoadingMore || !this._state.isInitialized)
|
|
509
|
+
return;
|
|
510
|
+
const el = this.wrapper.element;
|
|
511
|
+
const fixed = this._fixedHeight();
|
|
512
|
+
const loadedBottom = fixed !== null ? this._state.data.length * fixed : this._offsetOf(this._view.length);
|
|
513
|
+
const distanceToLoaded = loadedBottom - (el.scrollTop + el.clientHeight);
|
|
514
|
+
if (distanceToLoaded < (this.props.autoLoadThreshold ?? 100))
|
|
515
|
+
void this._loadMore();
|
|
516
|
+
};
|
|
528
517
|
if (props.className)
|
|
529
518
|
this.class.add(props.className);
|
|
530
519
|
if (props.style)
|
|
@@ -546,8 +535,6 @@ class Virtualization extends Component {
|
|
|
546
535
|
this.renderViewport = this.renderViewport.bind(this);
|
|
547
536
|
this._makeView();
|
|
548
537
|
}
|
|
549
|
-
contentWrapper = new Component();
|
|
550
|
-
wrapper;
|
|
551
538
|
_makeView() {
|
|
552
539
|
this._topSpacer = new Component('div');
|
|
553
540
|
this._topSpacer.element.style.cssText = 'height: 0px;';
|
|
@@ -576,7 +563,6 @@ class Virtualization extends Component {
|
|
|
576
563
|
this.motif.on('scroll', this._handleScroll);
|
|
577
564
|
}
|
|
578
565
|
}
|
|
579
|
-
_initialLoadStarted = false;
|
|
580
566
|
onBuilding() {
|
|
581
567
|
if (this.props.mainTemplate || this._initialLoadStarted)
|
|
582
568
|
return;
|
|
@@ -593,10 +579,6 @@ class Virtualization extends Component {
|
|
|
593
579
|
this._stopDataWatch();
|
|
594
580
|
this._clearContent();
|
|
595
581
|
}
|
|
596
|
-
_offsets = null;
|
|
597
|
-
_resizeObserver;
|
|
598
|
-
_observed;
|
|
599
|
-
_observedHeight = -1;
|
|
600
582
|
_fixedHeight() {
|
|
601
583
|
const h = this.props.itemHeight;
|
|
602
584
|
return typeof h === 'function' ? null : h;
|
|
@@ -678,10 +660,6 @@ class Virtualization extends Component {
|
|
|
678
660
|
this._resizeObserver = undefined;
|
|
679
661
|
this._observed = undefined;
|
|
680
662
|
}
|
|
681
|
-
_loadSeq = 0;
|
|
682
|
-
_dataWatchStop;
|
|
683
|
-
_reloadScheduled = false;
|
|
684
|
-
_reloadTimes = [];
|
|
685
663
|
_stopDataWatch() {
|
|
686
664
|
this._dataWatchStop?.();
|
|
687
665
|
this._dataWatchStop = undefined;
|
|
@@ -780,19 +758,6 @@ class Virtualization extends Component {
|
|
|
780
758
|
this._renderErrorState(error);
|
|
781
759
|
}
|
|
782
760
|
}
|
|
783
|
-
_handleScroll = (_sender, _event) => {
|
|
784
|
-
this.renderViewport();
|
|
785
|
-
if (this.props.autoLoad === false)
|
|
786
|
-
return;
|
|
787
|
-
if (!this._state.hasMore || this._isLoadingMore || !this._state.isInitialized)
|
|
788
|
-
return;
|
|
789
|
-
const el = this.wrapper.element;
|
|
790
|
-
const fixed = this._fixedHeight();
|
|
791
|
-
const loadedBottom = fixed !== null ? this._state.data.length * fixed : this._offsetOf(this._view.length);
|
|
792
|
-
const distanceToLoaded = loadedBottom - (el.scrollTop + el.clientHeight);
|
|
793
|
-
if (distanceToLoaded < (this.props.autoLoadThreshold ?? 100))
|
|
794
|
-
void this._loadMore();
|
|
795
|
-
};
|
|
796
761
|
async _loadInitial() {
|
|
797
762
|
const seq = ++this._loadSeq;
|
|
798
763
|
this._state.isLoading = true;
|
|
@@ -1181,12 +1146,6 @@ function addJitter(base, jitterFactor = 0.1) {
|
|
|
1181
1146
|
class Policy {
|
|
1182
1147
|
}
|
|
1183
1148
|
class RetryPolicy extends Policy {
|
|
1184
|
-
retries;
|
|
1185
|
-
backoff;
|
|
1186
|
-
delayMs;
|
|
1187
|
-
jitter;
|
|
1188
|
-
shouldHandle;
|
|
1189
|
-
onRetry;
|
|
1190
1149
|
constructor(options = {}) {
|
|
1191
1150
|
super();
|
|
1192
1151
|
this.retries = options.retries ?? 3;
|
|
@@ -1225,7 +1184,6 @@ class RetryPolicy extends Policy {
|
|
|
1225
1184
|
}
|
|
1226
1185
|
}
|
|
1227
1186
|
class TimeoutPolicy extends Policy {
|
|
1228
|
-
timeoutMs;
|
|
1229
1187
|
constructor(opts) {
|
|
1230
1188
|
super();
|
|
1231
1189
|
this.timeoutMs = opts.timeoutMs;
|
|
@@ -1245,17 +1203,12 @@ class TimeoutPolicy extends Policy {
|
|
|
1245
1203
|
}
|
|
1246
1204
|
}
|
|
1247
1205
|
class CircuitBreakerPolicy extends Policy {
|
|
1248
|
-
failureThreshold;
|
|
1249
|
-
successThreshold;
|
|
1250
|
-
durationOfBreakMs;
|
|
1251
|
-
shouldHandle;
|
|
1252
|
-
onStateChange;
|
|
1253
|
-
state = 'CLOSED';
|
|
1254
|
-
failureCount = 0;
|
|
1255
|
-
successCount = 0;
|
|
1256
|
-
nextAttemptTime = 0;
|
|
1257
1206
|
constructor(opts = {}) {
|
|
1258
1207
|
super();
|
|
1208
|
+
this.state = 'CLOSED';
|
|
1209
|
+
this.failureCount = 0;
|
|
1210
|
+
this.successCount = 0;
|
|
1211
|
+
this.nextAttemptTime = 0;
|
|
1259
1212
|
this.failureThreshold = opts.failureThreshold ?? 5;
|
|
1260
1213
|
this.successThreshold = opts.successThreshold ?? 2;
|
|
1261
1214
|
this.durationOfBreakMs = opts.durationOfBreakMs ?? 60000;
|
|
@@ -1308,12 +1261,10 @@ class CircuitBreakerPolicy extends Policy {
|
|
|
1308
1261
|
}
|
|
1309
1262
|
}
|
|
1310
1263
|
class BulkheadPolicy extends Policy {
|
|
1311
|
-
maxConcurrent;
|
|
1312
|
-
maxQueue;
|
|
1313
|
-
active = 0;
|
|
1314
|
-
queue = [];
|
|
1315
1264
|
constructor(opts = {}) {
|
|
1316
1265
|
super();
|
|
1266
|
+
this.active = 0;
|
|
1267
|
+
this.queue = [];
|
|
1317
1268
|
this.maxConcurrent = opts.maxConcurrent ?? 10;
|
|
1318
1269
|
this.maxQueue = opts.maxQueue ?? 50;
|
|
1319
1270
|
}
|
|
@@ -1346,11 +1297,6 @@ class BulkheadPolicy extends Policy {
|
|
|
1346
1297
|
}
|
|
1347
1298
|
}
|
|
1348
1299
|
class RateLimiterPolicy extends Policy {
|
|
1349
|
-
tokensPerInterval;
|
|
1350
|
-
intervalMs;
|
|
1351
|
-
capacity;
|
|
1352
|
-
tokens;
|
|
1353
|
-
lastRefill;
|
|
1354
1300
|
constructor(opts = {}) {
|
|
1355
1301
|
super();
|
|
1356
1302
|
this.tokensPerInterval = opts.tokensPerInterval ?? 1;
|
|
@@ -1380,8 +1326,6 @@ class RateLimiterPolicy extends Policy {
|
|
|
1380
1326
|
}
|
|
1381
1327
|
}
|
|
1382
1328
|
class FallbackPolicy extends Policy {
|
|
1383
|
-
fallback;
|
|
1384
|
-
shouldHandle;
|
|
1385
1329
|
constructor(opts) {
|
|
1386
1330
|
super();
|
|
1387
1331
|
this.fallback = opts.fallback;
|
|
@@ -1399,7 +1343,6 @@ class FallbackPolicy extends Policy {
|
|
|
1399
1343
|
}
|
|
1400
1344
|
}
|
|
1401
1345
|
class PolicyWrap extends Policy {
|
|
1402
|
-
policies;
|
|
1403
1346
|
constructor(...policies) {
|
|
1404
1347
|
super();
|
|
1405
1348
|
this.policies = policies;
|
|
@@ -1424,34 +1367,36 @@ function decorate(policy, fn) {
|
|
|
1424
1367
|
return (ctx) => policy.execute(fn, ctx);
|
|
1425
1368
|
}
|
|
1426
1369
|
class Resilience {
|
|
1370
|
+
constructor() {
|
|
1371
|
+
this.resiliences = [];
|
|
1372
|
+
this.retry = (opts) => {
|
|
1373
|
+
this.resiliences.push(resilience.retry(opts));
|
|
1374
|
+
return this;
|
|
1375
|
+
};
|
|
1376
|
+
this.timeout = (opts) => {
|
|
1377
|
+
this.resiliences.push(resilience.timeout(opts));
|
|
1378
|
+
return this;
|
|
1379
|
+
};
|
|
1380
|
+
this.circuitBreaker = (opts) => {
|
|
1381
|
+
this.resiliences.push(resilience.circuitBreaker(opts));
|
|
1382
|
+
return this;
|
|
1383
|
+
};
|
|
1384
|
+
this.bulkhead = (opts) => {
|
|
1385
|
+
this.resiliences.push(resilience.bulkhead(opts));
|
|
1386
|
+
return this;
|
|
1387
|
+
};
|
|
1388
|
+
this.rateLimiter = (opts) => {
|
|
1389
|
+
this.resiliences.push(resilience.rateLimiter(opts));
|
|
1390
|
+
return this;
|
|
1391
|
+
};
|
|
1392
|
+
this.fallback = (opts) => {
|
|
1393
|
+
this.resiliences.push(resilience.fallback(opts));
|
|
1394
|
+
return this;
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1427
1397
|
static get create() {
|
|
1428
1398
|
return new Resilience();
|
|
1429
1399
|
}
|
|
1430
|
-
resiliences = [];
|
|
1431
|
-
retry = (opts) => {
|
|
1432
|
-
this.resiliences.push(resilience.retry(opts));
|
|
1433
|
-
return this;
|
|
1434
|
-
};
|
|
1435
|
-
timeout = (opts) => {
|
|
1436
|
-
this.resiliences.push(resilience.timeout(opts));
|
|
1437
|
-
return this;
|
|
1438
|
-
};
|
|
1439
|
-
circuitBreaker = (opts) => {
|
|
1440
|
-
this.resiliences.push(resilience.circuitBreaker(opts));
|
|
1441
|
-
return this;
|
|
1442
|
-
};
|
|
1443
|
-
bulkhead = (opts) => {
|
|
1444
|
-
this.resiliences.push(resilience.bulkhead(opts));
|
|
1445
|
-
return this;
|
|
1446
|
-
};
|
|
1447
|
-
rateLimiter = (opts) => {
|
|
1448
|
-
this.resiliences.push(resilience.rateLimiter(opts));
|
|
1449
|
-
return this;
|
|
1450
|
-
};
|
|
1451
|
-
fallback = (opts) => {
|
|
1452
|
-
this.resiliences.push(resilience.fallback(opts));
|
|
1453
|
-
return this;
|
|
1454
|
-
};
|
|
1455
1400
|
async execute(action, ctx) {
|
|
1456
1401
|
return resilience.wrap(...this.resiliences).execute(action, ctx);
|
|
1457
1402
|
}
|