@expressive/react 0.28.0 → 0.29.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.esm.js +9 -0
- package/lib/index.js +9 -0
- package/package.json +3 -3
package/lib/index.esm.js
CHANGED
|
@@ -10,8 +10,17 @@ function Provider(props) {
|
|
|
10
10
|
let { for: included, use: assign } = props;
|
|
11
11
|
const ambient = useLookup();
|
|
12
12
|
const context = useMemo(() => ambient.push(), []);
|
|
13
|
+
const reject = (value) => {
|
|
14
|
+
throw new Error(`Provider expects a Model instance or class but got ${value}.`);
|
|
15
|
+
};
|
|
16
|
+
if (!included)
|
|
17
|
+
reject(included);
|
|
13
18
|
if (typeof included == "function" || included instanceof Model)
|
|
14
19
|
included = { [0]: included };
|
|
20
|
+
Object.entries(included).forEach(([K, V]) => {
|
|
21
|
+
if (!(Model.is(V) || V instanceof Model))
|
|
22
|
+
reject(`${V} as ${K}`);
|
|
23
|
+
});
|
|
15
24
|
context.include(included).forEach((isExplicit, model) => {
|
|
16
25
|
if (assign && isExplicit)
|
|
17
26
|
for (const K in assign)
|
package/lib/index.js
CHANGED
|
@@ -12,8 +12,17 @@ function Provider(props) {
|
|
|
12
12
|
let { for: included, use: assign } = props;
|
|
13
13
|
const ambient = useLookup();
|
|
14
14
|
const context = react.useMemo(() => ambient.push(), []);
|
|
15
|
+
const reject = (value) => {
|
|
16
|
+
throw new Error(`Provider expects a Model instance or class but got ${value}.`);
|
|
17
|
+
};
|
|
18
|
+
if (!included)
|
|
19
|
+
reject(included);
|
|
15
20
|
if (typeof included == "function" || included instanceof mvc.Model)
|
|
16
21
|
included = { [0]: included };
|
|
22
|
+
Object.entries(included).forEach(([K, V]) => {
|
|
23
|
+
if (!(mvc.Model.is(V) || V instanceof mvc.Model))
|
|
24
|
+
reject(`${V} as ${K}`);
|
|
25
|
+
});
|
|
17
26
|
context.include(included).forEach((isExplicit, model) => {
|
|
18
27
|
if (assign && isExplicit)
|
|
19
28
|
for (const K in assign)
|
package/package.json
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"preversion": "npm run test && npm run build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@expressive/mvc": "^0.
|
|
32
|
+
"@expressive/mvc": "^0.29.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": ">=16.8.0 <19.0.0"
|
|
@@ -41,6 +41,6 @@
|
|
|
41
41
|
"react": ">=17.0.2",
|
|
42
42
|
"react-test-renderer": "^17.0.2"
|
|
43
43
|
},
|
|
44
|
-
"version": "0.
|
|
45
|
-
"gitHead": "
|
|
44
|
+
"version": "0.29.1",
|
|
45
|
+
"gitHead": "bc5ef985433d6f7d198eda375cda9e8a055ca0d0"
|
|
46
46
|
}
|