native-document 1.0.68 → 1.0.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/native-document.dev.js +478 -59
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.devtools.min.js +1 -1
- package/dist/native-document.min.js +1 -1
- package/package.json +1 -1
- package/src/data/ObservableArray.js +67 -1
- package/src/data/ObservableItem.js +3 -1
- package/src/data/observable-helpers/array.js +1 -1
- package/src/utils/filters/date.js +95 -0
- package/src/utils/filters/index.js +4 -0
- package/src/utils/filters/standard.js +137 -0
- package/src/utils/filters/strings.js +35 -0
- package/src/utils/filters/utils.js +41 -0
- package/types/observable.d.ts +1 -1
- package/utils.js +3 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var NativeDocument = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
let DebugManager
|
|
4
|
+
let DebugManager = {};
|
|
5
5
|
|
|
6
6
|
{
|
|
7
|
-
DebugManager
|
|
7
|
+
DebugManager = {
|
|
8
8
|
enabled: false,
|
|
9
9
|
|
|
10
10
|
enable() {
|
|
@@ -35,7 +35,7 @@ var NativeDocument = (function (exports) {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
}
|
|
38
|
-
var DebugManager = DebugManager
|
|
38
|
+
var DebugManager$1 = DebugManager;
|
|
39
39
|
|
|
40
40
|
const MemoryManager = (function() {
|
|
41
41
|
|
|
@@ -84,7 +84,7 @@ var NativeDocument = (function (exports) {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
if (cleanedCount > 0) {
|
|
87
|
-
DebugManager.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
87
|
+
DebugManager$1.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
};
|
|
@@ -207,7 +207,7 @@ var NativeDocument = (function (exports) {
|
|
|
207
207
|
try{
|
|
208
208
|
callback.call(plugin, ...data);
|
|
209
209
|
} catch (error) {
|
|
210
|
-
DebugManager.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
210
|
+
DebugManager$1.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
}
|
|
@@ -343,6 +343,7 @@ var NativeDocument = (function (exports) {
|
|
|
343
343
|
|
|
344
344
|
operations = operations || DEFAULT_OPERATIONS;
|
|
345
345
|
for(let i = 0, length = $listeners.length; i < length; i++) {
|
|
346
|
+
$listeners[i];
|
|
346
347
|
$listeners[i]($currentValue, $previousValue, operations);
|
|
347
348
|
}
|
|
348
349
|
};
|
|
@@ -360,6 +361,7 @@ var NativeDocument = (function (exports) {
|
|
|
360
361
|
callback.set ? callback.set(value) : callback(value);
|
|
361
362
|
});
|
|
362
363
|
};
|
|
364
|
+
|
|
363
365
|
ObservableItem.prototype.triggerWatchers = function() {
|
|
364
366
|
if(!this.$watchers) {
|
|
365
367
|
return;
|
|
@@ -459,7 +461,7 @@ var NativeDocument = (function (exports) {
|
|
|
459
461
|
ObservableItem.prototype.subscribe = function(callback, target = null) {
|
|
460
462
|
this.$listeners = this.$listeners ?? [];
|
|
461
463
|
if (this.$isCleanedUp) {
|
|
462
|
-
DebugManager.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
464
|
+
DebugManager$1.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
463
465
|
return () => {};
|
|
464
466
|
}
|
|
465
467
|
if (typeof callback !== 'function') {
|
|
@@ -1000,7 +1002,7 @@ var NativeDocument = (function (exports) {
|
|
|
1000
1002
|
}
|
|
1001
1003
|
{
|
|
1002
1004
|
if (this[name] && !this.$localExtensions.has(name)) {
|
|
1003
|
-
DebugManager.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
|
|
1005
|
+
DebugManager$1.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
|
|
1004
1006
|
}
|
|
1005
1007
|
this.$localExtensions.set(name, method);
|
|
1006
1008
|
}
|
|
@@ -1034,17 +1036,17 @@ var NativeDocument = (function (exports) {
|
|
|
1034
1036
|
const method = methods[name];
|
|
1035
1037
|
|
|
1036
1038
|
if (typeof method !== 'function') {
|
|
1037
|
-
DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
1039
|
+
DebugManager$1.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
1038
1040
|
continue;
|
|
1039
1041
|
}
|
|
1040
1042
|
|
|
1041
1043
|
if (protectedMethods.has(name)) {
|
|
1042
|
-
DebugManager.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
1044
|
+
DebugManager$1.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
1043
1045
|
throw new NativeDocumentError(`Cannot override protected method "${name}"`);
|
|
1044
1046
|
}
|
|
1045
1047
|
|
|
1046
1048
|
if (NDElement.prototype[name]) {
|
|
1047
|
-
DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
1049
|
+
DebugManager$1.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
1048
1050
|
}
|
|
1049
1051
|
|
|
1050
1052
|
NDElement.prototype[name] = method;
|
|
@@ -1190,7 +1192,7 @@ var NativeDocument = (function (exports) {
|
|
|
1190
1192
|
const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
|
|
1191
1193
|
|
|
1192
1194
|
if (foundReserved.length > 0) {
|
|
1193
|
-
DebugManager.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
1195
|
+
DebugManager$1.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
1194
1196
|
}
|
|
1195
1197
|
|
|
1196
1198
|
return attributes;
|
|
@@ -1238,7 +1240,7 @@ var NativeDocument = (function (exports) {
|
|
|
1238
1240
|
element.appendChild = function(child, before = null) {
|
|
1239
1241
|
const parent = anchorEnd.parentNode;
|
|
1240
1242
|
if(!parent) {
|
|
1241
|
-
DebugManager.error('Anchor', 'Anchor : parent not found', child);
|
|
1243
|
+
DebugManager$1.error('Anchor', 'Anchor : parent not found', child);
|
|
1242
1244
|
return;
|
|
1243
1245
|
}
|
|
1244
1246
|
before = before ?? anchorEnd;
|
|
@@ -1356,18 +1358,18 @@ var NativeDocument = (function (exports) {
|
|
|
1356
1358
|
* @returns {ObservableItem}
|
|
1357
1359
|
* @constructor
|
|
1358
1360
|
*/
|
|
1359
|
-
function Observable(value, configs = null) {
|
|
1361
|
+
function Observable$1(value, configs = null) {
|
|
1360
1362
|
return new ObservableItem(value, configs);
|
|
1361
1363
|
}
|
|
1362
1364
|
|
|
1363
|
-
const $ = Observable;
|
|
1364
|
-
const obs = Observable;
|
|
1365
|
+
const $ = Observable$1;
|
|
1366
|
+
const obs = Observable$1;
|
|
1365
1367
|
|
|
1366
1368
|
/**
|
|
1367
1369
|
*
|
|
1368
1370
|
* @param {string} propertyName
|
|
1369
1371
|
*/
|
|
1370
|
-
Observable.useValueProperty = function(propertyName = 'value') {
|
|
1372
|
+
Observable$1.useValueProperty = function(propertyName = 'value') {
|
|
1371
1373
|
Object.defineProperty(ObservableItem.prototype, propertyName, {
|
|
1372
1374
|
get() {
|
|
1373
1375
|
return this.$currentValue;
|
|
@@ -1385,7 +1387,7 @@ var NativeDocument = (function (exports) {
|
|
|
1385
1387
|
* @param id
|
|
1386
1388
|
* @returns {ObservableItem|null}
|
|
1387
1389
|
*/
|
|
1388
|
-
Observable.getById = function(id) {
|
|
1390
|
+
Observable$1.getById = function(id) {
|
|
1389
1391
|
const item = MemoryManager.getObservableById(parseInt(id));
|
|
1390
1392
|
if(!item) {
|
|
1391
1393
|
throw new NativeDocumentError('Observable.getById : No observable found with id ' + id);
|
|
@@ -1397,7 +1399,7 @@ var NativeDocument = (function (exports) {
|
|
|
1397
1399
|
*
|
|
1398
1400
|
* @param {ObservableItem} observable
|
|
1399
1401
|
*/
|
|
1400
|
-
Observable.cleanup = function(observable) {
|
|
1402
|
+
Observable$1.cleanup = function(observable) {
|
|
1401
1403
|
observable.cleanup();
|
|
1402
1404
|
};
|
|
1403
1405
|
|
|
@@ -1406,7 +1408,7 @@ var NativeDocument = (function (exports) {
|
|
|
1406
1408
|
* @param {Boolean} enable
|
|
1407
1409
|
* @param {{interval:Boolean, threshold:number}} options
|
|
1408
1410
|
*/
|
|
1409
|
-
Observable.autoCleanup = function(enable = false, options = {}) {
|
|
1411
|
+
Observable$1.autoCleanup = function(enable = false, options = {}) {
|
|
1410
1412
|
if(!enable) {
|
|
1411
1413
|
return;
|
|
1412
1414
|
}
|
|
@@ -1554,7 +1556,7 @@ var NativeDocument = (function (exports) {
|
|
|
1554
1556
|
continue;
|
|
1555
1557
|
}
|
|
1556
1558
|
const observables = value.filter(item => Validator.isObservable(item));
|
|
1557
|
-
value = Observable.computed(() => {
|
|
1559
|
+
value = Observable$1.computed(() => {
|
|
1558
1560
|
return value.map(item => Validator.isObservable(item) ? item.val() : item).join(' ') || ' ';
|
|
1559
1561
|
}, observables);
|
|
1560
1562
|
}
|
|
@@ -2203,7 +2205,7 @@ var NativeDocument = (function (exports) {
|
|
|
2203
2205
|
String.prototype.use = function(args) {
|
|
2204
2206
|
const value = this;
|
|
2205
2207
|
|
|
2206
|
-
return Observable.computed(() => {
|
|
2208
|
+
return Observable$1.computed(() => {
|
|
2207
2209
|
return value.replace(/\$\{(.*?)}/g, (match, key) => {
|
|
2208
2210
|
const data = args[key];
|
|
2209
2211
|
if(Validator.isObservable(data)) {
|
|
@@ -2223,7 +2225,7 @@ var NativeDocument = (function (exports) {
|
|
|
2223
2225
|
return value;
|
|
2224
2226
|
}
|
|
2225
2227
|
const [_, id] = value.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);
|
|
2226
|
-
return Observable.getById(id);
|
|
2228
|
+
return Observable$1.getById(id);
|
|
2227
2229
|
});
|
|
2228
2230
|
};
|
|
2229
2231
|
|
|
@@ -2321,6 +2323,355 @@ var NativeDocument = (function (exports) {
|
|
|
2321
2323
|
});
|
|
2322
2324
|
};
|
|
2323
2325
|
|
|
2326
|
+
function toDate(value) {
|
|
2327
|
+
if (value instanceof Date) return value;
|
|
2328
|
+
return new Date(value);
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
function isSameDay(date1, date2) {
|
|
2332
|
+
const d1 = toDate(date1);
|
|
2333
|
+
const d2 = toDate(date2);
|
|
2334
|
+
return d1.getFullYear() === d2.getFullYear() &&
|
|
2335
|
+
d1.getMonth() === d2.getMonth() &&
|
|
2336
|
+
d1.getDate() === d2.getDate();
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
function getSecondsOfDay(date) {
|
|
2340
|
+
const d = toDate(date);
|
|
2341
|
+
return (d.getHours() * 3600) + (d.getMinutes() * 60) + d.getSeconds();
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
function createFilter(observableOrValue, callbackFn){
|
|
2345
|
+
const isObservable = Validator.isObservable(observableOrValue);
|
|
2346
|
+
|
|
2347
|
+
return {
|
|
2348
|
+
dependencies: isObservable ? observableOrValue : null,
|
|
2349
|
+
callback: (value) => callbackFn(value, isObservable ? observableOrValue.val() : observableOrValue)
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
function createMultiSourceFilter(sources, callbackFn){
|
|
2354
|
+
const observables = sources.filter(Validator.isObservable);
|
|
2355
|
+
|
|
2356
|
+
const getValues = () => sources.map(src =>
|
|
2357
|
+
Validator.isObservable(src) ? src.val() : src
|
|
2358
|
+
);
|
|
2359
|
+
|
|
2360
|
+
return {
|
|
2361
|
+
dependencies: observables.length > 0 ? observables : null,
|
|
2362
|
+
callback: (value) => callbackFn(value, getValues())
|
|
2363
|
+
};
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
function equals(observableOrValue){
|
|
2367
|
+
return createFilter(observableOrValue, (value, target) => value === target);
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
function notEquals(observableOrValue){
|
|
2371
|
+
return createFilter(observableOrValue, (value, target) => value !== target);
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
function greaterThan(observableOrValue){
|
|
2375
|
+
return createFilter(observableOrValue, (value, target) => value > target);
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
function greaterThanOrEqual(observableOrValue){
|
|
2379
|
+
return createFilter(observableOrValue, (value, target) => value >= target);
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
function lessThan(observableOrValue){
|
|
2383
|
+
return createFilter(observableOrValue, (value, target) => value < target);
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
function lessThanOrEqual(observableOrValue){
|
|
2387
|
+
return createFilter(observableOrValue, (value, target) => value <= target);
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
function between(minObservableOrValue, maxObservableOrValue){
|
|
2391
|
+
return createMultiSourceFilter(
|
|
2392
|
+
[minObservableOrValue, maxObservableOrValue],
|
|
2393
|
+
(value, [min, max]) => value >= min && value <= max
|
|
2394
|
+
);
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
function In(observableOrArray){
|
|
2398
|
+
return createFilter(observableOrArray, (value, arr) => arr.includes(value));
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
function notIn(observableOrArray){
|
|
2402
|
+
return createFilter(observableOrArray, (value, arr) => !arr.includes(value));
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
function isEmpty(observableOrValue = true){
|
|
2406
|
+
return createFilter(observableOrValue, (value, shouldBeEmpty) => {
|
|
2407
|
+
const isActuallyEmpty = !value || value === '' ||
|
|
2408
|
+
(Array.isArray(value) && value.length === 0);
|
|
2409
|
+
|
|
2410
|
+
return shouldBeEmpty ? isActuallyEmpty : !isActuallyEmpty;
|
|
2411
|
+
});
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
function isNotEmpty(observableOrValue = true){
|
|
2415
|
+
return createFilter(observableOrValue, (value, shouldBeNotEmpty) => {
|
|
2416
|
+
const isActuallyNotEmpty = !!value && value !== '' &&
|
|
2417
|
+
(!Array.isArray(value) || value.length > 0);
|
|
2418
|
+
|
|
2419
|
+
return shouldBeNotEmpty ? isActuallyNotEmpty : !isActuallyNotEmpty;
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
function match(patternObservableOrValue, asRegexObservableOrValue = true, flagsObservableOrValue = ''){
|
|
2424
|
+
return createMultiSourceFilter(
|
|
2425
|
+
[patternObservableOrValue, asRegexObservableOrValue, flagsObservableOrValue],
|
|
2426
|
+
(value, [pattern, asRegex, flags]) => {
|
|
2427
|
+
if (!pattern) return true;
|
|
2428
|
+
|
|
2429
|
+
if (asRegex){
|
|
2430
|
+
try {
|
|
2431
|
+
const regex = new RegExp(pattern, flags);
|
|
2432
|
+
return regex.test(String(value));
|
|
2433
|
+
} catch (error){
|
|
2434
|
+
console.warn('Invalid regex pattern:', pattern, error);
|
|
2435
|
+
return false;
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
if (!flags || flags === ''){
|
|
2440
|
+
return String(value).toLowerCase().includes(String(pattern).toLowerCase());
|
|
2441
|
+
}
|
|
2442
|
+
return String(value).includes(String(pattern));
|
|
2443
|
+
}
|
|
2444
|
+
);
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
function and(...filters){
|
|
2448
|
+
const dependencies = filters
|
|
2449
|
+
.flatMap(f => f.dependencies ? (Array.isArray(f.dependencies) ? f.dependencies : [f.dependencies]) : [])
|
|
2450
|
+
.filter(Validator.isObservable);
|
|
2451
|
+
|
|
2452
|
+
return {
|
|
2453
|
+
dependencies: dependencies.length > 0 ? dependencies : null,
|
|
2454
|
+
callback: (value) => filters.every(f => f.callback(value))
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
function or(...filters){
|
|
2459
|
+
const dependencies = filters
|
|
2460
|
+
.flatMap(f => f.dependencies ? (Array.isArray(f.dependencies) ? f.dependencies : [f.dependencies]) : [])
|
|
2461
|
+
.filter(Validator.isObservable);
|
|
2462
|
+
|
|
2463
|
+
return {
|
|
2464
|
+
dependencies: dependencies.length > 0 ? dependencies : null,
|
|
2465
|
+
callback: (value) => filters.some(f => f.callback(value))
|
|
2466
|
+
};
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
function not(filter){
|
|
2470
|
+
return {
|
|
2471
|
+
dependencies: filter.dependencies,
|
|
2472
|
+
callback: (value) => !filter.callback(value)
|
|
2473
|
+
};
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
function custom(callbackFn, ...observables){
|
|
2477
|
+
const dependencies = observables.filter(Validator.isObservable);
|
|
2478
|
+
|
|
2479
|
+
return {
|
|
2480
|
+
dependencies: dependencies.length > 0 ? dependencies : null,
|
|
2481
|
+
callback: (value) => {
|
|
2482
|
+
const values = observables.map(o =>
|
|
2483
|
+
Validator.isObservable(o) ? o.val() : o
|
|
2484
|
+
);
|
|
2485
|
+
return callbackFn(value, ...values);
|
|
2486
|
+
}
|
|
2487
|
+
};
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
const gt = greaterThan;
|
|
2491
|
+
const gte = greaterThanOrEqual;
|
|
2492
|
+
const lt = lessThan;
|
|
2493
|
+
const lte = lessThanOrEqual;
|
|
2494
|
+
const eq = equals;
|
|
2495
|
+
const neq = notEquals;
|
|
2496
|
+
const all = and;
|
|
2497
|
+
const any = or;
|
|
2498
|
+
|
|
2499
|
+
const dateEquals = (observableOrValue) => {
|
|
2500
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2501
|
+
if (!value || !target) return false;
|
|
2502
|
+
return isSameDay(value, target);
|
|
2503
|
+
});
|
|
2504
|
+
};
|
|
2505
|
+
|
|
2506
|
+
const dateBefore = (observableOrValue) => {
|
|
2507
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2508
|
+
if (!value || !target) return false;
|
|
2509
|
+
return toDate(value) < toDate(target);
|
|
2510
|
+
});
|
|
2511
|
+
};
|
|
2512
|
+
|
|
2513
|
+
const dateAfter = (observableOrValue) => {
|
|
2514
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2515
|
+
if (!value || !target) return false;
|
|
2516
|
+
return toDate(value) > toDate(target);
|
|
2517
|
+
});
|
|
2518
|
+
};
|
|
2519
|
+
|
|
2520
|
+
const dateBetween = (startObservableOrValue, endObservableOrValue) => {
|
|
2521
|
+
return createMultiSourceFilter(
|
|
2522
|
+
[startObservableOrValue, endObservableOrValue],
|
|
2523
|
+
(value, [start, end]) => {
|
|
2524
|
+
if (!value || !start || !end) return false;
|
|
2525
|
+
const date = toDate(value);
|
|
2526
|
+
return date >= toDate(start) && date <= toDate(end);
|
|
2527
|
+
}
|
|
2528
|
+
);
|
|
2529
|
+
};
|
|
2530
|
+
|
|
2531
|
+
const timeEquals = (observableOrValue) => {
|
|
2532
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2533
|
+
if (!value || !target) return false;
|
|
2534
|
+
const d1 = toDate(value);
|
|
2535
|
+
const d2 = toDate(target);
|
|
2536
|
+
return d1.getHours() === d2.getHours() &&
|
|
2537
|
+
d1.getMinutes() === d2.getMinutes() &&
|
|
2538
|
+
d1.getSeconds() === d2.getSeconds();
|
|
2539
|
+
});
|
|
2540
|
+
};
|
|
2541
|
+
|
|
2542
|
+
const timeAfter = (observableOrValue) => {
|
|
2543
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2544
|
+
return getSecondsOfDay(value) > getSecondsOfDay(target);
|
|
2545
|
+
});
|
|
2546
|
+
};
|
|
2547
|
+
|
|
2548
|
+
const timeBefore = (observableOrValue) => {
|
|
2549
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2550
|
+
return getSecondsOfDay(value) < getSecondsOfDay(target);
|
|
2551
|
+
});
|
|
2552
|
+
};
|
|
2553
|
+
|
|
2554
|
+
const timeBetween = (startObservableOrValue, endObservableOrValue) => {
|
|
2555
|
+
return createMultiSourceFilter([startObservableOrValue, endObservableOrValue],
|
|
2556
|
+
(value, [start, end]) => {
|
|
2557
|
+
if (!value || !start || !end) return false;
|
|
2558
|
+
const date = getSecondsOfDay(value);
|
|
2559
|
+
return date >= getSecondsOfDay(start) && date <= getSecondsOfDay(end);
|
|
2560
|
+
}
|
|
2561
|
+
);
|
|
2562
|
+
};
|
|
2563
|
+
|
|
2564
|
+
const dateTimeEquals = (observableOrValue) => {
|
|
2565
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2566
|
+
if (!value || !target) return false;
|
|
2567
|
+
return toDate(value).getTime() === toDate(target).getTime();
|
|
2568
|
+
});
|
|
2569
|
+
};
|
|
2570
|
+
|
|
2571
|
+
const dateTimeAfter = (observableOrValue) => {
|
|
2572
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2573
|
+
if (!value || !target) return false;
|
|
2574
|
+
return toDate(value) > toDate(target);
|
|
2575
|
+
});
|
|
2576
|
+
};
|
|
2577
|
+
|
|
2578
|
+
const dateTimeBefore = (observableOrValue) => {
|
|
2579
|
+
return createFilter(observableOrValue, (value, target) => {
|
|
2580
|
+
if (!value || !target) return false;
|
|
2581
|
+
return toDate(value) < toDate(target);
|
|
2582
|
+
});
|
|
2583
|
+
};
|
|
2584
|
+
|
|
2585
|
+
const dateTimeBetween = (startObservableOrValue, endObservableOrValue) => {
|
|
2586
|
+
return createMultiSourceFilter([startObservableOrValue, endObservableOrValue], (value, [start, end]) => {
|
|
2587
|
+
if (!value || !start || !end) return false;
|
|
2588
|
+
const date = toDate(value);
|
|
2589
|
+
return date >= toDate(start) && date <= toDate(end);
|
|
2590
|
+
});
|
|
2591
|
+
};
|
|
2592
|
+
|
|
2593
|
+
function includes(observableOrValue, caseSensitive = false){
|
|
2594
|
+
return createFilter(observableOrValue, (value, query) => {
|
|
2595
|
+
if (!value) return false;
|
|
2596
|
+
if (!query) return true;
|
|
2597
|
+
if (!caseSensitive){
|
|
2598
|
+
return String(value).toLowerCase().includes(String(query).toLowerCase());
|
|
2599
|
+
}
|
|
2600
|
+
return String(value).includes(String(query));
|
|
2601
|
+
});
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2604
|
+
const contains = includes;
|
|
2605
|
+
|
|
2606
|
+
function startsWith(observableOrValue, caseSensitive = false){
|
|
2607
|
+
return createFilter(observableOrValue, (value, query) => {
|
|
2608
|
+
if (!query) return true;
|
|
2609
|
+
if (!caseSensitive){
|
|
2610
|
+
return String(value).toLowerCase().startsWith(String(query).toLowerCase());
|
|
2611
|
+
}
|
|
2612
|
+
return String(value).startsWith(String(query));
|
|
2613
|
+
});
|
|
2614
|
+
}
|
|
2615
|
+
|
|
2616
|
+
function endsWith(observableOrValue, caseSensitive = false){
|
|
2617
|
+
return createFilter(observableOrValue, (value, query) => {
|
|
2618
|
+
if (!query) return true;
|
|
2619
|
+
if (!caseSensitive){
|
|
2620
|
+
return String(value).toLowerCase().endsWith(String(query).toLowerCase());
|
|
2621
|
+
}
|
|
2622
|
+
return String(value).endsWith(String(query));
|
|
2623
|
+
});
|
|
2624
|
+
}
|
|
2625
|
+
|
|
2626
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
2627
|
+
__proto__: null,
|
|
2628
|
+
In: In,
|
|
2629
|
+
all: all,
|
|
2630
|
+
and: and,
|
|
2631
|
+
any: any,
|
|
2632
|
+
between: between,
|
|
2633
|
+
contains: contains,
|
|
2634
|
+
createFilter: createFilter,
|
|
2635
|
+
createMultiSourceFilter: createMultiSourceFilter,
|
|
2636
|
+
custom: custom,
|
|
2637
|
+
dateAfter: dateAfter,
|
|
2638
|
+
dateBefore: dateBefore,
|
|
2639
|
+
dateBetween: dateBetween,
|
|
2640
|
+
dateEquals: dateEquals,
|
|
2641
|
+
dateTimeAfter: dateTimeAfter,
|
|
2642
|
+
dateTimeBefore: dateTimeBefore,
|
|
2643
|
+
dateTimeBetween: dateTimeBetween,
|
|
2644
|
+
dateTimeEquals: dateTimeEquals,
|
|
2645
|
+
endsWith: endsWith,
|
|
2646
|
+
eq: eq,
|
|
2647
|
+
equals: equals,
|
|
2648
|
+
getSecondsOfDay: getSecondsOfDay,
|
|
2649
|
+
greaterThan: greaterThan,
|
|
2650
|
+
greaterThanOrEqual: greaterThanOrEqual,
|
|
2651
|
+
gt: gt,
|
|
2652
|
+
gte: gte,
|
|
2653
|
+
includes: includes,
|
|
2654
|
+
isEmpty: isEmpty,
|
|
2655
|
+
isNotEmpty: isNotEmpty,
|
|
2656
|
+
isSameDay: isSameDay,
|
|
2657
|
+
lessThan: lessThan,
|
|
2658
|
+
lessThanOrEqual: lessThanOrEqual,
|
|
2659
|
+
lt: lt,
|
|
2660
|
+
lte: lte,
|
|
2661
|
+
match: match,
|
|
2662
|
+
neq: neq,
|
|
2663
|
+
not: not,
|
|
2664
|
+
notEquals: notEquals,
|
|
2665
|
+
notIn: notIn,
|
|
2666
|
+
or: or,
|
|
2667
|
+
startsWith: startsWith,
|
|
2668
|
+
timeAfter: timeAfter,
|
|
2669
|
+
timeBefore: timeBefore,
|
|
2670
|
+
timeBetween: timeBetween,
|
|
2671
|
+
timeEquals: timeEquals,
|
|
2672
|
+
toDate: toDate
|
|
2673
|
+
});
|
|
2674
|
+
|
|
2324
2675
|
const mutationMethods = ['push', 'pop', 'shift', 'unshift', 'reverse', 'sort', 'splice'];
|
|
2325
2676
|
const noMutationMethods = ['map', 'forEach', 'filter', 'reduce', 'some', 'every', 'find', 'findIndex', 'concat', 'includes', 'indexOf'];
|
|
2326
2677
|
|
|
@@ -2331,7 +2682,7 @@ var NativeDocument = (function (exports) {
|
|
|
2331
2682
|
* @param {{propagation: boolean, deep: boolean, reset: boolean}|null} configs
|
|
2332
2683
|
* @constructor
|
|
2333
2684
|
*/
|
|
2334
|
-
const ObservableArray = function (target, configs) {
|
|
2685
|
+
const ObservableArray = function (target, configs = null) {
|
|
2335
2686
|
if(!Array.isArray(target)) {
|
|
2336
2687
|
throw new NativeDocumentError('Observable.array : target must be an array');
|
|
2337
2688
|
}
|
|
@@ -2433,13 +2784,80 @@ var NativeDocument = (function (exports) {
|
|
|
2433
2784
|
this.trigger({ action: 'populate', args: [this.$currentValue, iteration, callback] });
|
|
2434
2785
|
};
|
|
2435
2786
|
|
|
2787
|
+
|
|
2788
|
+
ObservableArray.prototype.where = function(predicates) {
|
|
2789
|
+
const sourceArray = this;
|
|
2790
|
+
const observableDependencies = [sourceArray];
|
|
2791
|
+
const filterCallbacks = {};
|
|
2792
|
+
|
|
2793
|
+
for (const [key, rawPredicate] of Object.entries(predicates)) {
|
|
2794
|
+
const predicate = Validator.isObservable(rawPredicate) ? match(rawPredicate, false) : rawPredicate;
|
|
2795
|
+
if (predicate && typeof predicate === 'object' && 'callback' in predicate) {
|
|
2796
|
+
filterCallbacks[key] = predicate.callback;
|
|
2797
|
+
|
|
2798
|
+
if (predicate.dependencies) {
|
|
2799
|
+
const deps = Array.isArray(predicate.dependencies)
|
|
2800
|
+
? predicate.dependencies
|
|
2801
|
+
: [predicate.dependencies];
|
|
2802
|
+
observableDependencies.push(...deps);
|
|
2803
|
+
}
|
|
2804
|
+
} else if(typeof predicate === 'function') {
|
|
2805
|
+
filterCallbacks[key] = predicate;
|
|
2806
|
+
} else {
|
|
2807
|
+
filterCallbacks[key] = (value) => value === predicate;
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2811
|
+
const viewArray = Observable.array();
|
|
2812
|
+
|
|
2813
|
+
const filters = Object.entries(filterCallbacks);
|
|
2814
|
+
const updateView = () => {
|
|
2815
|
+
const filtered = sourceArray.val().filter(item => {
|
|
2816
|
+
for (const [key, callback] of filters) {
|
|
2817
|
+
if(key === '_') {
|
|
2818
|
+
if (!callback(item)) return false;
|
|
2819
|
+
} else {
|
|
2820
|
+
if (!callback(item[key])) return false;
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
return true;
|
|
2824
|
+
});
|
|
2825
|
+
|
|
2826
|
+
viewArray.set(filtered);
|
|
2827
|
+
};
|
|
2828
|
+
|
|
2829
|
+
observableDependencies.forEach(dep => dep.subscribe(updateView));
|
|
2830
|
+
|
|
2831
|
+
updateView();
|
|
2832
|
+
|
|
2833
|
+
return viewArray;
|
|
2834
|
+
};
|
|
2835
|
+
|
|
2836
|
+
ObservableArray.prototype.whereSome = function(fields, filter) {
|
|
2837
|
+
return this.where({
|
|
2838
|
+
_: {
|
|
2839
|
+
dependencies: filter.dependencies,
|
|
2840
|
+
callback: (item) => fields.some(field => filter.callback(item[field]))
|
|
2841
|
+
}
|
|
2842
|
+
});
|
|
2843
|
+
};
|
|
2844
|
+
|
|
2845
|
+
ObservableArray.prototype.whereEvery = function(fields, filter) {
|
|
2846
|
+
return this.where({
|
|
2847
|
+
_: {
|
|
2848
|
+
dependencies: filter.dependencies,
|
|
2849
|
+
callback: (item) => fields.every(field => filter.callback(item[field]))
|
|
2850
|
+
}
|
|
2851
|
+
});
|
|
2852
|
+
};
|
|
2853
|
+
|
|
2436
2854
|
/**
|
|
2437
2855
|
*
|
|
2438
2856
|
* @param {Array} target
|
|
2439
2857
|
* @param {{propagation: boolean, deep: boolean, reset: boolean}|null} configs
|
|
2440
2858
|
* @returns {ObservableArray}
|
|
2441
2859
|
*/
|
|
2442
|
-
Observable.array = function(target, configs = null) {
|
|
2860
|
+
Observable$1.array = function(target = [], configs = null) {
|
|
2443
2861
|
return new ObservableArray(target, configs);
|
|
2444
2862
|
};
|
|
2445
2863
|
|
|
@@ -2448,8 +2866,8 @@ var NativeDocument = (function (exports) {
|
|
|
2448
2866
|
* @param {Function} callback
|
|
2449
2867
|
* @returns {Function}
|
|
2450
2868
|
*/
|
|
2451
|
-
Observable.batch = function(callback) {
|
|
2452
|
-
const $observer = Observable(0);
|
|
2869
|
+
Observable$1.batch = function(callback) {
|
|
2870
|
+
const $observer = Observable$1(0);
|
|
2453
2871
|
const batch = function() {
|
|
2454
2872
|
if(Validator.isAsyncFunction(callback)) {
|
|
2455
2873
|
return (callback(...arguments)).then(() => {
|
|
@@ -2507,7 +2925,7 @@ var NativeDocument = (function (exports) {
|
|
|
2507
2925
|
* @param {{propagation: boolean, deep: boolean, reset: boolean}|null} configs
|
|
2508
2926
|
* @returns {Proxy}
|
|
2509
2927
|
*/
|
|
2510
|
-
Observable.init = function(initialValue, configs = null) {
|
|
2928
|
+
Observable$1.init = function(initialValue, configs = null) {
|
|
2511
2929
|
const data = {};
|
|
2512
2930
|
for(const key in initialValue) {
|
|
2513
2931
|
const itemValue = initialValue[key];
|
|
@@ -2515,24 +2933,24 @@ var NativeDocument = (function (exports) {
|
|
|
2515
2933
|
if(configs?.deep !== false) {
|
|
2516
2934
|
const mappedItemValue = itemValue.map(item => {
|
|
2517
2935
|
if(Validator.isJson(item)) {
|
|
2518
|
-
return Observable.json(item, configs);
|
|
2936
|
+
return Observable$1.json(item, configs);
|
|
2519
2937
|
}
|
|
2520
2938
|
if(Validator.isArray(item)) {
|
|
2521
|
-
return Observable.array(item, configs);
|
|
2939
|
+
return Observable$1.array(item, configs);
|
|
2522
2940
|
}
|
|
2523
|
-
return Observable(item, configs);
|
|
2941
|
+
return Observable$1(item, configs);
|
|
2524
2942
|
});
|
|
2525
|
-
data[key] = Observable.array(mappedItemValue, configs);
|
|
2943
|
+
data[key] = Observable$1.array(mappedItemValue, configs);
|
|
2526
2944
|
continue;
|
|
2527
2945
|
}
|
|
2528
|
-
data[key] = Observable.array(itemValue, configs);
|
|
2946
|
+
data[key] = Observable$1.array(itemValue, configs);
|
|
2529
2947
|
continue;
|
|
2530
2948
|
}
|
|
2531
2949
|
if(Validator.isObservable(itemValue) || Validator.isProxy(itemValue)) {
|
|
2532
2950
|
data[key] = itemValue;
|
|
2533
2951
|
continue;
|
|
2534
2952
|
}
|
|
2535
|
-
data[key] = Observable(itemValue, configs);
|
|
2953
|
+
data[key] = Observable$1(itemValue, configs);
|
|
2536
2954
|
}
|
|
2537
2955
|
|
|
2538
2956
|
const $reset = () => {
|
|
@@ -2544,10 +2962,10 @@ var NativeDocument = (function (exports) {
|
|
|
2544
2962
|
|
|
2545
2963
|
const $val = () => ObservableObjectValue(data);
|
|
2546
2964
|
|
|
2547
|
-
const $clone = () => Observable.init($val(), configs);
|
|
2965
|
+
const $clone = () => Observable$1.init($val(), configs);
|
|
2548
2966
|
|
|
2549
2967
|
const $updateWith = (values) => {
|
|
2550
|
-
Observable.update(proxy, values);
|
|
2968
|
+
Observable$1.update(proxy, values);
|
|
2551
2969
|
};
|
|
2552
2970
|
|
|
2553
2971
|
const $get = (key) => ObservableGet(data, key);
|
|
@@ -2585,8 +3003,8 @@ var NativeDocument = (function (exports) {
|
|
|
2585
3003
|
* @param {any[]} data
|
|
2586
3004
|
* @return Proxy[]
|
|
2587
3005
|
*/
|
|
2588
|
-
Observable.arrayOfObject = function(data) {
|
|
2589
|
-
return data.map(item => Observable.object(item));
|
|
3006
|
+
Observable$1.arrayOfObject = function(data) {
|
|
3007
|
+
return data.map(item => Observable$1.object(item));
|
|
2590
3008
|
};
|
|
2591
3009
|
|
|
2592
3010
|
/**
|
|
@@ -2594,7 +3012,7 @@ var NativeDocument = (function (exports) {
|
|
|
2594
3012
|
* @param {ObservableItem|Object<ObservableItem>} data
|
|
2595
3013
|
* @returns {{}|*|null}
|
|
2596
3014
|
*/
|
|
2597
|
-
Observable.value = function(data) {
|
|
3015
|
+
Observable$1.value = function(data) {
|
|
2598
3016
|
if(Validator.isObservable(data)) {
|
|
2599
3017
|
return data.val();
|
|
2600
3018
|
}
|
|
@@ -2605,7 +3023,7 @@ var NativeDocument = (function (exports) {
|
|
|
2605
3023
|
const result = [];
|
|
2606
3024
|
for(let i = 0, length = data.length; i < length; i++) {
|
|
2607
3025
|
const item = data[i];
|
|
2608
|
-
result.push(Observable.value(item));
|
|
3026
|
+
result.push(Observable$1.value(item));
|
|
2609
3027
|
}
|
|
2610
3028
|
return result;
|
|
2611
3029
|
}
|
|
@@ -2613,7 +3031,7 @@ var NativeDocument = (function (exports) {
|
|
|
2613
3031
|
};
|
|
2614
3032
|
|
|
2615
3033
|
|
|
2616
|
-
Observable.update = function($target, newData) {
|
|
3034
|
+
Observable$1.update = function($target, newData) {
|
|
2617
3035
|
const data = Validator.isProxy(newData) ? newData.$value : newData;
|
|
2618
3036
|
const configs = $target.configs;
|
|
2619
3037
|
|
|
@@ -2628,9 +3046,9 @@ var NativeDocument = (function (exports) {
|
|
|
2628
3046
|
if(Validator.isObservable(firstElementFromOriginalValue) || Validator.isProxy(firstElementFromOriginalValue)) {
|
|
2629
3047
|
const newValues = newValue.map(item => {
|
|
2630
3048
|
if(Validator.isProxy(firstElementFromOriginalValue)) {
|
|
2631
|
-
return Observable.init(item, configs);
|
|
3049
|
+
return Observable$1.init(item, configs);
|
|
2632
3050
|
}
|
|
2633
|
-
return Observable(item, configs);
|
|
3051
|
+
return Observable$1(item, configs);
|
|
2634
3052
|
});
|
|
2635
3053
|
targetItem.set(newValues);
|
|
2636
3054
|
continue;
|
|
@@ -2642,15 +3060,15 @@ var NativeDocument = (function (exports) {
|
|
|
2642
3060
|
continue;
|
|
2643
3061
|
}
|
|
2644
3062
|
if(Validator.isProxy(targetItem)) {
|
|
2645
|
-
Observable.update(targetItem, newValue);
|
|
3063
|
+
Observable$1.update(targetItem, newValue);
|
|
2646
3064
|
continue;
|
|
2647
3065
|
}
|
|
2648
3066
|
$target[key] = newValue;
|
|
2649
3067
|
}
|
|
2650
3068
|
};
|
|
2651
3069
|
|
|
2652
|
-
Observable.object = Observable.init;
|
|
2653
|
-
Observable.json = Observable.init;
|
|
3070
|
+
Observable$1.object = Observable$1.init;
|
|
3071
|
+
Observable$1.json = Observable$1.init;
|
|
2654
3072
|
|
|
2655
3073
|
/**
|
|
2656
3074
|
*
|
|
@@ -2658,7 +3076,7 @@ var NativeDocument = (function (exports) {
|
|
|
2658
3076
|
* @param {Array|Function} dependencies
|
|
2659
3077
|
* @returns {ObservableItem}
|
|
2660
3078
|
*/
|
|
2661
|
-
Observable.computed = function(callback, dependencies = []) {
|
|
3079
|
+
Observable$1.computed = function(callback, dependencies = []) {
|
|
2662
3080
|
const initialValue = callback();
|
|
2663
3081
|
const observable = new ObservableItem(initialValue);
|
|
2664
3082
|
const updatedValue = () => observable.set(callback());
|
|
@@ -2698,7 +3116,7 @@ var NativeDocument = (function (exports) {
|
|
|
2698
3116
|
*/
|
|
2699
3117
|
use(name) {
|
|
2700
3118
|
const {observer: originalObserver, subscribers } = $stores.get(name);
|
|
2701
|
-
const observerFollower = Observable(originalObserver.val());
|
|
3119
|
+
const observerFollower = Observable$1(originalObserver.val());
|
|
2702
3120
|
const unSubscriber = originalObserver.subscribe(value => observerFollower.set(value));
|
|
2703
3121
|
const updaterUnsubscriber = observerFollower.subscribe(value => originalObserver.set(value));
|
|
2704
3122
|
observerFollower.destroy = () => {
|
|
@@ -2724,7 +3142,7 @@ var NativeDocument = (function (exports) {
|
|
|
2724
3142
|
* @returns {ObservableItem}
|
|
2725
3143
|
*/
|
|
2726
3144
|
create(name, value) {
|
|
2727
|
-
const observer = Observable(value);
|
|
3145
|
+
const observer = Observable$1(value);
|
|
2728
3146
|
$stores.set(name, { observer, subscribers: new Set()});
|
|
2729
3147
|
return observer;
|
|
2730
3148
|
},
|
|
@@ -2815,14 +3233,14 @@ var NativeDocument = (function (exports) {
|
|
|
2815
3233
|
}
|
|
2816
3234
|
|
|
2817
3235
|
try {
|
|
2818
|
-
const indexObserver = callback.length >= 2 ? Observable(indexKey) : null;
|
|
3236
|
+
const indexObserver = callback.length >= 2 ? Observable$1(indexKey) : null;
|
|
2819
3237
|
let child = ElementCreator.getChild(callback(item, indexObserver));
|
|
2820
3238
|
if(!child) {
|
|
2821
3239
|
throw new NativeDocumentError("ForEach child can't be null or undefined!");
|
|
2822
3240
|
}
|
|
2823
3241
|
cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
|
|
2824
3242
|
} catch (e) {
|
|
2825
|
-
DebugManager.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
3243
|
+
DebugManager$1.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
2826
3244
|
throw e;
|
|
2827
3245
|
}
|
|
2828
3246
|
return keyId;
|
|
@@ -2988,7 +3406,7 @@ var NativeDocument = (function (exports) {
|
|
|
2988
3406
|
cache.delete(keyId);
|
|
2989
3407
|
}
|
|
2990
3408
|
|
|
2991
|
-
const indexObserver = isIndexRequired ? Observable(indexKey) : null;
|
|
3409
|
+
const indexObserver = isIndexRequired ? Observable$1(indexKey) : null;
|
|
2992
3410
|
let child = ElementCreator.getChild(callback(item, indexObserver));
|
|
2993
3411
|
if(!child) {
|
|
2994
3412
|
throw new NativeDocumentError("ForEachArray child can't be null or undefined!");
|
|
@@ -3194,7 +3612,7 @@ var NativeDocument = (function (exports) {
|
|
|
3194
3612
|
*/
|
|
3195
3613
|
const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
|
|
3196
3614
|
if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
|
|
3197
|
-
return DebugManager.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
3615
|
+
return DebugManager$1.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
3198
3616
|
}
|
|
3199
3617
|
const element = Anchor('Show if : '+(comment || ''));
|
|
3200
3618
|
|
|
@@ -3234,7 +3652,7 @@ var NativeDocument = (function (exports) {
|
|
|
3234
3652
|
* @returns {DocumentFragment}
|
|
3235
3653
|
*/
|
|
3236
3654
|
const HideIf = function(condition, child, configs) {
|
|
3237
|
-
const hideCondition = Observable(!condition.val());
|
|
3655
|
+
const hideCondition = Observable$1(!condition.val());
|
|
3238
3656
|
condition.subscribe(value => hideCondition.set(!value));
|
|
3239
3657
|
|
|
3240
3658
|
return ShowIf(hideCondition, child, configs);
|
|
@@ -3981,7 +4399,7 @@ var NativeDocument = (function (exports) {
|
|
|
3981
4399
|
window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
|
|
3982
4400
|
this.handleRouteChange(route, params, query, path);
|
|
3983
4401
|
} catch (e) {
|
|
3984
|
-
DebugManager.error('HistoryRouter', 'Error in pushState', e);
|
|
4402
|
+
DebugManager$1.error('HistoryRouter', 'Error in pushState', e);
|
|
3985
4403
|
}
|
|
3986
4404
|
};
|
|
3987
4405
|
/**
|
|
@@ -3994,7 +4412,7 @@ var NativeDocument = (function (exports) {
|
|
|
3994
4412
|
window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
|
|
3995
4413
|
this.handleRouteChange(route, params, {}, path);
|
|
3996
4414
|
} catch(e) {
|
|
3997
|
-
DebugManager.error('HistoryRouter', 'Error in replaceState', e);
|
|
4415
|
+
DebugManager$1.error('HistoryRouter', 'Error in replaceState', e);
|
|
3998
4416
|
}
|
|
3999
4417
|
};
|
|
4000
4418
|
this.forward = function() {
|
|
@@ -4021,7 +4439,7 @@ var NativeDocument = (function (exports) {
|
|
|
4021
4439
|
}
|
|
4022
4440
|
this.handleRouteChange(route, params, query, path);
|
|
4023
4441
|
} catch(e) {
|
|
4024
|
-
DebugManager.error('HistoryRouter', 'Error in popstate event', e);
|
|
4442
|
+
DebugManager$1.error('HistoryRouter', 'Error in popstate event', e);
|
|
4025
4443
|
}
|
|
4026
4444
|
});
|
|
4027
4445
|
const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
|
|
@@ -4175,7 +4593,7 @@ var NativeDocument = (function (exports) {
|
|
|
4175
4593
|
listener(request);
|
|
4176
4594
|
next && next(request);
|
|
4177
4595
|
} catch (e) {
|
|
4178
|
-
DebugManager.warn('Route Listener', 'Error in listener:', e);
|
|
4596
|
+
DebugManager$1.warn('Route Listener', 'Error in listener:', e);
|
|
4179
4597
|
}
|
|
4180
4598
|
}
|
|
4181
4599
|
};
|
|
@@ -4334,7 +4752,7 @@ var NativeDocument = (function (exports) {
|
|
|
4334
4752
|
*/
|
|
4335
4753
|
Router.create = function(options, callback) {
|
|
4336
4754
|
if(!Validator.isFunction(callback)) {
|
|
4337
|
-
DebugManager.error('Router', 'Callback must be a function', e);
|
|
4755
|
+
DebugManager$1.error('Router', 'Callback must be a function', e);
|
|
4338
4756
|
throw new RouterError('Callback must be a function');
|
|
4339
4757
|
}
|
|
4340
4758
|
const router = new Router(options);
|
|
@@ -4508,6 +4926,7 @@ var NativeDocument = (function (exports) {
|
|
|
4508
4926
|
|
|
4509
4927
|
var utils = /*#__PURE__*/Object.freeze({
|
|
4510
4928
|
__proto__: null,
|
|
4929
|
+
Filters: index,
|
|
4511
4930
|
NativeFetch: NativeFetch,
|
|
4512
4931
|
Service: Service
|
|
4513
4932
|
});
|
|
@@ -4516,7 +4935,7 @@ var NativeDocument = (function (exports) {
|
|
|
4516
4935
|
exports.ElementCreator = ElementCreator;
|
|
4517
4936
|
exports.HtmlElementWrapper = HtmlElementWrapper;
|
|
4518
4937
|
exports.NDElement = NDElement;
|
|
4519
|
-
exports.Observable = Observable;
|
|
4938
|
+
exports.Observable = Observable$1;
|
|
4520
4939
|
exports.PluginsManager = PluginsManager;
|
|
4521
4940
|
exports.SingletonView = SingletonView;
|
|
4522
4941
|
exports.Store = Store;
|