igniteui-theming 25.1.0 → 25.2.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.
Files changed (128) hide show
  1. package/dist/index.d.ts +75 -0
  2. package/dist/index.js +12 -0
  3. package/dist/json/components/bootstrap.json +1 -0
  4. package/dist/json/components/fluent.json +1 -0
  5. package/dist/json/components/indigo.json +1 -0
  6. package/dist/json/components/material.json +1 -0
  7. package/{json → dist/json}/components/themes.json +31 -1
  8. package/dist/mcp/generators/css.d.ts +7 -4
  9. package/dist/mcp/generators/css.js +129 -104
  10. package/dist/mcp/generators/sass.js +227 -254
  11. package/dist/mcp/index.js +259 -323
  12. package/dist/mcp/knowledge/color-usage.js +524 -502
  13. package/dist/mcp/knowledge/colors.js +61 -50
  14. package/dist/mcp/knowledge/component-metadata.js +697 -598
  15. package/dist/mcp/knowledge/component-themes.js +70 -57
  16. package/dist/mcp/knowledge/custom-palettes.js +4 -9
  17. package/dist/mcp/knowledge/docs/colors/guidance.js +4 -0
  18. package/dist/mcp/knowledge/docs/colors/usage.js +4 -0
  19. package/dist/mcp/knowledge/docs/layout/functions/border-radius.js +4 -0
  20. package/dist/mcp/knowledge/docs/layout/functions/pad.js +4 -0
  21. package/dist/mcp/knowledge/docs/layout/functions/sizable.js +4 -0
  22. package/dist/mcp/knowledge/docs/layout/mixins/sizable.js +4 -0
  23. package/dist/mcp/knowledge/docs/layout/mixins/sizing.js +4 -0
  24. package/dist/mcp/knowledge/docs/layout/mixins/spacing.js +4 -0
  25. package/dist/mcp/knowledge/docs/layout/overview.js +4 -0
  26. package/dist/mcp/knowledge/docs/setup/platform.js +4 -0
  27. package/dist/mcp/knowledge/elevations.d.ts +1 -1
  28. package/dist/mcp/knowledge/elevations.js +26 -12
  29. package/dist/mcp/knowledge/index.js +23 -87
  30. package/dist/mcp/knowledge/layout-docs.d.ts +1 -1
  31. package/dist/mcp/knowledge/multipliers.js +5 -0
  32. package/dist/mcp/knowledge/palettes.js +29 -17
  33. package/dist/mcp/knowledge/platforms/angular.js +98 -120
  34. package/dist/mcp/knowledge/platforms/blazor.js +39 -34
  35. package/dist/mcp/knowledge/platforms/common.js +83 -68
  36. package/dist/mcp/knowledge/platforms/index.js +265 -242
  37. package/dist/mcp/knowledge/platforms/react.js +43 -35
  38. package/dist/mcp/knowledge/platforms/webcomponents.js +266 -292
  39. package/dist/mcp/knowledge/sass-api.js +1 -0
  40. package/dist/mcp/knowledge/typography.js +13 -5
  41. package/dist/mcp/resources/index.js +1 -0
  42. package/dist/mcp/resources/presets.js +409 -508
  43. package/dist/mcp/theming/dist/json/colors/meta/multipliers.js +50 -0
  44. package/dist/mcp/theming/dist/json/colors/presets/palettes.js +85 -0
  45. package/dist/mcp/theming/dist/json/components/themes.js +5792 -0
  46. package/dist/mcp/theming/dist/json/elevations/indigo.js +29 -0
  47. package/dist/mcp/theming/dist/json/elevations/material.js +3 -0
  48. package/dist/mcp/theming/dist/json/typography/presets/typescales.js +621 -0
  49. package/dist/mcp/tools/descriptions.js +98 -154
  50. package/dist/mcp/tools/handlers/color.js +58 -56
  51. package/dist/mcp/tools/handlers/component-theme.js +163 -225
  52. package/dist/mcp/tools/handlers/component-tokens.js +159 -219
  53. package/dist/mcp/tools/handlers/custom-palette.js +138 -179
  54. package/dist/mcp/tools/handlers/elevations.js +27 -28
  55. package/dist/mcp/tools/handlers/index.js +11 -0
  56. package/dist/mcp/tools/handlers/layout.js +125 -176
  57. package/dist/mcp/tools/handlers/palette.js +105 -120
  58. package/dist/mcp/tools/handlers/platform.js +289 -311
  59. package/dist/mcp/tools/handlers/resource.js +22 -31
  60. package/dist/mcp/tools/handlers/theme.js +86 -103
  61. package/dist/mcp/tools/handlers/typography.js +29 -30
  62. package/dist/mcp/tools/index.js +13 -0
  63. package/dist/mcp/tools/schemas.js +239 -218
  64. package/dist/mcp/utils/color.js +277 -239
  65. package/dist/mcp/utils/preprocessing.js +57 -30
  66. package/dist/mcp/utils/result.js +43 -45
  67. package/dist/mcp/utils/sass.js +271 -191
  68. package/dist/mcp/utils/theming-resolve.d.ts +19 -0
  69. package/dist/mcp/utils/theming-resolve.js +57 -0
  70. package/dist/mcp/utils/types.js +96 -53
  71. package/dist/mcp/validators/custom-palette.js +218 -243
  72. package/dist/mcp/validators/index.js +3 -0
  73. package/dist/mcp/validators/palette.js +231 -229
  74. package/dist/tailwind/utilities/bootstrap.css +1 -0
  75. package/dist/tailwind/utilities/fluent.css +1 -0
  76. package/dist/tailwind/utilities/indigo.css +1 -0
  77. package/dist/tailwind/utilities/material.css +1 -0
  78. package/package.json +45 -64
  79. package/sass/json/README.md +12 -7
  80. package/sass/themes/_mixins.scss +1 -0
  81. package/sass/themes/components/button-group/_button-group-theme.scss +42 -0
  82. package/sass/themes/components/grid/_grid-theme.scss +1 -1
  83. package/sass/themes/schemas/components/dark/_button-group.scss +173 -50
  84. package/sass/themes/schemas/components/dark/_grid.scss +0 -16
  85. package/sass/themes/schemas/components/light/_button-group.scss +221 -99
  86. package/sass/themes/schemas/components/light/_grid.scss +14 -20
  87. package/LICENSE +0 -21
  88. package/README.md +0 -391
  89. package/dist/mcp/json/colors/presets/palettes.json.js +0 -13
  90. package/dist/mcp/json/components/themes.json.js +0 -143
  91. package/dist/mcp/json/elevations/indigo.json.js +0 -8
  92. package/dist/mcp/json/elevations/material.json.js +0 -8
  93. package/dist/mcp/json/typography/presets/typescales.json.js +0 -17
  94. package/dist/mcp/knowledge/docs/colors/guidance.md.js +0 -4
  95. package/dist/mcp/knowledge/docs/colors/usage.md.js +0 -4
  96. package/dist/mcp/knowledge/docs/layout/functions/border-radius.md.js +0 -4
  97. package/dist/mcp/knowledge/docs/layout/functions/pad.md.js +0 -4
  98. package/dist/mcp/knowledge/docs/layout/functions/sizable.md.js +0 -4
  99. package/dist/mcp/knowledge/docs/layout/mixins/sizable.md.js +0 -4
  100. package/dist/mcp/knowledge/docs/layout/mixins/sizing.md.js +0 -4
  101. package/dist/mcp/knowledge/docs/layout/mixins/spacing.md.js +0 -4
  102. package/dist/mcp/knowledge/docs/layout/overview.md.js +0 -4
  103. package/dist/mcp/knowledge/docs/setup/platform.md.js +0 -4
  104. package/dist/mcp/vite-env.d.ts +0 -18
  105. package/index.js +0 -5
  106. package/json/components/bootstrap.json +0 -1
  107. package/json/components/fluent.json +0 -1
  108. package/json/components/indigo.json +0 -1
  109. package/json/components/material.json +0 -1
  110. package/tailwind/utilities/bootstrap.css +0 -1
  111. package/tailwind/utilities/fluent.css +0 -1
  112. package/tailwind/utilities/indigo.css +0 -1
  113. package/tailwind/utilities/material.css +0 -1
  114. /package/{json → dist/json}/colors/meta/multipliers.json +0 -0
  115. /package/{json → dist/json}/colors/meta/palette.json +0 -0
  116. /package/{json → dist/json}/colors/presets/palettes.json +0 -0
  117. /package/{json → dist/json}/elevations/indigo.json +0 -0
  118. /package/{json → dist/json}/elevations/material.json +0 -0
  119. /package/{json → dist/json}/typography/presets/typescales.json +0 -0
  120. /package/{tailwind → dist/tailwind}/themes/base.css +0 -0
  121. /package/{tailwind → dist/tailwind}/themes/dark/bootstrap.css +0 -0
  122. /package/{tailwind → dist/tailwind}/themes/dark/fluent.css +0 -0
  123. /package/{tailwind → dist/tailwind}/themes/dark/indigo.css +0 -0
  124. /package/{tailwind → dist/tailwind}/themes/dark/material.css +0 -0
  125. /package/{tailwind → dist/tailwind}/themes/light/bootstrap.css +0 -0
  126. /package/{tailwind → dist/tailwind}/themes/light/fluent.css +0 -0
  127. /package/{tailwind → dist/tailwind}/themes/light/indigo.css +0 -0
  128. /package/{tailwind → dist/tailwind}/themes/light/material.css +0 -0
@@ -1,197 +1,146 @@
1
- import "../../knowledge/colors.js";
2
- import { COMPONENT_METADATA, getComponentSelector, getComponentPlatformAvailability } from "../../knowledge/component-metadata.js";
3
- import "../../knowledge/custom-palettes.js";
4
- import "../../utils/types.js";
5
- import "../../knowledge/palettes.js";
6
- import "node:fs";
7
- import "node:path";
8
- const SIZE_KEYWORDS = {
9
- small: 1,
10
- medium: 2,
11
- large: 3
1
+ import { COMPONENT_METADATA, getComponentPlatformAvailability, getComponentSelector } from "../../knowledge/component-metadata.js";
2
+ import "../../knowledge/index.js";
3
+ //#region src/tools/handlers/layout.ts
4
+ /**
5
+ * Handlers for layout scale tools: set_size, set_spacing, set_roundness.
6
+ */
7
+ var SIZE_KEYWORDS = {
8
+ small: 1,
9
+ medium: 2,
10
+ large: 3
12
11
  };
13
12
  function normalizeComponentName(component) {
14
- return component ? component.toLowerCase().trim() : null;
13
+ return component ? component.toLowerCase().trim() : null;
15
14
  }
16
15
  function buildSelectorList(value) {
17
- return Array.isArray(value) ? value : [value];
16
+ return Array.isArray(value) ? value : [value];
18
17
  }
19
18
  function resolveScope(component, scope, platform) {
20
- const notes = [];
21
- if (component) {
22
- const normalized = normalizeComponentName(component);
23
- if (!normalized || !COMPONENT_METADATA[normalized]) {
24
- const available = Object.keys(COMPONENT_METADATA);
25
- const suggestions = normalized ? available.filter((name) => name.includes(normalized)).slice(0, 10) : [];
26
- const list = suggestions.length > 0 ? suggestions : available.slice(0, 15);
27
- return {
28
- error: `**Error:** Component "${component}" not found.
19
+ const notes = [];
20
+ if (component) {
21
+ const normalized = normalizeComponentName(component);
22
+ if (!normalized || !COMPONENT_METADATA[normalized]) {
23
+ const available = Object.keys(COMPONENT_METADATA);
24
+ const suggestions = normalized ? available.filter((name) => name.includes(normalized)).slice(0, 10) : [];
25
+ const list = suggestions.length > 0 ? suggestions : available.slice(0, 15);
26
+ return { error: `**Error:** Component "${component}" not found.
29
27
 
30
28
  ${suggestions.length > 0 ? "**Similar components:**" : "**Available components:**"}
31
- ${list.map((name) => `- ${name}`).join("\n")}`
32
- };
33
- }
34
- if (scope) {
35
- notes.push("Scope ignored because component was provided.");
36
- }
37
- const selectorsEntry = COMPONENT_METADATA[normalized].selectors;
38
- let selectors = [];
39
- if (platform && platform !== "generic") {
40
- selectors = getComponentSelector(normalized, platform);
41
- if (selectors.length === 0) {
42
- const availability = getComponentPlatformAvailability(normalized);
43
- const availablePlatforms = [];
44
- if (availability?.angular) availablePlatforms.push("angular");
45
- if (availability?.webcomponents)
46
- availablePlatforms.push("webcomponents");
47
- return {
48
- error: `**Error:** Component "${component}" is not available on platform "${platform}".
49
- ${availablePlatforms.length > 0 ? `Available platforms: ${availablePlatforms.join(", ")}.` : ""}`
50
- };
51
- }
52
- } else {
53
- if (selectorsEntry.angular) {
54
- selectors = selectors.concat(buildSelectorList(selectorsEntry.angular));
55
- }
56
- if (selectorsEntry.webcomponents) {
57
- selectors = selectors.concat(
58
- buildSelectorList(selectorsEntry.webcomponents)
59
- );
60
- }
61
- if (selectorsEntry.angular && selectorsEntry.webcomponents) {
62
- notes.push(
63
- "Platform not specified; output includes Angular and Web Components selectors."
64
- );
65
- }
66
- }
67
- return {
68
- selectors: Array.from(new Set(selectors)),
69
- notes,
70
- scopeLabel: `component "${normalized}"`
71
- };
72
- }
73
- if (scope) {
74
- return {
75
- selectors: [scope],
76
- notes,
77
- scopeLabel: `scope "${scope}"`
78
- };
79
- }
80
- return {
81
- selectors: [":root"],
82
- notes,
83
- scopeLabel: "global scope (:root)"
84
- };
29
+ ${list.map((name) => `- ${name}`).join("\n")}` };
30
+ }
31
+ if (scope) notes.push("Scope ignored because component was provided.");
32
+ const selectorsEntry = COMPONENT_METADATA[normalized].selectors;
33
+ let selectors = [];
34
+ if (platform && platform !== "generic") {
35
+ selectors = getComponentSelector(normalized, platform);
36
+ if (selectors.length === 0) {
37
+ const availability = getComponentPlatformAvailability(normalized);
38
+ const availablePlatforms = [];
39
+ if (availability?.angular) availablePlatforms.push("angular");
40
+ if (availability?.webcomponents) availablePlatforms.push("webcomponents");
41
+ return { error: `**Error:** Component "${component}" is not available on platform "${platform}".
42
+ ${availablePlatforms.length > 0 ? `Available platforms: ${availablePlatforms.join(", ")}.` : ""}` };
43
+ }
44
+ } else {
45
+ if (selectorsEntry.angular) selectors = selectors.concat(buildSelectorList(selectorsEntry.angular));
46
+ if (selectorsEntry.webcomponents) selectors = selectors.concat(buildSelectorList(selectorsEntry.webcomponents));
47
+ if (selectorsEntry.angular && selectorsEntry.webcomponents) notes.push("Platform not specified; output includes Angular and Web Components selectors.");
48
+ }
49
+ return {
50
+ selectors: Array.from(new Set(selectors)),
51
+ notes,
52
+ scopeLabel: `component "${normalized}"`
53
+ };
54
+ }
55
+ if (scope) return {
56
+ selectors: [scope],
57
+ notes,
58
+ scopeLabel: `scope "${scope}"`
59
+ };
60
+ return {
61
+ selectors: [":root"],
62
+ notes,
63
+ scopeLabel: "global scope (:root)"
64
+ };
85
65
  }
86
66
  function formatSelectorBlock(selectors, declarations) {
87
- const selectorLine = selectors.join(",\n");
88
- const lines = [
89
- selectorLine,
90
- "{",
91
- ...declarations.map((line) => ` ${line}`),
92
- "}"
93
- ];
94
- return lines.join("\n");
67
+ return [
68
+ selectors.join(",\n"),
69
+ "{",
70
+ ...declarations.map((line) => ` ${line}`),
71
+ "}"
72
+ ].join("\n");
95
73
  }
96
74
  function buildResponse(description, output, code, notes, guidance) {
97
- const responseParts = [description];
98
- if (notes.length > 0) {
99
- responseParts.push("", ...notes);
100
- }
101
- if (guidance.length > 0) {
102
- responseParts.push("", ...guidance);
103
- }
104
- responseParts.push("");
105
- responseParts.push(output === "sass" ? "```scss" : "```css");
106
- responseParts.push(code);
107
- responseParts.push("```");
108
- return {
109
- content: [
110
- {
111
- type: "text",
112
- text: responseParts.join("\n")
113
- }
114
- ]
115
- };
75
+ const responseParts = [description];
76
+ if (notes.length > 0) responseParts.push("", ...notes);
77
+ if (guidance.length > 0) responseParts.push("", ...guidance);
78
+ responseParts.push("");
79
+ responseParts.push(output === "sass" ? "```scss" : "```css");
80
+ responseParts.push(code);
81
+ responseParts.push("```");
82
+ return { content: [{
83
+ type: "text",
84
+ text: responseParts.join("\n")
85
+ }] };
116
86
  }
117
87
  function coerceSizeValue(size) {
118
- if (typeof size === "number") {
119
- return { display: String(size), value: size };
120
- }
121
- const normalized = size.toLowerCase();
122
- const value = SIZE_KEYWORDS[normalized];
123
- return { display: `${size} (${value})`, value };
88
+ if (typeof size === "number") return {
89
+ display: String(size),
90
+ value: size
91
+ };
92
+ const value = SIZE_KEYWORDS[size.toLowerCase()];
93
+ return {
94
+ display: `${size} (${value})`,
95
+ value
96
+ };
124
97
  }
125
98
  async function handleSetSize(params) {
126
- const { component, scope, platform, size, output = "css" } = params;
127
- const resolution = resolveScope(component, scope, platform);
128
- if ("error" in resolution) {
129
- return {
130
- content: [{ type: "text", text: resolution.error }],
131
- isError: true
132
- };
133
- }
134
- const { selectors, notes, scopeLabel } = resolution;
135
- const { display, value } = coerceSizeValue(size);
136
- const declarations = [`--ig-size: ${value};`];
137
- const code = formatSelectorBlock(selectors, declarations);
138
- const description = `Set size to ${display} in ${scopeLabel}.`;
139
- const guidance = output === "sass" ? [
140
- "Sass note: sizable() requires @include sizable() in component styles.",
141
- "Components map --ig-size to --component-size internally."
142
- ] : [];
143
- return buildResponse(description, output, code, notes, guidance);
99
+ const { component, scope, platform, size, output = "css" } = params;
100
+ const resolution = resolveScope(component, scope, platform);
101
+ if ("error" in resolution) return {
102
+ content: [{
103
+ type: "text",
104
+ text: resolution.error
105
+ }],
106
+ isError: true
107
+ };
108
+ const { selectors, notes, scopeLabel } = resolution;
109
+ const { display, value } = coerceSizeValue(size);
110
+ const code = formatSelectorBlock(selectors, [`--ig-size: ${value};`]);
111
+ return buildResponse(`Set size to ${display} in ${scopeLabel}.`, output, code, notes, output === "sass" ? ["Sass note: sizable() requires @include sizable() in component styles.", "Components map --ig-size to --component-size internally."] : []);
144
112
  }
145
113
  async function handleSetSpacing(params) {
146
- const {
147
- component,
148
- scope,
149
- platform,
150
- spacing,
151
- inline,
152
- block,
153
- output = "css"
154
- } = params;
155
- const resolution = resolveScope(component, scope, platform);
156
- if ("error" in resolution) {
157
- return {
158
- content: [{ type: "text", text: resolution.error }],
159
- isError: true
160
- };
161
- }
162
- const { selectors, notes, scopeLabel } = resolution;
163
- const declarations = [];
164
- if (spacing !== void 0) declarations.push(`--ig-spacing: ${spacing};`);
165
- if (inline !== void 0)
166
- declarations.push(`--ig-spacing-inline: ${inline};`);
167
- if (block !== void 0) declarations.push(`--ig-spacing-block: ${block};`);
168
- const code = formatSelectorBlock(selectors, declarations);
169
- const description = `Set spacing in ${scopeLabel}.`;
170
- const guidance = output === "sass" ? [
171
- "Sass note: pad() functions require @include spacing() once at root scope."
172
- ] : [];
173
- return buildResponse(description, output, code, notes, guidance);
114
+ const { component, scope, platform, spacing, inline, block, output = "css" } = params;
115
+ const resolution = resolveScope(component, scope, platform);
116
+ if ("error" in resolution) return {
117
+ content: [{
118
+ type: "text",
119
+ text: resolution.error
120
+ }],
121
+ isError: true
122
+ };
123
+ const { selectors, notes, scopeLabel } = resolution;
124
+ const declarations = [];
125
+ if (spacing !== void 0) declarations.push(`--ig-spacing: ${spacing};`);
126
+ if (inline !== void 0) declarations.push(`--ig-spacing-inline: ${inline};`);
127
+ if (block !== void 0) declarations.push(`--ig-spacing-block: ${block};`);
128
+ const code = formatSelectorBlock(selectors, declarations);
129
+ return buildResponse(`Set spacing in ${scopeLabel}.`, output, code, notes, output === "sass" ? ["Sass note: pad() functions require @include spacing() once at root scope."] : []);
174
130
  }
175
131
  async function handleSetRoundness(params) {
176
- const { component, scope, platform, radiusFactor, output = "css" } = params;
177
- const resolution = resolveScope(component, scope, platform);
178
- if ("error" in resolution) {
179
- return {
180
- content: [{ type: "text", text: resolution.error }],
181
- isError: true
182
- };
183
- }
184
- const { selectors, notes, scopeLabel } = resolution;
185
- const declarations = [`--ig-radius-factor: ${radiusFactor};`];
186
- const code = formatSelectorBlock(selectors, declarations);
187
- const description = `Set roundness factor to ${radiusFactor} in ${scopeLabel}.`;
188
- const guidance = output === "sass" ? [
189
- "Sass note: border-radius() responds to --ig-radius-factor without extra mixins."
190
- ] : [];
191
- return buildResponse(description, output, code, notes, guidance);
132
+ const { component, scope, platform, radiusFactor, output = "css" } = params;
133
+ const resolution = resolveScope(component, scope, platform);
134
+ if ("error" in resolution) return {
135
+ content: [{
136
+ type: "text",
137
+ text: resolution.error
138
+ }],
139
+ isError: true
140
+ };
141
+ const { selectors, notes, scopeLabel } = resolution;
142
+ const code = formatSelectorBlock(selectors, [`--ig-radius-factor: ${radiusFactor};`]);
143
+ return buildResponse(`Set roundness factor to ${radiusFactor} in ${scopeLabel}.`, output, code, notes, output === "sass" ? ["Sass note: border-radius() responds to --ig-radius-factor without extra mixins."] : []);
192
144
  }
193
- export {
194
- handleSetRoundness,
195
- handleSetSize,
196
- handleSetSpacing
197
- };
145
+ //#endregion
146
+ export { handleSetRoundness, handleSetSize, handleSetSpacing };
@@ -1,127 +1,112 @@
1
- import { generatePaletteCss, formatCssOutput } from "../../generators/css.js";
2
- import { generatePalette } from "../../generators/sass.js";
3
1
  import { PLATFORM_METADATA } from "../../knowledge/platforms/index.js";
4
- import "../../knowledge/colors.js";
5
- import "../../knowledge/component-metadata.js";
6
- import "../../knowledge/custom-palettes.js";
7
- import "../../utils/types.js";
8
- import "../../knowledge/palettes.js";
9
- import "../../utils/color.js";
10
- import { validatePaletteColors, formatValidationResult, generateWarningComments } from "../../validators/palette.js";
2
+ import { generatePalette } from "../../generators/sass.js";
3
+ import { formatCssOutput, generatePaletteCss } from "../../generators/css.js";
4
+ import { formatValidationResult, generateWarningComments, validatePaletteColors } from "../../validators/palette.js";
5
+ import "../../validators/index.js";
6
+ //#region src/tools/handlers/palette.ts
7
+ /**
8
+ * Handler for create_palette tool.
9
+ */
11
10
  async function handleCreatePalette(params) {
12
- const variant = params.variant ?? "light";
13
- const output = params.output ?? "sass";
14
- const validation = await validatePaletteColors({
15
- variant,
16
- surface: params.surface,
17
- gray: params.gray
18
- });
19
- if (output === "css") {
20
- return handleCssOutput(params, validation);
21
- }
22
- return handleSassOutput(params, validation);
11
+ const variant = params.variant ?? "light";
12
+ const output = params.output ?? "sass";
13
+ const validation = await validatePaletteColors({
14
+ variant,
15
+ surface: params.surface,
16
+ gray: params.gray
17
+ });
18
+ if (output === "css") return handleCssOutput(params, validation);
19
+ return handleSassOutput(params, validation);
23
20
  }
21
+ /**
22
+ * Handle CSS output format - generates CSS custom properties directly.
23
+ */
24
24
  async function handleCssOutput(params, validation) {
25
- try {
26
- const result = await generatePaletteCss({
27
- primary: params.primary,
28
- secondary: params.secondary,
29
- surface: params.surface,
30
- gray: params.gray,
31
- info: params.info,
32
- success: params.success,
33
- warn: params.warn,
34
- error: params.error,
35
- variant: params.variant
36
- });
37
- const formattedCss = formatCssOutput(result.css, result.description);
38
- const responseParts = [result.description];
39
- responseParts.push("");
40
- responseParts.push("Output format: CSS custom properties");
41
- const validationText = formatValidationResult(validation);
42
- if (validationText) {
43
- responseParts.push("");
44
- responseParts.push(validationText);
45
- }
46
- responseParts.push("");
47
- responseParts.push("```css");
48
- responseParts.push(formattedCss.trimEnd());
49
- responseParts.push("```");
50
- return {
51
- content: [
52
- {
53
- type: "text",
54
- text: responseParts.join("\n")
55
- }
56
- ]
57
- };
58
- } catch (error) {
59
- const message = error instanceof Error ? error.message : String(error);
60
- return {
61
- content: [
62
- {
63
- type: "text",
64
- text: `**Error generating CSS palette**
65
-
66
- ${message}`
67
- }
68
- ]
69
- };
70
- }
25
+ try {
26
+ const result = await generatePaletteCss({
27
+ primary: params.primary,
28
+ secondary: params.secondary,
29
+ surface: params.surface,
30
+ gray: params.gray,
31
+ info: params.info,
32
+ success: params.success,
33
+ warn: params.warn,
34
+ error: params.error,
35
+ variant: params.variant
36
+ });
37
+ const formattedCss = formatCssOutput(result.css, result.description);
38
+ const responseParts = [result.description];
39
+ responseParts.push("");
40
+ responseParts.push("Output format: CSS custom properties");
41
+ const validationText = formatValidationResult(validation);
42
+ if (validationText) {
43
+ responseParts.push("");
44
+ responseParts.push(validationText);
45
+ }
46
+ responseParts.push("");
47
+ responseParts.push("```css");
48
+ responseParts.push(formattedCss.trimEnd());
49
+ responseParts.push("```");
50
+ return { content: [{
51
+ type: "text",
52
+ text: responseParts.join("\n")
53
+ }] };
54
+ } catch (error) {
55
+ return { content: [{
56
+ type: "text",
57
+ text: `**Error generating CSS palette**\n\n${error instanceof Error ? error.message : String(error)}`
58
+ }] };
59
+ }
71
60
  }
61
+ /**
62
+ * Handle Sass output format - generates Sass code using the palette() function.
63
+ */
72
64
  function handleSassOutput(params, validation) {
73
- const result = generatePalette({
74
- platform: params.platform,
75
- licensed: params.licensed,
76
- primary: params.primary,
77
- secondary: params.secondary,
78
- surface: params.surface,
79
- gray: params.gray,
80
- info: params.info,
81
- success: params.success,
82
- warn: params.warn,
83
- error: params.error,
84
- variant: params.variant,
85
- name: params.name
86
- });
87
- let finalCode = result.code;
88
- if (!validation.isValid) {
89
- const warningComments = generateWarningComments(validation);
90
- if (warningComments.length > 0) {
91
- const lines = finalCode.split("\n");
92
- const useIndex = lines.findIndex(
93
- (line) => line.startsWith("@use '") || line.startsWith('@use "')
94
- );
95
- if (useIndex > 0) {
96
- lines.splice(useIndex, 0, ...warningComments, "");
97
- finalCode = lines.join("\n");
98
- }
99
- }
100
- }
101
- const responseParts = [result.description];
102
- const platformNote = params.platform ? `Platform: ${PLATFORM_METADATA[params.platform]?.name ?? params.platform}` : "Platform: Not specified (generic output). Specify `platform` for optimized code.";
103
- responseParts.push("");
104
- responseParts.push(platformNote);
105
- const validationText = formatValidationResult(validation);
106
- if (validationText) {
107
- responseParts.push("");
108
- responseParts.push(validationText);
109
- }
110
- responseParts.push("");
111
- responseParts.push(`Variables created: ${result.variables.join(", ")}`);
112
- responseParts.push("");
113
- responseParts.push("```scss");
114
- responseParts.push(finalCode.trimEnd());
115
- responseParts.push("```");
116
- return {
117
- content: [
118
- {
119
- type: "text",
120
- text: responseParts.join("\n")
121
- }
122
- ]
123
- };
65
+ const result = generatePalette({
66
+ platform: params.platform,
67
+ licensed: params.licensed,
68
+ primary: params.primary,
69
+ secondary: params.secondary,
70
+ surface: params.surface,
71
+ gray: params.gray,
72
+ info: params.info,
73
+ success: params.success,
74
+ warn: params.warn,
75
+ error: params.error,
76
+ variant: params.variant,
77
+ name: params.name
78
+ });
79
+ let finalCode = result.code;
80
+ if (!validation.isValid) {
81
+ const warningComments = generateWarningComments(validation);
82
+ if (warningComments.length > 0) {
83
+ const lines = finalCode.split("\n");
84
+ const useIndex = lines.findIndex((line) => line.startsWith("@use '") || line.startsWith("@use \""));
85
+ if (useIndex > 0) {
86
+ lines.splice(useIndex, 0, ...warningComments, "");
87
+ finalCode = lines.join("\n");
88
+ }
89
+ }
90
+ }
91
+ const responseParts = [result.description];
92
+ const platformNote = params.platform ? `Platform: ${PLATFORM_METADATA[params.platform]?.name ?? params.platform}` : "Platform: Not specified (generic output). Specify `platform` for optimized code.";
93
+ responseParts.push("");
94
+ responseParts.push(platformNote);
95
+ const validationText = formatValidationResult(validation);
96
+ if (validationText) {
97
+ responseParts.push("");
98
+ responseParts.push(validationText);
99
+ }
100
+ responseParts.push("");
101
+ responseParts.push(`Variables created: ${result.variables.join(", ")}`);
102
+ responseParts.push("");
103
+ responseParts.push("```scss");
104
+ responseParts.push(finalCode.trimEnd());
105
+ responseParts.push("```");
106
+ return { content: [{
107
+ type: "text",
108
+ text: responseParts.join("\n")
109
+ }] };
124
110
  }
125
- export {
126
- handleCreatePalette
127
- };
111
+ //#endregion
112
+ export { handleCreatePalette };