@sugarcube-org/core 0.0.1-alpha.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/README.md +9 -0
- package/dist/index.d.ts +230 -0
- package/dist/index.js +7 -0
- package/package.json +23 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
type Color = string;
|
|
2
|
+
type Dimension = {
|
|
3
|
+
value: number;
|
|
4
|
+
unit: "px" | "rem";
|
|
5
|
+
};
|
|
6
|
+
type FluidDimension = {
|
|
7
|
+
min: Dimension;
|
|
8
|
+
max: Dimension;
|
|
9
|
+
};
|
|
10
|
+
type Duration = string;
|
|
11
|
+
type CubicBezier = [number, number, number, number];
|
|
12
|
+
type FontFamily = string | string[];
|
|
13
|
+
type FontWeight = number | FontWeightString;
|
|
14
|
+
type FontWeightString = "thin" | "hairline" | "extra-light" | "ultra-light" | "light" | "normal" | "regular" | "book" | "medium" | "semi-bold" | "demi-bold" | "bold" | "extra-bold" | "ultra-bold" | "black" | "heavy" | "extra-black" | "ultra-black";
|
|
15
|
+
type LineCap = "round" | "butt" | "square";
|
|
16
|
+
type TokenType = SimpleTokenType | CompositeTokenType;
|
|
17
|
+
type SimpleTokenType = "color" | "dimension" | "fluidDimension" | "duration" | "cubicBezier" | "fontFamily" | "fontWeight" | "number";
|
|
18
|
+
type CompositeTokenType = AlwaysDecomposedType | OptionallyDecomposedType | StructuralCompositeType;
|
|
19
|
+
type AlwaysDecomposedType = "typography";
|
|
20
|
+
type OptionallyDecomposedType = "border" | "shadow" | "gradient" | "transition";
|
|
21
|
+
type StructuralCompositeType = "strokeStyle";
|
|
22
|
+
type Reference<T extends TokenType = TokenType> = string & {
|
|
23
|
+
__tokenType?: T;
|
|
24
|
+
};
|
|
25
|
+
type TokenValue<T extends TokenType> = RawTokenValue<T> | Reference<T>;
|
|
26
|
+
type RawTokenValue<T extends TokenType> = T extends SimpleTokenType ? SimpleTokenValue<T> : T extends CompositeTokenType ? CompositeTokenValue<T> : never;
|
|
27
|
+
type SimpleTokenValue<T extends SimpleTokenType = SimpleTokenType> = T extends "color" ? Color : T extends "dimension" ? Dimension : T extends "fluidDimension" ? FluidDimension : T extends "duration" ? Duration : T extends "cubicBezier" ? CubicBezier : T extends "fontFamily" ? FontFamily : T extends "fontWeight" ? FontWeight : T extends "number" ? number : never;
|
|
28
|
+
type CompositeTokenValue<T extends CompositeTokenType = CompositeTokenType> = T extends "typography" ? Typography : T extends "border" ? Border : T extends "shadow" ? Shadow : T extends "gradient" ? Gradient : T extends "transition" ? Transition : T extends "strokeStyle" ? StrokeStyle : never;
|
|
29
|
+
type Typography = {
|
|
30
|
+
fontFamily: TokenValue<"fontFamily">;
|
|
31
|
+
fontSize: TokenValue<"dimension">;
|
|
32
|
+
fontWeight?: TokenValue<"fontWeight">;
|
|
33
|
+
letterSpacing?: TokenValue<"dimension">;
|
|
34
|
+
lineHeight?: TokenValue<"number">;
|
|
35
|
+
};
|
|
36
|
+
type Transition = {
|
|
37
|
+
duration: TokenValue<"duration">;
|
|
38
|
+
delay?: TokenValue<"duration">;
|
|
39
|
+
timingFunction: TokenValue<"cubicBezier">;
|
|
40
|
+
};
|
|
41
|
+
type StrokeStyleKeyword = "solid" | "dashed" | "dotted" | "double" | "groove" | "ridge" | "outset" | "inset";
|
|
42
|
+
type StrokeStyleCustom = {
|
|
43
|
+
dashArray: Array<TokenValue<"dimension">>;
|
|
44
|
+
lineCap: LineCap;
|
|
45
|
+
};
|
|
46
|
+
type StrokeStyle = StrokeStyleKeyword | StrokeStyleCustom;
|
|
47
|
+
type Border = {
|
|
48
|
+
color: TokenValue<"color">;
|
|
49
|
+
width: TokenValue<"dimension">;
|
|
50
|
+
style: StrokeStyle;
|
|
51
|
+
};
|
|
52
|
+
type ShadowObject = {
|
|
53
|
+
color: TokenValue<"color">;
|
|
54
|
+
offsetX: TokenValue<"dimension">;
|
|
55
|
+
offsetY: TokenValue<"dimension">;
|
|
56
|
+
blur: TokenValue<"dimension">;
|
|
57
|
+
spread: TokenValue<"dimension">;
|
|
58
|
+
inset?: boolean;
|
|
59
|
+
};
|
|
60
|
+
type Shadow = ShadowObject | ShadowObject[];
|
|
61
|
+
type GradientStop = {
|
|
62
|
+
color: TokenValue<"color">;
|
|
63
|
+
position: number;
|
|
64
|
+
};
|
|
65
|
+
type Gradient = GradientStop[];
|
|
66
|
+
type TokenMetadata = {
|
|
67
|
+
$description?: string;
|
|
68
|
+
$extensions?: SugarcubeExtensions;
|
|
69
|
+
};
|
|
70
|
+
type SugarcubeExtensions = {
|
|
71
|
+
"com.sugarcube": {
|
|
72
|
+
color?: ColorMetadata;
|
|
73
|
+
fluid?: FluidMetadata;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
type ColorMetadata = {
|
|
77
|
+
format: ColorFormatName;
|
|
78
|
+
};
|
|
79
|
+
type FluidMetadata = {
|
|
80
|
+
viewports: {
|
|
81
|
+
min: Dimension;
|
|
82
|
+
max: Dimension;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
type ColorFormatName = "hex" | "rgb" | "hsl" | "p3";
|
|
86
|
+
type MetadataMap = {
|
|
87
|
+
root: TokenMetadata;
|
|
88
|
+
groups: Record<string, TokenMetadata>;
|
|
89
|
+
tokens: Record<string, TokenMetadata>;
|
|
90
|
+
};
|
|
91
|
+
type CSSProperties<T extends TokenType> = T extends SimpleTokenType ? SimpleCSSProperties : T extends AlwaysDecomposedType ? AlwaysDecomposedProperties : T extends OptionallyDecomposedType ? OptionallyDecomposedProperties<T> : T extends StructuralCompositeType ? SimpleCSSProperties : never;
|
|
92
|
+
type SimpleCSSProperties = {
|
|
93
|
+
value: string | number;
|
|
94
|
+
featureValues?: Array<{
|
|
95
|
+
query: string;
|
|
96
|
+
value: string;
|
|
97
|
+
}>;
|
|
98
|
+
};
|
|
99
|
+
type AlwaysDecomposedProperties = CSSTypographyProperties;
|
|
100
|
+
type CSSTypographyProperties = {
|
|
101
|
+
"font-family": string;
|
|
102
|
+
"font-size": string;
|
|
103
|
+
"font-weight"?: number | string;
|
|
104
|
+
"letter-spacing"?: string;
|
|
105
|
+
"line-height"?: number | string;
|
|
106
|
+
};
|
|
107
|
+
type OptionallyDecomposedProperties<T extends OptionallyDecomposedType> = T extends "border" ? CSSBorderProperties : T extends "shadow" ? CSSShadowProperties : T extends "gradient" ? CSSGradientProperties : T extends "transition" ? CSSTransitionProperties : never;
|
|
108
|
+
type CSSBorderProperties = {
|
|
109
|
+
value: string;
|
|
110
|
+
split?: {
|
|
111
|
+
width: string;
|
|
112
|
+
style: string;
|
|
113
|
+
color: string;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
type CSSShadowProperties = {
|
|
117
|
+
value: string;
|
|
118
|
+
split?: CSSShadowSplitProperties | CSSShadowSplitProperties[];
|
|
119
|
+
};
|
|
120
|
+
type CSSShadowSplitProperties = {
|
|
121
|
+
"offset-x": string;
|
|
122
|
+
"offset-y": string;
|
|
123
|
+
"blur": string;
|
|
124
|
+
"spread": string;
|
|
125
|
+
"color": string;
|
|
126
|
+
"inset"?: "inset";
|
|
127
|
+
};
|
|
128
|
+
type CSSGradientProperties = {
|
|
129
|
+
value: string;
|
|
130
|
+
split?: {
|
|
131
|
+
stops: Array<{
|
|
132
|
+
color: string;
|
|
133
|
+
position: string;
|
|
134
|
+
}>;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
type CSSTransitionProperties = {
|
|
138
|
+
value: string;
|
|
139
|
+
split?: {
|
|
140
|
+
"duration": string;
|
|
141
|
+
"timing-function": string;
|
|
142
|
+
"delay"?: string;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
type BaseToken = TokenMetadata & {
|
|
146
|
+
$value: TokenValue<TokenType>;
|
|
147
|
+
};
|
|
148
|
+
type SelfTypedToken<T extends TokenType = TokenType> = BaseToken & {
|
|
149
|
+
$type: T;
|
|
150
|
+
};
|
|
151
|
+
type InheritedTypeToken = BaseToken;
|
|
152
|
+
type Token<T extends TokenType = TokenType> = SelfTypedToken<T> | InheritedTypeToken;
|
|
153
|
+
type UnresolvedToken<T extends TokenType = TokenType> = (SelfTypedToken<T> & {
|
|
154
|
+
$path: string;
|
|
155
|
+
}) | (InheritedTypeToken & {
|
|
156
|
+
$path: string;
|
|
157
|
+
});
|
|
158
|
+
type ResolvedToken<T extends TokenType = TokenType> = UnresolvedToken<T> & {
|
|
159
|
+
$resolvedValue: RawTokenValue<T>;
|
|
160
|
+
};
|
|
161
|
+
type ConvertedToken<T extends TokenType = TokenType> = ResolvedToken<T> & {
|
|
162
|
+
$type: T;
|
|
163
|
+
cssProperties: CSSProperties<T>;
|
|
164
|
+
};
|
|
165
|
+
type DesignTokens = TokenGroup;
|
|
166
|
+
type TokenGroup = {
|
|
167
|
+
[key: string]: Token | TokenGroup | string | undefined;
|
|
168
|
+
} & TokenMetadata;
|
|
169
|
+
type FlattenedTokens = {
|
|
170
|
+
[path: string]: UnresolvedToken;
|
|
171
|
+
};
|
|
172
|
+
type ResolvedTokens = {
|
|
173
|
+
[path: string]: ResolvedToken;
|
|
174
|
+
};
|
|
175
|
+
type ConvertedTokens = {
|
|
176
|
+
[path: string]: ConvertedToken;
|
|
177
|
+
};
|
|
178
|
+
type ValidationError = {
|
|
179
|
+
path: string;
|
|
180
|
+
message: string;
|
|
181
|
+
};
|
|
182
|
+
type ResolutionError = {
|
|
183
|
+
type: "circular" | "missing" | "type-mismatch";
|
|
184
|
+
path: string;
|
|
185
|
+
message: string;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
declare function flatten(tree: DesignTokens): {
|
|
189
|
+
tokens: FlattenedTokens;
|
|
190
|
+
errors: ValidationError[];
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
declare function resolve(tokens: FlattenedTokens): {
|
|
194
|
+
resolved: ResolvedTokens;
|
|
195
|
+
errors: ResolutionError[];
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Converts a set of resolved tokens to CSS-ready converted tokens
|
|
200
|
+
* @param tokens - The resolved tokens to convert
|
|
201
|
+
* @param metadataMap - Metadata for the token conversion process
|
|
202
|
+
* @returns A record of converted tokens with kebab-case keys
|
|
203
|
+
* @throws If any token has an unsupported type or is missing required properties
|
|
204
|
+
*/
|
|
205
|
+
declare function convert(tokens: ResolvedTokens, metadataMap: MetadataMap): ConvertedTokens;
|
|
206
|
+
|
|
207
|
+
declare function generateCSS(tokens: ConvertedTokens, options?: {
|
|
208
|
+
splitTypes?: OptionallyDecomposedType[];
|
|
209
|
+
}): Promise<string>;
|
|
210
|
+
|
|
211
|
+
type MetadataResult = {
|
|
212
|
+
metadata: MetadataMap;
|
|
213
|
+
errors: ValidationError[];
|
|
214
|
+
};
|
|
215
|
+
declare function collectMetadata(tree: DesignTokens): MetadataResult;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* This function takes a JSON string representation of a token tree and converts it
|
|
219
|
+
* into a DesignTokens object.
|
|
220
|
+
*
|
|
221
|
+
* @param {string} json - A JSON string representing a token tree structure.
|
|
222
|
+
* @returns {DesignTokens} A DesignTokens object representing the parsed token structure.
|
|
223
|
+
* @throws {SyntaxError} If the provided JSON string is not valid JSON.
|
|
224
|
+
* @throws {TypeError} If the JSON structure doesn't match the expected DesignTokens format.
|
|
225
|
+
*/
|
|
226
|
+
declare function parseJson(json: string): DesignTokens;
|
|
227
|
+
|
|
228
|
+
declare function validate(tokens: FlattenedTokens, metadata: MetadataMap): ValidationError[];
|
|
229
|
+
|
|
230
|
+
export { type MetadataMap, type OptionallyDecomposedType, type ResolutionError, type ResolvedTokens, type ValidationError, collectMetadata, convert, flatten, generateCSS, parseJson, resolve, validate };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var B=Object.defineProperty;var i=(e,n)=>B(e,"name",{value:n,configurable:!0});const u={PARSE:{INVALID_INPUT_TYPE:i(e=>`Invalid input: expected string, got ${e}`,"INVALID_INPUT_TYPE"),JSON_PARSE_ERROR:i(e=>`JSON parsing error: ${e}`,"JSON_PARSE_ERROR")},FLATTEN:{INVALID_TOKEN_NAME:i(e=>`Invalid token name '${e}': cannot contain '.', '{', or '}'`,"INVALID_TOKEN_NAME"),INVALID_NODE_STRUCTURE:i(e=>`Invalid node structure at '${e}': expected object`,"INVALID_NODE_STRUCTURE"),MISSING_INHERITED_TYPE:i(e=>`Token at '${e}' has no type (neither explicit nor inherited)`,"MISSING_INHERITED_TYPE"),UNEXPECTED_ERROR:i(e=>`Unexpected error during flattening: ${e}`,"UNEXPECTED_ERROR")},METADATA:{COLLECTION_ERROR:i(e=>`Error collecting metadata: ${e}`,"COLLECTION_ERROR"),INVALID_EXTENSIONS:i(e=>`Invalid extensions at '${e}': expected object, got ${typeof e}`,"INVALID_EXTENSIONS"),INVALID_DESCRIPTION:i(e=>`Invalid description at '${e}': expected string, got ${typeof e}`,"INVALID_DESCRIPTION")},VALIDATE:{INVALID_TOKEN_STRUCTURE:i(e=>`Invalid token at '${e}'. Each token should have "$type" and "$value" properties`,"INVALID_TOKEN_STRUCTURE"),MISSING_TYPE:i(e=>`Token at '${e}' is missing the "$type" property`,"MISSING_TYPE"),MISSING_VALUE:i(e=>`Token at '${e}' is missing the "$value" property`,"MISSING_VALUE"),UNKNOWN_TOKEN_TYPE:i((e,n)=>`Unknown token type '${e}' at '${n}'. Valid types are: color, dimension, fontFamily, fontWeight, duration, cubicBezier, strokeStyle, border, transition, shadow, gradient, typography`,"UNKNOWN_TOKEN_TYPE"),INVALID_COLOR:i((e,n)=>`Invalid color at '${n}': ${e}. Color should be a valid hex value"`,"INVALID_COLOR"),INVALID_DIMENSION:i((e,n)=>`Invalid dimension at '${n}': ${e}. Dimensions should have a numeric value and unit, like { "value": 16, "unit": "px" }`,"INVALID_DIMENSION"),INVALID_DIMENSION_UNIT:i((e,n)=>`Invalid unit at '${n}': ${e}. Unit must be either "px" or "rem"`,"INVALID_DIMENSION_UNIT"),INVALID_FONT_FAMILY:i((e,n)=>`Invalid font family at '${n}': ${e}. Should be a string or array of strings, like "Arial" or ["Arial", "sans-serif"]`,"INVALID_FONT_FAMILY"),INVALID_FONT_WEIGHT:i((e,n)=>`Invalid font weight at '${n}': ${e}. Should be a number between 1-1000 or a keyword like "thin", "light", "normal", "bold"`,"INVALID_FONT_WEIGHT"),INVALID_DURATION:i((e,n)=>`Invalid duration at '${n}': ${e}. Should be like { "value": 300, "unit": "ms" }`,"INVALID_DURATION"),INVALID_DURATION_UNIT:i((e,n)=>`Invalid unit at '${n}': ${e}. Unit must be "ms" or "s"`,"INVALID_DURATION_UNIT"),INVALID_CUBIC_BEZIER:i((e,n)=>`Invalid cubic bezier at '${n}': ${e}. Should be an array of 4 numbers between 0 and 1`,"INVALID_CUBIC_BEZIER"),INVALID_CUBIC_BEZIER_RANGE:i((e,n)=>`Invalid cubic bezier control points at '${n}': ${e}. X values must be between 0 and 1`,"INVALID_CUBIC_BEZIER_RANGE"),INVALID_STROKE_STYLE:i((e,n)=>`Invalid stroke style at '${n}': ${e}. Should be "solid", "dashed", "dotted", etc.`,"INVALID_STROKE_STYLE"),INVALID_DASH_ARRAY_ITEM:i((e,n)=>`Invalid dash array item at '${n}': ${e}. Should be a string or dimension object like { "value": 4, "unit": "px" }`,"INVALID_DASH_ARRAY_ITEM"),INVALID_STROKE_LINE_CAP:i((e,n)=>`Invalid line cap at '${n}': ${e}. Should be one of: round, butt, square`,"INVALID_STROKE_LINE_CAP"),INVALID_BORDER:i((e,n)=>`Invalid border at '${n}': ${e}. Should have color, width, and style properties`,"INVALID_BORDER"),INVALID_SHADOW:i((e,n)=>`Invalid shadow at '${n}': ${e}. Should have color, offsetX, offsetY properties (blur and spread are optional)`,"INVALID_SHADOW"),INVALID_SHADOW_INSET:i((e,n)=>`Invalid inset value at '${n}': ${e}. Should be true or false`,"INVALID_SHADOW_INSET"),INVALID_TRANSITION:i((e,n)=>`Invalid transition at '${n}': ${e}. Should have duration, delay, and timingFunction properties`,"INVALID_TRANSITION"),INVALID_GRADIENT:i((e,n)=>`Invalid gradient at '${n}': ${e}. Should be an array of color stops with position values between 0 and 1`,"INVALID_GRADIENT"),INVALID_GRADIENT_STOP_POSITION:i((e,n)=>`Invalid gradient stop position at '${n}': ${e}. Position must be between 0 and 1`,"INVALID_GRADIENT_STOP_POSITION"),INVALID_TYPOGRAPHY:i((e,n)=>`Invalid typography at '${n}': ${e}. Should have fontFamily and fontSize (fontWeight, letterSpacing, and lineHeight are optional)`,"INVALID_TYPOGRAPHY"),MISSING_REQUIRED_PROPERTY:i((e,n)=>`Missing required property '${e}' at '${n}'`,"MISSING_REQUIRED_PROPERTY"),MISSING_REQUIRED_PROPERTIES:i((e,n)=>`Missing required properties at '${n}': ${e.join(", ")}`,"MISSING_REQUIRED_PROPERTIES"),INVALID_NUMBER:i((e,n)=>`Invalid number at '${n}': ${e}. Expected a number value`,"INVALID_NUMBER"),INVALID_ARRAY:i((e,n)=>`Invalid array at '${n}': ${e}. Expected an array value`,"INVALID_ARRAY"),MISSING_FLUID_CONFIG:i(e=>`Missing fluid configuration at root level. Token at '${e}' requires fluid viewport settings`,"MISSING_FLUID_CONFIG"),INVALID_FLUID_DIMENSION:i((e,n)=>`Invalid fluid dimension at '${n}': ${e}. Fluid dimensions should have min and max values, like { "min": { "value": 16, "unit": "px" }, "max": { "value": 24, "unit": "px" } }`,"INVALID_FLUID_DIMENSION"),INVALID_VIEWPORT_CONFIG:i((e,n)=>`Invalid viewport configuration at '${n}': ${e}. Viewport config should have min and max dimension values`,"INVALID_VIEWPORT_CONFIG"),MISMATCHED_UNITS:i((e,n,t)=>`Mismatched units at '${t}': min uses '${e}', max uses '${n}'. Both values must use the same unit`,"MISMATCHED_UNITS"),INVALID_FLUID_VALUE_RANGE:i(e=>`Invalid fluid value range at '${e}': min value must be less than max value`,"INVALID_FLUID_VALUE_RANGE"),INVALID_VALUE_TYPE:i((e,n,t)=>`Invalid value type at '${t}': expected ${e}, got ${n}`,"INVALID_VALUE_TYPE")},CONVERT:{UNSUPPORTED_TOKEN_TYPE:i(e=>`Unsupported token type: ${e}. Valid types are: color, dimension, fontFamily, fontWeight, duration, cubicBezier, strokeStyle, border, transition, shadow, gradient, typography`,"UNSUPPORTED_TOKEN_TYPE"),MISSING_FLUID_CONFIG:i(e=>`Missing fluid configuration for token at path: ${e}`,"MISSING_FLUID_CONFIG")},RESOLVE:{CIRCULAR_REFERENCE:i((e,n)=>`Circular reference detected: ${e} -> ${n}`,"CIRCULAR_REFERENCE"),REFERENCE_NOT_FOUND:i((e,n)=>`Reference not found: ${n} in ${e}`,"REFERENCE_NOT_FOUND"),TYPE_MISMATCH:i(e=>`Type mismatch in reference resolution at ${e}`,"TYPE_MISMATCH")},GENERATE:{INVALID_CSS_VALUE:i((e,n)=>`Invalid CSS value for property '${e}': ${n}`,"INVALID_CSS_VALUE")}};function K(e){return R(e)}i(K,"flatten");function R(e,n="",t){const r={},o=[];for(const[s,a]of Object.entries(e)){if(s.startsWith("$"))continue;const f=n?`${n}.${s}`:s;if(s.includes(".")||s.includes("{")||s.includes("}")){o.push({path:s,message:u.FLATTEN.INVALID_TOKEN_NAME(s)});continue}if(typeof a!="object"||a===null){o.push({path:f,message:u.FLATTEN.INVALID_NODE_STRUCTURE(f)});continue}const l="$type"in a?a.$type:t;if("$value"in a){if(!l){o.push({path:f,message:u.FLATTEN.MISSING_INHERITED_TYPE(f)});continue}r[f]={$type:l,$value:a.$value,$path:f}}else{const I=R(a,f,l);Object.assign(r,I.tokens),o.push(...I.errors)}}return{tokens:r,errors:o}}i(R,"processTokens");const Q=new Set(["$description","$extensions"]);function c(e){return typeof e=="string"&&e.startsWith("{")&&e.endsWith("}")}i(c,"isReference");function q(e){return typeof e=="object"&&e!==null&&typeof e.query=="string"&&typeof e.value=="string"}i(q,"isFeatureValue");function X(e){return typeof e!="object"||e===null||!("value"in e)||typeof e.value!="string"&&typeof e.value!="number"?!1:"featureValues"in e?Array.isArray(e.featureValues)?e.featureValues.every(q):!1:!0}i(X,"isSimpleCSSProperties");function Z(e){return!!(typeof e=="string"||typeof e=="number"||X(e))}i(Z,"isValidCSSValue");function $(e,n,t,r){return typeof n=="string"&&c(n)?ee(e,n,t,r):Array.isArray(n)?n.map(o=>$(e,o,t,r)):typeof n=="object"&&n!==null?Object.entries(n).reduce((s,[a,f])=>({...s,[a]:$(`${e}.${a}`,f,t,r)}),{}):n}i($,"resolveValue");function J(e){const n={},t=new Set,r=[];for(const[o,s]of Object.entries(e))try{if(!s.$path)continue;n[s.$path]={...s,$resolvedValue:$(s.$path,s.$value,e,t)}}catch(a){const f=a instanceof Error?a.message:String(a);let l,I;f.includes("Circular reference detected")?(l="circular",I=f):f.includes("Reference not found")?(l="missing",I=f):(l="type-mismatch",I=u.RESOLVE.TYPE_MISMATCH(s.$path)),r.push({type:l,path:s.$path,message:I})}return{resolved:n,errors:r}}i(J,"resolve");function ee(e,n,t,r){const o=n.slice(1,-1);if(r.has(o))throw new Error(`Circular reference detected: ${e} -> ${o}`);const s=t[o];if(!s)throw new Error(`Reference not found: ${o} in ${e}`);r.add(o);const a=$(o,s.$value,t,r);return r.delete(o),a}i(ee,"resolveReferenceChain");function p(e){return["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"].includes(e.toLowerCase())?e:/[\s'"!@#$%^&*()=+[\]{};:|\\/,.<>?~]/.test(e)?`"${e}"`:e}i(p,"quoteFont");const ne={thin:100,hairline:100,"extra-light":200,"ultra-light":200,light:300,normal:400,regular:400,book:400,medium:500,"semi-bold":600,"demi-bold":600,bold:700,"extra-bold":800,"ultra-bold":800,black:900,heavy:900,"extra-black":950,"ultra-black":950};function b(e){return c(e)?{value:e}:typeof e=="number"?{value:e}:{value:ne[e.toLowerCase()]??e}}i(b,"convertFontWeightToken");function te(e){if(c(e))return{"font-family":e,"font-size":e};const n={"font-family":c(e.fontFamily)?e.fontFamily:Array.isArray(e.fontFamily)?e.fontFamily.map(t=>p(t)).join(", "):p(e.fontFamily),"font-size":c(e.fontSize)?e.fontSize:`${e.fontSize.value}${e.fontSize.unit}`};return e.fontWeight&&(n["font-weight"]=c(e.fontWeight)?e.fontWeight:b(e.fontWeight).value),e.letterSpacing&&(n["letter-spacing"]=c(e.letterSpacing)?e.letterSpacing:`${e.letterSpacing.value}${e.letterSpacing.unit}`),e.lineHeight&&(n["line-height"]=(c(e.lineHeight),e.lineHeight)),n}i(te,"convertTypographyToken");function re(e){if(c(e))return{value:e};const n=(c(e.duration),e.duration),t=c(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,r=e.delay&&(c(e.delay),e.delay),o={duration:n,"timing-function":t,...r&&{delay:r}};return{value:[n,t,r].filter(Boolean).join(" "),split:o}}i(re,"convertTransitionToken");function ie(e){return c(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}i(ie,"convertCubicBezierToken");function oe(e){return c(e)?{value:e}:{value:e}}i(oe,"convertNumberToken");function se(e){return c(e)?{value:e}:{value:e.toString()}}i(se,"convertDurationToken");function h(e){return c(e)?{value:e}:typeof e=="string"?{value:e}:{value:`${e.dashArray.map(t=>c(t)?t:`${t.value}${t.unit}`).join(" ")} ${e.lineCap}`}}i(h,"convertStrokeStyleToken");function ue(e){if(c(e))return{value:e};const n=c(e.width)?e.width:`${e.width.value}${e.width.unit}`,t=(c(e.color),e.color);let r;return typeof e.style=="string"?r=e.style:r=h(e.style).value,{value:`${n} ${r} ${t}`,split:{width:n,style:r,color:t}}}i(ue,"convertBorderToken");function O(e){const n=c(e.offsetX)?e.offsetX:`${e.offsetX.value}${e.offsetX.unit}`,t=c(e.offsetY)?e.offsetY:`${e.offsetY.value}${e.offsetY.unit}`,r=c(e.blur)?e.blur:`${e.blur.value}${e.blur.unit}`,o=c(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,s=(c(e.color),e.color),a={color:s,"offset-x":n,"offset-y":t,blur:r,spread:o,...e.inset&&{inset:"inset"}};return{value:`${e.inset?"inset ":""}${n} ${t} ${r} ${o} ${s}`,split:a}}i(O,"convertSingleShadow");function ce(e){if(c(e))return{value:e};if(!Array.isArray(e)){const t=O(e);return{value:t.value,split:[t.split]}}const n=e.map(O);return{value:n.map(t=>t.value).join(", "),split:n.map(t=>t.split)}}i(ce,"convertShadowToken");function ae(e){if(c(e))return{value:e};const n=e.map(t=>({color:(c(t.color),t.color),position:`${t.position}%`}));return{value:`linear-gradient(${n.map(t=>`${t.color} ${t.position}`).join(", ")})`,split:{stops:n}}}i(ae,"convertGradientToken");function fe(e){return c(e)?{value:e}:{value:Array.isArray(e)?e.map(t=>p(t)).join(", "):p(e)}}i(fe,"convertFontFamilyToken");function le(e){return c(e)?{value:e}:{value:`${e.value}${e.unit}`}}i(le,"convertDimensionToken");function Ie(e,n,t){if(e in t.tokens&&t.tokens[e]?.[n]!==void 0)return t.tokens[e][n];const r=e.split(".");for(;r.length>0;){const o=r.join(".");if(o in t.groups&&t.groups[o]&&n in t.groups[o])return t.groups[o][n];r.pop()}return t.root[n]}i(Ie,"getMetadataValue");function P(e,n){return Ie(e,"$extensions",n)?.["com.sugarcube"]}i(P,"getExtensions");function C(e,n){return P(e,n)?.fluid}i(C,"getFluidConfig");function de(e,n){return P(e,n)?.color?.format}i(de,"getColorFormat");function E(e,n=16){switch(e.unit){case"px":return e.value;case"rem":return e.value*n;default:throw new Error(`Unsupported unit: ${e.unit}. Fluid dimensions must use 'px' or 'rem'`)}}i(E,"normalizeToPixels");function Ae(e,n){if(!n?.viewports)throw new Error("Fluid metadata is required for fluid dimensions");const{min:t,max:r}=e,{viewports:o}=n,s=16,a=E(t,s),f=E(r,s),l=E(o.min,s),I=E(o.max,s);if(a===f)return{value:`${a/s}rem`};const g=a/s,_=f/s,V=l/s,W=I/s,L=(_-g)/(W-V),H=-1*V*L+g;return{value:`clamp(${g}rem, ${H.toFixed(2)}rem + ${(L*100).toFixed(2)}vw, ${_}rem)`}}i(Ae,"convertFluidDimension");function $e(e,n){if(c(e))return{value:e};const t=C(n.path,n.metadataMap);if(!t)throw new Error(u.CONVERT.MISSING_FLUID_CONFIG(n.path));return Ae(e,t)}i($e,"convertFluidDimensionToken");function pe(e,n,t){const r=Math.max(e,n,t),o=Math.min(e,n,t);let s=0,a=0;const f=(r+o)/2;if(r!==o){const l=r-o;switch(a=f>.5?l/(2-r-o):l/(r+o),r){case e:s=(n-t)/l+(n<t?6:0);break;case n:s=(t-e)/l+2;break;case t:s=(e-n)/l+4;break}s*=60}return[Math.round(s),Math.round(a*100),Math.round(f*100)]}i(pe,"rgbToHsl");const m=i(e=>Number.isInteger(e)?e.toString():Number(e.toFixed(3)).toString(),"formatNumber"),Ee={hex:{type:"standard",convert:i((e,n,t,r)=>{const o=i(s=>Math.round(s*255).toString(16).padStart(2,"0"),"toHex");return`#${o(e)}${o(n)}${o(t)}${r<1?o(r):""}`},"convert")},rgb:{type:"standard",convert:i((e,n,t,r)=>{const o=[e,n,t].map(s=>Math.round(s*255));return r===1?`rgb(${o.join(", ")})`:`rgba(${o.join(", ")}, ${m(r)})`},"convert")},hsl:{type:"standard",convert:i((e,n,t,r)=>{const[o,s,a]=pe(e,n,t);return r===1?`hsl(${o}, ${s}%, ${a}%)`:`hsla(${o}, ${s}%, ${a}%, ${m(r)})`},"convert")},p3:{type:"conditional",featureQuery:"@supports (color: color(display-p3 1 1 1))",convert:i((e,n,t,r)=>{const o=[e,n,t].map(m).join(" ");return r===1?`color(display-p3 ${o})`:`color(display-p3 ${o} / ${m(r)})`},"convert")}};function me(e,n){if(c(e))return{value:e};const t=de(n.path,n.metadataMap)||"hex";if(t==="hex")return{value:e};const r=Ee[t];if(!r)return{value:e};const o=e.substring(1),s=parseInt(o.substring(0,2),16)/255,a=parseInt(o.substring(2,4),16)/255,f=parseInt(o.substring(4,6),16)/255,l=o.length===8?parseInt(o.substring(6,8),16)/255:1;return r.type==="conditional"?{value:e,featureValues:[{query:r.featureQuery,value:r.convert(s,a,f,l)}]}:{value:r.convert(s,a,f,l)}}i(me,"convertColorToken");const ye={duration:se,number:oe,cubicBezier:ie,color:me,dimension:le,fluidDimension:$e,typography:te,border:ue,shadow:ce,gradient:ae,transition:re,strokeStyle:h,fontFamily:fe,fontWeight:b},F=new Map;function M(e){const n=F.get(e);if(n)return n;const t=e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z])(?=[a-z])/g,"$1-$2").toLowerCase();return F.set(e,t),t}i(M,"toKebabCase");function ge(e,n){const t=ye[e.$type];if(!t)throw new Error(u.CONVERT.UNSUPPORTED_TOKEN_TYPE(e.$type));return{$type:e.$type,$value:e.$value,$path:e.$path,$resolvedValue:e.$resolvedValue,cssProperties:t(e.$value,n)}}i(ge,"convertSingleToken");function Se(e,n){const t={};for(const[r,o]of Object.entries(e)){if(Q.has(r)||o===void 0)continue;const s={metadataMap:n,path:r};if(!("$type"in o))throw new Error(`Token at path ${r} is missing $type property`);if(o.$type==="fluidDimension"&&!n)throw new Error(u.CONVERT.MISSING_FLUID_CONFIG(r));const a=r.split(".").map(M).join("-");t[a]=ge(o,s)}return t}i(Se,"convert");const S="(color: color(display-p3 1 1 1))",Te=[{query:S,test:i(e=>e.$type!=="color"?!1:e.cssProperties.featureValues?.some(t=>t.query===S)??!1,"test"),convertToCSSVars:i((e,n)=>{const r=n.cssProperties.featureValues?.find(o=>o.query===S);return r?[{name:`--${Ne(e)}`,value:r.value}]:[]},"convertToCSSVars")}];function Ne(e){return e.split(".").join("-")}i(Ne,"formatCSSVarPath");function U(e){return typeof e=="number"?e.toString():e.replace(/\{([^}]+)\}/g,(n,t)=>`var(--${t.split(".").map(M).join("-")})`)}i(U,"convertReferenceToCSSVar");function A(e,n){if(!Z(n))throw new Error(u.GENERATE.INVALID_CSS_VALUE(e,String(n)));const t=typeof n=="object"&&"value"in n?U(n.value):U(n);return{name:`--${e}`,value:t}}i(A,"createSingleCSSVar");function De(e,n){if(!("split"in n)||!n.split)return{base:"value"in n?[A(e,n.value)]:Object.entries(n).map(([t,r])=>A(`${e}-${t}`,r))};if(Array.isArray(n.split)){const t=n.split.length>1;return{base:n.split.flatMap((r,o)=>Object.entries(r).map(([s,a])=>{const f=t?`-${o+1}-${s}`:`-${s}`;return A(`${e}${f}`,a)}))}}return{base:Object.entries(n.split).map(([t,r])=>A(`${e}-${t}`,r))}}i(De,"convertSplitTokenToCSSVars");function _e(e){return{name:`--${e}`,value:[`var(--${e}-width)`,`var(--${e}-style)`,`var(--${e}-color)`].join(" ")}}i(_e,"createBorderCSSVar");function x(e,n,t){return[`var(--${e}${n?`-${t+1}`:""}-offset-x)`,`var(--${e}${n?`-${t+1}`:""}-offset-y)`,`var(--${e}${n?`-${t+1}`:""}-blur)`,`var(--${e}${n?`-${t+1}`:""}-spread)`,`var(--${e}${n?`-${t+1}`:""}-color)`].join(" ")}i(x,"createShadowCSSVar");function Ve(e,n,t){if("split"in t){if(e!=="shadow")return e==="border"?_e(n):void 0;if(Array.isArray(t.split)){const r=t.split.length>1,o=t.split.map((s,a)=>x(n,r,a)).join(", ");return{name:`--${n}`,value:o}}return{name:`--${n}`,value:x(n,!1,0)}}}i(Ve,"createCombinedCSSVar");function Le(e,n,t){if(!(n.$type==="typography"||t.includes(n.$type)))return[A(e,n.cssProperties)];const{base:o}=De(e,n.cssProperties),s=Ve(n.$type,e,n.cssProperties);return s?[...o,s]:o}i(Le,"convertTokenToCSSVarSet");function Re(e){const n=`${e.root.selector}{${e.root.vars.map(r=>`${r.name}:${r.value}`).join(";")}}`,t=e.features.map(r=>`@supports ${r.query}{${e.root.selector}{${r.vars.map(o=>`${o.name}:${o.value}`).join(";")}}}`).join("");return n+t}i(Re,"convertCSSVarsToString");async function be(e,n={}){const t=Object.entries(e).filter(([s])=>s!=="$extensions").flatMap(([s,a])=>Le(s,a,n.splitTypes||[])),r=Te.map(s=>{const f=Object.entries(e).filter(([l,I])=>s.test(I)).flatMap(([l,I])=>s.convertToCSSVars(l,I));return f.length>0?{query:s.query,vars:f}:null}).filter(s=>s!==null),o=Re({root:{selector:":root",vars:t},features:r});return he(o)}i(be,"generateCSS");function he(e){return e=e.replace(/{/g,`{
|
|
2
|
+
`),e=e.replace(/([^{]);/g,`$1;
|
|
3
|
+
`),e=e.replace(/}(?!$)/g,`
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
`),e=e.replace(/}$/,`
|
|
7
|
+
}`),e}i(he,"formatCSSVars");function Oe(e){const n={root:{},groups:{},tokens:{}},t=[];if(N(e)){const{value:r,errors:o}=T(e,"");n.root=r,t.push(...o)}return v(e,"",n,t),{metadata:n,errors:t}}i(Oe,"collectMetadata");function v(e,n,t,r){for(const[o,s]of Object.entries(e)){if(o.startsWith("$"))continue;const a=n?`${n}.${o}`:o;if(!(typeof s!="object"||s===null)){if(!("$value"in s)&&N(s)){const{value:f,errors:l}=T(s,a);l.length>0&&r.push(...l),t.groups[a]=f}else if("$value"in s&&N(s)){const{value:f,errors:l}=T(s,a);l.length>0&&r.push(...l),t.tokens[a]=f}"$value"in s||v(s,a,t,r)}}}i(v,"collectNodeMetadata");function T(e,n){const t={},r=[];return j(e)?("$extensions"in e&&(typeof e.$extensions!="object"||e.$extensions===null?r.push({path:n,message:u.METADATA.INVALID_EXTENSIONS(n)}):t.$extensions=e.$extensions),"$description"in e&&(typeof e.$description!="string"?r.push({path:n,message:u.METADATA.INVALID_DESCRIPTION(n)}):t.$description=e.$description),{value:t,errors:r}):{value:t,errors:r}}i(T,"extractMetadata");function N(e){return j(e)&&("$extensions"in e||"$description"in e)}i(N,"hasMetadata");function j(e){return typeof e=="object"&&e!==null}i(j,"isValidNode");function Pe(e){return JSON.parse(e)}i(Pe,"parseJson");function y(e,n){const t=[];return(typeof e!="string"||!/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/.test(e))&&t.push({path:n,message:u.VALIDATE.INVALID_COLOR(e,n)}),t}i(y,"validateColor");function d(e,n){const t=[];if(typeof e!="object"||e===null||Array.isArray(e))return t.push({path:n,message:u.VALIDATE.INVALID_DIMENSION(e,n)}),t;const r=e;return"value"in r?typeof r.value!="number"&&t.push({path:`${n}.value`,message:u.VALIDATE.INVALID_NUMBER(r.value,n)}):t.push({path:`${n}.value`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("value",n)}),"unit"in r?(typeof r.unit!="string"||!["px","rem"].includes(r.unit))&&t.push({path:`${n}.unit`,message:u.VALIDATE.INVALID_DIMENSION_UNIT(r.unit,n)}):t.push({path:`${n}.unit`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("unit",n)}),t}i(d,"validateDimension");function Ce(e,n){const t=[];return(typeof e!="number"||isNaN(e))&&t.push({path:n,message:`Invalid number value at ${n}. Expected a number, got ${e}`}),t}i(Ce,"validateNumber");function k(e,n){const t=[];return typeof e=="string"||(Array.isArray(e)?e.every(r=>typeof r=="string")||t.push({path:n,message:u.VALIDATE.INVALID_FONT_FAMILY(e,n)}):t.push({path:n,message:u.VALIDATE.INVALID_FONT_FAMILY(e,n)})),t}i(k,"validateFontFamily");const Fe=["thin","hairline","extra-light","ultra-light","light","normal","regular","book","medium","semi-bold","demi-bold","bold","extra-bold","ultra-bold","black","heavy","extra-black","ultra-black"];function G(e,n){const t=[];return typeof e=="number"?(e<1||e>1e3)&&t.push({path:n,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,n)}):typeof e=="string"?Fe.includes(e.toLowerCase())||t.push({path:n,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,n)}):t.push({path:n,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,n)}),t}i(G,"validateFontWeight");function D(e,n){const t=[];if(typeof e!="object"||e===null||Array.isArray(e))return t.push({path:n,message:u.VALIDATE.INVALID_DURATION(e,n)}),t;const r=e;return"value"in r?typeof r.value!="number"&&t.push({path:`${n}.value`,message:u.VALIDATE.INVALID_NUMBER(r.value,n)}):t.push({path:`${n}.value`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("value",n)}),"unit"in r?(typeof r.unit!="string"||r.unit!=="ms")&&t.push({path:`${n}.unit`,message:u.VALIDATE.INVALID_DURATION_UNIT(r.unit,n)}):t.push({path:`${n}.unit`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("unit",n)}),t}i(D,"validateDuration");function Y(e,n){const t=[];if(!Array.isArray(e)||e.length!==4||!e.every(r=>typeof r=="number"))t.push({path:n,message:u.VALIDATE.INVALID_CUBIC_BEZIER(e,n)});else{const[r,,o]=e;(r!==void 0&&(r<0||r>1)||o!==void 0&&(o<0||o>1))&&t.push({path:n,message:u.VALIDATE.INVALID_CUBIC_BEZIER_RANGE(e,n)})}return t}i(Y,"validateCubicBezier");function Me(e,n){const t=[];if(e==null)return t.push({path:n,message:u.VALIDATE.INVALID_TYPOGRAPHY(e,n)}),t;if(typeof e!="object"||Array.isArray(e))return t.push({path:n,message:u.VALIDATE.INVALID_TYPOGRAPHY(e,n)}),t;const r=e;if("fontFamily"in r||t.push({path:`${n}.fontFamily`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("fontFamily",n)}),"fontSize"in r||t.push({path:`${n}.fontSize`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("fontSize",n)}),"fontFamily"in r&&!c(r.fontFamily)&&t.push(...k(r.fontFamily,`${n}.fontFamily`)),"fontSize"in r&&!c(r.fontSize)){const o=r.fontSize;typeof o!="object"||!o||Array.isArray(o)?t.push({path:`${n}.fontSize`,message:u.VALIDATE.INVALID_DIMENSION(o,n)}):t.push(...d(o,`${n}.fontSize`))}if("letterSpacing"in r&&!c(r.letterSpacing)){const o=r.letterSpacing;typeof o!="object"||!o||Array.isArray(o)?t.push({path:`${n}.letterSpacing`,message:u.VALIDATE.INVALID_DIMENSION(o,n)}):t.push(...d(o,`${n}.letterSpacing`))}if("fontWeight"in r&&!c(r.fontWeight)&&t.push(...G(r.fontWeight,`${n}.fontWeight`)),"lineHeight"in r&&!c(r.lineHeight)){const o=r.lineHeight;typeof o!="number"&&t.push({path:`${n}.lineHeight`,message:u.VALIDATE.INVALID_NUMBER(o,n)})}return t}i(Me,"validateTypographyObject");function Ue(e,n){return Me(e,n)}i(Ue,"validateTypography");const xe=["solid","dashed","dotted","double","groove","ridge","outset","inset"],ve=["round","butt","square"];function je(e,n){const t=[];if(typeof e!="string"&&typeof e!="object")t.push({path:n,message:u.VALIDATE.INVALID_DASH_ARRAY_ITEM(e,n)});else if(typeof e=="object"&&!c(e)){const r=e;(typeof r.value!="number"||typeof r.unit!="string")&&t.push({path:n,message:u.VALIDATE.INVALID_DIMENSION(r,n)})}return t}i(je,"validateDashArrayItem");function ke(e,n){const t=[];return"dashArray"in e?"lineCap"in e?(Array.isArray(e.dashArray)?e.dashArray.forEach((r,o)=>{t.push(...je(r,`${n}.dashArray[${o}]`))}):t.push({path:`${n}.dashArray`,message:u.VALIDATE.INVALID_ARRAY(e.dashArray,n)}),ve.includes(e.lineCap)||t.push({path:`${n}.lineCap`,message:u.VALIDATE.INVALID_STROKE_LINE_CAP(e.lineCap,n)})):t.push({path:n,message:u.VALIDATE.MISSING_REQUIRED_PROPERTIES(["lineCap"],n)}):t.push({path:n,message:u.VALIDATE.MISSING_REQUIRED_PROPERTIES(["dashArray"],n)}),t}i(ke,"validateCustomStrokeStyle");function w(e,n){const t=[];return typeof e=="string"?xe.includes(e)||t.push({path:n,message:u.VALIDATE.INVALID_STROKE_STYLE(e,n)}):typeof e=="object"&&e!==null&&!Array.isArray(e)?t.push(...ke(e,n)):t.push({path:n,message:u.VALIDATE.INVALID_STROKE_STYLE(e,n)}),t}i(w,"validateStrokeStyle");function Ge(e,n){return typeof e!="object"||e===null||Array.isArray(e)?[{path:n,message:u.VALIDATE.INVALID_DIMENSION(e,n)}]:d(e,n)}i(Ge,"validateBorderWidth");function Ye(e,n){const t=[];if(typeof e!="object"||Array.isArray(e)||e===null)return t.push({path:n,message:u.VALIDATE.INVALID_BORDER(e,n)}),t;const r=e,o=["color","width","style"];for(const s of o)s in r||t.push({path:`${n}.${s}`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY(s,n)});return"color"in r&&!c(r.color)&&t.push(...y(r.color,`${n}.color`)),"width"in r&&!c(r.width)&&t.push(...Ge(r.width,`${n}.width`)),"style"in r&&!c(r.style)&&t.push(...w(r.style,`${n}.style`)),t}i(Ye,"validateBorder");function we(e,n){const t=[];if(typeof e!="object"||Array.isArray(e)||e===null)return t.push({path:n,message:u.VALIDATE.INVALID_TRANSITION(e,n)}),t;const r=e,s=["duration","delay","timingFunction"].filter(a=>!(a in r));return s.length>0&&t.push({path:n,message:u.VALIDATE.MISSING_REQUIRED_PROPERTIES(s,n)}),"duration"in r&&!c(r.duration)&&t.push(...D(r.duration,`${n}.duration`)),"delay"in r&&!c(r.delay)&&t.push(...D(r.delay,`${n}.delay`)),"timingFunction"in r&&!c(r.timingFunction)&&t.push(...Y(r.timingFunction,`${n}.timingFunction`)),t}i(we,"validateTransition");function z(e,n){const t=[];if(typeof e!="object"||e===null)return t.push({path:n,message:u.VALIDATE.INVALID_SHADOW(e,n)}),t;const r=e;"color"in r?c(r.color)||t.push(...y(r.color,`${n}.color`)):t.push({path:`${n}.color`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("color",n)});const o=["offsetX","offsetY","blur","spread"];for(const s of o)s in r?c(r[s])||t.push(...d(r[s],`${n}.${s}`)):t.push({path:`${n}.${s}`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY(s,n)});return"inset"in r&&typeof r.inset!="boolean"&&t.push({path:`${n}.inset`,message:u.VALIDATE.INVALID_SHADOW_INSET(r.inset,n)}),t}i(z,"validateShadowObject");function ze(e,n){const t=[];return Array.isArray(e)?e.forEach((r,o)=>{t.push(...z(r,`${n}[${o}]`))}):typeof e=="object"&&e!==null?t.push(...z(e,n)):t.push({path:n,message:u.VALIDATE.INVALID_SHADOW(e,n)}),t}i(ze,"validateShadow");function We(e,n){const t=[];if(typeof e!="object"||e===null)return t.push({path:n,message:u.VALIDATE.INVALID_GRADIENT(e,n)}),t;const r=e;if("color"in r?c(r.color)||t.push(...y(r.color,`${n}.color`)):t.push({path:`${n}.color`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("color",n)}),!("position"in r))t.push({path:`${n}.position`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY("position",n)});else if(!c(r.position)){const o=r.position;typeof o!="number"?t.push({path:`${n}.position`,message:u.VALIDATE.INVALID_NUMBER(o,n)}):(o<0||o>1)&&t.push({path:`${n}.position`,message:u.VALIDATE.INVALID_GRADIENT_STOP_POSITION(o,n)})}return t}i(We,"validateGradientStop");function He(e,n){const t=[];return Array.isArray(e)?(e.forEach((r,o)=>{t.push(...We(r,`${n}[${o}]`))}),t):(t.push({path:n,message:u.VALIDATE.INVALID_ARRAY(e,n)}),t)}i(He,"validateGradient");function Be(e,n){const t=[];if(typeof e!="object"||e===null||Array.isArray(e))return t.push({path:n,message:u.VALIDATE.INVALID_FLUID_DIMENSION(e,n)}),t;const r=e,o=["min","max"];for(const s of o){if(!(s in r)){t.push({path:`${n}.${s}`,message:u.VALIDATE.MISSING_REQUIRED_PROPERTY(s,n)});continue}t.push(...d(r[s],`${n}.${s}`))}return t}i(Be,"validateFluidDimension");const Ke={color:i((e,n)=>y(e,n),"color"),dimension:i((e,n)=>d(e,n),"dimension"),fluidDimension:i((e,n)=>Be(e,n),"fluidDimension"),duration:i((e,n)=>D(e,n),"duration"),cubicBezier:i((e,n)=>Y(e,n),"cubicBezier"),fontFamily:i((e,n)=>k(e,n),"fontFamily"),fontWeight:i((e,n)=>G(e,n),"fontWeight"),number:i((e,n)=>Ce(e,n),"number"),strokeStyle:i((e,n)=>w(e,n),"strokeStyle"),typography:i((e,n)=>Ue(e,n),"typography"),border:i((e,n)=>Ye(e,n),"border"),shadow:i((e,n)=>ze(e,n),"shadow"),gradient:i((e,n)=>He(e,n),"gradient"),transition:i((e,n)=>we(e,n),"transition")};function Qe(e,n,t){const r=[];if(!("$type"in e))return[{path:n,message:u.VALIDATE.MISSING_TYPE(n)}];if(!("$value"in e))return[{path:n,message:u.VALIDATE.MISSING_VALUE(n)}];const o=Ke[e.$type];return o?c(e.$value)?[]:(e.$type==="fluidDimension"&&(C(n,t)?.viewports||r.push({path:n,message:u.VALIDATE.MISSING_FLUID_CONFIG(n)})),[...r,...o(e.$value,n)]):[{path:n,message:u.VALIDATE.UNKNOWN_TOKEN_TYPE(e.$type,n)}]}i(Qe,"validateTokenNode");function qe(e,n){const t=[];for(const[r,o]of Object.entries(e))if(!(typeof o!="object"||o===null)&&!(!o.$path||o.$path.startsWith("$"))){if(typeof o!="object"||o===null){t.push({path:r,message:u.VALIDATE.INVALID_TOKEN_STRUCTURE(r)});continue}t.push(...Qe(o,o.$path,n))}return t}i(qe,"validate");export{Oe as collectMetadata,Se as convert,K as flatten,be as generateCSS,Pe as parseJson,J as resolve,qe as validate};
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sugarcube-org/core",
|
|
3
|
+
"version": "0.0.1-alpha.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "restricted"
|
|
6
|
+
},
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"pkgroll": "^2.5.1"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "pkgroll --minify",
|
|
19
|
+
"dev": "pkgroll --watch",
|
|
20
|
+
"test": "vitest",
|
|
21
|
+
"type-check": "tsc --noEmit"
|
|
22
|
+
}
|
|
23
|
+
}
|