@expressive/react 0.41.0 → 0.42.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 +26 -39
- package/dist/index.mjs +19 -32
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -100,7 +100,7 @@ declare module '@expressive/mvc' {
|
|
|
100
100
|
*/
|
|
101
101
|
function as<T extends Model, P = {}>(this: Model.New<T>, render: (using: T & P) => React.ReactNode): Component<T, P & Model.Values<T>>;
|
|
102
102
|
/** Fetch instance of this class from context. */
|
|
103
|
-
function get<T extends Model>(this: Model.Type<T>,
|
|
103
|
+
function get<T extends Model>(this: Model.Type<T>, passive?: true): T;
|
|
104
104
|
/** Fetch instance of this class optionally. May be undefined, but will never subscribe. */
|
|
105
105
|
function get<T extends Model>(this: Model.Type<T>, required: boolean): T | undefined;
|
|
106
106
|
function get<T extends Model, R>(this: Model.Type<T>, factory: get.Factory<T, Promise<R> | R>): NoVoid<R>;
|
package/dist/index.js
CHANGED
|
@@ -21,18 +21,18 @@ 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_mvc2.Model,
|
|
25
25
|
Provider: () => Provider,
|
|
26
|
-
add: () =>
|
|
27
|
-
default: () =>
|
|
28
|
-
get: () =>
|
|
29
|
-
has: () =>
|
|
30
|
-
ref: () =>
|
|
31
|
-
set: () =>
|
|
32
|
-
use: () =>
|
|
26
|
+
add: () => import_mvc3.add,
|
|
27
|
+
default: () => import_mvc2.Model,
|
|
28
|
+
get: () => import_mvc3.get,
|
|
29
|
+
has: () => import_mvc3.has,
|
|
30
|
+
ref: () => import_mvc3.ref,
|
|
31
|
+
set: () => import_mvc3.set,
|
|
32
|
+
use: () => import_mvc3.use
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(src_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_mvc2 = require("@expressive/mvc");
|
|
36
36
|
|
|
37
37
|
// src/component.ts
|
|
38
38
|
function createComponent(render) {
|
|
@@ -80,27 +80,20 @@ function setContext(model, context) {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// src/useLocal.ts
|
|
83
|
-
var import_mvc2 = require("@expressive/mvc");
|
|
84
|
-
var PENDING = /* @__PURE__ */ new WeakMap();
|
|
85
83
|
function useLocal(argument, repeat) {
|
|
86
84
|
const state = (0, import_react2.useState)(() => {
|
|
87
|
-
let apply;
|
|
88
85
|
let enabled;
|
|
89
86
|
let local;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (!repeat)
|
|
101
|
-
apply = void 0;
|
|
102
|
-
});
|
|
103
|
-
instance.set(0);
|
|
87
|
+
function apply() {
|
|
88
|
+
if (typeof argument == "function")
|
|
89
|
+
argument(this);
|
|
90
|
+
else if (argument) {
|
|
91
|
+
for (const key in this)
|
|
92
|
+
if (argument.hasOwnProperty(key))
|
|
93
|
+
this[key] = argument[key];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const instance = this.new(apply);
|
|
104
97
|
const release = instance.get((current) => {
|
|
105
98
|
local = current;
|
|
106
99
|
if (enabled)
|
|
@@ -108,9 +101,9 @@ function useLocal(argument, repeat) {
|
|
|
108
101
|
});
|
|
109
102
|
return (props) => {
|
|
110
103
|
argument = props;
|
|
111
|
-
if (
|
|
104
|
+
if (repeat && enabled) {
|
|
112
105
|
enabled = false;
|
|
113
|
-
apply();
|
|
106
|
+
apply.call(instance);
|
|
114
107
|
const update = instance.set();
|
|
115
108
|
if (update)
|
|
116
109
|
update.then(() => enabled = true);
|
|
@@ -132,12 +125,6 @@ function useLocal(argument, repeat) {
|
|
|
132
125
|
});
|
|
133
126
|
return state[0](argument);
|
|
134
127
|
}
|
|
135
|
-
import_mvc2.Model.on((_, subject) => {
|
|
136
|
-
const pending = PENDING.get(subject);
|
|
137
|
-
if (pending)
|
|
138
|
-
pending();
|
|
139
|
-
return null;
|
|
140
|
-
});
|
|
141
128
|
|
|
142
129
|
// src/useRemote.ts
|
|
143
130
|
function useRemote(argument) {
|
|
@@ -197,7 +184,7 @@ function useRemote(argument) {
|
|
|
197
184
|
}
|
|
198
185
|
|
|
199
186
|
// src/index.ts
|
|
200
|
-
var
|
|
187
|
+
var import_mvc3 = require("@expressive/mvc");
|
|
201
188
|
|
|
202
189
|
// src/consumer.ts
|
|
203
190
|
function Consumer(props) {
|
|
@@ -229,10 +216,10 @@ function Provider(props) {
|
|
|
229
216
|
}
|
|
230
217
|
|
|
231
218
|
// src/index.ts
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
219
|
+
import_mvc2.Model.at = usingContext;
|
|
220
|
+
import_mvc2.Model.as = createComponent;
|
|
221
|
+
import_mvc2.Model.get = useRemote;
|
|
222
|
+
import_mvc2.Model.use = useLocal;
|
|
236
223
|
// Annotate the CommonJS export names for ESM import in node:
|
|
237
224
|
0 && (module.exports = {
|
|
238
225
|
Consumer,
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { Model as
|
|
2
|
+
import { Model as Model2 } from "@expressive/mvc";
|
|
3
3
|
|
|
4
4
|
// src/component.ts
|
|
5
5
|
function createComponent(render) {
|
|
@@ -47,27 +47,20 @@ function setContext(model, context) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// src/useLocal.ts
|
|
50
|
-
import { Model as Model2 } from "@expressive/mvc";
|
|
51
|
-
var PENDING = /* @__PURE__ */ new WeakMap();
|
|
52
50
|
function useLocal(argument, repeat) {
|
|
53
51
|
const state = useState(() => {
|
|
54
|
-
let apply;
|
|
55
52
|
let enabled;
|
|
56
53
|
let local;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (!repeat)
|
|
68
|
-
apply = void 0;
|
|
69
|
-
});
|
|
70
|
-
instance.set(0);
|
|
54
|
+
function apply() {
|
|
55
|
+
if (typeof argument == "function")
|
|
56
|
+
argument(this);
|
|
57
|
+
else if (argument) {
|
|
58
|
+
for (const key in this)
|
|
59
|
+
if (argument.hasOwnProperty(key))
|
|
60
|
+
this[key] = argument[key];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const instance = this.new(apply);
|
|
71
64
|
const release = instance.get((current) => {
|
|
72
65
|
local = current;
|
|
73
66
|
if (enabled)
|
|
@@ -75,9 +68,9 @@ function useLocal(argument, repeat) {
|
|
|
75
68
|
});
|
|
76
69
|
return (props) => {
|
|
77
70
|
argument = props;
|
|
78
|
-
if (
|
|
71
|
+
if (repeat && enabled) {
|
|
79
72
|
enabled = false;
|
|
80
|
-
apply();
|
|
73
|
+
apply.call(instance);
|
|
81
74
|
const update = instance.set();
|
|
82
75
|
if (update)
|
|
83
76
|
update.then(() => enabled = true);
|
|
@@ -99,12 +92,6 @@ function useLocal(argument, repeat) {
|
|
|
99
92
|
});
|
|
100
93
|
return state[0](argument);
|
|
101
94
|
}
|
|
102
|
-
Model2.on((_, subject) => {
|
|
103
|
-
const pending = PENDING.get(subject);
|
|
104
|
-
if (pending)
|
|
105
|
-
pending();
|
|
106
|
-
return null;
|
|
107
|
-
});
|
|
108
95
|
|
|
109
96
|
// src/useRemote.ts
|
|
110
97
|
function useRemote(argument) {
|
|
@@ -196,16 +183,16 @@ function Provider(props) {
|
|
|
196
183
|
}
|
|
197
184
|
|
|
198
185
|
// src/index.ts
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
186
|
+
Model2.at = usingContext;
|
|
187
|
+
Model2.as = createComponent;
|
|
188
|
+
Model2.get = useRemote;
|
|
189
|
+
Model2.use = useLocal;
|
|
203
190
|
export {
|
|
204
191
|
Consumer,
|
|
205
|
-
|
|
192
|
+
Model2 as Model,
|
|
206
193
|
Provider,
|
|
207
194
|
add,
|
|
208
|
-
|
|
195
|
+
Model2 as default,
|
|
209
196
|
get,
|
|
210
197
|
has,
|
|
211
198
|
ref,
|
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.42.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.42.0",
|
|
46
|
+
"gitHead": "a49c69c9d8cfec956664046510d4e862505cdd1e"
|
|
47
47
|
}
|