@designid/tokens 0.4.6 → 1.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/bin/build.js +413 -76
- package/bin/watch.js +25 -2
- package/package.json +8 -11
- package/types/design-tokens.ts +1083 -0
- package/types/files.d.ts +116 -3
- package/types/index.d.ts +79 -0
- package/types/token.d.ts +31 -0
- package/types/typography.d.ts +51 -0
- package/types/utils.d.ts +49 -0
- package/bin/build-icons.js +0 -2
- package/example/tokens/border/composition.tokens.json +0 -31
- package/example/tokens/colors/brand/primary.tokens.json +0 -44
- package/example/tokens/colors/icon/mono.tokens.json +0 -15
- package/example/tokens/effect/shadow.tokens.json +0 -41
- package/example/tokens/font/family.tokens.json +0 -110
- package/example/tokens/font/h1.tokens.json +0 -59
- package/example/tokens/foundation.tokens.json +0 -145
package/types/files.d.ts
CHANGED
|
@@ -3,14 +3,48 @@ import type {
|
|
|
3
3
|
TFont,
|
|
4
4
|
TTokenReference,
|
|
5
5
|
} from "./index.ts";
|
|
6
|
+
import type {
|
|
7
|
+
TokenReference,
|
|
8
|
+
JsonPointerReference,
|
|
9
|
+
CompositeStringValue,
|
|
10
|
+
ValueOrReference,
|
|
11
|
+
FontFaceValue,
|
|
12
|
+
FontFaceCollectionValue,
|
|
13
|
+
TokenType,
|
|
14
|
+
ModeExtension,
|
|
15
|
+
GeneratorsExtension,
|
|
16
|
+
BreakpointsExtension,
|
|
17
|
+
EnhancedExtensionData
|
|
18
|
+
} from "../src/types/design-tokens.ts";
|
|
6
19
|
|
|
7
20
|
type TThemeKey = string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Enhanced font configuration supporting W3C FontFace specification
|
|
24
|
+
* Maintains backward compatibility while adding new W3C features
|
|
25
|
+
*/
|
|
26
|
+
export type TEnhancedFont = FontFaceValue | TFont;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Collection of enhanced fonts supporting both legacy and W3C formats
|
|
30
|
+
*/
|
|
31
|
+
export type TEnhancedFontCollection = TEnhancedFont[] | FontFaceCollectionValue;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Enhanced token reference supporting W3C specifications
|
|
35
|
+
*/
|
|
36
|
+
export type TEnhancedTokenReference =
|
|
37
|
+
| TTokenReference
|
|
38
|
+
| TokenReference
|
|
39
|
+
| JsonPointerReference
|
|
40
|
+
| CompositeStringValue;
|
|
41
|
+
|
|
8
42
|
export type TConfigMetaDataIcons = {
|
|
9
43
|
objectPath: string;
|
|
10
44
|
size?: number;
|
|
11
45
|
style?: {
|
|
12
46
|
type: "mono" | "animated";
|
|
13
|
-
fill:
|
|
47
|
+
fill: TEnhancedTokenReference | string;
|
|
14
48
|
};
|
|
15
49
|
};
|
|
16
50
|
|
|
@@ -35,13 +69,51 @@ export type TConfigFile = {
|
|
|
35
69
|
};
|
|
36
70
|
};
|
|
37
71
|
$modes: Record<TThemeKey, TTheme>;
|
|
38
|
-
$fonts?:
|
|
72
|
+
$fonts?: TEnhancedFontCollection;
|
|
73
|
+
/**
|
|
74
|
+
* Enhanced extensions configuration supporting W3C design tokens specification
|
|
75
|
+
*/
|
|
76
|
+
$extensions?: {
|
|
77
|
+
/**
|
|
78
|
+
* Default mode configuration for tokens
|
|
79
|
+
*/
|
|
80
|
+
mode?: ModeExtension;
|
|
81
|
+
/**
|
|
82
|
+
* Global generator configuration
|
|
83
|
+
*/
|
|
84
|
+
generators?: GeneratorsExtension;
|
|
85
|
+
/**
|
|
86
|
+
* Global breakpoint configuration
|
|
87
|
+
*/
|
|
88
|
+
breakpoints?: BreakpointsExtension;
|
|
89
|
+
/**
|
|
90
|
+
* Additional vendor-specific extensions
|
|
91
|
+
*/
|
|
92
|
+
[vendorKey: `$${string}`]: EnhancedExtensionData | unknown;
|
|
93
|
+
};
|
|
39
94
|
$metaData: {
|
|
40
95
|
tokenNamespace: string;
|
|
41
96
|
dsNamespace?: string;
|
|
42
97
|
fontNamespace?: `${string}-${string}-${string}` | string;
|
|
43
98
|
icons?: TConfigMetaDataIcons;
|
|
44
99
|
tokens?: {
|
|
100
|
+
/**
|
|
101
|
+
* W3C Design Tokens specification compliance level
|
|
102
|
+
*/
|
|
103
|
+
w3cCompliance?: {
|
|
104
|
+
/**
|
|
105
|
+
* Enforce strict W3C token type validation
|
|
106
|
+
*/
|
|
107
|
+
strictTypes?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Support for W3C extensions (modes, generators, breakpoints)
|
|
110
|
+
*/
|
|
111
|
+
enableExtensions?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Validate token references using W3C format
|
|
114
|
+
*/
|
|
115
|
+
validateReferences?: boolean;
|
|
116
|
+
};
|
|
45
117
|
css?: {
|
|
46
118
|
mediaQuery?: {
|
|
47
119
|
match?:
|
|
@@ -64,7 +136,26 @@ export type TConfigFile = {
|
|
|
64
136
|
}[];
|
|
65
137
|
}
|
|
66
138
|
}
|
|
67
|
-
}
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Token validation configuration
|
|
142
|
+
*/
|
|
143
|
+
validation?: {
|
|
144
|
+
/**
|
|
145
|
+
* Enable token reference validation
|
|
146
|
+
*/
|
|
147
|
+
enableReferenceValidation?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Supported token types for validation
|
|
150
|
+
*/
|
|
151
|
+
supportedTypes?: TokenType[];
|
|
152
|
+
/**
|
|
153
|
+
* Custom validation rules
|
|
154
|
+
*/
|
|
155
|
+
customRules?: {
|
|
156
|
+
[ruleName: string]: (token: unknown) => boolean | string;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
68
159
|
};
|
|
69
160
|
colorspace:
|
|
70
161
|
| "hex" // Default colorspace
|
|
@@ -117,8 +208,30 @@ export type TCSSFileWrapperOptions = {
|
|
|
117
208
|
filter?: {
|
|
118
209
|
namespace?: string[];
|
|
119
210
|
isInclusion?: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Filter by W3C token types
|
|
213
|
+
*/
|
|
214
|
+
tokenTypes?: TokenType[];
|
|
120
215
|
},
|
|
121
216
|
transformValue?: (value: string) => string;
|
|
217
|
+
customFilter?: (token: any) => boolean;
|
|
218
|
+
/**
|
|
219
|
+
* W3C Design Tokens specific options
|
|
220
|
+
*/
|
|
221
|
+
w3cOptions?: {
|
|
222
|
+
/**
|
|
223
|
+
* Include W3C metadata in output
|
|
224
|
+
*/
|
|
225
|
+
includeMetadata?: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Process token references according to W3C spec
|
|
228
|
+
*/
|
|
229
|
+
processReferences?: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Handle composite string values
|
|
232
|
+
*/
|
|
233
|
+
processCompositeStrings?: boolean;
|
|
234
|
+
};
|
|
122
235
|
}
|
|
123
236
|
|
|
124
237
|
export default TConfigFile;
|
package/types/index.d.ts
CHANGED
|
@@ -4,3 +4,82 @@ export type * from './icons.d.ts';
|
|
|
4
4
|
export type * from './token.d.ts';
|
|
5
5
|
export type * from './typography.d.ts';
|
|
6
6
|
export type * from './utils.d.ts';
|
|
7
|
+
|
|
8
|
+
// Re-export W3C Design Tokens types for convenience
|
|
9
|
+
export type {
|
|
10
|
+
// Core W3C Types
|
|
11
|
+
DesignTokensFile,
|
|
12
|
+
DesignToken,
|
|
13
|
+
TokenGroup,
|
|
14
|
+
AnyToken,
|
|
15
|
+
TokenType,
|
|
16
|
+
TokenReference,
|
|
17
|
+
JsonPointerReference,
|
|
18
|
+
CompositeStringValue,
|
|
19
|
+
ValueOrReference,
|
|
20
|
+
|
|
21
|
+
// Basic Token Types
|
|
22
|
+
ColorToken,
|
|
23
|
+
DimensionToken,
|
|
24
|
+
FontFamilyToken,
|
|
25
|
+
FontWeightToken,
|
|
26
|
+
FontFaceToken,
|
|
27
|
+
FontFaceCollectionToken,
|
|
28
|
+
DurationToken,
|
|
29
|
+
CubicBezierToken,
|
|
30
|
+
NumberToken,
|
|
31
|
+
StringToken,
|
|
32
|
+
|
|
33
|
+
// Composite Token Types
|
|
34
|
+
StrokeStyleToken,
|
|
35
|
+
BorderToken,
|
|
36
|
+
TransitionToken,
|
|
37
|
+
ShadowToken,
|
|
38
|
+
GradientToken,
|
|
39
|
+
TypographyToken,
|
|
40
|
+
|
|
41
|
+
// Value Types
|
|
42
|
+
ColorValue,
|
|
43
|
+
ExtendedColorValue,
|
|
44
|
+
DimensionValue,
|
|
45
|
+
FontFamilyValue,
|
|
46
|
+
FontWeightValue,
|
|
47
|
+
FontFaceValue,
|
|
48
|
+
FontFaceCollectionValue,
|
|
49
|
+
DurationValue,
|
|
50
|
+
CubicBezierValue,
|
|
51
|
+
NumberValue,
|
|
52
|
+
StringValue,
|
|
53
|
+
StrokeStyleValue,
|
|
54
|
+
BorderValue,
|
|
55
|
+
TransitionValue,
|
|
56
|
+
ShadowValue,
|
|
57
|
+
GradientValue,
|
|
58
|
+
TypographyValue,
|
|
59
|
+
|
|
60
|
+
// Extension Types
|
|
61
|
+
ModeExtension,
|
|
62
|
+
GeneratorsExtension,
|
|
63
|
+
BreakpointsExtension,
|
|
64
|
+
EnhancedExtensionData,
|
|
65
|
+
|
|
66
|
+
// Utility Types
|
|
67
|
+
ValidationError,
|
|
68
|
+
ValidationResult,
|
|
69
|
+
ResolutionContext,
|
|
70
|
+
ResolutionResult,
|
|
71
|
+
|
|
72
|
+
// Type Guards and Utilities
|
|
73
|
+
isTokenReference,
|
|
74
|
+
isJsonPointerReference,
|
|
75
|
+
isCompositeStringValue,
|
|
76
|
+
isDesignToken,
|
|
77
|
+
isTokenGroup,
|
|
78
|
+
hasModeExtension,
|
|
79
|
+
hasGeneratorExtension,
|
|
80
|
+
hasBreakpointExtension,
|
|
81
|
+
|
|
82
|
+
// Constants
|
|
83
|
+
DESIGN_TOKENS_MEDIA_TYPE,
|
|
84
|
+
DESIGN_TOKENS_EXTENSIONS
|
|
85
|
+
} from '../src/types/design-tokens.ts';
|
package/types/token.d.ts
CHANGED
|
@@ -1,10 +1,41 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
TokenReference,
|
|
3
|
+
JsonPointerReference,
|
|
4
|
+
CompositeStringValue,
|
|
5
|
+
ValueOrReference,
|
|
6
|
+
TokenType,
|
|
7
|
+
AnyToken
|
|
8
|
+
} from "../src/types/design-tokens.ts";
|
|
9
|
+
|
|
1
10
|
export type TTokenValueOptions = {
|
|
2
11
|
isIncludedOriginalValue?: boolean;
|
|
3
12
|
fallbackValue?: string | number | boolean | null;
|
|
4
13
|
};
|
|
5
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Legacy token reference format (maintained for backward compatibility)
|
|
17
|
+
*/
|
|
6
18
|
export type TTokenReference = `{${string}}`;
|
|
7
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Enhanced token reference supporting W3C specifications
|
|
22
|
+
*/
|
|
23
|
+
export type TEnhancedTokenReference =
|
|
24
|
+
| TTokenReference
|
|
25
|
+
| TokenReference
|
|
26
|
+
| JsonPointerReference
|
|
27
|
+
| CompositeStringValue;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* W3C compliant token types
|
|
31
|
+
*/
|
|
32
|
+
export type TW3CTokenType = TokenType;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* W3C compliant value or reference type
|
|
36
|
+
*/
|
|
37
|
+
export type TW3CValueOrReference<T> = ValueOrReference<T>;
|
|
38
|
+
|
|
8
39
|
export type TTokenBreakpointOptions = {
|
|
9
40
|
target: TTokenBreakpointTarget;
|
|
10
41
|
dimension: "width" | "height";
|
package/types/typography.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type { TTokenBreakpointKey } from "./token.ts";
|
|
2
2
|
import type { TToken } from "./utils.ts";
|
|
3
|
+
import type {
|
|
4
|
+
FontFaceValue,
|
|
5
|
+
FontFaceFormatValue,
|
|
6
|
+
FontFaceStyleValue,
|
|
7
|
+
FontWeightValue
|
|
8
|
+
} from "../src/types/design-tokens.ts";
|
|
3
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Legacy font configuration (maintained for backward compatibility)
|
|
12
|
+
*/
|
|
4
13
|
type TBaseFont = {
|
|
5
14
|
family: string;
|
|
6
15
|
style: string;
|
|
@@ -10,8 +19,50 @@ type TBaseFont = {
|
|
|
10
19
|
format: string;
|
|
11
20
|
}
|
|
12
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Legacy TFont type (maintained for backward compatibility)
|
|
24
|
+
*/
|
|
13
25
|
export type TFont =
|
|
14
26
|
| (TBaseFont & { linkHref: string; src?: never })
|
|
15
27
|
| (TBaseFont & { src: string; linkHref?: never });
|
|
16
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Enhanced font configuration supporting W3C FontFace specification
|
|
31
|
+
* Provides better type safety and validation
|
|
32
|
+
*/
|
|
33
|
+
export type TEnhancedFont = FontFaceValue & {
|
|
34
|
+
/**
|
|
35
|
+
* Additional metadata for enhanced processing
|
|
36
|
+
*/
|
|
37
|
+
metadata?: {
|
|
38
|
+
/**
|
|
39
|
+
* Font display strategy
|
|
40
|
+
*/
|
|
41
|
+
display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
|
|
42
|
+
/**
|
|
43
|
+
* Font loading priority
|
|
44
|
+
*/
|
|
45
|
+
loading?: 'eager' | 'lazy';
|
|
46
|
+
/**
|
|
47
|
+
* Unicode range support
|
|
48
|
+
*/
|
|
49
|
+
unicodeRange?: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* W3C compliant font weight type
|
|
55
|
+
*/
|
|
56
|
+
export type TW3CFontWeight = FontWeightValue;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* W3C compliant font style type
|
|
60
|
+
*/
|
|
61
|
+
export type TW3CFontStyle = FontFaceStyleValue;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* W3C compliant font format type
|
|
65
|
+
*/
|
|
66
|
+
export type TW3CFontFormat = FontFaceFormatValue;
|
|
67
|
+
|
|
17
68
|
export type TTypographyBreakpointMap = Record<TTokenBreakpointKey, TToken>;
|
package/types/utils.d.ts
CHANGED
|
@@ -40,6 +40,55 @@ export type TToken =
|
|
|
40
40
|
};
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Enhanced token type supporting W3C design tokens specification
|
|
45
|
+
* Maintains backward compatibility while adding W3C features
|
|
46
|
+
*/
|
|
47
|
+
export type TEnhancedToken = TToken & {
|
|
48
|
+
/**
|
|
49
|
+
* W3C compliant extensions
|
|
50
|
+
*/
|
|
51
|
+
$extensions?: {
|
|
52
|
+
/**
|
|
53
|
+
* Legacy mode support (backward compatibility)
|
|
54
|
+
*/
|
|
55
|
+
mode?: Record<TTheme, string>;
|
|
56
|
+
/**
|
|
57
|
+
* Legacy generators support (backward compatibility)
|
|
58
|
+
*/
|
|
59
|
+
generators?: {
|
|
60
|
+
type: string;
|
|
61
|
+
value: Record<string, string | number>;
|
|
62
|
+
}[];
|
|
63
|
+
/**
|
|
64
|
+
* Legacy sort support (backward compatibility)
|
|
65
|
+
*/
|
|
66
|
+
sort?: keyof Token['$value'][] | string[];
|
|
67
|
+
/**
|
|
68
|
+
* Legacy breakpoint support (backward compatibility)
|
|
69
|
+
*/
|
|
70
|
+
breakpoint?: {
|
|
71
|
+
[key: string]: Token['$value'];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* W3C mode extension support
|
|
75
|
+
*/
|
|
76
|
+
$mode?: import("../src/types/design-tokens.ts").ModeExtension;
|
|
77
|
+
/**
|
|
78
|
+
* W3C generators extension support
|
|
79
|
+
*/
|
|
80
|
+
$generators?: import("../src/types/design-tokens.ts").GeneratorsExtension;
|
|
81
|
+
/**
|
|
82
|
+
* W3C breakpoints extension support
|
|
83
|
+
*/
|
|
84
|
+
$breakpoints?: import("../src/types/design-tokens.ts").BreakpointsExtension;
|
|
85
|
+
/**
|
|
86
|
+
* Additional vendor-specific extensions
|
|
87
|
+
*/
|
|
88
|
+
[vendorKey: `$${string}`]: unknown;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
43
92
|
export type TCreateModeDictionaryResponse = (TransformedToken & {
|
|
44
93
|
value: TToken["$value"]
|
|
45
94
|
})[];
|
package/bin/build-icons.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{readFileSync as F$,mkdirSync as _$}from"fs";import{writeFile as w$,readdir as C$,mkdir as M$}from"fs/promises";import{resolve as N$,relative as W$,join as h,dirname as R$}from"path";import g$ from"lodash";import h$ from"colorjs.io";var{colorspace:m$}=await Y();var Y$=await K(),j=Y$.default,{tokens:l$}=await Y();import{spawnSync as q$}from"child_process";import{existsSync as E,mkdirSync as X$,readFileSync as Z$,unlinkSync as Q$,writeFileSync as o$}from"fs";import{resolve as e$,join as q,basename as $w,normalize as ww,relative as Ww,sep as Gw,dirname as K$}from"path";var I=process.cwd(),{baseDir:Uw,distDir:Jw}=await Q(),{tokenNamespace:i,dsNamespace:Lw,tokens:Yw}=await Y(),z$=`${i}.icons`;async function E$($){let J=q($,"designid.config.ts");if(console.log("Compiling designid.config.ts with bun...",$),E(q($,"designid.config.js")))console.log("Removing existing designid.config.js file..."),Q$(q($,"designid.config.js"));if(E(J)){let W=q$("bun",["build",J,"--outfile ./designid.config.js","--minify","--target","node","--packages","external"],{stdio:"inherit",cwd:".",shell:!0});if(W.status!==0)console.error("Failed to compile designid.config.js with bun."),process.exit(W.status??1);if(W.status===0)return new Promise((G)=>{setTimeout(()=>{console.log("designid.config.js compiled successfully."),G(!0)},1000)})}}function D($="json"){return`${i}-design-system.tokens.svg${$==="d.ts"||$==="js"?".config":""}.${$}`}function l($){if(!E($))X$($,{recursive:!0})}async function p($,w=!1){let J=f(),W;if(J.endsWith(".json"))W=JSON.parse(Z$(J,"utf8").trim()??"{}");else{$=$??K$(J)+"/";let G=a($);if(G&&(w||!E(G)))await E$($);if(W=await import(G),W.default)W=W.default}return W}async function B(){let{baseDir:$}=await Q(),w=process.cwd(),W=q(w,$),{buildDir:G,distDir:z}=await Q();try{l(q(W,G)),l(q(W,z))}catch(L){console.error("Error creating directories:",L)}return W}function a($){return $?q($,"designid.config.js"):I?q(I,"designid.config.js"):q(process.cwd(),"designid.config.js")}function f(){let $=process.argv.find((H)=>H.startsWith("--config=")),[,w]=$?.split("=")??[];if(w)return w;let J=process.cwd(),W=a(I),G=q(J,"designid.config.ts"),z=E(W),L=E(G);if(z)return W;else if(L)return G;throw console.error("Config file not found"),new Error("Config file not found")}async function Q($=!1){let w=f(),W=(await p(I,$)).$paths;if(!W)throw console.error("Project paths not found"),new Error("Project paths not found");return{configFile:w,...W}}async function Y(){let w=(await p(I)).$metaData;if(!w)throw console.error("Project metaData not found"),new Error("Project metaData not found");if(!w.colorspace)w.colorspace="hex";if(!w.fontNamespace)w.fontNamespace=`${w.dsNamespace}.font`;if(!w?.tokens?.css?.mediaQuery?.match)w={...w??{},tokens:{...w.tokens??{},css:{...w.tokens?.css??{},mediaQuery:{...w.tokens?.css?.mediaQuery??{},match:"[data-theme]"}}}};if(w?.tokens?.css?.mediaQuery&&typeof w.tokens.css.mediaQuery.separateThemeFiles!=="boolean")w.tokens.css.mediaQuery.separateThemeFiles=!1;if(!w.dsNamespace)w.dsNamespace=w.tokenNamespace;return{...w,icons:w.icons??{objectPath:z$},dsNamespace:w.dsNamespace}}async function K(){return(await p(I)).$modes??{default:"light"}}var Zw=await K();var{icons:_}=await Y();function T($){$=$.replace(/<\?xml[^>]*\?>\s*/,""),$=$.replace(/<!DOCTYPE [^>]*>\s*/,"");let w=$.match(/<svg[^>]*>/),J=$.match(/viewBox="([\d\s.]+)"/),[W]=w??[],G=W;if(W&&G){let L=_?.style?.fill,H=/id="[^"]*"/.test(W);if(!G.includes("xmlns="))G=G.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"');if(!H&&L)G=G.replace("<svg",`<svg id="${L}"`);else if(H&&L)G=G.replace(/id="[^"]*"/,`id="${L}"`)}if(J&&W&&G){let L=J[1].split(" ").map(Number),H=L[2],U=L[3],X=_?.size??24,Z=H/U*X;$=$.replace(/height="[\d.]+px?"/,`height="${X}px"`),$=$.replace(/width="[\d.]+px?"/,`width="${Z}px"`);let S=/width="[\d.]+(px)?"/.test(W),N=/height="[\d.]+(px)?"/.test(W);if(!S)G=G.replace("<svg",`<svg width="${Z}px"`);else G=G.replace(/width="[\d.]+(px)?"/,`width="${Z}px"`);if(!N)G=G.replace("<svg",`<svg height="${X}px"`);else G=G.replace(/height="[\d.]+(px)?"/,`height="${X}px"`);$=$.replace(W,G)}if(!$?.match(/data-style="([^"]*)"/)&&_?.style?.type)$=$.replace("<svg ",`<svg data-style="${_.style.type}" `);return $}var Bw=await K();import{join as x}from"path";var{baseDir:Fw,distDir:$$,assets:C}=await Q(),{fontNamespace:_w}=await Y(),M=await B(),Cw=x(M,$$,"css"),Mw=C?.fonts?.sourceDir?x(M,C.fonts.sourceDir):null,V=x("assets","fonts"),e=C?.fonts?.distDir??V,Nw=e===V?x(M,$$,C?.fonts?.distDir??V):x(M,e);var{set:v,get:P$}=g$,{assets:u,buildDir:j$}=await Q(!0),{tokenNamespace:b$,icons:D$}=await Y(),m=await B(),y=h(m,u?.icons?.sourceDir??"icons"),p$="build",f$=u?.icons?.distDir??p$,T$=h(m,f$),V$=h(m,j$,"icons");async function G$($){let w=await C$($,{withFileTypes:!0}),J=await Promise.all(w.map((W)=>{let G=N$($,W.name);return W.isDirectory()?G$(G):G}));return Array.prototype.concat(...J)}async function v$(){if(!u?.icons?.sourceDir){console.error("Skipping icon build: iconsDir is not defined in the project paths.");return}let J=(await G$(y)).filter((H)=>H.endsWith(".svg")).map((H)=>{let U=F$(H,"utf8").replace(/(\s+(?=(?:[^"]*"[^"]*")*[^"]*$))/g," ").trim()??"";U=T(U);let X=W$(y,H).split("/").pop(),Z=(U.match(/name="(.*?)"/)??[])[1]??X?.replace(".svg",""),S=(U.match(/data-style="(.*?)"/)??[])[1],N=(U.match(/description="(.*?)"/)??[])[1],[d]=U.match(/<svg[^>]*>/)??[],[,H$]=d?.match(/width="([\d.]+)(px)?"/)??[],[,U$]=d?.match(/height="([\d.]+)(px)?"/)??[];if(S!=="animated"&&S!=="custom")return{path:H,folder:W$(y,H).split("/").slice(0,-1).concat(Z),file:X,style:S,content:U,name:Z,dimensions:{width:Number(H$),height:Number(U$)},description:N??""};return}).filter((H)=>H!==void 0).reduce((H,U)=>{if(U?.style!=="animated"&&U?.style!=="custom"&&U)v(H,U.folder.join("."),{$type:"icon",$name:U.name,$description:U.description,$style:U.style,$value:U.content,$dimensions:U.dimensions,...P$(H,U.folder.join("."))});return H},{}),W=D$?.objectPath??`${b$}.icons`;Object.keys(J).forEach(async(H)=>{let U=`${V$}/${H}`,X=`${U}/svg.${H}.tokens.json`;await M$(U,{recursive:!0});let Z=v({},`${W}${W?".":""}${H}`,J[H]);await w$(X,JSON.stringify(Z,null,2),{flag:"w",encoding:"utf-8"})});let G=`${T$}/tokens/${D("json")}`,z=R$(G);_$(z,{recursive:!0});let L=v({},W,J);await w$(G,JSON.stringify(L,null,2),{flag:"w",encoding:"utf-8"})}var KW=v$().catch(($)=>{console.error($),process.exit(1)});export{KW as default,v$ as buildIcons};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"io": {
|
|
3
|
-
"border": {
|
|
4
|
-
"thin": {
|
|
5
|
-
"$description": "Thin (default) border composition",
|
|
6
|
-
"default": {
|
|
7
|
-
"$type": "composition",
|
|
8
|
-
"$value": {
|
|
9
|
-
"width": {
|
|
10
|
-
"$type": "dimension",
|
|
11
|
-
"value": "1px"
|
|
12
|
-
},
|
|
13
|
-
"style": {
|
|
14
|
-
"$type": "string",
|
|
15
|
-
"value": "solid"
|
|
16
|
-
},
|
|
17
|
-
"color": {
|
|
18
|
-
"$type": "color",
|
|
19
|
-
"value": "{io.color.brand.primary.n1}",
|
|
20
|
-
"$extensions": {
|
|
21
|
-
"mode": {
|
|
22
|
-
"dark": "red"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"io": {
|
|
3
|
-
"color": {
|
|
4
|
-
"a": {
|
|
5
|
-
"$type": "color",
|
|
6
|
-
"$value": "white",
|
|
7
|
-
"$extensions": {
|
|
8
|
-
"mode": {
|
|
9
|
-
"dark": "purple"
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"brand": {
|
|
14
|
-
"primary": {
|
|
15
|
-
"nDefault": {
|
|
16
|
-
"$description": "Basic example with an hex color value.",
|
|
17
|
-
"$type": "color",
|
|
18
|
-
"$value": "purple",
|
|
19
|
-
"$extensions": {
|
|
20
|
-
"mode": {
|
|
21
|
-
"dark": "green"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"n0": {
|
|
26
|
-
"$description": "Basic example with an hex color value.",
|
|
27
|
-
"$type": "color",
|
|
28
|
-
"$value": "green"
|
|
29
|
-
},
|
|
30
|
-
"n1": {
|
|
31
|
-
"$description": "Basic example with an hex color value.",
|
|
32
|
-
"$type": "color",
|
|
33
|
-
"$value": "#1a73e8",
|
|
34
|
-
"$extensions": {
|
|
35
|
-
"mode": {
|
|
36
|
-
"dark": "blue"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"io": {
|
|
3
|
-
"effect": {
|
|
4
|
-
"shadow": {
|
|
5
|
-
"layer-1": {
|
|
6
|
-
"$description": "Shadow for layer 1 elements.",
|
|
7
|
-
"xs": {
|
|
8
|
-
"$type": "composition",
|
|
9
|
-
"$value": {
|
|
10
|
-
"offsetX": {
|
|
11
|
-
"$type": "dimension",
|
|
12
|
-
"value": "0px"
|
|
13
|
-
},
|
|
14
|
-
"offsetY": {
|
|
15
|
-
"$type": "dimension",
|
|
16
|
-
"value": "1px"
|
|
17
|
-
},
|
|
18
|
-
"blur": {
|
|
19
|
-
"$type": "dimension",
|
|
20
|
-
"value": "2px"
|
|
21
|
-
},
|
|
22
|
-
"spread": {
|
|
23
|
-
"$type": "dimension",
|
|
24
|
-
"value": "0px"
|
|
25
|
-
},
|
|
26
|
-
"color": {
|
|
27
|
-
"$type": "color",
|
|
28
|
-
"value": "{io.color.brand.primary.n1}",
|
|
29
|
-
"$extensions": {
|
|
30
|
-
"mode": {
|
|
31
|
-
"dark": "{io.color.brand.primary.n0}"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"io": {
|
|
3
|
-
"font": {
|
|
4
|
-
"family": {
|
|
5
|
-
"primary": {
|
|
6
|
-
"main": {
|
|
7
|
-
"$type": "string",
|
|
8
|
-
"$value": "Inter"
|
|
9
|
-
},
|
|
10
|
-
"fallback": {
|
|
11
|
-
"$type": "string",
|
|
12
|
-
"$value": "system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif"
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"weight": {
|
|
17
|
-
"primary": {
|
|
18
|
-
"regular": {
|
|
19
|
-
"$type": "number",
|
|
20
|
-
"$value": 400
|
|
21
|
-
},
|
|
22
|
-
"bold": {
|
|
23
|
-
"$type": "number",
|
|
24
|
-
"$value": 700
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"size": {
|
|
29
|
-
"xs": {
|
|
30
|
-
"$type": "number",
|
|
31
|
-
"$value": "0.75rem"
|
|
32
|
-
},
|
|
33
|
-
"sm": {
|
|
34
|
-
"$type": "number",
|
|
35
|
-
"$value": "1rem"
|
|
36
|
-
},
|
|
37
|
-
"md": {
|
|
38
|
-
"$type": "number",
|
|
39
|
-
"$value": "1.25rem"
|
|
40
|
-
},
|
|
41
|
-
"base": {
|
|
42
|
-
"$type": "dimension",
|
|
43
|
-
"$value": "{io.dimensions.tshirt.base}"
|
|
44
|
-
},
|
|
45
|
-
"lg": {
|
|
46
|
-
"$type": "number",
|
|
47
|
-
"$value": "1.5rem"
|
|
48
|
-
},
|
|
49
|
-
"xl": {
|
|
50
|
-
"$type": "number",
|
|
51
|
-
"$value": "1.75rem"
|
|
52
|
-
},
|
|
53
|
-
"2xl": {
|
|
54
|
-
"$type": "number",
|
|
55
|
-
"$value": "2rem"
|
|
56
|
-
},
|
|
57
|
-
"3xl": {
|
|
58
|
-
"$type": "number",
|
|
59
|
-
"$value": "2.25rem"
|
|
60
|
-
},
|
|
61
|
-
"4xl": {
|
|
62
|
-
"$type": "number",
|
|
63
|
-
"$value": "2.5rem"
|
|
64
|
-
},
|
|
65
|
-
"5xl": {
|
|
66
|
-
"$type": "number",
|
|
67
|
-
"$value": "3rem"
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
"lineHeight": {
|
|
71
|
-
"xs": {
|
|
72
|
-
"$type": "number",
|
|
73
|
-
"$value": "1.25rem"
|
|
74
|
-
},
|
|
75
|
-
"sm": {
|
|
76
|
-
"$type": "number",
|
|
77
|
-
"$value": "1.5rem"
|
|
78
|
-
},
|
|
79
|
-
"md": {
|
|
80
|
-
"$type": "number",
|
|
81
|
-
"$value": "1.75rem"
|
|
82
|
-
},
|
|
83
|
-
"base": {
|
|
84
|
-
"$type": "dimension",
|
|
85
|
-
"$value": "{io.dimensions.tshirt.base}"
|
|
86
|
-
},
|
|
87
|
-
"lg": {
|
|
88
|
-
"$type": "number",
|
|
89
|
-
"$value": "2rem"
|
|
90
|
-
},
|
|
91
|
-
"xl": {
|
|
92
|
-
"$type": "number",
|
|
93
|
-
"$value": "2.25rem"
|
|
94
|
-
},
|
|
95
|
-
"2xl": {
|
|
96
|
-
"$type": "number",
|
|
97
|
-
"$value": "2.5rem"
|
|
98
|
-
},
|
|
99
|
-
"3xl": {
|
|
100
|
-
"$type": "number",
|
|
101
|
-
"$value": "3rem"
|
|
102
|
-
},
|
|
103
|
-
"4xl": {
|
|
104
|
-
"$type": "number",
|
|
105
|
-
"$value": "3.5rem"
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|