@sanity/ui-codemod 1.0.0-alpha.2 → 1.0.0-alpha.3

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.
@@ -14,6 +14,9 @@ function addImportSpecifier(j, root, addTo, name) {
14
14
  hasFromSpecifier && !hasToSpecifier && (specs.push(j.importSpecifier(j.identifier(name), j.identifier(name))), hasChanges = !0);
15
15
  }), hasChanges;
16
16
  }
17
+ function getElementMatchNames(element, localNames) {
18
+ return localNames === void 0 ? /* @__PURE__ */ new Set([element]) : new Set(localNames);
19
+ }
17
20
  function isImportBindingUsed(j, root, name, specifierPath) {
18
21
  if (root.find(j.JSXOpeningElement).some(({ node }) => node.name.type === "JSXIdentifier" && node.name.name === name) || root.find(j.JSXClosingElement).some(({ node }) => node.name.type === "JSXIdentifier" && node.name.name === name))
19
22
  return !0;
@@ -60,8 +63,7 @@ function transformImportAlias(j, root, fromExport, toExport, localName, warning)
60
63
  }), updated;
61
64
  }
62
65
  function replaceElement(j, root, filter, from, to) {
63
- const names = new Set(from.localNames);
64
- names.size === 0 && names.add(from.element);
66
+ const names = getElementMatchNames(from.element, from.localNames);
65
67
  let hasChanges = !1, needsDefaultImportUpdate = !1;
66
68
  const aliases = /* @__PURE__ */ new Set();
67
69
  return root.find(j.JSXOpeningElement).forEach((path) => {
@@ -1 +1 @@
1
- {"version":3,"file":"box.mods.js","sources":["../../src/utils/addImportSpecifier.ts","../../src/utils/isImportBindingUsed.ts","../../src/utils/removeUnusedImport.ts","../../src/utils/transformImportAlias.ts","../../src/utils/replaceElement.ts","../../src/transforms/latest/box/box.mods.ts"],"sourcesContent":["import type {API} from 'jscodeshift'\n\n/**\n * Adds an import specifier to an existing import declaration.\n * Returns whether the AST was updated.\n */\nexport function addImportSpecifier(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n addTo: string,\n name: string,\n): boolean {\n let hasChanges = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const specs = path.node.specifiers\n\n if (!specs?.length) {\n return\n }\n\n const hasFromSpecifier = specs.some(\n (s) =>\n s.type === 'ImportSpecifier' &&\n s.imported.type === 'Identifier' &&\n s.imported.name === addTo,\n )\n const hasToSpecifier = specs.some(\n (s) =>\n s.type === 'ImportSpecifier' &&\n s.imported.type === 'Identifier' &&\n s.imported.name === name,\n )\n\n if (hasFromSpecifier && !hasToSpecifier) {\n specs.push(j.importSpecifier(j.identifier(name), j.identifier(name)))\n hasChanges = true\n }\n })\n\n return hasChanges\n}\n","import type {API, ASTPath, ImportSpecifier} from 'jscodeshift'\n\nexport function isImportBindingUsed(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n name: string,\n specifierPath: ASTPath<ImportSpecifier>,\n): boolean {\n const jsxOpening = root.find(j.JSXOpeningElement).some(({node}) => {\n return node.name.type === 'JSXIdentifier' && node.name.name === name\n })\n\n if (jsxOpening) {\n return true\n }\n\n const jsxClosing = root.find(j.JSXClosingElement).some(({node}) => {\n return node.name.type === 'JSXIdentifier' && node.name.name === name\n })\n\n if (jsxClosing) {\n return true\n }\n\n const importedPath = specifierPath.get('imported')\n const localPath = specifierPath.get('local')\n\n return root.find(j.Identifier).some((idPath) => {\n if (idPath.node.name !== name) {\n return false\n }\n\n if (idPath === importedPath || idPath === localPath) {\n return false\n }\n\n const parent = idPath.parent?.node\n\n if (!parent) {\n return true\n }\n\n if (parent.type === 'MemberExpression' && !parent.computed && parent.property === idPath.node) {\n return false\n }\n\n if (parent.type === 'TSQualifiedName' && parent.right === idPath.node) {\n return false\n }\n\n return true\n })\n}\n","import type {API, ASTPath, ImportSpecifier} from 'jscodeshift'\n\nimport {isImportBindingUsed} from './isImportBindingUsed'\n\n/**\n * Removes unused import specifier or the whole import if no specifiers remain.\n * Returns whether the AST was updated.\n */\nexport function removeUnusedImport(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n name: string,\n): boolean {\n let hasChanges = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const specs = path.node.specifiers\n\n if (!specs?.length) {\n return\n }\n\n const next = specs.filter((spec, i) => {\n if (spec.type !== 'ImportSpecifier' || spec.imported.type !== 'Identifier') {\n return true\n }\n\n if (spec.imported.name !== name) {\n return true\n }\n\n if ('importKind' in spec && spec.importKind === 'type') {\n return true\n }\n\n const localName = spec.local?.type === 'Identifier' ? spec.local.name : spec.imported.name\n const specifierPath = path.get('specifiers', i) as ASTPath<ImportSpecifier>\n\n return isImportBindingUsed(j, root, localName, specifierPath)\n })\n\n if (next.length === specs.length) {\n return\n }\n\n if (next.length === 0) {\n j(path).remove()\n hasChanges = true\n return\n }\n\n path.node.specifiers = next\n hasChanges = true\n })\n\n return hasChanges\n}\n","import type {API} from 'jscodeshift'\n\nimport {insertTodoWarning} from './insertTodoWarning'\n\nexport function transformImportAlias(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n fromExport: string,\n toExport: string,\n localName: string,\n warning?: string,\n): boolean {\n let updated = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const specs = path.node.specifiers\n\n if (!specs?.length) {\n return\n }\n\n for (const spec of specs) {\n if (spec.type !== 'ImportSpecifier' || spec.imported.type !== 'Identifier') {\n continue\n }\n\n if (spec.imported.name !== fromExport) {\n continue\n }\n\n const local = spec.local?.type === 'Identifier' ? spec.local.name : spec.imported.name\n\n if (local !== localName) {\n continue\n }\n\n spec.imported.name = toExport\n updated = true\n\n if (warning) {\n insertTodoWarning(j, path, warning)\n }\n\n return\n }\n })\n\n return updated\n}\n","import type {API, ASTPath, JSXAttribute, JSXOpeningElement, JSXSpreadAttribute} from 'jscodeshift'\n\nimport {addImportSpecifier} from './addImportSpecifier'\nimport {removeUnusedImport} from './removeUnusedImport'\nimport {transformImportAlias} from './transformImportAlias'\n\n/**\n * Replaces JSX component if `filter` passes. Runs callbacks and updates imports.\n * Returns whether the AST was updated.\n */\nexport function replaceElement(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n filter: (attrs: (JSXAttribute | JSXSpreadAttribute)[]) => boolean,\n from: {\n element: string\n localNames?: Iterable<string>\n callback?: (path: ASTPath<JSXOpeningElement>) => boolean | void\n },\n to: {\n element: string\n callback?: (path: ASTPath<JSXOpeningElement>) => boolean | void\n },\n): boolean {\n const names = new Set(from.localNames)\n\n if (names.size === 0) {\n names.add(from.element)\n }\n\n let hasChanges = false\n let needsDefaultImportUpdate = false\n const aliases = new Set<string>()\n\n root.find(j.JSXOpeningElement).forEach((path) => {\n const openingEl = path.node\n const openingName = openingEl.name\n\n if (openingName.type !== 'JSXIdentifier' || !names.has(openingName.name)) {\n return\n }\n\n const attrs = openingEl.attributes\n\n if (!attrs || !filter(attrs)) {\n if (from.callback?.(path)) {\n hasChanges = true\n }\n\n return\n }\n\n const localTag = openingName.name\n const preserveAlias = localTag !== from.element && localTag !== to.element\n\n if (preserveAlias) {\n if (!aliases.has(localTag)) {\n if (\n transformImportAlias(\n j,\n root,\n from.element,\n to.element,\n localTag,\n `Consider renaming ${localTag} to ${to.element}`,\n )\n ) {\n hasChanges = true\n }\n\n aliases.add(localTag)\n }\n } else {\n openingName.name = to.element\n\n const parentNode = path.parent?.node\n\n if (parentNode?.type === 'JSXElement') {\n const closing = parentNode.closingElement\n\n if (closing?.name.type === 'JSXIdentifier') {\n closing.name.name = to.element\n }\n }\n\n needsDefaultImportUpdate = true\n hasChanges = true\n }\n\n if (to.callback?.(path)) {\n hasChanges = true\n }\n })\n\n if (needsDefaultImportUpdate) {\n if (addImportSpecifier(j, root, from.element, to.element)) {\n hasChanges = true\n }\n\n if (removeUnusedImport(j, root, from.element)) {\n hasChanges = true\n }\n }\n\n return hasChanges\n}\n","import {LAYOUT_MODS} from '../../../constants/latest/layout-mods'\nimport type {AttributeMods} from '../../../types/AttributeMods'\n\n/** @internal */\nexport const BOX_MODS: AttributeMods = {\n ...LAYOUT_MODS,\n alignItems: {\n type: 'style-only',\n style: 'alignItems',\n },\n flexDirection: {\n type: 'style-only',\n style: 'flexDirection',\n },\n flexWrap: {\n type: 'style-only',\n style: 'flexWrap',\n },\n gridAutoColumns: {\n type: 'style-only',\n style: 'gridAutoColumns',\n },\n gridAutoFlow: {\n type: 'style-only',\n style: 'gridAutoFlow',\n },\n gridAutoRows: {\n type: 'style-only',\n style: 'gridAutoRows',\n },\n gridTemplateColumns: {\n type: 'style-mapped',\n style: 'gridTemplateColumns',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, 1fr)',\n 2: 'repeat(2, 1fr)',\n 3: 'repeat(3, 1fr)',\n 4: 'repeat(4, 1fr)',\n 5: 'repeat(5, 1fr)',\n 6: 'repeat(6, 1fr)',\n 7: 'repeat(7, 1fr)',\n 8: 'repeat(8, 1fr)',\n 9: 'repeat(9, 1fr)',\n 10: 'repeat(10, 1fr)',\n 11: 'repeat(11, 1fr)',\n 12: 'repeat(12, 1fr)',\n },\n },\n gridTemplateRows: {\n type: 'style-mapped',\n style: 'gridTemplateRows',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, 1fr)',\n 2: 'repeat(2, 1fr)',\n 3: 'repeat(3, 1fr)',\n 4: 'repeat(4, 1fr)',\n 5: 'repeat(5, 1fr)',\n 6: 'repeat(6, 1fr)',\n 7: 'repeat(7, 1fr)',\n 8: 'repeat(8, 1fr)',\n 9: 'repeat(9, 1fr)',\n 10: 'repeat(10, 1fr)',\n 11: 'repeat(11, 1fr)',\n 12: 'repeat(12, 1fr)',\n },\n },\n justifyContent: {\n type: 'style-only',\n style: 'justifyContent',\n },\n tone: {\n type: 'mapped-only',\n mapping: {\n default: 'none',\n none: 'none',\n transparent: 'neutral',\n neutral: 'neutral',\n brand: 'primary',\n primary: 'primary',\n positive: 'positive',\n caution: 'caution',\n critical: 'critical',\n suggest: 'suggest',\n },\n },\n}\n"],"names":[],"mappings":";;AAMO,SAAS,mBACd,GACA,MACA,OACA,MACS;AACT,MAAI,aAAa;AAEjB,SAAA,KAAK,KAAK,EAAE,iBAAiB,EAAE,QAAQ,CAAC,SAA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ods.js","sources":["../../src/utils/addImportSpecifier.ts","../../src/utils/getElementMatchNames.ts","../../src/utils/isImportBindingUsed.ts","../../src/utils/removeUnusedImport.ts","../../src/utils/transformImportAlias.ts","../../src/utils/replaceElement.ts","../../src/transforms/latest/box/box.mods.ts"],"sourcesContent":["import type {API} from 'jscodeshift'\n\n/**\n * Adds an import specifier to an existing import declaration.\n * Returns whether the AST was updated.\n */\nexport function addImportSpecifier(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n addTo: string,\n name: string,\n): boolean {\n let hasChanges = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const specs = path.node.specifiers\n\n if (!specs?.length) {\n return\n }\n\n const hasFromSpecifier = specs.some(\n (s) =>\n s.type === 'ImportSpecifier' &&\n s.imported.type === 'Identifier' &&\n s.imported.name === addTo,\n )\n const hasToSpecifier = specs.some(\n (s) =>\n s.type === 'ImportSpecifier' &&\n s.imported.type === 'Identifier' &&\n s.imported.name === name,\n )\n\n if (hasFromSpecifier && !hasToSpecifier) {\n specs.push(j.importSpecifier(j.identifier(name), j.identifier(name)))\n hasChanges = true\n }\n })\n\n return hasChanges\n}\n","export function getElementMatchNames(element: string, localNames?: Iterable<string>): Set<string> {\n if (localNames === undefined) {\n return new Set([element])\n }\n\n return new Set(localNames)\n}\n","import type {API, ASTPath, ImportSpecifier} from 'jscodeshift'\n\nexport function isImportBindingUsed(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n name: string,\n specifierPath: ASTPath<ImportSpecifier>,\n): boolean {\n const jsxOpening = root.find(j.JSXOpeningElement).some(({node}) => {\n return node.name.type === 'JSXIdentifier' && node.name.name === name\n })\n\n if (jsxOpening) {\n return true\n }\n\n const jsxClosing = root.find(j.JSXClosingElement).some(({node}) => {\n return node.name.type === 'JSXIdentifier' && node.name.name === name\n })\n\n if (jsxClosing) {\n return true\n }\n\n const importedPath = specifierPath.get('imported')\n const localPath = specifierPath.get('local')\n\n return root.find(j.Identifier).some((idPath) => {\n if (idPath.node.name !== name) {\n return false\n }\n\n if (idPath === importedPath || idPath === localPath) {\n return false\n }\n\n const parent = idPath.parent?.node\n\n if (!parent) {\n return true\n }\n\n if (parent.type === 'MemberExpression' && !parent.computed && parent.property === idPath.node) {\n return false\n }\n\n if (parent.type === 'TSQualifiedName' && parent.right === idPath.node) {\n return false\n }\n\n return true\n })\n}\n","import type {API, ASTPath, ImportSpecifier} from 'jscodeshift'\n\nimport {isImportBindingUsed} from './isImportBindingUsed'\n\n/**\n * Removes unused import specifier or the whole import if no specifiers remain.\n * Returns whether the AST was updated.\n */\nexport function removeUnusedImport(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n name: string,\n): boolean {\n let hasChanges = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const specs = path.node.specifiers\n\n if (!specs?.length) {\n return\n }\n\n const next = specs.filter((spec, i) => {\n if (spec.type !== 'ImportSpecifier' || spec.imported.type !== 'Identifier') {\n return true\n }\n\n if (spec.imported.name !== name) {\n return true\n }\n\n if ('importKind' in spec && spec.importKind === 'type') {\n return true\n }\n\n const localName = spec.local?.type === 'Identifier' ? spec.local.name : spec.imported.name\n const specifierPath = path.get('specifiers', i) as ASTPath<ImportSpecifier>\n\n return isImportBindingUsed(j, root, localName, specifierPath)\n })\n\n if (next.length === specs.length) {\n return\n }\n\n if (next.length === 0) {\n j(path).remove()\n hasChanges = true\n return\n }\n\n path.node.specifiers = next\n hasChanges = true\n })\n\n return hasChanges\n}\n","import type {API} from 'jscodeshift'\n\nimport {insertTodoWarning} from './insertTodoWarning'\n\nexport function transformImportAlias(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n fromExport: string,\n toExport: string,\n localName: string,\n warning?: string,\n): boolean {\n let updated = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const specs = path.node.specifiers\n\n if (!specs?.length) {\n return\n }\n\n for (const spec of specs) {\n if (spec.type !== 'ImportSpecifier' || spec.imported.type !== 'Identifier') {\n continue\n }\n\n if (spec.imported.name !== fromExport) {\n continue\n }\n\n const local = spec.local?.type === 'Identifier' ? spec.local.name : spec.imported.name\n\n if (local !== localName) {\n continue\n }\n\n spec.imported.name = toExport\n updated = true\n\n if (warning) {\n insertTodoWarning(j, path, warning)\n }\n\n return\n }\n })\n\n return updated\n}\n","import type {API, ASTPath, JSXAttribute, JSXOpeningElement, JSXSpreadAttribute} from 'jscodeshift'\n\nimport {addImportSpecifier} from './addImportSpecifier'\nimport {getElementMatchNames} from './getElementMatchNames'\nimport {removeUnusedImport} from './removeUnusedImport'\nimport {transformImportAlias} from './transformImportAlias'\n\n/**\n * Replaces JSX component if `filter` passes. Runs callbacks and updates imports.\n * If `localNames` is omitted, matches `from.element`. `localNames` may be an empty set,\n * to avoid rewriting unrelated JSX when only cross-file styled aliases are present.\n * Returns whether the AST was updated.\n */\nexport function replaceElement(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n filter: (attrs: (JSXAttribute | JSXSpreadAttribute)[]) => boolean,\n from: {\n element: string\n localNames?: Iterable<string>\n callback?: (path: ASTPath<JSXOpeningElement>) => boolean | void\n },\n to: {\n element: string\n callback?: (path: ASTPath<JSXOpeningElement>) => boolean | void\n },\n): boolean {\n const names = getElementMatchNames(from.element, from.localNames)\n\n let hasChanges = false\n let needsDefaultImportUpdate = false\n const aliases = new Set<string>()\n\n root.find(j.JSXOpeningElement).forEach((path) => {\n const openingEl = path.node\n const openingName = openingEl.name\n\n if (openingName.type !== 'JSXIdentifier' || !names.has(openingName.name)) {\n return\n }\n\n const attrs = openingEl.attributes\n\n if (!attrs || !filter(attrs)) {\n if (from.callback?.(path)) {\n hasChanges = true\n }\n\n return\n }\n\n const localTag = openingName.name\n const preserveAlias = localTag !== from.element && localTag !== to.element\n\n if (preserveAlias) {\n if (!aliases.has(localTag)) {\n if (\n transformImportAlias(\n j,\n root,\n from.element,\n to.element,\n localTag,\n `Consider renaming ${localTag} to ${to.element}`,\n )\n ) {\n hasChanges = true\n }\n\n aliases.add(localTag)\n }\n } else {\n openingName.name = to.element\n\n const parentNode = path.parent?.node\n\n if (parentNode?.type === 'JSXElement') {\n const closing = parentNode.closingElement\n\n if (closing?.name.type === 'JSXIdentifier') {\n closing.name.name = to.element\n }\n }\n\n needsDefaultImportUpdate = true\n hasChanges = true\n }\n\n if (to.callback?.(path)) {\n hasChanges = true\n }\n })\n\n if (needsDefaultImportUpdate) {\n if (addImportSpecifier(j, root, from.element, to.element)) {\n hasChanges = true\n }\n\n if (removeUnusedImport(j, root, from.element)) {\n hasChanges = true\n }\n }\n\n return hasChanges\n}\n","import {LAYOUT_MODS} from '../../../constants/latest/layout-mods'\nimport type {AttributeMods} from '../../../types/AttributeMods'\n\n/** @internal */\nexport const BOX_MODS: AttributeMods = {\n ...LAYOUT_MODS,\n alignItems: {\n type: 'style-only',\n style: 'alignItems',\n },\n flexDirection: {\n type: 'style-only',\n style: 'flexDirection',\n },\n flexWrap: {\n type: 'style-only',\n style: 'flexWrap',\n },\n gridAutoColumns: {\n type: 'style-only',\n style: 'gridAutoColumns',\n },\n gridAutoFlow: {\n type: 'style-only',\n style: 'gridAutoFlow',\n },\n gridAutoRows: {\n type: 'style-only',\n style: 'gridAutoRows',\n },\n gridTemplateColumns: {\n type: 'style-mapped',\n style: 'gridTemplateColumns',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, 1fr)',\n 2: 'repeat(2, 1fr)',\n 3: 'repeat(3, 1fr)',\n 4: 'repeat(4, 1fr)',\n 5: 'repeat(5, 1fr)',\n 6: 'repeat(6, 1fr)',\n 7: 'repeat(7, 1fr)',\n 8: 'repeat(8, 1fr)',\n 9: 'repeat(9, 1fr)',\n 10: 'repeat(10, 1fr)',\n 11: 'repeat(11, 1fr)',\n 12: 'repeat(12, 1fr)',\n },\n },\n gridTemplateRows: {\n type: 'style-mapped',\n style: 'gridTemplateRows',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, 1fr)',\n 2: 'repeat(2, 1fr)',\n 3: 'repeat(3, 1fr)',\n 4: 'repeat(4, 1fr)',\n 5: 'repeat(5, 1fr)',\n 6: 'repeat(6, 1fr)',\n 7: 'repeat(7, 1fr)',\n 8: 'repeat(8, 1fr)',\n 9: 'repeat(9, 1fr)',\n 10: 'repeat(10, 1fr)',\n 11: 'repeat(11, 1fr)',\n 12: 'repeat(12, 1fr)',\n },\n },\n justifyContent: {\n type: 'style-only',\n style: 'justifyContent',\n },\n tone: {\n type: 'mapped-only',\n mapping: {\n default: 'none',\n none: 'none',\n transparent: 'neutral',\n neutral: 'neutral',\n brand: 'primary',\n primary: 'primary',\n positive: 'positive',\n caution: 'caution',\n critical: 'critical',\n suggest: 'suggest',\n },\n },\n}\n"],"names":[],"mappings":";;AAMO,SAAS,mBACd,GACA,MACA,OACA,MACS;AACT,MAAI,aAAa;AAEjB,SAAA,KAAK,KAAK,EAAE,iBAAiB,EAAE,QAAQ,CAAC,SAAS;AAC/C,UAAM,QAAQ,KAAK,KAAK;AAExB,QAAI,CAAC,OAAO;AACV;AAGF,UAAM,mBAAmB,MAAM;AAAA,MAC7B,CAAC,MACC,EAAE,SAAS,qBACX,EAAE,SAAS,SAAS,gBACpB,EAAE,SAAS,SAAS;AAAA,IAAA,GAElB,iBAAiB,MAAM;AAAA,MAC3B,CAAC,MACC,EAAE,SAAS,qBACX,EAAE,SAAS,SAAS,gBACpB,EAAE,SAAS,SAAS;AAAA,IAAA;AAGpB,wBAAoB,CAAC,mBACvB,MAAM,KAAK,EAAE,gBAAgB,EAAE,WAAW,IAAI,GAAG,EAAE,WAAW,IAAI,CAAC,CAAC,GACpE,aAAa;AAAA,EAEjB,CAAC,GAEM;AACT;ACzCO,SAAS,qBAAqB,SAAiB,YAA4C;AAChG,SAAI,eAAe,SACV,oBAAI,IAAI,CAAC,OAAO,CAAC,IAGnB,IAAI,IAAI,UAAU;AAC3B;ACJO,SAAS,oBACd,GACA,MACA,MACA,eACS;AAaT,MAZmB,KAAK,KAAK,EAAE,iBAAiB,EAA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,EAEF,kBAAkB;AAAA,IAChB,MAAM;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAAA,EAEF,gBAAgB;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA,EAAA;AAAA,EAET,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,SAAS;AAAA,MACP,SAAS;AAAA,MACT,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,MACT,OAAO;AAAA,MACP,SAAS;AAAA,MACT,UAAU;AAAA,MACV,SAAS;AAAA,MACT,UAAU;AAAA,MACV,SAAS;AAAA,IAAA;AAAA,EACX;AAEJ;"}
@@ -94,25 +94,54 @@ function getAttribute(attrs, name) {
94
94
  function getAttributeExpression(attr, j) {
95
95
  return attr.value ? attr.value.type === "StringLiteral" || attr.value.type === "Literal" ? attr.value : attr.value.type === "JSXExpressionContainer" ? attr.value.expression : null : j.booleanLiteral(!0);
96
96
  }
97
+ function getStaticPrimitive(expr) {
98
+ if (expr.type === "StringLiteral" || expr.type === "NumericLiteral" || expr.type === "BooleanLiteral" || expr.type === "Literal") {
99
+ const { value } = expr;
100
+ if (typeof value == "string" || typeof value == "number" || typeof value == "boolean")
101
+ return value;
102
+ }
103
+ }
97
104
  function getStaticAttributeExpression(j, attrs, name) {
98
105
  const attr = getAttribute(attrs, name);
99
106
  if (!attr)
100
107
  return null;
101
108
  const expr = getAttributeExpression(attr, j);
102
- return expr && (expr.type === "StringLiteral" || expr.type === "NumericLiteral" || expr.type === "BooleanLiteral" || expr.type === "Literal") ? expr.value : null;
109
+ if (!expr)
110
+ return null;
111
+ const primitive = getStaticPrimitive(expr);
112
+ if (primitive !== void 0)
113
+ return primitive;
114
+ if (expr.type !== "ArrayExpression")
115
+ return null;
116
+ const elements = expr.elements, values = [];
117
+ for (const element of elements) {
118
+ if (element === null || element.type === "NullLiteral") {
119
+ values.push(null);
120
+ continue;
121
+ }
122
+ if (element.type === "SpreadElement")
123
+ return null;
124
+ if (element.type === "Literal" && element.value === null) {
125
+ values.push(null);
126
+ continue;
127
+ }
128
+ if (element.type === "Identifier" && element.name === "undefined") {
129
+ values.push(void 0);
130
+ continue;
131
+ }
132
+ const elementValue = getStaticPrimitive(element);
133
+ if (elementValue === void 0)
134
+ return null;
135
+ values.push(elementValue);
136
+ }
137
+ return values;
103
138
  }
104
139
  function insertTodoWarning(j, path, warning) {
105
140
  let target = null;
106
- if (path.node.type === "ImportDeclaration")
107
- target = path.node;
108
- else if (path.node.type === "VariableDeclarator") {
109
- const parent = path.parent;
110
- parent?.node.type === "VariableDeclaration" && (target = parent.node);
111
- } else path.parent?.node.type === "JSXElement" && (target = path.parent.node);
112
- return !target || (target.comments ??= [], target.comments.some((comment) => comment.value.includes(warning))) ? !1 : (target.comments.unshift(j.commentLine(` UI-CODEMOD TODO: ${warning}`, !0)), !0);
141
+ return path.node.type === "ImportDeclaration" ? target = path.node : path.parent?.node.type === "JSXElement" && (target = path.parent.node), !target || (target.comments ??= [], target.comments.some((comment) => comment.value.includes(warning))) ? !1 : (target.comments.unshift(j.commentLine(` UI-CODEMOD TODO: ${warning}`, !0)), !0);
113
142
  }
114
- function shouldTransformComponent(j, root, componentName, localNames, options) {
115
- if (localNames.size > 0)
143
+ function shouldTransformComponent(j, root, componentName, localNames, options, styledAliases) {
144
+ if (localNames.size > 0 || styledAliases && styledAliases.size > 0)
116
145
  return !0;
117
146
  const fromPackage = options?.fromPackage ?? DEFAULT_UI_PACKAGE, toPackage = options?.toPackage ?? DEFAULT_UI_PACKAGE;
118
147
  return fromPackage === toPackage ? !1 : root.find(j.ImportDeclaration).some((path) => {
@@ -1 +1 @@
1
- {"version":3,"file":"transformComponent.js","sources":["../../src/utils/getClonedImportSpecifiers.ts","../../src/utils/getSplitImportSpecifiers.ts","../../src/utils/transformImport.ts","../../src/utils/getComponentLocalNames.ts","../../src/utils/getAttribute.ts","../../src/utils/getAttributeExpression.ts","../../src/utils/getStaticAttributeExpression.ts","../../src/utils/insertTodoWarning.ts","../../src/utils/shouldTransformComponent.ts","../../src/utils/getCompositeAttrValue.ts","../../src/utils/getMappingExpression.ts","../../src/utils/getMappingValue.ts","../../src/utils/getMappingArray.ts","../../src/utils/getShorthandAttributes.ts","../../src/utils/getStyleExpression.ts","../../src/utils/isValidStyleType.ts","../../src/utils/mergeStyle.ts","../../src/utils/transformAttributes.ts","../../src/utils/transformComponent.ts"],"sourcesContent":["import type {API, ImportDefaultSpecifier, ImportSpecifier} from 'jscodeshift'\n\nexport function getClonedImportSpecifiers(\n j: API['jscodeshift'],\n specifiers: (ImportSpecifier | ImportDefaultSpecifier)[] = [],\n) {\n return specifiers.map((spec) => {\n if (spec.type === 'ImportSpecifier') {\n if (spec.imported.type !== 'Identifier' || spec.local?.type !== 'Identifier') {\n return spec\n }\n\n const clone = j.importSpecifier(\n j.identifier(spec.imported.name),\n j.identifier(spec.local.name),\n )\n\n if ('importKind' in spec && spec.importKind === 'type') {\n Object.assign(clone, {importKind: 'type'})\n }\n\n return clone\n } else {\n return j.importDefaultSpecifier(\n j.identifier((spec as ImportDefaultSpecifier).local?.name as string),\n )\n }\n })\n}\n","import type {ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier} from 'jscodeshift'\n\nexport function getSplitImportSpecifiers(\n specifiers: (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[] = [],\n componentName: string,\n) {\n const componentNames = new Set([componentName, `${componentName}Props`])\n const specs = {\n componentSpecs: [] as (ImportSpecifier | ImportDefaultSpecifier)[],\n restSpecs: [] as (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[],\n }\n\n for (const spec of specifiers) {\n if (spec.type === 'ImportNamespaceSpecifier') {\n specs.restSpecs.push(spec)\n continue\n }\n\n if (spec.type === 'ImportSpecifier' || spec.type === 'ImportDefaultSpecifier') {\n let local\n\n if (spec.type === 'ImportSpecifier') {\n const loc = spec.local ?? spec.imported\n local = loc.type === 'Identifier' ? loc.name : null\n }\n\n if (spec.type === 'ImportDefaultSpecifier') {\n local = spec.local?.type === 'Identifier' ? spec.local.name : null\n }\n\n if (local && componentNames.has(local)) {\n specs.componentSpecs.push(spec)\n } else {\n specs.restSpecs.push(spec)\n }\n }\n }\n\n return specs\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport {getClonedImportSpecifiers} from './getClonedImportSpecifiers'\nimport {getSplitImportSpecifiers} from './getSplitImportSpecifiers'\n\nexport const DEFAULT_UI_PACKAGE = '@sanity/ui'\n\n/**\n * Rewrites imports from `fromPackage` to `toPackage`, splitting imports if needed.\n * Returns whether the AST was updated.\n */\nexport function transformImport(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n fromPackage: string = DEFAULT_UI_PACKAGE,\n toPackage: string = DEFAULT_UI_PACKAGE,\n): boolean {\n if (fromPackage === toPackage) {\n return false\n }\n\n let hasChanges = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const node = path.node\n\n if (node.source.value !== fromPackage) {\n return\n }\n\n const {componentSpecs, restSpecs} = getSplitImportSpecifiers(node.specifiers, componentName)\n\n if (componentSpecs.length === 0) {\n return\n }\n\n if (restSpecs.length === 0) {\n if (node.source && typeof node.source === 'object' && 'value' in node.source) {\n const sourceLiteral = node.source as {value: string}\n sourceLiteral.value = toPackage\n }\n\n hasChanges = true\n return\n }\n\n path.node.specifiers = restSpecs\n const clonedImportSpecifiers = getClonedImportSpecifiers(j, componentSpecs)\n path.insertAfter(j.importDeclaration(clonedImportSpecifiers, j.stringLiteral(toPackage)))\n hasChanges = true\n })\n\n return hasChanges\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport type {BaseOptions} from '../types/BaseOptions'\nimport {DEFAULT_UI_PACKAGE} from './transformImport'\n\nexport function getComponentLocalNames(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n options?: BaseOptions,\n): Set<string> {\n const importedNames = new Set<string>()\n const packages = new Set([\n options?.fromPackage ?? DEFAULT_UI_PACKAGE,\n options?.toPackage ?? DEFAULT_UI_PACKAGE,\n ])\n let hasOtherPackageImport = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const node = path.node\n\n if ('importKind' in node && node.importKind === 'type') {\n return\n }\n\n const matchesPackage = packages.has(node.source.value as string)\n\n for (const spec of node.specifiers ?? []) {\n if (spec.type !== 'ImportSpecifier') {\n continue\n }\n\n if ('importKind' in spec && spec.importKind === 'type') {\n continue\n }\n\n if (spec.imported.type !== 'Identifier' || spec.imported.name !== componentName) {\n continue\n }\n\n const local = spec.local?.type === 'Identifier' ? spec.local.name : spec.imported.name\n\n if (!matchesPackage) {\n hasOtherPackageImport = true\n continue\n }\n\n importedNames.add(local)\n }\n })\n\n if (importedNames.size > 0) {\n return importedNames\n }\n\n if (hasOtherPackageImport) {\n return new Set()\n }\n\n const usesComponentInJsx = root.find(j.JSXOpeningElement).some(({node}) => {\n return node.name.type === 'JSXIdentifier' && node.name.name === componentName\n })\n\n if (usesComponentInJsx) {\n return new Set([componentName])\n }\n\n return new Set()\n}\n","import type {JSXAttribute, JSXElement} from 'jscodeshift'\n\nexport function getAttribute(\n attrs: JSXElement['openingElement']['attributes'],\n name: string,\n): JSXAttribute | undefined {\n if (!attrs) {\n return undefined\n }\n\n for (const attr of attrs) {\n if (\n attr.type === 'JSXAttribute' &&\n attr.name.type === 'JSXIdentifier' &&\n attr.name.name === name\n ) {\n return attr\n }\n }\n\n return undefined\n}\n","import {type API, type JSXAttribute} from 'jscodeshift'\n\nimport {type AnyExpression} from '../types/AnyExpression'\n\nexport function getAttributeExpression(\n attr: JSXAttribute,\n j: API['jscodeshift'],\n): AnyExpression | null {\n if (!attr.value) {\n return j.booleanLiteral(true)\n }\n\n if (attr.value.type === 'StringLiteral' || attr.value.type === 'Literal') {\n return attr.value\n }\n\n if (attr.value.type === 'JSXExpressionContainer') {\n return attr.value.expression\n }\n\n return null\n}\n","import type {API, JSXAttribute, JSXSpreadAttribute} from 'jscodeshift'\n\nimport {getAttribute} from './getAttribute'\nimport {getAttributeExpression} from './getAttributeExpression'\n\nexport type CompositePrimitive = string | number | boolean\n\nexport function getStaticAttributeExpression(\n j: API['jscodeshift'],\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n name: string,\n): CompositePrimitive | null {\n const attr = getAttribute(attrs, name)\n\n if (!attr) {\n return null\n }\n\n const expr = getAttributeExpression(attr, j)\n\n if (!expr) {\n return null\n }\n\n if (\n expr.type === 'StringLiteral' ||\n expr.type === 'NumericLiteral' ||\n expr.type === 'BooleanLiteral' ||\n expr.type === 'Literal'\n ) {\n return expr.value as string | number | boolean\n }\n\n return null\n}\n","import {\n type API,\n type ASTPath,\n type ImportDeclaration,\n type JSXOpeningElement,\n type VariableDeclarator,\n} from 'jscodeshift'\n\ntype CommentableNode = {\n comments?: {type: string; value: string; leading?: boolean}[] | null\n}\n\n/**\n * Inserts a `UI-CODEMOD TODO` comment.\n * Returns whether the AST was updated.\n */\nexport function insertTodoWarning(\n j: API['jscodeshift'],\n path: ASTPath<JSXOpeningElement | ImportDeclaration | VariableDeclarator>,\n warning: string,\n): boolean {\n let target: CommentableNode | null = null\n\n if (path.node.type === 'ImportDeclaration') {\n target = path.node\n } else if (path.node.type === 'VariableDeclarator') {\n const parent = path.parent\n\n if (parent?.node.type === 'VariableDeclaration') {\n target = parent.node\n }\n } else if (path.parent?.node.type === 'JSXElement') {\n target = path.parent.node\n }\n\n if (!target) {\n return false\n }\n\n target.comments ??= []\n\n if (target.comments.some((comment) => comment.value.includes(warning))) {\n return false\n }\n\n target.comments.unshift(j.commentLine(` UI-CODEMOD TODO: ${warning}`, true))\n return true\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport type {BaseOptions} from '../types/BaseOptions'\nimport {getSplitImportSpecifiers} from './getSplitImportSpecifiers'\nimport {DEFAULT_UI_PACKAGE} from './transformImport'\n\n/**\n * Returns whether a component transform should run on this file, based on local\n * usage or a pending import rewrite.\n */\nexport function shouldTransformComponent(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n localNames: Set<string>,\n options?: BaseOptions,\n): boolean {\n if (localNames.size > 0) {\n return true\n }\n\n const fromPackage = options?.fromPackage ?? DEFAULT_UI_PACKAGE\n const toPackage = options?.toPackage ?? DEFAULT_UI_PACKAGE\n\n if (fromPackage === toPackage) {\n return false\n }\n\n return root.find(j.ImportDeclaration).some((path) => {\n const node = path.node\n\n if (node.source.value !== fromPackage) {\n return false\n }\n\n const {componentSpecs} = getSplitImportSpecifiers(node.specifiers, componentName)\n\n return componentSpecs.length > 0\n })\n}\n","import type {API, JSXAttribute, JSXSpreadAttribute} from 'jscodeshift'\n\nimport type {CompositeAttributeMapping} from '../types/AttributeMods'\nimport {getStaticAttributeExpression} from './getStaticAttributeExpression'\n\nexport function getCompositeAttrValue(\n j: API['jscodeshift'],\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n mapping: CompositeAttributeMapping,\n) {\n let compositeAttrValue: string | null = null\n\n for (const compositeKey of Object.keys(mapping)) {\n const compositeMapping = mapping[compositeKey]\n\n if (!compositeMapping) {\n continue\n }\n\n let hasMatchingValues = true\n\n for (const propName of Object.keys(compositeMapping)) {\n const mappingValue = compositeMapping[propName]\n const attrValue = getStaticAttributeExpression(j, attrs, propName)\n\n if (mappingValue === undefined || attrValue !== mappingValue) {\n hasMatchingValues = false\n break\n }\n }\n\n if (hasMatchingValues) {\n compositeAttrValue = compositeKey\n break\n }\n }\n\n return compositeAttrValue\n}\n","import {type API} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\n\nexport function getMappingExpression(\n j: API['jscodeshift'],\n val: string | boolean | number | undefined,\n): AnyExpression {\n if (val === undefined) {\n return j.identifier('undefined')\n }\n\n if (typeof val === 'boolean') {\n return j.booleanLiteral(val)\n }\n\n if (typeof val === 'number') {\n return j.numericLiteral(val)\n }\n\n return j.stringLiteral(val)\n}\n","import type {AnyExpression} from '../types/AnyExpression'\nimport type {AttributeMapping} from '../types/AttributeMods'\n\nexport function getMappingValue(mapping: AttributeMapping, expr: AnyExpression) {\n let matchedVal\n\n for (const val in mapping) {\n if (expr.value === mapping[val]) {\n matchedVal = mapping[val]\n }\n }\n\n if (matchedVal) {\n return matchedVal\n }\n\n let key\n\n if (\n expr.type === 'NumericLiteral' ||\n expr.type === 'BooleanLiteral' ||\n expr.type === 'StringLiteral' ||\n expr.type === 'Literal'\n ) {\n key = String(expr.value)\n }\n\n if (expr.type === 'TemplateLiteral') {\n const expressions = expr.expressions as unknown[]\n const quasis = expr.quasis as {value: {cooked: string | null}}[]\n\n if (expressions.length === 0 && quasis.length === 1) {\n key = quasis[0]?.value.cooked ?? null\n }\n }\n\n if (!key) {\n return\n }\n\n if (Object.prototype.hasOwnProperty.call(mapping, key)) {\n return mapping[key]\n }\n\n const number = Number(key)\n\n if (!Number.isNaN(number) && Object.prototype.hasOwnProperty.call(mapping, number)) {\n return mapping[number]\n }\n\n return\n}\n","import {type API, type ArrayExpression} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\nimport type {AttributeMapping} from '../types/AttributeMods'\nimport {getMappingExpression} from './getMappingExpression'\nimport {getMappingValue} from './getMappingValue'\n\nexport function getMappingArray(\n j: API['jscodeshift'],\n arr: AnyExpression,\n mapping: AttributeMapping,\n allowUndefined?: boolean,\n): ArrayExpression | null {\n if (arr.type !== 'ArrayExpression') {\n return null\n }\n\n const elements = arr.elements as (AnyExpression | null)[]\n const output: AnyExpression[] = []\n\n for (const el of elements) {\n if (el == null || el.type === 'SpreadElement') {\n return null\n }\n\n const mappingValue = getMappingValue(mapping, el)\n\n if (!mappingValue && !allowUndefined) {\n return null\n }\n\n output.push(getMappingExpression(j, mappingValue))\n }\n\n return j.arrayExpression(output as never[])\n}\n","import type {API, JSXAttribute} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\nimport type {AttributeMod} from '../types/AttributeMods'\nimport {getMappingArray} from './getMappingArray'\nimport {getMappingExpression} from './getMappingExpression'\nimport {getMappingValue} from './getMappingValue'\n\nexport function getShorthandAttributes(\n j: API['jscodeshift'],\n expr: AnyExpression,\n mod: AttributeMod,\n) {\n const attributes: JSXAttribute[] = []\n\n if (!('props' in mod)) {\n return []\n }\n\n if (expr.type === 'ArrayExpression') {\n for (const prop of mod.props) {\n const styleArray = getMappingArray(j, expr, prop.mapping, true)\n\n if (!styleArray) {\n continue\n }\n\n attributes.push(\n j.jsxAttribute(j.jsxIdentifier(prop.name), j.jsxExpressionContainer(styleArray)),\n )\n }\n }\n\n for (const prop of mod.props) {\n const styleValue = getMappingValue(prop.mapping, expr)\n\n if (styleValue === undefined) {\n continue\n }\n\n if (typeof styleValue === 'string') {\n attributes.push(j.jsxAttribute(j.jsxIdentifier(prop.name), j.stringLiteral(styleValue)))\n } else {\n attributes.push(\n j.jsxAttribute(\n j.jsxIdentifier(prop.name),\n j.jsxExpressionContainer(getMappingExpression(j, styleValue) as never),\n ),\n )\n }\n }\n\n return attributes\n}\n","import {type API} from 'jscodeshift'\n\nimport {type AnyExpression} from '../types/AnyExpression'\n\nexport function getStyleExpression(j: API['jscodeshift'], expr: AnyExpression): AnyExpression {\n if (expr.type === 'Literal') {\n if (expr.value === null) {\n return j.literal(null)\n }\n\n if (typeof expr.value === 'boolean') {\n return j.booleanLiteral(expr.value)\n }\n\n if (typeof expr.value === 'number') {\n return j.numericLiteral(expr.value)\n }\n\n if (typeof expr.value === 'string') {\n return j.stringLiteral(expr.value)\n }\n }\n\n if (expr.type === 'BooleanLiteral') {\n return j.booleanLiteral(expr.value as boolean)\n }\n\n if (expr.type === 'NumericLiteral') {\n return j.numericLiteral(expr.value as number)\n }\n\n if (expr.type === 'StringLiteral') {\n return j.stringLiteral(expr.value as string)\n }\n\n return expr\n}\n","import {type AnyExpression} from '../types/AnyExpression'\n\nexport function isValidStyleType(expr: AnyExpression) {\n if (expr.type === 'TemplateLiteral') {\n const expressions = expr.expressions as unknown[]\n const quasis = expr.quasis as {value: {cooked: string | null}}[]\n return expressions.length === 0 && quasis.length === 1\n }\n\n if (\n expr.type === 'StringLiteral' ||\n expr.type === 'Literal' ||\n expr.type === 'NumericLiteral' ||\n expr.type === 'BooleanLiteral' ||\n expr.type === 'NullLiteral'\n ) {\n return true\n }\n\n return false\n}\n","import {type API, type JSXAttribute, type JSXSpreadAttribute} from 'jscodeshift'\n\nimport {type AnyExpression} from '../types/AnyExpression'\n\nexport function mergeStyle(\n j: API['jscodeshift'],\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n styleKey: string,\n styleExpression: AnyExpression,\n) {\n const styleProp = j.objectProperty(j.identifier(styleKey), styleExpression as never)\n\n const styleIndex = attrs.findIndex(\n (a): a is JSXAttribute =>\n a.type === 'JSXAttribute' && a.name.type === 'JSXIdentifier' && a.name.name === 'style',\n )\n\n if (styleIndex === -1) {\n attrs.push(\n j.jsxAttribute(\n j.jsxIdentifier('style'),\n j.jsxExpressionContainer(j.objectExpression([styleProp])),\n ),\n )\n\n return true\n }\n\n const styleAttr = attrs[styleIndex] as JSXAttribute\n\n if (styleAttr.value?.type !== 'JSXExpressionContainer') {\n return false\n }\n\n const expr = styleAttr.value.expression\n\n if (expr.type === 'ObjectExpression') {\n expr.properties = expr.properties.filter((prop) => {\n if (prop.type !== 'ObjectProperty' && prop.type !== 'Property') {\n return true\n }\n\n const key = prop.key\n\n const name =\n key.type === 'Identifier'\n ? key.name\n : key.type === 'StringLiteral' || key.type === 'Literal'\n ? String(key.value)\n : null\n\n return name !== styleKey\n })\n\n expr.properties.push(styleProp)\n return true\n }\n\n styleAttr.value = j.jsxExpressionContainer(\n j.objectExpression([j.spreadElement(expr as never), styleProp]),\n )\n\n return true\n}\n","import {type API, type ASTPath, type JSXOpeningElement} from 'jscodeshift'\n\nimport {type AttributeMods} from '../types/AttributeMods'\nimport {getAttribute} from './getAttribute'\nimport {getAttributeExpression} from './getAttributeExpression'\nimport {getCompositeAttrValue} from './getCompositeAttrValue'\nimport {getMappingArray} from './getMappingArray'\nimport {getMappingExpression} from './getMappingExpression'\nimport {getMappingValue} from './getMappingValue'\nimport {getShorthandAttributes} from './getShorthandAttributes'\nimport {getStyleExpression} from './getStyleExpression'\nimport {insertTodoWarning} from './insertTodoWarning'\nimport {isValidStyleType} from './isValidStyleType'\nimport {mergeStyle} from './mergeStyle'\n\n/**\n * Applies attribute migration rules to a JSX opening element.\n * Returns whether the AST was updated.\n */\nexport function transformAttributes(\n j: API['jscodeshift'],\n path: ASTPath<JSXOpeningElement>,\n mods: AttributeMods,\n todoWarning: string,\n): boolean {\n if (!path.node.attributes) {\n return false\n }\n\n let hasChanges = false\n const attrs = path.node.attributes\n const removeIdxs: number[] = []\n\n for (const [attrName, mod] of Object.entries(mods)) {\n if (mod?.type !== 'warn-missing') {\n continue\n }\n\n if (getAttribute(attrs, attrName)) {\n continue\n }\n\n if (insertTodoWarning(j, path, mod.warning || todoWarning)) {\n hasChanges = true\n }\n }\n\n for (let i = 0; i < attrs.length; i++) {\n const attr = attrs[i]\n\n if (!attr || attr.type !== 'JSXAttribute' || attr.name.type !== 'JSXIdentifier') {\n continue\n }\n\n const mod = mods[attr.name.name]\n const expr = getAttributeExpression(attr, j)\n\n if (!mod || !expr) {\n continue\n }\n\n if (mod.type === 'remove') {\n removeIdxs.push(i)\n }\n\n if (mod.type === 'warn-only') {\n if (insertTodoWarning(j, path, mod.warning || todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'rename-only') {\n if (attr.name.type === 'JSXIdentifier') {\n attr.name.name = mod.name\n hasChanges = true\n }\n }\n\n if (mod.type === 'style-only') {\n if (!expr || !isValidStyleType(expr)) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const merged = mergeStyle(j, attrs, mod.style, getStyleExpression(j, expr))\n\n if (merged) {\n removeIdxs.push(i)\n } else if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'style-mapped') {\n if (!expr || !isValidStyleType(expr)) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const styleValue = getMappingValue(mod.mapping, expr)\n\n if (styleValue === undefined) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const merged = mergeStyle(j, attrs, mod.style, getMappingExpression(j, styleValue))\n\n if (merged) {\n removeIdxs.push(i)\n } else if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'shorthand-mapped') {\n if (expr.type === 'ConditionalExpression' || expr.type === 'Identifier') {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const shorthandAttrs = getShorthandAttributes(j, expr, mod)\n\n if (shorthandAttrs.length) {\n attrs.splice(i + 1, 0, ...shorthandAttrs)\n removeIdxs.push(i)\n } else if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'composite') {\n const triggerName = attr.name.name\n const compositeValue = getCompositeAttrValue(j, attrs, mod.mapping)\n\n if (!compositeValue) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (attr.name.type === 'JSXIdentifier') {\n attr.name.name = mod.name\n }\n\n attr.value = j.stringLiteral(compositeValue)\n\n for (const attrName of Object.keys(mod.mapping[compositeValue] || {})) {\n if (attrName === triggerName) {\n continue\n }\n\n const otherAttr = getAttribute(attrs, attrName)\n\n if (otherAttr) {\n const k = attrs.indexOf(otherAttr)\n\n if (k !== -1) {\n removeIdxs.push(k)\n }\n }\n }\n\n hasChanges = true\n }\n\n if (mod.type === 'mapped-only' || mod.type === 'rename-mapped') {\n if (mod.type === 'rename-mapped') {\n if (attr.name.type === 'JSXIdentifier') {\n attr.name.name = mod.name\n }\n }\n\n if (expr.type === 'ConditionalExpression' || expr.type === 'Identifier') {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (expr.type === 'ArrayExpression') {\n const styleArray = getMappingArray(j, expr, mod.mapping)\n\n if (!styleArray) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (attr.value?.type === 'JSXExpressionContainer') {\n attr.value.expression = styleArray\n } else {\n attr.value = j.jsxExpressionContainer(styleArray)\n }\n\n hasChanges = true\n continue\n }\n\n const styleValue = getMappingValue(mod.mapping, expr)\n\n if (styleValue === undefined) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (typeof styleValue === 'string') {\n attr.value = j.stringLiteral(styleValue)\n } else {\n attr.value = j.jsxExpressionContainer(getMappingExpression(j, styleValue) as never)\n }\n\n hasChanges = true\n }\n }\n\n const idxsToRemove = [...new Set(removeIdxs)].sort((a, b) => b - a)\n\n if (idxsToRemove.length > 0) {\n hasChanges = true\n\n for (const i of idxsToRemove) {\n attrs.splice(i, 1)\n }\n }\n\n return hasChanges\n}\n","import type {API, Collection, FileInfo} from 'jscodeshift'\n\nexport type TransformContext = {\n j: API['jscodeshift']\n root: Collection\n markChanged: () => void\n}\n\n/**\n * Runs a component transform on a file and only calls `toSource()` when\n * `markChanged()` was invoked. Returns `undefined` for no-op files.\n */\nexport function transformComponent(\n fileInfo: FileInfo,\n api: API,\n fn: (ctx: TransformContext) => void,\n): string | undefined {\n const j = api.jscodeshift\n const root = j(fileInfo.source)\n let hasChanges = false\n\n fn({\n j,\n root,\n markChanged: () => {\n hasChanges = true\n },\n })\n\n return hasChanges ? root.toSource() : undefined\n}\n"],"names":[],"mappings":";AAEO,SAAS,0BACd,GACA,aAA2D,IAC3D;AACA,SAAO,WAAW,IAAI,CAAC,SAAS;AAC9B,QAAI,K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G,MAAM,WAAW,MACxC,aAAa;AAGf;AAAA,UACF;AAEI,eAAK,OAAO,SAAS,2BACvB,KAAK,MAAM,aAAa,aAExB,KAAK,QAAQ,EAAE,uBAAuB,UAAU,GAGlD,aAAa;AACb;AAAA,QACF;AAEA,cAAM,aAAa,gBAAgB,IAAI,SAAS,IAAI;AAEpD,YAAI,eAAe,QAAW;AACxB,4BAAkB,GAAG,MAAM,WAAW,MACxC,aAAa;AAGf;AAAA,QACF;AAEI,eAAO,cAAe,WACxB,KAAK,QAAQ,EAAE,cAAc,UAAU,IAEvC,KAAK,QAAQ,EAAE,uBAAuB,qBAAqB,GAAG,UAAU,CAAU,GAGpF,aAAa;AAAA,MACf;AAAA,IAAA;AAAA,EACF;AAEA,QAAM,eAAe,CAAC,GAAG,IAAI,IAAI,UAAU,CAAC,EAAE,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC;AAElE,MAAI,aAAa,SAAS,GAAG;AAC3B,iBAAa;AAEb,eAAW,KAAK;AACd,YAAM,OAAO,GAAG,CAAC;AAAA,EAErB;AAEA,SAAO;AACT;AC3OO,SAAS,mBACd,UACA,KACA,IACoB;AACpB,QAAM,IAAI,IAAI,aACR,OAAO,EAAE,SAAS,MAAM;AAC9B,MAAI,aAAa;AAEjB,SAAA,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA,aAAa,MAAM;AACjB,mBAAa;AAAA,IACf;AAAA,EAAA,CACD,GAEM,aAAa,KAAK,aAAa;AACxC;"}
1
+ {"version":3,"file":"transformComponent.js","sources":["../../src/utils/getClonedImportSpecifiers.ts","../../src/utils/getSplitImportSpecifiers.ts","../../src/utils/transformImport.ts","../../src/utils/getComponentLocalNames.ts","../../src/utils/getAttribute.ts","../../src/utils/getAttributeExpression.ts","../../src/utils/getStaticAttributeExpression.ts","../../src/utils/insertTodoWarning.ts","../../src/utils/shouldTransformComponent.ts","../../src/utils/getCompositeAttrValue.ts","../../src/utils/getMappingExpression.ts","../../src/utils/getMappingValue.ts","../../src/utils/getMappingArray.ts","../../src/utils/getShorthandAttributes.ts","../../src/utils/getStyleExpression.ts","../../src/utils/isValidStyleType.ts","../../src/utils/mergeStyle.ts","../../src/utils/transformAttributes.ts","../../src/utils/transformComponent.ts"],"sourcesContent":["import type {API, ImportDefaultSpecifier, ImportSpecifier} from 'jscodeshift'\n\nexport function getClonedImportSpecifiers(\n j: API['jscodeshift'],\n specifiers: (ImportSpecifier | ImportDefaultSpecifier)[] = [],\n) {\n return specifiers.map((spec) => {\n if (spec.type === 'ImportSpecifier') {\n if (spec.imported.type !== 'Identifier' || spec.local?.type !== 'Identifier') {\n return spec\n }\n\n const clone = j.importSpecifier(\n j.identifier(spec.imported.name),\n j.identifier(spec.local.name),\n )\n\n if ('importKind' in spec && spec.importKind === 'type') {\n Object.assign(clone, {importKind: 'type'})\n }\n\n return clone\n } else {\n return j.importDefaultSpecifier(\n j.identifier((spec as ImportDefaultSpecifier).local?.name as string),\n )\n }\n })\n}\n","import type {ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier} from 'jscodeshift'\n\nexport function getSplitImportSpecifiers(\n specifiers: (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[] = [],\n componentName: string,\n) {\n const componentNames = new Set([componentName, `${componentName}Props`])\n const specs = {\n componentSpecs: [] as (ImportSpecifier | ImportDefaultSpecifier)[],\n restSpecs: [] as (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[],\n }\n\n for (const spec of specifiers) {\n if (spec.type === 'ImportNamespaceSpecifier') {\n specs.restSpecs.push(spec)\n continue\n }\n\n if (spec.type === 'ImportSpecifier' || spec.type === 'ImportDefaultSpecifier') {\n let local\n\n if (spec.type === 'ImportSpecifier') {\n const loc = spec.local ?? spec.imported\n local = loc.type === 'Identifier' ? loc.name : null\n }\n\n if (spec.type === 'ImportDefaultSpecifier') {\n local = spec.local?.type === 'Identifier' ? spec.local.name : null\n }\n\n if (local && componentNames.has(local)) {\n specs.componentSpecs.push(spec)\n } else {\n specs.restSpecs.push(spec)\n }\n }\n }\n\n return specs\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport {getClonedImportSpecifiers} from './getClonedImportSpecifiers'\nimport {getSplitImportSpecifiers} from './getSplitImportSpecifiers'\n\nexport const DEFAULT_UI_PACKAGE = '@sanity/ui'\n\n/**\n * Rewrites imports from `fromPackage` to `toPackage`, splitting imports if needed.\n * Returns whether the AST was updated.\n */\nexport function transformImport(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n fromPackage: string = DEFAULT_UI_PACKAGE,\n toPackage: string = DEFAULT_UI_PACKAGE,\n): boolean {\n if (fromPackage === toPackage) {\n return false\n }\n\n let hasChanges = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const node = path.node\n\n if (node.source.value !== fromPackage) {\n return\n }\n\n const {componentSpecs, restSpecs} = getSplitImportSpecifiers(node.specifiers, componentName)\n\n if (componentSpecs.length === 0) {\n return\n }\n\n if (restSpecs.length === 0) {\n if (node.source && typeof node.source === 'object' && 'value' in node.source) {\n const sourceLiteral = node.source as {value: string}\n sourceLiteral.value = toPackage\n }\n\n hasChanges = true\n return\n }\n\n path.node.specifiers = restSpecs\n const clonedImportSpecifiers = getClonedImportSpecifiers(j, componentSpecs)\n path.insertAfter(j.importDeclaration(clonedImportSpecifiers, j.stringLiteral(toPackage)))\n hasChanges = true\n })\n\n return hasChanges\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport type {BaseOptions} from '../types/BaseOptions'\nimport {DEFAULT_UI_PACKAGE} from './transformImport'\n\nexport function getComponentLocalNames(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n options?: BaseOptions,\n): Set<string> {\n const importedNames = new Set<string>()\n const packages = new Set([\n options?.fromPackage ?? DEFAULT_UI_PACKAGE,\n options?.toPackage ?? DEFAULT_UI_PACKAGE,\n ])\n let hasOtherPackageImport = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const node = path.node\n\n if ('importKind' in node && node.importKind === 'type') {\n return\n }\n\n const matchesPackage = packages.has(node.source.value as string)\n\n for (const spec of node.specifiers ?? []) {\n if (spec.type !== 'ImportSpecifier') {\n continue\n }\n\n if ('importKind' in spec && spec.importKind === 'type') {\n continue\n }\n\n if (spec.imported.type !== 'Identifier' || spec.imported.name !== componentName) {\n continue\n }\n\n const local = spec.local?.type === 'Identifier' ? spec.local.name : spec.imported.name\n\n if (!matchesPackage) {\n hasOtherPackageImport = true\n continue\n }\n\n importedNames.add(local)\n }\n })\n\n if (importedNames.size > 0) {\n return importedNames\n }\n\n if (hasOtherPackageImport) {\n return new Set()\n }\n\n const usesComponentInJsx = root.find(j.JSXOpeningElement).some(({node}) => {\n return node.name.type === 'JSXIdentifier' && node.name.name === componentName\n })\n\n if (usesComponentInJsx) {\n return new Set([componentName])\n }\n\n return new Set()\n}\n","import type {JSXAttribute, JSXElement} from 'jscodeshift'\n\nexport function getAttribute(\n attrs: JSXElement['openingElement']['attributes'],\n name: string,\n): JSXAttribute | undefined {\n if (!attrs) {\n return undefined\n }\n\n for (const attr of attrs) {\n if (\n attr.type === 'JSXAttribute' &&\n attr.name.type === 'JSXIdentifier' &&\n attr.name.name === name\n ) {\n return attr\n }\n }\n\n return undefined\n}\n","import {type API, type JSXAttribute} from 'jscodeshift'\n\nimport {type AnyExpression} from '../types/AnyExpression'\n\nexport function getAttributeExpression(\n attr: JSXAttribute,\n j: API['jscodeshift'],\n): AnyExpression | null {\n if (!attr.value) {\n return j.booleanLiteral(true)\n }\n\n if (attr.value.type === 'StringLiteral' || attr.value.type === 'Literal') {\n return attr.value\n }\n\n if (attr.value.type === 'JSXExpressionContainer') {\n return attr.value.expression\n }\n\n return null\n}\n","import type {API, JSXAttribute, JSXSpreadAttribute} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\nimport {getAttribute} from './getAttribute'\nimport {getAttributeExpression} from './getAttributeExpression'\n\nexport type CompositePrimitive = string | number | boolean\n\nexport type StaticAttributeValue = CompositePrimitive | (CompositePrimitive | null | undefined)[]\n\nfunction getStaticPrimitive(expr: AnyExpression): CompositePrimitive | undefined {\n if (\n expr.type === 'StringLiteral' ||\n expr.type === 'NumericLiteral' ||\n expr.type === 'BooleanLiteral' ||\n expr.type === 'Literal'\n ) {\n const {value} = expr\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return value\n }\n }\n\n return undefined\n}\n\nexport function getStaticAttributeExpression(\n j: API['jscodeshift'],\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n name: string,\n): StaticAttributeValue | null {\n const attr = getAttribute(attrs, name)\n\n if (!attr) {\n return null\n }\n\n const expr = getAttributeExpression(attr, j)\n\n if (!expr) {\n return null\n }\n\n const primitive = getStaticPrimitive(expr as AnyExpression)\n\n if (primitive !== undefined) {\n return primitive\n }\n\n if (expr.type !== 'ArrayExpression') {\n return null\n }\n\n const elements = expr.elements as ((AnyExpression & {name?: string}) | null)[]\n const values: (CompositePrimitive | null | undefined)[] = []\n\n for (const element of elements) {\n if (element === null || element.type === 'NullLiteral') {\n values.push(null)\n continue\n }\n\n if (element.type === 'SpreadElement') {\n return null\n }\n\n if (element.type === 'Literal' && element.value === null) {\n values.push(null)\n continue\n }\n\n if (element.type === 'Identifier' && element.name === 'undefined') {\n values.push(undefined)\n continue\n }\n\n const elementValue = getStaticPrimitive(element)\n\n if (elementValue === undefined) {\n return null\n }\n\n values.push(elementValue)\n }\n\n return values\n}\n","import {type API, type ASTPath, type ImportDeclaration, type JSXOpeningElement} from 'jscodeshift'\n\ntype CommentableNode = {\n comments?: {type: string; value: string; leading?: boolean}[] | null\n}\n\n/**\n * Inserts a `UI-CODEMOD TODO` comment.\n * Returns whether the AST was updated.\n */\nexport function insertTodoWarning(\n j: API['jscodeshift'],\n path: ASTPath<JSXOpeningElement | ImportDeclaration>,\n warning: string,\n): boolean {\n let target: CommentableNode | null = null\n\n if (path.node.type === 'ImportDeclaration') {\n target = path.node\n } else if (path.parent?.node.type === 'JSXElement') {\n target = path.parent.node\n }\n\n if (!target) {\n return false\n }\n\n target.comments ??= []\n\n if (target.comments.some((comment) => comment.value.includes(warning))) {\n return false\n }\n\n target.comments.unshift(j.commentLine(` UI-CODEMOD TODO: ${warning}`, true))\n return true\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport type {BaseOptions} from '../types/BaseOptions'\nimport {getSplitImportSpecifiers} from './getSplitImportSpecifiers'\nimport {DEFAULT_UI_PACKAGE} from './transformImport'\n\n/**\n * Returns whether a component transform should run on this file, based on local\n * usage or a pending import rewrite.\n */\nexport function shouldTransformComponent(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n localNames: Set<string>,\n options?: BaseOptions,\n styledAliases?: Set<string>,\n): boolean {\n if (localNames.size > 0) {\n return true\n }\n\n if (styledAliases && styledAliases.size > 0) {\n return true\n }\n\n const fromPackage = options?.fromPackage ?? DEFAULT_UI_PACKAGE\n const toPackage = options?.toPackage ?? DEFAULT_UI_PACKAGE\n\n if (fromPackage === toPackage) {\n return false\n }\n\n return root.find(j.ImportDeclaration).some((path) => {\n const node = path.node\n\n if (node.source.value !== fromPackage) {\n return false\n }\n\n const {componentSpecs} = getSplitImportSpecifiers(node.specifiers, componentName)\n\n return componentSpecs.length > 0\n })\n}\n","import type {API, JSXAttribute, JSXSpreadAttribute} from 'jscodeshift'\n\nimport type {CompositeAttributeMapping} from '../types/AttributeMods'\nimport {getStaticAttributeExpression} from './getStaticAttributeExpression'\n\nexport function getCompositeAttrValue(\n j: API['jscodeshift'],\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n mapping: CompositeAttributeMapping,\n) {\n let compositeAttrValue: string | null = null\n\n for (const compositeKey of Object.keys(mapping)) {\n const compositeMapping = mapping[compositeKey]\n\n if (!compositeMapping) {\n continue\n }\n\n let hasMatchingValues = true\n\n for (const propName of Object.keys(compositeMapping)) {\n const mappingValue = compositeMapping[propName]\n const attrValue = getStaticAttributeExpression(j, attrs, propName)\n\n if (mappingValue === undefined || attrValue !== mappingValue) {\n hasMatchingValues = false\n break\n }\n }\n\n if (hasMatchingValues) {\n compositeAttrValue = compositeKey\n break\n }\n }\n\n return compositeAttrValue\n}\n","import {type API} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\n\nexport function getMappingExpression(\n j: API['jscodeshift'],\n val: string | boolean | number | undefined,\n): AnyExpression {\n if (val === undefined) {\n return j.identifier('undefined')\n }\n\n if (typeof val === 'boolean') {\n return j.booleanLiteral(val)\n }\n\n if (typeof val === 'number') {\n return j.numericLiteral(val)\n }\n\n return j.stringLiteral(val)\n}\n","import type {AnyExpression} from '../types/AnyExpression'\nimport type {AttributeMapping} from '../types/AttributeMods'\n\nexport function getMappingValue(mapping: AttributeMapping, expr: AnyExpression) {\n let matchedVal\n\n for (const val in mapping) {\n if (expr.value === mapping[val]) {\n matchedVal = mapping[val]\n }\n }\n\n if (matchedVal) {\n return matchedVal\n }\n\n let key\n\n if (\n expr.type === 'NumericLiteral' ||\n expr.type === 'BooleanLiteral' ||\n expr.type === 'StringLiteral' ||\n expr.type === 'Literal'\n ) {\n key = String(expr.value)\n }\n\n if (expr.type === 'TemplateLiteral') {\n const expressions = expr.expressions as unknown[]\n const quasis = expr.quasis as {value: {cooked: string | null}}[]\n\n if (expressions.length === 0 && quasis.length === 1) {\n key = quasis[0]?.value.cooked ?? null\n }\n }\n\n if (!key) {\n return\n }\n\n if (Object.prototype.hasOwnProperty.call(mapping, key)) {\n return mapping[key]\n }\n\n const number = Number(key)\n\n if (!Number.isNaN(number) && Object.prototype.hasOwnProperty.call(mapping, number)) {\n return mapping[number]\n }\n\n return\n}\n","import {type API, type ArrayExpression} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\nimport type {AttributeMapping} from '../types/AttributeMods'\nimport {getMappingExpression} from './getMappingExpression'\nimport {getMappingValue} from './getMappingValue'\n\nexport function getMappingArray(\n j: API['jscodeshift'],\n arr: AnyExpression,\n mapping: AttributeMapping,\n allowUndefined?: boolean,\n): ArrayExpression | null {\n if (arr.type !== 'ArrayExpression') {\n return null\n }\n\n const elements = arr.elements as (AnyExpression | null)[]\n const output: AnyExpression[] = []\n\n for (const el of elements) {\n if (el == null || el.type === 'SpreadElement') {\n return null\n }\n\n const mappingValue = getMappingValue(mapping, el)\n\n if (!mappingValue && !allowUndefined) {\n return null\n }\n\n output.push(getMappingExpression(j, mappingValue))\n }\n\n return j.arrayExpression(output as never[])\n}\n","import type {API, JSXAttribute} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\nimport type {AttributeMod} from '../types/AttributeMods'\nimport {getMappingArray} from './getMappingArray'\nimport {getMappingExpression} from './getMappingExpression'\nimport {getMappingValue} from './getMappingValue'\n\nexport function getShorthandAttributes(\n j: API['jscodeshift'],\n expr: AnyExpression,\n mod: AttributeMod,\n) {\n const attributes: JSXAttribute[] = []\n\n if (!('props' in mod)) {\n return []\n }\n\n if (expr.type === 'ArrayExpression') {\n for (const prop of mod.props) {\n const styleArray = getMappingArray(j, expr, prop.mapping, true)\n\n if (!styleArray) {\n continue\n }\n\n attributes.push(\n j.jsxAttribute(j.jsxIdentifier(prop.name), j.jsxExpressionContainer(styleArray)),\n )\n }\n }\n\n for (const prop of mod.props) {\n const styleValue = getMappingValue(prop.mapping, expr)\n\n if (styleValue === undefined) {\n continue\n }\n\n if (typeof styleValue === 'string') {\n attributes.push(j.jsxAttribute(j.jsxIdentifier(prop.name), j.stringLiteral(styleValue)))\n } else {\n attributes.push(\n j.jsxAttribute(\n j.jsxIdentifier(prop.name),\n j.jsxExpressionContainer(getMappingExpression(j, styleValue) as never),\n ),\n )\n }\n }\n\n return attributes\n}\n","import {type API} from 'jscodeshift'\n\nimport {type AnyExpression} from '../types/AnyExpression'\n\nexport function getStyleExpression(j: API['jscodeshift'], expr: AnyExpression): AnyExpression {\n if (expr.type === 'Literal') {\n if (expr.value === null) {\n return j.literal(null)\n }\n\n if (typeof expr.value === 'boolean') {\n return j.booleanLiteral(expr.value)\n }\n\n if (typeof expr.value === 'number') {\n return j.numericLiteral(expr.value)\n }\n\n if (typeof expr.value === 'string') {\n return j.stringLiteral(expr.value)\n }\n }\n\n if (expr.type === 'BooleanLiteral') {\n return j.booleanLiteral(expr.value as boolean)\n }\n\n if (expr.type === 'NumericLiteral') {\n return j.numericLiteral(expr.value as number)\n }\n\n if (expr.type === 'StringLiteral') {\n return j.stringLiteral(expr.value as string)\n }\n\n return expr\n}\n","import {type AnyExpression} from '../types/AnyExpression'\n\nexport function isValidStyleType(expr: AnyExpression) {\n if (expr.type === 'TemplateLiteral') {\n const expressions = expr.expressions as unknown[]\n const quasis = expr.quasis as {value: {cooked: string | null}}[]\n return expressions.length === 0 && quasis.length === 1\n }\n\n if (\n expr.type === 'StringLiteral' ||\n expr.type === 'Literal' ||\n expr.type === 'NumericLiteral' ||\n expr.type === 'BooleanLiteral' ||\n expr.type === 'NullLiteral'\n ) {\n return true\n }\n\n return false\n}\n","import {type API, type JSXAttribute, type JSXSpreadAttribute} from 'jscodeshift'\n\nimport {type AnyExpression} from '../types/AnyExpression'\n\nexport function mergeStyle(\n j: API['jscodeshift'],\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n styleKey: string,\n styleExpression: AnyExpression,\n) {\n const styleProp = j.objectProperty(j.identifier(styleKey), styleExpression as never)\n\n const styleIndex = attrs.findIndex(\n (a): a is JSXAttribute =>\n a.type === 'JSXAttribute' && a.name.type === 'JSXIdentifier' && a.name.name === 'style',\n )\n\n if (styleIndex === -1) {\n attrs.push(\n j.jsxAttribute(\n j.jsxIdentifier('style'),\n j.jsxExpressionContainer(j.objectExpression([styleProp])),\n ),\n )\n\n return true\n }\n\n const styleAttr = attrs[styleIndex] as JSXAttribute\n\n if (styleAttr.value?.type !== 'JSXExpressionContainer') {\n return false\n }\n\n const expr = styleAttr.value.expression\n\n if (expr.type === 'ObjectExpression') {\n expr.properties = expr.properties.filter((prop) => {\n if (prop.type !== 'ObjectProperty' && prop.type !== 'Property') {\n return true\n }\n\n const key = prop.key\n\n const name =\n key.type === 'Identifier'\n ? key.name\n : key.type === 'StringLiteral' || key.type === 'Literal'\n ? String(key.value)\n : null\n\n return name !== styleKey\n })\n\n expr.properties.push(styleProp)\n return true\n }\n\n styleAttr.value = j.jsxExpressionContainer(\n j.objectExpression([j.spreadElement(expr as never), styleProp]),\n )\n\n return true\n}\n","import {type API, type ASTPath, type JSXOpeningElement} from 'jscodeshift'\n\nimport {type AttributeMods} from '../types/AttributeMods'\nimport {getAttribute} from './getAttribute'\nimport {getAttributeExpression} from './getAttributeExpression'\nimport {getCompositeAttrValue} from './getCompositeAttrValue'\nimport {getMappingArray} from './getMappingArray'\nimport {getMappingExpression} from './getMappingExpression'\nimport {getMappingValue} from './getMappingValue'\nimport {getShorthandAttributes} from './getShorthandAttributes'\nimport {getStyleExpression} from './getStyleExpression'\nimport {insertTodoWarning} from './insertTodoWarning'\nimport {isValidStyleType} from './isValidStyleType'\nimport {mergeStyle} from './mergeStyle'\n\n/**\n * Applies attribute migration rules to a JSX opening element.\n * Returns whether the AST was updated.\n */\nexport function transformAttributes(\n j: API['jscodeshift'],\n path: ASTPath<JSXOpeningElement>,\n mods: AttributeMods,\n todoWarning: string,\n): boolean {\n if (!path.node.attributes) {\n return false\n }\n\n let hasChanges = false\n const attrs = path.node.attributes\n const removeIdxs: number[] = []\n\n for (const [attrName, mod] of Object.entries(mods)) {\n if (mod?.type !== 'warn-missing') {\n continue\n }\n\n if (getAttribute(attrs, attrName)) {\n continue\n }\n\n if (insertTodoWarning(j, path, mod.warning || todoWarning)) {\n hasChanges = true\n }\n }\n\n for (let i = 0; i < attrs.length; i++) {\n const attr = attrs[i]\n\n if (!attr || attr.type !== 'JSXAttribute' || attr.name.type !== 'JSXIdentifier') {\n continue\n }\n\n const mod = mods[attr.name.name]\n const expr = getAttributeExpression(attr, j)\n\n if (!mod || !expr) {\n continue\n }\n\n if (mod.type === 'remove') {\n removeIdxs.push(i)\n }\n\n if (mod.type === 'warn-only') {\n if (insertTodoWarning(j, path, mod.warning || todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'rename-only') {\n if (attr.name.type === 'JSXIdentifier') {\n attr.name.name = mod.name\n hasChanges = true\n }\n }\n\n if (mod.type === 'style-only') {\n if (!expr || !isValidStyleType(expr)) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const merged = mergeStyle(j, attrs, mod.style, getStyleExpression(j, expr))\n\n if (merged) {\n removeIdxs.push(i)\n } else if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'style-mapped') {\n if (!expr || !isValidStyleType(expr)) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const styleValue = getMappingValue(mod.mapping, expr)\n\n if (styleValue === undefined) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const merged = mergeStyle(j, attrs, mod.style, getMappingExpression(j, styleValue))\n\n if (merged) {\n removeIdxs.push(i)\n } else if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'shorthand-mapped') {\n if (expr.type === 'ConditionalExpression' || expr.type === 'Identifier') {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const shorthandAttrs = getShorthandAttributes(j, expr, mod)\n\n if (shorthandAttrs.length) {\n attrs.splice(i + 1, 0, ...shorthandAttrs)\n removeIdxs.push(i)\n } else if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'composite') {\n const triggerName = attr.name.name\n const compositeValue = getCompositeAttrValue(j, attrs, mod.mapping)\n\n if (!compositeValue) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (attr.name.type === 'JSXIdentifier') {\n attr.name.name = mod.name\n }\n\n attr.value = j.stringLiteral(compositeValue)\n\n for (const attrName of Object.keys(mod.mapping[compositeValue] || {})) {\n if (attrName === triggerName) {\n continue\n }\n\n const otherAttr = getAttribute(attrs, attrName)\n\n if (otherAttr) {\n const k = attrs.indexOf(otherAttr)\n\n if (k !== -1) {\n removeIdxs.push(k)\n }\n }\n }\n\n hasChanges = true\n }\n\n if (mod.type === 'mapped-only' || mod.type === 'rename-mapped') {\n if (mod.type === 'rename-mapped') {\n if (attr.name.type === 'JSXIdentifier') {\n attr.name.name = mod.name\n }\n }\n\n if (expr.type === 'ConditionalExpression' || expr.type === 'Identifier') {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (expr.type === 'ArrayExpression') {\n const styleArray = getMappingArray(j, expr, mod.mapping)\n\n if (!styleArray) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (attr.value?.type === 'JSXExpressionContainer') {\n attr.value.expression = styleArray\n } else {\n attr.value = j.jsxExpressionContainer(styleArray)\n }\n\n hasChanges = true\n continue\n }\n\n const styleValue = getMappingValue(mod.mapping, expr)\n\n if (styleValue === undefined) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (typeof styleValue === 'string') {\n attr.value = j.stringLiteral(styleValue)\n } else {\n attr.value = j.jsxExpressionContainer(getMappingExpression(j, styleValue) as never)\n }\n\n hasChanges = true\n }\n }\n\n const idxsToRemove = [...new Set(removeIdxs)].sort((a, b) => b - a)\n\n if (idxsToRemove.length > 0) {\n hasChanges = true\n\n for (const i of idxsToRemove) {\n attrs.splice(i, 1)\n }\n }\n\n return hasChanges\n}\n","import type {API, Collection, FileInfo} from 'jscodeshift'\n\nexport type TransformContext = {\n j: API['jscodeshift']\n root: Collection\n markChanged: () => void\n}\n\n/**\n * Runs a component transform on a file and only calls `toSource()` when\n * `markChanged()` was invoked. Returns `undefined` for no-op files.\n */\nexport function transformComponent(\n fileInfo: FileInfo,\n api: API,\n fn: (ctx: TransformContext) => void,\n): string | undefined {\n const j = api.jscodeshift\n const root = j(fileInfo.source)\n let hasChanges = false\n\n fn({\n j,\n root,\n markChanged: () => {\n hasChanges = true\n },\n })\n\n return hasChanges ? root.toSource() : undefined\n}\n"],"names":[],"mappings":";AAEO,SAAS,0BACd,GACA,aAA2D,IAC3D;AACA,SAAO,WAAW,IAAI,CAAC,SAAS;AAC9B,QAAI,KAAK,SAAS,mBAAmB;AACnC,UAAI,KAAK,SAAS,SAAS,gBAAgB,KAAK,OAAO,SAAS;AAC9D,eAAO;AAGT,YAAM,QAAQ,EAAE;AAAA,QACd,EAAE,WAAW,KAAK,SAAS,IAAI;AAAA,QAC/B,EAAE,WAAW,KAAK,MAAM,IAAI;AAAA,MAAA;AAG9B,aAAI,gBAAgB,QAAQ,KAAK,eAAe,UAC9C,OAAO,OAAO,OAAO,EAAC,YAAY,OAAA,CAAO,GAGpC;AAAA,IACT;AACE,aAAO,EAAE;AAAA,QACP,EAAE,WAAY,KAAgC,OAAO,IAAc;AAAA,MAAA;AAAA,EAGzE,CAAC;AACH;AC1BO,SAAS,yBACd,aAAsF,CAAA,GACtF,eACA;AACA,QAAM,iBAAiB,oBAAI,IAAI,CAAC,eAAe,GAAG,aAAa,OAAO,CAAC,GACjE,QAAQ;AAAA,IACZ,gBAAgB,CAAA;AAAA,IAChB,WAAW,CAAA;AAAA,EAAC;AAGd,aAAW,QAAQ,YAAY;AAC7B,QAAI,KAAK,SAAS,4BAA4B;AAC5C,YAAM,UAAU,KAAK,IAAI;AACzB;AAAA,IACF;AAEA,QAAI,KAAK,SAAS,qBAAqB,KAAK,SAAS,0BAA0B;AAC7E,UAAI;AAEJ,UAAI,KAAK,SAAS,mBAAmB;AACnC,cAAM,MAAM,KAAK,SAAS,KAAK;AAC/B,gBAAQ,IAAI,SAAS,eAAe,IAAI,OAAO;AAAA,MACjD;AAEI,WAAK,SAAS,6BAChB,QAAQ,KAAK,OAAO,SAAS,eAAe,KAAK,MAAM,OAAO,OAG5D,SAAS,eA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AE,cAAc,UAAU,IAEvC,KAAK,QAAQ,EAAE,uBAAuB,qBAAqB,GAAG,UAAU,CAAU,GAGpF,aAAa;AAAA,MACf;AAAA,IAAA;AAAA,EACF;AAEA,QAAM,eAAe,CAAC,GAAG,IAAI,IAAI,UAAU,CAAC,EAAE,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC;AAElE,MAAI,aAAa,SAAS,GAAG;AAC3B,iBAAa;AAEb,eAAW,KAAK;AACd,YAAM,OAAO,GAAG,CAAC;AAAA,EAErB;AAEA,SAAO;AACT;AC3OO,SAAS,mBACd,UACA,KACA,IACoB;AACpB,QAAM,IAAI,IAAI,aACR,OAAO,EAAE,SAAS,MAAM;AAC9B,MAAI,aAAa;AAEjB,SAAA,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA,aAAa,MAAM;AACjB,mBAAa;AAAA,IACf;AAAA,EAAA,CACD,GAEM,aAAa,KAAK,aAAa;AACxC;"}
@@ -1,8 +1,86 @@
1
1
  import "jscodeshift";
2
- import { insertTodoWarning, transformComponent, getComponentLocalNames, shouldTransformComponent, transformImport, transformAttributes, getStaticAttributeExpression } from "../../../_chunks-es/transformComponent.js";
2
+ import { getComponentLocalNames, insertTodoWarning, transformComponent, shouldTransformComponent, transformImport, transformAttributes, getStaticAttributeExpression } from "../../../_chunks-es/transformComponent.js";
3
+ import { readFileSync, existsSync } from "node:fs";
4
+ import { resolve, dirname, join } from "node:path";
3
5
  import { replaceElement, BOX_MODS } from "../../../_chunks-es/box.mods.js";
4
6
  import { FLEX_MODS } from "../../../_chunks-es/flex.mods.js";
5
7
  import { GRID_MODS } from "../../../_chunks-es/grid.mods.js";
8
+ const parseCache = /* @__PURE__ */ new Map();
9
+ function parseModule(j, filePath) {
10
+ const cached = parseCache.get(filePath);
11
+ if (cached)
12
+ return cached;
13
+ try {
14
+ const source = readFileSync(filePath, "utf8"), root = j(source);
15
+ return parseCache.set(filePath, root), root;
16
+ } catch {
17
+ return null;
18
+ }
19
+ }
20
+ const EXTENSIONS = [".tsx", ".ts", ".jsx", ".js"];
21
+ function resolveRelativeModulePath(fromFilePath, moduleSpecifier) {
22
+ if (!moduleSpecifier.startsWith("."))
23
+ return null;
24
+ const base = resolve(dirname(fromFilePath), moduleSpecifier);
25
+ for (const ext of EXTENSIONS) {
26
+ const filePath = `${base}${ext}`;
27
+ if (existsSync(filePath))
28
+ return filePath;
29
+ }
30
+ for (const ext of EXTENSIONS) {
31
+ const indexPath = join(base, `index${ext}`);
32
+ if (existsSync(indexPath))
33
+ return indexPath;
34
+ }
35
+ return existsSync(base) ? base : null;
36
+ }
37
+ function findVariableInit(j, root, name) {
38
+ let init = null;
39
+ return root.find(j.VariableDeclarator).forEach((path) => {
40
+ const { id } = path.node;
41
+ id.type === "Identifier" && id.name === name && path.node.init && (init = path.node.init);
42
+ }), init;
43
+ }
44
+ function getExportSpecifierName(exported) {
45
+ return exported.type === "Identifier" || exported.type === "JSXIdentifier" ? exported.name : null;
46
+ }
47
+ function getNamedExportInit(j, exportName, filePath, visited = /* @__PURE__ */ new Set()) {
48
+ if (visited.has(filePath))
49
+ return null;
50
+ visited.add(filePath);
51
+ const root = parseModule(j, filePath);
52
+ if (!root)
53
+ return null;
54
+ for (const path of root.find(j.ExportNamedDeclaration).paths()) {
55
+ const { declaration, specifiers, source } = path.node, reexportSource = typeof source?.value == "string" ? source.value : null;
56
+ if (declaration?.type === "VariableDeclaration") {
57
+ for (const declarator of declaration.declarations)
58
+ if (declarator.type === "VariableDeclarator" && declarator.id.type === "Identifier" && declarator.id.name === exportName && declarator.init)
59
+ return { init: declarator.init, modulePath: filePath };
60
+ }
61
+ for (const spec of specifiers ?? []) {
62
+ if (spec.type !== "ExportSpecifier")
63
+ continue;
64
+ const exported = getExportSpecifierName(spec.exported);
65
+ if (!exported || exported !== exportName)
66
+ continue;
67
+ const local = spec.local?.type === "Identifier" ? spec.local.name : exported;
68
+ if (reexportSource) {
69
+ const resolvedPath = resolveRelativeModulePath(filePath, reexportSource);
70
+ if (resolvedPath) {
71
+ const followed = getNamedExportInit(j, local, resolvedPath, visited);
72
+ if (followed)
73
+ return followed;
74
+ }
75
+ continue;
76
+ }
77
+ const init = findVariableInit(j, root, local);
78
+ if (init)
79
+ return { init, modulePath: filePath };
80
+ }
81
+ }
82
+ return null;
83
+ }
6
84
  function getStyledComponentName(node) {
7
85
  if (!node || typeof node != "object" || !("type" in node))
8
86
  return null;
@@ -19,7 +97,7 @@ function getStyledComponentName(node) {
19
97
  }
20
98
  return current.type === "MemberExpression" && current.object ? getStyledComponentName(current.object) : null;
21
99
  }
22
- function getStyledComponentAliases(j, root, localNames) {
100
+ function getSameFileStyledComponentAliases(j, root, localNames) {
23
101
  const aliases = /* @__PURE__ */ new Set(), names = new Set(localNames);
24
102
  return root.find(j.VariableDeclarator).forEach((path) => {
25
103
  const { id, init } = path.node;
@@ -29,35 +107,72 @@ function getStyledComponentAliases(j, root, localNames) {
29
107
  baseComponent && names.has(baseComponent) && aliases.add(id.name);
30
108
  }), aliases;
31
109
  }
32
- const DEFAULT_WARNING = "Please double check styled-component migration(s) below";
110
+ function getImportedStyledComponentAliases(j, root, componentName, filePath, options) {
111
+ const aliases = /* @__PURE__ */ new Set();
112
+ return filePath && root.find(j.ImportDeclaration).forEach((path) => {
113
+ const source = path.node.source.value;
114
+ if (typeof source != "string")
115
+ return;
116
+ const resolvedPath = resolveRelativeModulePath(filePath, source);
117
+ if (resolvedPath)
118
+ for (const spec of path.node.specifiers ?? []) {
119
+ if (spec.type !== "ImportSpecifier" || "importKind" in spec && spec.importKind === "type" || spec.imported.type !== "Identifier")
120
+ continue;
121
+ const exportName = spec.imported.name, localName = spec.local?.type === "Identifier" ? spec.local.name : exportName, namedExport = getNamedExportInit(j, exportName, resolvedPath);
122
+ if (!namedExport)
123
+ continue;
124
+ const sourceRoot = parseModule(j, namedExport.modulePath);
125
+ if (!sourceRoot)
126
+ continue;
127
+ const exportLocalNames = getComponentLocalNames(j, sourceRoot, componentName, options), baseComponent = getStyledComponentName(namedExport.init);
128
+ baseComponent && exportLocalNames.has(baseComponent) && aliases.add(localName);
129
+ }
130
+ }), aliases;
131
+ }
132
+ function getStyledComponentAliases(j, root, componentName, filePath, localNames, options) {
133
+ const sameFile = getSameFileStyledComponentAliases(j, root, localNames), imported = getImportedStyledComponentAliases(j, root, componentName, filePath, options);
134
+ return /* @__PURE__ */ new Set([...sameFile, ...imported]);
135
+ }
136
+ const DEFAULT_WARNING = "Please double check styled-component migration below";
33
137
  function transformStyledComponents(j, root, aliases, filter, options = {}) {
34
- const names = new Set(aliases), { callback, warning = DEFAULT_WARNING } = options, aliasesToWarn = /* @__PURE__ */ new Set();
138
+ const names = new Set(aliases), { callback, warning = DEFAULT_WARNING } = options;
35
139
  let hasChanges = !1;
36
140
  return root.find(j.JSXOpeningElement).forEach((path) => {
37
141
  const name = path.node.name;
38
142
  if (name.type !== "JSXIdentifier" || !names.has(name.name))
39
143
  return;
40
144
  const attrs = path.node.attributes ?? [];
41
- filter(attrs) || aliasesToWarn.add(name.name), filter(attrs) && callback?.(path) && (hasChanges = !0);
42
- }), root.find(j.VariableDeclarator).forEach((path) => {
43
- const { id } = path.node;
44
- id.type === "Identifier" && aliasesToWarn.has(id.name) && insertTodoWarning(j, path, warning) && (hasChanges = !0);
145
+ if (!filter(attrs)) {
146
+ insertTodoWarning(j, path, warning) && (hasChanges = !0);
147
+ return;
148
+ }
149
+ callback?.(path) && (hasChanges = !0);
45
150
  }), hasChanges;
46
151
  }
47
- const BOX_TODO_WARNING = "Please double check the Box migration below", FLEX_TODO_WARNING = "Please double check the Flex migration below", GRID_TODO_WARNING = "Please double check the Grid migration below", STYLED_TODO_WARNING = "Please double check styled(Box) migration(s) below";
152
+ const BOX_TODO_WARNING = "Please double check the Box migration below", FLEX_TODO_WARNING = "Please double check the Flex migration below", GRID_TODO_WARNING = "Please double check the Grid migration below", STYLED_TODO_WARNING = "Please double check styled(Box) migration below";
48
153
  function transform(fileInfo, api, options) {
49
154
  const { fromPackage, toPackage } = options || {};
50
155
  return transformComponent(fileInfo, api, ({ j, root, markChanged }) => {
51
- const localNames = getComponentLocalNames(j, root, "Box", options), styledAliases = getStyledComponentAliases(j, root, localNames);
52
- if (!shouldTransformComponent(j, root, "Box", localNames, options))
156
+ const localNames = getComponentLocalNames(j, root, "Box", options), styledAliases = getStyledComponentAliases(
157
+ j,
158
+ root,
159
+ "Box",
160
+ fileInfo.path,
161
+ localNames,
162
+ options
163
+ );
164
+ if (!shouldTransformComponent(j, root, "Box", localNames, options, styledAliases))
53
165
  return;
54
- const replaceWithFlex = (attrs) => {
55
- const display = getStaticAttributeExpression(j, attrs, "display");
56
- return display === "flex" || display == "inline-flex";
57
- }, replaceWithGrid = (attrs) => {
58
- const display = getStaticAttributeExpression(j, attrs, "display");
59
- return display === "grid" || display == "inline-grid";
60
- };
166
+ const matchesDisplayValue = (attrs, suffix, exclude) => {
167
+ const display = getStaticAttributeExpression(j, attrs, "display") || [], values = Array.isArray(display) ? display : [display];
168
+ let matchesExclude;
169
+ for (const excluded of exclude)
170
+ if (values.some((value) => typeof value == "string" && value.endsWith(excluded))) {
171
+ matchesExclude = !0;
172
+ break;
173
+ }
174
+ return matchesExclude ? !1 : values.some((value) => typeof value == "string" && value.endsWith(suffix));
175
+ }, replaceWithFlex = (attrs) => matchesDisplayValue(attrs, "flex", ["block", "inline", "grid"]), replaceWithGrid = (attrs) => matchesDisplayValue(attrs, "grid", ["block", "inline", "flex"]);
61
176
  transformImport(j, root, "Box", fromPackage, toPackage) && markChanged(), replaceElement(
62
177
  j,
63
178
  root,
@@ -1 +1 @@
1
- {"version":3,"file":"box.js","sources":["../../../../src/utils/getStyledComponentName.ts","../../../../src/utils/getStyledComponentAliases.ts","../../../../src/utils/transformStyledComponents.ts","../../../../src/transforms/latest/box/box.ts"],"sourcesContent":["export function getStyledComponentName(node: unknown): string | null {\n if (!node || typeof node !== 'object' || !('type' in node)) {\n return null\n }\n\n const current = node as {\n type: string\n callee?: unknown\n tag?: unknown\n object?: unknown\n arguments?: unknown[]\n }\n\n if (current.type === 'TaggedTemplateExpression') {\n return getStyledComponentName(current.tag)\n }\n\n if (current.type === 'CallExpression') {\n const callee = current.callee\n\n if (\n callee &&\n typeof callee === 'object' &&\n 'type' in callee &&\n callee.type === 'Identifier' &&\n 'name' in callee &&\n callee.name === 'styled'\n ) {\n const arg = current.arguments?.[0]\n\n if (\n arg &&\n typeof arg === 'object' &&\n 'type' in arg &&\n arg.type === 'Identifier' &&\n 'name' in arg\n ) {\n return arg.name as string\n }\n\n return null\n }\n\n return getStyledComponentName(callee)\n }\n\n if (current.type === 'MemberExpression' && current.object) {\n return getStyledComponentName(current.object)\n }\n\n return null\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport {getStyledComponentName} from './getStyledComponentName'\n\nexport function getStyledComponentAliases(\n j: API['jscodeshift'],\n root: Collection,\n localNames: Iterable<string>,\n): Set<string> {\n const aliases = new Set<string>()\n const names = new Set(localNames)\n\n root.find(j.VariableDeclarator).forEach((path) => {\n const {id, init} = path.node\n\n if (!init || id.type !== 'Identifier') {\n return\n }\n\n const baseComponent = getStyledComponentName(init)\n\n if (baseComponent && names.has(baseComponent)) {\n aliases.add(id.name)\n }\n })\n\n return aliases\n}\n","import type {API, ASTPath, JSXAttribute, JSXOpeningElement, JSXSpreadAttribute} from 'jscodeshift'\n\nimport {insertTodoWarning} from './insertTodoWarning'\n\nconst DEFAULT_WARNING = 'Please double check styled-component migration(s) below'\n\n/**\n * Runs callback on JSX styled-component if `filter` passes. Otherwise, adds\n * a TODO on the styled definition if manual review is needed.\n * Returns whether the AST was updated.\n */\nexport function transformStyledComponents(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n aliases: Iterable<string>,\n filter: (attrs: (JSXAttribute | JSXSpreadAttribute)[]) => boolean,\n options: {\n callback?: (path: ASTPath<JSXOpeningElement>) => boolean | void\n warning?: string\n } = {},\n): boolean {\n const names = new Set(aliases)\n const {callback, warning = DEFAULT_WARNING} = options\n const aliasesToWarn = new Set<string>()\n let hasChanges = false\n\n root.find(j.JSXOpeningElement).forEach((path) => {\n const name = path.node.name\n\n if (name.type !== 'JSXIdentifier' || !names.has(name.name)) {\n return\n }\n\n const attrs = path.node.attributes ?? []\n\n if (!filter(attrs)) {\n aliasesToWarn.add(name.name)\n }\n\n if (filter(attrs)) {\n if (callback?.(path)) {\n hasChanges = true\n }\n }\n })\n\n root.find(j.VariableDeclarator).forEach((path) => {\n const {id} = path.node\n\n if (id.type === 'Identifier' && aliasesToWarn.has(id.name)) {\n if (insertTodoWarning(j, path, warning)) {\n hasChanges = true\n }\n }\n })\n\n return hasChanges\n}\n","import {type API, type FileInfo, type JSXSpreadAttribute, type JSXAttribute} from 'jscodeshift'\n\nimport type {BaseOptions} from '../../../types/BaseOptions'\nimport {getComponentLocalNames} from '../../../utils/getComponentLocalNames'\nimport {getStaticAttributeExpression} from '../../../utils/getStaticAttributeExpression'\nimport {getStyledComponentAliases} from '../../../utils/getStyledComponentAliases'\nimport {replaceElement} from '../../../utils/replaceElement'\nimport {shouldTransformComponent} from '../../../utils/shouldTransformComponent'\nimport {transformAttributes} from '../../../utils/transformAttributes'\nimport {transformComponent} from '../../../utils/transformComponent'\nimport {transformImport} from '../../../utils/transformImport'\nimport {transformStyledComponents} from '../../../utils/transformStyledComponents'\nimport {FLEX_MODS} from '../flex/flex.mods'\nimport {GRID_MODS} from '../grid/grid.mods'\nimport {BOX_MODS} from './box.mods'\n\nconst BOX_TODO_WARNING = 'Please double check the Box migration below'\nconst FLEX_TODO_WARNING = 'Please double check the Flex migration below'\nconst GRID_TODO_WARNING = 'Please double check the Grid migration below'\nconst STYLED_TODO_WARNING = 'Please double check styled(Box) migration(s) below'\n\n/** @internal */\nexport default function transform(\n fileInfo: FileInfo,\n api: API,\n options?: BaseOptions,\n): string | undefined {\n const {fromPackage, toPackage} = options || {}\n\n return transformComponent(fileInfo, api, ({j, root, markChanged}) => {\n const localNames = getComponentLocalNames(j, root, 'Box', options)\n const styledAliases = getStyledComponentAliases(j, root, localNames)\n\n if (!shouldTransformComponent(j, root, 'Box', localNames, options)) {\n return\n }\n\n const replaceWithFlex = (attrs: (JSXAttribute | JSXSpreadAttribute)[]) => {\n const display = getStaticAttributeExpression(j, attrs, 'display')\n return display === 'flex' || display == 'inline-flex'\n }\n\n const replaceWithGrid = (attrs: (JSXAttribute | JSXSpreadAttribute)[]) => {\n const display = getStaticAttributeExpression(j, attrs, 'display')\n return display === 'grid' || display == 'inline-grid'\n }\n\n if (transformImport(j, root, 'Box', fromPackage, toPackage)) {\n markChanged()\n }\n\n if (\n replaceElement(\n j,\n root,\n replaceWithFlex,\n {\n element: 'Box',\n localNames,\n },\n {\n element: 'Flex',\n callback: (path) => transformAttributes(j, path, FLEX_MODS, FLEX_TODO_WARNING),\n },\n )\n ) {\n markChanged()\n }\n\n if (\n replaceElement(\n j,\n root,\n replaceWithGrid,\n {\n element: 'Box',\n localNames,\n callback: (path) => transformAttributes(j, path, BOX_MODS, BOX_TODO_WARNING),\n },\n {\n element: 'Grid',\n callback: (path) => transformAttributes(j, path, GRID_MODS, GRID_TODO_WARNING),\n },\n )\n ) {\n markChanged()\n }\n\n if (\n transformStyledComponents(\n j,\n root,\n styledAliases,\n (attrs) => !replaceWithFlex(attrs) && !replaceWithGrid(attrs),\n {\n warning: STYLED_TODO_WARNING,\n callback: (path) => transformAttributes(j, path, BOX_MODS, BOX_TODO_WARNING),\n },\n )\n ) {\n markChanged()\n }\n })\n}\n"],"names":[],"mappings":";;;;;AAAO,SAAS,uBAAuB,MAA8B;AACnE,MAAI,CAAC,QAAQ,OAAO,QAAS,YAAY,EAAE,UAAU;AACnD,WAAO;AAGT,QAAM,UAAU;AAQhB,MAAI,QAAQ,SAAS;AACnB,WAAO,uBAAuB,QAAQ,GAAG;AAG3C,MAAI,QAAQ,SAAS,kBAAkB;AACrC,UAAM,SAAS,QAAQ;AAEvB,QACE,UACA,OAAO,UAAW,YAClB,UAAU,UACV,OAAO,SAAS,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U,CAAC,SAAS,oBAAoB,GAAG,MAAM,WAAW,iBAAiB;AAAA,MAAA;AAAA,IAC/E,KAGF,eAIA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA,CAAC,UAAU,CAAC,gBAAgB,KAAK,KAAK,CAAC,gBAAgB,KAAK;AAAA,MAC5D;AAAA,QACE,SAAS;AAAA,QACT,UAAU,CAAC,SAAS,oBAAoB,GAAG,MAAM,UAAU,gBAAgB;AAAA,MAAA;AAAA,IAC7E,KAGF,YAAA;AAAA,EAEJ,CAAC;AACH;"}
1
+ {"version":3,"file":"box.js","sources":["../../../../src/utils/parseModule.ts","../../../../src/utils/resolveRelativeModulePath.ts","../../../../src/utils/getNamedExportInit.ts","../../../../src/utils/getStyledComponentName.ts","../../../../src/utils/getStyledComponentAliases.ts","../../../../src/utils/transformStyledComponents.ts","../../../../src/transforms/latest/box/box.ts"],"sourcesContent":["import {readFileSync} from 'node:fs'\n\nimport type {API, Collection} from 'jscodeshift'\n\nconst parseCache = new Map<string, Collection>()\n\nexport function parseModule(j: API['jscodeshift'], filePath: string): Collection | null {\n const cached = parseCache.get(filePath)\n\n if (cached) {\n return cached\n }\n\n try {\n const source = readFileSync(filePath, 'utf8')\n const root = j(source)\n\n parseCache.set(filePath, root)\n\n return root\n } catch {\n return null\n }\n}\n\n/** @internal */\nexport function clearModuleParseCache(): void {\n parseCache.clear()\n}\n","import {existsSync} from 'node:fs'\nimport {dirname, join, resolve} from 'node:path'\n\nconst EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js'] as const\n\nexport function resolveRelativeModulePath(\n fromFilePath: string,\n moduleSpecifier: string,\n): string | null {\n if (!moduleSpecifier.startsWith('.')) {\n return null\n }\n\n const base = resolve(dirname(fromFilePath), moduleSpecifier)\n\n for (const ext of EXTENSIONS) {\n const filePath = `${base}${ext}`\n\n if (existsSync(filePath)) {\n return filePath\n }\n }\n\n for (const ext of EXTENSIONS) {\n const indexPath = join(base, `index${ext}`)\n\n if (existsSync(indexPath)) {\n return indexPath\n }\n }\n\n if (existsSync(base)) {\n return base\n }\n\n return null\n}\n","import type {API, Expression, ExportSpecifier} from 'jscodeshift'\n\nimport {parseModule} from './parseModule'\nimport {resolveRelativeModulePath} from './resolveRelativeModulePath'\n\nexport type NamedExportInit = {\n init: Expression\n modulePath: string\n}\n\nfunction findVariableInit(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n name: string,\n): Expression | null {\n let init: Expression | null = null\n\n root.find(j.VariableDeclarator).forEach((path) => {\n const {id} = path.node\n\n if (id.type === 'Identifier' && id.name === name && path.node.init) {\n init = path.node.init\n }\n })\n\n return init\n}\n\nfunction getExportSpecifierName(exported: ExportSpecifier['exported']): string | null {\n if (exported.type === 'Identifier' || exported.type === 'JSXIdentifier') {\n return exported.name\n }\n\n return null\n}\n\nexport function getNamedExportInit(\n j: API['jscodeshift'],\n exportName: string,\n filePath: string,\n visited: Set<string> = new Set(),\n): NamedExportInit | null {\n if (visited.has(filePath)) {\n return null\n }\n\n visited.add(filePath)\n\n const root = parseModule(j, filePath)\n\n if (!root) {\n return null\n }\n\n for (const path of root.find(j.ExportNamedDeclaration).paths()) {\n const {declaration, specifiers, source} = path.node\n const reexportSource = typeof source?.value === 'string' ? source.value : null\n\n if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.type !== 'VariableDeclarator') {\n continue\n }\n\n if (\n declarator.id.type === 'Identifier' &&\n declarator.id.name === exportName &&\n declarator.init\n ) {\n return {init: declarator.init, modulePath: filePath}\n }\n }\n }\n\n for (const spec of specifiers ?? []) {\n if (spec.type !== 'ExportSpecifier') {\n continue\n }\n\n const exported = getExportSpecifierName(spec.exported)\n\n if (!exported || exported !== exportName) {\n continue\n }\n\n const local = spec.local?.type === 'Identifier' ? spec.local.name : exported\n\n if (reexportSource) {\n const resolvedPath = resolveRelativeModulePath(filePath, reexportSource)\n\n if (resolvedPath) {\n const followed = getNamedExportInit(j, local, resolvedPath, visited)\n\n if (followed) {\n return followed\n }\n }\n\n continue\n }\n\n const init = findVariableInit(j, root, local)\n\n if (init) {\n return {init, modulePath: filePath}\n }\n }\n }\n\n return null\n}\n","export function getStyledComponentName(node: unknown): string | null {\n if (!node || typeof node !== 'object' || !('type' in node)) {\n return null\n }\n\n const current = node as {\n type: string\n callee?: unknown\n tag?: unknown\n object?: unknown\n arguments?: unknown[]\n }\n\n if (current.type === 'TaggedTemplateExpression') {\n return getStyledComponentName(current.tag)\n }\n\n if (current.type === 'CallExpression') {\n const callee = current.callee\n\n if (\n callee &&\n typeof callee === 'object' &&\n 'type' in callee &&\n callee.type === 'Identifier' &&\n 'name' in callee &&\n callee.name === 'styled'\n ) {\n const arg = current.arguments?.[0]\n\n if (\n arg &&\n typeof arg === 'object' &&\n 'type' in arg &&\n arg.type === 'Identifier' &&\n 'name' in arg\n ) {\n return arg.name as string\n }\n\n return null\n }\n\n return getStyledComponentName(callee)\n }\n\n if (current.type === 'MemberExpression' && current.object) {\n return getStyledComponentName(current.object)\n }\n\n return null\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport type {BaseOptions} from '../types/BaseOptions'\nimport {getComponentLocalNames} from './getComponentLocalNames'\nimport {getNamedExportInit} from './getNamedExportInit'\nimport {getStyledComponentName} from './getStyledComponentName'\nimport {parseModule} from './parseModule'\nimport {resolveRelativeModulePath} from './resolveRelativeModulePath'\n\nexport function getSameFileStyledComponentAliases(\n j: API['jscodeshift'],\n root: Collection,\n localNames: Iterable<string>,\n): Set<string> {\n const aliases = new Set<string>()\n const names = new Set(localNames)\n\n root.find(j.VariableDeclarator).forEach((path) => {\n const {id, init} = path.node\n\n if (!init || id.type !== 'Identifier') {\n return\n }\n\n const baseComponent = getStyledComponentName(init)\n\n if (baseComponent && names.has(baseComponent)) {\n aliases.add(id.name)\n }\n })\n\n return aliases\n}\n\nexport function getImportedStyledComponentAliases(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n filePath: string | undefined,\n options?: BaseOptions,\n): Set<string> {\n const aliases = new Set<string>()\n\n if (!filePath) {\n return aliases\n }\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const source = path.node.source.value\n\n if (typeof source !== 'string') {\n return\n }\n\n const resolvedPath = resolveRelativeModulePath(filePath, source)\n\n if (!resolvedPath) {\n return\n }\n\n for (const spec of path.node.specifiers ?? []) {\n if (spec.type !== 'ImportSpecifier') {\n continue\n }\n\n if ('importKind' in spec && spec.importKind === 'type') {\n continue\n }\n\n if (spec.imported.type !== 'Identifier') {\n continue\n }\n\n const exportName = spec.imported.name\n const localName = spec.local?.type === 'Identifier' ? spec.local.name : exportName\n const namedExport = getNamedExportInit(j, exportName, resolvedPath)\n\n if (!namedExport) {\n continue\n }\n\n const sourceRoot = parseModule(j, namedExport.modulePath)\n\n if (!sourceRoot) {\n continue\n }\n\n const exportLocalNames = getComponentLocalNames(j, sourceRoot, componentName, options)\n const baseComponent = getStyledComponentName(namedExport.init)\n\n if (baseComponent && exportLocalNames.has(baseComponent)) {\n aliases.add(localName)\n }\n }\n })\n\n return aliases\n}\n\nexport function getStyledComponentAliases(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n filePath: string | undefined,\n localNames: Set<string>,\n options?: BaseOptions,\n): Set<string> {\n const sameFile = getSameFileStyledComponentAliases(j, root, localNames)\n const imported = getImportedStyledComponentAliases(j, root, componentName, filePath, options)\n\n return new Set([...sameFile, ...imported])\n}\n","import type {API, ASTPath, JSXAttribute, JSXOpeningElement, JSXSpreadAttribute} from 'jscodeshift'\n\nimport {insertTodoWarning} from './insertTodoWarning'\n\nconst DEFAULT_WARNING = 'Please double check styled-component migration below'\n\n/**\n * Runs callback on JSX styled-component if `filter` passes. Otherwise, adds\n * a TODO on the component JSX instance when manual review is needed.\n * Returns whether the AST was updated.\n */\nexport function transformStyledComponents(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n aliases: Iterable<string>,\n filter: (attrs: (JSXAttribute | JSXSpreadAttribute)[]) => boolean,\n options: {\n callback?: (path: ASTPath<JSXOpeningElement>) => boolean | void\n warning?: string\n } = {},\n): boolean {\n const names = new Set(aliases)\n const {callback, warning = DEFAULT_WARNING} = options\n let hasChanges = false\n\n root.find(j.JSXOpeningElement).forEach((path) => {\n const name = path.node.name\n\n if (name.type !== 'JSXIdentifier' || !names.has(name.name)) {\n return\n }\n\n const attrs = path.node.attributes ?? []\n\n if (!filter(attrs)) {\n if (insertTodoWarning(j, path, warning)) {\n hasChanges = true\n }\n\n return\n }\n\n if (callback?.(path)) {\n hasChanges = true\n }\n })\n\n return hasChanges\n}\n","import {type API, type FileInfo, type JSXSpreadAttribute, type JSXAttribute} from 'jscodeshift'\n\nimport type {BaseOptions} from '../../../types/BaseOptions'\nimport {getComponentLocalNames} from '../../../utils/getComponentLocalNames'\nimport {getStaticAttributeExpression} from '../../../utils/getStaticAttributeExpression'\nimport {getStyledComponentAliases} from '../../../utils/getStyledComponentAliases'\nimport {replaceElement} from '../../../utils/replaceElement'\nimport {shouldTransformComponent} from '../../../utils/shouldTransformComponent'\nimport {transformAttributes} from '../../../utils/transformAttributes'\nimport {transformComponent} from '../../../utils/transformComponent'\nimport {transformImport} from '../../../utils/transformImport'\nimport {transformStyledComponents} from '../../../utils/transformStyledComponents'\nimport {FLEX_MODS} from '../flex/flex.mods'\nimport {GRID_MODS} from '../grid/grid.mods'\nimport {BOX_MODS} from './box.mods'\n\nconst BOX_TODO_WARNING = 'Please double check the Box migration below'\nconst FLEX_TODO_WARNING = 'Please double check the Flex migration below'\nconst GRID_TODO_WARNING = 'Please double check the Grid migration below'\nconst STYLED_TODO_WARNING = 'Please double check styled(Box) migration below'\n\n/** @internal */\nexport default function transform(\n fileInfo: FileInfo,\n api: API,\n options?: BaseOptions,\n): string | undefined {\n const {fromPackage, toPackage} = options || {}\n\n return transformComponent(fileInfo, api, ({j, root, markChanged}) => {\n const localNames = getComponentLocalNames(j, root, 'Box', options)\n const styledAliases = getStyledComponentAliases(\n j,\n root,\n 'Box',\n fileInfo.path,\n localNames,\n options,\n )\n\n if (!shouldTransformComponent(j, root, 'Box', localNames, options, styledAliases)) {\n return\n }\n\n const matchesDisplayValue = (\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n suffix: string,\n exclude: string[],\n ) => {\n const display = getStaticAttributeExpression(j, attrs, 'display') || []\n const values = Array.isArray(display) ? display : [display]\n let matchesExclude\n\n for (const excluded of exclude) {\n if (values.some((value) => typeof value === 'string' && value.endsWith(excluded))) {\n matchesExclude = true\n break\n }\n }\n\n if (matchesExclude) {\n return false\n }\n\n return values.some((value) => typeof value === 'string' && value.endsWith(suffix))\n }\n\n const replaceWithFlex = (attrs: (JSXAttribute | JSXSpreadAttribute)[]) =>\n matchesDisplayValue(attrs, 'flex', ['block', 'inline', 'grid'])\n\n const replaceWithGrid = (attrs: (JSXAttribute | JSXSpreadAttribute)[]) =>\n matchesDisplayValue(attrs, 'grid', ['block', 'inline', 'flex'])\n\n if (transformImport(j, root, 'Box', fromPackage, toPackage)) {\n markChanged()\n }\n\n if (\n replaceElement(\n j,\n root,\n replaceWithFlex,\n {\n element: 'Box',\n localNames,\n },\n {\n element: 'Flex',\n callback: (path) => transformAttributes(j, path, FLEX_MODS, FLEX_TODO_WARNING),\n },\n )\n ) {\n markChanged()\n }\n\n if (\n replaceElement(\n j,\n root,\n replaceWithGrid,\n {\n element: 'Box',\n localNames,\n callback: (path) => transformAttributes(j, path, BOX_MODS, BOX_TODO_WARNING),\n },\n {\n element: 'Grid',\n callback: (path) => transformAttributes(j, path, GRID_MODS, GRID_TODO_WARNING),\n },\n )\n ) {\n markChanged()\n }\n\n if (\n transformStyledComponents(\n j,\n root,\n styledAliases,\n (attrs) => !replaceWithFlex(attrs) && !replaceWithGrid(attrs),\n {\n warning: STYLED_TODO_WARNING,\n callback: (path) => transformAttributes(j, path, BOX_MODS, BOX_TODO_WARNING),\n },\n )\n ) {\n markChanged()\n }\n })\n}\n"],"names":[],"mappings":";;;;;;;AAIA,MAAM,iCAAiB,I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