@expressive/react 0.46.0 → 0.48.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 +19 -44
- package/dist/index.mjs +8 -32
- 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
|
@@ -21,18 +21,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
Consumer: () => Consumer,
|
|
24
|
-
Model: () =>
|
|
24
|
+
Model: () => import_mvc3.Model,
|
|
25
25
|
Provider: () => Provider,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
use: () => import_mvc3.use
|
|
26
|
+
default: () => import_mvc3.Model,
|
|
27
|
+
get: () => import_mvc4.get,
|
|
28
|
+
has: () => import_mvc4.has,
|
|
29
|
+
ref: () => import_mvc4.ref,
|
|
30
|
+
set: () => import_mvc4.set,
|
|
31
|
+
use: () => import_mvc4.use
|
|
33
32
|
});
|
|
34
33
|
module.exports = __toCommonJS(src_exports);
|
|
35
|
-
var
|
|
34
|
+
var import_mvc3 = require("@expressive/mvc");
|
|
36
35
|
|
|
37
36
|
// src/component.ts
|
|
38
37
|
function createComponent(render) {
|
|
@@ -53,31 +52,8 @@ var import_mvc = require("@expressive/mvc");
|
|
|
53
52
|
var import_react = require("react");
|
|
54
53
|
var import_react2 = require("react");
|
|
55
54
|
var Shared = (0, import_react.createContext)(new import_mvc.Context());
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
return (0, import_react.useContext)(Shared);
|
|
59
|
-
}
|
|
60
|
-
function createContext(value, children) {
|
|
61
|
-
return (0, import_react.createElement)(Shared.Provider, { key: value.id, value }, children);
|
|
62
|
-
}
|
|
63
|
-
function usingContext(from, resolve) {
|
|
64
|
-
const waiting = Register.get(from);
|
|
65
|
-
const callback = (context) => {
|
|
66
|
-
resolve(context.get(this));
|
|
67
|
-
};
|
|
68
|
-
if (waiting instanceof import_mvc.Context)
|
|
69
|
-
callback(waiting);
|
|
70
|
-
else if (waiting)
|
|
71
|
-
waiting.push(callback);
|
|
72
|
-
else
|
|
73
|
-
Register.set(from, [callback]);
|
|
74
|
-
}
|
|
75
|
-
function setContext(model, context) {
|
|
76
|
-
const waiting = Register.get(model);
|
|
77
|
-
if (waiting instanceof Array)
|
|
78
|
-
waiting.forEach((cb) => cb(context));
|
|
79
|
-
Register.set(model, context);
|
|
80
|
-
}
|
|
55
|
+
var useContext = () => (0, import_react.useContext)(Shared);
|
|
56
|
+
var createContext = (value, children) => (0, import_react.createElement)(Shared.Provider, { key: value.id, value }, children);
|
|
81
57
|
|
|
82
58
|
// src/useLocal.ts
|
|
83
59
|
function useLocal(argument, repeat) {
|
|
@@ -104,7 +80,6 @@ function useLocal(argument, repeat) {
|
|
|
104
80
|
enabled = true;
|
|
105
81
|
}
|
|
106
82
|
const context = useContext();
|
|
107
|
-
setContext(instance, context);
|
|
108
83
|
context.has(instance);
|
|
109
84
|
if (!local)
|
|
110
85
|
instance.set();
|
|
@@ -179,7 +154,7 @@ function useRemote(argument) {
|
|
|
179
154
|
}
|
|
180
155
|
|
|
181
156
|
// src/index.ts
|
|
182
|
-
var
|
|
157
|
+
var import_mvc4 = require("@expressive/mvc");
|
|
183
158
|
|
|
184
159
|
// src/consumer.ts
|
|
185
160
|
function Consumer(props) {
|
|
@@ -194,30 +169,30 @@ function Consumer(props) {
|
|
|
194
169
|
}
|
|
195
170
|
|
|
196
171
|
// src/provider.ts
|
|
172
|
+
var import_mvc2 = require("@expressive/mvc");
|
|
197
173
|
function Provider(props) {
|
|
198
|
-
let { for:
|
|
174
|
+
let { for: include, use: assign } = props;
|
|
199
175
|
const ambient = useContext();
|
|
200
176
|
const context = (0, import_react2.useMemo)(() => ambient.push(), []);
|
|
201
|
-
|
|
177
|
+
if (typeof include == "function" || include instanceof import_mvc2.Model)
|
|
178
|
+
include = { [""]: include };
|
|
179
|
+
context.include(include, (model, explicit) => {
|
|
202
180
|
if (assign && explicit)
|
|
203
181
|
model.set(assign);
|
|
204
|
-
setContext(model, context);
|
|
205
182
|
});
|
|
206
183
|
(0, import_react2.useEffect)(() => () => context.pop(), []);
|
|
207
184
|
return createContext(context, props.children);
|
|
208
185
|
}
|
|
209
186
|
|
|
210
187
|
// src/index.ts
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
import_mvc2.Model.use = useLocal;
|
|
188
|
+
import_mvc3.Model.as = createComponent;
|
|
189
|
+
import_mvc3.Model.get = useRemote;
|
|
190
|
+
import_mvc3.Model.use = useLocal;
|
|
215
191
|
// Annotate the CommonJS export names for ESM import in node:
|
|
216
192
|
0 && (module.exports = {
|
|
217
193
|
Consumer,
|
|
218
194
|
Model,
|
|
219
195
|
Provider,
|
|
220
|
-
add,
|
|
221
196
|
get,
|
|
222
197
|
has,
|
|
223
198
|
ref,
|
package/dist/index.mjs
CHANGED
|
@@ -20,31 +20,8 @@ import { Context } from "@expressive/mvc";
|
|
|
20
20
|
import { createContext as reactCreateContext, createElement, useContext as reactUseContext } from "react";
|
|
21
21
|
import { useState, useEffect, useMemo } from "react";
|
|
22
22
|
var Shared = reactCreateContext(new Context());
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
return reactUseContext(Shared);
|
|
26
|
-
}
|
|
27
|
-
function createContext(value, children) {
|
|
28
|
-
return createElement(Shared.Provider, { key: value.id, value }, children);
|
|
29
|
-
}
|
|
30
|
-
function usingContext(from, resolve) {
|
|
31
|
-
const waiting = Register.get(from);
|
|
32
|
-
const callback = (context) => {
|
|
33
|
-
resolve(context.get(this));
|
|
34
|
-
};
|
|
35
|
-
if (waiting instanceof Context)
|
|
36
|
-
callback(waiting);
|
|
37
|
-
else if (waiting)
|
|
38
|
-
waiting.push(callback);
|
|
39
|
-
else
|
|
40
|
-
Register.set(from, [callback]);
|
|
41
|
-
}
|
|
42
|
-
function setContext(model, context) {
|
|
43
|
-
const waiting = Register.get(model);
|
|
44
|
-
if (waiting instanceof Array)
|
|
45
|
-
waiting.forEach((cb) => cb(context));
|
|
46
|
-
Register.set(model, context);
|
|
47
|
-
}
|
|
23
|
+
var useContext = () => reactUseContext(Shared);
|
|
24
|
+
var createContext = (value, children) => createElement(Shared.Provider, { key: value.id, value }, children);
|
|
48
25
|
|
|
49
26
|
// src/useLocal.ts
|
|
50
27
|
function useLocal(argument, repeat) {
|
|
@@ -71,7 +48,6 @@ function useLocal(argument, repeat) {
|
|
|
71
48
|
enabled = true;
|
|
72
49
|
}
|
|
73
50
|
const context = useContext();
|
|
74
|
-
setContext(instance, context);
|
|
75
51
|
context.has(instance);
|
|
76
52
|
if (!local)
|
|
77
53
|
instance.set();
|
|
@@ -146,7 +122,7 @@ function useRemote(argument) {
|
|
|
146
122
|
}
|
|
147
123
|
|
|
148
124
|
// src/index.ts
|
|
149
|
-
import {
|
|
125
|
+
import { get, use, ref, set, has } from "@expressive/mvc";
|
|
150
126
|
|
|
151
127
|
// src/consumer.ts
|
|
152
128
|
function Consumer(props) {
|
|
@@ -161,21 +137,22 @@ function Consumer(props) {
|
|
|
161
137
|
}
|
|
162
138
|
|
|
163
139
|
// src/provider.ts
|
|
140
|
+
import { Model } from "@expressive/mvc";
|
|
164
141
|
function Provider(props) {
|
|
165
|
-
let { for:
|
|
142
|
+
let { for: include, use: assign } = props;
|
|
166
143
|
const ambient = useContext();
|
|
167
144
|
const context = useMemo(() => ambient.push(), []);
|
|
168
|
-
|
|
145
|
+
if (typeof include == "function" || include instanceof Model)
|
|
146
|
+
include = { [""]: include };
|
|
147
|
+
context.include(include, (model, explicit) => {
|
|
169
148
|
if (assign && explicit)
|
|
170
149
|
model.set(assign);
|
|
171
|
-
setContext(model, context);
|
|
172
150
|
});
|
|
173
151
|
useEffect(() => () => context.pop(), []);
|
|
174
152
|
return createContext(context, props.children);
|
|
175
153
|
}
|
|
176
154
|
|
|
177
155
|
// src/index.ts
|
|
178
|
-
Model2.at = usingContext;
|
|
179
156
|
Model2.as = createComponent;
|
|
180
157
|
Model2.get = useRemote;
|
|
181
158
|
Model2.use = useLocal;
|
|
@@ -183,7 +160,6 @@ export {
|
|
|
183
160
|
Consumer,
|
|
184
161
|
Model2 as Model,
|
|
185
162
|
Provider,
|
|
186
|
-
add,
|
|
187
163
|
Model2 as default,
|
|
188
164
|
get,
|
|
189
165
|
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.48.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.48.0",
|
|
46
|
+
"gitHead": "1f5ddf82e800cf53bf867ac5e546ad3186ce8bf5"
|
|
47
47
|
}
|