@expressive/react 0.21.6 → 0.21.7
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 +20 -15
- package/lib/index.js +20 -15
- package/package.json +2 -2
package/lib/index.esm.js
CHANGED
|
@@ -15,23 +15,28 @@ function usePeerContext(instance) {
|
|
|
15
15
|
if (pending) {
|
|
16
16
|
const local = useLookup();
|
|
17
17
|
pending.forEach(init => init(local));
|
|
18
|
+
Applied.set(instance, local);
|
|
18
19
|
Pending.delete(instance);
|
|
19
|
-
Applied.set(instance, true);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
let pending = Pending.get(
|
|
23
|
+
function setContext(model, has) {
|
|
24
|
+
let pending = Pending.get(model);
|
|
25
25
|
if (!pending)
|
|
26
|
-
Pending.set(
|
|
27
|
-
pending.
|
|
28
|
-
callback(context.get(type));
|
|
29
|
-
});
|
|
26
|
+
Pending.set(model, pending = []);
|
|
27
|
+
pending.forEach(cb => cb(has));
|
|
30
28
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
if (pending)
|
|
34
|
-
|
|
29
|
+
function hasContext(model) {
|
|
30
|
+
let pending = Pending.get(model);
|
|
31
|
+
if (!pending)
|
|
32
|
+
Pending.set(model, pending = []);
|
|
33
|
+
return (callback) => {
|
|
34
|
+
const applied = Applied.get(model);
|
|
35
|
+
if (applied)
|
|
36
|
+
callback(applied);
|
|
37
|
+
else
|
|
38
|
+
pending.push(callback);
|
|
39
|
+
};
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
function Consumer(props) {
|
|
@@ -50,12 +55,12 @@ function Provider(props) {
|
|
|
50
55
|
const context = useMemo(() => ambient.push(), []);
|
|
51
56
|
if (typeof included == "function" || included instanceof Model)
|
|
52
57
|
included = { [0]: included };
|
|
53
|
-
context.include(included).forEach((
|
|
54
|
-
if (assign &&
|
|
58
|
+
context.include(included).forEach((isExplicit, model) => {
|
|
59
|
+
if (assign && isExplicit)
|
|
55
60
|
for (const K in assign)
|
|
56
61
|
if (K in model)
|
|
57
62
|
model[K] = assign[K];
|
|
58
|
-
|
|
63
|
+
setContext(model, context);
|
|
59
64
|
});
|
|
60
65
|
useLayoutEffect(() => () => context.pop(), []);
|
|
61
66
|
return createElement(LookupContext.Provider, { value: context, key: context.key }, props.fallback == false
|
|
@@ -63,7 +68,7 @@ function Provider(props) {
|
|
|
63
68
|
: createElement(Suspense, { fallback: props.fallback || null }, props.children));
|
|
64
69
|
}
|
|
65
70
|
|
|
66
|
-
Control.has =
|
|
71
|
+
Control.has = hasContext;
|
|
67
72
|
Control.get = (adapter) => {
|
|
68
73
|
const context = useLookup();
|
|
69
74
|
const state = useState(0);
|
package/lib/index.js
CHANGED
|
@@ -18,23 +18,28 @@ function usePeerContext(instance) {
|
|
|
18
18
|
if (pending) {
|
|
19
19
|
const local = useLookup();
|
|
20
20
|
pending.forEach(init => init(local));
|
|
21
|
+
Applied.set(instance, local);
|
|
21
22
|
Pending.delete(instance);
|
|
22
|
-
Applied.set(instance, true);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
let pending = Pending.get(
|
|
26
|
+
function setContext(model, has) {
|
|
27
|
+
let pending = Pending.get(model);
|
|
28
28
|
if (!pending)
|
|
29
|
-
Pending.set(
|
|
30
|
-
pending.
|
|
31
|
-
callback(context.get(type));
|
|
32
|
-
});
|
|
29
|
+
Pending.set(model, pending = []);
|
|
30
|
+
pending.forEach(cb => cb(has));
|
|
33
31
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
if (pending)
|
|
37
|
-
|
|
32
|
+
function hasContext(model) {
|
|
33
|
+
let pending = Pending.get(model);
|
|
34
|
+
if (!pending)
|
|
35
|
+
Pending.set(model, pending = []);
|
|
36
|
+
return (callback) => {
|
|
37
|
+
const applied = Applied.get(model);
|
|
38
|
+
if (applied)
|
|
39
|
+
callback(applied);
|
|
40
|
+
else
|
|
41
|
+
pending.push(callback);
|
|
42
|
+
};
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
function Consumer(props) {
|
|
@@ -53,12 +58,12 @@ function Provider(props) {
|
|
|
53
58
|
const context = react.useMemo(() => ambient.push(), []);
|
|
54
59
|
if (typeof included == "function" || included instanceof mvc.Model)
|
|
55
60
|
included = { [0]: included };
|
|
56
|
-
context.include(included).forEach((
|
|
57
|
-
if (assign &&
|
|
61
|
+
context.include(included).forEach((isExplicit, model) => {
|
|
62
|
+
if (assign && isExplicit)
|
|
58
63
|
for (const K in assign)
|
|
59
64
|
if (K in model)
|
|
60
65
|
model[K] = assign[K];
|
|
61
|
-
|
|
66
|
+
setContext(model, context);
|
|
62
67
|
});
|
|
63
68
|
react.useLayoutEffect(() => () => context.pop(), []);
|
|
64
69
|
return react.createElement(LookupContext.Provider, { value: context, key: context.key }, props.fallback == false
|
|
@@ -66,7 +71,7 @@ function Provider(props) {
|
|
|
66
71
|
: react.createElement(react.Suspense, { fallback: props.fallback || null }, props.children));
|
|
67
72
|
}
|
|
68
73
|
|
|
69
|
-
mvc.Control.has =
|
|
74
|
+
mvc.Control.has = hasContext;
|
|
70
75
|
mvc.Control.get = (adapter) => {
|
|
71
76
|
const context = useLookup();
|
|
72
77
|
const state = react.useState(0);
|
package/package.json
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"postversion": "git push & npm publish"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@expressive/mvc": "^0.21.
|
|
33
|
+
"@expressive/mvc": "^0.21.7"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": ">=16.8.0 <19.0.0"
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"react": ">=17.0.2",
|
|
43
43
|
"react-test-renderer": "^17.0.2"
|
|
44
44
|
},
|
|
45
|
-
"version": "0.21.
|
|
45
|
+
"version": "0.21.7"
|
|
46
46
|
}
|