@nice2dev/ui-forms 1.3.10 → 1.3.12
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/README.md +41 -8
- package/dist/index.cjs +6 -3
- package/dist/index.d.ts +808 -158
- package/dist/index.mjs +4905 -1928
- package/dist/studio.cjs +10 -0
- package/dist/studio.d.ts +796 -0
- package/dist/studio.mjs +1233 -0
- package/dist/ui-forms.css +1 -1
- package/package.json +10 -5
package/dist/studio.mjs
ADDED
|
@@ -0,0 +1,1233 @@
|
|
|
1
|
+
var ae = Object.defineProperty;
|
|
2
|
+
var ce = (e, t, n) => t in e ? ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var q = (e, t, n) => ce(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
const H = {
|
|
5
|
+
bom: !1,
|
|
6
|
+
eol: `
|
|
7
|
+
`,
|
|
8
|
+
indent: " ",
|
|
9
|
+
finalNewline: !0,
|
|
10
|
+
colonSpace: !0
|
|
11
|
+
};
|
|
12
|
+
function C(e) {
|
|
13
|
+
const t = e.charCodeAt(0) === 65279, n = e.includes(`\r
|
|
14
|
+
`) ? `\r
|
|
15
|
+
` : `
|
|
16
|
+
`;
|
|
17
|
+
let i = H.indent;
|
|
18
|
+
const r = e.split(/\r?\n/);
|
|
19
|
+
for (let c = 1; c < r.length; c++) {
|
|
20
|
+
const d = /^([ \t]+)\S/.exec(r[c]);
|
|
21
|
+
if (d) {
|
|
22
|
+
i = d[1];
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const a = /"\s*:(\s?)/.exec(e);
|
|
27
|
+
return {
|
|
28
|
+
bom: t,
|
|
29
|
+
eol: n,
|
|
30
|
+
indent: i,
|
|
31
|
+
finalNewline: /\n$/.test(e),
|
|
32
|
+
colonSpace: a ? a[1] !== "" : !0
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function E(e) {
|
|
36
|
+
const t = C(e);
|
|
37
|
+
return { value: JSON.parse(t.bom ? e.slice(1) : e), format: t };
|
|
38
|
+
}
|
|
39
|
+
function k(e, t) {
|
|
40
|
+
const n = { ...H, ...t }, i = j(e, n, "");
|
|
41
|
+
return (n.bom ? "\uFEFF" : "") + i + (n.finalNewline ? n.eol : "");
|
|
42
|
+
}
|
|
43
|
+
function le(e, t) {
|
|
44
|
+
if (t === void 0)
|
|
45
|
+
return e;
|
|
46
|
+
let n = t.includes(`\r
|
|
47
|
+
`) ? e.replace(/\r?\n/g, `\r
|
|
48
|
+
`) : e;
|
|
49
|
+
return t.charCodeAt(0) === 65279 && n.charCodeAt(0) !== 65279 && (n = "\uFEFF" + n), n;
|
|
50
|
+
}
|
|
51
|
+
function I(e, t) {
|
|
52
|
+
if (e === t)
|
|
53
|
+
return !0;
|
|
54
|
+
if (typeof e != typeof t || e === null || t === null || typeof e != "object" || Array.isArray(e) !== Array.isArray(t))
|
|
55
|
+
return !1;
|
|
56
|
+
if (Array.isArray(e)) {
|
|
57
|
+
const a = t;
|
|
58
|
+
return e.length === a.length && e.every((c, d) => I(c, a[d]));
|
|
59
|
+
}
|
|
60
|
+
const n = e, i = t, r = Object.keys(n);
|
|
61
|
+
return r.length !== Object.keys(i).length ? !1 : r.every(
|
|
62
|
+
(a) => Object.prototype.hasOwnProperty.call(i, a) && I(n[a], i[a])
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
function X(e, t, n) {
|
|
66
|
+
return de(e, t, n).text;
|
|
67
|
+
}
|
|
68
|
+
function de(e, t, n) {
|
|
69
|
+
const i = C(e), r = (s) => ({
|
|
70
|
+
text: k(t, i),
|
|
71
|
+
exact: !1,
|
|
72
|
+
reason: s
|
|
73
|
+
});
|
|
74
|
+
let a;
|
|
75
|
+
try {
|
|
76
|
+
a = new fe(e).parseDocument();
|
|
77
|
+
} catch (s) {
|
|
78
|
+
return r(s instanceof Error ? s.message : String(s));
|
|
79
|
+
}
|
|
80
|
+
if (T(a))
|
|
81
|
+
return r("duplicate keys");
|
|
82
|
+
const c = [], d = {
|
|
83
|
+
text: e,
|
|
84
|
+
format: i,
|
|
85
|
+
edits: c,
|
|
86
|
+
options: n,
|
|
87
|
+
compact: !e.trimEnd().includes(`
|
|
88
|
+
`)
|
|
89
|
+
};
|
|
90
|
+
U(d, a, t, "", !1);
|
|
91
|
+
const u = ue(e, c);
|
|
92
|
+
try {
|
|
93
|
+
const s = JSON.parse(i.bom ? u.slice(1) : u);
|
|
94
|
+
if (!I(s, t))
|
|
95
|
+
return r("patch did not read back");
|
|
96
|
+
} catch {
|
|
97
|
+
return r("patch was not valid JSON");
|
|
98
|
+
}
|
|
99
|
+
return { text: u, exact: !0 };
|
|
100
|
+
}
|
|
101
|
+
class fe {
|
|
102
|
+
constructor(t) {
|
|
103
|
+
q(this, "pos", 0);
|
|
104
|
+
this.text = t;
|
|
105
|
+
}
|
|
106
|
+
parseDocument() {
|
|
107
|
+
this.text.charCodeAt(0) === 65279 && (this.pos = 1);
|
|
108
|
+
const t = this.value();
|
|
109
|
+
if (this.ws(), this.pos < this.text.length)
|
|
110
|
+
throw new Error(`Unexpected text at ${this.pos}`);
|
|
111
|
+
return t;
|
|
112
|
+
}
|
|
113
|
+
ws() {
|
|
114
|
+
for (; this.pos < this.text.length && /\s/.test(this.text[this.pos]); )
|
|
115
|
+
this.pos++;
|
|
116
|
+
}
|
|
117
|
+
value() {
|
|
118
|
+
this.ws();
|
|
119
|
+
const t = this.text[this.pos];
|
|
120
|
+
if (t === "{")
|
|
121
|
+
return this.object();
|
|
122
|
+
if (t === "[")
|
|
123
|
+
return this.array();
|
|
124
|
+
const n = this.pos;
|
|
125
|
+
if (t === '"')
|
|
126
|
+
return { kind: "scalar", start: n, end: this.stringEnd(), value: JSON.parse(this.slice(n)) };
|
|
127
|
+
const i = /^(?:-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/.exec(
|
|
128
|
+
this.text.slice(n, n + 64)
|
|
129
|
+
);
|
|
130
|
+
if (!i)
|
|
131
|
+
throw new Error(`Unexpected token at ${n}`);
|
|
132
|
+
return this.pos = n + i[0].length, { kind: "scalar", start: n, end: this.pos, value: JSON.parse(i[0]) };
|
|
133
|
+
}
|
|
134
|
+
slice(t) {
|
|
135
|
+
return this.text.slice(t, this.pos);
|
|
136
|
+
}
|
|
137
|
+
/** Moves past a string literal, returns its end. */
|
|
138
|
+
stringEnd() {
|
|
139
|
+
for (this.pos++; this.pos < this.text.length; ) {
|
|
140
|
+
const t = this.text[this.pos];
|
|
141
|
+
if (t === "\\") {
|
|
142
|
+
this.pos += 2;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (this.pos++, t === '"')
|
|
146
|
+
return this.pos;
|
|
147
|
+
}
|
|
148
|
+
throw new Error("Unterminated string");
|
|
149
|
+
}
|
|
150
|
+
object() {
|
|
151
|
+
const t = this.pos++, n = [];
|
|
152
|
+
if (this.ws(), this.text[this.pos] === "}")
|
|
153
|
+
return { kind: "object", start: t, end: ++this.pos, members: n };
|
|
154
|
+
for (; ; ) {
|
|
155
|
+
this.ws();
|
|
156
|
+
const i = this.pos;
|
|
157
|
+
if (this.text[this.pos] !== '"')
|
|
158
|
+
throw new Error(`Expected a key at ${this.pos}`);
|
|
159
|
+
const r = JSON.parse(this.text.slice(i, this.stringEnd()));
|
|
160
|
+
if (this.ws(), this.text[this.pos] !== ":")
|
|
161
|
+
throw new Error(`Expected ':' at ${this.pos}`);
|
|
162
|
+
this.pos++, n.push({ key: r, start: i, value: this.value() }), this.ws();
|
|
163
|
+
const a = this.text[this.pos++];
|
|
164
|
+
if (a === "}")
|
|
165
|
+
return { kind: "object", start: t, end: this.pos, members: n };
|
|
166
|
+
if (a !== ",")
|
|
167
|
+
throw new Error(`Expected ',' or '}' at ${this.pos - 1}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
array() {
|
|
171
|
+
const t = this.pos++, n = [];
|
|
172
|
+
if (this.ws(), this.text[this.pos] === "]")
|
|
173
|
+
return { kind: "array", start: t, end: ++this.pos, items: n };
|
|
174
|
+
for (; ; ) {
|
|
175
|
+
n.push(this.value()), this.ws();
|
|
176
|
+
const i = this.text[this.pos++];
|
|
177
|
+
if (i === "]")
|
|
178
|
+
return { kind: "array", start: t, end: this.pos, items: n };
|
|
179
|
+
if (i !== ",")
|
|
180
|
+
throw new Error(`Expected ',' or ']' at ${this.pos - 1}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function T(e) {
|
|
185
|
+
if (e.kind === "object") {
|
|
186
|
+
const t = /* @__PURE__ */ new Set();
|
|
187
|
+
for (const n of e.members) {
|
|
188
|
+
if (t.has(n.key) || T(n.value))
|
|
189
|
+
return !0;
|
|
190
|
+
t.add(n.key);
|
|
191
|
+
}
|
|
192
|
+
} else if (e.kind === "array")
|
|
193
|
+
return e.items.some(T);
|
|
194
|
+
return !1;
|
|
195
|
+
}
|
|
196
|
+
function M(e) {
|
|
197
|
+
if (e.kind === "scalar")
|
|
198
|
+
return e.value;
|
|
199
|
+
if (e.kind === "array")
|
|
200
|
+
return e.items.map(M);
|
|
201
|
+
const t = {};
|
|
202
|
+
for (const n of e.members)
|
|
203
|
+
t[n.key] = M(n.value);
|
|
204
|
+
return t;
|
|
205
|
+
}
|
|
206
|
+
function j(e, t, n) {
|
|
207
|
+
if (e === null || typeof e != "object")
|
|
208
|
+
return e === void 0 ? "null" : JSON.stringify(e);
|
|
209
|
+
const i = n + t.indent, r = t.colonSpace ? ": " : ":";
|
|
210
|
+
if (Array.isArray(e))
|
|
211
|
+
return e.length === 0 ? "[]" : `[${t.eol}${e.map((c) => i + j(c, t, i)).join(`,${t.eol}`)}${t.eol}${n}]`;
|
|
212
|
+
const a = Object.entries(e).filter(
|
|
213
|
+
([, c]) => c !== void 0
|
|
214
|
+
);
|
|
215
|
+
return a.length === 0 ? "{}" : `{${t.eol}${a.map(([c, d]) => `${i}${JSON.stringify(c)}${r}${j(d, t, i)}`).join(`,${t.eol}`)}${t.eol}${n}}`;
|
|
216
|
+
}
|
|
217
|
+
function O(e, t, n = !1) {
|
|
218
|
+
if (e === null || typeof e != "object")
|
|
219
|
+
return e === void 0 ? "null" : JSON.stringify(e);
|
|
220
|
+
const i = t.colonSpace ? ": " : ":", r = n ? "," : ", ";
|
|
221
|
+
if (Array.isArray(e))
|
|
222
|
+
return `[${e.map((d) => O(d, t, n)).join(r)}]`;
|
|
223
|
+
const a = Object.entries(e).filter(
|
|
224
|
+
([, d]) => d !== void 0
|
|
225
|
+
), c = n ? "" : " ";
|
|
226
|
+
return a.length === 0 ? "{}" : `{${c}${a.map(([d, u]) => `${JSON.stringify(d)}${i}${O(u, t, n)}`).join(r)}${c}}`;
|
|
227
|
+
}
|
|
228
|
+
const Y = (e) => e.compact ? "," : ", ";
|
|
229
|
+
function ue(e, t) {
|
|
230
|
+
let n = e;
|
|
231
|
+
for (const i of [...t].sort((r, a) => a.start - r.start))
|
|
232
|
+
n = n.slice(0, i.start) + i.text + n.slice(i.end);
|
|
233
|
+
return n;
|
|
234
|
+
}
|
|
235
|
+
function x(e, t) {
|
|
236
|
+
var i;
|
|
237
|
+
const n = e.lastIndexOf(`
|
|
238
|
+
`, t - 1) + 1;
|
|
239
|
+
return ((i = /^[ \t]*/.exec(e.slice(n, t))) == null ? void 0 : i[0]) ?? "";
|
|
240
|
+
}
|
|
241
|
+
function Z(e, t) {
|
|
242
|
+
return !e.slice(t.start, t.end).includes(`
|
|
243
|
+
`);
|
|
244
|
+
}
|
|
245
|
+
function V(e, t, n) {
|
|
246
|
+
return e.compact ? !0 : t.kind === "scalar" || (t.kind === "object" ? t.members.length === 0 : t.items.length === 0) ? n : Z(e.text, t);
|
|
247
|
+
}
|
|
248
|
+
function N(e, t, n, i) {
|
|
249
|
+
const r = V(e, t, i);
|
|
250
|
+
e.edits.push({
|
|
251
|
+
start: t.start,
|
|
252
|
+
end: t.end,
|
|
253
|
+
text: r ? O(n, e.format, e.compact) : j(n, e.format, x(e.text, t.start))
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
const Q = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
|
|
257
|
+
function U(e, t, n, i, r) {
|
|
258
|
+
if (t.kind === "scalar") {
|
|
259
|
+
if (t.value === n)
|
|
260
|
+
return;
|
|
261
|
+
N(e, t, n, r);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
I(M(t), n) || (t.kind === "object" && Q(n) ? pe(e, t, n, i, r) : t.kind === "array" && Array.isArray(n) ? ye(e, t, n, i, r) : N(e, t, n, r));
|
|
265
|
+
}
|
|
266
|
+
function ee(e, t, n) {
|
|
267
|
+
return n !== void 0 ? x(e.text, n) : x(e.text, t.start) + e.format.indent;
|
|
268
|
+
}
|
|
269
|
+
function pe(e, t, n, i, r) {
|
|
270
|
+
var l;
|
|
271
|
+
const a = V(e, t, r), c = t.members.filter(
|
|
272
|
+
(f) => Object.prototype.hasOwnProperty.call(n, f.key) && n[f.key] !== void 0
|
|
273
|
+
), d = Object.keys(n).filter(
|
|
274
|
+
(f) => n[f] !== void 0 && !t.members.some((h) => h.key === f)
|
|
275
|
+
);
|
|
276
|
+
if (c.length === 0 && t.members.length > 0) {
|
|
277
|
+
N(e, t, n, r);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
for (const f of c)
|
|
281
|
+
U(e, f.value, n[f.key], `${i}/${we(f.key)}`, a);
|
|
282
|
+
if (te(
|
|
283
|
+
e,
|
|
284
|
+
t.members.map((f) => ({ start: f.start, end: f.value.end })),
|
|
285
|
+
t.members.map((f) => c.includes(f))
|
|
286
|
+
), d.length === 0)
|
|
287
|
+
return;
|
|
288
|
+
const u = e.format.colonSpace ? ": " : ":";
|
|
289
|
+
if (a) {
|
|
290
|
+
const f = d.map(
|
|
291
|
+
(h) => `${JSON.stringify(h)}${u}${O(n[h], e.format, e.compact)}`
|
|
292
|
+
);
|
|
293
|
+
se(e, t, c.length > 0 ? c[c.length - 1].value.end : void 0, f);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const s = ee(e, t, (l = t.members[0]) == null ? void 0 : l.start), o = d.map(
|
|
297
|
+
(f) => `${s}${JSON.stringify(f)}${u}${j(n[f], e.format, s)}`
|
|
298
|
+
);
|
|
299
|
+
ne(e, t, c.length > 0 ? c[c.length - 1].value.end : void 0, o);
|
|
300
|
+
}
|
|
301
|
+
const me = ["name", "id", "code", "key", "slug", "state", "Id"];
|
|
302
|
+
function he(e, t, n, i) {
|
|
303
|
+
var u, s;
|
|
304
|
+
const r = [...n, ...i];
|
|
305
|
+
if (r.length === 0 || !r.every(Q))
|
|
306
|
+
return;
|
|
307
|
+
const a = (o, l) => {
|
|
308
|
+
const f = o.map((h) => h[l]);
|
|
309
|
+
return f.every((h) => typeof h == "string" || typeof h == "number") && new Set(f).size === f.length;
|
|
310
|
+
}, c = (s = (u = e.options) == null ? void 0 : u.arrayKey) == null ? void 0 : s.call(u, t);
|
|
311
|
+
return (c ? [c] : me).find((o) => a(n, o) && a(i, o));
|
|
312
|
+
}
|
|
313
|
+
function ye(e, t, n, i, r) {
|
|
314
|
+
var g;
|
|
315
|
+
const a = V(e, t, r), c = t.items.map(M), d = he(e, i, c, n), u = (p) => p[d], s = d !== void 0 ? c.map((p) => {
|
|
316
|
+
const m = u(p);
|
|
317
|
+
return n.findIndex((b) => u(b) === m);
|
|
318
|
+
}) : be(c, n);
|
|
319
|
+
{
|
|
320
|
+
const p = new Set(s.filter((m) => m >= 0));
|
|
321
|
+
for (let m = 0; m < s.length; m++) {
|
|
322
|
+
if (s[m] >= 0)
|
|
323
|
+
continue;
|
|
324
|
+
let b = -1;
|
|
325
|
+
for (let y = m - 1; y >= 0; y--)
|
|
326
|
+
if (s[y] >= 0) {
|
|
327
|
+
b = s[y];
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
let v = n.length;
|
|
331
|
+
for (let y = m + 1; y < s.length; y++)
|
|
332
|
+
if (s[y] >= 0) {
|
|
333
|
+
v = s[y];
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
for (let y = b + 1; y < v; y++)
|
|
337
|
+
if (!p.has(y)) {
|
|
338
|
+
s[m] = y, p.add(y);
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
const o = s.filter((p) => p >= 0);
|
|
344
|
+
if (o.some((p, m) => m > 0 && p < o[m - 1])) {
|
|
345
|
+
N(e, t, n, r);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (o.length === 0 && t.items.length > 0) {
|
|
349
|
+
N(e, t, n, r);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
t.items.forEach((p, m) => {
|
|
353
|
+
s[m] >= 0 && U(e, p, n[s[m]], `${i}/${s[m]}`, a);
|
|
354
|
+
}), te(
|
|
355
|
+
e,
|
|
356
|
+
t.items.map((p) => ({ start: p.start, end: p.end })),
|
|
357
|
+
s.map((p) => p >= 0)
|
|
358
|
+
);
|
|
359
|
+
const l = t.items.length > 0 && t.items.every((p) => p.kind !== "scalar" && Z(e.text, p)), f = ee(e, t, (g = t.items[0]) == null ? void 0 : g.start), h = /* @__PURE__ */ new Map();
|
|
360
|
+
n.forEach((p, m) => {
|
|
361
|
+
if (s.includes(m))
|
|
362
|
+
return;
|
|
363
|
+
let b;
|
|
364
|
+
for (let $ = t.items.length - 1; $ >= 0; $--)
|
|
365
|
+
if (s[$] >= 0 && s[$] < m) {
|
|
366
|
+
b = $;
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
const v = a ? O(p, e.format, e.compact) : l ? `${f}${O(p, e.format)}` : `${f}${j(p, e.format, f)}`, y = h.get(b) ?? [];
|
|
370
|
+
y.push(v), h.set(b, y);
|
|
371
|
+
});
|
|
372
|
+
for (const [p, m] of h) {
|
|
373
|
+
const b = p === void 0 ? void 0 : t.items[p].end;
|
|
374
|
+
if (p === void 0 && o.length > 0) {
|
|
375
|
+
const v = t.items[s.findIndex(($) => $ >= 0)], y = a ? Y(e) : `,${e.format.eol}`;
|
|
376
|
+
e.edits.push({
|
|
377
|
+
start: v.start,
|
|
378
|
+
end: v.start,
|
|
379
|
+
text: a ? m.join(y) + y : m.join(y).trimStart() + y + f
|
|
380
|
+
});
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
a ? se(e, t, b, m) : ne(e, t, b, m);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
const ge = 4e6;
|
|
387
|
+
function be(e, t) {
|
|
388
|
+
const n = e.length, i = t.length;
|
|
389
|
+
if (n * i > ge)
|
|
390
|
+
return e.map((o, l) => l < i ? l : -1);
|
|
391
|
+
const r = e.map((o) => JSON.stringify(o)), a = t.map((o) => JSON.stringify(o)), c = Array.from({ length: n + 1 }, () => new Uint32Array(i + 1));
|
|
392
|
+
for (let o = n - 1; o >= 0; o--)
|
|
393
|
+
for (let l = i - 1; l >= 0; l--)
|
|
394
|
+
c[o][l] = r[o] === a[l] ? c[o + 1][l + 1] + 1 : Math.max(c[o + 1][l], c[o][l + 1]);
|
|
395
|
+
const d = new Array(n).fill(-1);
|
|
396
|
+
let u = 0, s = 0;
|
|
397
|
+
for (; u < n && s < i; )
|
|
398
|
+
r[u] === a[s] ? d[u++] = s++ : c[u + 1][s] >= c[u][s + 1] ? u++ : s++;
|
|
399
|
+
return d;
|
|
400
|
+
}
|
|
401
|
+
function te(e, t, n) {
|
|
402
|
+
for (let i = 0; i < t.length; i++) {
|
|
403
|
+
if (n[i])
|
|
404
|
+
continue;
|
|
405
|
+
let r = i;
|
|
406
|
+
for (; r + 1 < t.length && !n[r + 1]; )
|
|
407
|
+
r++;
|
|
408
|
+
r + 1 < t.length ? e.edits.push({ start: t[i].start, end: t[r + 1].start, text: "" }) : i > 0 ? e.edits.push({ start: t[i - 1].end, end: t[r].end, text: "" }) : e.edits.push({ start: t[i].start, end: t[r].end, text: "" }), i = r;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function ne(e, t, n, i) {
|
|
412
|
+
const r = e.format.eol;
|
|
413
|
+
if (n !== void 0) {
|
|
414
|
+
e.edits.push({ start: n, end: n, text: `,${r}${i.join(`,${r}`)}` });
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
const a = t.end - 1;
|
|
418
|
+
if ((t.kind === "object" ? t.members.length : t.items.length) === 0)
|
|
419
|
+
e.edits.push({
|
|
420
|
+
start: t.start + 1,
|
|
421
|
+
end: a,
|
|
422
|
+
text: `${r}${i.join(`,${r}`)}${r}${x(e.text, t.start)}`
|
|
423
|
+
});
|
|
424
|
+
else {
|
|
425
|
+
const d = t.kind === "object" ? t.members[0].start : t.items[0].start;
|
|
426
|
+
e.edits.push({ start: d, end: d, text: `${i.join(`,${r}`).trimStart()}` });
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
function se(e, t, n, i) {
|
|
430
|
+
const r = Y(e);
|
|
431
|
+
if (n !== void 0) {
|
|
432
|
+
e.edits.push({ start: n, end: n, text: `${r}${i.join(r)}` });
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const a = t.kind === "object" && !e.compact ? " " : "";
|
|
436
|
+
e.edits.push({
|
|
437
|
+
start: t.start + 1,
|
|
438
|
+
end: t.end - 1,
|
|
439
|
+
text: `${a}${i.join(r)}${a}`
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
function we(e) {
|
|
443
|
+
return e.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
444
|
+
}
|
|
445
|
+
const K = (e) => e.slice(e.lastIndexOf("/") + 1), ke = (e) => e.charCodeAt(0) === 65279 ? e.slice(1) : e;
|
|
446
|
+
function R(e) {
|
|
447
|
+
return {
|
|
448
|
+
id: e.id,
|
|
449
|
+
label: e.label,
|
|
450
|
+
labelKey: e.labelKey,
|
|
451
|
+
icon: e.icon,
|
|
452
|
+
match: e.match,
|
|
453
|
+
editor: e.editor,
|
|
454
|
+
decode(t, n) {
|
|
455
|
+
return e.select(E(t[0].text).value, n);
|
|
456
|
+
},
|
|
457
|
+
encode(t, n, i) {
|
|
458
|
+
const r = n[0].text, a = E(r).value, c = e.assign(a, t, i);
|
|
459
|
+
return {
|
|
460
|
+
files: [
|
|
461
|
+
{ path: n[0].path, text: X(r, c, { arrayKey: e.arrayKey }) }
|
|
462
|
+
]
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
const F = R({
|
|
468
|
+
id: "json",
|
|
469
|
+
label: "JSON",
|
|
470
|
+
labelKey: "devStudio.kind.json",
|
|
471
|
+
icon: "code",
|
|
472
|
+
match: (e) => e.toLowerCase().endsWith(".json"),
|
|
473
|
+
editor: "json",
|
|
474
|
+
select: (e) => e,
|
|
475
|
+
assign: (e, t) => t
|
|
476
|
+
}), P = {
|
|
477
|
+
id: "text",
|
|
478
|
+
label: "Text",
|
|
479
|
+
labelKey: "devStudio.kind.text",
|
|
480
|
+
icon: "file",
|
|
481
|
+
match: () => !0,
|
|
482
|
+
editor: "text",
|
|
483
|
+
decode: (e) => e[0].text,
|
|
484
|
+
encode: (e, t) => ({
|
|
485
|
+
files: [{ path: t[0].path, text: le(e, t[0].text) }]
|
|
486
|
+
})
|
|
487
|
+
};
|
|
488
|
+
function ve(e, t) {
|
|
489
|
+
return e.find((n) => n.match(t)) ?? (F.match(t) ? F : P);
|
|
490
|
+
}
|
|
491
|
+
function $e(e, t, n) {
|
|
492
|
+
for (const i of [F, P])
|
|
493
|
+
if (i.match(e.path))
|
|
494
|
+
try {
|
|
495
|
+
const r = i.decode([e], n);
|
|
496
|
+
return {
|
|
497
|
+
key: `${i.id}:${e.path}`,
|
|
498
|
+
kind: i,
|
|
499
|
+
paths: [e.path],
|
|
500
|
+
label: K(e.path),
|
|
501
|
+
model: r,
|
|
502
|
+
error: t
|
|
503
|
+
};
|
|
504
|
+
} catch {
|
|
505
|
+
}
|
|
506
|
+
return {
|
|
507
|
+
key: `text:${e.path}`,
|
|
508
|
+
kind: P,
|
|
509
|
+
paths: [e.path],
|
|
510
|
+
label: K(e.path),
|
|
511
|
+
model: e.text,
|
|
512
|
+
error: t
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
function Se(e, t, n, i) {
|
|
516
|
+
var d, u;
|
|
517
|
+
const r = e.encode(t, n, i), a = new Map(n.map((s) => [s.path, s.text])), c = ((d = r.files.find((s) => a.get(s.path) !== s.text)) == null ? void 0 : d.path) ?? ((u = r.deleted) == null ? void 0 : u.find((s) => a.has(s)));
|
|
518
|
+
if (c !== void 0)
|
|
519
|
+
throw new Error(`${K(c)} would not be stored as it is`);
|
|
520
|
+
}
|
|
521
|
+
function Ce(e, t, n) {
|
|
522
|
+
const i = /* @__PURE__ */ new Map();
|
|
523
|
+
for (const a of t) {
|
|
524
|
+
const c = ve(e, a.path), d = c.group ? c.group(a.path) : a.path, u = `${c.id}:${d}`, s = i.get(u) ?? { kind: c, group: d, files: [] };
|
|
525
|
+
s.files.push(a), i.set(u, s);
|
|
526
|
+
}
|
|
527
|
+
const r = [];
|
|
528
|
+
for (const [a, { kind: c, group: d, files: u }] of i) {
|
|
529
|
+
const s = u.map((l) => l.path).sort(), o = K(c.group ? d : s[0]);
|
|
530
|
+
try {
|
|
531
|
+
const l = c.decode(u, n);
|
|
532
|
+
Se(c, l, u, n), r.push({ key: a, kind: c, paths: s, label: o, model: l });
|
|
533
|
+
} catch (l) {
|
|
534
|
+
const f = l instanceof Error ? l.message : String(l);
|
|
535
|
+
for (const h of u)
|
|
536
|
+
r.push($e(h, f, n));
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return r.sort((a, c) => a.label.localeCompare(c.label));
|
|
540
|
+
}
|
|
541
|
+
function Ve(e, t, n, i) {
|
|
542
|
+
const r = n.filter((u) => e.paths.includes(u.path)), a = e.kind.encode(t, r, i), c = new Map(n.map((u) => [u.path, u])), d = [];
|
|
543
|
+
for (const u of a.files) {
|
|
544
|
+
const s = c.get(u.path);
|
|
545
|
+
s && s.text === u.text || d.push({ type: "write", path: u.path, text: u.text, baseVersion: s == null ? void 0 : s.version });
|
|
546
|
+
}
|
|
547
|
+
for (const u of a.deleted ?? []) {
|
|
548
|
+
const s = c.get(u);
|
|
549
|
+
s && d.push({ type: "delete", path: u, baseVersion: s.version });
|
|
550
|
+
}
|
|
551
|
+
return d;
|
|
552
|
+
}
|
|
553
|
+
function je(e, t) {
|
|
554
|
+
try {
|
|
555
|
+
return JSON.parse(ke(e));
|
|
556
|
+
} catch {
|
|
557
|
+
return t;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
const w = (e) => typeof e == "object" && e !== null && !Array.isArray(e), S = (...e) => (t) => {
|
|
561
|
+
const n = t.toLowerCase();
|
|
562
|
+
return e.some((i) => n.endsWith(i.toLowerCase()));
|
|
563
|
+
};
|
|
564
|
+
function J(e) {
|
|
565
|
+
return R({
|
|
566
|
+
id: e.id,
|
|
567
|
+
label: e.label,
|
|
568
|
+
labelKey: e.labelKey,
|
|
569
|
+
icon: e.icon,
|
|
570
|
+
editor: e.editor,
|
|
571
|
+
match: e.match,
|
|
572
|
+
select: (t) => {
|
|
573
|
+
if (Array.isArray(t))
|
|
574
|
+
return t;
|
|
575
|
+
const n = w(t) ? t[e.property] : void 0;
|
|
576
|
+
return Array.isArray(n) ? n : [];
|
|
577
|
+
},
|
|
578
|
+
assign: (t, n) => Array.isArray(t) ? n : w(t) && !(e.property in t) && n.length === 0 ? t : { ...w(t) ? t : {}, [e.property]: n },
|
|
579
|
+
arrayKey: e.itemKey ? () => e.itemKey : void 0
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
function ie(e) {
|
|
583
|
+
const t = J(e);
|
|
584
|
+
return {
|
|
585
|
+
...t,
|
|
586
|
+
decode: (n, i) => t.decode(n, i).map((r, a) => e.toItem(r, a)),
|
|
587
|
+
encode: (n, i, r) => t.encode(
|
|
588
|
+
n.map((a) => e.fromItem(a)),
|
|
589
|
+
i,
|
|
590
|
+
r
|
|
591
|
+
)
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
function re(e) {
|
|
595
|
+
return R({
|
|
596
|
+
...e,
|
|
597
|
+
select: (t) => w(t) ? t : {},
|
|
598
|
+
assign: (t, n) => n
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
const Oe = /^(.*)\.([a-z]{2,3}(?:-[A-Za-z]{2,4})?)\.i18n\.json$/i, Ke = (e) => {
|
|
602
|
+
const t = Oe.exec(e);
|
|
603
|
+
return t ? { group: t[1], locale: t[2] } : null;
|
|
604
|
+
}, D = (e) => w(e) && Object.values(e).every((t) => typeof t == "string");
|
|
605
|
+
function Ae(e) {
|
|
606
|
+
if (w(e)) {
|
|
607
|
+
for (const t of ["translations", "keys"])
|
|
608
|
+
if (t in e) {
|
|
609
|
+
if (D(e[t]))
|
|
610
|
+
return e[t];
|
|
611
|
+
throw new Error(`"${t}" is not a flat map of texts`);
|
|
612
|
+
}
|
|
613
|
+
if (D(e))
|
|
614
|
+
return e;
|
|
615
|
+
}
|
|
616
|
+
throw new Error("no translations in this file");
|
|
617
|
+
}
|
|
618
|
+
function z(e, t) {
|
|
619
|
+
return w(e) ? w(e.translations) ? { ...e, translations: t } : w(e.keys) ? { ...e, keys: t } : D(e) ? t : { ...e, translations: t } : { translations: t };
|
|
620
|
+
}
|
|
621
|
+
function Ee(e = {}) {
|
|
622
|
+
const t = e.parse ?? Ke, n = e.pathFor ?? ((i, r) => `${i}.${r}.i18n.json`);
|
|
623
|
+
return {
|
|
624
|
+
id: e.id ?? "i18n",
|
|
625
|
+
label: e.label ?? "Translations",
|
|
626
|
+
labelKey: e.labelKey ?? "devStudio.kind.i18n",
|
|
627
|
+
icon: "globe",
|
|
628
|
+
editor: "i18n",
|
|
629
|
+
match: (i) => t(i) !== null,
|
|
630
|
+
group: (i) => {
|
|
631
|
+
var r;
|
|
632
|
+
return ((r = t(i)) == null ? void 0 : r.group) ?? i;
|
|
633
|
+
},
|
|
634
|
+
decode(i) {
|
|
635
|
+
const r = {};
|
|
636
|
+
for (const a of i) {
|
|
637
|
+
const c = t(a.path);
|
|
638
|
+
c && (r[c.locale] = { ...Ae(E(a.text).value) });
|
|
639
|
+
}
|
|
640
|
+
return r;
|
|
641
|
+
},
|
|
642
|
+
encode(i, r) {
|
|
643
|
+
const a = /* @__PURE__ */ new Map();
|
|
644
|
+
let c = "";
|
|
645
|
+
for (const o of r) {
|
|
646
|
+
const l = t(o.path);
|
|
647
|
+
l && (a.set(l.locale, o), c = l.group);
|
|
648
|
+
}
|
|
649
|
+
const d = a.get("en") ?? r[0], u = [];
|
|
650
|
+
for (const [o, l] of Object.entries(i)) {
|
|
651
|
+
const f = a.get(o);
|
|
652
|
+
if (f) {
|
|
653
|
+
const g = E(f.text).value;
|
|
654
|
+
u.push({
|
|
655
|
+
path: f.path,
|
|
656
|
+
text: X(f.text, z(g, l))
|
|
657
|
+
});
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
660
|
+
const h = n(c || K((d == null ? void 0 : d.path) ?? "module"), o);
|
|
661
|
+
if (d) {
|
|
662
|
+
const g = E(d.text).value, p = w(g) && "locale" in g ? { ...g, locale: o } : g;
|
|
663
|
+
u.push({
|
|
664
|
+
path: h,
|
|
665
|
+
text: k(
|
|
666
|
+
z(p, l),
|
|
667
|
+
C(d.text)
|
|
668
|
+
)
|
|
669
|
+
});
|
|
670
|
+
} else
|
|
671
|
+
u.push({ path: h, text: k({ locale: o, translations: l }) });
|
|
672
|
+
}
|
|
673
|
+
const s = [...a.entries()].filter(([o]) => !(o in i)).map(([, o]) => o.path);
|
|
674
|
+
return { files: u, deleted: s };
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
const A = (e) => JSON.parse(JSON.stringify(e));
|
|
679
|
+
function Ue(e) {
|
|
680
|
+
const t = e.revisions !== !1;
|
|
681
|
+
let n = 0;
|
|
682
|
+
const i = e.workspaces.map((s) => ({
|
|
683
|
+
meta: {
|
|
684
|
+
id: s.id,
|
|
685
|
+
label: s.label,
|
|
686
|
+
description: s.description,
|
|
687
|
+
icon: s.icon,
|
|
688
|
+
readOnly: s.readOnly
|
|
689
|
+
},
|
|
690
|
+
packages: new Map((s.packages ?? []).map((o) => [o.id, { ...o, workspaceId: s.id }])),
|
|
691
|
+
modules: new Map(
|
|
692
|
+
s.modules.map((o) => [
|
|
693
|
+
o.id,
|
|
694
|
+
{
|
|
695
|
+
...o,
|
|
696
|
+
files: new Map(
|
|
697
|
+
Object.entries(o.files).map(
|
|
698
|
+
([l, f]) => [l, { text: f, version: ++n }]
|
|
699
|
+
)
|
|
700
|
+
),
|
|
701
|
+
revisions: []
|
|
702
|
+
}
|
|
703
|
+
])
|
|
704
|
+
)
|
|
705
|
+
}));
|
|
706
|
+
let r = (e.templates ?? []).map((s) => A(s));
|
|
707
|
+
const a = (s) => {
|
|
708
|
+
const o = i.find((l) => l.meta.id === s);
|
|
709
|
+
if (!o)
|
|
710
|
+
throw new Error(`Unknown workspace "${s}"`);
|
|
711
|
+
return o;
|
|
712
|
+
}, c = (s) => {
|
|
713
|
+
const o = a(s.workspaceId).modules.get(s.id);
|
|
714
|
+
if (!o)
|
|
715
|
+
throw new Error(`Unknown module "${s.id}"`);
|
|
716
|
+
return o;
|
|
717
|
+
}, d = (s, o) => ({
|
|
718
|
+
workspaceId: s,
|
|
719
|
+
id: o.id,
|
|
720
|
+
packageId: o.packageId,
|
|
721
|
+
label: o.label ?? o.id,
|
|
722
|
+
description: o.description,
|
|
723
|
+
icon: o.icon,
|
|
724
|
+
version: o.version,
|
|
725
|
+
readOnly: o.readOnly || a(s).meta.readOnly,
|
|
726
|
+
files: [...o.files.keys()].sort()
|
|
727
|
+
}), u = (s, o) => ({
|
|
728
|
+
path: s,
|
|
729
|
+
text: o.text,
|
|
730
|
+
version: String(o.version)
|
|
731
|
+
});
|
|
732
|
+
return {
|
|
733
|
+
async listWorkspaces() {
|
|
734
|
+
return i.map((s) => ({ ...s.meta }));
|
|
735
|
+
},
|
|
736
|
+
async listModules(s) {
|
|
737
|
+
return [...a(s).modules.values()].map((l) => d(s, l));
|
|
738
|
+
},
|
|
739
|
+
async listPackages(s) {
|
|
740
|
+
const o = a(s), l = [...o.packages.values()], f = [...new Set([...o.modules.values()].map((h) => h.packageId).filter(Boolean))].filter((h) => !o.packages.has(h)).map((h) => ({ id: h, workspaceId: s, label: h, derived: !0 }));
|
|
741
|
+
return [...l, ...f];
|
|
742
|
+
},
|
|
743
|
+
async readModule(s) {
|
|
744
|
+
return [...c(s).files.entries()].map(([l, f]) => u(l, f));
|
|
745
|
+
},
|
|
746
|
+
async writeModule(s, o) {
|
|
747
|
+
const l = c(s);
|
|
748
|
+
if (l.readOnly || a(s.workspaceId).meta.readOnly)
|
|
749
|
+
throw new Error(`Module "${s.id}" is read-only`);
|
|
750
|
+
const f = o.filter((p) => p.baseVersion !== void 0).filter((p) => {
|
|
751
|
+
const m = l.files.get(p.path);
|
|
752
|
+
return m ? String(m.version) !== p.baseVersion : !1;
|
|
753
|
+
}).map((p) => {
|
|
754
|
+
var m;
|
|
755
|
+
return { path: p.path, currentVersion: String((m = l.files.get(p.path)) == null ? void 0 : m.version) };
|
|
756
|
+
});
|
|
757
|
+
if (f.length > 0)
|
|
758
|
+
return { ok: !1, conflicts: f };
|
|
759
|
+
let h;
|
|
760
|
+
if (t) {
|
|
761
|
+
const p = {};
|
|
762
|
+
for (const [m, b] of l.files)
|
|
763
|
+
p[m] = b.text;
|
|
764
|
+
h = `r${++n}`, l.revisions.unshift({
|
|
765
|
+
id: h,
|
|
766
|
+
timestamp: Date.now(),
|
|
767
|
+
label: h,
|
|
768
|
+
summary: o.map((m) => `${m.type} ${m.path}`).join(", "),
|
|
769
|
+
files: p
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
const g = {};
|
|
773
|
+
for (const p of o)
|
|
774
|
+
if (p.type === "delete")
|
|
775
|
+
l.files.delete(p.path);
|
|
776
|
+
else {
|
|
777
|
+
const m = ++n;
|
|
778
|
+
l.files.set(p.path, { text: p.text, version: m }), g[p.path] = String(m);
|
|
779
|
+
}
|
|
780
|
+
return { ok: !0, versions: g, revision: h };
|
|
781
|
+
},
|
|
782
|
+
async createModule(s) {
|
|
783
|
+
const o = a(s.workspaceId);
|
|
784
|
+
if (o.meta.readOnly)
|
|
785
|
+
throw new Error(`Workspace "${s.workspaceId}" is read-only`);
|
|
786
|
+
if (o.modules.has(s.id))
|
|
787
|
+
throw new Error(`Module "${s.id}" already exists`);
|
|
788
|
+
const l = {
|
|
789
|
+
id: s.id,
|
|
790
|
+
packageId: s.packageId,
|
|
791
|
+
files: new Map(
|
|
792
|
+
s.files.map((f) => [f.path, { text: f.text, version: ++n }])
|
|
793
|
+
),
|
|
794
|
+
revisions: []
|
|
795
|
+
};
|
|
796
|
+
return o.modules.set(s.id, l), d(s.workspaceId, l);
|
|
797
|
+
},
|
|
798
|
+
async deleteModule(s) {
|
|
799
|
+
const o = a(s.workspaceId);
|
|
800
|
+
if (o.meta.readOnly)
|
|
801
|
+
throw new Error(`Workspace "${s.workspaceId}" is read-only`);
|
|
802
|
+
o.modules.delete(s.id);
|
|
803
|
+
},
|
|
804
|
+
async savePackage(s) {
|
|
805
|
+
return a(s.workspaceId).packages.set(s.id, { ...s, derived: !1 }), { ...s, derived: !1 };
|
|
806
|
+
},
|
|
807
|
+
async deletePackage(s) {
|
|
808
|
+
a(s.workspaceId).packages.delete(s.id);
|
|
809
|
+
},
|
|
810
|
+
async listTemplates() {
|
|
811
|
+
return r.map((s) => A(s));
|
|
812
|
+
},
|
|
813
|
+
async saveTemplate(s, o) {
|
|
814
|
+
const l = (o == null ? void 0 : o.previousId) ?? s.id, f = A(s), h = r.findIndex((g) => g.id === l);
|
|
815
|
+
return r = h >= 0 ? r.map((g, p) => p === h ? f : g) : [...r, f], A(f);
|
|
816
|
+
},
|
|
817
|
+
async deleteTemplate(s) {
|
|
818
|
+
r = r.filter((o) => o.id !== s);
|
|
819
|
+
},
|
|
820
|
+
async listRevisions(s, o) {
|
|
821
|
+
return c(s).revisions.filter((l) => !o || o in l.files).map(({ files: l, ...f }) => ({ ...f, ...o ? { path: o } : {} }));
|
|
822
|
+
},
|
|
823
|
+
async readRevision(s, o, l) {
|
|
824
|
+
const f = c(s).revisions.find((h) => h.id === o);
|
|
825
|
+
if (!f)
|
|
826
|
+
throw new Error(`Unknown revision "${o}"`);
|
|
827
|
+
return l ? f.files[l] ?? "" : JSON.stringify(f.files, null, 2);
|
|
828
|
+
},
|
|
829
|
+
async rollback(s, o, l) {
|
|
830
|
+
const f = c(s), h = f.revisions.find((p) => p.id === o);
|
|
831
|
+
if (!h)
|
|
832
|
+
throw new Error(`Unknown revision "${o}"`);
|
|
833
|
+
const g = l ? { [l]: h.files[l] } : h.files;
|
|
834
|
+
if (!l)
|
|
835
|
+
for (const p of [...f.files.keys()])
|
|
836
|
+
p in g || f.files.delete(p);
|
|
837
|
+
for (const [p, m] of Object.entries(g))
|
|
838
|
+
m !== void 0 && f.files.set(p, { text: m, version: ++n });
|
|
839
|
+
},
|
|
840
|
+
snapshot() {
|
|
841
|
+
return {
|
|
842
|
+
workspaces: i.map((s) => ({
|
|
843
|
+
...s.meta,
|
|
844
|
+
packages: [...s.packages.values()].map(({ workspaceId: o, ...l }) => l),
|
|
845
|
+
modules: [...s.modules.values()].map((o) => ({
|
|
846
|
+
id: o.id,
|
|
847
|
+
packageId: o.packageId,
|
|
848
|
+
label: o.label,
|
|
849
|
+
description: o.description,
|
|
850
|
+
icon: o.icon,
|
|
851
|
+
version: o.version,
|
|
852
|
+
readOnly: o.readOnly,
|
|
853
|
+
files: Object.fromEntries([...o.files.entries()].map(([l, f]) => [l, f.text]))
|
|
854
|
+
}))
|
|
855
|
+
})),
|
|
856
|
+
templates: r.map((s) => A(s)),
|
|
857
|
+
revisions: t
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
function Re(e) {
|
|
863
|
+
return e;
|
|
864
|
+
}
|
|
865
|
+
function L(e, t) {
|
|
866
|
+
if (!t || e === void 0 || e === null)
|
|
867
|
+
return !0;
|
|
868
|
+
if (t.enum && !t.enum.includes(e))
|
|
869
|
+
return !1;
|
|
870
|
+
switch (t.type) {
|
|
871
|
+
case "string":
|
|
872
|
+
return typeof e == "string";
|
|
873
|
+
case "number":
|
|
874
|
+
return typeof e == "number";
|
|
875
|
+
case "integer":
|
|
876
|
+
return Number.isInteger(e);
|
|
877
|
+
case "boolean":
|
|
878
|
+
return typeof e == "boolean";
|
|
879
|
+
case "array":
|
|
880
|
+
return Array.isArray(e) && (!t.items || e.every((n) => L(n, t.items)));
|
|
881
|
+
case "object": {
|
|
882
|
+
if (typeof e != "object" || Array.isArray(e))
|
|
883
|
+
return !1;
|
|
884
|
+
const n = t.properties;
|
|
885
|
+
return !n || Object.entries(e).every(([i, r]) => i in n && L(r, n[i]));
|
|
886
|
+
}
|
|
887
|
+
default:
|
|
888
|
+
return !0;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
function _e(e, t) {
|
|
892
|
+
var c;
|
|
893
|
+
const n = (e.fields ?? []).map((d) => d.name), i = (c = e.schema) == null ? void 0 : c.properties;
|
|
894
|
+
if (!e.schema || !i)
|
|
895
|
+
return { section: e, keys: n };
|
|
896
|
+
const r = Object.entries(i).filter(
|
|
897
|
+
([d, u]) => !(d in t) || L(t[d], u)
|
|
898
|
+
), a = r.map(([d]) => d);
|
|
899
|
+
return {
|
|
900
|
+
section: {
|
|
901
|
+
...e,
|
|
902
|
+
schema: {
|
|
903
|
+
...e.schema,
|
|
904
|
+
properties: Object.fromEntries(r),
|
|
905
|
+
...e.schema.required ? { required: e.schema.required.filter((d) => a.includes(d)) } : {}
|
|
906
|
+
}
|
|
907
|
+
},
|
|
908
|
+
keys: [...a, ...n]
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
function qe(e) {
|
|
912
|
+
var n;
|
|
913
|
+
const t = /* @__PURE__ */ new Set();
|
|
914
|
+
for (const i of e) {
|
|
915
|
+
for (const r of Object.keys(((n = i.schema) == null ? void 0 : n.properties) ?? {}))
|
|
916
|
+
t.add(r);
|
|
917
|
+
for (const r of i.fields ?? [])
|
|
918
|
+
t.add(r.name);
|
|
919
|
+
}
|
|
920
|
+
return t;
|
|
921
|
+
}
|
|
922
|
+
function ze(e) {
|
|
923
|
+
return e.map((t) => {
|
|
924
|
+
const n = t;
|
|
925
|
+
return {
|
|
926
|
+
name: String(n.tableName || n.name || "Entity"),
|
|
927
|
+
columns: (Array.isArray(n.fields) ? n.fields : []).map((i) => ({
|
|
928
|
+
name: String(i.name ?? ""),
|
|
929
|
+
// seeds spell the type both ways (OmniVerk: `dataType`, older files: `type`)
|
|
930
|
+
dataType: String(i.dataType ?? i.type ?? "string"),
|
|
931
|
+
isPrimaryKey: !!i.isPrimaryKey,
|
|
932
|
+
isForeignKey: !!(i.isForeignKey ?? i.foreignKey)
|
|
933
|
+
}))
|
|
934
|
+
};
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
function Be(e) {
|
|
938
|
+
const t = e.manifest ?? {}, n = String(t.displayName || t.packageName || "Module"), i = (e.views ?? []).map((a) => ({
|
|
939
|
+
id: `view:${a.id}`,
|
|
940
|
+
label: a.name,
|
|
941
|
+
type: "view"
|
|
942
|
+
})), r = (e.entities ?? []).map((a) => {
|
|
943
|
+
const c = String(a.name ?? "Entity");
|
|
944
|
+
return { id: `entity:${c}`, label: c, type: "entity" };
|
|
945
|
+
});
|
|
946
|
+
return {
|
|
947
|
+
roles: [
|
|
948
|
+
{ id: "admin", label: "Admin" },
|
|
949
|
+
{ id: "user", label: "User" }
|
|
950
|
+
],
|
|
951
|
+
actions: [
|
|
952
|
+
{ id: "view", label: "View" },
|
|
953
|
+
{ id: "create", label: "Create" },
|
|
954
|
+
{ id: "edit", label: "Edit" },
|
|
955
|
+
{ id: "delete", label: "Delete" }
|
|
956
|
+
],
|
|
957
|
+
resources: [
|
|
958
|
+
{
|
|
959
|
+
id: "module",
|
|
960
|
+
label: n,
|
|
961
|
+
type: "module",
|
|
962
|
+
children: [
|
|
963
|
+
...i.length ? [{ id: "views", label: "Views", type: "group", children: i }] : [],
|
|
964
|
+
...r.length ? [{ id: "entities", label: "Entities", type: "group", children: r }] : []
|
|
965
|
+
]
|
|
966
|
+
}
|
|
967
|
+
],
|
|
968
|
+
grants: {}
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
const _ = re({
|
|
972
|
+
id: "manifest",
|
|
973
|
+
label: "Manifest",
|
|
974
|
+
labelKey: "devStudio.kind.manifest",
|
|
975
|
+
icon: "file",
|
|
976
|
+
editor: "manifest",
|
|
977
|
+
match: S(".manifest.json")
|
|
978
|
+
}), Ne = J({
|
|
979
|
+
id: "entities",
|
|
980
|
+
label: "Entities",
|
|
981
|
+
labelKey: "devStudio.kind.entities",
|
|
982
|
+
icon: "database",
|
|
983
|
+
editor: "entities",
|
|
984
|
+
match: S(".entities.json"),
|
|
985
|
+
property: "entities",
|
|
986
|
+
itemKey: "name"
|
|
987
|
+
}), Ie = Ee();
|
|
988
|
+
function oe(e, t) {
|
|
989
|
+
const n = e, i = typeof e == "object" && e !== null && typeof n.id == "string";
|
|
990
|
+
return {
|
|
991
|
+
key: i ? n.id : `#${t}`,
|
|
992
|
+
label: i && n.name || (i ? n.id : `#${t + 1}`),
|
|
993
|
+
...i ? { definition: n } : { rawReason: "no id" },
|
|
994
|
+
source: e
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
const Me = ie({
|
|
998
|
+
id: "views",
|
|
999
|
+
label: "Views",
|
|
1000
|
+
labelKey: "devStudio.kind.views",
|
|
1001
|
+
icon: "grid",
|
|
1002
|
+
editor: "views",
|
|
1003
|
+
match: S(".views.json"),
|
|
1004
|
+
property: "views",
|
|
1005
|
+
itemKey: "id",
|
|
1006
|
+
toItem: (e, t) => oe(e, t),
|
|
1007
|
+
fromItem: (e) => e.definition ?? e.source
|
|
1008
|
+
}), xe = ie({
|
|
1009
|
+
id: "workflows",
|
|
1010
|
+
label: "Workflows",
|
|
1011
|
+
labelKey: "devStudio.kind.workflows",
|
|
1012
|
+
icon: "git-branch",
|
|
1013
|
+
editor: "workflows",
|
|
1014
|
+
match: S(".workflows.json"),
|
|
1015
|
+
property: "workflows",
|
|
1016
|
+
itemKey: "id",
|
|
1017
|
+
toItem: (e, t) => oe(e, t),
|
|
1018
|
+
fromItem: (e) => e.definition ?? e.source
|
|
1019
|
+
}), Je = J({
|
|
1020
|
+
id: "dataSources",
|
|
1021
|
+
label: "Data sources",
|
|
1022
|
+
labelKey: "devStudio.kind.dataSources",
|
|
1023
|
+
icon: "database",
|
|
1024
|
+
editor: "dataSources",
|
|
1025
|
+
match: S(".datasources.json"),
|
|
1026
|
+
property: "dataSources",
|
|
1027
|
+
itemKey: "key"
|
|
1028
|
+
}), Te = re({
|
|
1029
|
+
id: "rbac",
|
|
1030
|
+
label: "Access",
|
|
1031
|
+
labelKey: "devStudio.kind.rbac",
|
|
1032
|
+
icon: "shield",
|
|
1033
|
+
editor: "rbac",
|
|
1034
|
+
match: S(".rbac.json")
|
|
1035
|
+
}), Fe = J({
|
|
1036
|
+
id: "hooks",
|
|
1037
|
+
label: "Lifecycle hooks",
|
|
1038
|
+
labelKey: "devStudio.kind.hooks",
|
|
1039
|
+
icon: "zap",
|
|
1040
|
+
editor: "hooks",
|
|
1041
|
+
match: S(".hooks.json"),
|
|
1042
|
+
property: "bindings",
|
|
1043
|
+
itemKey: "id"
|
|
1044
|
+
}), Pe = [
|
|
1045
|
+
_,
|
|
1046
|
+
Ne,
|
|
1047
|
+
Ie,
|
|
1048
|
+
Me,
|
|
1049
|
+
xe,
|
|
1050
|
+
Je,
|
|
1051
|
+
Te,
|
|
1052
|
+
Fe
|
|
1053
|
+
];
|
|
1054
|
+
function B(e) {
|
|
1055
|
+
return e.normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/ł/g, "l").replace(/Ł/g, "L").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "module";
|
|
1056
|
+
}
|
|
1057
|
+
const W = (e) => {
|
|
1058
|
+
const t = e.find((n) => _.match(n.path));
|
|
1059
|
+
return t ? je(t.text, void 0) : void 0;
|
|
1060
|
+
};
|
|
1061
|
+
function De(e) {
|
|
1062
|
+
const t = e.find((n) => _.match(n.path));
|
|
1063
|
+
return t ? K(t.path).replace(/\.manifest\.json$/i, "") : "module";
|
|
1064
|
+
}
|
|
1065
|
+
const G = (e) => Array.isArray(e.fields) ? e.fields : [], We = {
|
|
1066
|
+
id: "native",
|
|
1067
|
+
kinds: Pe,
|
|
1068
|
+
locales: ["en", "pl", "de", "fr", "es", "uk"],
|
|
1069
|
+
requiredLocales: ["en"],
|
|
1070
|
+
moduleId: (e) => {
|
|
1071
|
+
const t = W(e), n = (t == null ? void 0 : t.id) ?? (t == null ? void 0 : t.packageName);
|
|
1072
|
+
return typeof n == "string" ? n : void 0;
|
|
1073
|
+
},
|
|
1074
|
+
validateModule: ({ files: e }) => {
|
|
1075
|
+
const t = W(e);
|
|
1076
|
+
return t ? ["id", "name", "version"].filter((n) => typeof t[n] != "string" || !t[n]).map((n) => ({
|
|
1077
|
+
severity: "error",
|
|
1078
|
+
code: "manifest.required",
|
|
1079
|
+
message: `The manifest needs "${n}".`,
|
|
1080
|
+
messageKey: "devStudio.issue.manifestRequired",
|
|
1081
|
+
params: { field: n },
|
|
1082
|
+
pointer: `/${n}`
|
|
1083
|
+
})) : [
|
|
1084
|
+
{
|
|
1085
|
+
severity: "error",
|
|
1086
|
+
code: "manifest.missing",
|
|
1087
|
+
message: "The module has no manifest.",
|
|
1088
|
+
messageKey: "devStudio.issue.manifestMissing"
|
|
1089
|
+
}
|
|
1090
|
+
];
|
|
1091
|
+
},
|
|
1092
|
+
newFile: (e, { files: t }) => {
|
|
1093
|
+
const n = De(t), r = {
|
|
1094
|
+
entities: ["entities.json", { entities: [] }],
|
|
1095
|
+
views: ["views.json", { views: [] }],
|
|
1096
|
+
workflows: ["workflows.json", { workflows: [] }],
|
|
1097
|
+
dataSources: ["datasources.json", { dataSources: [] }],
|
|
1098
|
+
rbac: ["rbac.json", { roles: [], actions: [], resources: [], grants: {} }],
|
|
1099
|
+
hooks: ["hooks.json", { bindings: [] }]
|
|
1100
|
+
}[e];
|
|
1101
|
+
return r ? { path: `${n}.${r[0]}`, text: k(r[1]) } : void 0;
|
|
1102
|
+
},
|
|
1103
|
+
generateModule: async (e, { existingIds: t }) => {
|
|
1104
|
+
let n = B(e.name);
|
|
1105
|
+
for (let r = 2; t.has(n); r++)
|
|
1106
|
+
n = `${B(e.name)}-${r}`;
|
|
1107
|
+
const i = [
|
|
1108
|
+
{
|
|
1109
|
+
path: `${n}.manifest.json`,
|
|
1110
|
+
text: k({
|
|
1111
|
+
id: n,
|
|
1112
|
+
name: e.name,
|
|
1113
|
+
version: "1.0.0",
|
|
1114
|
+
...e.description ? { description: e.description } : {},
|
|
1115
|
+
...e.icon ? { icon: e.icon } : {},
|
|
1116
|
+
...e.packageId ? { category: e.packageId } : {}
|
|
1117
|
+
})
|
|
1118
|
+
},
|
|
1119
|
+
{ path: `${n}.entities.json`, text: k({ entities: e.entities }) }
|
|
1120
|
+
];
|
|
1121
|
+
for (const r of e.locales) {
|
|
1122
|
+
const a = { "module.displayName": e.name };
|
|
1123
|
+
for (const c of e.entities) {
|
|
1124
|
+
const d = String(c.name ?? "");
|
|
1125
|
+
a[`entity.${d}.displayName`] = d;
|
|
1126
|
+
for (const u of G(c))
|
|
1127
|
+
a[`field.${d}.${String(u.name)}.label`] = String(u.name);
|
|
1128
|
+
}
|
|
1129
|
+
i.push({
|
|
1130
|
+
path: `${n}.${r}.i18n.json`,
|
|
1131
|
+
text: k({ locale: r, translations: a })
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
if (e.views) {
|
|
1135
|
+
const r = e.entities.map((a) => {
|
|
1136
|
+
const c = String(a.name ?? "Item");
|
|
1137
|
+
return {
|
|
1138
|
+
id: `${c}List`,
|
|
1139
|
+
name: `${c} list`,
|
|
1140
|
+
kind: "grid",
|
|
1141
|
+
version: 2,
|
|
1142
|
+
columns: 12,
|
|
1143
|
+
dataSources: [{ key: "rows", type: "entity", entity: c, autoLoad: !0 }],
|
|
1144
|
+
rows: [
|
|
1145
|
+
{
|
|
1146
|
+
id: "r1",
|
|
1147
|
+
cells: [
|
|
1148
|
+
{
|
|
1149
|
+
id: "grid",
|
|
1150
|
+
controlType: "dataGrid",
|
|
1151
|
+
colSpan: 12,
|
|
1152
|
+
props: {
|
|
1153
|
+
columns: G(a).map((d) => ({
|
|
1154
|
+
field: String(d.name),
|
|
1155
|
+
header: String(d.name)
|
|
1156
|
+
}))
|
|
1157
|
+
},
|
|
1158
|
+
bindings: { data: { source: "rows", field: "" } }
|
|
1159
|
+
}
|
|
1160
|
+
]
|
|
1161
|
+
}
|
|
1162
|
+
]
|
|
1163
|
+
};
|
|
1164
|
+
});
|
|
1165
|
+
i.push({ path: `${n}.views.json`, text: k({ views: r }) });
|
|
1166
|
+
}
|
|
1167
|
+
if (e.permissions) {
|
|
1168
|
+
const r = {
|
|
1169
|
+
roles: [
|
|
1170
|
+
{ id: "viewer", label: "Viewer" },
|
|
1171
|
+
{ id: "editor", label: "Editor" },
|
|
1172
|
+
{ id: "admin", label: "Admin" }
|
|
1173
|
+
],
|
|
1174
|
+
actions: [
|
|
1175
|
+
{ id: "view", label: "View" },
|
|
1176
|
+
{ id: "edit", label: "Edit" },
|
|
1177
|
+
{ id: "delete", label: "Delete" }
|
|
1178
|
+
],
|
|
1179
|
+
resources: e.entities.map((a) => ({
|
|
1180
|
+
id: `entity:${String(a.name)}`,
|
|
1181
|
+
label: String(a.name),
|
|
1182
|
+
type: "entity"
|
|
1183
|
+
})),
|
|
1184
|
+
grants: {}
|
|
1185
|
+
};
|
|
1186
|
+
i.push({ path: `${n}.rbac.json`, text: k(r) });
|
|
1187
|
+
}
|
|
1188
|
+
return { id: n, packageId: e.packageId, files: i };
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
export {
|
|
1192
|
+
J as arrayFileKind,
|
|
1193
|
+
Ce as buildDocuments,
|
|
1194
|
+
Ue as createMemoryStudioProvider,
|
|
1195
|
+
Re as defineManifestSection,
|
|
1196
|
+
Be as deriveDefaultRbac,
|
|
1197
|
+
C as detectJsonTextFormat,
|
|
1198
|
+
Ve as encodeDocument,
|
|
1199
|
+
S as endsWithAny,
|
|
1200
|
+
ze as entitiesToSchemas,
|
|
1201
|
+
K as fileName,
|
|
1202
|
+
_e as fitManifestSection,
|
|
1203
|
+
Ee as i18nFileKind,
|
|
1204
|
+
ie as itemsFileKind,
|
|
1205
|
+
F as jsonFallbackKind,
|
|
1206
|
+
R as jsonFileKind,
|
|
1207
|
+
L as jsonValueFitsSchema,
|
|
1208
|
+
I as jsonValuesEqual,
|
|
1209
|
+
le as keepTextFormat,
|
|
1210
|
+
qe as manifestSectionKeys,
|
|
1211
|
+
De as modulePrefix,
|
|
1212
|
+
Je as nativeDataSourcesKind,
|
|
1213
|
+
Ne as nativeEntitiesKind,
|
|
1214
|
+
Pe as nativeFileKinds,
|
|
1215
|
+
Fe as nativeHooksKind,
|
|
1216
|
+
Ie as nativeI18nKind,
|
|
1217
|
+
_ as nativeManifestKind,
|
|
1218
|
+
Te as nativeRbacKind,
|
|
1219
|
+
We as nativeStudioPreset,
|
|
1220
|
+
Me as nativeViewsKind,
|
|
1221
|
+
xe as nativeWorkflowsKind,
|
|
1222
|
+
re as objectFileKind,
|
|
1223
|
+
E as parseJsonText,
|
|
1224
|
+
X as patchJsonText,
|
|
1225
|
+
de as patchJsonTextDetailed,
|
|
1226
|
+
Ae as readTranslations,
|
|
1227
|
+
ve as resolveFileKind,
|
|
1228
|
+
je as safeJson,
|
|
1229
|
+
B as slugifyModuleId,
|
|
1230
|
+
k as stringifyJsonText,
|
|
1231
|
+
P as textFallbackKind,
|
|
1232
|
+
z as writeTranslations
|
|
1233
|
+
};
|