@dxtmisha/scripts 0.6.3 → 0.7.6

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 (121) hide show
  1. package/bin/ai-doc.ts +1 -3
  2. package/bin/build-functional.ts +5 -0
  3. package/bin/design-flags.ts +5 -0
  4. package/bin/design-wiki-storm.ts +9 -0
  5. package/package.json +14 -8
  6. package/src/classes/Ai/AiAbstract.ts +14 -1
  7. package/src/classes/Ai/AiGoogleLite.ts +2 -1
  8. package/src/classes/Build/__tests__/buildFunctional.test.ts +43 -0
  9. package/src/classes/Build/buildFunctional.ts +54 -0
  10. package/src/classes/Component/ComponentCreator.ts +1 -0
  11. package/src/classes/Component/ComponentItem.ts +15 -0
  12. package/src/classes/Component/ComponentWiki.ts +8 -0
  13. package/src/classes/Component/ComponentWikiFile.ts +2 -0
  14. package/src/classes/Component/__tests__/ComponentCreator.test.ts +71 -0
  15. package/src/classes/Component/__tests__/ComponentItem.test.ts +71 -0
  16. package/src/classes/Design/DesignCommand.ts +65 -10
  17. package/src/classes/Design/DesignComponent.ts +303 -39
  18. package/src/classes/Design/DesignConstructor.ts +49 -20
  19. package/src/classes/Design/DesignConstructors.ts +61 -2
  20. package/src/classes/Design/DesignFlags.ts +215 -0
  21. package/src/classes/Design/DesignReplace.ts +11 -7
  22. package/src/classes/Design/DesignStructure.ts +8 -6
  23. package/src/classes/Design/DesignStructureClasses.ts +8 -4
  24. package/src/classes/Design/DesignStructureItemAbstract.ts +11 -2
  25. package/src/classes/Design/DesignStructureRead.ts +8 -4
  26. package/src/classes/Design/DesignStructureStyles.ts +8 -4
  27. package/src/classes/Design/DesignTypes.ts +53 -28
  28. package/src/classes/Design/DesignTypescript.ts +11 -2
  29. package/src/classes/Design/DesignUi.ts +74 -4
  30. package/src/classes/Design/DesignWiki.ts +4 -6
  31. package/src/classes/Design/DesignWikiStorm.ts +94 -0
  32. package/src/classes/Design/DesignWikiStormItem.ts +246 -0
  33. package/src/classes/Git/GitRead.ts +1 -0
  34. package/src/classes/Git/__tests__/GitRead.test.ts +70 -0
  35. package/src/classes/Library/LibraryAiWiki.ts +127 -0
  36. package/src/classes/Library/LibraryAiWikiItem.ts +79 -0
  37. package/src/classes/Library/LibraryExport.ts +0 -2
  38. package/src/classes/Library/LibraryFlags.ts +9 -7
  39. package/src/classes/Library/LibraryItems.ts +22 -13
  40. package/src/classes/Library/LibraryList.ts +189 -0
  41. package/src/classes/Library/LibraryMedia.ts +22 -8
  42. package/src/classes/Library/LibraryPlugin.ts +73 -0
  43. package/src/classes/Library/LibraryTypes.ts +130 -0
  44. package/src/classes/Package/PackageInit.ts +12 -4
  45. package/src/classes/Package/PackageItem.ts +16 -5
  46. package/src/classes/Properties/Properties.ts +14 -3
  47. package/src/classes/Properties/PropertiesCache.ts +19 -20
  48. package/src/classes/Properties/PropertiesConfig.ts +46 -26
  49. package/src/classes/Properties/PropertiesConvector.ts +10 -6
  50. package/src/classes/Properties/PropertiesFile.ts +27 -31
  51. package/src/classes/Properties/PropertiesImport.ts +10 -7
  52. package/src/classes/Properties/PropertiesItems.ts +19 -12
  53. package/src/classes/Properties/PropertiesKeys.ts +15 -9
  54. package/src/classes/Properties/PropertiesMain.ts +13 -7
  55. package/src/classes/Properties/PropertiesPalette.ts +12 -6
  56. package/src/classes/Properties/PropertiesPath.ts +17 -11
  57. package/src/classes/Properties/PropertiesScss.ts +10 -8
  58. package/src/classes/Properties/PropertiesSeparator.ts +9 -11
  59. package/src/classes/Properties/PropertiesSettings.ts +8 -6
  60. package/src/classes/Properties/PropertiesStandard.ts +5 -6
  61. package/src/classes/Properties/PropertiesTool.ts +16 -9
  62. package/src/classes/Properties/PropertiesTypes.ts +12 -12
  63. package/src/classes/Properties/PropertiesValues.ts +14 -14
  64. package/src/classes/Properties/PropertiesWrap.ts +5 -6
  65. package/src/classes/Properties/convector/convectorColor.ts +5 -3
  66. package/src/classes/Properties/to/PropertiesToAbstract.ts +18 -4
  67. package/src/classes/Styles/Styles.ts +1 -0
  68. package/src/composables/__tests__/useAi.test.ts +75 -0
  69. package/src/config.ts +9 -0
  70. package/src/functions/__tests__/getComponentPaths.test.ts +19 -0
  71. package/src/functions/__tests__/getConfigAi.test.ts +26 -0
  72. package/src/functions/__tests__/getConstructorProperties.test.ts +51 -0
  73. package/src/functions/__tests__/getDirname.test.ts +31 -0
  74. package/src/functions/__tests__/getNameDirByPaths.test.ts +40 -0
  75. package/src/functions/__tests__/getPackageJson.test.ts +34 -0
  76. package/src/functions/__tests__/hasNativeDirname.test.ts +18 -0
  77. package/src/functions/__tests__/toPathStandardSep.test.ts +31 -0
  78. package/src/functions/getConfigAi.ts +3 -2
  79. package/src/functions/toPathStandardSep.ts +1 -1
  80. package/src/library-ai.ts +0 -1
  81. package/src/library.ts +10 -0
  82. package/src/media/properties/css.ts +3 -1
  83. package/src/media/templates/component/{DesignComponentWikiAi.vue → DesignComponentAiWiki.vue} +2 -2
  84. package/src/media/templates/component/props.ts +2 -3
  85. package/src/media/templates/component/styleToken.scss +1 -1
  86. package/src/media/templates/component/wiki.ts +6 -12
  87. package/src/media/templates/component/wikiData.ts +28 -0
  88. package/src/media/templates/constructors/props.ts +3 -4
  89. package/src/media/templates/packages/figma/README.md +1 -0
  90. package/src/media/templates/packages/figma/ai.sample.config.ts +2 -0
  91. package/src/media/templates/packages/figma/design.config.json +3 -0
  92. package/src/media/templates/packages/figma/index.html +12 -0
  93. package/src/media/templates/packages/figma/manifest.json +25 -0
  94. package/src/media/templates/packages/figma/package.json +37 -0
  95. package/src/media/templates/packages/figma/src/App.vue +9 -0
  96. package/src/media/templates/packages/figma/src/classes/_.gitignore.txt +1 -0
  97. package/src/media/templates/packages/figma/src/code.ts +16 -0
  98. package/src/media/templates/packages/figma/src/components/_.gitignore.txt +1 -0
  99. package/src/media/templates/packages/figma/src/composables/_.gitignore.txt +1 -0
  100. package/src/media/templates/packages/figma/src/functions/_.gitignore.txt +1 -0
  101. package/src/media/templates/packages/figma/src/library.ts +0 -0
  102. package/src/media/templates/packages/figma/src/main.ts +4 -0
  103. package/src/media/templates/packages/figma/src/media/_.gitignore.txt +1 -0
  104. package/src/media/templates/packages/figma/src/storybook/_.gitignore.txt +1 -0
  105. package/src/media/templates/packages/figma/src/types/_.gitignore.txt +1 -0
  106. package/src/media/templates/packages/figma/src/vite-env.d.ts +1 -0
  107. package/src/media/templates/packages/figma/tsconfig.app.json +12 -0
  108. package/src/media/templates/packages/figma/tsconfig.json +7 -0
  109. package/src/media/templates/packages/figma/tsconfig.node.json +8 -0
  110. package/src/media/templates/packages/figma/vite.config.ts +7 -0
  111. package/src/media/templates/packages/library/src/main.ts +1 -1
  112. package/src/media/templates/packages/project/design.config.json +3 -0
  113. package/src/media/templates/packages/project/index.html +1 -2
  114. package/src/media/templates/packages/project/public/_.gitignore.txt +0 -0
  115. package/src/media/templates/packages/project/src/main.ts +2 -1
  116. package/src/media/templates/packages/project/src/vite-env.d.ts +1 -0
  117. package/src/types/configTypes.ts +6 -0
  118. package/src/types/designTypes.ts +12 -0
  119. package/src/types/libraryTypes.ts +1 -1
  120. package/src/types/webTypes.ts +105 -0
  121. /package/src/media/templates/packages/{library/public/_.gitignore.txt → figma/src/config.ts} +0 -0
@@ -14,9 +14,11 @@ import {
14
14
  } from '../../types/propertyTypes'
15
15
 
16
16
  /**
17
- * Class for working with colors.
17
+ * Manager for design palette and color saturation.
18
+ * This class handles the extraction of available shade levels (saturation steps) and tracks the usage of palette colors across the design system. It facilitates the mapping between functional variables and their underlying palette definitions, ensuring that generated styles correctly reference the intended theme colors.
18
19
  *
19
- * Класс для работы с цветами.
20
+ * Менеджер палитры дизайна и насыщенности цветов.
21
+ * Этот класс обрабатывает извлечение доступных уровней оттенков (шагов насыщенности) и отслеживает использование цветов палитры в системе дизайна. Он упрощает сопоставление функциональных переменных с их базовыми определениями в палитре, гарантируя, что сгенерированные стили правильно ссылаются на нужные цвета темы.
20
22
  */
21
23
  export class PropertiesPalette {
22
24
  /**
@@ -28,9 +30,11 @@ export class PropertiesPalette {
28
30
  }
29
31
 
30
32
  /**
31
- * Returns a list of available saturation levels.
33
+ * Retrieves a list of available saturation levels (shades) grouped by design.
34
+ * Scans the token cluster for items categorized as 'shade' and returns their resolved value structures.
32
35
  *
33
- * Возвращает список доступных уровней насыщенности.
36
+ * Возвращает список доступных уровней насыщенности (оттенков), сгруппированных по дизайну.
37
+ * Сканирует кластер токенов на наличие элементов, классифицированных как 'shade', и возвращает их разрешенные структуры значений.
34
38
  */
35
39
  getShade(): PropertyPaletteList {
36
40
  return forEach(this.items.findCategory(PropertyCategory.shade), ({
@@ -49,9 +53,11 @@ export class PropertiesPalette {
49
53
  }
50
54
 
51
55
  /**
52
- * Getting a list of used values.
56
+ * Generates a report of all palette colors currently utilized in functional variables.
57
+ * Iterates through the entire property tree to identify variables referencing palette colors and maps them to their corresponding CSS variable names.
53
58
  *
54
- * Получаем список использованных значений.
59
+ * Генерирует отчет обо всех цветах палитры, используемых в данный момент в функциональных переменных.
60
+ * Итерирует по всему дереву свойств для идентификации переменных, ссылающихся на цвета палитры, и сопоставляет их с соответствующими именами CSS-переменных.
55
61
  */
56
62
  getUsed(): PropertyPaletteUsed[] {
57
63
  const list = this.getList()
@@ -24,9 +24,11 @@ export type PropertiesPathList = PropertiesPathItem[]
24
24
  const DIR_CACHE = 'read'
25
25
 
26
26
  /**
27
- * Class for working with paths by the given name of the design.
27
+ * Directory and path resolver for multi-design token environments.
28
+ * This class translates abstract design names into concrete filesystem paths for global tokens and component-specific settings. It coordinates the cross-platform path discovery flow and provided cached traversal mechanisms (`to`, `toAll`) to efficiently process token files across the entire project structure.
28
29
  *
29
- * Класс для работы с путями по заданному названию дизайна.
30
+ * Резолвер директорий и путей для сред с несколькими дизайнами токенов.
31
+ * Этот класс преобразует абстрактные названия дизайнов в конкретные пути файловой системы для глобальных токенов и настроек компонентов. Он координирует процесс обнаружения путей на разных платформах и предоставляет механизмы кэшированного обхода (`to`, `toAll`) для эффективной обработки файлов токенов во всей структуре проекта.
30
32
  */
31
33
  export class PropertiesPath {
32
34
  private readonly paths: PropertiesPathList
@@ -92,12 +94,14 @@ export class PropertiesPath {
92
94
  }
93
95
 
94
96
  /**
95
- * Processes all token values for the selected design and combines them into one-big array.
97
+ * Executes a cached transformation for a specific design and token group.
98
+ * Resolves paths for the target design, executes the provided callback to process the data, and caches the result for future performance. Ideal for processing individual themes or component layers within a theme.
96
99
  *
97
- * Обрабатывает все значения токена у выбранного дизайна и соединяет их в одну-большую массива.
98
- * @param name name of the group/ названия группы
99
- * @param design design name/ название дизайна
100
- * @param callback function for processing/ функция для обработки
100
+ * Выполняет кэшированную трансформацию для конкретного дизайна и группы токенов.
101
+ * Разрешает пути для целевого дизайна, выполняет предоставленный callback для обработки данных и кэширует результат. Идеально подходит для обработки отдельных тем или слоев компонентов внутри темы.
102
+ * @param name unique name for the processing group (used as cache key) / уникальное имя группы обработки (используется как ключ кэша)
103
+ * @param design names of the design to process / названия дизайна для обработки
104
+ * @param callback function that receives resolved paths and returns processed data / функция, которая получает разрешенные пути и возвращает обработанные данные
101
105
  */
102
106
  to(
103
107
  name: string,
@@ -128,11 +132,13 @@ export class PropertiesPath {
128
132
  }
129
133
 
130
134
  /**
131
- * Processes all token values for all designs and combines them into one-big array.
135
+ * Orchestrates a global cached transformation across all registered designs.
136
+ * Iterates through every design defined in the constructor, processes its tokens using the provided callback, and merges the results into a single unified property tree.
132
137
  *
133
- * Обрабатывает все значения токена у всех дизайнов и соединяет их в одну-большую массива.
134
- * @param name name of the group/ названия группы
135
- * @param callback function for processing/ функция для обработки
138
+ * Координирует глобальную кэшированную трансформацию для всех зарегистрированных дизайнов.
139
+ * Итерирует по каждому дизайну, определенному в конструкторе, обрабатывает его токены с помощью предоставленного callback и объединяет результаты в единое унифицированное дерево свойств.
140
+ * @param name unique name for the global processing group / уникальное имя глобальной группы обработки
141
+ * @param callback function for processing individual designs / функция для обработки отдельных дизайнов
136
142
  */
137
143
  toAll(
138
144
  name: string,
@@ -20,22 +20,24 @@ const NAME_SHADE = 'setDesignShade'
20
20
  const NAME_PROPERTIES = 'setDesignsProperties'
21
21
 
22
22
  /**
23
- * Class for working with SCSS.
23
+ * Class for generating SCSS structures from design tokens.
24
24
  *
25
- * Класс для работы с SCSS.
25
+ * Класс для генерации структур SCSS из токенов дизайна.
26
26
  */
27
27
  export class PropertiesScss {
28
28
  /**
29
- * Constructor
30
- * @param items
29
+ * Constructor for initializing the SCSS generator.
30
+ *
31
+ * Конструктор для инициализации генератора SCSS.
32
+ * @param items property management instance / экземпляр управления свойствами
31
33
  */
32
34
  constructor(private items: PropertiesItems) {
33
35
  }
34
36
 
35
37
  /**
36
- * Returns a formatted string for SCSS.
38
+ * Returns a complete SCSS formatted string containing all configuration mixins.
37
39
  *
38
- * Возвращает отформатированную строку для SCSS.
40
+ * Возвращает полную отформатированную строку SCSS, содержащую все миксины конфигурации.
39
41
  */
40
42
  get() {
41
43
  let data = '@use "@dxtmisha/styles" as variables;\r\n\r\n'
@@ -145,9 +147,9 @@ export class PropertiesScss {
145
147
  }
146
148
 
147
149
  /**
148
- * Returns a list of properties.
150
+ * Generates a SCSS map structure for all identified properties.
149
151
  *
150
- * Возвращает список свойств.
152
+ * Генерирует структуру карты SCSS для всех определенных свойств.
151
153
  */
152
154
  getProperties(): string {
153
155
  return this.getPropertiesValue(NAME_PROPERTIES, this.to())
@@ -12,19 +12,17 @@ import {
12
12
  } from '../../types/propertyTypes'
13
13
 
14
14
  /**
15
- * Class for working with property splitting into multiple sub-properties.
15
+ * Class for handling the splitting of property names with separators into nested sub-properties.
16
16
  *
17
- * Класс для работы с разделением свойства на множество под-свойств.
17
+ * Класс для работы с разделением названий свойств с разделителями на вложенные под-свойства.
18
18
  */
19
19
  export class PropertiesSeparator {
20
20
  /**
21
- * Checks if the structure has grouped records.
21
+ * Checks if the property list contains any keys that require splitting (contain separators).
22
22
  *
23
- * Проверяет, есть ли у структуры сгруппированные записи.
24
- * @param properties an array that needs to be transformed/
25
- * массив, который нужно преобразовать
26
- * @param limit the maximum permissible level of verification/
27
- * максимальный допустимый уровень проверки
23
+ * Проверяет, содержит ли список свойств ключи, требующие разделения (содержащие разделители).
24
+ * @param properties list of properties to check / список свойств для проверки
25
+ * @param limit maximum recursion depth for verification / максимальная глубина рекурсии для проверки
28
26
  */
29
27
  static is(
30
28
  properties: PropertyList,
@@ -52,10 +50,10 @@ export class PropertiesSeparator {
52
50
  }
53
51
 
54
52
  /**
55
- * Transforming a property with long names with separators into a set of sub-properties.
53
+ * Transforms properties with separator-containing keys into a nested object structure.
56
54
  *
57
- * Преобразование свойства с длинными названиями с разделителями на множество под-свойств.
58
- * @param properties an array that needs to be transformed/ массив, который нужно преобразовать
55
+ * Преобразует свойства с ключами, содержащими разделители, во вложенную структуру объектов.
56
+ * @param properties the property list to transform / список свойств для преобразования
59
57
  */
60
58
  static to(properties: PropertyList): PropertyList {
61
59
  let data: PropertyList = {}
@@ -16,14 +16,16 @@ import { UI_DIRS_COMPONENTS, UI_DIRS_CONSTRUCTOR, UI_KEY_CONSTRUCTOR } from '../
16
16
  const DIR_NAME = 'settings'
17
17
 
18
18
  /**
19
- * Class for searching all components.
19
+ * Class for searching and loading global component settings.
20
20
  *
21
- * Класс для поиск всех компоненты.
21
+ * Класс для поиска и загрузки глобальных настроек компонентов.
22
22
  */
23
23
  export class PropertiesSettings {
24
24
  /**
25
- * Constructor
26
- * @param path object of the class for working with paths/ объект класса для работы с путями
25
+ * Constructor for initializing the settings resolver.
26
+ *
27
+ * Конструктор для инициализации резолвера настроек.
28
+ * @param path path handler instance / экземпляр обработчика путей
27
29
  */
28
30
  constructor(
29
31
  private readonly path: PropertiesPath
@@ -31,9 +33,9 @@ export class PropertiesSettings {
31
33
  }
32
34
 
33
35
  /**
34
- * Returns the basic settings of the component.
36
+ * Returns a unified list of settings for all identified components and constructors.
35
37
  *
36
- * Возвращает базовые настройки у компонента.
38
+ * Возвращает унифицированный список настроек для всех определенных компонентов и конструкторов.
37
39
  */
38
40
  get(): PropertyList {
39
41
  return {
@@ -16,17 +16,16 @@ import {
16
16
  } from '../../types/propertyTypes'
17
17
 
18
18
  /**
19
- * A class for transforming a property into a basic structure for work.
19
+ * Class for transforming raw property data into a standardized structure for internal processing.
20
20
  *
21
- * Класс для преобразования свойства в базовую структуру для работы.
21
+ * Класс для преобразования сырых данных свойств в стандартизированную структуру для внутренней обработки.
22
22
  */
23
23
  export class PropertiesStandard {
24
24
  /**
25
- * Transforms an array into the required data structure.
25
+ * Transforms a property list or raw data into a standardized PropertyList structure.
26
26
  *
27
- * Преобразует массив в нужную структуру.
28
- * @param properties an array that needs to be transformed/
29
- * массив, который нужно преобразовать
27
+ * Преобразует список свойств или сырые данные в стандартизированную структуру PropertyList.
28
+ * @param properties the property list or data to transform / список свойств или данные для преобразования
30
29
  */
31
30
  static to(properties: PropertyListOrData): PropertyList {
32
31
  const data: PropertyList = {}
@@ -12,16 +12,16 @@ import basicProperties from '../../media/properties.json'
12
12
  import { UI_KEY_CONSTRUCTOR, UI_FILE_PROPERTY } from '../../config'
13
13
 
14
14
  /**
15
- * A class for static methods of obtaining various data.
15
+ * Utility class for naming components and reading design system property files.
16
16
  *
17
- * Класс для статических методов получения различных данных.
17
+ * Утилитарный класс для именования компонентов и чтения файлов свойств дизайн-системы.
18
18
  */
19
19
  export class PropertiesTool {
20
20
  /**
21
- * Checks if the names of the design relate to the construction.
21
+ * Checks if the design name identifies as a constructor.
22
22
  *
23
- * Проверяет, относятся ли названия дизайна к конструкции.
24
- * @param design design name/ название дизайна
23
+ * Проверяет, идентифицирует ли название дизайна конструктор.
24
+ * @param design design name / название дизайна
25
25
  */
26
26
  static isConstructor(design: string): boolean {
27
27
  return design === UI_KEY_CONSTRUCTOR
@@ -37,11 +37,11 @@ export class PropertiesTool {
37
37
  }
38
38
 
39
39
  /**
40
- * Return a list of component names.
40
+ * Generates a camelCase component name string based on design and component name.
41
41
  *
42
- * Возвращаем список названий компонентов.
43
- * @param design design name/ название дизайна
44
- * @param component component name/ название компонента
42
+ * Генерирует строку названия компонента в стиле camelCase на основе дизайна и названия компонента.
43
+ * @param design design name / название дизайна
44
+ * @param component component name / название компонента
45
45
  */
46
46
  static getComponentName(design: string, component?: string): string {
47
47
  return `${design}${component ? `-${toCamelCase(component)}` : ''}`
@@ -58,6 +58,13 @@ export class PropertiesTool {
58
58
  return `.${this.getComponentName(design, component)}`
59
59
  }
60
60
 
61
+ /**
62
+ * Reads a property list from a specified path, with special handling for constructors.
63
+ *
64
+ * Считывает список свойств по указанному пути с особой обработкой для конструкторов.
65
+ * @param design design name / название дизайна
66
+ * @param path array representing the directory path / массив, представляющий путь к директории
67
+ */
61
68
  static readFile(
62
69
  design: string,
63
70
  path: string[] | undefined
@@ -8,9 +8,9 @@ import {
8
8
  } from '../../types/propertyTypes'
9
9
 
10
10
  /**
11
- * Class with a list of available types.
11
+ * Utility class for identifying and managing property types based on naming conventions and symbols.
12
12
  *
13
- * Класс со списком доступных типов.
13
+ * Утилитарный класс для идентификации и управления типами свойств на основе соглашений об именовании и символов.
14
14
  */
15
15
  export class PropertiesTypes {
16
16
  private static readonly SYMBOLS: Record<string, string> = {
@@ -27,11 +27,11 @@ export class PropertiesTypes {
27
27
  }
28
28
 
29
29
  /**
30
- * Checks if the list contains such a type.
30
+ * Checks if the property type matches the specified list of allowed types.
31
31
  *
32
- * Проверяет, входит ли в список такой тип.
33
- * @param type property type/ тип свойства
34
- * @param name key name/ название ключа
32
+ * Проверяет, соответствует ли тип свойства указанному списку разрешенных типов.
33
+ * @param type current property type / текущий тип свойства
34
+ * @param name list of allowed types / список разрешенных типов
35
35
  */
36
36
  static isInType(
37
37
  type?: PropertyItem['_type'],
@@ -48,10 +48,10 @@ export class PropertiesTypes {
48
48
  }
49
49
 
50
50
  /**
51
- * Checks if there is a type in the name of the property.
51
+ * Determines if the property name contains a type-identifying symbol or specific prefix.
52
52
  *
53
- * Проверяет, если есть тип в названии свойства.
54
- * @param name key name/ название ключа
53
+ * Определяет, содержит ли название свойства символ-идентификатор типа или специфический префикс.
54
+ * @param name property key name / название ключа свойства
55
55
  */
56
56
  static isTypeInName(name: string): boolean {
57
57
  return Boolean(name.match(this.getExpSymbols()))
@@ -98,10 +98,10 @@ export class PropertiesTypes {
98
98
  }
99
99
 
100
100
  /**
101
- * Returns the variable type name from the property name.
101
+ * Extracts and returns the property type identifier from its name string.
102
102
  *
103
- * Возвращает название типа переменной из названия свойства.
104
- * @param name key name/ название ключа
103
+ * Извлекает и возвращает идентификатор типа свойства из строки его названия.
104
+ * @param name property key name / название ключа свойства
105
105
  */
106
106
  static getTypeInName(name: string): PropertyItem['_type'] {
107
107
  if (this.isTypeInName(name)) {
@@ -3,26 +3,26 @@
3
3
  import { type PropertyItemPartial } from '../../types/propertyTypes'
4
4
 
5
5
  /**
6
- * Class for working with the values.
6
+ * Utility class for validating and normalizing design system property values.
7
7
  *
8
- * Класс для работы со значениями.
8
+ * Утилитарный класс для валидации и нормализации значений свойств дизайн-системы.
9
9
  */
10
10
  export class PropertiesValues {
11
11
  /**
12
- * Checks if the values are complete.
12
+ * Checks if the value is marked as "full" (starting with `=`), meaning it doesn't require further processing.
13
13
  *
14
- * Проверяет, является ли значение полным.
15
- * @param value property value/ значение свойства
14
+ * Проверяет, помечено ли значение как «полное» (начинается с `=`), что означает отсутствие необходимости дальнейшей обработки.
15
+ * @param value property value / значение свойства
16
16
  */
17
17
  static isFull(value: PropertyItemPartial['value']): value is string {
18
18
  return typeof value === 'string' && Boolean(value.match(this.getExpFull()))
19
19
  }
20
20
 
21
21
  /**
22
- * Checks if the value is a color value.
22
+ * Identifies if the value is a hex color string.
23
23
  *
24
- * Проверяет, является ли значение цветом.
25
- * @param value property value/ значение свойства
24
+ * Определяет, является ли значение строкой цвета в формате HEX.
25
+ * @param value property value / значение свойства
26
26
  */
27
27
  static isColor(value: PropertyItemPartial['__c']): boolean {
28
28
  return Boolean(
@@ -33,10 +33,10 @@ export class PropertiesValues {
33
33
  }
34
34
 
35
35
  /**
36
- * Checks if the value is a color with transparency.
36
+ * Identifies if the value is a hex color string with an alpha channel (opacity).
37
37
  *
38
- * Проверяет, является ли значение цветом с прозрачности.
39
- * @param value property value/ значение свойства
38
+ * Определяет, является ли значение строкой цвета HEX с альфа-каналом (прозрачностью).
39
+ * @param value property value / значение свойства
40
40
  */
41
41
  static isColorWithOpacity(value: PropertyItemPartial['__c']): boolean {
42
42
  return Boolean(
@@ -47,10 +47,10 @@ export class PropertiesValues {
47
47
  }
48
48
 
49
49
  /**
50
- * Removes unnecessary values from the values.
50
+ * Cleans up the value by removing the "full" marker or converting numeric values to strings.
51
51
  *
52
- * Убирает лишние значения из значений.
53
- * @param value property value/ значение свойства
52
+ * Очищает значение, удаляя маркер «полноты» или преобразовывая числовые значения в строки.
53
+ * @param value property value / значение свойства
54
54
  */
55
55
  static reValue(value: PropertyItemPartial['value']): PropertyItemPartial['value'] {
56
56
  if (this.isFull(value)) {
@@ -11,17 +11,16 @@ import {
11
11
  } from '../../types/propertyTypes'
12
12
 
13
13
  /**
14
- * A class for moving data up the level, if the property is used in all records at the same level.
14
+ * Utility class for optimizing the property structure by moving duplicated data to a higher level.
15
15
  *
16
- * Класс для переноса данных выше по уровню, если свойство используется во всех записях на одном уровне.
16
+ * Утилитарный класс для оптимизации структуры свойств путем переноса дублирующихся данных на более высокий уровень.
17
17
  */
18
18
  export class PropertiesWrap {
19
19
  /**
20
- * Drag the duplicate properties to the top level to reduce the record.
20
+ * Analyzes the property list and moves duplicate properties to the parent level to reduce redundancy.
21
21
  *
22
- * Перетаскивает дублирующиеся свойства на верхний уровень для уменьшения записи.
23
- * @param properties an array that needs to be transformed/
24
- * массив, который нужно преобразовать
22
+ * Анализирует список свойств и переносит дублирующиеся свойства на родительский уровень для уменьшения избыточности.
23
+ * @param properties property list to transform / список свойств для преобразования
25
24
  */
26
25
  static to(properties: PropertyList): void {
27
26
  forEach(properties, (item) => {
@@ -6,10 +6,12 @@ import {
6
6
  } from '../../../types/propertyTypes'
7
7
 
8
8
  /**
9
- * Data conversion into colors.
9
+ * Convector for transforming design token color metadata into internal property structures.
10
+ * Supports opacity modification based on 'studio.tokens' extensions.
10
11
  *
11
- * Преобразование данных в цвета.
12
- * @param item values for conversion/ значения для преобразования
12
+ * Конвектор для преобразования метаданных цвета токенов дизайна во внутренние структуры свойств.
13
+ * Поддерживает модификацию прозрачности на основе расширений 'studio.tokens'.
14
+ * @param item property input object for conversion / входной объект свойства для преобразования
13
15
  */
14
16
  export function convectorColor(item: PropertyItemInput): void {
15
17
  const type: string | undefined = item?.$extensions?.['studio.tokens']?.modify?.type
@@ -3,22 +3,36 @@
3
3
  import { PropertiesItems } from '../PropertiesItems'
4
4
 
5
5
  /**
6
- * Abstract class for conversion.
6
+ * Abstract base class for data transformation processes.
7
+ * Provides the core orchestration for initializing and writing transformed property data.
7
8
  *
8
- * Абстрактный класс для преобразования.
9
+ * Абстрактный базовый класс для процессов преобразования данных.
10
+ * Обеспечивает основную оркестровку инициализации и записи преобразованных данных свойств.
9
11
  */
10
12
  export abstract class PropertiesToAbstract {
13
+ /**
14
+ * Abstract property defining the cache file path for the specific transformation.
15
+ *
16
+ * Абстрактное свойство, определяющее путь к файлу кэша для конкретного преобразования.
17
+ */
11
18
  protected readonly abstract FILE_CACHE: string
12
19
 
13
20
  /**
14
- * Constructor
15
- * @param items data for processing/ данные для обработки
21
+ * Constructor that initializes the transformation with a set of property items.
22
+ *
23
+ * Конструктор, который инициализирует преобразование набором элементов свойств.
24
+ * @param items data for processing / данные для обработки
16
25
  */
17
26
  constructor(
18
27
  protected items: PropertiesItems
19
28
  ) {
20
29
  }
21
30
 
31
+ /**
32
+ * Executes the full transformation pipeline: initialization followed by writing the output.
33
+ *
34
+ * Выполняет полный конвейер преобразования: инициализацию с последующей записью результата.
35
+ */
22
36
  to(): void {
23
37
  this.init()
24
38
  this.write()
@@ -188,6 +188,7 @@ export class Styles {
188
188
  [
189
189
  `@use "./${FILE_BASIC}";`,
190
190
  `@use "@dxtmisha/styles/${FILE_PROPERTIES}" as ui;`,
191
+ `@use "@dxtmisha/media/style.css";`,
191
192
  '',
192
193
  '@include ui.initGlobal;',
193
194
  `@include ui.initDesignBody('${design}.main');`
@@ -0,0 +1,75 @@
1
+ import { describe, expect, it, vi, beforeEach } from 'vitest'
2
+ import { useAi } from '../useAi'
3
+ import { PropertiesConfig } from '../../classes/Properties/PropertiesConfig'
4
+ import { AiGoogle } from '../../classes/Ai/AiGoogle'
5
+ import { AiGoogleCli } from '../../classes/Ai/AiGoogleCli'
6
+
7
+ vi.mock('../../classes/Properties/PropertiesConfig', () => ({
8
+ PropertiesConfig: {
9
+ getAiType: vi.fn()
10
+ }
11
+ }))
12
+
13
+ vi.mock('../../classes/Ai/AiGoogle', () => {
14
+ return {
15
+ AiGoogle: vi.fn().mockImplementation(function () {
16
+ return { name: 'AiGoogleInstance' }
17
+ })
18
+ }
19
+ })
20
+
21
+ vi.mock('../../classes/Ai/AiGoogleCli', () => {
22
+ return {
23
+ AiGoogleCli: vi.fn().mockImplementation(function () {
24
+ return { name: 'AiGoogleCliInstance' }
25
+ })
26
+ }
27
+ })
28
+
29
+ describe('useAi', () => {
30
+ beforeEach(() => {
31
+ vi.clearAllMocks()
32
+ })
33
+
34
+ it('should return an instance of AiGoogle when the type is gemini', () => {
35
+ vi.mocked(PropertiesConfig.getAiType).mockReturnValue('gemini')
36
+ const mockInstance = { name: 'AiGoogleInstance' }
37
+ vi.mocked(AiGoogle).mockImplementation(function () {
38
+ return mockInstance as any
39
+ })
40
+
41
+ const result = useAi()
42
+
43
+ expect(result).toEqual(mockInstance)
44
+ expect(AiGoogle).toHaveBeenCalled()
45
+ })
46
+
47
+ it('should return an instance of AiGoogleCli when the type is gemini-cli', () => {
48
+ vi.mocked(PropertiesConfig.getAiType).mockReturnValue('gemini-cli')
49
+ const mockInstance = { name: 'AiGoogleCliInstance' }
50
+ vi.mocked(AiGoogleCli).mockImplementation(function () {
51
+ return mockInstance as any
52
+ })
53
+
54
+ const result = useAi()
55
+
56
+ expect(result).toEqual(mockInstance)
57
+ expect(AiGoogleCli).toHaveBeenCalled()
58
+ })
59
+
60
+ it('should return undefined for an unknown type', () => {
61
+ vi.mocked(PropertiesConfig.getAiType).mockReturnValue('unknown' as any)
62
+
63
+ const result = useAi()
64
+
65
+ expect(result).toBeUndefined()
66
+ })
67
+
68
+ it('should return undefined if no type is configured', () => {
69
+ vi.mocked(PropertiesConfig.getAiType).mockReturnValue(undefined as any)
70
+
71
+ const result = useAi()
72
+
73
+ expect(result).toBeUndefined()
74
+ })
75
+ })
package/src/config.ts CHANGED
@@ -21,6 +21,7 @@ export const UI_FLAG_NOT_EXPORT = /\/\/ *export:none/
21
21
 
22
22
  /** Folder where all the code is stored/ Папка, где хранится весь код */
23
23
  export const UI_DIR_IN = 'src'
24
+ export const UI_DIR_AI = 'ai'
24
25
  /** Components directory name/ Название директории компонентов */
25
26
  export const UI_DIR_COMPONENTS = 'components'
26
27
  /** Constructors directory name/ Название директории конструкторов */
@@ -34,6 +35,7 @@ export const UI_DIR_DIST_TEMPORARY = 'dist-temporary'
34
35
  export const UI_DIR_PROMPT = 'prompt'
35
36
  export const UI_DIR_PACKAGES = 'packages'
36
37
 
38
+ export const UI_DIRS_AI_WIKI = [UI_DIR_IN, UI_DIR_WIKI, UI_DIR_AI]
37
39
  /** Name of the path to tokens/ Название пути к токенам */
38
40
  export const UI_DIRS_TOKENS = [UI_DIR_IN, 'media']
39
41
  /** Directory containing the list of icons/ Директория со списком иконок */
@@ -74,6 +76,11 @@ export const UI_FILE_NAME_FLAGS = 'flags'
74
76
  /** File name for storing media data and icons/ Название файла для хранения медиа-данных и иконок */
75
77
  export const UI_FILE_NAME_MEDIA = 'media'
76
78
 
79
+ /** File name for the list of component descriptions/ Название файла для список описаний компонентов */
80
+ export const UI_FILE_NAME_DESIGN = 'design'
81
+ export const UI_FILE_NAME_PLUGIN = 'plugin'
82
+ export const UI_FILE_NAME_STYLE = 'style'
83
+
77
84
  /** File name for the list of component descriptions for the wiki/ Название файла для список описаний компонентов для wiki */
78
85
  export const UI_FILE_NAME_WIKI = 'wiki'
79
86
 
@@ -84,6 +91,8 @@ export const UI_FILE_NAME_VITE_WORKERS = 'vite-workers.config.ts'
84
91
  export const UI_FILE_INDEX = 'index.ts'
85
92
 
86
93
  export const UI_FILE_AI_TYPES = 'ai-types.txt'
94
+ export const UI_FILE_STYLE_SCSS = 'style.scss'
95
+ export const UI_FILE_STYLE_PROPERTIES = 'ui-properties.scss'
87
96
 
88
97
  /** SCSS file extension/ Расширение файлов SCSS */
89
98
  export const UI_EXTENSION_STYLE = 'scss'