@expressive/mvc 0.7.1 → 0.7.2
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 +2 -5
- package/lib/index.esm.js +30 -36
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +30 -36
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -506,16 +506,13 @@ declare namespace Consumer {
|
|
|
506
506
|
}
|
|
507
507
|
declare function Consumer<T extends Class>(props: Consumer.Props<T>): any;
|
|
508
508
|
|
|
509
|
-
declare type Collection = Array<Model | typeof Model> | {
|
|
510
|
-
[anything: string]: Model | typeof Model;
|
|
511
|
-
};
|
|
512
509
|
declare class Lookup {
|
|
513
510
|
private table;
|
|
514
511
|
get local(): Model[];
|
|
515
512
|
private key;
|
|
516
513
|
get(T: typeof Model): any;
|
|
517
|
-
push(
|
|
518
|
-
|
|
514
|
+
push(): this;
|
|
515
|
+
inject(T: typeof Model, I: Model, writable?: boolean): void;
|
|
519
516
|
pop(): void;
|
|
520
517
|
}
|
|
521
518
|
|
package/lib/index.esm.js
CHANGED
|
@@ -922,12 +922,15 @@ function createProxy(emit, watch) {
|
|
|
922
922
|
assign(proxy, {
|
|
923
923
|
from,
|
|
924
924
|
delete(key) {
|
|
925
|
+
// TODO: this commit's fix needs tests.
|
|
926
|
+
// Was not cause by coverage.
|
|
927
|
+
const out = from.delete(key);
|
|
925
928
|
emit(key);
|
|
926
|
-
return
|
|
929
|
+
return out;
|
|
927
930
|
},
|
|
928
931
|
clear() {
|
|
929
|
-
emit(ANY);
|
|
930
932
|
from.clear();
|
|
933
|
+
emit(ANY);
|
|
931
934
|
},
|
|
932
935
|
has(key) {
|
|
933
936
|
watch(this, key);
|
|
@@ -1107,26 +1110,10 @@ class Lookup {
|
|
|
1107
1110
|
get(T) {
|
|
1108
1111
|
return this[this.key(T)];
|
|
1109
1112
|
}
|
|
1110
|
-
push(
|
|
1111
|
-
|
|
1112
|
-
if (I instanceof Model || typeof I == "function")
|
|
1113
|
-
next.register(I);
|
|
1114
|
-
else
|
|
1115
|
-
for (const i of values(I))
|
|
1116
|
-
next.register(i);
|
|
1117
|
-
return next;
|
|
1113
|
+
push() {
|
|
1114
|
+
return create(this);
|
|
1118
1115
|
}
|
|
1119
|
-
|
|
1120
|
-
let writable = true;
|
|
1121
|
-
let T;
|
|
1122
|
-
if (I instanceof Model) {
|
|
1123
|
-
T = I.constructor;
|
|
1124
|
-
writable = false;
|
|
1125
|
-
}
|
|
1126
|
-
else {
|
|
1127
|
-
T = I;
|
|
1128
|
-
I = I.create();
|
|
1129
|
-
}
|
|
1116
|
+
inject(T, I, writable) {
|
|
1130
1117
|
do {
|
|
1131
1118
|
const key = this.key(T);
|
|
1132
1119
|
const conflict = this.hasOwnProperty(key);
|
|
@@ -1137,7 +1124,6 @@ class Lookup {
|
|
|
1137
1124
|
});
|
|
1138
1125
|
T = getPrototypeOf(T);
|
|
1139
1126
|
} while (T !== Model);
|
|
1140
|
-
return I;
|
|
1141
1127
|
}
|
|
1142
1128
|
pop() {
|
|
1143
1129
|
for (const key of getOwnPropertySymbols(this)) {
|
|
@@ -1420,7 +1406,28 @@ const Oops$1 = issues({
|
|
|
1420
1406
|
function Provider(props) {
|
|
1421
1407
|
if ("of" in props)
|
|
1422
1408
|
throw Oops$1.PropDeprecated();
|
|
1423
|
-
const
|
|
1409
|
+
const from = useLookup();
|
|
1410
|
+
const context = React.useMemo(() => {
|
|
1411
|
+
const I = props.for;
|
|
1412
|
+
if (!I)
|
|
1413
|
+
throw Oops$1.NoType();
|
|
1414
|
+
const layer = from.push();
|
|
1415
|
+
function register(I) {
|
|
1416
|
+
if (I instanceof Model)
|
|
1417
|
+
layer.inject(I.constructor, I, false);
|
|
1418
|
+
else
|
|
1419
|
+
layer.inject(I, I.create(), true);
|
|
1420
|
+
}
|
|
1421
|
+
if (I instanceof Model || typeof I == "function")
|
|
1422
|
+
register(I);
|
|
1423
|
+
else
|
|
1424
|
+
values(I).forEach(register);
|
|
1425
|
+
for (const instance of layer.local)
|
|
1426
|
+
if (instance)
|
|
1427
|
+
for (const apply of getPending(instance))
|
|
1428
|
+
apply(layer);
|
|
1429
|
+
return layer;
|
|
1430
|
+
}, []);
|
|
1424
1431
|
const render = props.children;
|
|
1425
1432
|
useAppliedProps(context, props);
|
|
1426
1433
|
React.useLayoutEffect(() => () => context.pop(), []);
|
|
@@ -1428,19 +1435,6 @@ function Provider(props) {
|
|
|
1428
1435
|
? React.createElement(RenderFunction, { context, render })
|
|
1429
1436
|
: render);
|
|
1430
1437
|
}
|
|
1431
|
-
function useNewContext(inject) {
|
|
1432
|
-
const from = useLookup();
|
|
1433
|
-
return React.useMemo(() => {
|
|
1434
|
-
if (!inject)
|
|
1435
|
-
throw Oops$1.NoType();
|
|
1436
|
-
const context = from.push(inject);
|
|
1437
|
-
for (const instance of context.local)
|
|
1438
|
-
if (instance)
|
|
1439
|
-
for (const apply of getPending(instance))
|
|
1440
|
-
apply(context);
|
|
1441
|
-
return context;
|
|
1442
|
-
}, []);
|
|
1443
|
-
}
|
|
1444
1438
|
function useAppliedProps(within, props) {
|
|
1445
1439
|
const update = React.useMemo(() => {
|
|
1446
1440
|
const targets = within.local;
|