@dxtmisha/scripts 0.11.8 → 1.1.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/CHANGELOG.md +77 -0
- package/ai-resources/componentMaterials.md +19 -0
- package/ai-resources/componentPrompt.md +381 -0
- package/ai-resources/componentWiki.md +13 -0
- package/bin/arguments.ts +168 -0
- package/bin/build-packages.ts +34 -3
- package/bin/build-publish-packages.ts +12 -2
- package/bin/design-component.ts +7 -1
- package/bin/design-constructor.ts +22 -3
- package/bin/design-figma.ts +26 -4
- package/bin/design-flags.ts +14 -2
- package/bin/design-library.ts +7 -1
- package/bin/design-package.ts +29 -5
- package/bin/design-prompt.ts +27 -3
- package/bin/design-screenshot.ts +12 -2
- package/bin/design-types-save.ts +32 -5
- package/bin/design-types.ts +32 -6
- package/bin/design-ui.ts +21 -3
- package/bin/design-wiki-storm.ts +11 -3
- package/dist/AiZAi-BiLAcdFy.js +232 -0
- package/dist/PropertiesConfig-BKZz_FWW.js +262 -0
- package/{src/config.ts → dist/config.d.ts} +185 -158
- package/dist/config.js +20 -0
- package/dist/figmaApiTypes-CArSsNW8.js +6 -0
- package/dist/library-ai.d.ts +482 -0
- package/dist/library-ai.js +2 -0
- package/dist/library-figma.d.ts +462 -0
- package/dist/library-figma.js +75 -0
- package/dist/library-ui.d.ts +586 -0
- package/dist/library-ui.js +3760 -0
- package/dist/library.d.ts +4910 -0
- package/dist/library.js +1568 -0
- package/dist/propertyTypes-C64u6rT3.js +236 -0
- package/package.json +76 -27
- package/bin/ai-doc.ts +0 -7
- package/bin/build-functional.ts +0 -5
- package/bin/design-component-wiki.ts +0 -11
- package/src/classes/Ai/AiAbstract.ts +0 -242
- package/src/classes/Ai/AiClaude.ts +0 -26
- package/src/classes/Ai/AiClaudeAgent.ts +0 -16
- package/src/classes/Ai/AiClaudeAgentLite.ts +0 -86
- package/src/classes/Ai/AiClaudeCli.ts +0 -24
- package/src/classes/Ai/AiClaudeCliLite.ts +0 -108
- package/src/classes/Ai/AiClaudeLite.ts +0 -112
- package/src/classes/Ai/AiDoc.ts +0 -81
- package/src/classes/Ai/AiDocItem.ts +0 -27
- package/src/classes/Ai/AiDocItemAbstract.ts +0 -209
- package/src/classes/Ai/AiDocItemClasses.ts +0 -27
- package/src/classes/Ai/AiDocItemComposables.ts +0 -20
- package/src/classes/Ai/AiDocType.ts +0 -45
- package/src/classes/Ai/AiGoogle.ts +0 -26
- package/src/classes/Ai/AiGoogleCli.ts +0 -24
- package/src/classes/Ai/AiGoogleCliLite.ts +0 -108
- package/src/classes/Ai/AiGoogleLite.ts +0 -78
- package/src/classes/Ai/AiOpenAi.ts +0 -26
- package/src/classes/Ai/AiOpenAiLite.ts +0 -107
- package/src/classes/Ai/AiZAi.ts +0 -17
- package/src/classes/Ai/AiZAiLite.ts +0 -77
- package/src/classes/Ai/ApiTmp.ts +0 -43
- package/src/classes/BrowserItem.ts +0 -408
- package/src/classes/Build/BuildFunctional.ts +0 -54
- package/src/classes/Build/BuildPackages.ts +0 -137
- package/src/classes/Build/BuildPublishPackages.ts +0 -105
- package/src/classes/BuildItem.ts +0 -187
- package/src/classes/Component/ComponentCreator.ts +0 -45
- package/src/classes/Component/ComponentItem.ts +0 -161
- package/src/classes/Component/ComponentWiki.ts +0 -258
- package/src/classes/Component/ComponentWikiFile.ts +0 -138
- package/src/classes/Design/DesignCommand.ts +0 -243
- package/src/classes/Design/DesignComponent.ts +0 -824
- package/src/classes/Design/DesignConstructor.ts +0 -222
- package/src/classes/Design/DesignConstructors.ts +0 -101
- package/src/classes/Design/DesignFigma.ts +0 -61
- package/src/classes/Design/DesignFlags.ts +0 -215
- package/src/classes/Design/DesignReplace.ts +0 -672
- package/src/classes/Design/DesignScreenshot.ts +0 -140
- package/src/classes/Design/DesignStructure.ts +0 -201
- package/src/classes/Design/DesignStructureClasses.ts +0 -105
- package/src/classes/Design/DesignStructureItemAbstract.ts +0 -52
- package/src/classes/Design/DesignStructureRead.ts +0 -349
- package/src/classes/Design/DesignStructureStyles.ts +0 -45
- package/src/classes/Design/DesignTypes.ts +0 -94
- package/src/classes/Design/DesignTypesAi.ts +0 -135
- package/src/classes/Design/DesignTypesDescription.ts +0 -121
- package/src/classes/Design/DesignTypesMake.ts +0 -460
- package/src/classes/Design/DesignTypesMcp.ts +0 -90
- package/src/classes/Design/DesignTypesPrompts.ts +0 -332
- package/src/classes/Design/DesignTypescript.ts +0 -244
- package/src/classes/Design/DesignUi.ts +0 -143
- package/src/classes/Design/DesignWiki.ts +0 -52
- package/src/classes/Design/DesignWikiStorm.ts +0 -95
- package/src/classes/Design/DesignWikiStormItem.ts +0 -316
- package/src/classes/FigmaApi.ts +0 -190
- package/src/classes/Git/GitRead.ts +0 -261
- package/src/classes/Library/LibraryAiMcpItem.ts +0 -67
- package/src/classes/Library/LibraryAiPrompt.ts +0 -268
- package/src/classes/Library/LibraryAiPromptItem.ts +0 -331
- package/src/classes/Library/LibraryAiWiki.ts +0 -127
- package/src/classes/Library/LibraryAiWikiItem.ts +0 -79
- package/src/classes/Library/LibraryExport.ts +0 -167
- package/src/classes/Library/LibraryFlags.ts +0 -62
- package/src/classes/Library/LibraryItems.ts +0 -138
- package/src/classes/Library/LibraryList.ts +0 -189
- package/src/classes/Library/LibraryMedia.ts +0 -139
- package/src/classes/Library/LibraryPlugin.ts +0 -73
- package/src/classes/Library/LibraryTypes.ts +0 -130
- package/src/classes/Package/PackageFile.ts +0 -154
- package/src/classes/Package/PackageInit.ts +0 -54
- package/src/classes/Package/PackageItem.ts +0 -329
- package/src/classes/Properties/Properties.ts +0 -175
- package/src/classes/Properties/PropertiesCache.ts +0 -248
- package/src/classes/Properties/PropertiesConfig.ts +0 -213
- package/src/classes/Properties/PropertiesConvector.ts +0 -52
- package/src/classes/Properties/PropertiesFile.ts +0 -522
- package/src/classes/Properties/PropertiesImport.ts +0 -182
- package/src/classes/Properties/PropertiesItems.ts +0 -605
- package/src/classes/Properties/PropertiesKeys.ts +0 -121
- package/src/classes/Properties/PropertiesMain.ts +0 -138
- package/src/classes/Properties/PropertiesPalette.ts +0 -149
- package/src/classes/Properties/PropertiesPath.ts +0 -193
- package/src/classes/Properties/PropertiesScss.ts +0 -261
- package/src/classes/Properties/PropertiesSeparator.ts +0 -118
- package/src/classes/Properties/PropertiesSettings.ts +0 -104
- package/src/classes/Properties/PropertiesStandard.ts +0 -180
- package/src/classes/Properties/PropertiesTool.ts +0 -80
- package/src/classes/Properties/PropertiesTypes.ts +0 -147
- package/src/classes/Properties/PropertiesValues.ts +0 -75
- package/src/classes/Properties/PropertiesWrap.ts +0 -187
- package/src/classes/Properties/convector/convectorColor.ts +0 -27
- package/src/classes/Properties/convector/convectorFontFamilies.ts +0 -18
- package/src/classes/Properties/convector/convectorShadow.ts +0 -61
- package/src/classes/Properties/convector/convectorTypography.ts +0 -19
- package/src/classes/Properties/to/PropertiesToAbstract.ts +0 -51
- package/src/classes/Properties/to/PropertiesToAnimate.ts +0 -59
- package/src/classes/Properties/to/PropertiesToClass.ts +0 -49
- package/src/classes/Properties/to/PropertiesToClone.ts +0 -114
- package/src/classes/Properties/to/PropertiesToComponent.ts +0 -52
- package/src/classes/Properties/to/PropertiesToDrag.ts +0 -231
- package/src/classes/Properties/to/PropertiesToDuplicate.ts +0 -165
- package/src/classes/Properties/to/PropertiesToFull.ts +0 -36
- package/src/classes/Properties/to/PropertiesToLink.ts +0 -259
- package/src/classes/Properties/to/PropertiesToMedia.ts +0 -187
- package/src/classes/Properties/to/PropertiesToMulti.ts +0 -101
- package/src/classes/Properties/to/PropertiesToNone.ts +0 -46
- package/src/classes/Properties/to/PropertiesToPalette.ts +0 -241
- package/src/classes/Properties/to/PropertiesToProperty.ts +0 -31
- package/src/classes/Properties/to/PropertiesToRemove.ts +0 -33
- package/src/classes/Properties/to/PropertiesToReplace.ts +0 -77
- package/src/classes/Properties/to/PropertiesToRoot.ts +0 -40
- package/src/classes/Properties/to/PropertiesToSimilar.ts +0 -128
- package/src/classes/Properties/to/PropertiesToSort.ts +0 -146
- package/src/classes/Properties/to/PropertiesToState.ts +0 -65
- package/src/classes/Properties/to/PropertiesToStyle.ts +0 -52
- package/src/classes/Properties/to/PropertiesToSub.ts +0 -95
- package/src/classes/Properties/to/PropertiesToSubclass.ts +0 -76
- package/src/classes/Properties/to/PropertiesToVar.ts +0 -194
- package/src/classes/Properties/to/PropertiesToVariable.ts +0 -176
- package/src/classes/Styles/Styles.ts +0 -247
- package/src/classes/Styles/StylesClasses.ts +0 -86
- package/src/classes/Styles/StylesProperties.ts +0 -197
- package/src/classes/Styles/StylesRoot.ts +0 -103
- package/src/classes/Styles/StylesTool.ts +0 -112
- package/src/classes/Styles/to/StylesToAbstract.ts +0 -93
- package/src/classes/Styles/to/StylesToAnimate.ts +0 -19
- package/src/classes/Styles/to/StylesToClass.ts +0 -25
- package/src/classes/Styles/to/StylesToClassFull.ts +0 -19
- package/src/classes/Styles/to/StylesToContainer.ts +0 -24
- package/src/classes/Styles/to/StylesToMedia.ts +0 -19
- package/src/classes/Styles/to/StylesToProperty.ts +0 -123
- package/src/classes/Styles/to/StylesToRoot.ts +0 -14
- package/src/classes/Styles/to/StylesToSelector.ts +0 -71
- package/src/classes/Styles/to/StylesToVar.ts +0 -105
- package/src/classes/Styles/to/StylesToVirtual.ts +0 -33
- package/src/composables/useAi.ts +0 -38
- package/src/demo/ai.ts +0 -10
- package/src/functions/getComponentPaths.ts +0 -13
- package/src/functions/getConfigAi.ts +0 -14
- package/src/functions/getConstructorProperties.ts +0 -54
- package/src/functions/getDirname.ts +0 -17
- package/src/functions/getNameDirByPaths.ts +0 -16
- package/src/functions/getPackageJson.ts +0 -19
- package/src/functions/hasNativeDirname.ts +0 -8
- package/src/functions/run.ts +0 -47
- package/src/functions/toPathStandardSep.ts +0 -14
- package/src/library-ai.ts +0 -10
- package/src/library.ts +0 -73
- package/src/media/ai/ai-doc-types.ts +0 -21
- package/src/media/properties/css.ts +0 -634
- package/src/media/properties/cssSelector.ts +0 -74
- package/src/media/properties/cssVirtual.ts +0 -12
- package/src/media/properties/listSort.ts +0 -113
- package/src/media/properties/style.ts +0 -81
- package/src/media/templates/component/DesignComponent.mdx +0 -30
- package/src/media/templates/component/DesignComponent.stories.ts +0 -34
- package/src/media/templates/component/DesignComponent.vue +0 -54
- package/src/media/templates/component/DesignComponentAiWiki.vue +0 -25
- package/src/media/templates/component/index.ts +0 -13
- package/src/media/templates/component/props.ts +0 -27
- package/src/media/templates/component/styleToken.scss +0 -17
- package/src/media/templates/component/wiki.ts +0 -13
- package/src/media/templates/component/wikiData.ts +0 -28
- package/src/media/templates/componentDoc/ComponentDoc.vue +0 -26
- package/src/media/templates/componentDoc/index.ts +0 -12
- package/src/media/templates/componentDoc/materials/README.md +0 -8
- package/src/media/templates/componentDoc/materials/prompt.md +0 -38
- package/src/media/templates/componentDoc/subcomponents/_.gitignore.txt +0 -0
- package/src/media/templates/componentDoc/types.ts +0 -15
- package/src/media/templates/componentDoc/wiki/ComponentDoc.mdx +0 -13
- package/src/media/templates/componentDoc/wiki/ComponentDoc.stories.ts +0 -24
- package/src/media/templates/componentDoc/wiki/prompt.md +0 -41
- package/src/media/templates/constructors/Constructors.ts +0 -33
- package/src/media/templates/constructors/ConstructorsDesign.tsx +0 -129
- package/src/media/templates/constructors/basicTypes.ts +0 -0
- package/src/media/templates/constructors/index.ts +0 -5
- package/src/media/templates/constructors/props.ts +0 -28
- package/src/media/templates/constructors/style.scss +0 -5
- package/src/media/templates/constructors/types.ts +0 -47
- package/src/media/templates/packages/figma/README.md +0 -1
- package/src/media/templates/packages/figma/_.gitignore.txt +0 -29
- package/src/media/templates/packages/figma/ai.sample.config.ts +0 -2
- package/src/media/templates/packages/figma/design.config.json +0 -3
- package/src/media/templates/packages/figma/index.html +0 -12
- package/src/media/templates/packages/figma/manifest.json +0 -25
- package/src/media/templates/packages/figma/package.json +0 -37
- package/src/media/templates/packages/figma/src/App.vue +0 -9
- package/src/media/templates/packages/figma/src/classes/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/code.ts +0 -16
- package/src/media/templates/packages/figma/src/components/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/composables/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/config.ts +0 -0
- package/src/media/templates/packages/figma/src/functions/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/library.ts +0 -0
- package/src/media/templates/packages/figma/src/main.ts +0 -4
- package/src/media/templates/packages/figma/src/media/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/storybook/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/types/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/vite-env.d.ts +0 -1
- package/src/media/templates/packages/figma/tsconfig.app.json +0 -12
- package/src/media/templates/packages/figma/tsconfig.json +0 -7
- package/src/media/templates/packages/figma/tsconfig.node.json +0 -8
- package/src/media/templates/packages/figma/vite.config.ts +0 -7
- package/src/media/templates/packages/library/README.md +0 -1
- package/src/media/templates/packages/library/_.gitignore.txt +0 -27
- package/src/media/templates/packages/library/ai-description.md +0 -15
- package/src/media/templates/packages/library/design.config.json +0 -3
- package/src/media/templates/packages/library/index.html +0 -12
- package/src/media/templates/packages/library/materials/README.md +0 -8
- package/src/media/templates/packages/library/materials/prompt.md +0 -45
- package/src/media/templates/packages/library/package.json +0 -46
- package/src/media/templates/packages/library/src/App.vue +0 -8
- package/src/media/templates/packages/library/src/classes/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/components/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/composables/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/functions/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/library.ts +0 -0
- package/src/media/templates/packages/library/src/main.ts +0 -6
- package/src/media/templates/packages/library/src/style.scss +0 -0
- package/src/media/templates/packages/library/src/types/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/vite-env.d.ts +0 -1
- package/src/media/templates/packages/library/tsconfig.app.json +0 -11
- package/src/media/templates/packages/library/tsconfig.json +0 -7
- package/src/media/templates/packages/library/tsconfig.node.json +0 -7
- package/src/media/templates/packages/library/vite.config.ts +0 -14
- package/src/media/templates/packages/nitro/README.md +0 -1
- package/src/media/templates/packages/nitro/_.gitignore.txt +0 -28
- package/src/media/templates/packages/nitro/index.html +0 -2
- package/src/media/templates/packages/nitro/package.json +0 -25
- package/src/media/templates/packages/nitro/server/plugins/ui-plugin.ts +0 -7
- package/src/media/templates/packages/nitro/server/routes/api/hello.ts +0 -13
- package/src/media/templates/packages/nitro/src/App.vue +0 -10
- package/src/media/templates/packages/nitro/src/assets/_.gitignore.txt +0 -0
- package/src/media/templates/packages/nitro/src/components/_.gitignore.txt +0 -0
- package/src/media/templates/packages/nitro/src/composables/_.gitignore.txt +0 -0
- package/src/media/templates/packages/nitro/src/entry-client.ts +0 -13
- package/src/media/templates/packages/nitro/src/entry-server.ts +0 -29
- package/src/media/templates/packages/nitro/src/main.ts +0 -14
- package/src/media/templates/packages/nitro/src/pages/HomePage.vue +0 -8
- package/src/media/templates/packages/nitro/src/router.ts +0 -11
- package/src/media/templates/packages/nitro/src/style.scss +0 -0
- package/src/media/templates/packages/nitro/src/templates/main.html +0 -21
- package/src/media/templates/packages/nitro/src/vite-env.d.ts +0 -11
- package/src/media/templates/packages/nitro/tsconfig.app.json +0 -14
- package/src/media/templates/packages/nitro/tsconfig.json +0 -7
- package/src/media/templates/packages/nitro/tsconfig.node.json +0 -12
- package/src/media/templates/packages/nitro/vite.config.ts +0 -17
- package/src/media/templates/packages/project/README.md +0 -1
- package/src/media/templates/packages/project/_.gitignore.txt +0 -28
- package/src/media/templates/packages/project/design.config.json +0 -3
- package/src/media/templates/packages/project/index.html +0 -12
- package/src/media/templates/packages/project/materials/README.md +0 -8
- package/src/media/templates/packages/project/materials/prompt.md +0 -41
- package/src/media/templates/packages/project/package.json +0 -13
- package/src/media/templates/packages/project/public/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/App.vue +0 -12
- package/src/media/templates/packages/project/src/assets/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/components/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/composables/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/main.ts +0 -6
- package/src/media/templates/packages/project/src/style.scss +0 -0
- package/src/media/templates/packages/project/src/vite-env.d.ts +0 -1
- package/src/media/templates/packages/project/tsconfig.app.json +0 -11
- package/src/media/templates/packages/project/tsconfig.json +0 -7
- package/src/media/templates/packages/project/tsconfig.node.json +0 -7
- package/src/media/templates/packages/project/vite.config.ts +0 -7
- package/src/media/templates/prompts/aiCodeGlobalPrompt.en.md +0 -22
- package/src/media/templates/prompts/aiCodeGlobalPrompt.ru.md +0 -21
- package/src/media/templates/prompts/aiCodeVuePrompt.en.md +0 -17
- package/src/media/templates/prompts/aiCodeVuePrompt.ru.md +0 -17
- package/src/media/templates/prompts/aiDocClassPrompt.en.txt +0 -63
- package/src/media/templates/prompts/aiDocClassPrompt.ru.txt +0 -63
- package/src/media/templates/prompts/aiDocComposablePrompt.en.txt +0 -67
- package/src/media/templates/prompts/aiDocComposablePrompt.ru.txt +0 -67
- package/src/media/templates/prompts/aiDocFunctionPrompt.en.txt +0 -57
- package/src/media/templates/prompts/aiDocFunctionPrompt.ru.txt +0 -57
- package/src/media/templates/prompts/componentPrompt.en.txt +0 -182
- package/src/media/templates/prompts/componentPrompt.ru.txt +0 -182
- package/src/media/templates/prompts/demoClassEn.mdx +0 -111
- package/src/media/templates/prompts/demoClassRu.mdx +0 -111
- package/src/media/templates/prompts/demoComponentEn.mdx +0 -282
- package/src/media/templates/prompts/demoComponentRu.mdx +0 -282
- package/src/media/templates/prompts/demoComposableEn.mdx +0 -103
- package/src/media/templates/prompts/demoComposableRu.mdx +0 -103
- package/src/media/templates/prompts/demoDocEn.mdx +0 -30
- package/src/media/templates/prompts/demoDocRu.mdx +0 -30
- package/src/media/templates/viteComponentTemplateConfig.ts +0 -14
- package/src/types/aiTypes.ts +0 -19
- package/src/types/configTypes.ts +0 -69
- package/src/types/designTypes.ts +0 -167
- package/src/types/figmaApiTypes.ts +0 -337
- package/src/types/gitTypes.ts +0 -59
- package/src/types/libraryTypes.ts +0 -49
- package/src/types/propertyTypes.ts +0 -586
- package/src/types/screenshotTypes.ts +0 -55
- package/src/types/webTypes.ts +0 -134
- package/src/vite-env.d.ts +0 -1
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
// export:none
|
|
2
|
-
|
|
3
|
-
import { forEach, isFilled, isObjectNotArray, toCamelCase, uniqueArray } from '@dxtmisha/functional-basic'
|
|
4
|
-
|
|
5
|
-
import { DesignStructureItemAbstract } from './DesignStructureItemAbstract'
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
type PropertyItem,
|
|
9
|
-
PropertyKey,
|
|
10
|
-
PropertyType
|
|
11
|
-
} from '../../types/propertyTypes'
|
|
12
|
-
import type {
|
|
13
|
-
DesignStructureItem,
|
|
14
|
-
DesignStructureItemSub,
|
|
15
|
-
DesignStructureList,
|
|
16
|
-
DesignStructureStateList
|
|
17
|
-
} from '../../types/designTypes'
|
|
18
|
-
|
|
19
|
-
import { UI_PROPERTY_FOR_PROPS } from '../../config'
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Engine for parsing and resolving component property dependencies and states.
|
|
23
|
-
* It processes the raw property metadata to identify interactive states, link classes, and compile all possible values for code generation.
|
|
24
|
-
*
|
|
25
|
-
* Движок для парсинга и разрешения зависимостей свойств и состояний компонента.
|
|
26
|
-
* Обрабатывает сырые метаданные свойств для идентификации интерактивных состояний, связанных классов и компиляции всех возможных значений для генерации кода.
|
|
27
|
-
*/
|
|
28
|
-
export class DesignStructureRead extends DesignStructureItemAbstract<DesignStructureList> {
|
|
29
|
-
protected states: DesignStructureStateList
|
|
30
|
-
|
|
31
|
-
protected data: DesignStructureList = {}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Constructor for DesignStructureRead.
|
|
35
|
-
*
|
|
36
|
-
* Конструктор для DesignStructureRead.
|
|
37
|
-
* @param component component name whose properties are being resolved / имя компонента, свойства которого разрешаются
|
|
38
|
-
*/
|
|
39
|
-
constructor(
|
|
40
|
-
component: string
|
|
41
|
-
) {
|
|
42
|
-
super(component)
|
|
43
|
-
this.states = this.makeState(this.items?.value)
|
|
44
|
-
|
|
45
|
-
this.makeMain()
|
|
46
|
-
this.makeValue()
|
|
47
|
-
this.makeValueAll()
|
|
48
|
-
this.makeValueUnique()
|
|
49
|
-
// this.makeValueState()
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Getting all dependencies of the component.
|
|
54
|
-
*
|
|
55
|
-
* Получение всех зависимостей у компонента.
|
|
56
|
-
*/
|
|
57
|
-
getStates(): DesignStructureStateList {
|
|
58
|
-
return this.states
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Checks if the property is available for addition to props.
|
|
63
|
-
*
|
|
64
|
-
* Проверяет, доступно ли свойство для добавления в props.
|
|
65
|
-
* @param item object for checking/ объект для проверки
|
|
66
|
-
*/
|
|
67
|
-
protected isProps(item: PropertyItem): boolean {
|
|
68
|
-
const is = item?.[PropertyKey.prop]
|
|
69
|
-
|
|
70
|
-
return is !== false && (
|
|
71
|
-
isFilled(is)
|
|
72
|
-
|| item?.[PropertyKey.variable] === PropertyType.state
|
|
73
|
-
|| UI_PROPERTY_FOR_PROPS.indexOf(item?.[PropertyKey.name] as string) !== -1
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Checks whether the property is a reference to a class.
|
|
79
|
-
*
|
|
80
|
-
* Проверяет, является ли свойство ссылкой на класс.
|
|
81
|
-
* @param item object for checking/ объект для проверки
|
|
82
|
-
*/
|
|
83
|
-
protected isLinkClass(item: PropertyItem): boolean {
|
|
84
|
-
return typeof item.value === 'string'
|
|
85
|
-
&& item?.[PropertyKey.variable] === PropertyType.linkClass
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Transformations to a class name.
|
|
90
|
-
*
|
|
91
|
-
* Преобразование в имя класса.
|
|
92
|
-
* @param value values of properties from the value field/ значения свойств из поля value
|
|
93
|
-
*/
|
|
94
|
-
protected getClass(value: string): string {
|
|
95
|
-
return this.properties.get()
|
|
96
|
-
.getKeys(value)
|
|
97
|
-
.join('.')
|
|
98
|
-
.replace('.', '-')
|
|
99
|
-
.replace(/\./g, '--')
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Returns all properties of a component by its reference.
|
|
104
|
-
*
|
|
105
|
-
* Возвращает все свойства компонента по его reference.
|
|
106
|
-
* @param index link to a property/ ссылка на свойство
|
|
107
|
-
*/
|
|
108
|
-
protected getClassState(index: string): PropertyItem | undefined {
|
|
109
|
-
return this.properties.get().getItem(index)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Returns records that meet state conditions.
|
|
114
|
-
*
|
|
115
|
-
* Возвращает записи, удовлетворяющие условиям состояния.
|
|
116
|
-
* @param properties input data/ входной данный
|
|
117
|
-
*/
|
|
118
|
-
protected makeState(properties?: PropertyItem['value']): DesignStructureStateList {
|
|
119
|
-
const state: DesignStructureStateList = []
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
isFilled(properties)
|
|
123
|
-
&& isObjectNotArray(properties)
|
|
124
|
-
) {
|
|
125
|
-
forEach(properties, (item, index) => {
|
|
126
|
-
if (this.isProps(item)) {
|
|
127
|
-
state.push({
|
|
128
|
-
index,
|
|
129
|
-
type: PropertyType.property,
|
|
130
|
-
item,
|
|
131
|
-
className: undefined,
|
|
132
|
-
state: this.makeState(item.value)
|
|
133
|
-
})
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (this.isLinkClass(item)) {
|
|
137
|
-
const value = item?.[PropertyKey.css] || item.value
|
|
138
|
-
|
|
139
|
-
if (typeof value === 'string') {
|
|
140
|
-
const link = this.getClassState(value)
|
|
141
|
-
|
|
142
|
-
if (link) {
|
|
143
|
-
state.push({
|
|
144
|
-
index,
|
|
145
|
-
type: PropertyType.linkClass,
|
|
146
|
-
item: link,
|
|
147
|
-
className: this.getClass(value),
|
|
148
|
-
state: this.makeState(link.value)
|
|
149
|
-
})
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
})
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return state
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Retrieves all properties for preparing data filling.
|
|
161
|
-
*
|
|
162
|
-
* Получает все свойства для подготовки заполнения данными.
|
|
163
|
-
*/
|
|
164
|
-
protected makeMain(): this {
|
|
165
|
-
this.states?.forEach(({
|
|
166
|
-
index,
|
|
167
|
-
type,
|
|
168
|
-
item,
|
|
169
|
-
className
|
|
170
|
-
}) => {
|
|
171
|
-
this.data[index] = {
|
|
172
|
-
name: this.toName(item, index),
|
|
173
|
-
index,
|
|
174
|
-
type,
|
|
175
|
-
className,
|
|
176
|
-
value: [],
|
|
177
|
-
valueAll: [],
|
|
178
|
-
state: [],
|
|
179
|
-
style: Boolean(item?.[PropertyKey.style]),
|
|
180
|
-
default: item?.[PropertyKey.default],
|
|
181
|
-
category: item?.[PropertyKey.category]
|
|
182
|
-
}
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
return this
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Receives the default values.
|
|
190
|
-
*
|
|
191
|
-
* Получает базовые значения.
|
|
192
|
-
*/
|
|
193
|
-
protected makeValue(): this {
|
|
194
|
-
this.states?.forEach(({
|
|
195
|
-
index,
|
|
196
|
-
item
|
|
197
|
-
}) => {
|
|
198
|
-
this.data?.[index]?.value.push(...this.toValue(item?.value))
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
return this
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Gets all possible values.
|
|
206
|
-
*
|
|
207
|
-
* Получает всех возможных значения.
|
|
208
|
-
* @param state basic values/ базовые значения
|
|
209
|
-
*/
|
|
210
|
-
protected makeValueAll(state = this.states): this {
|
|
211
|
-
state?.forEach(({
|
|
212
|
-
index,
|
|
213
|
-
item,
|
|
214
|
-
state
|
|
215
|
-
}) => {
|
|
216
|
-
if (index in this.data) {
|
|
217
|
-
const value = this.toValue(item?.value)
|
|
218
|
-
this.data?.[index]?.valueAll.push(...value)
|
|
219
|
-
|
|
220
|
-
if (state && value.indexOf(true) !== -1) {
|
|
221
|
-
this.makeValueAll(state)
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
})
|
|
225
|
-
|
|
226
|
-
return this
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Updates values by removing duplicates and updating the style property value.
|
|
231
|
-
*
|
|
232
|
-
* Обновляет значения, удаляя все повторы и обновляя значения свойства style.
|
|
233
|
-
*/
|
|
234
|
-
protected makeValueUnique(): this {
|
|
235
|
-
forEach(this.data, (property) => {
|
|
236
|
-
property.valueAll = uniqueArray(property.valueAll)
|
|
237
|
-
|
|
238
|
-
if (!isFilled(property.value)) {
|
|
239
|
-
property.value = [true]
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (!isFilled(property.valueAll)) {
|
|
243
|
-
property.valueAll = [true]
|
|
244
|
-
}
|
|
245
|
-
})
|
|
246
|
-
|
|
247
|
-
return this
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Updates values in a map.
|
|
252
|
-
*
|
|
253
|
-
* Обновляет значения в карте.
|
|
254
|
-
* @param states basic values/ базовые значения
|
|
255
|
-
* @param parent
|
|
256
|
-
*/
|
|
257
|
-
protected makeValueState(
|
|
258
|
-
states = this.states,
|
|
259
|
-
parent?: DesignStructureItem['state']
|
|
260
|
-
): this {
|
|
261
|
-
states?.forEach(({
|
|
262
|
-
index,
|
|
263
|
-
item,
|
|
264
|
-
state
|
|
265
|
-
}) => {
|
|
266
|
-
const structure = this.data[index]
|
|
267
|
-
|
|
268
|
-
if (structure) {
|
|
269
|
-
if (parent) {
|
|
270
|
-
const value: DesignStructureItemSub = {
|
|
271
|
-
name: structure.name,
|
|
272
|
-
index,
|
|
273
|
-
value: this.toValue(item.value),
|
|
274
|
-
state: []
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
parent.push(value)
|
|
278
|
-
this.makeValueState(state, value.state)
|
|
279
|
-
|
|
280
|
-
if (
|
|
281
|
-
value.state.length > 0
|
|
282
|
-
&& value.value.length === 0
|
|
283
|
-
) {
|
|
284
|
-
value.value.push(true)
|
|
285
|
-
}
|
|
286
|
-
} else {
|
|
287
|
-
this.makeValueState(state, this.data[index]?.state)
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
})
|
|
291
|
-
|
|
292
|
-
return this
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Returns a formatted string with the property name.
|
|
297
|
-
*
|
|
298
|
-
* Возвращает отформатированную строку с названием свойства.
|
|
299
|
-
* @param item object for checking/ объект для проверки
|
|
300
|
-
* @param index property identifier/ идентификатор свойства
|
|
301
|
-
*/
|
|
302
|
-
protected toName(item: PropertyItem, index: string): string {
|
|
303
|
-
const prop = item?.[PropertyKey.prop]
|
|
304
|
-
|
|
305
|
-
return toCamelCase(
|
|
306
|
-
(typeof prop === 'string' && prop)
|
|
307
|
-
|| item?.[PropertyKey.rename]
|
|
308
|
-
|| item?.[PropertyKey.index]
|
|
309
|
-
|| index
|
|
310
|
-
)
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Returns all available values.
|
|
315
|
-
*
|
|
316
|
-
* Возвращает все доступные значения.
|
|
317
|
-
* @param properties array with all property records/ массив со всеми записями свойств
|
|
318
|
-
*/
|
|
319
|
-
protected toValue(properties?: PropertyItem['value']): DesignStructureItem['value'] {
|
|
320
|
-
if (
|
|
321
|
-
isFilled(properties)
|
|
322
|
-
&& isObjectNotArray(properties)
|
|
323
|
-
) {
|
|
324
|
-
const value: DesignStructureItem['value'] = []
|
|
325
|
-
let isTrue = false
|
|
326
|
-
|
|
327
|
-
forEach(properties, (item, name) => {
|
|
328
|
-
if (
|
|
329
|
-
!(name in this.data)
|
|
330
|
-
|| item?.[PropertyKey.prop]
|
|
331
|
-
) {
|
|
332
|
-
if (item?.[PropertyKey.variable] === PropertyType.state) {
|
|
333
|
-
value.push(name)
|
|
334
|
-
} else {
|
|
335
|
-
isTrue = true
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
})
|
|
339
|
-
|
|
340
|
-
if (isTrue) {
|
|
341
|
-
value.push(true)
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
return value
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
return [true]
|
|
348
|
-
}
|
|
349
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// export:none
|
|
2
|
-
|
|
3
|
-
import { StylesProperties } from '../Styles/StylesProperties'
|
|
4
|
-
import { DesignStructureItemAbstract } from './DesignStructureItemAbstract'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Engine for compiling component-specific styles from design system tokens.
|
|
8
|
-
* It coordinates the transformation of structural metadata into CSS-in-JS style rules using the global theme environment.
|
|
9
|
-
*
|
|
10
|
-
* Движок для компиляции специфичных для компонента стилей из токенов дизайн-системы.
|
|
11
|
-
* Координирует преобразование структурных метаданных в правила стилей CSS-in-JS с использованием глобального тематического окружения.
|
|
12
|
-
*/
|
|
13
|
-
export class DesignStructureStyles extends DesignStructureItemAbstract<string[]> {
|
|
14
|
-
protected data: string[]
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Constructor for DesignStructureStyles.
|
|
18
|
-
*
|
|
19
|
-
* Конструктор для DesignStructureStyles.
|
|
20
|
-
* @param component component name for which styles are being compiled / имя компонента, для которого компилируются стили
|
|
21
|
-
*/
|
|
22
|
-
constructor(
|
|
23
|
-
component: string
|
|
24
|
-
) {
|
|
25
|
-
super(component)
|
|
26
|
-
this.data = this.make()
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Performing transformation.
|
|
31
|
-
*
|
|
32
|
-
* Выполнение преобразования.
|
|
33
|
-
*/
|
|
34
|
-
make(): string[] {
|
|
35
|
-
if (this.items) {
|
|
36
|
-
return [
|
|
37
|
-
'& {',
|
|
38
|
-
...(new StylesProperties(' ', this.items)).make(),
|
|
39
|
-
'}'
|
|
40
|
-
]
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return []
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { ServerStorage } from '@dxtmisha/functional-basic'
|
|
2
|
-
|
|
3
|
-
import { DesignTypesAi } from './DesignTypesAi'
|
|
4
|
-
import { DesignTypesDescription } from './DesignTypesDescription'
|
|
5
|
-
import { DesignTypesMake } from './DesignTypesMake'
|
|
6
|
-
import { DesignTypesMcp } from './DesignTypesMcp'
|
|
7
|
-
import { DesignTypesPrompts } from './DesignTypesPrompts'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Engine for generating compressed and AI-optimized TypeScript type definitions.
|
|
11
|
-
* It scans the build output for declaration files, sanitizes them, and uses AI to produce a minimal, context-rich type library for use in automated coding assistants.
|
|
12
|
-
*
|
|
13
|
-
* Движок для генерации сжатых и оптимизированных для ИИ определений типов TypeScript.
|
|
14
|
-
* Сканирует выходные данные сборки на наличие файлов деклараций, очищает их и использует ИИ для создания минимальной, насыщенной контекстом библиотеки типов для использования в автоматизированных помощниках по кодированию.
|
|
15
|
-
*/
|
|
16
|
-
export class DesignTypes {
|
|
17
|
-
/** Instance of DesignTypesAi for AI interactions / Экземпляр DesignTypesAi для ИИ взаимодействия */
|
|
18
|
-
protected readonly ai: DesignTypesAi
|
|
19
|
-
|
|
20
|
-
/** Instance of DesignTypesDescription for description generation / Экземпляр DesignTypesDescription для генерации описания */
|
|
21
|
-
protected readonly description: DesignTypesDescription
|
|
22
|
-
|
|
23
|
-
/** Instance of DesignTypesMake for declaration file processing / Экземпляр DesignTypesMake для обработки файлов деклараций */
|
|
24
|
-
protected readonly makeTypes: DesignTypesMake
|
|
25
|
-
|
|
26
|
-
/** Instance of DesignTypesMcp for MCP server resources processing / Экземпляр DesignTypesMcp для обработки ресурсов MCP-сервера */
|
|
27
|
-
protected readonly mcp: DesignTypesMcp
|
|
28
|
-
|
|
29
|
-
/** Instance of DesignTypesPrompts for prompt file processing / Экземпляр DesignTypesPrompts для обработки файлов промптов */
|
|
30
|
-
protected readonly prompts: DesignTypesPrompts
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Constructor for DesignTypes.
|
|
34
|
-
*
|
|
35
|
-
* Конструктор для DesignTypes.
|
|
36
|
-
* @param dir input directory path containing declaration files / входной путь к директории, содержащей файлы деклараций
|
|
37
|
-
* @param promptsDir input directory path containing prompt files / входной путь к директории, содержащей файлы промптов
|
|
38
|
-
* @param isRaw flag disabling AI processing to create raw types and empty description / флаг отключения ИИ обработки для создания сырых типов и пустого описания
|
|
39
|
-
*/
|
|
40
|
-
constructor(
|
|
41
|
-
protected readonly dir: string = 'dist',
|
|
42
|
-
protected readonly promptsDir: string = 'ai-resources',
|
|
43
|
-
protected readonly isRaw: boolean = false
|
|
44
|
-
) {
|
|
45
|
-
ServerStorage.setErrorStatus(true)
|
|
46
|
-
|
|
47
|
-
this.ai = new DesignTypesAi(this.dir, this.isRaw)
|
|
48
|
-
this.makeTypes = new DesignTypesMake(this.ai)
|
|
49
|
-
this.prompts = new DesignTypesPrompts(this.promptsDir, this.ai)
|
|
50
|
-
this.description = new DesignTypesDescription(this.ai, this.makeTypes, this.prompts, this.isRaw)
|
|
51
|
-
this.mcp = new DesignTypesMcp(this.ai, this.prompts, this.isRaw)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Main method to execute the type generation process.
|
|
56
|
-
*
|
|
57
|
-
* Основной метод для выполнения процесса генерации типов.
|
|
58
|
-
* @returns current instance / текущий экземпляр
|
|
59
|
-
*/
|
|
60
|
-
async make(): Promise<this> {
|
|
61
|
-
console.log('DesignTypes: making AI types...')
|
|
62
|
-
|
|
63
|
-
await this.makeTypes.make()
|
|
64
|
-
await this.prompts.make()
|
|
65
|
-
await this.description.make()
|
|
66
|
-
await this.mcp.make()
|
|
67
|
-
|
|
68
|
-
console.log('DesignTypes: AI types saved.')
|
|
69
|
-
|
|
70
|
-
return this
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Generates type definitions by combining processed files from ai-types-list directory without running AI.
|
|
75
|
-
*
|
|
76
|
-
* Генерирует определения типов путем объединения обработанных файлов из директории ai-types-list без запуска ИИ.
|
|
77
|
-
* @returns current instance / текущий экземпляр
|
|
78
|
-
*/
|
|
79
|
-
async makeSave(): Promise<this> {
|
|
80
|
-
console.log('DesignTypes: saving AI types from list...')
|
|
81
|
-
|
|
82
|
-
this.makeTypes.makeSave()
|
|
83
|
-
|
|
84
|
-
if (!this.description.is()) {
|
|
85
|
-
await this.description.make()
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
await this.mcp.make()
|
|
89
|
-
|
|
90
|
-
console.log('DesignTypes: AI types saved.')
|
|
91
|
-
|
|
92
|
-
return this
|
|
93
|
-
}
|
|
94
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { getPackageJson } from '../../functions/getPackageJson'
|
|
2
|
-
import { useAi } from '../../composables/useAi'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Class for handling low-level AI interactions, directory configuration, and prompt execution.
|
|
6
|
-
*
|
|
7
|
-
* Класс для низкоуровневого взаимодействия с ИИ, конфигурации директории и выполнения промптов.
|
|
8
|
-
*/
|
|
9
|
-
export class DesignTypesAi {
|
|
10
|
-
/** Cached project name / Кэшированное название проекта */
|
|
11
|
-
protected projectName: string
|
|
12
|
-
|
|
13
|
-
/** Array of directory path segments / Массив сегментов пути директории */
|
|
14
|
-
protected readonly dirArray: string[]
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Constructor for DesignTypesAi.
|
|
18
|
-
*
|
|
19
|
-
* Конструктор для DesignTypesAi.
|
|
20
|
-
* @param dir input directory path containing declaration files / входной путь к директории, содержащей файлы деклараций
|
|
21
|
-
* @param isRaw flag disabling AI processing / флаг отключения ИИ обработки
|
|
22
|
-
*/
|
|
23
|
-
constructor(
|
|
24
|
-
protected readonly dir: string = 'dist',
|
|
25
|
-
protected readonly isRaw: boolean = false
|
|
26
|
-
) {
|
|
27
|
-
this.dirArray = this.dir.split('/')
|
|
28
|
-
this.projectName = getPackageJson()?.name ?? 'none'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Returns the array of directory path segments.
|
|
33
|
-
*
|
|
34
|
-
* Возвращает массив сегментов пути директории.
|
|
35
|
-
* @returns directory path segments / сегменты пути директории
|
|
36
|
-
*/
|
|
37
|
-
getDirArray(): string[] {
|
|
38
|
-
return this.dirArray
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Returns the project name from package.json.
|
|
43
|
-
*
|
|
44
|
-
* Возвращает название проекта из package.json.
|
|
45
|
-
* @returns project name or 'none' / название проекта или 'none'
|
|
46
|
-
*/
|
|
47
|
-
getProjectName(): string {
|
|
48
|
-
return this.projectName
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Sends content and a prompt to the AI for processing.
|
|
53
|
-
*
|
|
54
|
-
* Отправляет контент и промпт ИИ для обработки.
|
|
55
|
-
* @param content content for processing / контент для обработки
|
|
56
|
-
* @param prompt instructions for the AI / инструкции для ИИ
|
|
57
|
-
* @param code code to optimize / код для оптимизации
|
|
58
|
-
* @returns AI generated content or undefined / сгенерированный ИИ контент или undefined
|
|
59
|
-
*/
|
|
60
|
-
async toAi(
|
|
61
|
-
content: string,
|
|
62
|
-
prompt: string,
|
|
63
|
-
code?: string
|
|
64
|
-
): Promise<string | undefined> {
|
|
65
|
-
if (this.isRaw) {
|
|
66
|
-
return undefined
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const ai = useAi()
|
|
70
|
-
|
|
71
|
-
if (ai) {
|
|
72
|
-
if (code) {
|
|
73
|
-
ai.addPrompt(
|
|
74
|
-
`File JS Code (SUPPLEMENTARY REFERENCE & CONTEXT ONLY):\n`
|
|
75
|
-
+ `The following JavaScript code is provided STRICTLY as supplementary background context to give a full picture of implementation details and logic.\n`
|
|
76
|
-
+ `CRITICAL RESTRICTION: You MUST NOT treat or use this data as "File Content". Do NOT generate, return, or include any classes, methods, functions, or entities from "File JS Code" in the output unless they are explicitly present in "File Content".\n\n`
|
|
77
|
-
+ '```\n'
|
|
78
|
-
+ `${code}\n`
|
|
79
|
-
+ '```'
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
ai.addPrompt('You are a world-class senior developer and an exceptional technical writer.')
|
|
84
|
-
ai.addPrompt('CRITICAL DIRECTIVE: No data stored in history, previous chat messages, or prior conversation context must influence the result. Process strictly and exclusively the data provided in the text below.')
|
|
85
|
-
ai.addPrompt(
|
|
86
|
-
`TASK INSTRUCTIONS & GOAL:\n`
|
|
87
|
-
+ `The following are the exact rules, requirements, and execution instructions for processing the file content:\n\n`
|
|
88
|
-
+ `${prompt}`
|
|
89
|
-
)
|
|
90
|
-
ai.addPrompt(
|
|
91
|
-
`File Content (PRIMARY DATA TO PROCESS):\n`
|
|
92
|
-
+ `The following is the primary target file content that you MUST process according to the instructions in the prompt above:\n`
|
|
93
|
-
+ '```\n'
|
|
94
|
-
+ `${content}\n`
|
|
95
|
-
+ '```'
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
const generate = await ai.generate('go!')
|
|
99
|
-
|
|
100
|
-
if (generate) {
|
|
101
|
-
return generate
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return undefined
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Sends content and a prompt to the AI for processing and parses the resulting JSON response.
|
|
110
|
-
*
|
|
111
|
-
* Отправляет контент и промпт ИИ для обработки и парсит полученный JSON-ответ.
|
|
112
|
-
* @param content content for processing / контент для обработки
|
|
113
|
-
* @param prompt instructions for the AI / инструкции для ИИ
|
|
114
|
-
* @param code code to optimize / код для оптимизации
|
|
115
|
-
* @returns parsed JSON object or undefined / распарсенный JSON объект или undefined
|
|
116
|
-
*/
|
|
117
|
-
async toAiJson<T>(
|
|
118
|
-
content: string,
|
|
119
|
-
prompt: string,
|
|
120
|
-
code?: string
|
|
121
|
-
): Promise<T | undefined> {
|
|
122
|
-
const generate = await this.toAi(content, prompt, code)
|
|
123
|
-
|
|
124
|
-
if (generate) {
|
|
125
|
-
try {
|
|
126
|
-
const cleaned = generate.replace(/```json|```/g, '').trim()
|
|
127
|
-
return JSON.parse(cleaned) as T
|
|
128
|
-
} catch {
|
|
129
|
-
return undefined
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return undefined
|
|
134
|
-
}
|
|
135
|
-
}
|