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