@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
|
@@ -19,171 +19,174 @@ import { Node, SyntaxKind } from "ts-morph";
|
|
|
19
19
|
* @param visited Set of visited nodes to prevent infinite recursion
|
|
20
20
|
* @returns Array of extracted string literal values
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
function extractStringLiterals(node, visited = /* @__PURE__ */ new Set()) {
|
|
23
23
|
if (visited.has(node)) return [];
|
|
24
24
|
visited.add(node);
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (Node.isConditionalExpression(node)) return [...extractStringLiterals(node.getWhenTrue(), visited), ...extractStringLiterals(node.getWhenFalse(), visited)];
|
|
30
|
-
const binaryValues = extractBinaryExpressionValues(node, visited);
|
|
31
|
-
if (binaryValues) return binaryValues;
|
|
32
|
-
const wrappedExpressionValues = extractWrappedExpressionValues(node, visited);
|
|
33
|
-
if (wrappedExpressionValues) return wrappedExpressionValues;
|
|
34
|
-
const propertyAccessValues = extractPropertyAccessValues(node, visited);
|
|
35
|
-
if (propertyAccessValues) return propertyAccessValues;
|
|
36
|
-
const elementAccessValues = extractElementAccessValues(node);
|
|
37
|
-
if (elementAccessValues) return elementAccessValues;
|
|
38
|
-
const callExpressionValues = extractCallExpressionValues(node, visited);
|
|
39
|
-
if (callExpressionValues) return callExpressionValues;
|
|
40
|
-
const identifierValues = extractIdentifierValues(node, visited);
|
|
41
|
-
if (identifierValues) return identifierValues;
|
|
42
|
-
return [];
|
|
43
|
-
};
|
|
44
|
-
const extractDirectLiteralValues = (node) => {
|
|
45
|
-
if (Node.isStringLiteral(node) || Node.isNoSubstitutionTemplateLiteral(node)) return [node.getLiteralValue()];
|
|
46
|
-
return null;
|
|
47
|
-
};
|
|
48
|
-
const extractTemplateExpressionValues = (node, visited) => {
|
|
49
|
-
if (!Node.isTemplateExpression(node)) return null;
|
|
50
|
-
const parts = [[node.getHead().getLiteralText()]];
|
|
51
|
-
node.getTemplateSpans().forEach((span) => {
|
|
52
|
-
const exprValues = extractStringLiterals(span.getExpression(), visited);
|
|
53
|
-
const literalText = span.getLiteral().getLiteralText();
|
|
54
|
-
parts.push(exprValues.length > 0 ? exprValues.map((value) => `${value}${literalText}`) : ["", literalText]);
|
|
55
|
-
});
|
|
56
|
-
return parts.reduce((acc, segment) => acc.flatMap((base) => segment.map((frag) => `${base}${frag}`)), [""]).filter((value) => value.length > 0);
|
|
57
|
-
};
|
|
58
|
-
const extractBinaryExpressionValues = (node, visited) => {
|
|
59
|
-
if (!Node.isBinaryExpression(node)) return null;
|
|
60
|
-
const operator = node.getOperatorToken().getText();
|
|
61
|
-
if (operator === "+") {
|
|
62
|
-
const left = extractStringLiterals(node.getLeft(), visited);
|
|
63
|
-
const right = extractStringLiterals(node.getRight(), visited);
|
|
64
|
-
const combined = left.flatMap((l) => right.map((r) => `${l}${r}`));
|
|
65
|
-
return combined.length > 0 ? combined : [];
|
|
25
|
+
const values = [];
|
|
26
|
+
if (Node.isStringLiteral(node)) {
|
|
27
|
+
values.push(node.getLiteralValue());
|
|
28
|
+
return values;
|
|
66
29
|
}
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (Node.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (!Node.isElementAccessExpression(node)) return null;
|
|
83
|
-
return extractLiteralValuesFromType(node);
|
|
84
|
-
};
|
|
85
|
-
const extractCallExpressionValues = (node, visited) => {
|
|
86
|
-
if (!Node.isCallExpression(node)) return null;
|
|
87
|
-
const expression = node.getExpression();
|
|
88
|
-
const fromDefinitions = Node.isIdentifier(expression) ? expression.getDefinitionNodes().flatMap((definition) => {
|
|
89
|
-
if (Node.isFunctionDeclaration(definition)) return definition.getDescendantsOfKind(SyntaxKind.ReturnStatement).flatMap((returnStmt) => {
|
|
90
|
-
const expression = returnStmt.getExpression();
|
|
91
|
-
return expression ? extractStringLiterals(expression, visited) : [];
|
|
92
|
-
});
|
|
93
|
-
if (Node.isVariableDeclaration(definition)) {
|
|
94
|
-
const initializer = definition.getInitializer();
|
|
95
|
-
return initializer ? extractFromFunctionLike(initializer, visited) : [];
|
|
30
|
+
if (Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
31
|
+
values.push(node.getLiteralValue());
|
|
32
|
+
return values;
|
|
33
|
+
}
|
|
34
|
+
if (Node.isConditionalExpression(node)) {
|
|
35
|
+
values.push(...extractStringLiterals(node.getWhenTrue(), visited));
|
|
36
|
+
values.push(...extractStringLiterals(node.getWhenFalse(), visited));
|
|
37
|
+
return values;
|
|
38
|
+
}
|
|
39
|
+
if (Node.isBinaryExpression(node)) {
|
|
40
|
+
const op = node.getOperatorToken().getText();
|
|
41
|
+
if (op === "||" || op === "??") {
|
|
42
|
+
values.push(...extractStringLiterals(node.getLeft(), visited));
|
|
43
|
+
values.push(...extractStringLiterals(node.getRight(), visited));
|
|
44
|
+
return values;
|
|
96
45
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
46
|
+
}
|
|
47
|
+
if (Node.isParenthesizedExpression(node)) {
|
|
48
|
+
values.push(...extractStringLiterals(node.getExpression(), visited));
|
|
49
|
+
return values;
|
|
50
|
+
}
|
|
51
|
+
if (Node.isAsExpression(node)) {
|
|
52
|
+
values.push(...extractStringLiterals(node.getExpression(), visited));
|
|
53
|
+
return values;
|
|
54
|
+
}
|
|
55
|
+
if (Node.isPropertyAccessExpression(node)) {
|
|
56
|
+
const typeValues = extractLiteralValuesFromType(node);
|
|
57
|
+
if (typeValues.length > 0) {
|
|
58
|
+
values.push(...typeValues);
|
|
59
|
+
return values;
|
|
108
60
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
61
|
+
const expression = node.getExpression();
|
|
62
|
+
const propertyName = node.getName();
|
|
63
|
+
const baseValues = extractObjectValues(expression, visited);
|
|
64
|
+
for (const objValue of baseValues) if (typeof objValue === "object" && objValue !== null && propertyName in objValue) {
|
|
65
|
+
const propValue = objValue[propertyName];
|
|
66
|
+
if (typeof propValue === "string") values.push(propValue);
|
|
67
|
+
}
|
|
68
|
+
return values;
|
|
69
|
+
}
|
|
70
|
+
if (Node.isElementAccessExpression(node)) {
|
|
71
|
+
const typeValues = extractLiteralValuesFromType(node);
|
|
72
|
+
if (typeValues.length > 0) {
|
|
73
|
+
values.push(...typeValues);
|
|
74
|
+
return values;
|
|
75
|
+
}
|
|
76
|
+
return values;
|
|
77
|
+
}
|
|
78
|
+
if (Node.isCallExpression(node)) {
|
|
79
|
+
const expression = node.getExpression();
|
|
80
|
+
if (Node.isIdentifier(expression)) for (const definition of expression.getDefinitionNodes()) {
|
|
81
|
+
if (Node.isFunctionDeclaration(definition)) for (const returnStmt of definition.getDescendantsOfKind(SyntaxKind.ReturnStatement)) {
|
|
82
|
+
const returnExpr = returnStmt.getExpression();
|
|
83
|
+
if (returnExpr) values.push(...extractStringLiterals(returnExpr, visited));
|
|
84
|
+
}
|
|
85
|
+
if (Node.isVariableDeclaration(definition)) {
|
|
86
|
+
const initializer = definition.getInitializer();
|
|
87
|
+
if (initializer) values.push(...extractFromFunctionLike(initializer, visited));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return values;
|
|
91
|
+
}
|
|
92
|
+
if (Node.isIdentifier(node)) {
|
|
93
|
+
let foundInitializer = false;
|
|
94
|
+
for (const definition of node.getDefinitionNodes()) {
|
|
95
|
+
if (Node.isVariableDeclaration(definition)) {
|
|
96
|
+
const initializer = definition.getInitializer();
|
|
97
|
+
if (initializer) {
|
|
98
|
+
foundInitializer = true;
|
|
99
|
+
values.push(...extractStringLiterals(initializer, visited));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (Node.isParameterDeclaration(definition)) {
|
|
103
|
+
const initializer = definition.getInitializer();
|
|
104
|
+
if (initializer) {
|
|
105
|
+
foundInitializer = true;
|
|
106
|
+
values.push(...extractStringLiterals(initializer, visited));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (Node.isBindingElement(definition)) {
|
|
110
|
+
const initializer = definition.getInitializer();
|
|
111
|
+
if (initializer) {
|
|
112
|
+
foundInitializer = true;
|
|
113
|
+
values.push(...extractStringLiterals(initializer, visited));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (!foundInitializer && values.length === 0) values.push(...extractLiteralValuesFromType(node));
|
|
118
|
+
return values;
|
|
119
|
+
}
|
|
120
|
+
return values;
|
|
121
|
+
}
|
|
113
122
|
/**
|
|
114
123
|
* Extract string literals from arrow functions or function expressions
|
|
115
124
|
*/
|
|
116
|
-
|
|
125
|
+
function extractFromFunctionLike(node, visited) {
|
|
117
126
|
const values = [];
|
|
118
127
|
if (Node.isArrowFunction(node)) {
|
|
119
128
|
const body = node.getBody();
|
|
120
|
-
if (Node.isBlock(body)) body.getDescendantsOfKind(SyntaxKind.ReturnStatement)
|
|
129
|
+
if (Node.isBlock(body)) for (const returnStmt of body.getDescendantsOfKind(SyntaxKind.ReturnStatement)) {
|
|
121
130
|
const returnExpr = returnStmt.getExpression();
|
|
122
131
|
if (returnExpr) values.push(...extractStringLiterals(returnExpr, visited));
|
|
123
|
-
}
|
|
132
|
+
}
|
|
124
133
|
else values.push(...extractStringLiterals(body, visited));
|
|
125
|
-
} else if (Node.isFunctionExpression(node)) node.getDescendantsOfKind(SyntaxKind.ReturnStatement)
|
|
134
|
+
} else if (Node.isFunctionExpression(node)) for (const returnStmt of node.getDescendantsOfKind(SyntaxKind.ReturnStatement)) {
|
|
126
135
|
const returnExpr = returnStmt.getExpression();
|
|
127
136
|
if (returnExpr) values.push(...extractStringLiterals(returnExpr, visited));
|
|
128
|
-
}
|
|
137
|
+
}
|
|
129
138
|
return values;
|
|
130
|
-
}
|
|
139
|
+
}
|
|
131
140
|
/**
|
|
132
141
|
* Extract object literal values from an expression.
|
|
133
142
|
* Returns an array of all possible object values (for union types or indexed access).
|
|
134
143
|
*/
|
|
135
|
-
|
|
144
|
+
function extractObjectValues(node, visited) {
|
|
136
145
|
if (visited.has(node)) return [];
|
|
137
146
|
visited.add(node);
|
|
138
147
|
const values = [];
|
|
139
148
|
if (Node.isObjectLiteralExpression(node)) {
|
|
140
149
|
const obj = {};
|
|
141
|
-
node.getProperties().
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (nestedValues.length > 0) obj[name] = nestedValues[0];
|
|
149
|
-
}
|
|
150
|
+
for (const prop of node.getProperties()) if (Node.isPropertyAssignment(prop)) {
|
|
151
|
+
const name = prop.getName();
|
|
152
|
+
const init = prop.getInitializer();
|
|
153
|
+
if (init && Node.isStringLiteral(init)) obj[name] = init.getLiteralValue();
|
|
154
|
+
else if (init && Node.isObjectLiteralExpression(init)) {
|
|
155
|
+
const nestedValues = extractObjectValues(init, visited);
|
|
156
|
+
if (nestedValues.length > 0) obj[name] = nestedValues[0];
|
|
150
157
|
}
|
|
151
|
-
}
|
|
158
|
+
}
|
|
152
159
|
values.push(obj);
|
|
153
160
|
return values;
|
|
154
161
|
}
|
|
155
162
|
if (Node.isIdentifier(node)) {
|
|
156
|
-
node.getDefinitionNodes().
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
});
|
|
163
|
+
for (const definition of node.getDefinitionNodes()) if (Node.isVariableDeclaration(definition)) {
|
|
164
|
+
const initializer = definition.getInitializer();
|
|
165
|
+
if (initializer) if (Node.isAsExpression(initializer)) {
|
|
166
|
+
const inner = initializer.getExpression();
|
|
167
|
+
values.push(...extractObjectValues(inner, visited));
|
|
168
|
+
} else values.push(...extractObjectValues(initializer, visited));
|
|
169
|
+
}
|
|
165
170
|
return values;
|
|
166
171
|
}
|
|
167
172
|
if (Node.isElementAccessExpression(node)) {
|
|
168
|
-
extractObjectValues(node.getExpression(), visited)
|
|
169
|
-
|
|
170
|
-
});
|
|
173
|
+
const baseObjects = extractObjectValues(node.getExpression(), visited);
|
|
174
|
+
for (const obj of baseObjects) if (typeof obj === "object" && obj !== null) for (const value of Object.values(obj)) values.push(value);
|
|
171
175
|
return values;
|
|
172
176
|
}
|
|
173
177
|
return values;
|
|
174
|
-
}
|
|
178
|
+
}
|
|
175
179
|
/**
|
|
176
180
|
* Extract literal values from a TypeScript type (for union types like 'brand' | 'secondary')
|
|
177
181
|
*/
|
|
178
|
-
|
|
182
|
+
function extractLiteralValuesFromType(node) {
|
|
179
183
|
const values = [];
|
|
180
184
|
const nodeType = node.getType();
|
|
181
|
-
if (nodeType.isUnion())
|
|
182
|
-
if (unionMember.isStringLiteral()) values.push(unionMember.getLiteralValue());
|
|
183
|
-
});
|
|
184
|
-
else if (nodeType.isStringLiteral()) values.push(nodeType.getLiteralValue());
|
|
185
|
+
if (nodeType.isUnion()) {
|
|
186
|
+
for (const unionMember of nodeType.getUnionTypes()) if (unionMember.isStringLiteral()) values.push(unionMember.getLiteralValue());
|
|
187
|
+
} else if (nodeType.isStringLiteral()) values.push(nodeType.getLiteralValue());
|
|
185
188
|
return values;
|
|
186
|
-
}
|
|
189
|
+
}
|
|
187
190
|
|
|
188
191
|
//#endregion
|
|
189
192
|
export { extractStringLiterals };
|
|
@@ -7,7 +7,14 @@ let ts_morph = require("ts-morph");
|
|
|
7
7
|
/**
|
|
8
8
|
* Find all JSX usages of a component from its identifier
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
function findJsxReferences(identifier) {
|
|
11
|
+
const elements = [];
|
|
12
|
+
for (const reference of identifier.findReferencesAsNodes()) {
|
|
13
|
+
const node = reference.getFirstAncestor((n) => ts_morph.Node.isJsxOpeningElement(n) || ts_morph.Node.isJsxSelfClosingElement(n));
|
|
14
|
+
if (node && (ts_morph.Node.isJsxOpeningElement(node) || ts_morph.Node.isJsxSelfClosingElement(node))) elements.push(node);
|
|
15
|
+
}
|
|
16
|
+
return elements;
|
|
17
|
+
}
|
|
11
18
|
|
|
12
19
|
//#endregion
|
|
13
20
|
exports.findJsxReferences = findJsxReferences;
|
|
@@ -6,7 +6,14 @@ import { Node, SyntaxKind } from "ts-morph";
|
|
|
6
6
|
/**
|
|
7
7
|
* Find all JSX usages of a component from its identifier
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
function findJsxReferences(identifier) {
|
|
10
|
+
const elements = [];
|
|
11
|
+
for (const reference of identifier.findReferencesAsNodes()) {
|
|
12
|
+
const node = reference.getFirstAncestor((n) => Node.isJsxOpeningElement(n) || Node.isJsxSelfClosingElement(n));
|
|
13
|
+
if (node && (Node.isJsxOpeningElement(node) || Node.isJsxSelfClosingElement(node))) elements.push(node);
|
|
14
|
+
}
|
|
15
|
+
return elements;
|
|
16
|
+
}
|
|
10
17
|
|
|
11
18
|
//#endregion
|
|
12
19
|
export { findJsxReferences };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
const require_runtime = require('../../../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_purgeFromCode = require('./purgeFromCode.cjs');
|
|
4
|
-
const require_safelist = require('./utils/safelist.cjs');
|
|
5
4
|
const require_files = require('./utils/files.cjs');
|
|
6
|
-
|
|
7
|
-
node_fs = require_runtime.__toESM(node_fs);
|
|
5
|
+
const require_safelist = require('./utils/safelist.cjs');
|
|
8
6
|
let node_path = require("node:path");
|
|
9
7
|
node_path = require_runtime.__toESM(node_path);
|
|
8
|
+
let node_fs = require("node:fs");
|
|
9
|
+
node_fs = require_runtime.__toESM(node_fs);
|
|
10
10
|
|
|
11
11
|
//#region ../tailwind/dist/purger/optimized/purge.js
|
|
12
12
|
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
@@ -14,16 +14,16 @@ const warnedLocations = /* @__PURE__ */ new Set();
|
|
|
14
14
|
/**
|
|
15
15
|
* Clear warned locations (call at start of new purge run)
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
function clearWarnings() {
|
|
18
18
|
warnedLocations.clear();
|
|
19
|
-
}
|
|
19
|
+
}
|
|
20
20
|
/**
|
|
21
21
|
* Main purge function - optimized version
|
|
22
22
|
*
|
|
23
23
|
* Uses purgeFromCodeOptimized internally to ensure consistent behavior
|
|
24
24
|
* between CLI and playground.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
async function purgeOptimized(options) {
|
|
27
27
|
const { entry = "/src/", output = "dist/safelist.ts", colorModes = ["dark"], variants, autoVariants, componentData } = options;
|
|
28
28
|
const startTime = performance.now();
|
|
29
29
|
clearWarnings();
|
|
@@ -39,20 +39,19 @@ const purgeOptimized = async (options) => {
|
|
|
39
39
|
spreadsTraced: 0,
|
|
40
40
|
expressionsResolved: 0
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
for (const filePath of files) {
|
|
43
|
+
const result = await require_purgeFromCode.purgeFromCodeOptimized(node_fs.default.readFileSync(filePath, "utf-8"), {
|
|
44
44
|
colorModes,
|
|
45
45
|
variants,
|
|
46
46
|
autoVariants,
|
|
47
47
|
componentData
|
|
48
48
|
});
|
|
49
|
-
}))).forEach((result) => {
|
|
50
49
|
allClasses.push(...result.safelist);
|
|
51
50
|
result.imports.forEach((imp) => allImports.add(imp));
|
|
52
51
|
result.components.forEach((comp) => allComponents.add(comp));
|
|
53
52
|
stats.spreadsTraced += result.stats.spreadsTraced;
|
|
54
53
|
stats.expressionsResolved += result.stats.expressionsResolved;
|
|
55
|
-
}
|
|
54
|
+
}
|
|
56
55
|
allClasses.push(...require_safelist.getThemeAndScaleClasses(colorModes));
|
|
57
56
|
const finalSafelist = require_safelist.deduplicateSafelist(allClasses).sort();
|
|
58
57
|
await require_safelist.saveSafelistToFile(finalSafelist, node_path.default.join(workspaceDir, output));
|
|
@@ -64,7 +63,7 @@ const purgeOptimized = async (options) => {
|
|
|
64
63
|
components: [...allComponents],
|
|
65
64
|
stats
|
|
66
65
|
};
|
|
67
|
-
}
|
|
66
|
+
}
|
|
68
67
|
|
|
69
68
|
//#endregion
|
|
70
69
|
exports.purgeOptimized = purgeOptimized;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
import { purgeFromCodeOptimized } from "./purgeFromCode.js";
|
|
3
|
-
import { deduplicateSafelist, getThemeAndScaleClasses, saveSafelistToFile } from "./utils/safelist.js";
|
|
4
3
|
import { scanForFiles } from "./utils/files.js";
|
|
5
|
-
import
|
|
4
|
+
import { deduplicateSafelist, getThemeAndScaleClasses, saveSafelistToFile } from "./utils/safelist.js";
|
|
6
5
|
import path from "node:path";
|
|
6
|
+
import fs from "node:fs";
|
|
7
7
|
|
|
8
8
|
//#region ../tailwind/dist/purger/optimized/purge.js
|
|
9
9
|
/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
|
|
@@ -11,16 +11,16 @@ const warnedLocations = /* @__PURE__ */ new Set();
|
|
|
11
11
|
/**
|
|
12
12
|
* Clear warned locations (call at start of new purge run)
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
function clearWarnings() {
|
|
15
15
|
warnedLocations.clear();
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
17
|
/**
|
|
18
18
|
* Main purge function - optimized version
|
|
19
19
|
*
|
|
20
20
|
* Uses purgeFromCodeOptimized internally to ensure consistent behavior
|
|
21
21
|
* between CLI and playground.
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
async function purgeOptimized(options) {
|
|
24
24
|
const { entry = "/src/", output = "dist/safelist.ts", colorModes = ["dark"], variants, autoVariants, componentData } = options;
|
|
25
25
|
const startTime = performance.now();
|
|
26
26
|
clearWarnings();
|
|
@@ -36,20 +36,19 @@ const purgeOptimized = async (options) => {
|
|
|
36
36
|
spreadsTraced: 0,
|
|
37
37
|
expressionsResolved: 0
|
|
38
38
|
};
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
for (const filePath of files) {
|
|
40
|
+
const result = await purgeFromCodeOptimized(fs.readFileSync(filePath, "utf-8"), {
|
|
41
41
|
colorModes,
|
|
42
42
|
variants,
|
|
43
43
|
autoVariants,
|
|
44
44
|
componentData
|
|
45
45
|
});
|
|
46
|
-
}))).forEach((result) => {
|
|
47
46
|
allClasses.push(...result.safelist);
|
|
48
47
|
result.imports.forEach((imp) => allImports.add(imp));
|
|
49
48
|
result.components.forEach((comp) => allComponents.add(comp));
|
|
50
49
|
stats.spreadsTraced += result.stats.spreadsTraced;
|
|
51
50
|
stats.expressionsResolved += result.stats.expressionsResolved;
|
|
52
|
-
}
|
|
51
|
+
}
|
|
53
52
|
allClasses.push(...getThemeAndScaleClasses(colorModes));
|
|
54
53
|
const finalSafelist = deduplicateSafelist(allClasses).sort();
|
|
55
54
|
await saveSafelistToFile(finalSafelist, path.join(workspaceDir, output));
|
|
@@ -61,7 +60,7 @@ const purgeOptimized = async (options) => {
|
|
|
61
60
|
components: [...allComponents],
|
|
62
61
|
stats
|
|
63
62
|
};
|
|
64
|
-
}
|
|
63
|
+
}
|
|
65
64
|
|
|
66
65
|
//#endregion
|
|
67
66
|
export { purgeOptimized };
|