@virtuoso.dev/reactive-engine-react 0.2.0 → 0.2.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/dist/index.js +54 -53
- package/package.json +31 -28
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Engine as d } from "@virtuoso.dev/reactive-engine-core";
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
3
2
|
import * as s from "react";
|
|
3
|
+
import { Engine as p } from "@virtuoso.dev/reactive-engine-core";
|
|
4
4
|
import h from "tiny-invariant";
|
|
5
|
-
const
|
|
5
|
+
const o = typeof document < "u" ? s.useLayoutEffect : s.useEffect, y = Symbol("engineRefInternal");
|
|
6
6
|
function x() {
|
|
7
7
|
let e = null;
|
|
8
8
|
const n = /* @__PURE__ */ new Set();
|
|
@@ -24,7 +24,7 @@ function x() {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function _() {
|
|
28
28
|
const [e] = s.useState(() => x());
|
|
29
29
|
return e;
|
|
30
30
|
}
|
|
@@ -49,8 +49,7 @@ function I(e, n) {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
function m(e) {
|
|
52
|
-
|
|
53
|
-
return ((n = f.get(e)) == null ? void 0 : n.engine) ?? null;
|
|
52
|
+
return f.get(e)?.engine ?? null;
|
|
54
53
|
}
|
|
55
54
|
const V = s.createContext(null);
|
|
56
55
|
function a() {
|
|
@@ -67,18 +66,18 @@ function w(e) {
|
|
|
67
66
|
() => n.getValue(e)
|
|
68
67
|
);
|
|
69
68
|
}
|
|
70
|
-
function
|
|
69
|
+
function F(e) {
|
|
71
70
|
const n = a();
|
|
72
71
|
n.register(e);
|
|
73
72
|
const [t, r] = s.useState(() => n.getValue(e));
|
|
74
|
-
return
|
|
73
|
+
return o(() => n.sub(e, r), [n, e]), t;
|
|
75
74
|
}
|
|
76
|
-
const v = "useSyncExternalStore" in s ? w :
|
|
77
|
-
function
|
|
75
|
+
const v = "useSyncExternalStore" in s ? w : F;
|
|
76
|
+
function j(...e) {
|
|
78
77
|
const n = a(), t = s.useMemo(() => n.combineCells(e), [n, ...e]);
|
|
79
78
|
return v(t);
|
|
80
79
|
}
|
|
81
|
-
function
|
|
80
|
+
function P(e) {
|
|
82
81
|
const n = a();
|
|
83
82
|
return n.register(e), s.useCallback(
|
|
84
83
|
(t) => {
|
|
@@ -87,13 +86,15 @@ function N(e) {
|
|
|
87
86
|
[n, e]
|
|
88
87
|
);
|
|
89
88
|
}
|
|
90
|
-
function
|
|
91
|
-
return [v(e),
|
|
89
|
+
function k(e) {
|
|
90
|
+
return [v(e), P(e)];
|
|
92
91
|
}
|
|
93
92
|
function C(e) {
|
|
94
|
-
const n = typeof e != "string", t = n ? null : e, r = n ? e : null, [u, l] = s.useState(
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
const n = typeof e != "string", t = n ? null : e, r = n ? e : null, [u, l] = s.useState(
|
|
94
|
+
() => t !== null ? m(t) : null
|
|
95
|
+
);
|
|
96
|
+
o(() => {
|
|
97
|
+
if (t === null) {
|
|
97
98
|
l(null);
|
|
98
99
|
return;
|
|
99
100
|
}
|
|
@@ -101,21 +102,21 @@ function C(e) {
|
|
|
101
102
|
l(m(t));
|
|
102
103
|
});
|
|
103
104
|
}, [t]);
|
|
104
|
-
const [
|
|
105
|
-
return
|
|
105
|
+
const [c, i] = s.useState(() => r ? r.current : null);
|
|
106
|
+
return o(() => {
|
|
106
107
|
if (!r) {
|
|
107
|
-
|
|
108
|
+
i(null);
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
111
|
const b = E(r);
|
|
111
|
-
return
|
|
112
|
-
|
|
112
|
+
return i(r.current), b.subscribe(() => {
|
|
113
|
+
i(r.current);
|
|
113
114
|
});
|
|
114
|
-
}, [r]), n ?
|
|
115
|
+
}, [r]), n ? c : u;
|
|
115
116
|
}
|
|
116
|
-
function
|
|
117
|
+
function N(e, n) {
|
|
117
118
|
const t = C(n), [r, u] = s.useState(() => t ? t.getValue(e) : void 0);
|
|
118
|
-
return
|
|
119
|
+
return o(() => {
|
|
119
120
|
if (!t) {
|
|
120
121
|
u(void 0);
|
|
121
122
|
return;
|
|
@@ -123,9 +124,9 @@ function L(e, n) {
|
|
|
123
124
|
return t.register(e), u(t.getValue(e)), t.sub(e, u);
|
|
124
125
|
}, [t, e]), r;
|
|
125
126
|
}
|
|
126
|
-
function
|
|
127
|
+
function L(e, n) {
|
|
127
128
|
const t = C(n);
|
|
128
|
-
return
|
|
129
|
+
return o(() => {
|
|
129
130
|
t && t.register(e);
|
|
130
131
|
}, [t, e]), s.useCallback(
|
|
131
132
|
(r) => {
|
|
@@ -134,52 +135,52 @@ function M(e, n) {
|
|
|
134
135
|
[t, e]
|
|
135
136
|
);
|
|
136
137
|
}
|
|
137
|
-
function
|
|
138
|
-
return [
|
|
138
|
+
function A(e, n) {
|
|
139
|
+
return [N(e, n), L(e, n)];
|
|
139
140
|
}
|
|
140
|
-
function
|
|
141
|
-
const { cells: n, engineSource: t } = e, r = C(t), u = s.useMemo(() => r ? r.combineCells(n) : null, [r, ...n]), [l,
|
|
141
|
+
function G(e) {
|
|
142
|
+
const { cells: n, engineSource: t } = e, r = C(t), u = s.useMemo(() => r ? r.combineCells(n) : null, [r, ...n]), [l, c] = s.useState(
|
|
142
143
|
() => r && u ? r.getValue(u) : void 0
|
|
143
144
|
);
|
|
144
|
-
return
|
|
145
|
+
return o(() => {
|
|
145
146
|
if (!r || !u) {
|
|
146
|
-
|
|
147
|
+
c(void 0);
|
|
147
148
|
return;
|
|
148
149
|
}
|
|
149
|
-
return r.register(u),
|
|
150
|
+
return r.register(u), c(r.getValue(u)), r.sub(u, c);
|
|
150
151
|
}, [r, u]), l;
|
|
151
152
|
}
|
|
152
|
-
const
|
|
153
|
+
const O = ({
|
|
153
154
|
children: e,
|
|
154
155
|
engineId: n,
|
|
155
156
|
engineRef: t,
|
|
156
157
|
initFn: r,
|
|
157
158
|
initWith: u,
|
|
158
159
|
updateDeps: l,
|
|
159
|
-
updateFn:
|
|
160
|
+
updateFn: c
|
|
160
161
|
}) => {
|
|
161
|
-
const [
|
|
162
|
-
return
|
|
163
|
-
const g = new
|
|
164
|
-
return b(g), r
|
|
165
|
-
n && R(n, null), t && E(t).set(null), g.dispose();
|
|
162
|
+
const [i, b] = s.useState(null);
|
|
163
|
+
return o(() => {
|
|
164
|
+
const g = new p(u, n);
|
|
165
|
+
return b(g), r?.(g), n !== void 0 && R(n, g), t && E(t).set(g), () => {
|
|
166
|
+
n !== void 0 && R(n, null), t && E(t).set(null), g.dispose();
|
|
166
167
|
};
|
|
167
|
-
}, [u, n, t]),
|
|
168
|
-
|
|
169
|
-
}, [
|
|
168
|
+
}, [u, n, t]), o(() => {
|
|
169
|
+
i && c?.(i);
|
|
170
|
+
}, [i, ...l ?? []]), i && /* @__PURE__ */ d(V.Provider, { value: i, children: e });
|
|
170
171
|
};
|
|
171
172
|
export {
|
|
172
173
|
V as EngineContext,
|
|
173
|
-
|
|
174
|
-
|
|
174
|
+
O as EngineProvider,
|
|
175
|
+
k as useCell,
|
|
175
176
|
v as useCellValue,
|
|
176
|
-
|
|
177
|
+
j as useCellValues,
|
|
177
178
|
a as useEngine,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
179
|
+
_ as useEngineRef,
|
|
180
|
+
o as useIsomorphicLayoutEffect,
|
|
181
|
+
P as usePublisher,
|
|
182
|
+
A as useRemoteCell,
|
|
183
|
+
N as useRemoteCellValue,
|
|
184
|
+
G as useRemoteCellValues,
|
|
185
|
+
L as useRemotePublisher
|
|
185
186
|
};
|
package/package.json
CHANGED
|
@@ -1,59 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virtuoso.dev/reactive-engine-react",
|
|
3
|
+
"version": "0.2.1",
|
|
3
4
|
"private": false,
|
|
4
|
-
"
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/petyosi/react-virtuoso.git",
|
|
9
|
+
"directory": "packages/reactive-engine-react"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
5
14
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
"module": "dist/index.js",
|
|
15
|
+
"sideEffects": false,
|
|
8
16
|
"main": "dist/index.js",
|
|
17
|
+
"module": "dist/index.js",
|
|
9
18
|
"types": "dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
10
25
|
"publishConfig": {
|
|
11
26
|
"access": "public",
|
|
12
27
|
"provenance": true
|
|
13
28
|
},
|
|
14
|
-
"repository": {
|
|
15
|
-
"type": "git",
|
|
16
|
-
"url": "git+https://github.com/petyosi/react-virtuoso.git",
|
|
17
|
-
"directory": "packages/reactive-engine-react"
|
|
18
|
-
},
|
|
19
|
-
"license": "MIT",
|
|
20
29
|
"dependencies": {
|
|
21
30
|
"tiny-invariant": "^1.3.3"
|
|
22
31
|
},
|
|
23
|
-
"peerDependencies": {
|
|
24
|
-
"@virtuoso.dev/reactive-engine-core": ">=0.0.4",
|
|
25
|
-
"react": ">= 18",
|
|
26
|
-
"react-dom": ">= 18"
|
|
27
|
-
},
|
|
28
32
|
"devDependencies": {
|
|
29
|
-
"@types/node": "^22.
|
|
33
|
+
"@types/node": "^22.19.1",
|
|
30
34
|
"@types/react": "^19.2.7",
|
|
31
35
|
"@types/react-dom": "^19.2.3",
|
|
36
|
+
"@vitejs/plugin-react": "^4.7.0",
|
|
32
37
|
"@vitest/browser": "^4.0.16",
|
|
33
38
|
"@vitest/browser-playwright": "^4.0.16",
|
|
34
|
-
"
|
|
35
|
-
"eslint": "^9.24.0",
|
|
36
|
-
"playwright": "^1.33.0",
|
|
37
|
-
"prettier": "^3.5.3",
|
|
39
|
+
"playwright": "^1.58.2",
|
|
38
40
|
"react": "^19.2.3",
|
|
39
41
|
"react-dom": "^19.2.3",
|
|
40
|
-
"typescript": "
|
|
42
|
+
"typescript": "^5.9.3",
|
|
41
43
|
"vite": "^6.4.1",
|
|
42
44
|
"vite-plugin-dts": "^4.5.4",
|
|
43
45
|
"vitest": "^4.0.16",
|
|
44
46
|
"vitest-browser-react": "^2.0.2",
|
|
45
|
-
"@virtuoso.dev/
|
|
46
|
-
|
|
47
|
+
"@virtuoso.dev/reactive-engine-core": "0.0.5"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@virtuoso.dev/reactive-engine-core": ">=0.0.5",
|
|
51
|
+
"react": ">= 18",
|
|
52
|
+
"react-dom": ">= 18"
|
|
47
53
|
},
|
|
48
|
-
"files": [
|
|
49
|
-
"dist"
|
|
50
|
-
],
|
|
51
54
|
"scripts": {
|
|
52
55
|
"build": "tsc && vite build",
|
|
53
56
|
"test": "vitest --run --passWithNoTests --browser.headless",
|
|
54
|
-
"lint": "
|
|
57
|
+
"lint": "oxlint --type-aware --type-check",
|
|
55
58
|
"typecheck": "tsgo --noEmit",
|
|
56
|
-
"format": "
|
|
57
|
-
"format:check": "
|
|
59
|
+
"format": "oxfmt",
|
|
60
|
+
"format:check": "oxfmt --check"
|
|
58
61
|
}
|
|
59
62
|
}
|