@expressive/react 0.45.0 → 0.47.0
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/dist/index.d.ts +1 -1
- package/dist/index.js +10 -10
- package/dist/index.mjs +11 -10
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Model, Context } from '@expressive/mvc';
|
|
2
|
-
export { Model,
|
|
2
|
+
export { Model, Model as default, get, has, ref, set, use } from '@expressive/mvc';
|
|
3
3
|
import { FunctionComponentElement, ReactNode } from 'react';
|
|
4
4
|
|
|
5
5
|
declare namespace Consumer {
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,6 @@ __export(src_exports, {
|
|
|
23
23
|
Consumer: () => Consumer,
|
|
24
24
|
Model: () => import_mvc2.Model,
|
|
25
25
|
Provider: () => Provider,
|
|
26
|
-
add: () => import_mvc3.add,
|
|
27
26
|
default: () => import_mvc2.Model,
|
|
28
27
|
get: () => import_mvc3.get,
|
|
29
28
|
has: () => import_mvc3.has,
|
|
@@ -62,15 +61,15 @@ function createContext(value, children) {
|
|
|
62
61
|
}
|
|
63
62
|
function usingContext(from, resolve) {
|
|
64
63
|
const waiting = Register.get(from);
|
|
65
|
-
const
|
|
66
|
-
resolve(
|
|
64
|
+
const callback = (context) => {
|
|
65
|
+
resolve(context.get(this));
|
|
67
66
|
};
|
|
68
67
|
if (waiting instanceof import_mvc.Context)
|
|
69
|
-
|
|
68
|
+
callback(waiting);
|
|
70
69
|
else if (waiting)
|
|
71
|
-
waiting.push(
|
|
70
|
+
waiting.push(callback);
|
|
72
71
|
else
|
|
73
|
-
Register.set(from, [
|
|
72
|
+
Register.set(from, [callback]);
|
|
74
73
|
}
|
|
75
74
|
function setContext(model, context) {
|
|
76
75
|
const waiting = Register.get(model);
|
|
@@ -84,7 +83,7 @@ function useLocal(argument, repeat) {
|
|
|
84
83
|
const state = (0, import_react2.useState)(() => {
|
|
85
84
|
let enabled;
|
|
86
85
|
let local;
|
|
87
|
-
const instance = this
|
|
86
|
+
const instance = new this(argument);
|
|
88
87
|
const release = instance.get((current) => {
|
|
89
88
|
local = current;
|
|
90
89
|
if (enabled)
|
|
@@ -106,6 +105,8 @@ function useLocal(argument, repeat) {
|
|
|
106
105
|
const context = useContext();
|
|
107
106
|
setContext(instance, context);
|
|
108
107
|
context.has(instance);
|
|
108
|
+
if (!local)
|
|
109
|
+
instance.set();
|
|
109
110
|
(0, import_react2.useEffect)(() => {
|
|
110
111
|
enabled = true;
|
|
111
112
|
return () => {
|
|
@@ -196,8 +197,8 @@ function Provider(props) {
|
|
|
196
197
|
let { for: included, use: assign } = props;
|
|
197
198
|
const ambient = useContext();
|
|
198
199
|
const context = (0, import_react2.useMemo)(() => ambient.push(), []);
|
|
199
|
-
context.include(included
|
|
200
|
-
if (assign &&
|
|
200
|
+
context.include(included, (model, explicit) => {
|
|
201
|
+
if (assign && explicit)
|
|
201
202
|
model.set(assign);
|
|
202
203
|
setContext(model, context);
|
|
203
204
|
});
|
|
@@ -215,7 +216,6 @@ import_mvc2.Model.use = useLocal;
|
|
|
215
216
|
Consumer,
|
|
216
217
|
Model,
|
|
217
218
|
Provider,
|
|
218
|
-
add,
|
|
219
219
|
get,
|
|
220
220
|
has,
|
|
221
221
|
ref,
|
package/dist/index.mjs
CHANGED
|
@@ -29,15 +29,15 @@ function createContext(value, children) {
|
|
|
29
29
|
}
|
|
30
30
|
function usingContext(from, resolve) {
|
|
31
31
|
const waiting = Register.get(from);
|
|
32
|
-
const
|
|
33
|
-
resolve(
|
|
32
|
+
const callback = (context) => {
|
|
33
|
+
resolve(context.get(this));
|
|
34
34
|
};
|
|
35
35
|
if (waiting instanceof Context)
|
|
36
|
-
|
|
36
|
+
callback(waiting);
|
|
37
37
|
else if (waiting)
|
|
38
|
-
waiting.push(
|
|
38
|
+
waiting.push(callback);
|
|
39
39
|
else
|
|
40
|
-
Register.set(from, [
|
|
40
|
+
Register.set(from, [callback]);
|
|
41
41
|
}
|
|
42
42
|
function setContext(model, context) {
|
|
43
43
|
const waiting = Register.get(model);
|
|
@@ -51,7 +51,7 @@ function useLocal(argument, repeat) {
|
|
|
51
51
|
const state = useState(() => {
|
|
52
52
|
let enabled;
|
|
53
53
|
let local;
|
|
54
|
-
const instance = this
|
|
54
|
+
const instance = new this(argument);
|
|
55
55
|
const release = instance.get((current) => {
|
|
56
56
|
local = current;
|
|
57
57
|
if (enabled)
|
|
@@ -73,6 +73,8 @@ function useLocal(argument, repeat) {
|
|
|
73
73
|
const context = useContext();
|
|
74
74
|
setContext(instance, context);
|
|
75
75
|
context.has(instance);
|
|
76
|
+
if (!local)
|
|
77
|
+
instance.set();
|
|
76
78
|
useEffect(() => {
|
|
77
79
|
enabled = true;
|
|
78
80
|
return () => {
|
|
@@ -144,7 +146,7 @@ function useRemote(argument) {
|
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
// src/index.ts
|
|
147
|
-
import {
|
|
149
|
+
import { get, use, ref, set, has } from "@expressive/mvc";
|
|
148
150
|
|
|
149
151
|
// src/consumer.ts
|
|
150
152
|
function Consumer(props) {
|
|
@@ -163,8 +165,8 @@ function Provider(props) {
|
|
|
163
165
|
let { for: included, use: assign } = props;
|
|
164
166
|
const ambient = useContext();
|
|
165
167
|
const context = useMemo(() => ambient.push(), []);
|
|
166
|
-
context.include(included
|
|
167
|
-
if (assign &&
|
|
168
|
+
context.include(included, (model, explicit) => {
|
|
169
|
+
if (assign && explicit)
|
|
168
170
|
model.set(assign);
|
|
169
171
|
setContext(model, context);
|
|
170
172
|
});
|
|
@@ -181,7 +183,6 @@ export {
|
|
|
181
183
|
Consumer,
|
|
182
184
|
Model2 as Model,
|
|
183
185
|
Provider,
|
|
184
|
-
add,
|
|
185
186
|
Model2 as default,
|
|
186
187
|
get,
|
|
187
188
|
has,
|
package/package.json
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"preversion": "npm run test && npm run build"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@expressive/mvc": "^0.
|
|
34
|
+
"@expressive/mvc": "^0.47.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": ">=16.8.0 <19.0.0"
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"react": "^18.2.0",
|
|
43
43
|
"react-test-renderer": "^18.2.0"
|
|
44
44
|
},
|
|
45
|
-
"version": "0.
|
|
46
|
-
"gitHead": "
|
|
45
|
+
"version": "0.47.0",
|
|
46
|
+
"gitHead": "7c0ddd5ea9b7e08bd5aa21aa8e1ab65ceef17fcf"
|
|
47
47
|
}
|