@sxl-studio/token-transformer 1.0.0 → 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/README.en.md +77 -608
- package/README.md +77 -685
- package/config/sxl-transform.config.yaml +120 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +411 -141
- package/dist/cli.js.map +1 -1
- package/dist/config/loader.d.ts +6 -0
- package/dist/config/loader.js +160 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +847 -0
- package/dist/config/schema.js +123 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/core/color-modifiers.d.ts +31 -0
- package/dist/core/color-modifiers.js +289 -0
- package/dist/core/color-modifiers.js.map +1 -0
- package/dist/core/color-parser.d.ts +24 -0
- package/dist/core/color-parser.js +281 -0
- package/dist/core/color-parser.js.map +1 -0
- package/dist/core/debug-report.d.ts +11 -0
- package/dist/core/debug-report.js +161 -0
- package/dist/core/debug-report.js.map +1 -0
- package/dist/core/incremental.d.ts +18 -0
- package/dist/core/incremental.js +105 -0
- package/dist/core/incremental.js.map +1 -0
- package/dist/core/math.d.ts +3 -0
- package/dist/core/math.js +261 -0
- package/dist/core/math.js.map +1 -0
- package/dist/core/parser.d.ts +4 -3
- package/dist/core/parser.js +68 -172
- package/dist/core/parser.js.map +1 -1
- package/dist/core/resolver.d.ts +26 -0
- package/dist/core/resolver.js +431 -0
- package/dist/core/resolver.js.map +1 -0
- package/dist/core/token-loader.d.ts +11 -0
- package/dist/core/token-loader.js +380 -0
- package/dist/core/token-loader.js.map +1 -0
- package/dist/core/token-parser.d.ts +9 -0
- package/dist/core/token-parser.js +138 -0
- package/dist/core/token-parser.js.map +1 -0
- package/dist/core/token-types.d.ts +7 -0
- package/dist/core/token-types.js +132 -0
- package/dist/core/token-types.js.map +1 -0
- package/dist/core/types.d.ts +154 -63
- package/dist/core/writer.d.ts +18 -5
- package/dist/core/writer.js +545 -91
- package/dist/core/writer.js.map +1 -1
- package/dist/emit/css.d.ts +2 -0
- package/dist/emit/css.js +538 -0
- package/dist/emit/css.js.map +1 -0
- package/dist/emit/kotlin.d.ts +2 -0
- package/dist/emit/kotlin.js +406 -0
- package/dist/emit/kotlin.js.map +1 -0
- package/dist/emit/shared.d.ts +13 -0
- package/dist/emit/shared.js +127 -0
- package/dist/emit/shared.js.map +1 -0
- package/dist/emit/swift.d.ts +2 -0
- package/dist/emit/swift.js +432 -0
- package/dist/emit/swift.js.map +1 -0
- package/dist/emit/typography.d.ts +17 -0
- package/dist/emit/typography.js +132 -0
- package/dist/emit/typography.js.map +1 -0
- package/dist/emit/xml.d.ts +2 -0
- package/dist/emit/xml.js +311 -0
- package/dist/emit/xml.js.map +1 -0
- package/dist/index.d.ts +15 -6
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/dist/transformers/css.d.ts +1 -1
- package/dist/transformers/css.js +13 -482
- package/dist/transformers/css.js.map +1 -1
- package/dist/transformers/kotlin.d.ts +2 -2
- package/dist/transformers/kotlin.js +14 -442
- package/dist/transformers/kotlin.js.map +1 -1
- package/dist/transformers/swiftui.d.ts +2 -2
- package/dist/transformers/swiftui.js +14 -433
- package/dist/transformers/swiftui.js.map +1 -1
- package/dist/utils/color.d.ts +7 -5
- package/dist/utils/color.js +90 -86
- package/dist/utils/color.js.map +1 -1
- package/dist/utils/dimension.d.ts +8 -5
- package/dist/utils/dimension.js +54 -52
- package/dist/utils/dimension.js.map +1 -1
- package/dist/utils/naming.d.ts +10 -12
- package/dist/utils/naming.js +102 -44
- package/dist/utils/naming.js.map +1 -1
- package/package.json +30 -10
- package/config.example.json +0 -45
- package/dist/core/loader.d.ts +0 -8
- package/dist/core/loader.js +0 -105
- package/dist/core/loader.js.map +0 -1
- package/dist/transformers/vue3.d.ts +0 -28
- package/dist/transformers/vue3.js +0 -534
- package/dist/transformers/vue3.js.map +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
const LEGACY_TYPE_ALIASES = {
|
|
2
|
+
fontFamilies: "fontFamily",
|
|
3
|
+
fontWeights: "fontWeight",
|
|
4
|
+
fontStyles: "fontStyle",
|
|
5
|
+
fontSizes: "fontSize",
|
|
6
|
+
lineHeights: "lineHeight",
|
|
7
|
+
letterSpacings: "letterSpacing",
|
|
8
|
+
paragraphSpacings: "paragraphSpacing",
|
|
9
|
+
paragraphIndents: "paragraphIndent",
|
|
10
|
+
borderRadii: "borderRadius",
|
|
11
|
+
textCases: "textCase",
|
|
12
|
+
textDecorations: "textDecoration",
|
|
13
|
+
size: "sizing",
|
|
14
|
+
space: "spacing",
|
|
15
|
+
string: "text",
|
|
16
|
+
backdropBlur: "backdrop-blur",
|
|
17
|
+
backgroundBlur: "backdrop-blur",
|
|
18
|
+
"background-blur": "backdrop-blur",
|
|
19
|
+
layerBlur: "blur",
|
|
20
|
+
boxShadow: "shadow",
|
|
21
|
+
};
|
|
22
|
+
export const SIMPLE_TOKEN_TYPES = new Set([
|
|
23
|
+
"color",
|
|
24
|
+
"dimension",
|
|
25
|
+
"sizing",
|
|
26
|
+
"spacing",
|
|
27
|
+
"borderRadius",
|
|
28
|
+
"borderWidth",
|
|
29
|
+
"opacity",
|
|
30
|
+
"number",
|
|
31
|
+
"fontFamily",
|
|
32
|
+
"fontWeight",
|
|
33
|
+
"fontStyle",
|
|
34
|
+
"fontSize",
|
|
35
|
+
"lineHeight",
|
|
36
|
+
"letterSpacing",
|
|
37
|
+
"paragraphSpacing",
|
|
38
|
+
"paragraphIndent",
|
|
39
|
+
"textCase",
|
|
40
|
+
"textDecoration",
|
|
41
|
+
"boolean",
|
|
42
|
+
"text",
|
|
43
|
+
"duration",
|
|
44
|
+
"cubicBezier",
|
|
45
|
+
"strokeStyle",
|
|
46
|
+
]);
|
|
47
|
+
export const COMPOSITE_TOKEN_TYPES = new Set([
|
|
48
|
+
"typography",
|
|
49
|
+
"shadow",
|
|
50
|
+
"border",
|
|
51
|
+
"fill",
|
|
52
|
+
"gradient",
|
|
53
|
+
"effects",
|
|
54
|
+
"blur",
|
|
55
|
+
"backdrop-blur",
|
|
56
|
+
"glass",
|
|
57
|
+
"grid",
|
|
58
|
+
"transition",
|
|
59
|
+
"template",
|
|
60
|
+
"composition",
|
|
61
|
+
]);
|
|
62
|
+
const CANONICAL = new Set([...SIMPLE_TOKEN_TYPES, ...COMPOSITE_TOKEN_TYPES]);
|
|
63
|
+
const EXTRA_ALIASES = {
|
|
64
|
+
color: "color",
|
|
65
|
+
gradient: "gradient",
|
|
66
|
+
img: "img",
|
|
67
|
+
fill: "fill",
|
|
68
|
+
dimension: "dimension",
|
|
69
|
+
number: "number",
|
|
70
|
+
spacing: "spacing",
|
|
71
|
+
sizing: "sizing",
|
|
72
|
+
border: "border",
|
|
73
|
+
borderWidth: "borderWidth",
|
|
74
|
+
borderRadius: "borderRadius",
|
|
75
|
+
strokeStyle: "strokeStyle",
|
|
76
|
+
shadow: "shadow",
|
|
77
|
+
blur: "blur",
|
|
78
|
+
glass: "glass",
|
|
79
|
+
effects: "effects",
|
|
80
|
+
typography: "typography",
|
|
81
|
+
fontFamily: "fontFamily",
|
|
82
|
+
fontWeight: "fontWeight",
|
|
83
|
+
fontStyle: "fontStyle",
|
|
84
|
+
fontSize: "fontSize",
|
|
85
|
+
lineHeight: "lineHeight",
|
|
86
|
+
letterSpacing: "letterSpacing",
|
|
87
|
+
paragraphSpacing: "paragraphSpacing",
|
|
88
|
+
paragraphIndent: "paragraphIndent",
|
|
89
|
+
textCase: "textCase",
|
|
90
|
+
textDecoration: "textDecoration",
|
|
91
|
+
text: "text",
|
|
92
|
+
opacity: "opacity",
|
|
93
|
+
duration: "duration",
|
|
94
|
+
cubicBezier: "cubicBezier",
|
|
95
|
+
transition: "transition",
|
|
96
|
+
grid: "grid",
|
|
97
|
+
boolean: "boolean",
|
|
98
|
+
template: "template",
|
|
99
|
+
composition: "composition",
|
|
100
|
+
};
|
|
101
|
+
const ALIAS_MAP = buildAliasMap();
|
|
102
|
+
function buildAliasMap() {
|
|
103
|
+
const map = { ...LEGACY_TYPE_ALIASES };
|
|
104
|
+
for (const [alias, canonical] of Object.entries(EXTRA_ALIASES)) {
|
|
105
|
+
map[alias] = canonical;
|
|
106
|
+
}
|
|
107
|
+
for (const canonical of CANONICAL) {
|
|
108
|
+
map[canonical] = canonical;
|
|
109
|
+
}
|
|
110
|
+
return map;
|
|
111
|
+
}
|
|
112
|
+
export function normalizeTokenTypeKey(raw) {
|
|
113
|
+
const value = raw.trim();
|
|
114
|
+
if (!value)
|
|
115
|
+
return value;
|
|
116
|
+
return ALIAS_MAP[value] ?? value;
|
|
117
|
+
}
|
|
118
|
+
export function isSimpleType(type) {
|
|
119
|
+
return SIMPLE_TOKEN_TYPES.has(normalizeTokenTypeKey(type));
|
|
120
|
+
}
|
|
121
|
+
export function isCompositeType(type) {
|
|
122
|
+
return COMPOSITE_TOKEN_TYPES.has(normalizeTokenTypeKey(type));
|
|
123
|
+
}
|
|
124
|
+
export function isTokenType(type) {
|
|
125
|
+
const normalized = normalizeTokenTypeKey(type);
|
|
126
|
+
return SIMPLE_TOKEN_TYPES.has(normalized) || COMPOSITE_TOKEN_TYPES.has(normalized);
|
|
127
|
+
}
|
|
128
|
+
export function shouldSkipByType(type) {
|
|
129
|
+
const normalized = normalizeTokenTypeKey(type);
|
|
130
|
+
return normalized === "template" || normalized === "composition";
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=token-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-types.js","sourceRoot":"","sources":["../../src/core/token-types.ts"],"names":[],"mappings":"AAAA,MAAM,mBAAmB,GAA2B;IAClD,YAAY,EAAE,YAAY;IAC1B,WAAW,EAAE,YAAY;IACzB,UAAU,EAAE,WAAW;IACvB,SAAS,EAAE,UAAU;IACrB,WAAW,EAAE,YAAY;IACzB,cAAc,EAAE,eAAe;IAC/B,iBAAiB,EAAE,kBAAkB;IACrC,gBAAgB,EAAE,iBAAiB;IACnC,WAAW,EAAE,c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AAI,KAAK,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,kBAAkB,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,qBAAqB,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,MAAM,UAAU,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC/C,OAAO,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,qBAAqB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AACrF,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,UAAU,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC/C,OAAO,UAAU,KAAK,UAAU,IAAI,UAAU,KAAK,aAAa,CAAC;AACnE,CAAC"}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -1,83 +1,174 @@
|
|
|
1
|
-
|
|
2
|
-
export type
|
|
3
|
-
export type
|
|
4
|
-
export type
|
|
1
|
+
import type { CollisionStrategy, OptionsConfig, OutputConfig, OutputFileConfig, Platform, SplitBySourceFileConfig, SourceConfig, TokenFilterConfig, TokenSetConfig, TokenSetSelectorConfig, TransformerConfig, UnresolvedAliasAction, UnsupportedTypeAction } from "../config/schema.js";
|
|
2
|
+
export type { CollisionStrategy, OptionsConfig, OutputConfig, OutputFileConfig, Platform, SplitBySourceFileConfig, SourceConfig, TokenFilterConfig, TokenSetConfig, TokenSetSelectorConfig, TransformerConfig, UnresolvedAliasAction, UnsupportedTypeAction, };
|
|
3
|
+
export type ColorModifyType = "lighten" | "darken" | "alpha" | "mix";
|
|
4
|
+
export type ColorSpace = "srgb" | "hsl" | "lch" | "oklch" | "p3";
|
|
5
|
+
export type FigmaModify = {
|
|
6
|
+
type: ColorModifyType;
|
|
7
|
+
value: number | string;
|
|
8
|
+
space: ColorSpace;
|
|
9
|
+
color?: string;
|
|
10
|
+
};
|
|
11
|
+
export type FigmaCodeSyntax = {
|
|
12
|
+
Web?: string;
|
|
13
|
+
Android?: string;
|
|
14
|
+
iOS?: string;
|
|
15
|
+
};
|
|
16
|
+
export type TokenExtensions = {
|
|
17
|
+
"figma.scopes"?: string[];
|
|
18
|
+
"figma.codeSyntax"?: FigmaCodeSyntax;
|
|
19
|
+
"figma.hide"?: boolean;
|
|
20
|
+
"figma.modify"?: FigmaModify | FigmaModify[];
|
|
21
|
+
};
|
|
5
22
|
export type FlatToken = {
|
|
6
23
|
path: string;
|
|
7
|
-
|
|
8
|
-
type: TokenType | string;
|
|
24
|
+
type: string;
|
|
9
25
|
value: unknown;
|
|
10
26
|
resolvedValue?: unknown;
|
|
27
|
+
description?: string;
|
|
28
|
+
extensions?: TokenExtensions;
|
|
29
|
+
id?: string;
|
|
11
30
|
isAlias: boolean;
|
|
12
31
|
aliasPath?: string;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
32
|
+
sourceFile: string;
|
|
33
|
+
sourceCollection?: string;
|
|
34
|
+
sourceMode?: string;
|
|
35
|
+
};
|
|
36
|
+
export type CollectionConfig = {
|
|
37
|
+
name: string;
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
modes: ModeConfig[];
|
|
40
|
+
ref?: RefRuleConfig[];
|
|
41
|
+
};
|
|
42
|
+
export type ModeConfig = {
|
|
43
|
+
name: string;
|
|
44
|
+
enabled: boolean;
|
|
45
|
+
files: Record<string, string>;
|
|
46
|
+
ref?: RefRuleConfig[];
|
|
16
47
|
};
|
|
17
|
-
export type
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
48
|
+
export type RefRuleConfig = {
|
|
49
|
+
type: string;
|
|
50
|
+
collection: string;
|
|
51
|
+
mode?: string;
|
|
21
52
|
};
|
|
22
|
-
export type
|
|
53
|
+
export type TokensProjectConfig = {
|
|
54
|
+
settings?: {
|
|
55
|
+
remBase?: number;
|
|
56
|
+
};
|
|
57
|
+
collections?: CollectionConfig[];
|
|
58
|
+
};
|
|
59
|
+
export type ResolvedSourceConfig = {
|
|
23
60
|
tokenDir: string;
|
|
24
|
-
configFile
|
|
25
|
-
include
|
|
26
|
-
exclude
|
|
61
|
+
configFile: string;
|
|
62
|
+
include: string[];
|
|
63
|
+
exclude: string[];
|
|
27
64
|
};
|
|
28
|
-
export type
|
|
65
|
+
export type ResolvedOutputConfig = Omit<OutputConfig, "outputDir"> & {
|
|
29
66
|
outputDir: string;
|
|
30
|
-
fileMapping?: FileMapping[];
|
|
31
|
-
prefix?: string;
|
|
32
|
-
codeSyntax?: CodeSyntaxConfig;
|
|
33
|
-
resolveAliases?: boolean;
|
|
34
|
-
splitEffects?: boolean;
|
|
35
|
-
showDescriptions?: boolean;
|
|
36
|
-
options?: Record<string, unknown>;
|
|
37
|
-
};
|
|
38
|
-
export type FileMapping = {
|
|
39
|
-
sources: string[];
|
|
40
|
-
output: string;
|
|
41
|
-
filter?: TokenFilter;
|
|
42
|
-
};
|
|
43
|
-
export type TokenFilter = {
|
|
44
|
-
types?: string[];
|
|
45
|
-
paths?: string[];
|
|
46
|
-
excludePaths?: string[];
|
|
47
|
-
};
|
|
48
|
-
export type CodeSyntaxConfig = {
|
|
49
|
-
variableTemplate?: string;
|
|
50
|
-
colorFormat?: "hex" | "rgb" | "rgba" | "hsl";
|
|
51
|
-
dimensionUnit?: string;
|
|
52
|
-
prefix?: string;
|
|
53
|
-
};
|
|
54
|
-
export type GlobalSettings = {
|
|
55
|
-
remBase?: number;
|
|
56
|
-
colorFormat?: "hex" | "rgb" | "rgba" | "hsl";
|
|
57
|
-
verbose?: boolean;
|
|
58
67
|
};
|
|
59
|
-
export type
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
tokenCount: number;
|
|
63
|
-
errors: string[];
|
|
68
|
+
export type ResolvedTransformerConfig = Omit<TransformerConfig, "source" | "outputs"> & {
|
|
69
|
+
source: ResolvedSourceConfig;
|
|
70
|
+
outputs: ResolvedOutputConfig[];
|
|
64
71
|
};
|
|
65
72
|
export type OutputFile = {
|
|
66
73
|
path: string;
|
|
67
74
|
content: string;
|
|
68
75
|
tokenCount: number;
|
|
76
|
+
outputId?: string;
|
|
77
|
+
tokenSetId?: string;
|
|
78
|
+
sourceFiles?: string[];
|
|
69
79
|
};
|
|
70
|
-
export type
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}[];
|
|
80
|
+
export type DiagnosticsLevel = "info" | "warn" | "error";
|
|
81
|
+
export type Diagnostic = {
|
|
82
|
+
level: DiagnosticsLevel;
|
|
83
|
+
message: string;
|
|
84
|
+
code?: string;
|
|
85
|
+
tokenPath?: string;
|
|
86
|
+
outputId?: string;
|
|
78
87
|
};
|
|
79
|
-
export type
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
export type TransformResult = {
|
|
89
|
+
files: OutputFile[];
|
|
90
|
+
diagnostics: Diagnostic[];
|
|
91
|
+
removedFiles?: string[];
|
|
92
|
+
};
|
|
93
|
+
export type SelectorResolvedFiles = {
|
|
94
|
+
selector: TokenSetSelectorConfig;
|
|
95
|
+
files: string[];
|
|
96
|
+
resolverFiles: string[];
|
|
97
|
+
};
|
|
98
|
+
export type TokenSetResolved = {
|
|
99
|
+
id: string;
|
|
100
|
+
unresolvedAliases: UnresolvedAliasAction;
|
|
101
|
+
tokens: FlatToken[];
|
|
102
|
+
resolverTokens: FlatToken[];
|
|
103
|
+
selectors: SelectorResolvedFiles[];
|
|
104
|
+
};
|
|
105
|
+
export type SourceFileFingerprint = {
|
|
106
|
+
size: number;
|
|
107
|
+
mtimeMs: number;
|
|
108
|
+
};
|
|
109
|
+
export type SmartOutputState = {
|
|
110
|
+
path: string;
|
|
111
|
+
outputId: string;
|
|
112
|
+
tokenSetId?: string;
|
|
113
|
+
contentHash: string;
|
|
114
|
+
sourceFiles: string[];
|
|
115
|
+
};
|
|
116
|
+
export type SmartTransformState = {
|
|
117
|
+
version: 1;
|
|
118
|
+
configHash: string;
|
|
119
|
+
generatedAt: string;
|
|
120
|
+
sourceFiles: Record<string, SourceFileFingerprint>;
|
|
121
|
+
outputs: Record<string, SmartOutputState>;
|
|
122
|
+
};
|
|
123
|
+
export type SmartTransformMode = "smart" | "force";
|
|
124
|
+
export type SmartTransformMeta = {
|
|
125
|
+
mode: SmartTransformMode;
|
|
126
|
+
fullRebuild: boolean;
|
|
127
|
+
reason: string;
|
|
128
|
+
changedSourceFiles: string[];
|
|
129
|
+
removedSourceFiles: string[];
|
|
130
|
+
affectedTokenSets: string[];
|
|
131
|
+
affectedOutputIds: string[];
|
|
132
|
+
skippedOutputCount: number;
|
|
133
|
+
};
|
|
134
|
+
export type NameCollision = {
|
|
135
|
+
requested: string;
|
|
136
|
+
resolved: string;
|
|
137
|
+
tokenPath: string;
|
|
138
|
+
strategy: CollisionStrategy;
|
|
139
|
+
};
|
|
140
|
+
export type AliasResolutionContext = {
|
|
141
|
+
remBase: number;
|
|
142
|
+
maxDepth: number;
|
|
143
|
+
};
|
|
144
|
+
export type UnsupportedTypeResolution = {
|
|
145
|
+
action: UnsupportedTypeAction;
|
|
146
|
+
type: string;
|
|
147
|
+
};
|
|
148
|
+
export type EmitterInput = {
|
|
149
|
+
tokens: FlatToken[];
|
|
150
|
+
platform: Platform;
|
|
151
|
+
prefix?: string;
|
|
152
|
+
resolveAliases: boolean;
|
|
153
|
+
splitEffects: boolean;
|
|
154
|
+
showDescriptions: boolean;
|
|
155
|
+
collisions: CollisionStrategy;
|
|
156
|
+
outputId: string;
|
|
157
|
+
remBase?: number;
|
|
158
|
+
};
|
|
159
|
+
export type PlatformConfig = {
|
|
160
|
+
outputDir: string;
|
|
161
|
+
prefix?: string;
|
|
162
|
+
resolveAliases?: boolean;
|
|
163
|
+
splitEffects?: boolean;
|
|
164
|
+
showDescriptions?: boolean;
|
|
165
|
+
};
|
|
166
|
+
export type EmitResult = {
|
|
167
|
+
content: string;
|
|
168
|
+
diagnostics: Diagnostic[];
|
|
169
|
+
extraFiles?: {
|
|
170
|
+
relativePath: string;
|
|
171
|
+
content: string;
|
|
172
|
+
tokenCount?: number;
|
|
173
|
+
}[];
|
|
83
174
|
};
|
package/dist/core/writer.d.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { Diagnostic, OutputFile, ResolvedTransformerConfig, SmartTransformMeta, SmartTransformMode, SmartTransformState, TokenSetResolved, TransformResult } from "./types.js";
|
|
2
|
+
export type RunTransformResult = TransformResult & {
|
|
3
|
+
tokenSets: TokenSetResolved[];
|
|
4
|
+
state: SmartTransformState;
|
|
5
|
+
meta: SmartTransformMeta;
|
|
6
|
+
};
|
|
7
|
+
export type RunTransformOptions = {
|
|
8
|
+
autoFixAliasSyntax?: boolean;
|
|
9
|
+
skipTokensWithIssues?: boolean;
|
|
10
|
+
mode?: SmartTransformMode;
|
|
11
|
+
previousState?: SmartTransformState | null;
|
|
12
|
+
configHash?: string;
|
|
6
13
|
};
|
|
14
|
+
export declare function runTransform(config: ResolvedTransformerConfig, runOptions?: RunTransformOptions): Promise<RunTransformResult>;
|
|
15
|
+
export declare function writeOutputFiles(files: OutputFile[], removedFiles?: string[]): Promise<{
|
|
16
|
+
written: number;
|
|
17
|
+
removed: number;
|
|
18
|
+
diagnostics: Diagnostic[];
|
|
19
|
+
}>;
|