@expressive/mvc 0.17.0 → 0.17.1
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 +1 -1
- package/lib/index.esm.js +8 -2
- package/lib/index.js +8 -2
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ declare namespace Model {
|
|
|
73
73
|
/** Including but not limited to T. */
|
|
74
74
|
type Extends<T> = T | (string & Record<never, never>);
|
|
75
75
|
/** Any typeof Model, using class constructor as the reference. */
|
|
76
|
-
export type Type<T extends Model = Model> = (abstract new (...args: any[]) => T)
|
|
76
|
+
export type Type<T extends Model = Model> = (abstract new (...args: any[]) => T);
|
|
77
77
|
/** A typeof Model, specifically one which may be created without arguments. */
|
|
78
78
|
export type New<T extends Model = Model> = (new () => T) & typeof Model;
|
|
79
79
|
export type Effect<T> = (this: T, argument: T) => Callback | Promise<any> | void;
|
package/lib/index.esm.js
CHANGED
|
@@ -1203,7 +1203,7 @@ class Register {
|
|
|
1203
1203
|
const key = this.has(T);
|
|
1204
1204
|
defineProperty(this, key, {
|
|
1205
1205
|
configurable: true,
|
|
1206
|
-
value: this.hasOwnProperty(key) ? null : I,
|
|
1206
|
+
value: this.hasOwnProperty(key) && I !== this[key] ? null : I,
|
|
1207
1207
|
writable
|
|
1208
1208
|
});
|
|
1209
1209
|
T = getPrototypeOf(T);
|
|
@@ -1241,7 +1241,8 @@ const Global$1 = new Register();
|
|
|
1241
1241
|
const Oops$3 = issues({
|
|
1242
1242
|
AlreadyExists: (name) => `Shared instance of ${name} already exists! Consider unmounting existing, or use ${name}.reset() to force-delete it.`,
|
|
1243
1243
|
DoesNotExist: (name) => `Tried to access singleton ${name}, but none exist! Did you forget to initialize?\nCall ${name}.new() before attempting to access, or consider using ${name}.use() instead.`,
|
|
1244
|
-
NotFound: (name) => `Couldn't find ${name} in context; did you forget to use a Provider
|
|
1244
|
+
NotFound: (name) => `Couldn't find ${name} in context; did you forget to use a Provider?`,
|
|
1245
|
+
MultipleExist: (name) => `Did find ${name} in context, but multiple were defined by same Provider.`
|
|
1245
1246
|
});
|
|
1246
1247
|
const LookupContext = React.createContext(Global$1);
|
|
1247
1248
|
function useLookup() {
|
|
@@ -1254,6 +1255,8 @@ function useLookup() {
|
|
|
1254
1255
|
}
|
|
1255
1256
|
function useContext(Type, required) {
|
|
1256
1257
|
const instance = useLookup().get(Type);
|
|
1258
|
+
if (instance === null)
|
|
1259
|
+
throw Oops$3.MultipleExist(Type.name);
|
|
1257
1260
|
if (!instance && required !== false)
|
|
1258
1261
|
throw MVC.isTypeof(Type) && Type.global
|
|
1259
1262
|
? Oops$3.DoesNotExist(Type.name)
|
|
@@ -1547,6 +1550,7 @@ function useNewContext(include, assign) {
|
|
|
1547
1550
|
entries(include).forEach(e => register(...e));
|
|
1548
1551
|
for (const instance of init) {
|
|
1549
1552
|
control(instance).state.forEach(value => {
|
|
1553
|
+
// TODO: should this run repeatedly?
|
|
1550
1554
|
if (Parent.get(value) === instance) {
|
|
1551
1555
|
context.add(value);
|
|
1552
1556
|
init.add(value);
|
|
@@ -1554,6 +1558,8 @@ function useNewContext(include, assign) {
|
|
|
1554
1558
|
});
|
|
1555
1559
|
for (const apply of getPending(instance))
|
|
1556
1560
|
apply(context);
|
|
1561
|
+
// TODO: add test to validate this.
|
|
1562
|
+
init.delete(instance);
|
|
1557
1563
|
}
|
|
1558
1564
|
React.useLayoutEffect(() => () => context.pop(), []);
|
|
1559
1565
|
return context;
|
package/lib/index.js
CHANGED
|
@@ -1211,7 +1211,7 @@ class Register {
|
|
|
1211
1211
|
const key = this.has(T);
|
|
1212
1212
|
defineProperty(this, key, {
|
|
1213
1213
|
configurable: true,
|
|
1214
|
-
value: this.hasOwnProperty(key) ? null : I,
|
|
1214
|
+
value: this.hasOwnProperty(key) && I !== this[key] ? null : I,
|
|
1215
1215
|
writable
|
|
1216
1216
|
});
|
|
1217
1217
|
T = getPrototypeOf(T);
|
|
@@ -1249,7 +1249,8 @@ const Global$1 = new Register();
|
|
|
1249
1249
|
const Oops$3 = issues({
|
|
1250
1250
|
AlreadyExists: (name) => `Shared instance of ${name} already exists! Consider unmounting existing, or use ${name}.reset() to force-delete it.`,
|
|
1251
1251
|
DoesNotExist: (name) => `Tried to access singleton ${name}, but none exist! Did you forget to initialize?\nCall ${name}.new() before attempting to access, or consider using ${name}.use() instead.`,
|
|
1252
|
-
NotFound: (name) => `Couldn't find ${name} in context; did you forget to use a Provider
|
|
1252
|
+
NotFound: (name) => `Couldn't find ${name} in context; did you forget to use a Provider?`,
|
|
1253
|
+
MultipleExist: (name) => `Did find ${name} in context, but multiple were defined by same Provider.`
|
|
1253
1254
|
});
|
|
1254
1255
|
const LookupContext = React__default["default"].createContext(Global$1);
|
|
1255
1256
|
function useLookup() {
|
|
@@ -1262,6 +1263,8 @@ function useLookup() {
|
|
|
1262
1263
|
}
|
|
1263
1264
|
function useContext(Type, required) {
|
|
1264
1265
|
const instance = useLookup().get(Type);
|
|
1266
|
+
if (instance === null)
|
|
1267
|
+
throw Oops$3.MultipleExist(Type.name);
|
|
1265
1268
|
if (!instance && required !== false)
|
|
1266
1269
|
throw MVC.isTypeof(Type) && Type.global
|
|
1267
1270
|
? Oops$3.DoesNotExist(Type.name)
|
|
@@ -1555,6 +1558,7 @@ function useNewContext(include, assign) {
|
|
|
1555
1558
|
entries(include).forEach(e => register(...e));
|
|
1556
1559
|
for (const instance of init) {
|
|
1557
1560
|
control(instance).state.forEach(value => {
|
|
1561
|
+
// TODO: should this run repeatedly?
|
|
1558
1562
|
if (Parent.get(value) === instance) {
|
|
1559
1563
|
context.add(value);
|
|
1560
1564
|
init.add(value);
|
|
@@ -1562,6 +1566,8 @@ function useNewContext(include, assign) {
|
|
|
1562
1566
|
});
|
|
1563
1567
|
for (const apply of getPending(instance))
|
|
1564
1568
|
apply(context);
|
|
1569
|
+
// TODO: add test to validate this.
|
|
1570
|
+
init.delete(instance);
|
|
1565
1571
|
}
|
|
1566
1572
|
React__default["default"].useLayoutEffect(() => () => context.pop(), []);
|
|
1567
1573
|
return context;
|
package/package.json
CHANGED