@usefragments/core 1.10.2 → 2.0.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.
- package/dist/{chunk-MZ4SW3TP.js → chunk-3IOWHECM.js} +8 -1
- package/dist/{chunk-MZ4SW3TP.js.map → chunk-3IOWHECM.js.map} +1 -1
- package/dist/chunk-7ULGH74M.js +66 -0
- package/dist/chunk-7ULGH74M.js.map +1 -0
- package/dist/{chunk-XN3LSDPY.js → chunk-BMPYIUZE.js} +612 -344
- package/dist/chunk-BMPYIUZE.js.map +1 -0
- package/dist/{chunk-YF65VYRY.js → chunk-ML5S6QNU.js} +191 -169
- package/dist/chunk-ML5S6QNU.js.map +1 -0
- package/dist/{chunk-3LLRNCPX.js → chunk-MZ2FS7U4.js} +1 -1
- package/dist/chunk-MZ2FS7U4.js.map +1 -0
- package/dist/chunk-PWIJMOI4.js +202 -0
- package/dist/chunk-PWIJMOI4.js.map +1 -0
- package/dist/chunk-RYFULE43.js +578 -0
- package/dist/chunk-RYFULE43.js.map +1 -0
- package/dist/codes/index.d.ts +2 -2
- package/dist/codes/index.js +3 -2
- package/dist/compiled-types/index.d.ts +327 -2
- package/dist/compiled-types/index.js +1 -1
- package/dist/generate/index.d.ts +3 -2
- package/dist/{governance-CLk_wkP9.d.ts → governance-hOPXGbbs.d.ts} +474 -515
- package/dist/governance-telemetry.d.ts +6 -0
- package/dist/governance-telemetry.js +1 -1
- package/dist/{index-_sxhUNqx.d.ts → index-C8bcXVav.d.ts} +448 -448
- package/dist/index.d.ts +3280 -1305
- package/dist/index.js +2414 -350
- package/dist/index.js.map +1 -1
- package/dist/manifest.d.ts +228 -0
- package/dist/manifest.js +24 -0
- package/dist/manifest.js.map +1 -0
- package/dist/preview/index.js +45 -1
- package/dist/preview/index.js.map +1 -1
- package/dist/preview-runtime.d.ts +1 -2
- package/dist/preview-runtime.js +150 -14
- package/dist/preview-runtime.js.map +1 -1
- package/dist/react-types.d.ts +1 -2
- package/dist/registry.d.ts +1412 -203
- package/dist/registry.js +30 -3
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/index.js +3 -2
- package/dist/storyAdapter.d.ts +1 -2
- package/dist/storyAdapter.js +11 -49
- package/dist/storyAdapter.js.map +1 -1
- package/dist/test-utils.d.ts +3 -2
- package/dist/topology/index.d.ts +1 -1
- package/dist/topology/index.js +1 -1
- package/package.json +8 -2
- package/src/__tests__/contract-parser.test.ts +318 -277
- package/src/__tests__/preview-runtime-hook.test.tsx +315 -0
- package/src/__tests__/preview-runtime.test.tsx +30 -8
- package/src/__tests__/schema.test.ts +191 -14
- package/src/analysis-plan/analysis-plan-v1.test.ts +320 -0
- package/src/analysis-plan/coverage.ts +181 -0
- package/src/analysis-plan/digest.ts +141 -0
- package/src/analysis-plan/index.ts +34 -0
- package/src/analysis-plan/types.ts +207 -0
- package/src/approved-contract-tokens.test.ts +39 -0
- package/src/approved-contract-tokens.ts +18 -0
- package/src/codes/__tests__/codes.test.ts +13 -0
- package/src/codes/codes.ts +40 -0
- package/src/compiled-types/index.ts +640 -39
- package/src/compiled-types/parse.test.ts +145 -4
- package/src/component-contract.ts +95 -53
- package/src/composition.ts +7 -13
- package/src/constants.ts +3 -6
- package/src/contract/hash.test.ts +20 -0
- package/src/contract/hash.ts +66 -9
- package/src/contract/index.ts +24 -1
- package/src/contract/manifest.test.ts +94 -0
- package/src/contract/manifest.ts +68 -0
- package/src/contract/preimage.test.ts +219 -1
- package/src/contract/preimage.ts +326 -6
- package/src/contract/stamp.test.ts +3 -0
- package/src/contract/stamp.ts +1 -1
- package/src/contract-parser.ts +54 -30
- package/src/defineFragment.test.ts +476 -91
- package/src/defineFragment.ts +204 -114
- package/src/domain-ids.test.ts +35 -0
- package/src/domain-ids.ts +61 -0
- package/src/evaluation/evaluate.test.ts +522 -0
- package/src/evaluation/evaluate.ts +690 -0
- package/src/evaluation/evaluation-v2-receipt-v1.test.ts +772 -0
- package/src/evaluation/index.ts +58 -0
- package/src/evaluation/receipt.ts +753 -0
- package/src/evaluation/types.ts +406 -0
- package/src/facts/builders.ts +2 -0
- package/src/facts/compile.ts +29 -6
- package/src/facts/fact-index.ts +13 -3
- package/src/facts/fact-integrity-v1.test.ts +172 -0
- package/src/facts/facts.test.ts +15 -0
- package/src/facts/ids.ts +46 -3
- package/src/facts/index.ts +14 -1
- package/src/facts/integrity.ts +134 -0
- package/src/facts/types.ts +36 -0
- package/src/governance-integrity.test.ts +1 -0
- package/src/governance-integrity.ts +5 -3
- package/src/governance-telemetry.ts +8 -0
- package/src/governance.ts +70 -8
- package/src/index.ts +230 -37
- package/src/preview/validation.test.ts +62 -0
- package/src/preview/validation.ts +48 -2
- package/src/preview-runtime.tsx +227 -20
- package/src/registry-install-plan.ts +200 -109
- package/src/registry-shards.test.ts +263 -0
- package/src/registry.ts +237 -0
- package/src/repository-binding.test.ts +50 -0
- package/src/repository-binding.ts +96 -0
- package/src/rules/families.test.ts +36 -0
- package/src/rules/finding.ts +7 -2
- package/src/rules/index.ts +17 -1
- package/src/rules/rule-config.test.ts +66 -0
- package/src/rules/rule-config.ts +73 -0
- package/src/rules/rules.test.ts +26 -0
- package/src/rules/tokens-css-vars-must-be-defined.test.ts +51 -2
- package/src/rules/tokens-css-vars-must-be-defined.ts +34 -1
- package/src/schema.ts +293 -113
- package/src/schemas/index.ts +1 -1
- package/src/storyAdapter.test.ts +68 -12
- package/src/storyAdapter.ts +44 -75
- package/src/topology/resolve-area.ts +1 -1
- package/src/types.ts +258 -40
- package/dist/chunk-3LLRNCPX.js.map +0 -1
- package/dist/chunk-RANPUC6C.js +0 -72
- package/dist/chunk-RANPUC6C.js.map +0 -1
- package/dist/chunk-XN3LSDPY.js.map +0 -1
- package/dist/chunk-YF65VYRY.js.map +0 -1
- package/src/fragment-types.ts +0 -214
- package/src/react-create-element.test.ts +0 -22
- package/src/react-create-element.ts +0 -12
- package/src/storyFilters.test.ts +0 -350
- package/src/storyFilters.ts +0 -253
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Design-system manifest v1 — the committed, human-curated vocabulary that
|
|
5
|
+
* every local agent surface reads. FCID is `contractHash(manifest)`.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare const FRAGMENTS_MANIFEST_FILENAME = "fragments.manifest.json";
|
|
9
|
+
declare const FRAGMENTS_MANIFEST_SCHEMA_VERSION = 1;
|
|
10
|
+
declare const FRAGMENTS_MANIFEST_TOKEN_RULE = "no-raw-values";
|
|
11
|
+
declare const fragmentsManifestPrimitiveSchema: z.ZodObject<{
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
members: z.ZodArray<z.ZodString, "many">;
|
|
14
|
+
intents: z.ZodArray<z.ZodString, "many">;
|
|
15
|
+
props: z.ZodArray<z.ZodString, "many">;
|
|
16
|
+
do: z.ZodArray<z.ZodString, "many">;
|
|
17
|
+
dont: z.ZodArray<z.ZodString, "many">;
|
|
18
|
+
exemplar: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
props: string[];
|
|
21
|
+
name: string;
|
|
22
|
+
members: string[];
|
|
23
|
+
intents: string[];
|
|
24
|
+
do: string[];
|
|
25
|
+
dont: string[];
|
|
26
|
+
exemplar?: string | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
props: string[];
|
|
29
|
+
name: string;
|
|
30
|
+
members: string[];
|
|
31
|
+
intents: string[];
|
|
32
|
+
do: string[];
|
|
33
|
+
dont: string[];
|
|
34
|
+
exemplar?: string | undefined;
|
|
35
|
+
}>;
|
|
36
|
+
declare const fragmentsManifestPatternSchema: z.ZodObject<{
|
|
37
|
+
name: z.ZodString;
|
|
38
|
+
intent: z.ZodString;
|
|
39
|
+
primitives: z.ZodArray<z.ZodString, "many">;
|
|
40
|
+
shape: z.ZodString;
|
|
41
|
+
exemplar: z.ZodOptional<z.ZodString>;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
shape: string;
|
|
44
|
+
name: string;
|
|
45
|
+
intent: string;
|
|
46
|
+
primitives: string[];
|
|
47
|
+
exemplar?: string | undefined;
|
|
48
|
+
}, {
|
|
49
|
+
shape: string;
|
|
50
|
+
name: string;
|
|
51
|
+
intent: string;
|
|
52
|
+
primitives: string[];
|
|
53
|
+
exemplar?: string | undefined;
|
|
54
|
+
}>;
|
|
55
|
+
declare const fragmentsManifestGrammarSchema: z.ZodObject<{
|
|
56
|
+
rule: z.ZodString;
|
|
57
|
+
check: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}, "strip", z.ZodTypeAny, {
|
|
59
|
+
rule: string;
|
|
60
|
+
check?: string | undefined;
|
|
61
|
+
}, {
|
|
62
|
+
rule: string;
|
|
63
|
+
check?: string | undefined;
|
|
64
|
+
}>;
|
|
65
|
+
declare const fragmentsManifestSchema: z.ZodObject<{
|
|
66
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
67
|
+
designSystem: z.ZodObject<{
|
|
68
|
+
packageName: z.ZodString;
|
|
69
|
+
importPath: z.ZodString;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
importPath: string;
|
|
72
|
+
packageName: string;
|
|
73
|
+
}, {
|
|
74
|
+
importPath: string;
|
|
75
|
+
packageName: string;
|
|
76
|
+
}>;
|
|
77
|
+
tokens: z.ZodObject<{
|
|
78
|
+
prefix: z.ZodString;
|
|
79
|
+
rule: z.ZodLiteral<"no-raw-values">;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
rule: "no-raw-values";
|
|
82
|
+
prefix: string;
|
|
83
|
+
}, {
|
|
84
|
+
rule: "no-raw-values";
|
|
85
|
+
prefix: string;
|
|
86
|
+
}>;
|
|
87
|
+
primitives: z.ZodArray<z.ZodObject<{
|
|
88
|
+
name: z.ZodString;
|
|
89
|
+
members: z.ZodArray<z.ZodString, "many">;
|
|
90
|
+
intents: z.ZodArray<z.ZodString, "many">;
|
|
91
|
+
props: z.ZodArray<z.ZodString, "many">;
|
|
92
|
+
do: z.ZodArray<z.ZodString, "many">;
|
|
93
|
+
dont: z.ZodArray<z.ZodString, "many">;
|
|
94
|
+
exemplar: z.ZodOptional<z.ZodString>;
|
|
95
|
+
}, "strip", z.ZodTypeAny, {
|
|
96
|
+
props: string[];
|
|
97
|
+
name: string;
|
|
98
|
+
members: string[];
|
|
99
|
+
intents: string[];
|
|
100
|
+
do: string[];
|
|
101
|
+
dont: string[];
|
|
102
|
+
exemplar?: string | undefined;
|
|
103
|
+
}, {
|
|
104
|
+
props: string[];
|
|
105
|
+
name: string;
|
|
106
|
+
members: string[];
|
|
107
|
+
intents: string[];
|
|
108
|
+
do: string[];
|
|
109
|
+
dont: string[];
|
|
110
|
+
exemplar?: string | undefined;
|
|
111
|
+
}>, "many">;
|
|
112
|
+
patterns: z.ZodArray<z.ZodObject<{
|
|
113
|
+
name: z.ZodString;
|
|
114
|
+
intent: z.ZodString;
|
|
115
|
+
primitives: z.ZodArray<z.ZodString, "many">;
|
|
116
|
+
shape: z.ZodString;
|
|
117
|
+
exemplar: z.ZodOptional<z.ZodString>;
|
|
118
|
+
}, "strip", z.ZodTypeAny, {
|
|
119
|
+
shape: string;
|
|
120
|
+
name: string;
|
|
121
|
+
intent: string;
|
|
122
|
+
primitives: string[];
|
|
123
|
+
exemplar?: string | undefined;
|
|
124
|
+
}, {
|
|
125
|
+
shape: string;
|
|
126
|
+
name: string;
|
|
127
|
+
intent: string;
|
|
128
|
+
primitives: string[];
|
|
129
|
+
exemplar?: string | undefined;
|
|
130
|
+
}>, "many">;
|
|
131
|
+
grammar: z.ZodArray<z.ZodObject<{
|
|
132
|
+
rule: z.ZodString;
|
|
133
|
+
check: z.ZodOptional<z.ZodString>;
|
|
134
|
+
}, "strip", z.ZodTypeAny, {
|
|
135
|
+
rule: string;
|
|
136
|
+
check?: string | undefined;
|
|
137
|
+
}, {
|
|
138
|
+
rule: string;
|
|
139
|
+
check?: string | undefined;
|
|
140
|
+
}>, "many">;
|
|
141
|
+
rules: z.ZodObject<{
|
|
142
|
+
preset: z.ZodString;
|
|
143
|
+
off: z.ZodArray<z.ZodString, "many">;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
preset: string;
|
|
146
|
+
off: string[];
|
|
147
|
+
}, {
|
|
148
|
+
preset: string;
|
|
149
|
+
off: string[];
|
|
150
|
+
}>;
|
|
151
|
+
}, "strip", z.ZodTypeAny, {
|
|
152
|
+
schemaVersion: 1;
|
|
153
|
+
tokens: {
|
|
154
|
+
rule: "no-raw-values";
|
|
155
|
+
prefix: string;
|
|
156
|
+
};
|
|
157
|
+
rules: {
|
|
158
|
+
preset: string;
|
|
159
|
+
off: string[];
|
|
160
|
+
};
|
|
161
|
+
primitives: {
|
|
162
|
+
props: string[];
|
|
163
|
+
name: string;
|
|
164
|
+
members: string[];
|
|
165
|
+
intents: string[];
|
|
166
|
+
do: string[];
|
|
167
|
+
dont: string[];
|
|
168
|
+
exemplar?: string | undefined;
|
|
169
|
+
}[];
|
|
170
|
+
designSystem: {
|
|
171
|
+
importPath: string;
|
|
172
|
+
packageName: string;
|
|
173
|
+
};
|
|
174
|
+
patterns: {
|
|
175
|
+
shape: string;
|
|
176
|
+
name: string;
|
|
177
|
+
intent: string;
|
|
178
|
+
primitives: string[];
|
|
179
|
+
exemplar?: string | undefined;
|
|
180
|
+
}[];
|
|
181
|
+
grammar: {
|
|
182
|
+
rule: string;
|
|
183
|
+
check?: string | undefined;
|
|
184
|
+
}[];
|
|
185
|
+
}, {
|
|
186
|
+
schemaVersion: 1;
|
|
187
|
+
tokens: {
|
|
188
|
+
rule: "no-raw-values";
|
|
189
|
+
prefix: string;
|
|
190
|
+
};
|
|
191
|
+
rules: {
|
|
192
|
+
preset: string;
|
|
193
|
+
off: string[];
|
|
194
|
+
};
|
|
195
|
+
primitives: {
|
|
196
|
+
props: string[];
|
|
197
|
+
name: string;
|
|
198
|
+
members: string[];
|
|
199
|
+
intents: string[];
|
|
200
|
+
do: string[];
|
|
201
|
+
dont: string[];
|
|
202
|
+
exemplar?: string | undefined;
|
|
203
|
+
}[];
|
|
204
|
+
designSystem: {
|
|
205
|
+
importPath: string;
|
|
206
|
+
packageName: string;
|
|
207
|
+
};
|
|
208
|
+
patterns: {
|
|
209
|
+
shape: string;
|
|
210
|
+
name: string;
|
|
211
|
+
intent: string;
|
|
212
|
+
primitives: string[];
|
|
213
|
+
exemplar?: string | undefined;
|
|
214
|
+
}[];
|
|
215
|
+
grammar: {
|
|
216
|
+
rule: string;
|
|
217
|
+
check?: string | undefined;
|
|
218
|
+
}[];
|
|
219
|
+
}>;
|
|
220
|
+
type FragmentsManifestPrimitive = z.infer<typeof fragmentsManifestPrimitiveSchema>;
|
|
221
|
+
type FragmentsManifestPattern = z.infer<typeof fragmentsManifestPatternSchema>;
|
|
222
|
+
type FragmentsManifestGrammar = z.infer<typeof fragmentsManifestGrammarSchema>;
|
|
223
|
+
type FragmentsManifest = z.infer<typeof fragmentsManifestSchema>;
|
|
224
|
+
declare function parseFragmentsManifest(input: unknown): FragmentsManifest;
|
|
225
|
+
/** FCID for a parsed manifest: content-address, key-order independent. */
|
|
226
|
+
declare function fragmentsManifestFcid(manifest: FragmentsManifest): string;
|
|
227
|
+
|
|
228
|
+
export { FRAGMENTS_MANIFEST_FILENAME, FRAGMENTS_MANIFEST_SCHEMA_VERSION, FRAGMENTS_MANIFEST_TOKEN_RULE, type FragmentsManifest, type FragmentsManifestGrammar, type FragmentsManifestPattern, type FragmentsManifestPrimitive, fragmentsManifestFcid, fragmentsManifestGrammarSchema, fragmentsManifestPatternSchema, fragmentsManifestPrimitiveSchema, fragmentsManifestSchema, parseFragmentsManifest };
|
package/dist/manifest.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FRAGMENTS_MANIFEST_FILENAME,
|
|
3
|
+
FRAGMENTS_MANIFEST_SCHEMA_VERSION,
|
|
4
|
+
FRAGMENTS_MANIFEST_TOKEN_RULE,
|
|
5
|
+
fragmentsManifestFcid,
|
|
6
|
+
fragmentsManifestGrammarSchema,
|
|
7
|
+
fragmentsManifestPatternSchema,
|
|
8
|
+
fragmentsManifestPrimitiveSchema,
|
|
9
|
+
fragmentsManifestSchema,
|
|
10
|
+
parseFragmentsManifest
|
|
11
|
+
} from "./chunk-7ULGH74M.js";
|
|
12
|
+
import "./chunk-PWIJMOI4.js";
|
|
13
|
+
export {
|
|
14
|
+
FRAGMENTS_MANIFEST_FILENAME,
|
|
15
|
+
FRAGMENTS_MANIFEST_SCHEMA_VERSION,
|
|
16
|
+
FRAGMENTS_MANIFEST_TOKEN_RULE,
|
|
17
|
+
fragmentsManifestFcid,
|
|
18
|
+
fragmentsManifestGrammarSchema,
|
|
19
|
+
fragmentsManifestPatternSchema,
|
|
20
|
+
fragmentsManifestPrimitiveSchema,
|
|
21
|
+
fragmentsManifestSchema,
|
|
22
|
+
parseFragmentsManifest
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/preview/index.js
CHANGED
|
@@ -825,6 +825,18 @@ function clipRegionToSize(region, size) {
|
|
|
825
825
|
}
|
|
826
826
|
|
|
827
827
|
// src/preview/validation.ts
|
|
828
|
+
var PREVIEWABILITY_VALUES = /* @__PURE__ */ new Set([
|
|
829
|
+
"ready",
|
|
830
|
+
"building",
|
|
831
|
+
"needs-preview-provider",
|
|
832
|
+
"missing-dependency",
|
|
833
|
+
"missing-asset",
|
|
834
|
+
"server-only",
|
|
835
|
+
"unsupported-framework",
|
|
836
|
+
"runtime-error",
|
|
837
|
+
"build-error",
|
|
838
|
+
"docs-only"
|
|
839
|
+
]);
|
|
828
840
|
function definePreviewArtifactManifest(manifest) {
|
|
829
841
|
const validation = validatePreviewArtifactManifest(manifest);
|
|
830
842
|
if (!validation.ok) {
|
|
@@ -909,12 +921,25 @@ function validateComponents(value, issues) {
|
|
|
909
921
|
issues.push("components must be an object");
|
|
910
922
|
return;
|
|
911
923
|
}
|
|
924
|
+
const normalizedComponentKeys = /* @__PURE__ */ new Set();
|
|
912
925
|
for (const [key, component] of Object.entries(value)) {
|
|
913
926
|
if (!isRecord(component)) {
|
|
914
927
|
issues.push(`components.${key} must be an object`);
|
|
915
928
|
continue;
|
|
916
929
|
}
|
|
917
|
-
|
|
930
|
+
const componentKey = component.componentKey;
|
|
931
|
+
if (typeof componentKey !== "string" || !componentKey.trim()) {
|
|
932
|
+
issues.push(`components.${key}.componentKey must be a non-empty string`);
|
|
933
|
+
} else {
|
|
934
|
+
if (key !== componentKey) {
|
|
935
|
+
issues.push(`components.${key}.componentKey must match its components map key`);
|
|
936
|
+
}
|
|
937
|
+
const normalizedComponentKey = componentKey.trim();
|
|
938
|
+
if (normalizedComponentKeys.has(normalizedComponentKey)) {
|
|
939
|
+
issues.push(`components contains duplicate normalized componentKey ${componentKey}`);
|
|
940
|
+
}
|
|
941
|
+
normalizedComponentKeys.add(normalizedComponentKey);
|
|
942
|
+
}
|
|
918
943
|
requireString(component, "publicRef", issues, `components.${key}`);
|
|
919
944
|
requireString(component, "displayName", issues, `components.${key}`);
|
|
920
945
|
requireString(component, "exportName", issues, `components.${key}`);
|
|
@@ -925,17 +950,33 @@ function validateComponents(value, issues) {
|
|
|
925
950
|
`components.${key}.definitionSource must be one of typescript, fragment, manual, synthesized`
|
|
926
951
|
);
|
|
927
952
|
}
|
|
953
|
+
if (!isPreviewability(component.previewability)) {
|
|
954
|
+
issues.push(
|
|
955
|
+
`components.${key}.previewability must be one of ${[...PREVIEWABILITY_VALUES].join(", ")}`
|
|
956
|
+
);
|
|
957
|
+
}
|
|
928
958
|
if (!isRecord(component.props)) {
|
|
929
959
|
issues.push(`components.${key}.props must be an object`);
|
|
930
960
|
}
|
|
931
961
|
if (!Array.isArray(component.variants)) {
|
|
932
962
|
issues.push(`components.${key}.variants must be an array`);
|
|
933
963
|
} else {
|
|
964
|
+
const normalizedVariantIds = /* @__PURE__ */ new Set();
|
|
934
965
|
component.variants.forEach((variant, index) => {
|
|
935
966
|
if (!isRecord(variant)) {
|
|
936
967
|
issues.push(`components.${key}.variants.${index} must be an object`);
|
|
937
968
|
return;
|
|
938
969
|
}
|
|
970
|
+
const variantPath = `components.${key}.variants.${index}`;
|
|
971
|
+
if (typeof variant.id !== "string" || !variant.id.trim()) {
|
|
972
|
+
issues.push(`${variantPath}.id must be a non-empty string`);
|
|
973
|
+
} else {
|
|
974
|
+
const normalizedVariantId = variant.id.trim();
|
|
975
|
+
if (normalizedVariantIds.has(normalizedVariantId)) {
|
|
976
|
+
issues.push(`${variantPath}.id must be unique within the component`);
|
|
977
|
+
}
|
|
978
|
+
normalizedVariantIds.add(normalizedVariantId);
|
|
979
|
+
}
|
|
939
980
|
validateDesignReference(
|
|
940
981
|
variant.design,
|
|
941
982
|
issues,
|
|
@@ -1063,6 +1104,9 @@ function isRecord(value) {
|
|
|
1063
1104
|
function isPreviewDefinitionSource(value) {
|
|
1064
1105
|
return value === "typescript" || value === "fragment" || value === "manual" || value === "synthesized";
|
|
1065
1106
|
}
|
|
1107
|
+
function isPreviewability(value) {
|
|
1108
|
+
return typeof value === "string" && PREVIEWABILITY_VALUES.has(value);
|
|
1109
|
+
}
|
|
1066
1110
|
function isFiniteNumber(value) {
|
|
1067
1111
|
return typeof value === "number" && Number.isFinite(value);
|
|
1068
1112
|
}
|