@yahoo/uds 3.114.0-beta.2 → 3.114.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/dist/automated-config/dist/generated/autoVariants.cjs +3 -0
- package/dist/automated-config/dist/generated/autoVariants.d.cts +3 -0
- package/dist/automated-config/dist/generated/autoVariants.d.ts +3 -0
- package/dist/automated-config/dist/generated/autoVariants.js +3 -0
- package/dist/automated-config/dist/generated/generatedConfigs.cjs +1883 -0
- package/dist/automated-config/dist/generated/generatedConfigs.d.cts +175 -1
- package/dist/automated-config/dist/generated/generatedConfigs.d.ts +175 -1
- package/dist/automated-config/dist/generated/generatedConfigs.js +1882 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.cjs +84 -0
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.cts +3 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.ts +3 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.js +84 -0
- package/dist/automated-config/dist/mapTextVariantFixtureToValue.cjs +1 -12
- package/dist/automated-config/dist/mapTextVariantFixtureToValue.js +1 -12
- package/dist/automated-config/dist/properties.cjs +58 -12
- package/dist/automated-config/dist/properties.d.cts +8 -0
- package/dist/automated-config/dist/properties.d.ts +8 -0
- package/dist/automated-config/dist/properties.js +58 -12
- package/dist/automated-config/dist/utils/getConfigVariantProperties.d.cts +2 -2
- package/dist/automated-config/dist/utils/getConfigVariantProperties.d.ts +2 -2
- package/dist/cli/commands/sync.cjs +7 -1
- package/dist/cli/commands/sync.d.cts +1 -1
- package/dist/cli/commands/sync.d.ts +1 -1
- package/dist/cli/commands/sync.js +7 -1
- package/dist/cli/commands/version.cjs +2 -0
- package/dist/cli/commands/version.d.cts +1 -1
- package/dist/cli/commands/version.d.ts +1 -1
- package/dist/cli/commands/version.js +2 -0
- package/dist/cli/dist/cli.cjs +1 -1
- package/dist/cli/dist/cli.js +1 -1
- package/dist/cli/dist/commands/editor-rules.cjs +2 -2
- package/dist/cli/dist/commands/editor-rules.js +2 -2
- package/dist/cli/dist/utils/rules/config.cjs +1 -1
- package/dist/cli/dist/utils/rules/config.js +1 -1
- package/dist/cli/runner.cjs +2 -11
- package/dist/cli/runner.js +2 -11
- package/dist/components/Scrim.cjs +28 -0
- package/dist/components/Scrim.d.cts +14 -0
- package/dist/components/Scrim.d.ts +14 -0
- package/dist/components/Scrim.js +26 -0
- package/dist/components/client/BottomSheet/BottomSheet.cjs +209 -0
- package/dist/components/client/BottomSheet/BottomSheet.d.cts +77 -0
- package/dist/components/client/BottomSheet/BottomSheet.d.ts +77 -0
- package/dist/components/client/BottomSheet/BottomSheet.js +207 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.cjs +26 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.d.cts +15 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.d.ts +15 -0
- package/dist/components/client/BottomSheet/BottomSheetContent.js +24 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.cjs +15 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.d.cts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.d.ts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetDismiss.js +13 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.cjs +30 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.d.cts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.d.ts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetHandle.js +28 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.cjs +42 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.d.cts +18 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.d.ts +18 -0
- package/dist/components/client/BottomSheet/BottomSheetHeader.js +40 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.cjs +21 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.d.cts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.d.ts +19 -0
- package/dist/components/client/BottomSheet/BottomSheetProvider.js +19 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.cjs +15 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.d.cts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.d.ts +12 -0
- package/dist/components/client/BottomSheet/BottomSheetTrigger.js +13 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.cjs +32 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.d.cts +22 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.d.ts +22 -0
- package/dist/components/client/BottomSheet/UDSBottomSheetConfigProvider.js +29 -0
- package/dist/components/client/BottomSheet/index.cjs +22 -0
- package/dist/components/client/BottomSheet/index.d.cts +10 -0
- package/dist/components/client/BottomSheet/index.d.ts +10 -0
- package/dist/components/client/BottomSheet/index.js +12 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.cjs +188 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.d.cts +44 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.d.ts +44 -0
- package/dist/components/client/BottomSheet/useBottomSheetDrag.js +185 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.cjs +138 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.d.cts +46 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.d.ts +46 -0
- package/dist/components/client/BottomSheet/useBottomSheetSnapModel.js +135 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.cjs +34 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.d.cts +38 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.d.ts +38 -0
- package/dist/components/client/BottomSheet/useBottomSheetStore.js +31 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.cjs +17 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.d.cts +13 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.d.ts +13 -0
- package/dist/components/client/BottomSheet/useBottomSheetStoreInternal.js +15 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.cjs +89 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.d.cts +34 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.d.ts +34 -0
- package/dist/components/client/BottomSheet/useExpansionMargins.js +87 -0
- package/dist/components/client/BottomSheet/useViewportHeight.cjs +32 -0
- package/dist/components/client/BottomSheet/useViewportHeight.d.cts +9 -0
- package/dist/components/client/BottomSheet/useViewportHeight.d.ts +9 -0
- package/dist/components/client/BottomSheet/useViewportHeight.js +30 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.cjs +48 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.d.cts +10 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.d.ts +10 -0
- package/dist/components/client/BottomSheet/useVirtualKeyboard.js +46 -0
- package/dist/components/client/BottomSheet/utils.cjs +128 -0
- package/dist/components/client/BottomSheet/utils.d.cts +61 -0
- package/dist/components/client/BottomSheet/utils.d.ts +61 -0
- package/dist/components/client/BottomSheet/utils.js +118 -0
- package/dist/components/client/Menu/Menu.Content.cjs +1 -1
- package/dist/components/client/Menu/Menu.Content.js +1 -1
- package/dist/components/client/Menu/Menu.ItemCheckbox.d.cts +1 -1
- package/dist/components/client/Menu/Menu.ItemCheckbox.d.ts +1 -1
- package/dist/components/client/Menu/Menu.index.d.cts +1 -1
- package/dist/components/client/index.cjs +16 -0
- package/dist/components/client/index.d.cts +10 -1
- package/dist/components/client/index.d.ts +10 -1
- package/dist/components/client/index.js +9 -1
- package/dist/components/client/providers/UDSConfigProvider.cjs +10 -6
- package/dist/components/client/providers/UDSConfigProvider.d.cts +1 -0
- package/dist/components/client/providers/UDSConfigProvider.d.ts +1 -0
- package/dist/components/client/providers/UDSConfigProvider.js +10 -6
- package/dist/components/index.cjs +24 -0
- package/dist/components/index.d.cts +9 -1
- package/dist/components/index.d.ts +9 -1
- package/dist/components/index.js +17 -1
- package/dist/config/dist/index.cjs +110 -2
- package/dist/config/dist/index.js +110 -2
- package/dist/fixtures/dist/index.cjs +103 -0
- package/dist/fixtures/dist/index.d.cts +3 -2
- package/dist/fixtures/dist/index.d.ts +3 -2
- package/dist/fixtures/dist/index.js +103 -1
- package/dist/fixtures/index.cjs +1 -0
- package/dist/fixtures/index.d.cts +2 -2
- package/dist/fixtures/index.d.ts +2 -2
- package/dist/fixtures/index.js +2 -2
- package/dist/index.cjs +20 -2
- package/dist/index.d.cts +12 -5
- package/dist/index.d.ts +12 -5
- package/dist/index.js +11 -3
- package/dist/runtime/bottomSheetConfig.cjs +11 -0
- package/dist/runtime/bottomSheetConfig.d.cts +15 -0
- package/dist/runtime/bottomSheetConfig.d.ts +15 -0
- package/dist/runtime/bottomSheetConfig.js +9 -0
- package/dist/runtime/index.cjs +2 -0
- package/dist/runtime/index.d.cts +2 -1
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.js +2 -1
- package/dist/runtime/udsConfig.cjs +2 -0
- package/dist/runtime/udsConfig.d.cts +2 -0
- package/dist/runtime/udsConfig.d.ts +2 -0
- package/dist/runtime/udsConfig.js +2 -0
- package/dist/styles/styler.d.cts +33 -30
- package/dist/styles/styler.d.ts +33 -30
- package/dist/styles/variants.cjs +278 -278
- package/dist/styles/variants.d.cts +9 -0
- package/dist/styles/variants.d.ts +9 -0
- package/dist/styles/variants.js +278 -278
- package/dist/tailwind/dist/commands/generateComponentData.cjs +31 -33
- package/dist/tailwind/dist/commands/generateComponentData.d.ts +1 -1
- package/dist/tailwind/dist/commands/generateComponentData.js +31 -33
- package/dist/tailwind/dist/commands/generatePurgeCSSData.d.ts +1 -1
- package/dist/tailwind/dist/commands/purge.cjs +4 -3
- package/dist/tailwind/dist/commands/purge.d.ts +1 -1
- package/dist/tailwind/dist/commands/purge.js +4 -3
- package/dist/tailwind/dist/index.d.cts +0 -1
- package/dist/tailwind/dist/index.d.ts +3 -5
- package/dist/tailwind/dist/purger/legacy/purgeCSS.cjs +3 -4
- package/dist/tailwind/dist/purger/legacy/purgeCSS.js +3 -4
- package/dist/tailwind/dist/purger/optimized/ast/expressions.cjs +125 -122
- package/dist/tailwind/dist/purger/optimized/ast/expressions.js +125 -122
- package/dist/tailwind/dist/purger/optimized/ast/jsx.cjs +8 -1
- package/dist/tailwind/dist/purger/optimized/ast/jsx.js +8 -1
- package/dist/tailwind/dist/purger/optimized/purge.cjs +10 -11
- package/dist/tailwind/dist/purger/optimized/purge.js +9 -10
- package/dist/tailwind/dist/purger/optimized/purgeFromCode.cjs +127 -232
- package/dist/tailwind/dist/purger/optimized/purgeFromCode.js +127 -232
- package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.cjs +262 -330
- package/dist/tailwind/dist/purger/optimized/utils/componentAnalyzer.js +262 -329
- package/dist/tailwind/dist/purger/optimized/utils/files.cjs +3 -4
- package/dist/tailwind/dist/purger/optimized/utils/files.js +3 -4
- package/dist/tailwind/dist/purger/optimized/utils/safelist.cjs +21 -13
- package/dist/tailwind/dist/purger/optimized/utils/safelist.js +21 -13
- package/dist/tailwind/dist/tailwind/plugins/components.cjs +2 -0
- package/dist/tailwind/dist/tailwind/plugins/components.js +3 -1
- package/dist/tailwind/dist/tailwind/plugins/typography.cjs +13 -41
- package/dist/tailwind/dist/tailwind/plugins/typography.js +13 -41
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.cjs +2 -4
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.d.cts +1 -10
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.d.ts +1 -10
- package/dist/tailwind/dist/tailwind/utils/composeTailwindPlugins.js +2 -4
- package/dist/tailwind/dist/utils/tsMorph.cjs +1 -1
- package/dist/tokens/automation/configs/index.cjs +2 -0
- package/dist/tokens/automation/configs/index.d.cts +2 -2
- package/dist/tokens/automation/configs/index.d.ts +2 -2
- package/dist/tokens/automation/configs/index.js +2 -2
- package/dist/tokens/automation/index.cjs +2 -0
- package/dist/tokens/automation/index.d.cts +2 -2
- package/dist/tokens/automation/index.d.ts +2 -2
- package/dist/tokens/automation/index.js +2 -2
- package/dist/tokens/index.cjs +2 -0
- package/dist/tokens/index.d.cts +3 -3
- package/dist/tokens/index.d.ts +3 -3
- package/dist/tokens/index.js +2 -2
- package/dist/tokens/types.d.cts +2 -2
- package/dist/tokens/types.d.ts +2 -2
- package/dist/types/dist/index.d.cts +76 -1
- package/dist/types/dist/index.d.ts +76 -1
- package/dist/uds/generated/componentData.cjs +1187 -961
- package/dist/uds/generated/componentData.js +1111 -939
- package/dist/uds/generated/tailwindPurge.cjs +57 -29
- package/dist/uds/generated/tailwindPurge.js +57 -29
- package/dist/uds/package.cjs +4 -10
- package/dist/uds/package.js +4 -10
- package/package.json +4 -7
- package/dist/cli/dist/lib/logger.cjs +0 -66
- package/dist/cli/dist/lib/logger.js +0 -66
- package/dist/tailwind/dist/commands/css.cjs +0 -79
- package/dist/tailwind/dist/commands/css.d.ts +0 -3
- package/dist/tailwind/dist/commands/css.helpers.cjs +0 -32
- package/dist/tailwind/dist/commands/css.helpers.js +0 -28
- package/dist/tailwind/dist/commands/css.js +0 -79
- package/dist/tailwind/dist/css/generate.cjs +0 -120
- package/dist/tailwind/dist/css/generate.d.cts +0 -30
- package/dist/tailwind/dist/css/generate.d.ts +0 -31
- package/dist/tailwind/dist/css/generate.helpers.cjs +0 -112
- package/dist/tailwind/dist/css/generate.helpers.js +0 -100
- package/dist/tailwind/dist/css/generate.js +0 -115
- package/dist/tailwind/dist/css/postcss.cjs +0 -35
- package/dist/tailwind/dist/css/postcss.helpers.cjs +0 -27
- package/dist/tailwind/dist/css/postcss.helpers.js +0 -26
- package/dist/tailwind/dist/css/postcss.js +0 -35
- package/dist/tailwind/dist/css/runner.cjs +0 -278
- package/dist/tailwind/dist/css/runner.helpers.cjs +0 -26
- package/dist/tailwind/dist/css/runner.helpers.js +0 -23
- package/dist/tailwind/dist/css/runner.js +0 -275
- package/dist/tailwind/dist/css/theme.cjs +0 -12
- package/dist/tailwind/dist/css/theme.d.cts +0 -66
- package/dist/tailwind/dist/css/theme.d.ts +0 -66
- package/dist/tailwind/dist/css/theme.js +0 -11
- package/dist/tailwind/dist/css/utils.cjs +0 -234
- package/dist/tailwind/dist/css/utils.js +0 -223
- package/dist/tailwind/dist/utils/optimizeCSS.cjs +0 -405
- package/dist/tailwind/dist/utils/optimizeCSS.js +0 -403
- package/dist/tailwind/dist/utils/postcssPreserveVars.cjs +0 -67
- package/dist/tailwind/dist/utils/postcssPreserveVars.js +0 -65
- package/generated/componentData.json +0 -2397
- package/generated/tailwindPurge.ts +0 -4560
|
@@ -23,45 +23,43 @@ const makeGenerateComponentDataCommand = (getContext) => ({
|
|
|
23
23
|
require_print.print("Scanning components in:", componentsDir);
|
|
24
24
|
const componentPaths = await require_componentAnalyzer.scanComponentFiles(componentsDir);
|
|
25
25
|
require_print.print(`Found ${componentPaths.size} components`);
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
}));
|
|
36
|
-
const componentData = Object.fromEntries(componentDataEntries.filter((entry) => Boolean(entry)));
|
|
26
|
+
const componentData = {};
|
|
27
|
+
for (const [name, filePath] of componentPaths) try {
|
|
28
|
+
project.addSourceFileAtPath(filePath);
|
|
29
|
+
const info = require_componentAnalyzer.analyzeComponent(project, filePath);
|
|
30
|
+
if (info) componentData[name] = serializeComponentInfo(info);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.warn(`Warning: Could not analyze ${name}:`, error);
|
|
33
|
+
}
|
|
37
34
|
(0, node_fs.writeFileSync)(outputFile, JSON.stringify(componentData, null, 2));
|
|
38
35
|
require_print.print(`Generated component data for ${Object.keys(componentData).length} components`);
|
|
39
36
|
require_print.print(`Output written to: ${outputFile}`);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
37
|
+
let totalDefaults = 0;
|
|
38
|
+
let totalLiterals = 0;
|
|
39
|
+
let totalInternalComponents = 0;
|
|
40
|
+
for (const comp of Object.values(componentData)) {
|
|
41
|
+
totalDefaults += Object.keys(comp.defaultProps).length;
|
|
42
|
+
totalLiterals += Object.keys(comp.getStylesLiterals).length;
|
|
43
|
+
totalInternalComponents += comp.internalComponents.length;
|
|
44
|
+
}
|
|
49
45
|
require_print.print("\nStats:");
|
|
50
|
-
require_print.print(` Default props: ${
|
|
51
|
-
require_print.print(` getStyles literals: ${
|
|
52
|
-
require_print.print(` Internal component refs: ${
|
|
46
|
+
require_print.print(` Default props: ${totalDefaults}`);
|
|
47
|
+
require_print.print(` getStyles literals: ${totalLiterals}`);
|
|
48
|
+
require_print.print(` Internal component refs: ${totalInternalComponents}`);
|
|
53
49
|
}
|
|
54
50
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
function serializeComponentInfo(info) {
|
|
52
|
+
return {
|
|
53
|
+
name: info.name,
|
|
54
|
+
defaultProps: Object.fromEntries(info.defaultProps),
|
|
55
|
+
getStylesLiterals: Object.fromEntries(info.getStylesLiterals),
|
|
56
|
+
cxLiterals: info.cxLiterals,
|
|
57
|
+
internalComponents: info.internalComponents,
|
|
58
|
+
internalComponentProps: Object.fromEntries(Array.from(info.internalComponentProps.entries()).map(([key, propsMap]) => [key, Object.fromEntries(propsMap)])),
|
|
59
|
+
propToVariantKeys: Object.fromEntries(info.propToVariantKeys),
|
|
60
|
+
motionVarPrefixes: info.motionVarPrefixes
|
|
61
|
+
};
|
|
62
|
+
}
|
|
65
63
|
|
|
66
64
|
//#endregion
|
|
67
65
|
exports.makeGenerateComponentDataCommand = makeGenerateComponentDataCommand;
|
|
@@ -22,45 +22,43 @@ const makeGenerateComponentDataCommand = (getContext) => ({
|
|
|
22
22
|
print("Scanning components in:", componentsDir);
|
|
23
23
|
const componentPaths = await scanComponentFiles(componentsDir);
|
|
24
24
|
print(`Found ${componentPaths.size} components`);
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
}));
|
|
35
|
-
const componentData = Object.fromEntries(componentDataEntries.filter((entry) => Boolean(entry)));
|
|
25
|
+
const componentData = {};
|
|
26
|
+
for (const [name, filePath] of componentPaths) try {
|
|
27
|
+
project.addSourceFileAtPath(filePath);
|
|
28
|
+
const info = analyzeComponent(project, filePath);
|
|
29
|
+
if (info) componentData[name] = serializeComponentInfo(info);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.warn(`Warning: Could not analyze ${name}:`, error);
|
|
32
|
+
}
|
|
36
33
|
writeFileSync(outputFile, JSON.stringify(componentData, null, 2));
|
|
37
34
|
print(`Generated component data for ${Object.keys(componentData).length} components`);
|
|
38
35
|
print(`Output written to: ${outputFile}`);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
36
|
+
let totalDefaults = 0;
|
|
37
|
+
let totalLiterals = 0;
|
|
38
|
+
let totalInternalComponents = 0;
|
|
39
|
+
for (const comp of Object.values(componentData)) {
|
|
40
|
+
totalDefaults += Object.keys(comp.defaultProps).length;
|
|
41
|
+
totalLiterals += Object.keys(comp.getStylesLiterals).length;
|
|
42
|
+
totalInternalComponents += comp.internalComponents.length;
|
|
43
|
+
}
|
|
48
44
|
print("\nStats:");
|
|
49
|
-
print(` Default props: ${
|
|
50
|
-
print(` getStyles literals: ${
|
|
51
|
-
print(` Internal component refs: ${
|
|
45
|
+
print(` Default props: ${totalDefaults}`);
|
|
46
|
+
print(` getStyles literals: ${totalLiterals}`);
|
|
47
|
+
print(` Internal component refs: ${totalInternalComponents}`);
|
|
52
48
|
}
|
|
53
49
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
function serializeComponentInfo(info) {
|
|
51
|
+
return {
|
|
52
|
+
name: info.name,
|
|
53
|
+
defaultProps: Object.fromEntries(info.defaultProps),
|
|
54
|
+
getStylesLiterals: Object.fromEntries(info.getStylesLiterals),
|
|
55
|
+
cxLiterals: info.cxLiterals,
|
|
56
|
+
internalComponents: info.internalComponents,
|
|
57
|
+
internalComponentProps: Object.fromEntries(Array.from(info.internalComponentProps.entries()).map(([key, propsMap]) => [key, Object.fromEntries(propsMap)])),
|
|
58
|
+
propToVariantKeys: Object.fromEntries(info.propToVariantKeys),
|
|
59
|
+
motionVarPrefixes: info.motionVarPrefixes
|
|
60
|
+
};
|
|
61
|
+
}
|
|
64
62
|
|
|
65
63
|
//#endregion
|
|
66
64
|
export { makeGenerateComponentDataCommand };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
const require_analytics = require('../../../cli/dist/utils/analytics.cjs');
|
|
2
3
|
const require_print = require('../../../cli/dist/lib/print.cjs');
|
|
3
4
|
const require_spinner = require('../../../cli/dist/lib/spinner.cjs');
|
|
4
|
-
const require_purge = require('../purger/optimized/purge.cjs');
|
|
5
5
|
const require_purgeCSS = require('../purger/legacy/purgeCSS.cjs');
|
|
6
|
+
const require_purge = require('../purger/optimized/purge.cjs');
|
|
6
7
|
|
|
7
8
|
//#region ../tailwind/dist/commands/purge.js
|
|
8
9
|
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
@@ -27,7 +28,7 @@ const makePurgeCommand = (getContext) => ({
|
|
|
27
28
|
require_print.print(` Files scanned: ${result.stats.filesScanned}`);
|
|
28
29
|
require_print.print(` Spreads traced: ${result.stats.spreadsTraced}`);
|
|
29
30
|
require_print.print(` Expressions resolved: ${result.stats.expressionsResolved}`);
|
|
30
|
-
return;
|
|
31
|
+
return await require_analytics.trackEvent("purge", { optimized: true });
|
|
31
32
|
} catch (error) {
|
|
32
33
|
if (error instanceof Error) require_spinner.spinStop("❌", error.message);
|
|
33
34
|
else require_spinner.spinStop("❌", "Purging css failed! Please reach out to #uds-ask channel for support.");
|
|
@@ -42,7 +43,7 @@ const makePurgeCommand = (getContext) => ({
|
|
|
42
43
|
output: typeof output === "string" ? output : void 0
|
|
43
44
|
});
|
|
44
45
|
require_spinner.spinStop("✅", "Purging css done!");
|
|
45
|
-
return;
|
|
46
|
+
return await require_analytics.trackEvent("purge");
|
|
46
47
|
} catch (error) {
|
|
47
48
|
if (error instanceof Error) require_spinner.spinStop("❌", error.message);
|
|
48
49
|
else require_spinner.spinStop("❌", "Purging css failed! Please reach out to #uds-ask channel for support.");
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
import { trackEvent } from "../../../cli/dist/utils/analytics.js";
|
|
2
3
|
import { print } from "../../../cli/dist/lib/print.js";
|
|
3
4
|
import { spinStart, spinStop } from "../../../cli/dist/lib/spinner.js";
|
|
4
|
-
import { purgeOptimized } from "../purger/optimized/purge.js";
|
|
5
5
|
import { purge } from "../purger/legacy/purgeCSS.js";
|
|
6
|
+
import { purgeOptimized } from "../purger/optimized/purge.js";
|
|
6
7
|
|
|
7
8
|
//#region ../tailwind/dist/commands/purge.js
|
|
8
9
|
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
@@ -27,7 +28,7 @@ const makePurgeCommand = (getContext) => ({
|
|
|
27
28
|
print(` Files scanned: ${result.stats.filesScanned}`);
|
|
28
29
|
print(` Spreads traced: ${result.stats.spreadsTraced}`);
|
|
29
30
|
print(` Expressions resolved: ${result.stats.expressionsResolved}`);
|
|
30
|
-
return;
|
|
31
|
+
return await trackEvent("purge", { optimized: true });
|
|
31
32
|
} catch (error) {
|
|
32
33
|
if (error instanceof Error) spinStop("❌", error.message);
|
|
33
34
|
else spinStop("❌", "Purging css failed! Please reach out to #uds-ask channel for support.");
|
|
@@ -42,7 +43,7 @@ const makePurgeCommand = (getContext) => ({
|
|
|
42
43
|
output: typeof output === "string" ? output : void 0
|
|
43
44
|
});
|
|
44
45
|
spinStop("✅", "Purging css done!");
|
|
45
|
-
return;
|
|
46
|
+
return await trackEvent("purge");
|
|
46
47
|
} catch (error) {
|
|
47
48
|
if (error instanceof Error) spinStop("❌", error.message);
|
|
48
49
|
else spinStop("❌", "Purging css failed! Please reach out to #uds-ask channel for support.");
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
|
|
2
|
+
import "./tailwind/components/getResponsiveTextStyles.js";
|
|
3
|
+
import { WebTokens, parseTokens } from "./utils/parseTokens.js";
|
|
2
4
|
import "./commands/generateComponentData.js";
|
|
3
|
-
import "./commands/css.js";
|
|
4
5
|
import "./commands/generatePurgeCSSData.js";
|
|
5
|
-
import "./commands/purge.js";
|
|
6
|
-
import { defineTheme } from "./css/theme.js";
|
|
7
|
-
import "./tailwind/components/getResponsiveTextStyles.js";
|
|
8
|
-
import { WebTokens, parseTokens } from "./utils/parseTokens.js";
|
|
6
|
+
import "./commands/purge.js";
|
|
@@ -4,10 +4,10 @@ const require_index = require('../../../../css-tokens/dist/index.cjs');
|
|
|
4
4
|
const require_print = require('../../../../cli/dist/lib/print.cjs');
|
|
5
5
|
const require_spinner = require('../../../../cli/dist/lib/spinner.cjs');
|
|
6
6
|
const require_tsMorph = require('../../utils/tsMorph.cjs');
|
|
7
|
-
let ts_morph = require("ts-morph");
|
|
8
|
-
let node_fs = require("node:fs");
|
|
9
7
|
let node_path = require("node:path");
|
|
10
8
|
node_path = require_runtime.__toESM(node_path);
|
|
9
|
+
let node_fs = require("node:fs");
|
|
10
|
+
let ts_morph = require("ts-morph");
|
|
11
11
|
let fast_glob = require("fast-glob");
|
|
12
12
|
fast_glob = require_runtime.__toESM(fast_glob);
|
|
13
13
|
|
|
@@ -32,8 +32,7 @@ const getFiles = async (entry) => {
|
|
|
32
32
|
if (!workspaceDir) throw new Error("Workspace directory not found.");
|
|
33
33
|
return await (0, fast_glob.default)(["**/*.jsx", "**/*.tsx"], {
|
|
34
34
|
cwd: node_path.default.join(workspaceDir, entry),
|
|
35
|
-
absolute: true
|
|
36
|
-
ignore: ["**/node_modules/**"]
|
|
35
|
+
absolute: true
|
|
37
36
|
});
|
|
38
37
|
} catch {
|
|
39
38
|
throw new Error(`Couldn't find the entry directory: ${entry}. Please make sure it exists.`);
|
|
@@ -3,9 +3,9 @@ import { DARK_COLOR_MODE_CLASSNAME, LARGE_SCALE_MODE_CLASSNAME, LIGHT_COLOR_MODE
|
|
|
3
3
|
import { print } from "../../../../cli/dist/lib/print.js";
|
|
4
4
|
import { spinStart, spinStop } from "../../../../cli/dist/lib/spinner.js";
|
|
5
5
|
import { findReferencesAsJsxElements, getUsedPropsInReference } from "../../utils/tsMorph.js";
|
|
6
|
-
import { Node, Project, SyntaxKind, ts } from "ts-morph";
|
|
7
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
8
6
|
import path from "node:path";
|
|
7
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { Node, Project, SyntaxKind, ts } from "ts-morph";
|
|
9
9
|
import fg from "fast-glob";
|
|
10
10
|
|
|
11
11
|
//#region ../tailwind/dist/purger/legacy/purgeCSS.js
|
|
@@ -29,8 +29,7 @@ const getFiles = async (entry) => {
|
|
|
29
29
|
if (!workspaceDir) throw new Error("Workspace directory not found.");
|
|
30
30
|
return await fg(["**/*.jsx", "**/*.tsx"], {
|
|
31
31
|
cwd: path.join(workspaceDir, entry),
|
|
32
|
-
absolute: true
|
|
33
|
-
ignore: ["**/node_modules/**"]
|
|
32
|
+
absolute: true
|
|
34
33
|
});
|
|
35
34
|
} catch {
|
|
36
35
|
throw new Error(`Couldn't find the entry directory: ${entry}. Please make sure it exists.`);
|
|
@@ -20,171 +20,174 @@ let ts_morph = require("ts-morph");
|
|
|
20
20
|
* @param visited Set of visited nodes to prevent infinite recursion
|
|
21
21
|
* @returns Array of extracted string literal values
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
function extractStringLiterals(node, visited = /* @__PURE__ */ new Set()) {
|
|
24
24
|
if (visited.has(node)) return [];
|
|
25
25
|
visited.add(node);
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (ts_morph.Node.isConditionalExpression(node)) return [...extractStringLiterals(node.getWhenTrue(), visited), ...extractStringLiterals(node.getWhenFalse(), visited)];
|
|
31
|
-
const binaryValues = extractBinaryExpressionValues(node, visited);
|
|
32
|
-
if (binaryValues) return binaryValues;
|
|
33
|
-
const wrappedExpressionValues = extractWrappedExpressionValues(node, visited);
|
|
34
|
-
if (wrappedExpressionValues) return wrappedExpressionValues;
|
|
35
|
-
const propertyAccessValues = extractPropertyAccessValues(node, visited);
|
|
36
|
-
if (propertyAccessValues) return propertyAccessValues;
|
|
37
|
-
const elementAccessValues = extractElementAccessValues(node);
|
|
38
|
-
if (elementAccessValues) return elementAccessValues;
|
|
39
|
-
const callExpressionValues = extractCallExpressionValues(node, visited);
|
|
40
|
-
if (callExpressionValues) return callExpressionValues;
|
|
41
|
-
const identifierValues = extractIdentifierValues(node, visited);
|
|
42
|
-
if (identifierValues) return identifierValues;
|
|
43
|
-
return [];
|
|
44
|
-
};
|
|
45
|
-
const extractDirectLiteralValues = (node) => {
|
|
46
|
-
if (ts_morph.Node.isStringLiteral(node) || ts_morph.Node.isNoSubstitutionTemplateLiteral(node)) return [node.getLiteralValue()];
|
|
47
|
-
return null;
|
|
48
|
-
};
|
|
49
|
-
const extractTemplateExpressionValues = (node, visited) => {
|
|
50
|
-
if (!ts_morph.Node.isTemplateExpression(node)) return null;
|
|
51
|
-
const parts = [[node.getHead().getLiteralText()]];
|
|
52
|
-
node.getTemplateSpans().forEach((span) => {
|
|
53
|
-
const exprValues = extractStringLiterals(span.getExpression(), visited);
|
|
54
|
-
const literalText = span.getLiteral().getLiteralText();
|
|
55
|
-
parts.push(exprValues.length > 0 ? exprValues.map((value) => `${value}${literalText}`) : ["", literalText]);
|
|
56
|
-
});
|
|
57
|
-
return parts.reduce((acc, segment) => acc.flatMap((base) => segment.map((frag) => `${base}${frag}`)), [""]).filter((value) => value.length > 0);
|
|
58
|
-
};
|
|
59
|
-
const extractBinaryExpressionValues = (node, visited) => {
|
|
60
|
-
if (!ts_morph.Node.isBinaryExpression(node)) return null;
|
|
61
|
-
const operator = node.getOperatorToken().getText();
|
|
62
|
-
if (operator === "+") {
|
|
63
|
-
const left = extractStringLiterals(node.getLeft(), visited);
|
|
64
|
-
const right = extractStringLiterals(node.getRight(), visited);
|
|
65
|
-
const combined = left.flatMap((l) => right.map((r) => `${l}${r}`));
|
|
66
|
-
return combined.length > 0 ? combined : [];
|
|
26
|
+
const values = [];
|
|
27
|
+
if (ts_morph.Node.isStringLiteral(node)) {
|
|
28
|
+
values.push(node.getLiteralValue());
|
|
29
|
+
return values;
|
|
67
30
|
}
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (ts_morph.Node.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (!ts_morph.Node.isElementAccessExpression(node)) return null;
|
|
84
|
-
return extractLiteralValuesFromType(node);
|
|
85
|
-
};
|
|
86
|
-
const extractCallExpressionValues = (node, visited) => {
|
|
87
|
-
if (!ts_morph.Node.isCallExpression(node)) return null;
|
|
88
|
-
const expression = node.getExpression();
|
|
89
|
-
const fromDefinitions = ts_morph.Node.isIdentifier(expression) ? expression.getDefinitionNodes().flatMap((definition) => {
|
|
90
|
-
if (ts_morph.Node.isFunctionDeclaration(definition)) return definition.getDescendantsOfKind(ts_morph.SyntaxKind.ReturnStatement).flatMap((returnStmt) => {
|
|
91
|
-
const expression = returnStmt.getExpression();
|
|
92
|
-
return expression ? extractStringLiterals(expression, visited) : [];
|
|
93
|
-
});
|
|
94
|
-
if (ts_morph.Node.isVariableDeclaration(definition)) {
|
|
95
|
-
const initializer = definition.getInitializer();
|
|
96
|
-
return initializer ? extractFromFunctionLike(initializer, visited) : [];
|
|
31
|
+
if (ts_morph.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
32
|
+
values.push(node.getLiteralValue());
|
|
33
|
+
return values;
|
|
34
|
+
}
|
|
35
|
+
if (ts_morph.Node.isConditionalExpression(node)) {
|
|
36
|
+
values.push(...extractStringLiterals(node.getWhenTrue(), visited));
|
|
37
|
+
values.push(...extractStringLiterals(node.getWhenFalse(), visited));
|
|
38
|
+
return values;
|
|
39
|
+
}
|
|
40
|
+
if (ts_morph.Node.isBinaryExpression(node)) {
|
|
41
|
+
const op = node.getOperatorToken().getText();
|
|
42
|
+
if (op === "||" || op === "??") {
|
|
43
|
+
values.push(...extractStringLiterals(node.getLeft(), visited));
|
|
44
|
+
values.push(...extractStringLiterals(node.getRight(), visited));
|
|
45
|
+
return values;
|
|
97
46
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
47
|
+
}
|
|
48
|
+
if (ts_morph.Node.isParenthesizedExpression(node)) {
|
|
49
|
+
values.push(...extractStringLiterals(node.getExpression(), visited));
|
|
50
|
+
return values;
|
|
51
|
+
}
|
|
52
|
+
if (ts_morph.Node.isAsExpression(node)) {
|
|
53
|
+
values.push(...extractStringLiterals(node.getExpression(), visited));
|
|
54
|
+
return values;
|
|
55
|
+
}
|
|
56
|
+
if (ts_morph.Node.isPropertyAccessExpression(node)) {
|
|
57
|
+
const typeValues = extractLiteralValuesFromType(node);
|
|
58
|
+
if (typeValues.length > 0) {
|
|
59
|
+
values.push(...typeValues);
|
|
60
|
+
return values;
|
|
109
61
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
62
|
+
const expression = node.getExpression();
|
|
63
|
+
const propertyName = node.getName();
|
|
64
|
+
const baseValues = extractObjectValues(expression, visited);
|
|
65
|
+
for (const objValue of baseValues) if (typeof objValue === "object" && objValue !== null && propertyName in objValue) {
|
|
66
|
+
const propValue = objValue[propertyName];
|
|
67
|
+
if (typeof propValue === "string") values.push(propValue);
|
|
68
|
+
}
|
|
69
|
+
return values;
|
|
70
|
+
}
|
|
71
|
+
if (ts_morph.Node.isElementAccessExpression(node)) {
|
|
72
|
+
const typeValues = extractLiteralValuesFromType(node);
|
|
73
|
+
if (typeValues.length > 0) {
|
|
74
|
+
values.push(...typeValues);
|
|
75
|
+
return values;
|
|
76
|
+
}
|
|
77
|
+
return values;
|
|
78
|
+
}
|
|
79
|
+
if (ts_morph.Node.isCallExpression(node)) {
|
|
80
|
+
const expression = node.getExpression();
|
|
81
|
+
if (ts_morph.Node.isIdentifier(expression)) for (const definition of expression.getDefinitionNodes()) {
|
|
82
|
+
if (ts_morph.Node.isFunctionDeclaration(definition)) for (const returnStmt of definition.getDescendantsOfKind(ts_morph.SyntaxKind.ReturnStatement)) {
|
|
83
|
+
const returnExpr = returnStmt.getExpression();
|
|
84
|
+
if (returnExpr) values.push(...extractStringLiterals(returnExpr, visited));
|
|
85
|
+
}
|
|
86
|
+
if (ts_morph.Node.isVariableDeclaration(definition)) {
|
|
87
|
+
const initializer = definition.getInitializer();
|
|
88
|
+
if (initializer) values.push(...extractFromFunctionLike(initializer, visited));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return values;
|
|
92
|
+
}
|
|
93
|
+
if (ts_morph.Node.isIdentifier(node)) {
|
|
94
|
+
let foundInitializer = false;
|
|
95
|
+
for (const definition of node.getDefinitionNodes()) {
|
|
96
|
+
if (ts_morph.Node.isVariableDeclaration(definition)) {
|
|
97
|
+
const initializer = definition.getInitializer();
|
|
98
|
+
if (initializer) {
|
|
99
|
+
foundInitializer = true;
|
|
100
|
+
values.push(...extractStringLiterals(initializer, visited));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (ts_morph.Node.isParameterDeclaration(definition)) {
|
|
104
|
+
const initializer = definition.getInitializer();
|
|
105
|
+
if (initializer) {
|
|
106
|
+
foundInitializer = true;
|
|
107
|
+
values.push(...extractStringLiterals(initializer, visited));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (ts_morph.Node.isBindingElement(definition)) {
|
|
111
|
+
const initializer = definition.getInitializer();
|
|
112
|
+
if (initializer) {
|
|
113
|
+
foundInitializer = true;
|
|
114
|
+
values.push(...extractStringLiterals(initializer, visited));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (!foundInitializer && values.length === 0) values.push(...extractLiteralValuesFromType(node));
|
|
119
|
+
return values;
|
|
120
|
+
}
|
|
121
|
+
return values;
|
|
122
|
+
}
|
|
114
123
|
/**
|
|
115
124
|
* Extract string literals from arrow functions or function expressions
|
|
116
125
|
*/
|
|
117
|
-
|
|
126
|
+
function extractFromFunctionLike(node, visited) {
|
|
118
127
|
const values = [];
|
|
119
128
|
if (ts_morph.Node.isArrowFunction(node)) {
|
|
120
129
|
const body = node.getBody();
|
|
121
|
-
if (ts_morph.Node.isBlock(body)) body.getDescendantsOfKind(ts_morph.SyntaxKind.ReturnStatement)
|
|
130
|
+
if (ts_morph.Node.isBlock(body)) for (const returnStmt of body.getDescendantsOfKind(ts_morph.SyntaxKind.ReturnStatement)) {
|
|
122
131
|
const returnExpr = returnStmt.getExpression();
|
|
123
132
|
if (returnExpr) values.push(...extractStringLiterals(returnExpr, visited));
|
|
124
|
-
}
|
|
133
|
+
}
|
|
125
134
|
else values.push(...extractStringLiterals(body, visited));
|
|
126
|
-
} else if (ts_morph.Node.isFunctionExpression(node)) node.getDescendantsOfKind(ts_morph.SyntaxKind.ReturnStatement)
|
|
135
|
+
} else if (ts_morph.Node.isFunctionExpression(node)) for (const returnStmt of node.getDescendantsOfKind(ts_morph.SyntaxKind.ReturnStatement)) {
|
|
127
136
|
const returnExpr = returnStmt.getExpression();
|
|
128
137
|
if (returnExpr) values.push(...extractStringLiterals(returnExpr, visited));
|
|
129
|
-
}
|
|
138
|
+
}
|
|
130
139
|
return values;
|
|
131
|
-
}
|
|
140
|
+
}
|
|
132
141
|
/**
|
|
133
142
|
* Extract object literal values from an expression.
|
|
134
143
|
* Returns an array of all possible object values (for union types or indexed access).
|
|
135
144
|
*/
|
|
136
|
-
|
|
145
|
+
function extractObjectValues(node, visited) {
|
|
137
146
|
if (visited.has(node)) return [];
|
|
138
147
|
visited.add(node);
|
|
139
148
|
const values = [];
|
|
140
149
|
if (ts_morph.Node.isObjectLiteralExpression(node)) {
|
|
141
150
|
const obj = {};
|
|
142
|
-
node.getProperties().
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (nestedValues.length > 0) obj[name] = nestedValues[0];
|
|
150
|
-
}
|
|
151
|
+
for (const prop of node.getProperties()) if (ts_morph.Node.isPropertyAssignment(prop)) {
|
|
152
|
+
const name = prop.getName();
|
|
153
|
+
const init = prop.getInitializer();
|
|
154
|
+
if (init && ts_morph.Node.isStringLiteral(init)) obj[name] = init.getLiteralValue();
|
|
155
|
+
else if (init && ts_morph.Node.isObjectLiteralExpression(init)) {
|
|
156
|
+
const nestedValues = extractObjectValues(init, visited);
|
|
157
|
+
if (nestedValues.length > 0) obj[name] = nestedValues[0];
|
|
151
158
|
}
|
|
152
|
-
}
|
|
159
|
+
}
|
|
153
160
|
values.push(obj);
|
|
154
161
|
return values;
|
|
155
162
|
}
|
|
156
163
|
if (ts_morph.Node.isIdentifier(node)) {
|
|
157
|
-
node.getDefinitionNodes().
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
});
|
|
164
|
+
for (const definition of node.getDefinitionNodes()) if (ts_morph.Node.isVariableDeclaration(definition)) {
|
|
165
|
+
const initializer = definition.getInitializer();
|
|
166
|
+
if (initializer) if (ts_morph.Node.isAsExpression(initializer)) {
|
|
167
|
+
const inner = initializer.getExpression();
|
|
168
|
+
values.push(...extractObjectValues(inner, visited));
|
|
169
|
+
} else values.push(...extractObjectValues(initializer, visited));
|
|
170
|
+
}
|
|
166
171
|
return values;
|
|
167
172
|
}
|
|
168
173
|
if (ts_morph.Node.isElementAccessExpression(node)) {
|
|
169
|
-
extractObjectValues(node.getExpression(), visited)
|
|
170
|
-
|
|
171
|
-
});
|
|
174
|
+
const baseObjects = extractObjectValues(node.getExpression(), visited);
|
|
175
|
+
for (const obj of baseObjects) if (typeof obj === "object" && obj !== null) for (const value of Object.values(obj)) values.push(value);
|
|
172
176
|
return values;
|
|
173
177
|
}
|
|
174
178
|
return values;
|
|
175
|
-
}
|
|
179
|
+
}
|
|
176
180
|
/**
|
|
177
181
|
* Extract literal values from a TypeScript type (for union types like 'brand' | 'secondary')
|
|
178
182
|
*/
|
|
179
|
-
|
|
183
|
+
function extractLiteralValuesFromType(node) {
|
|
180
184
|
const values = [];
|
|
181
185
|
const nodeType = node.getType();
|
|
182
|
-
if (nodeType.isUnion())
|
|
183
|
-
if (unionMember.isStringLiteral()) values.push(unionMember.getLiteralValue());
|
|
184
|
-
});
|
|
185
|
-
else if (nodeType.isStringLiteral()) values.push(nodeType.getLiteralValue());
|
|
186
|
+
if (nodeType.isUnion()) {
|
|
187
|
+
for (const unionMember of nodeType.getUnionTypes()) if (unionMember.isStringLiteral()) values.push(unionMember.getLiteralValue());
|
|
188
|
+
} else if (nodeType.isStringLiteral()) values.push(nodeType.getLiteralValue());
|
|
186
189
|
return values;
|
|
187
|
-
}
|
|
190
|
+
}
|
|
188
191
|
|
|
189
192
|
//#endregion
|
|
190
193
|
exports.extractStringLiterals = extractStringLiterals;
|