@ea-lab/reactive-json 1.4.0 → 2.0.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/component/action/CustomEventListener.js +3 -2
- package/dist/component/action/ReactOnEvent.js +6 -5
- package/dist/component/attributeTransformer/setAttributeValue.js +20 -19
- package/dist/component/attributeTransformer/toggleAttributeValue.js +15 -14
- package/dist/component/attributeTransformer/unsetAttributeValue.js +8 -7
- package/dist/component/element/debug/VariablesDebug/VariablesDebug.js +74 -60
- package/dist/component/element/html/LabelFromValue.js +30 -18
- package/dist/component/element/index.js +28 -26
- package/dist/component/element/special/DataFilter.js +49 -40
- package/dist/component/element/special/DataSync.js +100 -0
- package/dist/component/element/special/index.js +15 -13
- package/dist/component/index.js +57 -55
- package/dist/component/reaction/fetchData.js +1 -1
- package/dist/component/reaction/index.js +1 -1
- package/dist/component/reaction/submitData.js +1 -1
- package/dist/component/reaction/utility/httpRequestCommon.js +118 -5
- package/dist/component/reaction/utility/index.js +1 -1
- package/dist/engine/DataStore.js +120 -0
- package/dist/engine/ReactiveJsonRoot.js +218 -277
- package/dist/engine/StoreContext.js +17 -0
- package/dist/engine/View.js +94 -58
- package/dist/engine/hook/useReactiveData.js +9 -0
- package/dist/engine/index.js +53 -45
- package/dist/engine/utility/formElementsCommon.js +36 -23
- package/dist/{httpRequestCommon-C7MsJIKA.js → index-BUPRVmV-.js} +616 -733
- package/dist/index-DJuOXIM5.js +25 -0
- package/dist/main.js +156 -146
- package/package.json +1 -1
- package/dist/index-Ya6_R5yr.js +0 -23
|
@@ -1,375 +1,316 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { a as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { EventDispatcherProvider as
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
import { jsx as p, jsxs as H, Fragment as st } from "react/jsx-runtime";
|
|
2
|
+
import { a as J } from "../index-BUPRVmV-.js";
|
|
3
|
+
import { useRef as K, useState as Q, useEffect as V, useMemo as it } from "react";
|
|
4
|
+
import { r as ct } from "../dnd-kit-sortable-tree.esm-Cz1RJyIg.js";
|
|
5
|
+
import { coreComponentsPlugin as X } from "../coreComponentsPlugin.js";
|
|
6
|
+
import { mergeComponentCollections as pt } from "./ComponentCollector.js";
|
|
7
|
+
import { DataStore as lt } from "./DataStore.js";
|
|
8
|
+
import { EventDispatcherProvider as dt } from "./EventDispatcherProvider.js";
|
|
9
|
+
import { GlobalDataContext as ut } from "./GlobalDataContext.js";
|
|
10
|
+
import mt from "./ParsingDebugDisplay/ParsingDebugDisplay.js";
|
|
11
|
+
import { StoreContext as ft } from "./StoreContext.js";
|
|
12
|
+
import { TemplateContext as gt } from "./TemplateContext.js";
|
|
13
|
+
import { dataLocationToPath as ht } from "./TemplateSystem.js";
|
|
14
|
+
import { useReactiveData as Pt } from "./hook/useReactiveData.js";
|
|
15
|
+
import { alterData as yt } from "./utility/alterData.js";
|
|
16
|
+
import { applyDataMapping as Dt } from "./utility/dataMappingSystem.js";
|
|
17
|
+
import { parseRjBuild as wt } from "./utility/parseRjBuild.js";
|
|
18
|
+
import { stringToBoolean as bt } from "./utility/stringToBoolean.js";
|
|
19
|
+
import { View as Ct } from "./View.js";
|
|
20
|
+
const St = ({ Wrapper: m }) => {
|
|
21
|
+
const E = Pt("");
|
|
22
|
+
return /* @__PURE__ */ p(m, { children: JSON.stringify(E, null, " ") });
|
|
23
|
+
}, xt = ({
|
|
24
|
+
dataOverride: m,
|
|
25
|
+
dataFetchMethod: E,
|
|
26
|
+
dataUrl: G,
|
|
27
|
+
debugMode: Y,
|
|
28
|
+
DebugModeContentWrapper: L,
|
|
29
|
+
DebugModeDataWrapper: O,
|
|
30
|
+
DebugModeRootWrapper: Z,
|
|
31
|
+
headersForData: z,
|
|
32
|
+
headersForRjBuild: s,
|
|
33
|
+
maybeRawAppData: I,
|
|
34
|
+
maybeRawAppRjBuild: w,
|
|
35
|
+
plugins: N,
|
|
31
36
|
rjBuildFetchMethod: b,
|
|
32
37
|
rjBuildUrl: f,
|
|
33
|
-
upstreamUpdateCallbacks:
|
|
38
|
+
upstreamUpdateCallbacks: R
|
|
34
39
|
}) => {
|
|
35
|
-
const
|
|
36
|
-
|
|
40
|
+
const g = [];
|
|
41
|
+
E && (g.push({
|
|
37
42
|
deprecatedProperty: "dataFetchMethod",
|
|
38
43
|
newProperty: "rjBuildFetchMethod"
|
|
39
|
-
}), b =
|
|
44
|
+
}), b = E), G && (g.push({
|
|
40
45
|
deprecatedProperty: "dataUrl",
|
|
41
46
|
newProperty: "rjBuildUrl"
|
|
42
|
-
}), f =
|
|
47
|
+
}), f = G), z && (g.push({
|
|
43
48
|
deprecatedProperty: "headersForData",
|
|
44
49
|
newProperty: "headersForRjBuild"
|
|
45
|
-
}),
|
|
50
|
+
}), s = z), I && (g.push({
|
|
46
51
|
deprecatedProperty: "maybeRawAppData",
|
|
47
52
|
newProperty: "maybeRawAppRjBuild"
|
|
48
|
-
}),
|
|
49
|
-
"A ReactiveJsonRoot component got the following deprecated properties that must be replaced: " +
|
|
53
|
+
}), w = I), g.length > 0 && console.warn(
|
|
54
|
+
"A ReactiveJsonRoot component got the following deprecated properties that must be replaced: " + g.map((t) => t.deprecatedProperty + " -> " + t.newProperty).join(", ")
|
|
50
55
|
);
|
|
51
|
-
const [
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return t;
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
{ updateId: 0, realCurrentData: {} }
|
|
63
|
-
), [at, ot] = w({}), [nt, Q] = w({}), [st, Y] = w([]), [I, T] = w(() => {
|
|
64
|
-
if (d)
|
|
65
|
-
return typeof d == "string" ? d : JSON.stringify(d);
|
|
66
|
-
}), [V, Z] = w(null), n = ft(null);
|
|
67
|
-
q(() => () => {
|
|
68
|
-
typeof document < "u" && n.current && n.current.parentNode && (n.current.parentNode.removeChild(n.current), n.current = null);
|
|
56
|
+
const a = K(new lt({})).current, [d, C] = Q({
|
|
57
|
+
templates: {},
|
|
58
|
+
renderView: {},
|
|
59
|
+
items: [],
|
|
60
|
+
rawAppRjBuild: null
|
|
61
|
+
}), [T, M] = Q(null), o = K(null);
|
|
62
|
+
V(() => () => {
|
|
63
|
+
typeof document < "u" && o.current && o.current.parentNode && (o.current.parentNode.removeChild(o.current), o.current = null);
|
|
69
64
|
}, []);
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
65
|
+
const S = it(
|
|
66
|
+
() => N ? pt([X, N]) : X,
|
|
67
|
+
[N]
|
|
68
|
+
);
|
|
69
|
+
V(() => {
|
|
70
|
+
let t = w;
|
|
71
|
+
typeof t == "string" || t && (t = JSON.stringify(t)), t && C((r) => ({ ...r, rawAppRjBuild: t }));
|
|
72
|
+
}, [w]), V(() => {
|
|
73
|
+
if (!f) return;
|
|
74
|
+
const t = {
|
|
75
|
+
method: b || "GET",
|
|
76
|
+
url: f,
|
|
77
|
+
headers: s
|
|
78
|
+
};
|
|
79
|
+
t.method.toLowerCase() === "post" ? J.post(t.url, {}, { headers: t.headers }).then((r) => {
|
|
80
|
+
C((i) => ({ ...i, rawAppRjBuild: r.data }));
|
|
81
|
+
}) : J.get(t.url, { headers: t.headers }).then((r) => {
|
|
82
|
+
C((i) => ({ ...i, rawAppRjBuild: r.data }));
|
|
83
|
+
});
|
|
84
|
+
}, [f, s, b]), V(() => {
|
|
85
|
+
if (!d.rawAppRjBuild) return;
|
|
86
|
+
const t = wt(d.rawAppRjBuild);
|
|
85
87
|
if (!t.success) {
|
|
86
88
|
if (console.group(
|
|
87
89
|
`Tried to load the app's RjBuild but the ${t.format} content could not be parsed.`
|
|
88
90
|
), console.error(t.error.message), console.debug("Context:", {
|
|
89
91
|
rjBuildUrl: f,
|
|
90
92
|
rjBuildFetchMethod: b,
|
|
91
|
-
headersForRjBuild:
|
|
92
|
-
maybeRawAppRjBuild:
|
|
93
|
-
dataOverride:
|
|
93
|
+
headersForRjBuild: s,
|
|
94
|
+
maybeRawAppRjBuild: w,
|
|
95
|
+
dataOverride: m
|
|
94
96
|
}), console.debug("Error details:", t.error), console.groupEnd(), typeof document < "u") {
|
|
95
97
|
let e = document.getElementById("rj-parsing-error-root");
|
|
96
|
-
if (e || (e = document.createElement("div"), e.id = "rj-parsing-error-root", document.body.appendChild(e)), !
|
|
97
|
-
const
|
|
98
|
-
e.appendChild(
|
|
98
|
+
if (e || (e = document.createElement("div"), e.id = "rj-parsing-error-root", document.body.appendChild(e)), !o.current) {
|
|
99
|
+
const l = document.createElement("div");
|
|
100
|
+
e.appendChild(l), o.current = l;
|
|
99
101
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/* @__PURE__ */
|
|
103
|
-
|
|
102
|
+
M(
|
|
103
|
+
ct.createPortal(
|
|
104
|
+
/* @__PURE__ */ p(
|
|
105
|
+
mt,
|
|
104
106
|
{
|
|
105
107
|
processedRjBuild: t,
|
|
106
108
|
errorContext: {
|
|
107
109
|
rjBuildUrl: f,
|
|
108
110
|
rjBuildFetchMethod: b,
|
|
109
|
-
headersForRjBuild:
|
|
110
|
-
maybeRawAppRjBuild:
|
|
111
|
+
headersForRjBuild: s,
|
|
112
|
+
maybeRawAppRjBuild: w
|
|
111
113
|
}
|
|
112
114
|
}
|
|
113
115
|
),
|
|
114
|
-
|
|
116
|
+
o.current,
|
|
115
117
|
() => {
|
|
116
|
-
|
|
118
|
+
o.current && (o.current.parentNode.removeChild(o.current), o.current = null);
|
|
117
119
|
}
|
|
118
120
|
)
|
|
119
121
|
);
|
|
120
122
|
}
|
|
121
123
|
return;
|
|
122
124
|
}
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
125
|
+
T && (M(null), typeof document < "u" && o.current && o.current.parentNode && (o.current.parentNode.removeChild(o.current), o.current = null));
|
|
126
|
+
const r = t.data, i = m !== void 0 ? m : r.data;
|
|
127
|
+
a.set("", i);
|
|
128
|
+
const n = {
|
|
129
|
+
templates: r.templates ?? r.listForms ?? {},
|
|
130
|
+
renderView: r.renderView ?? {},
|
|
131
|
+
items: Object.keys(r.renderView ?? {}),
|
|
132
|
+
rawAppRjBuild: d.rawAppRjBuild
|
|
133
|
+
}, h = r.additionalDataSource;
|
|
134
|
+
if (!Array.isArray(h) || h.length === 0) {
|
|
135
|
+
C((e) => ({ ...e, ...n }));
|
|
132
136
|
return;
|
|
133
137
|
}
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
plugins: E,
|
|
137
|
-
templateData: i,
|
|
138
|
-
templatePath: "data",
|
|
139
|
-
setData: R,
|
|
140
|
-
updateData: W
|
|
141
|
-
}, r = {
|
|
142
|
-
templateData: i,
|
|
143
|
-
templatePath: "data"
|
|
144
|
-
}, l = s.filter((e) => e.blocking === !0), v = s.filter((e) => e.blocking !== !0), o = async (e, p) => {
|
|
145
|
-
var y;
|
|
138
|
+
const x = h.filter((e) => e.blocking === !0), A = h.filter((e) => e.blocking !== !0), B = (e) => !e || e === "data" ? "" : e.startsWith("data.") ? e.substring(5) : e, _ = async (e, l) => {
|
|
139
|
+
var P;
|
|
146
140
|
try {
|
|
147
141
|
if (!e.src) {
|
|
148
|
-
console.warn("additionalDataSource item number " +
|
|
142
|
+
console.warn("additionalDataSource item number " + l + " missing 'src' property.", e);
|
|
149
143
|
return;
|
|
150
144
|
}
|
|
151
|
-
const
|
|
152
|
-
method: ((
|
|
145
|
+
const y = {
|
|
146
|
+
method: ((P = e.method) == null ? void 0 : P.toUpperCase()) || "GET",
|
|
153
147
|
url: e.src
|
|
154
148
|
};
|
|
155
|
-
|
|
156
|
-
const k = await
|
|
157
|
-
url:
|
|
158
|
-
method:
|
|
159
|
-
headers:
|
|
160
|
-
body:
|
|
161
|
-
},
|
|
149
|
+
s && Object.keys(s).length > 0 && (y.headers = s);
|
|
150
|
+
const k = await J(y), rt = {
|
|
151
|
+
url: y.url,
|
|
152
|
+
method: y.method,
|
|
153
|
+
headers: y.headers || {},
|
|
154
|
+
body: y.data
|
|
155
|
+
}, ot = {
|
|
162
156
|
headers: k.headers || {},
|
|
163
157
|
status: k.status,
|
|
164
158
|
data: k.data
|
|
165
|
-
},
|
|
166
|
-
requestContext:
|
|
167
|
-
responseContext:
|
|
159
|
+
}, D = yt({
|
|
160
|
+
requestContext: rt,
|
|
161
|
+
responseContext: ot,
|
|
168
162
|
responseBody: k.data,
|
|
169
163
|
// additionalDataSource always processes raw data, not RjBuild.
|
|
170
164
|
isRjBuild: !1,
|
|
171
|
-
dataProcessors: (
|
|
165
|
+
dataProcessors: (S == null ? void 0 : S.dataProcessor) || {}
|
|
172
166
|
});
|
|
173
|
-
if (e.dataMapping)
|
|
167
|
+
if (e.dataMapping) {
|
|
168
|
+
const u = {
|
|
169
|
+
headersForRjBuild: s,
|
|
170
|
+
plugins: S,
|
|
171
|
+
get templateData() {
|
|
172
|
+
return a.get("");
|
|
173
|
+
},
|
|
174
|
+
templatePath: "data",
|
|
175
|
+
setData: (c) => a.set("", c),
|
|
176
|
+
updateData: (c, j, at) => {
|
|
177
|
+
const nt = B(j);
|
|
178
|
+
a.set(nt, c, at);
|
|
179
|
+
}
|
|
180
|
+
}, v = {
|
|
181
|
+
get templateData() {
|
|
182
|
+
return a.get("");
|
|
183
|
+
},
|
|
184
|
+
templatePath: "data"
|
|
185
|
+
};
|
|
174
186
|
try {
|
|
175
|
-
|
|
187
|
+
Dt({
|
|
176
188
|
dataMapping: e.dataMapping,
|
|
177
|
-
responseData:
|
|
178
|
-
globalDataContext:
|
|
179
|
-
templateContext:
|
|
189
|
+
responseData: D,
|
|
190
|
+
globalDataContext: u,
|
|
191
|
+
templateContext: v
|
|
180
192
|
});
|
|
181
193
|
return;
|
|
182
|
-
} catch (
|
|
183
|
-
console.error("Error applying dataMapping for additionalDataSource:",
|
|
194
|
+
} catch (c) {
|
|
195
|
+
console.error("Error applying dataMapping for additionalDataSource:", c);
|
|
184
196
|
}
|
|
197
|
+
}
|
|
185
198
|
if (!e.path) {
|
|
186
|
-
if (typeof
|
|
199
|
+
if (typeof D != "object" || Array.isArray(D)) {
|
|
187
200
|
console.warn(
|
|
188
201
|
"additionalDataSource data cannot be merged at root - must be an object:",
|
|
189
|
-
|
|
202
|
+
D
|
|
190
203
|
);
|
|
191
204
|
return;
|
|
192
205
|
}
|
|
193
|
-
Object.entries(
|
|
194
|
-
|
|
195
|
-
type: "updateData",
|
|
196
|
-
path: u,
|
|
197
|
-
value: G
|
|
198
|
-
});
|
|
206
|
+
Object.entries(D).forEach(([u, v]) => {
|
|
207
|
+
a.set(u, v);
|
|
199
208
|
});
|
|
200
209
|
return;
|
|
201
210
|
}
|
|
202
211
|
try {
|
|
203
|
-
const u =
|
|
212
|
+
const u = {
|
|
213
|
+
templateData: a.get(""),
|
|
214
|
+
// use current snapshot
|
|
215
|
+
templatePath: "data"
|
|
216
|
+
}, v = {
|
|
217
|
+
templateData: a.get(""),
|
|
218
|
+
// use current snapshot
|
|
219
|
+
templatePath: "data"
|
|
220
|
+
}, c = ht({
|
|
204
221
|
dataLocation: e.path,
|
|
205
222
|
currentPath: "data",
|
|
206
|
-
globalDataContext:
|
|
207
|
-
templateContext:
|
|
223
|
+
globalDataContext: u,
|
|
224
|
+
templateContext: v
|
|
208
225
|
});
|
|
209
|
-
if (typeof
|
|
226
|
+
if (typeof c != "string") {
|
|
210
227
|
console.warn(
|
|
211
228
|
"additionalDataSource path evaluation did not result in a string:",
|
|
212
229
|
e.path,
|
|
213
230
|
"->",
|
|
214
|
-
|
|
231
|
+
c
|
|
215
232
|
);
|
|
216
233
|
return;
|
|
217
234
|
}
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
type: "updateData",
|
|
221
|
-
path: G,
|
|
222
|
-
value: P
|
|
223
|
-
});
|
|
235
|
+
const j = B(c);
|
|
236
|
+
a.set(j, D);
|
|
224
237
|
} catch (u) {
|
|
225
238
|
console.error("Error evaluating additionalDataSource path:", e.path, u);
|
|
226
239
|
}
|
|
227
|
-
} catch (
|
|
228
|
-
console.error("Error fetching additional data source:", e.src,
|
|
240
|
+
} catch ($) {
|
|
241
|
+
console.error("Error fetching additional data source:", e.src, $);
|
|
229
242
|
}
|
|
230
243
|
};
|
|
231
|
-
|
|
232
|
-
if (
|
|
233
|
-
const e =
|
|
234
|
-
await Promise.allSettled(e)
|
|
235
|
-
console.error("Error processing blocking additionalDataSource:", p);
|
|
236
|
-
});
|
|
244
|
+
(async () => {
|
|
245
|
+
if (x.length > 0) {
|
|
246
|
+
const e = x.map((l, P) => _(l, P));
|
|
247
|
+
await Promise.allSettled(e);
|
|
237
248
|
}
|
|
238
|
-
if (
|
|
239
|
-
const e =
|
|
240
|
-
(
|
|
249
|
+
if (C((e) => ({ ...e, ...n })), A.length > 0) {
|
|
250
|
+
const e = A.map(
|
|
251
|
+
(l, P) => _(l, x.length + P)
|
|
241
252
|
);
|
|
242
253
|
Promise.allSettled(e);
|
|
243
254
|
}
|
|
244
255
|
})();
|
|
245
|
-
}, [
|
|
246
|
-
function
|
|
247
|
-
if (!
|
|
256
|
+
}, [d.rawAppRjBuild, m, a]);
|
|
257
|
+
function W(t, r, i) {
|
|
258
|
+
if (!R || R.size === 0)
|
|
248
259
|
return !1;
|
|
249
|
-
for (const [
|
|
250
|
-
if (t ===
|
|
251
|
-
const
|
|
260
|
+
for (const [n, h] of R)
|
|
261
|
+
if (t === n || t.startsWith(n + ".") || n === "") {
|
|
262
|
+
const x = n === "" ? t : t.substring(n.length + 1);
|
|
252
263
|
try {
|
|
253
|
-
return
|
|
254
|
-
} catch (
|
|
255
|
-
console.warn("Error during upstream update:",
|
|
264
|
+
return h(r, x, i), !0;
|
|
265
|
+
} catch (A) {
|
|
266
|
+
console.warn("Error during upstream update:", A);
|
|
256
267
|
break;
|
|
257
268
|
}
|
|
258
269
|
}
|
|
259
270
|
return !1;
|
|
260
271
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if (l === v - 1) {
|
|
283
|
-
if (s === "remove" && Array.isArray(r))
|
|
284
|
-
r.splice(o, 1);
|
|
285
|
-
else if (s === "move")
|
|
286
|
-
if (i.increment) {
|
|
287
|
-
if (!Array.isArray(r))
|
|
288
|
-
return t;
|
|
289
|
-
const J = Math.min(
|
|
290
|
-
r.length,
|
|
291
|
-
Math.max(0, parseInt(o) + parseInt(i.increment))
|
|
292
|
-
);
|
|
293
|
-
if (J === parseInt(o))
|
|
294
|
-
return t;
|
|
295
|
-
const e = r.splice(o, 1);
|
|
296
|
-
if (e.length < 1)
|
|
297
|
-
return t;
|
|
298
|
-
r.splice(J, 0, e[0]);
|
|
299
|
-
} else
|
|
300
|
-
return t;
|
|
301
|
-
else if (i === void 0)
|
|
302
|
-
delete r[o];
|
|
303
|
-
else {
|
|
304
|
-
if (ut.isEqual(i, r[o]))
|
|
305
|
-
return t;
|
|
306
|
-
s === "add" ? (r[o] === void 0 && (r[o] = []), r[o].push(i)) : r[o] = i;
|
|
307
|
-
}
|
|
308
|
-
return {
|
|
309
|
-
// Using modulo in case of massive update counts in long frontend sessions.
|
|
310
|
-
updateId: (t.updateId ?? 0) % (Number.MAX_SAFE_INTEGER - 1) + 1,
|
|
311
|
-
realCurrentData: t.realCurrentData
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
if (r.hasOwnProperty(o)) {
|
|
315
|
-
(typeof r[o] != "object" || r[o] === null) && (r[o] = {}), r = r[o];
|
|
316
|
-
continue;
|
|
317
|
-
}
|
|
318
|
-
r[o] = {}, r = r[o];
|
|
319
|
-
}
|
|
320
|
-
throw new Error("Could not update data.");
|
|
321
|
-
}
|
|
322
|
-
if (!I)
|
|
323
|
-
return null;
|
|
324
|
-
const U = st.map((t) => {
|
|
325
|
-
var a;
|
|
326
|
-
return /* @__PURE__ */ C(
|
|
327
|
-
St,
|
|
328
|
-
{
|
|
329
|
-
datafield: t,
|
|
330
|
-
props: nt[t],
|
|
331
|
-
path: "data." + t,
|
|
332
|
-
currentData: (a = x.realCurrentData) == null ? void 0 : a[t]
|
|
333
|
-
},
|
|
334
|
-
t
|
|
335
|
-
);
|
|
336
|
-
}), O = wt(et), F = /* @__PURE__ */ C(gt, { children: /* @__PURE__ */ L(
|
|
337
|
-
yt,
|
|
272
|
+
const U = (t) => {
|
|
273
|
+
W("", t, void 0) || a.set("", t);
|
|
274
|
+
}, F = (t, r, i) => {
|
|
275
|
+
const n = r.startsWith("data.") ? r.substring(5) : r === "data" ? "" : r;
|
|
276
|
+
W(n, t, i) || a.set(n, t, i);
|
|
277
|
+
}, tt = {
|
|
278
|
+
element: d.templates,
|
|
279
|
+
headersForRjBuild: s,
|
|
280
|
+
plugins: S,
|
|
281
|
+
ReactiveJsonRoot: xt,
|
|
282
|
+
setData: U,
|
|
283
|
+
updateData: F,
|
|
284
|
+
// experimental: expose store for advanced usage
|
|
285
|
+
store: a,
|
|
286
|
+
// fallback: get data from store directly (non-reactive access)
|
|
287
|
+
get templateData() {
|
|
288
|
+
return a.get("");
|
|
289
|
+
},
|
|
290
|
+
templatePath: "data"
|
|
291
|
+
}, q = d.items.map((t) => /* @__PURE__ */ p(
|
|
292
|
+
Ct,
|
|
338
293
|
{
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
children: O && A ? /* @__PURE__ */ C(A, { children: U }) : U
|
|
360
|
-
}
|
|
361
|
-
),
|
|
362
|
-
O ? K && /* @__PURE__ */ C(K, { children: JSON.stringify(x.realCurrentData, null, " ") }) : null
|
|
363
|
-
]
|
|
364
|
-
}
|
|
365
|
-
) });
|
|
366
|
-
return O && A ? /* @__PURE__ */ L(rt, { children: [
|
|
367
|
-
F,
|
|
368
|
-
V
|
|
369
|
-
] }) : /* @__PURE__ */ L(pt, { children: [
|
|
370
|
-
F,
|
|
371
|
-
V
|
|
372
|
-
] });
|
|
294
|
+
datafield: t,
|
|
295
|
+
path: "data." + t,
|
|
296
|
+
props: d.renderView[t]
|
|
297
|
+
},
|
|
298
|
+
t
|
|
299
|
+
)), et = bt(Y);
|
|
300
|
+
return /* @__PURE__ */ p(ft.Provider, { value: a, children: /* @__PURE__ */ p(dt, { children: /* @__PURE__ */ p(ut.Provider, { value: tt, children: /* @__PURE__ */ p(gt.Provider, { value: {
|
|
301
|
+
// Same here, getter for compatibility, but won't trigger updates
|
|
302
|
+
get templateData() {
|
|
303
|
+
return a.get("");
|
|
304
|
+
},
|
|
305
|
+
templatePath: "data"
|
|
306
|
+
}, children: et && L ? /* @__PURE__ */ H(Z, { children: [
|
|
307
|
+
/* @__PURE__ */ p(L, { children: q }),
|
|
308
|
+
O && /* @__PURE__ */ p(St, { Wrapper: O }),
|
|
309
|
+
T
|
|
310
|
+
] }) : /* @__PURE__ */ H(st, { children: [
|
|
311
|
+
q,
|
|
312
|
+
T
|
|
313
|
+
] }) }) }) }) });
|
|
373
314
|
};
|
|
374
315
|
export {
|
|
375
316
|
xt as ReactiveJsonRoot
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as s, useRef as u, useContext as i } from "react";
|
|
3
|
+
import { DataStore as c } from "./DataStore.js";
|
|
4
|
+
const t = s(null), f = ({ children: r, initialData: e }) => {
|
|
5
|
+
const o = u(new c(e)).current;
|
|
6
|
+
return /* @__PURE__ */ n(t.Provider, { value: o, children: r });
|
|
7
|
+
}, x = () => {
|
|
8
|
+
const r = i(t);
|
|
9
|
+
if (!r)
|
|
10
|
+
throw new Error("useStore must be used within a StoreProvider");
|
|
11
|
+
return r;
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
t as StoreContext,
|
|
15
|
+
f as StoreProvider,
|
|
16
|
+
x as useStore
|
|
17
|
+
};
|