@rotorjs/react 0.1.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/DashboardLayoutContext.d.ts +6 -0
- package/dist/DashboardLayoutError.d.ts +6 -0
- package/dist/DashboardTileError.d.ts +5 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.js +146 -91
- package/package.json +2 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ComponentType, PropsWithChildren } from 'react';
|
|
2
|
+
export type DashboardLayoutContextValue = {
|
|
3
|
+
type: string;
|
|
4
|
+
tileContainer?: ComponentType<PropsWithChildren>;
|
|
5
|
+
};
|
|
6
|
+
export declare const DashboardLayoutContext: import('react').Context<DashboardLayoutContextValue>;
|
package/dist/main.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ export * from './Dashboard';
|
|
|
2
2
|
export * from './DashboardContext';
|
|
3
3
|
export * from './DashboardError';
|
|
4
4
|
export * from './DashboardLayout';
|
|
5
|
+
export * from './DashboardLayoutContext';
|
|
6
|
+
export * from './DashboardLayoutError';
|
|
7
|
+
export * from './DashboardTileError';
|
|
5
8
|
export * from './DashboardTiles';
|
|
6
9
|
export * from './getKey';
|
|
7
10
|
export * from './useDashboardState';
|
package/dist/main.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { createContext as e, createElement as t, useContext as n, useEffect as r, useMemo as i, useState as a } from "react";
|
|
2
2
|
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
3
|
-
//#region
|
|
4
|
-
var l =
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var l = Object.create, u = Object.defineProperty, d = Object.getOwnPropertyDescriptor, f = Object.getOwnPropertyNames, p = Object.getPrototypeOf, m = Object.prototype.hasOwnProperty, h = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), g = (e, t, n, r) => {
|
|
5
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = f(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !m.call(e, s) && s !== n && u(e, s, {
|
|
6
|
+
get: ((e) => t[e]).bind(null, s),
|
|
7
|
+
enumerable: !(r = d(t, s)) || r.enumerable
|
|
8
|
+
});
|
|
9
|
+
return e;
|
|
10
|
+
}, _ = (e, t, n) => (n = e == null ? {} : l(p(e)), g(t || !e || !e.__esModule ? u(n, "default", {
|
|
11
|
+
value: e,
|
|
12
|
+
enumerable: !0
|
|
13
|
+
}) : n, e)), v = class extends Event {
|
|
5
14
|
emitter;
|
|
6
15
|
constructor(e, t) {
|
|
7
16
|
super(e, t);
|
|
8
17
|
}
|
|
9
|
-
},
|
|
18
|
+
}, y = class extends v {
|
|
10
19
|
#e;
|
|
11
20
|
constructor(e) {
|
|
12
21
|
super("action"), this.#e = e;
|
|
@@ -14,37 +23,37 @@ var l = class extends Event {
|
|
|
14
23
|
get action() {
|
|
15
24
|
return this.#e;
|
|
16
25
|
}
|
|
17
|
-
},
|
|
18
|
-
for (let e = 0; e < 256; ++e)
|
|
26
|
+
}, b = [];
|
|
27
|
+
for (let e = 0; e < 256; ++e) b.push((e + 256).toString(16).slice(1));
|
|
19
28
|
//#endregion
|
|
20
29
|
//#region node_modules/uuid/dist/stringify.js
|
|
21
|
-
var
|
|
22
|
-
for (let e = 0; e < 256; ++e)
|
|
23
|
-
function
|
|
24
|
-
return (
|
|
30
|
+
var x = [];
|
|
31
|
+
for (let e = 0; e < 256; ++e) x.push((e + 256).toString(16).slice(1));
|
|
32
|
+
function S(e, t = 0) {
|
|
33
|
+
return (x[e[t + 0]] + x[e[t + 1]] + x[e[t + 2]] + x[e[t + 3]] + "-" + x[e[t + 4]] + x[e[t + 5]] + "-" + x[e[t + 6]] + x[e[t + 7]] + "-" + x[e[t + 8]] + x[e[t + 9]] + "-" + x[e[t + 10]] + x[e[t + 11]] + x[e[t + 12]] + x[e[t + 13]] + x[e[t + 14]] + x[e[t + 15]]).toLowerCase();
|
|
25
34
|
}
|
|
26
35
|
//#endregion
|
|
27
36
|
//#region node_modules/uuid/dist/rng.js
|
|
28
|
-
var
|
|
29
|
-
function
|
|
30
|
-
return crypto.getRandomValues(
|
|
37
|
+
var C = new Uint8Array(16);
|
|
38
|
+
function w() {
|
|
39
|
+
return crypto.getRandomValues(C);
|
|
31
40
|
}
|
|
32
41
|
//#endregion
|
|
33
42
|
//#region node_modules/uuid/dist/v7.js
|
|
34
|
-
var
|
|
35
|
-
function
|
|
43
|
+
var T = {};
|
|
44
|
+
function E(e, t, n) {
|
|
36
45
|
let r;
|
|
37
|
-
if (e) r =
|
|
46
|
+
if (e) r = O(e.random ?? e.rng?.() ?? w(), e.msecs, e.seq, t, n);
|
|
38
47
|
else {
|
|
39
|
-
let e = Date.now(), i =
|
|
40
|
-
|
|
48
|
+
let e = Date.now(), i = w();
|
|
49
|
+
D(T, e, i), r = O(i, T.msecs, T.seq, t, n);
|
|
41
50
|
}
|
|
42
|
-
return t ??
|
|
51
|
+
return t ?? S(r);
|
|
43
52
|
}
|
|
44
|
-
function
|
|
53
|
+
function D(e, t, n) {
|
|
45
54
|
return e.msecs ??= -Infinity, e.seq ??= 0, t > e.msecs ? (e.seq = n[6] << 23 | n[7] << 16 | n[8] << 8 | n[9], e.msecs = t) : (e.seq = e.seq + 1 | 0, e.seq === 0 && e.msecs++), e;
|
|
46
55
|
}
|
|
47
|
-
function
|
|
56
|
+
function O(e, t, n, r, i = 0) {
|
|
48
57
|
if (e.length < 16) throw Error("Random bytes length must be >= 16");
|
|
49
58
|
if (!r) r = new Uint8Array(16), i = 0;
|
|
50
59
|
else if (i < 0 || i + 16 > r.length) throw RangeError(`UUID byte range ${i}:${i + 15} is out of buffer bounds`);
|
|
@@ -52,81 +61,102 @@ function y(e, t, n, r, i = 0) {
|
|
|
52
61
|
}
|
|
53
62
|
//#endregion
|
|
54
63
|
//#region lib/DashboardContext.ts
|
|
55
|
-
var
|
|
64
|
+
var k = e(void 0);
|
|
56
65
|
//#endregion
|
|
57
66
|
//#region lib/DashboardError.tsx
|
|
58
|
-
function
|
|
67
|
+
function A({ error: e }) {
|
|
59
68
|
throw e;
|
|
60
69
|
}
|
|
61
70
|
//#endregion
|
|
71
|
+
//#region lib/DashboardLayoutContext.ts
|
|
72
|
+
var j = e(void 0);
|
|
73
|
+
//#endregion
|
|
62
74
|
//#region lib/getKey.ts
|
|
63
|
-
function
|
|
75
|
+
function M(e, t = 0) {
|
|
64
76
|
return `${encodeURIComponent(e.type)}:${e.id ? `id:${encodeURIComponent(e.id)}` : `idx:${t}`}`;
|
|
65
77
|
}
|
|
66
78
|
//#endregion
|
|
79
|
+
//#region lib/DashboardLayoutError.tsx
|
|
80
|
+
var N = { type: "error" };
|
|
81
|
+
function P({ id: e, error: r, children: i }) {
|
|
82
|
+
let { layouts: a } = n(k), o = a.error ?? A, c = {
|
|
83
|
+
type: "error",
|
|
84
|
+
id: e,
|
|
85
|
+
error: r
|
|
86
|
+
};
|
|
87
|
+
return /* @__PURE__ */ s(j.Provider, {
|
|
88
|
+
value: N,
|
|
89
|
+
children: /* @__PURE__ */ t(o, {
|
|
90
|
+
...c,
|
|
91
|
+
key: M(c)
|
|
92
|
+
}, i)
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
67
96
|
//#region lib/DashboardLayout.tsx
|
|
68
|
-
function
|
|
69
|
-
let { layouts: a, defaultLayout: o } = n(
|
|
70
|
-
error:
|
|
97
|
+
function F({ layout: e, children: r }) {
|
|
98
|
+
let { layouts: a, defaultLayout: o } = n(k), c = i(() => ({
|
|
99
|
+
error: A,
|
|
71
100
|
...a
|
|
72
|
-
}), [a]),
|
|
73
|
-
if (!
|
|
74
|
-
let
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
101
|
+
}), [a]), l = e ?? o, u = l?.type, d = i(() => ({ type: u }), [u]);
|
|
102
|
+
if (!l?.type) return null;
|
|
103
|
+
let f = c[l.type];
|
|
104
|
+
return f ? /* @__PURE__ */ s(j.Provider, {
|
|
105
|
+
value: d,
|
|
106
|
+
children: /* @__PURE__ */ t(f, {
|
|
107
|
+
...l,
|
|
108
|
+
key: M(l)
|
|
109
|
+
}, r)
|
|
110
|
+
}) : /* @__PURE__ */ s(P, {
|
|
111
|
+
error: `Invalid layout type "${l.type}"`,
|
|
112
|
+
children: r
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region lib/DashboardTileError.tsx
|
|
117
|
+
function I({ id: e, error: r }) {
|
|
118
|
+
let { tiles: i } = n(k), a = i.error ?? A, o = {
|
|
119
|
+
type: "error",
|
|
120
|
+
id: e,
|
|
121
|
+
error: r
|
|
122
|
+
};
|
|
123
|
+
return /* @__PURE__ */ t(a, {
|
|
124
|
+
...o,
|
|
125
|
+
key: M(o)
|
|
126
|
+
});
|
|
89
127
|
}
|
|
90
128
|
//#endregion
|
|
91
129
|
//#region lib/DashboardTiles.tsx
|
|
92
|
-
function
|
|
93
|
-
let { tiles: r } = n(
|
|
94
|
-
error:
|
|
130
|
+
function L({ content: e }) {
|
|
131
|
+
let { tiles: r } = n(k), a = i(() => ({
|
|
132
|
+
error: A,
|
|
95
133
|
...r
|
|
96
134
|
}), [r]);
|
|
97
135
|
return /* @__PURE__ */ s(o, { children: e.map((e, n) => {
|
|
98
|
-
if (!e) return null;
|
|
136
|
+
if (!e?.type) return null;
|
|
99
137
|
let r = a[e.type];
|
|
100
|
-
|
|
101
|
-
let r = a.error;
|
|
102
|
-
return /* @__PURE__ */ t(r, {
|
|
103
|
-
type: "error",
|
|
104
|
-
error: `Invalid tile type "${e.type}"`,
|
|
105
|
-
key: S(e, n)
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
return /* @__PURE__ */ t(r, {
|
|
138
|
+
return r ? /* @__PURE__ */ t(r, {
|
|
109
139
|
...e,
|
|
110
|
-
key:
|
|
111
|
-
});
|
|
140
|
+
key: M(e, n)
|
|
141
|
+
}) : /* @__PURE__ */ s(I, { error: `Invalid tile type "${e.type}"` }, M({ type: "error" }, n));
|
|
112
142
|
}) });
|
|
113
143
|
}
|
|
114
144
|
//#endregion
|
|
115
145
|
//#region lib/Dashboard.tsx
|
|
116
|
-
function
|
|
117
|
-
let [
|
|
146
|
+
function R({ engine: e, initialVars: t, initialFacts: n, layouts: o, defaultLayout: l, tiles: u, layout: d, content: f, children: p }) {
|
|
147
|
+
let [m] = a(t ?? {}), [h, g] = a(m), [_] = a(n ?? {}), [v, b] = a(_);
|
|
118
148
|
r(() => {
|
|
119
|
-
let t =
|
|
120
|
-
return Object.entries(
|
|
121
|
-
let a = new
|
|
149
|
+
let t = E(), n = new AbortController(), r = n.signal;
|
|
150
|
+
return Object.entries(m).forEach(([n, { value: r, exposed: i }]) => {
|
|
151
|
+
let a = new y({
|
|
122
152
|
type: "var",
|
|
123
153
|
name: n,
|
|
124
154
|
value: r,
|
|
125
155
|
exposed: i
|
|
126
156
|
});
|
|
127
157
|
a.emitter = t, e.dispatchEvent(a);
|
|
128
|
-
}), Object.entries(
|
|
129
|
-
let i = new
|
|
158
|
+
}), Object.entries(_).forEach(([n, { value: r }]) => {
|
|
159
|
+
let i = new y({
|
|
130
160
|
type: "fact",
|
|
131
161
|
name: n,
|
|
132
162
|
value: r
|
|
@@ -137,7 +167,7 @@ function T({ engine: e, initialVars: t, initialFacts: n, layouts: o, defaultLayo
|
|
|
137
167
|
let n = e.action;
|
|
138
168
|
switch (n.type) {
|
|
139
169
|
case "var":
|
|
140
|
-
|
|
170
|
+
g((e) => {
|
|
141
171
|
let t = e[n.name];
|
|
142
172
|
return Object.hasOwn(e, n.name) && t.value === n.value && t.exposed === (n.exposed ?? !1) ? e : {
|
|
143
173
|
...e,
|
|
@@ -148,7 +178,7 @@ function T({ engine: e, initialVars: t, initialFacts: n, layouts: o, defaultLayo
|
|
|
148
178
|
};
|
|
149
179
|
});
|
|
150
180
|
return;
|
|
151
|
-
case "fact":
|
|
181
|
+
case "fact": b((e) => {
|
|
152
182
|
let t = e[n.name];
|
|
153
183
|
return Object.hasOwn(e, n.name) && t.value === n.value ? e : {
|
|
154
184
|
...e,
|
|
@@ -161,44 +191,69 @@ function T({ engine: e, initialVars: t, initialFacts: n, layouts: o, defaultLayo
|
|
|
161
191
|
};
|
|
162
192
|
}, [
|
|
163
193
|
e,
|
|
164
|
-
|
|
165
|
-
|
|
194
|
+
m,
|
|
195
|
+
_
|
|
166
196
|
]);
|
|
167
|
-
let
|
|
197
|
+
let x = i(() => ({
|
|
168
198
|
engine: e,
|
|
169
|
-
vars:
|
|
170
|
-
facts:
|
|
199
|
+
vars: h,
|
|
200
|
+
facts: v,
|
|
171
201
|
layouts: o,
|
|
172
202
|
defaultLayout: l,
|
|
173
|
-
tiles:
|
|
203
|
+
tiles: u
|
|
174
204
|
}), [
|
|
175
205
|
e,
|
|
176
|
-
|
|
177
|
-
|
|
206
|
+
h,
|
|
207
|
+
v,
|
|
178
208
|
o,
|
|
179
209
|
l,
|
|
180
|
-
|
|
210
|
+
u
|
|
181
211
|
]);
|
|
182
|
-
return /* @__PURE__ */ s(
|
|
183
|
-
value:
|
|
184
|
-
children: /* @__PURE__ */ c(
|
|
185
|
-
layout:
|
|
186
|
-
children: [/* @__PURE__ */ s(
|
|
212
|
+
return /* @__PURE__ */ s(k.Provider, {
|
|
213
|
+
value: x,
|
|
214
|
+
children: /* @__PURE__ */ c(F, {
|
|
215
|
+
layout: d,
|
|
216
|
+
children: [/* @__PURE__ */ s(L, { content: f }), p]
|
|
187
217
|
})
|
|
188
218
|
});
|
|
189
219
|
}
|
|
190
220
|
//#endregion
|
|
191
221
|
//#region lib/useDashboardState.ts
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
222
|
+
var z = /* @__PURE__ */ _((/* @__PURE__ */ h(((e, t) => {
|
|
223
|
+
t.exports = function e(t, n) {
|
|
224
|
+
if (t === n) return !0;
|
|
225
|
+
if (t && n && typeof t == "object" && typeof n == "object") {
|
|
226
|
+
if (t.constructor !== n.constructor) return !1;
|
|
227
|
+
var r, i, a;
|
|
228
|
+
if (Array.isArray(t)) {
|
|
229
|
+
if (r = t.length, r != n.length) return !1;
|
|
230
|
+
for (i = r; i-- !== 0;) if (!e(t[i], n[i])) return !1;
|
|
231
|
+
return !0;
|
|
232
|
+
}
|
|
233
|
+
if (t.constructor === RegExp) return t.source === n.source && t.flags === n.flags;
|
|
234
|
+
if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === n.valueOf();
|
|
235
|
+
if (t.toString !== Object.prototype.toString) return t.toString() === n.toString();
|
|
236
|
+
if (a = Object.keys(t), r = a.length, r !== Object.keys(n).length) return !1;
|
|
237
|
+
for (i = r; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(n, a[i])) return !1;
|
|
238
|
+
for (i = r; i-- !== 0;) {
|
|
239
|
+
var o = a[i];
|
|
240
|
+
if (!e(t[o], n[o])) return !1;
|
|
241
|
+
}
|
|
242
|
+
return !0;
|
|
243
|
+
}
|
|
244
|
+
return t !== t && n !== n;
|
|
245
|
+
};
|
|
246
|
+
})))(), 1);
|
|
247
|
+
function B(e, t = []) {
|
|
248
|
+
let { engine: i } = n(k), [o, s] = a(e), [c, l] = a(t);
|
|
249
|
+
return (0, z.default)(e, o) || s(o), r(() => {
|
|
250
|
+
let e = E(), t = new AbortController(), n = t.signal;
|
|
251
|
+
return i.addEventListener("state", (t) => {
|
|
252
|
+
t.id === e && l(t.state);
|
|
253
|
+
}, { signal: n }), i.registerReducer(e, o), () => {
|
|
254
|
+
t.abort(), i.removeReducer(e);
|
|
200
255
|
};
|
|
201
|
-
}, [
|
|
256
|
+
}, [o, i]), c;
|
|
202
257
|
}
|
|
203
258
|
//#endregion
|
|
204
|
-
export {
|
|
259
|
+
export { R as Dashboard, k as DashboardContext, A as DashboardError, F as DashboardLayout, j as DashboardLayoutContext, P as DashboardLayoutError, I as DashboardTileError, L as DashboardTiles, M as getKey, B as useDashboardState };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rotorjs/react",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Rotor",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Aaron Burmeister"
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"@rotorjs/dashboards": "^0.12.0"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
+
"fast-deep-equal": "^3.1.3",
|
|
73
74
|
"uuid": "^14.0.0"
|
|
74
75
|
}
|
|
75
76
|
}
|