@plitzi/sdk-schema 0.39.1 → 0.39.2
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/CHANGELOG.md +10 -0
- package/dist/SchemaReducer.mjs +25 -26
- package/dist/helpers/FlatMap.mjs +1 -2
- package/dist/helpers/components.mjs +1 -2
- package/dist/helpers/elementId.mjs +1 -2
- package/dist/helpers/elementTree.mjs +1 -2
- package/dist/helpers/fitSnippet.mjs +4 -5
- package/dist/helpers/schemaValidator/bindings.mjs +1 -2
- package/dist/helpers/schemaValidator/components.mjs +41 -42
- package/dist/helpers/schemaValidator/context.mjs +1 -2
- package/dist/helpers/schemaValidator/index.mjs +1 -2
- package/dist/helpers/schemaValidator/pages.mjs +1 -2
- package/dist/helpers/schemaValidator/structure.mjs +2 -3
- package/dist/helpers/schemaValidator/types.mjs +1 -2
- package/dist/helpers/styleWithoutTag.mjs +1 -2
- package/dist/index.mjs +9 -9
- package/package.json +13 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @plitzi/sdk-schema
|
|
2
2
|
|
|
3
|
+
## 0.39.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fad1264: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
8
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
9
|
+
- Updated dependencies [fad1264]
|
|
10
|
+
- @plitzi/sdk-shared@0.39.2
|
|
11
|
+
- @plitzi/sdk-style@0.39.2
|
|
12
|
+
|
|
3
13
|
## 0.39.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/SchemaReducer.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import e from "./helpers/
|
|
2
|
-
import
|
|
1
|
+
import { addComponent as e, detachInstance as t, flatMapOf as n, removeComponent as r, renameElement as i, updateComponent as a } from "./helpers/components.mjs";
|
|
2
|
+
import o from "./helpers/FlatMap.mjs";
|
|
3
3
|
import { get as s, has as c, set as l } from "@plitzi/plitzi-ui/helpers";
|
|
4
4
|
import { produce as u } from "immer";
|
|
5
5
|
import { isSchemaSetting as d } from "@plitzi/sdk-shared/schema";
|
|
6
|
-
|
|
6
|
+
// src/SchemaReducer.ts
|
|
7
7
|
var f = (e, t) => {
|
|
8
8
|
if (t.length === 0) return;
|
|
9
9
|
let n = t.filter((t) => e.variables && !e.variables.find((e) => e.name === t.name));
|
|
@@ -69,9 +69,9 @@ var f = (e, t) => {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
case p.SCHEMA_REMOVE_PAGE: {
|
|
72
|
-
let { pageId:
|
|
73
|
-
return u(m, (
|
|
74
|
-
|
|
72
|
+
let { pageId: e } = h;
|
|
73
|
+
return u(m, (t) => {
|
|
74
|
+
o.removeElement(t.flat, e, !0), t.pages = t.pages.filter((t) => t !== e);
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
case p.SCHEMA_ADD_PAGE_FOLDER: {
|
|
@@ -129,56 +129,56 @@ var f = (e, t) => {
|
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
case p.SCHEMA_ADD_ELEMENT: {
|
|
132
|
-
let { to: e, data: t, dropPosition:
|
|
132
|
+
let { to: e, data: t, dropPosition: r, initialItems: i, variables: a = [] } = h;
|
|
133
133
|
return u(m, (o) => {
|
|
134
|
-
|
|
134
|
+
n(o, e)?.addElement(t, e, r, i), f(o, a);
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
case p.SCHEMA_ADD_SNIPPET: {
|
|
138
|
-
let { to: e, data: t, dropPosition:
|
|
138
|
+
let { to: e, data: t, dropPosition: r, initialItems: i, variables: a = [] } = h;
|
|
139
139
|
return u(m, (o) => {
|
|
140
140
|
let { [t.id]: s, ...c } = structuredClone({
|
|
141
141
|
...i,
|
|
142
142
|
[t.id]: t
|
|
143
143
|
});
|
|
144
|
-
|
|
144
|
+
n(o, e)?.addElement(s, e, r, c) && f(o, a);
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
case p.SCHEMA_REMOVE_ELEMENT: {
|
|
148
148
|
let { elementId: e } = h;
|
|
149
149
|
return u(m, (t) => {
|
|
150
|
-
|
|
150
|
+
n(t, e)?.removeElement(e);
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
case p.SCHEMA_MOVE_ELEMENT: {
|
|
154
|
-
let { from: e, to: t, elementId:
|
|
154
|
+
let { from: e, to: t, elementId: r, dropPosition: i } = h;
|
|
155
155
|
return u(m, (a) => {
|
|
156
|
-
let o =
|
|
157
|
-
o && Object.hasOwn(o.flat, t) && o.moveElement(e, t,
|
|
156
|
+
let o = n(a, r);
|
|
157
|
+
o && Object.hasOwn(o.flat, t) && o.moveElement(e, t, r, i);
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
case p.SCHEMA_CLONE_ELEMENT: {
|
|
161
|
-
let { to: e, data: t, dropPosition:
|
|
161
|
+
let { to: e, data: t, dropPosition: r, initialItems: i } = h;
|
|
162
162
|
return u(m, (a) => {
|
|
163
|
-
|
|
163
|
+
n(a, e)?.addElement(t, e, r, i);
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
case p.SCHEMA_UPDATE_ELEMENT: {
|
|
167
167
|
let { element: e } = h;
|
|
168
168
|
return u(m, (t) => {
|
|
169
|
-
|
|
169
|
+
n(t, e.id)?.updateElement(e);
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
case p.SCHEMA_RENAME_ELEMENT: {
|
|
173
173
|
let { elementId: e, id: t } = h;
|
|
174
174
|
return u(m, (n) => {
|
|
175
|
-
|
|
175
|
+
i(n, e, t);
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
178
|
case p.SCHEMA_UPDATE_ELEMENTS: {
|
|
179
179
|
let { elements: e } = h;
|
|
180
180
|
return u(m, (t) => {
|
|
181
|
-
e.forEach((e) =>
|
|
181
|
+
e.forEach((e) => n(t, e.id)?.updateElement(e));
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
184
|
case p.SCHEMA_UPDATE_SETTINGS: {
|
|
@@ -188,31 +188,30 @@ var f = (e, t) => {
|
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
190
|
case p.SCHEMA_ADD_COMPONENT: {
|
|
191
|
-
let { component:
|
|
191
|
+
let { component: t, from: n } = h;
|
|
192
192
|
return u(m, (r) => {
|
|
193
|
-
|
|
193
|
+
e(r, structuredClone(t), n);
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
case p.SCHEMA_UPDATE_COMPONENT: {
|
|
197
197
|
let { componentId: e, declaration: t } = h;
|
|
198
198
|
return u(m, (n) => {
|
|
199
|
-
|
|
199
|
+
a(n, e, t);
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
case p.SCHEMA_REMOVE_COMPONENT: {
|
|
203
203
|
let { componentId: e } = h;
|
|
204
204
|
return u(m, (t) => {
|
|
205
|
-
|
|
205
|
+
r(t, e);
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
208
|
case p.SCHEMA_DETACH_INSTANCE: {
|
|
209
209
|
let { instanceId: e } = h;
|
|
210
|
-
return u(m, (
|
|
211
|
-
n
|
|
210
|
+
return u(m, (n) => {
|
|
211
|
+
t(n, e);
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
214
|
default: return m;
|
|
215
215
|
}
|
|
216
216
|
};
|
|
217
|
-
//#endregion
|
|
218
217
|
export { p as SchemaActions, m as default };
|
package/dist/helpers/FlatMap.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { descendants as o, parentChain as s } from "./elementTree.mjs";
|
|
|
3
3
|
import { VARIABLE_REGEX as c } from "@plitzi/sdk-shared/schema";
|
|
4
4
|
import { EMPTY_STYLE_SCHEMA as l } from "@plitzi/sdk-shared/style";
|
|
5
5
|
import { calculateInheriting as u } from "@plitzi/sdk-style/helpers";
|
|
6
|
-
|
|
6
|
+
// src/helpers/FlatMap.ts
|
|
7
7
|
var d = class {
|
|
8
8
|
flat;
|
|
9
9
|
variables;
|
|
@@ -196,5 +196,4 @@ var d = class {
|
|
|
196
196
|
}).flatAsSnippet(t, n, r);
|
|
197
197
|
};
|
|
198
198
|
};
|
|
199
|
-
//#endregion
|
|
200
199
|
export { d as default };
|
|
@@ -2,7 +2,7 @@ import { isValidElementId as e, repointIds as t, uniqueElementId as n } from "./
|
|
|
2
2
|
import { descendants as r } from "./elementTree.mjs";
|
|
3
3
|
import i from "./FlatMap.mjs";
|
|
4
4
|
import { jsonCopy as a } from "@plitzi/sdk-shared/history";
|
|
5
|
-
|
|
5
|
+
// src/helpers/components.ts
|
|
6
6
|
var o = /* @__PURE__ */ new Set([
|
|
7
7
|
"referenceType",
|
|
8
8
|
"referenceId",
|
|
@@ -126,5 +126,4 @@ var o = /* @__PURE__ */ new Set([
|
|
|
126
126
|
}
|
|
127
127
|
return Object.assign(o.flat, b), delete o.flat[i], f.definition.items = f.definition.items.map((e) => e === i ? x.id : e), x.id;
|
|
128
128
|
};
|
|
129
|
-
//#endregion
|
|
130
129
|
export { o as RESERVED_PROP_NAMES, y as addComponent, p as componentNamed, S as detachInstance, d as documentIds, f as flatMapOf, h as instancesOf, m as isInstance, c as propNameProblem, x as removeComponent, g as renameElement, u as treeOf, l as treesOf, b as updateComponent };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/helpers/elementId.ts
|
|
2
2
|
var e = /^[A-Za-z](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?$/, t = (t) => e.test(t), n = (e) => e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^A-Za-z0-9_-]+/g, "-").replace(/-{2,}/g, "-").replace(/^[^A-Za-z]+/, "").replace(/-+$/, ""), r = (e) => new Set(Object.keys(e)), i = (e, n, r) => t(n) ? e[n] && n !== r ? `"${n}" is already used by another element here` : null : `"${n}" is not a valid name: start with a letter, then letters, numbers, hyphens and underscores`, a = (e, t) => {
|
|
3
3
|
let n = /* @__PURE__ */ new Set();
|
|
4
4
|
for (let r of t) {
|
|
@@ -106,5 +106,4 @@ var e = /^[A-Za-z](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?$/, t = (t) => e.test(t), n = (
|
|
|
106
106
|
}
|
|
107
107
|
return _(e, n), n;
|
|
108
108
|
};
|
|
109
|
-
//#endregion
|
|
110
109
|
export { i as elementIdConflict, a as elementIdsFree, t as isValidElementId, l as positionalElementId, c as randomElementId, v as remapCollidingIds, _ as repointIds, n as slugifyElementId, r as takenIds, u as uniqueElementId };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/helpers/elementTree.ts
|
|
2
2
|
var e = (e, t) => t && Object.hasOwn(e, t) ? e[t] : void 0, t = (t, n) => {
|
|
3
3
|
let r = [], i = /* @__PURE__ */ new Set([n]);
|
|
4
4
|
for (let a = e(t, e(t, n)?.definition.parentId); a && !i.has(a.id);) i.add(a.id), r.push(a.id), a = e(t, a.definition.parentId);
|
|
@@ -37,5 +37,4 @@ var e = (e, t) => t && Object.hasOwn(e, t) ? e[t] : void 0, t = (t, n) => {
|
|
|
37
37
|
elements: n
|
|
38
38
|
})).sort((e, t) => t.elements - e.elements);
|
|
39
39
|
};
|
|
40
|
-
//#endregion
|
|
41
40
|
export { r as descendants, a as elementsByRoot, t as parentChain, n as renderContext, i as rootName };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { documentIds as e } from "./components.mjs";
|
|
2
|
+
import { remapCollidingIds as t } from "./elementId.mjs";
|
|
3
3
|
import { isDisplayMode as n, sameSelector as r, selectorsOf as i } from "@plitzi/sdk-shared/style";
|
|
4
4
|
import { processSelector as a } from "@plitzi/sdk-style/helpers";
|
|
5
|
-
|
|
5
|
+
// src/helpers/fitSnippet.ts
|
|
6
6
|
var o = (e, t) => {
|
|
7
7
|
let n = 2;
|
|
8
8
|
for (; t.has(`${e}-${n}`);) n += 1;
|
|
@@ -57,7 +57,7 @@ var o = (e, t) => {
|
|
|
57
57
|
let i = structuredClone({
|
|
58
58
|
...r.initialItems,
|
|
59
59
|
[r.data.id]: r.data
|
|
60
|
-
}), a =
|
|
60
|
+
}), a = e(n.schema), o = t(i, (e) => a.has(e)), c = r.style ? s(n.style.platform, r.style.platform) : /* @__PURE__ */ new Map();
|
|
61
61
|
u(i, c);
|
|
62
62
|
let { [o[r.data.id] ?? r.data.id]: d, ...f } = i;
|
|
63
63
|
return {
|
|
@@ -66,5 +66,4 @@ var o = (e, t) => {
|
|
|
66
66
|
style: r.style && l(r.style, c)
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
|
-
//#endregion
|
|
70
69
|
export { d as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isValidElementId as e } from "../elementId.mjs";
|
|
2
|
-
|
|
2
|
+
// src/helpers/schemaValidator/bindings.ts
|
|
3
3
|
var t = ({ errors: e, warnings: t, variables: n }) => {
|
|
4
4
|
let r = /* @__PURE__ */ new Set();
|
|
5
5
|
n.forEach((n, i) => {
|
|
@@ -117,5 +117,4 @@ var t = ({ errors: e, warnings: t, variables: n }) => {
|
|
|
117
117
|
});
|
|
118
118
|
});
|
|
119
119
|
};
|
|
120
|
-
//#endregion
|
|
121
120
|
export { n as validateBindingSources, i as validateBindings, r as validateInteractions, t as validateVariables };
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { isInstance as e, propNameProblem as t } from "../components.mjs";
|
|
2
|
+
import { isValidElementId as n } from "../elementId.mjs";
|
|
3
|
+
// src/helpers/schemaValidator/components.ts
|
|
4
4
|
var r = ({ errors: r, warnings: i, flat: a, components: o, schema: s, options: c }, l) => {
|
|
5
5
|
let u = new Map(Object.keys(a).map((e) => [e, ""])), d = (e) => e ? `component "${e}"` : "the pages", f = /* @__PURE__ */ new Map();
|
|
6
|
-
Object.entries(o).forEach(([
|
|
7
|
-
let o = `Component "${
|
|
8
|
-
a.id !==
|
|
6
|
+
Object.entries(o).forEach(([e, a]) => {
|
|
7
|
+
let o = `Component "${e}"`;
|
|
8
|
+
a.id !== e && r.push({
|
|
9
9
|
code: "COMPONENT_ID_MISMATCH",
|
|
10
10
|
message: `${o} has id "${a.id}"`,
|
|
11
|
-
componentId:
|
|
12
|
-
}), e
|
|
11
|
+
componentId: e
|
|
12
|
+
}), n(e) || r.push({
|
|
13
13
|
code: "INVALID_COMPONENT_ID",
|
|
14
14
|
message: `${o} has a name that must start with a letter, then letters, numbers, hyphens and underscores`,
|
|
15
|
-
componentId:
|
|
15
|
+
componentId: e
|
|
16
16
|
});
|
|
17
17
|
let f = a.flat[a.rootId];
|
|
18
18
|
if (!f) {
|
|
19
19
|
r.push({
|
|
20
20
|
code: "COMPONENT_ROOT_MISSING",
|
|
21
21
|
message: `${o} is rooted at "${a.rootId}", which is not an element of its tree`,
|
|
22
|
-
componentId:
|
|
22
|
+
componentId: e
|
|
23
23
|
});
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
@@ -27,27 +27,27 @@ var r = ({ errors: r, warnings: i, flat: a, components: o, schema: s, options: c
|
|
|
27
27
|
code: "COMPONENT_ROOT_HAS_PARENT",
|
|
28
28
|
message: `${o} is rooted at "${a.rootId}", which names a parent — a component's root has none`,
|
|
29
29
|
elementId: a.rootId,
|
|
30
|
-
componentId:
|
|
31
|
-
}), Object.keys(a.flat).forEach((
|
|
32
|
-
let n = u.get(
|
|
33
|
-
n === void 0 ? u.set(
|
|
30
|
+
componentId: e
|
|
31
|
+
}), Object.keys(a.flat).forEach((t) => {
|
|
32
|
+
let n = u.get(t);
|
|
33
|
+
n === void 0 ? u.set(t, e) : r.push({
|
|
34
34
|
code: "DUPLICATE_ELEMENT_ID",
|
|
35
|
-
message: `"${
|
|
36
|
-
elementId:
|
|
37
|
-
componentId:
|
|
35
|
+
message: `"${t}" names an element of ${d(n)} and one of ${d(e)} — an id is one element in the whole space`,
|
|
36
|
+
elementId: t,
|
|
37
|
+
componentId: e
|
|
38
38
|
});
|
|
39
|
-
}), Object.keys(a.props ?? {}).forEach((
|
|
40
|
-
let i = n
|
|
39
|
+
}), Object.keys(a.props ?? {}).forEach((n) => {
|
|
40
|
+
let i = t(n);
|
|
41
41
|
i && r.push({
|
|
42
42
|
code: "INVALID_COMPONENT_PROP",
|
|
43
43
|
message: `${o}: ${i}`,
|
|
44
|
-
componentId:
|
|
44
|
+
componentId: e
|
|
45
45
|
});
|
|
46
|
-
}), (a.slots ?? []).forEach((
|
|
47
|
-
Object.hasOwn(a.flat,
|
|
46
|
+
}), (a.slots ?? []).forEach((t) => {
|
|
47
|
+
Object.hasOwn(a.flat, t) || r.push({
|
|
48
48
|
code: "MISSING_COMPONENT_SLOT",
|
|
49
|
-
message: `${o} declares slot "${
|
|
50
|
-
componentId:
|
|
49
|
+
message: `${o} declares slot "${t}", which is not an element of its tree`,
|
|
50
|
+
componentId: e
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
53
|
let p = l({
|
|
@@ -60,31 +60,31 @@ var r = ({ errors: r, warnings: i, flat: a, components: o, schema: s, options: c
|
|
|
60
60
|
baseElementId: a.rootId,
|
|
61
61
|
sourceTypes: c?.sourceTypes
|
|
62
62
|
});
|
|
63
|
-
p.errors.forEach((
|
|
64
|
-
...
|
|
65
|
-
message: `${o}: ${
|
|
66
|
-
componentId:
|
|
67
|
-
})), p.warnings.forEach((
|
|
68
|
-
...
|
|
69
|
-
message: `${o}: ${
|
|
70
|
-
componentId:
|
|
63
|
+
p.errors.forEach((t) => r.push({
|
|
64
|
+
...t,
|
|
65
|
+
message: `${o}: ${t.message}`,
|
|
66
|
+
componentId: e
|
|
67
|
+
})), p.warnings.forEach((t) => i.push({
|
|
68
|
+
...t,
|
|
69
|
+
message: `${o}: ${t.message}`,
|
|
70
|
+
componentId: e
|
|
71
71
|
}));
|
|
72
|
-
}), [["", a], ...Object.entries(o).map(([e, t]) => [e, t.flat])].forEach(([
|
|
72
|
+
}), [["", a], ...Object.entries(o).map(([e, t]) => [e, t.flat])].forEach(([t, n]) => {
|
|
73
73
|
Object.values(n).forEach((i) => {
|
|
74
|
-
if (!i || !
|
|
74
|
+
if (!i || !e(i)) return;
|
|
75
75
|
let a = i.attributes.referenceId, s = typeof a == "string" ? o[a] : void 0;
|
|
76
76
|
!s || typeof a != "string" ? r.push({
|
|
77
77
|
code: "UNRESOLVED_COMPONENT",
|
|
78
78
|
message: `Instance "${i.id}" places component "${String(a)}", which this space does not declare`,
|
|
79
79
|
elementId: i.id,
|
|
80
|
-
...
|
|
81
|
-
}) : (
|
|
82
|
-
let o = n[
|
|
83
|
-
|
|
80
|
+
...t ? { componentId: t } : {}
|
|
81
|
+
}) : (t && f.set(t, (f.get(t) ?? /* @__PURE__ */ new Set()).add(a)), (i.definition.items ?? []).forEach((e) => {
|
|
82
|
+
let o = n[e]?.attributes.slot ?? s.slots?.[0];
|
|
83
|
+
typeof o == "string" && s.slots?.includes(o) || r.push({
|
|
84
84
|
code: "UNKNOWN_COMPONENT_SLOT",
|
|
85
|
-
message: `"${
|
|
86
|
-
elementId:
|
|
87
|
-
...
|
|
85
|
+
message: `"${e}" fills ${typeof o == "string" ? `slot "${o}"` : "a slot"} of instance "${i.id}", but component "${a}" declares ${s.slots?.length ? `only ${s.slots.map((e) => `"${e}"`).join(", ")}` : "no slots"}`,
|
|
86
|
+
elementId: e,
|
|
87
|
+
...t ? { componentId: t } : {}
|
|
88
88
|
});
|
|
89
89
|
}));
|
|
90
90
|
});
|
|
@@ -102,5 +102,4 @@ var r = ({ errors: r, warnings: i, flat: a, components: o, schema: s, options: c
|
|
|
102
102
|
};
|
|
103
103
|
Object.keys(o).forEach((e) => m(e, []));
|
|
104
104
|
};
|
|
105
|
-
//#endregion
|
|
106
105
|
export { r as validateComponents };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/helpers/schemaValidator/context.ts
|
|
2
2
|
var e = (e, t) => {
|
|
3
3
|
let n = [], r = [], { flat: i, pages: a, pageFolders: o, variables: s, components: c } = e, l = t?.baseElementId, u = (e) => !!i[e], d = (e) => i[e], f = () => Object.values(i).filter((e) => e?.definition?.type === "layoutContainer" && !e.definition.parentId).map((e) => e.id);
|
|
4
4
|
return {
|
|
@@ -22,5 +22,4 @@ var e = (e, t) => {
|
|
|
22
22
|
])]
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
//#endregion
|
|
26
25
|
export { e as createValidationContext };
|
|
@@ -4,7 +4,7 @@ import { createValidationContext as a } from "./context.mjs";
|
|
|
4
4
|
import { validateLayoutCycles as o, validateOrphanedElements as s, validatePageFolders as c, validatePages as l, validateRootConsistency as u } from "./pages.mjs";
|
|
5
5
|
import { validateCircularReferences as d, validateElementIds as f, validateElements as p, validateParentChildConsistency as m, validateStructure as h } from "./structure.mjs";
|
|
6
6
|
import { REFERENCE_ERROR_CODES as g, isIntegrityError as _ } from "./types.mjs";
|
|
7
|
-
|
|
7
|
+
// src/helpers/schemaValidator/index.ts
|
|
8
8
|
var v = (g, _) => {
|
|
9
9
|
let y = a(g, _), { errors: b, warnings: x, baseElementId: S } = y;
|
|
10
10
|
return h(y) ? (p(y), m(y), d(y), l(y), u(y), c(y), o(y), s(y), r(y), f(y), e(y, _?.sourceTypes), t(y), n(y), S || i(y, v), {
|
|
@@ -23,5 +23,4 @@ var v = (g, _) => {
|
|
|
23
23
|
throw Error(e);
|
|
24
24
|
}
|
|
25
25
|
}, x = (e, t) => y(e, t).valid;
|
|
26
|
-
//#endregion
|
|
27
26
|
export { g as REFERENCE_ERROR_CODES, b as assertSchemaValid, _ as isIntegrityError, x as isSchemaValid, y as validateSchema };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { findLayoutCycle as e } from "@plitzi/sdk-shared/schema";
|
|
2
|
-
|
|
2
|
+
// src/helpers/schemaValidator/pages.ts
|
|
3
3
|
var t = ({ errors: e, warnings: t, pages: n, getElement: r }) => {
|
|
4
4
|
let i = /* @__PURE__ */ new Set(), a = 0;
|
|
5
5
|
n.forEach((t, n) => {
|
|
@@ -98,5 +98,4 @@ var t = ({ errors: e, warnings: t, pages: n, getElement: r }) => {
|
|
|
98
98
|
});
|
|
99
99
|
});
|
|
100
100
|
};
|
|
101
|
-
//#endregion
|
|
102
101
|
export { i as validateLayoutCycles, a as validateOrphanedElements, r as validatePageFolders, t as validatePages, n as validateRootConsistency };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isValidElementId as e } from "../elementId.mjs";
|
|
2
|
-
|
|
2
|
+
// src/helpers/schemaValidator/structure.ts
|
|
3
3
|
var t = ({ errors: e, flat: t, pages: n, pageFolders: r, variables: i, components: a }) => !t || typeof t != "object" ? (e.push({
|
|
4
4
|
code: "INVALID_FLAT",
|
|
5
5
|
message: "Schema.flat must be a valid Record<string, Element>"
|
|
@@ -57,7 +57,7 @@ var t = ({ errors: e, flat: t, pages: n, pageFolders: r, variables: i, component
|
|
|
57
57
|
code: "MISSING_ROOT_ID",
|
|
58
58
|
message: "Element missing definition.rootId",
|
|
59
59
|
elementId: n
|
|
60
|
-
}),
|
|
60
|
+
}), a.styleSelectors && typeof a.styleSelectors == "object" || e.push({
|
|
61
61
|
code: "MISSING_STYLE_SELECTORS",
|
|
62
62
|
message: "Element missing or invalid definition.styleSelectors",
|
|
63
63
|
elementId: n
|
|
@@ -152,5 +152,4 @@ var t = ({ errors: e, flat: t, pages: n, pageFolders: r, variables: i, component
|
|
|
152
152
|
}));
|
|
153
153
|
});
|
|
154
154
|
};
|
|
155
|
-
//#endregion
|
|
156
155
|
export { i as validateCircularReferences, a as validateElementIds, n as validateElements, r as validateParentChildConsistency, t as validateStructure };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/helpers/schemaValidator/types.ts
|
|
2
2
|
var e = /* @__PURE__ */ new Set([
|
|
3
3
|
"UNRESOLVED_BINDING_SOURCE",
|
|
4
4
|
"MISMATCHED_BINDING_SOURCE",
|
|
@@ -6,5 +6,4 @@ var e = /* @__PURE__ */ new Set([
|
|
|
6
6
|
"UNRESOLVED_COMPONENT",
|
|
7
7
|
"UNKNOWN_COMPONENT_SLOT"
|
|
8
8
|
]), t = (t) => !e.has(t.code);
|
|
9
|
-
//#endregion
|
|
10
9
|
export { e as REFERENCE_ERROR_CODES, t as isIntegrityError };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/helpers/styleWithoutTag.ts
|
|
2
2
|
var e = (e) => Object.keys(e ?? {}).length > 0, t = (t) => Object.values(t ?? {}).some(e), n = (n) => e(n.default) || t(n.states) || Object.values(n.variants ?? {}).some((n) => e(n.default) || t(n.states)), r = (e, t) => Object.values(e.platform).some((e) => Object.hasOwn(e, t) && Object.values(e[t].attributes).some(n)), i = /* @__PURE__ */ new Set(["apiContainer", "channel"]), a = (e) => {
|
|
3
3
|
let t = e.attributes.subType;
|
|
4
4
|
return i.has(e.definition.type) && (typeof t != "string" || t === "");
|
|
@@ -7,5 +7,4 @@ var e = (e) => Object.keys(e ?? {}).length > 0, t = (t) => Object.values(t ?? {}
|
|
|
7
7
|
let { styleSelectors: n, initialState: i, bindings: o } = e.definition, s = Object.values(n).some((e) => e.split(" ").some((e) => e && r(t, e))), c = Object.keys(i?.styleVariant ?? {}).length > 0, l = (o?.style?.length ?? 0) > 0;
|
|
8
8
|
if (s || c || l) return "has style but no `subType` (container tag), so it renders no element of its own and the style applies to nothing — its children lay out in its parent. Give it a tag (a `subType` of `div`, `section`, …) or move the style onto its parent or a child.";
|
|
9
9
|
};
|
|
10
|
-
//#endregion
|
|
11
10
|
export { a as rendersNoTag, o as styleWithoutTag };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import f from "./helpers/
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import k from "./helpers/
|
|
7
|
-
import { REFERENCE_ERROR_CODES as
|
|
8
|
-
import
|
|
1
|
+
import e from "./helpers/FlatMap.mjs";
|
|
2
|
+
import t, { SchemaActions as n } from "./SchemaReducer.mjs";
|
|
3
|
+
import { RESERVED_PROP_NAMES as r, addComponent as i, componentNamed as a, detachInstance as o, documentIds as s, flatMapOf as c, instancesOf as l, isInstance as u, propNameProblem as d, removeComponent as f, renameElement as p, treeOf as m, treesOf as h, updateComponent as g } from "./helpers/components.mjs";
|
|
4
|
+
import { descendants as _, elementsByRoot as v, parentChain as y, renderContext as b, rootName as x } from "./helpers/elementTree.mjs";
|
|
5
|
+
import { assertSchemaValid as S, isSchemaValid as C, validateSchema as w } from "./helpers/schemaValidator/index.mjs";
|
|
6
|
+
import { elementIdConflict as T, isValidElementId as E, positionalElementId as D, randomElementId as O, repointIds as k, slugifyElementId as A, uniqueElementId as j } from "./helpers/elementId.mjs";
|
|
7
|
+
import { REFERENCE_ERROR_CODES as M, isIntegrityError as N } from "./helpers/schemaValidator/types.mjs";
|
|
8
|
+
import P from "./helpers/fitSnippet.mjs";
|
|
9
9
|
import { rendersNoTag as F, styleWithoutTag as I } from "./helpers/styleWithoutTag.mjs";
|
|
10
|
-
export {
|
|
10
|
+
export { e as FlatMap, M as REFERENCE_ERROR_CODES, r as RESERVED_PROP_NAMES, n as SchemaActions, t as SchemaReducer, i as addComponent, S as assertSchemaValid, a as componentNamed, _ as descendants, o as detachInstance, s as documentIds, T as elementIdConflict, v as elementsByRoot, P as fitSnippet, c as flatMapOf, l as instancesOf, u as isInstance, N as isIntegrityError, C as isSchemaValid, E as isValidElementId, y as parentChain, D as positionalElementId, d as propNameProblem, O as randomElementId, f as removeComponent, p as renameElement, b as renderContext, F as rendersNoTag, k as repointIds, x as rootName, A as slugifyElementId, I as styleWithoutTag, m as treeOf, h as treesOf, j as uniqueElementId, g as updateComponent, w as validateSchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-schema",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.2",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -9,19 +9,21 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"@plitzi/source": "./src/index.ts",
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.mjs"
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"default": "./dist/index.mjs"
|
|
13
14
|
},
|
|
14
15
|
"./*": {
|
|
15
16
|
"@plitzi/source": "./src/*/index.ts",
|
|
16
17
|
"types": "./dist/*/index.d.ts",
|
|
17
|
-
"import": "./dist/*/index.mjs"
|
|
18
|
+
"import": "./dist/*/index.mjs",
|
|
19
|
+
"default": "./dist/*/index.mjs"
|
|
18
20
|
}
|
|
19
21
|
},
|
|
20
22
|
"type": "module",
|
|
21
23
|
"sideEffects": false,
|
|
22
24
|
"scripts": {
|
|
23
|
-
"lint": "eslint ./src",
|
|
24
|
-
"typecheck": "tsc -p tsconfig.app.json --noEmit",
|
|
25
|
+
"lint": "eslint --cache --cache-location .eslintcache --cache-strategy content ./src",
|
|
26
|
+
"typecheck": "tsc -p tsconfig.app.json --noEmit --incremental --tsBuildInfoFile .tsbuildinfo/app.tsbuildinfo",
|
|
25
27
|
"test": "vitest run",
|
|
26
28
|
"test:watch": "vitest",
|
|
27
29
|
"test:ui": "vitest --ui",
|
|
@@ -30,15 +32,15 @@
|
|
|
30
32
|
"build:prod": "vite build"
|
|
31
33
|
},
|
|
32
34
|
"dependencies": {
|
|
33
|
-
"@plitzi/plitzi-ui": "^1.6.
|
|
34
|
-
"@plitzi/sdk-shared": "0.39.
|
|
35
|
-
"@plitzi/sdk-style": "0.39.
|
|
36
|
-
"immer": "^11.
|
|
35
|
+
"@plitzi/plitzi-ui": "^1.6.38",
|
|
36
|
+
"@plitzi/sdk-shared": "0.39.2",
|
|
37
|
+
"@plitzi/sdk-style": "0.39.2",
|
|
38
|
+
"immer": "^11.2.9"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
41
|
"eslint": "^9.39.5",
|
|
40
42
|
"typescript": "^6.0.3",
|
|
41
|
-
"vite": "^8.3.
|
|
42
|
-
"vitest": "^5.0
|
|
43
|
+
"vite": "^8.3.7",
|
|
44
|
+
"vitest": "^5.1.0"
|
|
43
45
|
}
|
|
44
46
|
}
|