@expressive/mvc 0.9.4 → 0.9.5
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/lib/index.d.ts +33 -33
- package/lib/index.esm.js +39 -39
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +39 -39
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -460,6 +460,39 @@ declare class MVC extends Model {
|
|
|
460
460
|
static meta<T, M extends Class>(this: M, from: (this: M, state: M) => T, expect?: boolean): T;
|
|
461
461
|
}
|
|
462
462
|
|
|
463
|
+
declare function useValue<T extends {}, R>(source: (() => T) | T, compute: (this: T, from: T) => R, expect: true): Exclude<R, undefined>;
|
|
464
|
+
declare function useValue<T extends {}, R>(source: (() => T) | T, compute: (this: T, from: T) => R, expect?: boolean): R;
|
|
465
|
+
|
|
466
|
+
declare class Lookup {
|
|
467
|
+
private table;
|
|
468
|
+
get local(): Model[];
|
|
469
|
+
private key;
|
|
470
|
+
get(T: Model.Type): any;
|
|
471
|
+
push(): this;
|
|
472
|
+
inject(T: Model.Type, I: Model, writable?: boolean): void;
|
|
473
|
+
pop(): void;
|
|
474
|
+
}
|
|
475
|
+
declare function useContext<T extends Model>(Type: Model.Type<T>, required: false): T | undefined;
|
|
476
|
+
declare function useContext<T extends Model>(Type: Model.Type<T>, arg?: boolean): T;
|
|
477
|
+
declare function useContext<T extends Model>(Type: Model.Type<T>, effect: (found: T) => Callback | void): T;
|
|
478
|
+
declare function useContext<T extends Model, K extends Model.Field<T>>(Type: Model.Type<T>, key: K): T[K];
|
|
479
|
+
|
|
480
|
+
declare function useModel<T extends Model>(source: Model.Type<T> | (() => T), callback?: (instance: T) => void): T;
|
|
481
|
+
declare function useModel<T extends Model>(source: Model.Type<T> | (() => T), watch: Model.Field<T>[], callback?: (instance: T) => void): T;
|
|
482
|
+
declare function useModel<T extends Model>(source: Model.Type<T> | (() => T), apply: Model.Compat<T>, keys?: Model.Event<T>[]): T;
|
|
483
|
+
|
|
484
|
+
declare namespace useTap {
|
|
485
|
+
type Source<T extends Model> = T | Model.Type<T> | (() => T | Model.Type<T>);
|
|
486
|
+
}
|
|
487
|
+
declare function useTap<T extends Model>(source: useTap.Source<T>): T;
|
|
488
|
+
declare function useTap<T extends Model, K extends Model.Field<T>>(source: useTap.Source<T>, path: K, expect: true): Exclude<T[K], undefined>;
|
|
489
|
+
declare function useTap<T extends Model, K extends Model.Field<T>>(source: useTap.Source<T>, path: K, expect?: boolean): T[K];
|
|
490
|
+
declare function useTap<T extends Model, R>(source: useTap.Source<T>, connect: (this: T, model: T) => () => R): R;
|
|
491
|
+
declare function useTap<T extends Model, R>(source: useTap.Source<T>, connect: (this: T, model: T) => (() => R) | null): R | null;
|
|
492
|
+
declare function useTap<T extends Model, R>(source: useTap.Source<T>, compute: (this: T, model: T) => Promise<R> | R, expect: true): Exclude<R, undefined>;
|
|
493
|
+
declare function useTap<T extends Model, R>(source: useTap.Source<T>, compute: (this: T, model: T) => Promise<R>, expect?: boolean): R | undefined;
|
|
494
|
+
declare function useTap<T extends Model, R>(source: useTap.Source<T>, compute: (this: T, model: T) => R, expect?: boolean): R;
|
|
495
|
+
|
|
463
496
|
declare namespace Consumer {
|
|
464
497
|
type HasProps<E extends Class> = {
|
|
465
498
|
/** @deprecated - use for instead */
|
|
@@ -497,20 +530,6 @@ declare namespace Consumer {
|
|
|
497
530
|
}
|
|
498
531
|
declare function Consumer<T extends Class>(props: Consumer.Props<T>): any;
|
|
499
532
|
|
|
500
|
-
declare class Lookup {
|
|
501
|
-
private table;
|
|
502
|
-
get local(): Model[];
|
|
503
|
-
private key;
|
|
504
|
-
get(T: Model.Type): any;
|
|
505
|
-
push(): this;
|
|
506
|
-
inject(T: Model.Type, I: Model, writable?: boolean): void;
|
|
507
|
-
pop(): void;
|
|
508
|
-
}
|
|
509
|
-
declare function useContext<T extends Model>(Type: Model.Type<T>, required: false): T | undefined;
|
|
510
|
-
declare function useContext<T extends Model>(Type: Model.Type<T>, arg?: boolean): T;
|
|
511
|
-
declare function useContext<T extends Model>(Type: Model.Type<T>, effect: (found: T) => Callback | void): T;
|
|
512
|
-
declare function useContext<T extends Model, K extends Model.Field<T>>(Type: Model.Type<T>, key: K): T[K];
|
|
513
|
-
|
|
514
533
|
declare namespace Provider {
|
|
515
534
|
type Item = Model | Model.Type;
|
|
516
535
|
type Multiple<T extends Item = Item> = T[] | {
|
|
@@ -585,23 +604,4 @@ declare function tap<T extends Model>(Type: Model.Type<T>, callback?: (instance?
|
|
|
585
604
|
declare function tap<T extends Model>(Type: Model.Type<T>, required: true): T;
|
|
586
605
|
declare function tap<T extends Model>(Type: Model.Type<T>, required?: boolean): T | undefined;
|
|
587
606
|
|
|
588
|
-
declare function useValue<T extends {}, R>(source: (() => T) | T, compute: (this: T, from: T) => R, expect: true): Exclude<R, undefined>;
|
|
589
|
-
declare function useValue<T extends {}, R>(source: (() => T) | T, compute: (this: T, from: T) => R, expect?: boolean): R;
|
|
590
|
-
|
|
591
|
-
declare function useModel<T extends Model>(source: Model.Type<T> | (() => T), callback?: (instance: T) => void): T;
|
|
592
|
-
declare function useModel<T extends Model>(source: Model.Type<T> | (() => T), watch: Model.Field<T>[], callback?: (instance: T) => void): T;
|
|
593
|
-
declare function useModel<T extends Model>(source: Model.Type<T> | (() => T), apply: Model.Compat<T>, keys?: Model.Event<T>[]): T;
|
|
594
|
-
|
|
595
|
-
declare namespace useTap {
|
|
596
|
-
type Source<T extends Model> = T | Model.Type<T> | (() => T | Model.Type<T>);
|
|
597
|
-
}
|
|
598
|
-
declare function useTap<T extends Model>(source: useTap.Source<T>): T;
|
|
599
|
-
declare function useTap<T extends Model, K extends Model.Field<T>>(source: useTap.Source<T>, path: K, expect: true): Exclude<T[K], undefined>;
|
|
600
|
-
declare function useTap<T extends Model, K extends Model.Field<T>>(source: useTap.Source<T>, path: K, expect?: boolean): T[K];
|
|
601
|
-
declare function useTap<T extends Model, R>(source: useTap.Source<T>, connect: (this: T, model: T) => () => R): R;
|
|
602
|
-
declare function useTap<T extends Model, R>(source: useTap.Source<T>, connect: (this: T, model: T) => (() => R) | null): R | null;
|
|
603
|
-
declare function useTap<T extends Model, R>(source: useTap.Source<T>, compute: (this: T, model: T) => Promise<R> | R, expect: true): Exclude<R, undefined>;
|
|
604
|
-
declare function useTap<T extends Model, R>(source: useTap.Source<T>, compute: (this: T, model: T) => Promise<R>, expect?: boolean): R | undefined;
|
|
605
|
-
declare function useTap<T extends Model, R>(source: useTap.Source<T>, compute: (this: T, model: T) => R, expect?: boolean): R;
|
|
606
|
-
|
|
607
607
|
export { Consumer, Debug, Global, MVC, MVC as Model, Provider, add, MVC as default, get, has, ref, run, set, tap, use, useContext, useModel, useTap, useValue };
|
package/lib/index.esm.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { useState, useMemo } from 'react';
|
|
2
2
|
|
|
3
|
+
const { assign, create, defineProperties, defineProperty, entries, getPrototypeOf, getOwnPropertyNames, getOwnPropertyDescriptor, getOwnPropertySymbols, values } = Object;
|
|
4
|
+
|
|
3
5
|
class Issue extends Error {
|
|
4
6
|
constructor() {
|
|
5
7
|
super(...arguments);
|
|
@@ -17,8 +19,6 @@ function issues(register) {
|
|
|
17
19
|
return Library;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
const { assign, create, defineProperties, defineProperty, entries, getPrototypeOf, getOwnPropertyNames, getOwnPropertyDescriptor, getOwnPropertySymbols, values } = Object;
|
|
21
|
-
|
|
22
22
|
const Oops$e = issues({
|
|
23
23
|
NotReady: (model, key) => `Value ${model}.${key} value is not yet available.`,
|
|
24
24
|
});
|
|
@@ -1364,43 +1364,6 @@ class MVC extends Model {
|
|
|
1364
1364
|
}
|
|
1365
1365
|
}
|
|
1366
1366
|
|
|
1367
|
-
const LOCAL = "$debug local";
|
|
1368
|
-
const STATE = "$debug state";
|
|
1369
|
-
const UPDATE = "$debug update";
|
|
1370
|
-
const CONTROL = "$debug controller";
|
|
1371
|
-
defineProperties(Model.prototype, {
|
|
1372
|
-
[CONTROL]: {
|
|
1373
|
-
get() {
|
|
1374
|
-
return Control.get(this);
|
|
1375
|
-
}
|
|
1376
|
-
},
|
|
1377
|
-
[LOCAL]: {
|
|
1378
|
-
get() {
|
|
1379
|
-
return Subscriber.get(this);
|
|
1380
|
-
}
|
|
1381
|
-
},
|
|
1382
|
-
[STATE]: {
|
|
1383
|
-
get() {
|
|
1384
|
-
const { state } = Control.get(this);
|
|
1385
|
-
const output = {};
|
|
1386
|
-
state.forEach((value, key) => output[key] = value);
|
|
1387
|
-
return output;
|
|
1388
|
-
}
|
|
1389
|
-
},
|
|
1390
|
-
[UPDATE]: {
|
|
1391
|
-
get() {
|
|
1392
|
-
const source = Subscriber.get(this) || Control.get(this);
|
|
1393
|
-
return source && source.latest;
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
});
|
|
1397
|
-
const Debug = {
|
|
1398
|
-
CONTROL,
|
|
1399
|
-
LOCAL,
|
|
1400
|
-
STATE,
|
|
1401
|
-
UPDATE
|
|
1402
|
-
};
|
|
1403
|
-
|
|
1404
1367
|
const Oops$2 = issues({
|
|
1405
1368
|
BadProps: () => `Provider expects either a render function, 'get' or 'has' props.`
|
|
1406
1369
|
});
|
|
@@ -1530,5 +1493,42 @@ class Global extends MVC {
|
|
|
1530
1493
|
}
|
|
1531
1494
|
Global.keepAlive = true;
|
|
1532
1495
|
|
|
1496
|
+
const LOCAL = "$debug local";
|
|
1497
|
+
const STATE = "$debug state";
|
|
1498
|
+
const UPDATE = "$debug update";
|
|
1499
|
+
const CONTROL = "$debug controller";
|
|
1500
|
+
defineProperties(Model.prototype, {
|
|
1501
|
+
[CONTROL]: {
|
|
1502
|
+
get() {
|
|
1503
|
+
return Control.get(this);
|
|
1504
|
+
}
|
|
1505
|
+
},
|
|
1506
|
+
[LOCAL]: {
|
|
1507
|
+
get() {
|
|
1508
|
+
return Subscriber.get(this);
|
|
1509
|
+
}
|
|
1510
|
+
},
|
|
1511
|
+
[STATE]: {
|
|
1512
|
+
get() {
|
|
1513
|
+
const { state } = Control.get(this);
|
|
1514
|
+
const output = {};
|
|
1515
|
+
state.forEach((value, key) => output[key] = value);
|
|
1516
|
+
return output;
|
|
1517
|
+
}
|
|
1518
|
+
},
|
|
1519
|
+
[UPDATE]: {
|
|
1520
|
+
get() {
|
|
1521
|
+
const source = Subscriber.get(this) || Control.get(this);
|
|
1522
|
+
return source && source.latest;
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
});
|
|
1526
|
+
const Debug = {
|
|
1527
|
+
CONTROL,
|
|
1528
|
+
LOCAL,
|
|
1529
|
+
STATE,
|
|
1530
|
+
UPDATE
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
1533
|
export { Consumer, Debug, Global, MVC, MVC as Model, Provider, add, MVC as default, get, has, ref, run, set, tap, use$1 as use, useContext, useModel, useTap, useValue };
|
|
1534
1534
|
//# sourceMappingURL=index.esm.js.map
|