create-payload-app 4.0.0-internal.cd69eef → 4.0.0-internal.ce66a41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/README.md +5 -0
  2. package/dist/commands.d.ts +4 -0
  3. package/dist/commands.d.ts.map +1 -0
  4. package/dist/commands.js +5 -0
  5. package/dist/commands.js.map +1 -0
  6. package/dist/lib/agent-config.d.ts +12 -0
  7. package/dist/lib/agent-config.d.ts.map +1 -0
  8. package/dist/lib/agent-config.js +15 -0
  9. package/dist/lib/agent-config.js.map +1 -0
  10. package/dist/lib/ast/adapter-config.d.ts.map +1 -1
  11. package/dist/lib/ast/adapter-config.js +0 -10
  12. package/dist/lib/ast/adapter-config.js.map +1 -1
  13. package/dist/lib/ast/package-json.d.ts +9 -0
  14. package/dist/lib/ast/package-json.d.ts.map +1 -1
  15. package/dist/lib/ast/package-json.js +34 -8
  16. package/dist/lib/ast/package-json.js.map +1 -1
  17. package/dist/lib/ast/types.d.ts +1 -1
  18. package/dist/lib/ast/types.d.ts.map +1 -1
  19. package/dist/lib/ast/types.js +0 -1
  20. package/dist/lib/ast/types.js.map +1 -1
  21. package/dist/lib/configure-payload-tsconfig.d.ts +5 -0
  22. package/dist/lib/configure-payload-tsconfig.d.ts.map +1 -0
  23. package/dist/lib/configure-payload-tsconfig.js +26 -0
  24. package/dist/lib/configure-payload-tsconfig.js.map +1 -0
  25. package/dist/lib/create-project.d.ts +1 -2
  26. package/dist/lib/create-project.d.ts.map +1 -1
  27. package/dist/lib/create-project.js +56 -29
  28. package/dist/lib/create-project.js.map +1 -1
  29. package/dist/lib/generate-secret.js +1 -1
  30. package/dist/lib/generate-secret.js.map +1 -1
  31. package/dist/lib/get-package-manager.d.ts +9 -0
  32. package/dist/lib/get-package-manager.d.ts.map +1 -1
  33. package/dist/lib/get-package-manager.js +20 -0
  34. package/dist/lib/get-package-manager.js.map +1 -1
  35. package/dist/lib/init-next.d.ts.map +1 -1
  36. package/dist/lib/init-next.js +5 -34
  37. package/dist/lib/init-next.js.map +1 -1
  38. package/dist/lib/init-tanstack.d.ts +18 -0
  39. package/dist/lib/init-tanstack.d.ts.map +1 -0
  40. package/dist/lib/init-tanstack.js +149 -0
  41. package/dist/lib/init-tanstack.js.map +1 -0
  42. package/dist/lib/tanstack/detect.d.ts +5 -0
  43. package/dist/lib/tanstack/detect.d.ts.map +1 -0
  44. package/dist/lib/tanstack/detect.js +131 -0
  45. package/dist/lib/tanstack/detect.js.map +1 -0
  46. package/dist/lib/tanstack/prepare.d.ts +23 -0
  47. package/dist/lib/tanstack/prepare.d.ts.map +1 -0
  48. package/dist/lib/tanstack/prepare.js +114 -0
  49. package/dist/lib/tanstack/prepare.js.map +1 -0
  50. package/dist/lib/tanstack/template-files.d.ts +50 -0
  51. package/dist/lib/tanstack/template-files.d.ts.map +1 -0
  52. package/dist/lib/tanstack/template-files.js +64 -0
  53. package/dist/lib/tanstack/template-files.js.map +1 -0
  54. package/dist/lib/tanstack/transform-root-route.d.ts +7 -0
  55. package/dist/lib/tanstack/transform-root-route.d.ts.map +1 -0
  56. package/dist/lib/tanstack/transform-root-route.js +747 -0
  57. package/dist/lib/tanstack/transform-root-route.js.map +1 -0
  58. package/dist/lib/tanstack/transform-router.d.ts +5 -0
  59. package/dist/lib/tanstack/transform-router.d.ts.map +1 -0
  60. package/dist/lib/tanstack/transform-router.js +301 -0
  61. package/dist/lib/tanstack/transform-router.js.map +1 -0
  62. package/dist/lib/tanstack/transform-vite-config.d.ts +14 -0
  63. package/dist/lib/tanstack/transform-vite-config.d.ts.map +1 -0
  64. package/dist/lib/tanstack/transform-vite-config.js +576 -0
  65. package/dist/lib/tanstack/transform-vite-config.js.map +1 -0
  66. package/dist/lib/templates.d.ts.map +1 -1
  67. package/dist/lib/templates.js +6 -0
  68. package/dist/lib/templates.js.map +1 -1
  69. package/dist/lib/update-payload-in-project.d.ts +18 -3
  70. package/dist/lib/update-payload-in-project.d.ts.map +1 -1
  71. package/dist/lib/update-payload-in-project.js +98 -18
  72. package/dist/lib/update-payload-in-project.js.map +1 -1
  73. package/dist/main.d.ts +20 -1
  74. package/dist/main.d.ts.map +1 -1
  75. package/dist/main.js +120 -30
  76. package/dist/main.js.map +1 -1
  77. package/dist/scripts/pack-template-files.js +18 -0
  78. package/dist/scripts/pack-template-files.js.map +1 -1
  79. package/dist/template/src/app/(frontend)/styles.css +8 -1
  80. package/dist/template/src/app/(payload)/admin/[[...segments]]/not-found.tsx +1 -2
  81. package/dist/template/src/app/(payload)/admin/[[...segments]]/page.tsx +1 -2
  82. package/dist/template/src/app/(payload)/admin/importMap.js +15 -0
  83. package/dist/template/src/app/(payload)/api/[...slug]/route.ts +1 -2
  84. package/dist/template/src/app/(payload)/api/graphql/route.ts +1 -2
  85. package/dist/template/src/app/(payload)/api/graphql-playground/route.ts +1 -2
  86. package/dist/template/src/app/(payload)/layout.tsx +2 -3
  87. package/dist/template/src/payload.config.ts +4 -2
  88. package/dist/template-tanstack/routes/_payload/admin.$.tsx +9 -0
  89. package/dist/template-tanstack/routes/_payload/admin.index.tsx +9 -0
  90. package/dist/template-tanstack/routes/_payload/api.$.ts +11 -0
  91. package/dist/template-tanstack/routes/_payload/importMap.js +32 -0
  92. package/dist/template-tanstack/routes/_payload/server.functions.ts +50 -0
  93. package/dist/template-tanstack/routes/_payload.tsx +31 -0
  94. package/dist/template-tanstack/src/collections/Folders.ts +16 -0
  95. package/dist/template-tanstack/src/collections/Media.ts +20 -0
  96. package/dist/template-tanstack/src/collections/Tags.ts +16 -0
  97. package/dist/template-tanstack/src/collections/Users.ts +14 -0
  98. package/dist/template-tanstack/src/payload.config.ts +38 -0
  99. package/dist/template-tanstack/src/payload.css +1 -0
  100. package/dist/types.d.ts +22 -3
  101. package/dist/types.d.ts.map +1 -1
  102. package/dist/types.js.map +1 -1
  103. package/dist/utils/messages.d.ts +1 -0
  104. package/dist/utils/messages.d.ts.map +1 -1
  105. package/dist/utils/messages.js +8 -6
  106. package/dist/utils/messages.js.map +1 -1
  107. package/package.json +6 -6
  108. package/dist/ast-integration.spec.js +0 -132
  109. package/dist/ast-integration.spec.js.map +0 -1
  110. package/dist/lib/ast/package-json.spec.js +0 -67
  111. package/dist/lib/ast/package-json.spec.js.map +0 -1
  112. package/dist/lib/ast/payload-config.spec.js +0 -365
  113. package/dist/lib/ast/payload-config.spec.js.map +0 -1
  114. package/dist/lib/ast/utils.spec.js +0 -226
  115. package/dist/lib/ast/utils.spec.js.map +0 -1
  116. package/dist/lib/create-project.spec.js +0 -190
  117. package/dist/lib/create-project.spec.js.map +0 -1
  118. package/dist/lib/download-skill.d.ts +0 -8
  119. package/dist/lib/download-skill.d.ts.map +0 -1
  120. package/dist/lib/download-skill.js +0 -35
  121. package/dist/lib/download-skill.js.map +0 -1
  122. package/dist/lib/manage-env-files.spec.js +0 -118
  123. package/dist/lib/manage-env-files.spec.js.map +0 -1
  124. package/dist/lib/select-agent.d.ts +0 -16
  125. package/dist/lib/select-agent.d.ts.map +0 -1
  126. package/dist/lib/select-agent.js +0 -67
  127. package/dist/lib/select-agent.js.map +0 -1
  128. package/dist/lib/wrap-next-config.spec.js +0 -167
  129. package/dist/lib/wrap-next-config.spec.js.map +0 -1
  130. package/dist/utils/resolvePackageVersion.spec.js +0 -77
  131. package/dist/utils/resolvePackageVersion.spec.js.map +0 -1
  132. /package/dist/template/src/app/(payload)/{custom.scss → custom.css} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/tanstack/transform-root-route.ts"],"sourcesContent":["import type {\n ArrayLiteralExpression,\n ArrowFunction,\n Expression,\n FunctionDeclaration,\n FunctionExpression,\n ImportDeclaration,\n JsxSelfClosingElement,\n Node as MorphNode,\n ObjectLiteralExpression,\n PropertyAssignment,\n SourceFile,\n} from 'ts-morph'\n\nimport { Node, Project, QuoteKind, SyntaxKind } from 'ts-morph'\n\nimport type { TanStackAppDetails } from '../../types.js'\nimport type { TextTransformResult } from './transform-vite-config.js'\n\ntype LocalBinding =\n | {\n importedName?: string\n importKind: 'default' | 'named' | 'namespace'\n isTypeOnly: boolean\n kind: 'import'\n moduleSpecifier: string\n }\n | { kind: 'other' | 'variable' }\n\ntype NamedImport = { declaration: ImportDeclaration; localName: string }\ntype RouteComponentFunction = ArrowFunction | FunctionDeclaration | FunctionExpression\n\nconst PAYLOAD_CLIENT_MODULE = '@payloadcms/tanstack-start/client'\nconst ROUTER_MODULE = '@tanstack/react-router'\n\nexport function transformTanStackRootRoute({\n content,\n kind,\n}: {\n content: string\n kind: TanStackAppDetails['kind']\n}): TextTransformResult {\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n useInMemoryFileSystem: true,\n })\n const sourceFile = project.createSourceFile('__root.tsx', content)\n const createRootRouteImport = getNamedImport({\n importedName: 'createRootRoute',\n moduleSpecifier: ROUTER_MODULE,\n sourceFile,\n })\n\n if (!createRootRouteImport) {\n return failure('Could not identify the createRootRoute import.')\n }\n\n const createRootRouteCalls = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((call) => call.getExpression().getText() === createRootRouteImport.localName)\n\n if (createRootRouteCalls.length !== 1) {\n return failure('Expected exactly one createRootRoute() call.')\n }\n\n const createRootRouteCall = createRootRouteCalls[0]!\n if (createRootRouteCall.getArguments().length !== 1) {\n return failure('createRootRoute() must receive exactly one argument.')\n }\n\n const rootObject = createRootRouteCall.getArguments()[0]\n if (!Node.isObjectLiteralExpression(rootObject)) {\n return failure('createRootRoute() must receive an object literal.')\n }\n\n if (rootObject.getProperties().some(Node.isSpreadAssignment)) {\n return failure('Root route object spreads cannot be transformed safely.')\n }\n\n return kind === 'start'\n ? transformStartRoot({ content, rootObject, sourceFile })\n : transformRouterOnlyRoot({ content, rootObject, sourceFile })\n}\n\nfunction bindingNameIncludes({ localName, node }: { localName: string; node: MorphNode }): boolean {\n if (Node.isIdentifier(node)) {\n return node.getText() === localName\n }\n\n if (Node.isArrayBindingPattern(node) || Node.isObjectBindingPattern(node)) {\n return node\n .getElements()\n .some(\n (element) =>\n Node.isBindingElement(element) &&\n bindingNameIncludes({ localName, node: element.getNameNode() }),\n )\n }\n\n return false\n}\n\nfunction ensureNamedImport({\n importedName,\n moduleSpecifier,\n sourceFile,\n}: {\n importedName: string\n moduleSpecifier: string\n sourceFile: SourceFile\n}) {\n const declaration = sourceFile\n .getImportDeclarations()\n .find(\n (candidate) =>\n candidate.getModuleSpecifierValue() === moduleSpecifier &&\n !candidate.isTypeOnly() &&\n !candidate.getNamespaceImport(),\n )\n\n if (\n declaration\n ?.getNamedImports()\n .some((namedImport) => namedImport.getName() === importedName && !namedImport.getAliasNode())\n ) {\n return\n }\n\n if (declaration) {\n declaration.addNamedImport(importedName)\n } else {\n sourceFile.addImportDeclaration({ moduleSpecifier, namedImports: [importedName] })\n }\n}\n\nfunction failure(reason: string): TextTransformResult {\n return { reason, success: false }\n}\n\nfunction getAppStylesheetImport({\n requireSideEffect,\n sourceFile,\n}: {\n requireSideEffect: boolean\n sourceFile: SourceFile\n}): { declaration: ImportDeclaration; localName?: string; moduleSpecifier: string } | undefined {\n const imports = sourceFile.getImportDeclarations().filter((declaration) => {\n const moduleSpecifier = declaration.getModuleSpecifierValue()\n const isStylesheet = requireSideEffect\n ? /\\.css$/.test(moduleSpecifier)\n : /\\.css\\?url$/.test(moduleSpecifier)\n\n if (!isStylesheet) {\n return false\n }\n\n const hasNamedOrNamespaceImport =\n declaration.getNamedImports().length > 0 || Boolean(declaration.getNamespaceImport())\n return requireSideEffect\n ? !declaration.getDefaultImport() && !hasNamedOrNamespaceImport\n : Boolean(declaration.getDefaultImport()) && !hasNamedOrNamespaceImport\n })\n\n if (imports.length !== 1) {\n return undefined\n }\n\n const declaration = imports[0]!\n return {\n declaration,\n localName: declaration.getDefaultImport()?.getText(),\n moduleSpecifier: declaration.getModuleSpecifierValue(),\n }\n}\n\nfunction getFunction({\n functionName,\n sourceFile,\n}: {\n functionName: string\n sourceFile: SourceFile\n}): FunctionDeclaration | undefined {\n const functions = sourceFile\n .getFunctions()\n .filter((declaration) => declaration.getName() === functionName)\n\n return functions.length === 1 ? functions[0] : undefined\n}\n\nfunction getRouteComponentFunction({\n component,\n sourceFile,\n}: {\n component: Expression\n sourceFile: SourceFile\n}): RouteComponentFunction | undefined {\n if (Node.isArrowFunction(component) || Node.isFunctionExpression(component)) {\n return component\n }\n\n if (!Node.isIdentifier(component)) {\n return undefined\n }\n\n const functions: RouteComponentFunction[] = sourceFile\n .getFunctions()\n .filter((declaration) => declaration.getName() === component.getText())\n const variableFunctions = sourceFile\n .getVariableDeclarations()\n .filter((declaration) => declaration.getName() === component.getText())\n .map((declaration) => declaration.getInitializer())\n .filter(\n (initializer): initializer is ArrowFunction | FunctionExpression =>\n Node.isArrowFunction(initializer) || Node.isFunctionExpression(initializer),\n )\n\n functions.push(...variableFunctions)\n\n return functions.length === 1 ? functions[0] : undefined\n}\n\nfunction isDocumentShellExpression(expression: Expression | undefined): boolean {\n if (!expression) {\n return false\n }\n\n const openingElements = expression.getDescendantsOfKind(SyntaxKind.JsxOpeningElement)\n const selfClosingElements = expression.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)\n\n return [...openingElements, ...selfClosingElements].some(\n (element) => element.getTagNameNode().getText() === 'html',\n )\n}\n\nfunction routeComponentRendersDocumentShell({\n component,\n sourceFile,\n}: {\n component: Expression\n sourceFile: SourceFile\n}): boolean {\n const componentFunction = getRouteComponentFunction({ component, sourceFile })\n if (!componentFunction) {\n return false\n }\n\n const body = componentFunction.getBody()\n if (!body) {\n return false\n }\n\n if (Node.isExpression(body) && isDocumentShellExpression(body)) {\n return true\n }\n\n return body\n .getDescendantsOfKind(SyntaxKind.ReturnStatement)\n .filter((returnStatement) => {\n const containingFunction = returnStatement.getFirstAncestor(\n (ancestor) =>\n Node.isArrowFunction(ancestor) ||\n Node.isFunctionDeclaration(ancestor) ||\n Node.isFunctionExpression(ancestor),\n )\n\n return containingFunction?.getStart() === componentFunction.getStart()\n })\n .some((returnStatement) => isDocumentShellExpression(returnStatement.getExpression()))\n}\n\nfunction getHeadContentNode({\n functionDeclaration,\n localName,\n}: {\n functionDeclaration: FunctionDeclaration\n localName: string\n}): JsxSelfClosingElement | undefined {\n const matches = functionDeclaration\n .getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)\n .filter((element) => element.getTagNameNode().getText() === localName)\n\n return matches.length === 1 ? matches[0] : undefined\n}\n\nfunction getLocalBindings({\n localName,\n sourceFile,\n}: {\n localName: string\n sourceFile: SourceFile\n}): LocalBinding[] {\n const bindings: LocalBinding[] = []\n\n for (const declaration of sourceFile.getImportDeclarations()) {\n const moduleSpecifier = declaration.getModuleSpecifierValue()\n const defaultImport = declaration.getDefaultImport()\n if (defaultImport?.getText() === localName) {\n bindings.push({\n importKind: 'default',\n isTypeOnly: declaration.isTypeOnly(),\n kind: 'import',\n moduleSpecifier,\n })\n }\n\n const namespaceImport = declaration.getNamespaceImport()\n if (namespaceImport?.getText() === localName) {\n bindings.push({\n importKind: 'namespace',\n isTypeOnly: declaration.isTypeOnly(),\n kind: 'import',\n moduleSpecifier,\n })\n }\n\n for (const namedImport of declaration.getNamedImports()) {\n const namedImportLocalName = namedImport.getAliasNode()?.getText() ?? namedImport.getName()\n if (namedImportLocalName === localName) {\n bindings.push({\n importedName: namedImport.getName(),\n importKind: 'named',\n isTypeOnly: declaration.isTypeOnly() || namedImport.isTypeOnly(),\n kind: 'import',\n moduleSpecifier,\n })\n }\n }\n }\n\n for (const declaration of sourceFile.getVariableDeclarations()) {\n if (bindingNameIncludes({ localName, node: declaration.getNameNode() })) {\n bindings.push({ kind: 'variable' })\n }\n }\n\n const hasOtherDeclaration = [\n ...sourceFile.getClasses(),\n ...sourceFile.getEnums(),\n ...sourceFile.getFunctions(),\n ...sourceFile.getModules(),\n ].some((declaration) => declaration.getName() === localName)\n\n if (hasOtherDeclaration) {\n bindings.push({ kind: 'other' })\n }\n\n return bindings\n}\n\nfunction getNamedImport({\n importedName,\n moduleSpecifier,\n sourceFile,\n}: {\n importedName: string\n moduleSpecifier: string\n sourceFile: SourceFile\n}): NamedImport | undefined {\n const imports = sourceFile.getImportDeclarations().flatMap((declaration) =>\n declaration.getModuleSpecifierValue() === moduleSpecifier\n ? declaration\n .getNamedImports()\n .filter((namedImport) => namedImport.getName() === importedName)\n .map((namedImport) => ({\n declaration,\n localName: namedImport.getAliasNode()?.getText() ?? namedImport.getName(),\n }))\n : [],\n )\n\n if (imports.length !== 1) {\n return undefined\n }\n\n const imported = imports[0]!\n const bindings = getLocalBindings({ localName: imported.localName, sourceFile })\n const binding = bindings[0]\n\n if (\n bindings.length !== 1 ||\n binding?.kind !== 'import' ||\n binding.importKind !== 'named' ||\n binding.importedName !== importedName ||\n binding.isTypeOnly ||\n binding.moduleSpecifier !== moduleSpecifier\n ) {\n return undefined\n }\n\n return imported\n}\n\nfunction resolveRouterNamedImport({\n importedName,\n sourceFile,\n}: {\n importedName: 'HeadContent' | 'Scripts'\n sourceFile: SourceFile\n}):\n | { importedName: string; isPresent: boolean; localName: string; success: true }\n | { reason: string; success: false } {\n const matchingImports = sourceFile.getImportDeclarations().flatMap((declaration) =>\n declaration.getModuleSpecifierValue() === ROUTER_MODULE && !declaration.isTypeOnly()\n ? declaration\n .getNamedImports()\n .filter(\n (namedImport) => namedImport.getName() === importedName && !namedImport.isTypeOnly(),\n )\n .map((namedImport) => namedImport.getAliasNode()?.getText() ?? namedImport.getName())\n : [],\n )\n\n if (matchingImports.length > 1) {\n return {\n reason: `The TanStack router module imports ${importedName} more than once.`,\n success: false,\n }\n }\n\n const localName = matchingImports[0] ?? importedName\n const bindings = getLocalBindings({ localName, sourceFile })\n const binding = bindings[0]\n const isCompatible =\n binding?.kind === 'import' &&\n binding.importKind === 'named' &&\n binding.importedName === importedName &&\n !binding.isTypeOnly &&\n binding.moduleSpecifier === ROUTER_MODULE\n\n if (bindings.length > 0 && (bindings.length !== 1 || !isCompatible)) {\n return {\n reason: `Identifier \"${localName}\" is already bound incompatibly.`,\n success: false,\n }\n }\n\n return { importedName, isPresent: matchingImports.length === 1, localName, success: true }\n}\n\nfunction getSideEffectStylesheetImports(sourceFile: SourceFile): ImportDeclaration[] {\n return sourceFile\n .getImportDeclarations()\n .filter(\n (declaration) =>\n /\\.css$/.test(declaration.getModuleSpecifierValue()) &&\n !declaration.getDefaultImport() &&\n !declaration.getNamespaceImport() &&\n declaration.getNamedImports().length === 0,\n )\n}\n\nfunction getPropertyName(node: MorphNode): string | undefined {\n if (\n Node.isPropertyAssignment(node) ||\n Node.isShorthandPropertyAssignment(node) ||\n Node.isMethodDeclaration(node) ||\n Node.isGetAccessorDeclaration(node) ||\n Node.isSetAccessorDeclaration(node)\n ) {\n return node.getName()\n }\n}\n\nfunction getPropertyAssignment({\n object,\n propertyName,\n}: {\n object: ObjectLiteralExpression\n propertyName: string\n}) {\n const properties = object\n .getProperties()\n .filter((property) => getPropertyName(property) === propertyName)\n\n return properties.length === 1 && Node.isPropertyAssignment(properties[0])\n ? properties[0]\n : undefined\n}\n\nfunction getRootHeadLinks(\n rootObject: ObjectLiteralExpression,\n): { links: ArrayLiteralExpression; success: true } | { reason: string; success: false } {\n const headProperty = getPropertyAssignment({ object: rootObject, propertyName: 'head' })\n const headInitializer = headProperty?.getInitializer()\n if (!headInitializer || !Node.isArrowFunction(headInitializer)) {\n return { reason: 'The root head declaration cannot be transformed safely.', success: false }\n }\n\n const body = headInitializer.getBody()\n const headObject = Node.isParenthesizedExpression(body) ? body.getExpression() : body\n if (!Node.isObjectLiteralExpression(headObject)) {\n return { reason: 'The root head declaration cannot be transformed safely.', success: false }\n }\n\n const linksProperty = getPropertyAssignment({ object: headObject, propertyName: 'links' })\n const links = linksProperty?.getInitializer()\n if (\n !links ||\n !Node.isArrayLiteralExpression(links) ||\n links.getElements().some(Node.isSpreadElement)\n ) {\n return { reason: 'The root head links cannot be transformed safely.', success: false }\n }\n\n return { links, success: true }\n}\n\nfunction getShellState({\n expectedComponent,\n rootObject,\n withPayloadRootLocalName,\n}: {\n expectedComponent?: string\n rootObject: ObjectLiteralExpression\n withPayloadRootLocalName: string\n}):\n | { componentName: string; isWrapped: boolean; property?: PropertyAssignment; success: true }\n | { reason: string; success: false } {\n const properties = rootObject\n .getProperties()\n .filter((property) => getPropertyName(property) === 'shellComponent')\n\n if (properties.length === 0) {\n if (!expectedComponent) {\n return { componentName: 'RootDocument', isWrapped: false, success: true }\n }\n\n return {\n reason: 'The existing shellComponent cannot be transformed safely.',\n success: false,\n }\n }\n\n const property = properties[0]\n if (properties.length !== 1 || !property || !Node.isPropertyAssignment(property)) {\n return {\n reason: 'The existing shellComponent cannot be transformed safely.',\n success: false,\n }\n }\n\n const initializer = property.getInitializer()\n if (\n Node.isIdentifier(initializer) &&\n (!expectedComponent || initializer.getText() === expectedComponent)\n ) {\n return {\n componentName: initializer.getText(),\n isWrapped: false,\n property,\n success: true,\n }\n }\n\n if (\n Node.isCallExpression(initializer) &&\n initializer.getExpression().getText() === withPayloadRootLocalName &&\n initializer.getArguments().length === 1 &&\n Node.isIdentifier(initializer.getArguments()[0]) &&\n (!expectedComponent || initializer.getArguments()[0]!.getText() === expectedComponent)\n ) {\n return {\n componentName: initializer.getArguments()[0]!.getText(),\n isWrapped: true,\n property,\n success: true,\n }\n }\n\n return {\n reason: 'The existing shellComponent cannot be transformed safely.',\n success: false,\n }\n}\n\nfunction getStylesheetAttribute({\n name,\n element,\n}: {\n element: JsxSelfClosingElement\n name: string\n}): string | undefined {\n const attribute = element\n .getAttributes()\n .find(\n (candidate) => Node.isJsxAttribute(candidate) && candidate.getNameNode().getText() === name,\n )\n\n if (!attribute || !Node.isJsxAttribute(attribute)) {\n return undefined\n }\n\n const initializer = attribute.getInitializer()\n if (Node.isStringLiteral(initializer)) {\n return initializer.getLiteralValue()\n }\n\n if (Node.isJsxExpression(initializer)) {\n return initializer.getExpression()?.getText()\n }\n}\n\nfunction transformRouterOnlyRoot({\n content,\n rootObject,\n sourceFile,\n}: {\n content: string\n rootObject: ObjectLiteralExpression\n sourceFile: SourceFile\n}): TextTransformResult {\n const withPayloadRootImport = getNamedImport({\n importedName: 'withPayloadRoot',\n moduleSpecifier: PAYLOAD_CLIENT_MODULE,\n sourceFile,\n })\n const withPayloadRootLocalName = withPayloadRootImport?.localName ?? 'withPayloadRoot'\n const shellState = getShellState({ rootObject, withPayloadRootLocalName })\n if (!shellState.success) {\n return shellState\n }\n\n if (shellState.property && !shellState.isWrapped) {\n return failure('The existing shellComponent cannot be transformed safely.')\n }\n\n if (shellState.isWrapped && getSideEffectStylesheetImports(sourceFile).length > 0) {\n return failure('Side-effect stylesheet imports cannot be isolated from admin.')\n }\n\n const headContentImport = resolveRouterNamedImport({\n importedName: 'HeadContent',\n sourceFile,\n })\n if (!headContentImport.success) {\n return headContentImport\n }\n\n const scriptsImport = resolveRouterNamedImport({ importedName: 'Scripts', sourceFile })\n if (!scriptsImport.success) {\n return scriptsImport\n }\n\n const destinationValidation = validateRouterOnlyDestinations({\n isAlreadyWrapped: shellState.isWrapped,\n sourceFile,\n withPayloadRootLocalName,\n })\n if (!destinationValidation.success) {\n return destinationValidation\n }\n\n if (shellState.isWrapped) {\n const stylesheetImport = getAppStylesheetImport({ requireSideEffect: false, sourceFile })\n const rootDocument = getFunction({ functionName: 'RootDocument', sourceFile })\n if (\n !stylesheetImport ||\n stylesheetImport.localName !== 'appCss' ||\n !rootDocument ||\n !hasValidAppStylesheetLink({\n functionDeclaration: rootDocument,\n headContentLocalName: headContentImport.localName,\n localName: 'appCss',\n })\n ) {\n return failure('The existing Payload root shell does not match the supported configuration.')\n }\n\n const hasWithPayloadImport = Boolean(withPayloadRootImport)\n const hasAllRequiredImports =\n hasWithPayloadImport && headContentImport.isPresent && scriptsImport.isPresent\n\n if (!hasAllRequiredImports) {\n if (!hasWithPayloadImport) {\n ensureNamedImport({\n importedName: 'withPayloadRoot',\n moduleSpecifier: PAYLOAD_CLIENT_MODULE,\n sourceFile,\n })\n }\n if (!headContentImport.isPresent) {\n ensureNamedImport({\n importedName: 'HeadContent',\n moduleSpecifier: ROUTER_MODULE,\n sourceFile,\n })\n }\n if (!scriptsImport.isPresent) {\n ensureNamedImport({\n importedName: 'Scripts',\n moduleSpecifier: ROUTER_MODULE,\n sourceFile,\n })\n }\n sourceFile.formatText({ indentSize: 2 })\n\n return { content: sourceFile.getFullText(), modified: true, success: true }\n }\n\n return { content, modified: false, success: true }\n }\n\n const sideEffectStylesheets = getSideEffectStylesheetImports(sourceFile)\n\n if (sideEffectStylesheets.length !== 1) {\n return failure('Expected exactly one side-effect stylesheet import.')\n }\n\n const stylesheetImport = sideEffectStylesheets[0]!\n const componentProperties = rootObject\n .getProperties()\n .filter((property) => getPropertyName(property) === 'component')\n const componentProperty = componentProperties[0]\n if (\n componentProperties.length !== 1 ||\n !Node.isPropertyAssignment(componentProperty) ||\n !componentProperty.getInitializer()\n ) {\n return failure('The Router-only root must contain exactly one component option.')\n }\n\n if (\n routeComponentRendersDocumentShell({\n component: componentProperty.getInitializer()!,\n sourceFile,\n })\n ) {\n return failure('The Router-only route component cannot render the document shell.')\n }\n\n stylesheetImport.setDefaultImport('appCss')\n stylesheetImport.setModuleSpecifier(`${stylesheetImport.getModuleSpecifierValue()}?url`)\n rootObject.addPropertyAssignment({\n name: 'shellComponent',\n initializer: `${withPayloadRootLocalName}(RootDocument)`,\n })\n if (!withPayloadRootImport) {\n ensureNamedImport({\n importedName: 'withPayloadRoot',\n moduleSpecifier: PAYLOAD_CLIENT_MODULE,\n sourceFile,\n })\n }\n if (!headContentImport.isPresent) {\n ensureNamedImport({ importedName: 'HeadContent', moduleSpecifier: ROUTER_MODULE, sourceFile })\n }\n if (!scriptsImport.isPresent) {\n ensureNamedImport({ importedName: 'Scripts', moduleSpecifier: ROUTER_MODULE, sourceFile })\n }\n sourceFile.addStatements(`\nfunction RootDocument({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\" suppressHydrationWarning>\n <head>\n <link href={appCss} rel=\"stylesheet\" />\n <${headContentImport.localName} />\n </head>\n <body>\n {children}\n <${scriptsImport.localName} />\n </body>\n </html>\n )\n}`)\n sourceFile.formatText({ indentSize: 2 })\n\n return { content: sourceFile.getFullText(), modified: true, success: true }\n}\n\nfunction transformStartRoot({\n content,\n rootObject,\n sourceFile,\n}: {\n content: string\n rootObject: ObjectLiteralExpression\n sourceFile: SourceFile\n}): TextTransformResult {\n if (getSideEffectStylesheetImports(sourceFile).length > 0) {\n return failure('Side-effect stylesheet imports cannot be isolated from admin.')\n }\n\n const withPayloadRootImport = getNamedImport({\n importedName: 'withPayloadRoot',\n moduleSpecifier: PAYLOAD_CLIENT_MODULE,\n sourceFile,\n })\n const withPayloadRootLocalName = withPayloadRootImport?.localName ?? 'withPayloadRoot'\n const shellState = getShellState({\n expectedComponent: undefined,\n rootObject,\n withPayloadRootLocalName,\n })\n if (!shellState.success || !shellState.property) {\n return shellState.success\n ? failure('The existing shellComponent cannot be transformed safely.')\n : shellState\n }\n\n const withPayloadValidation = validateNamedDestination({\n importedName: 'withPayloadRoot',\n localName: withPayloadRootLocalName,\n moduleSpecifier: PAYLOAD_CLIENT_MODULE,\n sourceFile,\n })\n if (!withPayloadValidation.success) {\n return withPayloadValidation\n }\n const hasWithPayloadImport = Boolean(withPayloadRootImport)\n\n const headContentImport = getNamedImport({\n importedName: 'HeadContent',\n moduleSpecifier: ROUTER_MODULE,\n sourceFile,\n })\n const scriptsImport = getNamedImport({\n importedName: 'Scripts',\n moduleSpecifier: ROUTER_MODULE,\n sourceFile,\n })\n if (!headContentImport || !scriptsImport) {\n return failure('Could not identify the Start document imports.')\n }\n\n const stylesheetImport = getAppStylesheetImport({ requireSideEffect: false, sourceFile })\n if (!stylesheetImport?.localName) {\n return failure('Could not identify the app stylesheet import.')\n }\n\n const stylesheetBindings = getLocalBindings({ localName: stylesheetImport.localName, sourceFile })\n const stylesheetBinding = stylesheetBindings[0]\n if (\n stylesheetBindings.length !== 1 ||\n stylesheetBinding?.kind !== 'import' ||\n stylesheetBinding.importKind !== 'default' ||\n stylesheetBinding.isTypeOnly ||\n stylesheetBinding.moduleSpecifier !== stylesheetImport.moduleSpecifier\n ) {\n return failure(`Identifier \"${stylesheetImport.localName}\" is already bound incompatibly.`)\n }\n\n const rootDocument = getFunction({ functionName: shellState.componentName, sourceFile })\n if (!rootDocument) {\n return failure('Could not identify the Start root document component.')\n }\n\n const headContentNode = getHeadContentNode({\n functionDeclaration: rootDocument,\n localName: headContentImport.localName,\n })\n if (!headContentNode) {\n return failure('Could not identify HeadContent in the Start root document.')\n }\n\n const headLinks = getRootHeadLinks(rootObject)\n if (!headLinks.success) {\n return headLinks\n }\n\n let stylesheetIndex = -1\n for (const [index, element] of headLinks.links.getElements().entries()) {\n if (!Node.isObjectLiteralExpression(element)) {\n return failure('The app stylesheet link cannot be relocated safely.')\n }\n\n if (element.getProperties().some(Node.isSpreadAssignment)) {\n return failure('The app stylesheet link cannot be relocated safely.')\n }\n\n const rel = getStaticObjectPropertyValue({ object: element, propertyName: 'rel' })\n if (rel !== 'stylesheet') {\n continue\n }\n\n const hrefProperty = getPropertyAssignment({ object: element, propertyName: 'href' })\n if (\n hrefProperty?.getInitializer()?.getText() !== stylesheetImport.localName ||\n stylesheetIndex !== -1\n ) {\n return failure('The app stylesheet link cannot be relocated safely.')\n }\n\n stylesheetIndex = index\n }\n\n const hasStylesheetLink = hasValidAppStylesheetLink({\n functionDeclaration: rootDocument,\n headContentLocalName: headContentImport.localName,\n localName: stylesheetImport.localName,\n })\n if (stylesheetIndex === -1 && !hasStylesheetLink) {\n return failure('The app stylesheet link cannot be relocated safely.')\n }\n\n if (shellState.isWrapped && stylesheetIndex === -1 && hasStylesheetLink && hasWithPayloadImport) {\n return { content, modified: false, success: true }\n }\n\n if (stylesheetIndex !== -1) {\n headLinks.links.removeElement(stylesheetIndex)\n }\n if (!hasStylesheetLink) {\n headContentNode.replaceWithText(\n `<link href={${stylesheetImport.localName}} rel=\"stylesheet\" />\\n<${headContentImport.localName} />`,\n )\n }\n if (!shellState.isWrapped) {\n shellState.property.setInitializer(`${withPayloadRootLocalName}(${shellState.componentName})`)\n }\n if (!withPayloadRootImport) {\n ensureNamedImport({\n importedName: 'withPayloadRoot',\n moduleSpecifier: PAYLOAD_CLIENT_MODULE,\n sourceFile,\n })\n }\n sourceFile.formatText({ indentSize: 2 })\n\n return { content: sourceFile.getFullText(), modified: true, success: true }\n}\n\nfunction getStaticObjectPropertyValue({\n object,\n propertyName,\n}: {\n object: ObjectLiteralExpression\n propertyName: string\n}): string | undefined {\n const property = getPropertyAssignment({ object, propertyName })\n const initializer = property?.getInitializer()\n\n return Node.isStringLiteral(initializer) ? initializer.getLiteralValue() : undefined\n}\n\nfunction hasValidAppStylesheetLink({\n functionDeclaration,\n headContentLocalName,\n localName,\n}: {\n functionDeclaration: FunctionDeclaration\n headContentLocalName: string\n localName: string\n}): boolean {\n const links = functionDeclaration\n .getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)\n .filter(\n (element) =>\n element.getTagNameNode().getText() === 'link' &&\n getStylesheetAttribute({ name: 'href', element }) === localName &&\n getStylesheetAttribute({ name: 'rel', element }) === 'stylesheet',\n )\n\n const headContentElements = functionDeclaration\n .getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)\n .filter((element) => element.getTagNameNode().getText() === headContentLocalName)\n\n if (links.length !== 1 || headContentElements.length !== 1) {\n return false\n }\n\n const link = links[0]!\n const headContent = headContentElements[0]!\n const linkParent = link.getFirstAncestorByKind(SyntaxKind.JsxElement)\n const headContentParent = headContent.getFirstAncestorByKind(SyntaxKind.JsxElement)\n\n return (\n linkParent?.getStart() === headContentParent?.getStart() &&\n linkParent?.getOpeningElement().getTagNameNode().getText() === 'head' &&\n link.getStart() < headContent.getStart()\n )\n}\n\nfunction validateNamedDestination({\n importedName,\n localName,\n moduleSpecifier,\n sourceFile,\n}: {\n importedName: string\n localName: string\n moduleSpecifier: string\n sourceFile: SourceFile\n}): { reason: string; success: false } | { success: true } {\n const bindings = getLocalBindings({ localName, sourceFile })\n const binding = bindings[0]\n const isCompatible =\n binding?.kind === 'import' &&\n binding.importKind === 'named' &&\n binding.importedName === importedName &&\n !binding.isTypeOnly &&\n binding.moduleSpecifier === moduleSpecifier\n\n if (bindings.length > 0 && (bindings.length !== 1 || !isCompatible)) {\n return {\n reason: `Identifier \"${localName}\" is already bound incompatibly.`,\n success: false,\n }\n }\n\n return { success: true }\n}\n\nfunction validateRouterOnlyDestinations({\n isAlreadyWrapped,\n sourceFile,\n withPayloadRootLocalName,\n}: {\n isAlreadyWrapped: boolean\n sourceFile: SourceFile\n withPayloadRootLocalName: string\n}): { reason: string; success: false } | { success: true } {\n const destinations = [\n {\n importedName: 'withPayloadRoot',\n localName: withPayloadRootLocalName,\n moduleSpecifier: PAYLOAD_CLIENT_MODULE,\n },\n ]\n\n for (const destination of destinations) {\n const validation = validateNamedDestination({ ...destination, sourceFile })\n if (!validation.success) {\n return validation\n }\n }\n\n for (const localName of ['appCss', 'RootDocument']) {\n const bindings = getLocalBindings({ localName, sourceFile })\n if (bindings.length === 0) {\n continue\n }\n\n const binding = bindings[0]\n const isCompatible =\n isAlreadyWrapped &&\n bindings.length === 1 &&\n (localName === 'RootDocument'\n ? binding?.kind === 'other'\n : binding?.kind === 'import' &&\n binding.importKind === 'default' &&\n !binding.isTypeOnly &&\n /\\.css\\?url$/.test(binding.moduleSpecifier))\n\n if (!isCompatible) {\n return {\n reason: `Identifier \"${localName}\" is already bound incompatibly.`,\n success: false,\n }\n }\n }\n\n return { success: true }\n}\n"],"names":["Node","Project","QuoteKind","SyntaxKind","PAYLOAD_CLIENT_MODULE","ROUTER_MODULE","transformTanStackRootRoute","content","kind","project","manipulationSettings","quoteKind","Single","useInMemoryFileSystem","sourceFile","createSourceFile","createRootRouteImport","getNamedImport","importedName","moduleSpecifier","failure","createRootRouteCalls","getDescendantsOfKind","CallExpression","filter","call","getExpression","getText","localName","length","createRootRouteCall","getArguments","rootObject","isObjectLiteralExpression","getProperties","some","isSpreadAssignment","transformStartRoot","transformRouterOnlyRoot","bindingNameIncludes","node","isIdentifier","isArrayBindingPattern","isObjectBindingPattern","getElements","element","isBindingElement","getNameNode","ensureNamedImport","declaration","getImportDeclarations","find","candidate","getModuleSpecifierValue","isTypeOnly","getNamespaceImport","getNamedImports","namedImport","getName","getAliasNode","addNamedImport","addImportDeclaration","namedImports","reason","success","getAppStylesheetImport","requireSideEffect","imports","isStylesheet","test","hasNamedOrNamespaceImport","Boolean","getDefaultImport","undefined","getFunction","functionName","functions","getFunctions","getRouteComponentFunction","component","isArrowFunction","isFunctionExpression","variableFunctions","getVariableDeclarations","map","getInitializer","initializer","push","isDocumentShellExpression","expression","openingElements","JsxOpeningElement","selfClosingElements","JsxSelfClosingElement","getTagNameNode","routeComponentRendersDocumentShell","componentFunction","body","getBody","isExpression","ReturnStatement","returnStatement","containingFunction","getFirstAncestor","ancestor","isFunctionDeclaration","getStart","getHeadContentNode","functionDeclaration","matches","getLocalBindings","bindings","defaultImport","importKind","namespaceImport","namedImportLocalName","hasOtherDeclaration","getClasses","getEnums","getModules","flatMap","imported","binding","resolveRouterNamedImport","matchingImports","isCompatible","isPresent","getSideEffectStylesheetImports","getPropertyName","isPropertyAssignment","isShorthandPropertyAssignment","isMethodDeclaration","isGetAccessorDeclaration","isSetAccessorDeclaration","getPropertyAssignment","object","propertyName","properties","property","getRootHeadLinks","headProperty","headInitializer","headObject","isParenthesizedExpression","linksProperty","links","isArrayLiteralExpression","isSpreadElement","getShellState","expectedComponent","withPayloadRootLocalName","componentName","isWrapped","isCallExpression","getStylesheetAttribute","name","attribute","getAttributes","isJsxAttribute","isStringLiteral","getLiteralValue","isJsxExpression","withPayloadRootImport","shellState","headContentImport","scriptsImport","destinationValidation","validateRouterOnlyDestinations","isAlreadyWrapped","stylesheetImport","rootDocument","hasValidAppStylesheetLink","headContentLocalName","hasWithPayloadImport","hasAllRequiredImports","formatText","indentSize","getFullText","modified","sideEffectStylesheets","componentProperties","componentProperty","setDefaultImport","setModuleSpecifier","addPropertyAssignment","addStatements","withPayloadValidation","validateNamedDestination","stylesheetBindings","stylesheetBinding","headContentNode","headLinks","stylesheetIndex","index","entries","rel","getStaticObjectPropertyValue","hrefProperty","hasStylesheetLink","removeElement","replaceWithText","setInitializer","headContentElements","link","headContent","linkParent","getFirstAncestorByKind","JsxElement","headContentParent","getOpeningElement","destinations","destination","validation"],"mappings":"AAcA,SAASA,IAAI,EAAEC,OAAO,EAAEC,SAAS,EAAEC,UAAU,QAAQ,WAAU;AAkB/D,MAAMC,wBAAwB;AAC9B,MAAMC,gBAAgB;AAEtB,OAAO,SAASC,2BAA2B,EACzCC,OAAO,EACPC,IAAI,EAIL;IACC,MAAMC,UAAU,IAAIR,QAAQ;QAC1BS,sBAAsB;YAAEC,WAAWT,UAAUU,MAAM;QAAC;QACpDC,uBAAuB;IACzB;IACA,MAAMC,aAAaL,QAAQM,gBAAgB,CAAC,cAAcR;IAC1D,MAAMS,wBAAwBC,eAAe;QAC3CC,cAAc;QACdC,iBAAiBd;QACjBS;IACF;IAEA,IAAI,CAACE,uBAAuB;QAC1B,OAAOI,QAAQ;IACjB;IAEA,MAAMC,uBAAuBP,WAC1BQ,oBAAoB,CAACnB,WAAWoB,cAAc,EAC9CC,MAAM,CAAC,CAACC,OAASA,KAAKC,aAAa,GAAGC,OAAO,OAAOX,sBAAsBY,SAAS;IAEtF,IAAIP,qBAAqBQ,MAAM,KAAK,GAAG;QACrC,OAAOT,QAAQ;IACjB;IAEA,MAAMU,sBAAsBT,oBAAoB,CAAC,EAAE;IACnD,IAAIS,oBAAoBC,YAAY,GAAGF,MAAM,KAAK,GAAG;QACnD,OAAOT,QAAQ;IACjB;IAEA,MAAMY,aAAaF,oBAAoBC,YAAY,EAAE,CAAC,EAAE;IACxD,IAAI,CAAC/B,KAAKiC,yBAAyB,CAACD,aAAa;QAC/C,OAAOZ,QAAQ;IACjB;IAEA,IAAIY,WAAWE,aAAa,GAAGC,IAAI,CAACnC,KAAKoC,kBAAkB,GAA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IACC,MAAM4D,eAAe;QACnB;YACEhM,cAAc;YACdU,WAAW0H;YACXnI,iBAAiBf;QACnB;KACD;IAED,KAAK,MAAM+M,eAAeD,aAAc;QACtC,MAAME,aAAazB,yBAAyB;YAAE,GAAGwB,WAAW;YAAErM;QAAW;QACzE,IAAI,CAACsM,WAAWpJ,OAAO,EAAE;YACvB,OAAOoJ;QACT;IACF;IAEA,KAAK,MAAMxL,aAAa;QAAC;QAAU;KAAe,CAAE;QAClD,MAAMmF,WAAWD,iBAAiB;YAAElF;YAAWd;QAAW;QAC1D,IAAIiG,SAASlF,MAAM,KAAK,GAAG;YACzB;QACF;QAEA,MAAM6F,UAAUX,QAAQ,CAAC,EAAE;QAC3B,MAAMc,eACJ2C,oBACAzD,SAASlF,MAAM,KAAK,KACnBD,CAAAA,cAAc,iBACX8F,SAASlH,SAAS,UAClBkH,SAASlH,SAAS,YAClBkH,QAAQT,UAAU,KAAK,aACvB,CAACS,QAAQpE,UAAU,IACnB,cAAce,IAAI,CAACqD,QAAQvG,eAAe,CAAA;QAEhD,IAAI,CAAC0G,cAAc;YACjB,OAAO;gBACL9D,QAAQ,CAAC,YAAY,EAAEnC,UAAU,gCAAgC,CAAC;gBAClEoC,SAAS;YACX;QACF;IACF;IAEA,OAAO;QAAEA,SAAS;IAAK;AACzB"}
@@ -0,0 +1,5 @@
1
+ import type { TextTransformResult } from './transform-vite-config.js';
2
+ export declare function transformTanStackRouter({ content }: {
3
+ content: string;
4
+ }): TextTransformResult;
5
+ //# sourceMappingURL=transform-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-router.d.ts","sourceRoot":"","sources":["../../../src/lib/tanstack/transform-router.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAerE,wBAAgB,uBAAuB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,mBAAmB,CAwH7F"}
@@ -0,0 +1,301 @@
1
+ import { Node, Project, QuoteKind, SyntaxKind } from 'ts-morph';
2
+ const PAYLOAD_SEARCH_MODULE = '@payloadcms/tanstack-start/shared';
3
+ const ROUTER_MODULE = '@tanstack/react-router';
4
+ export function transformTanStackRouter({ content }) {
5
+ const project = new Project({
6
+ manipulationSettings: {
7
+ quoteKind: QuoteKind.Single
8
+ },
9
+ useInMemoryFileSystem: true
10
+ });
11
+ const sourceFile = project.createSourceFile('router.tsx', content);
12
+ const createRouterImport = getNamedImport({
13
+ importedName: 'createRouter',
14
+ moduleSpecifier: ROUTER_MODULE,
15
+ sourceFile
16
+ });
17
+ if (!createRouterImport) {
18
+ return failure('Could not identify the createRouter import.');
19
+ }
20
+ const createRouterCalls = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression).filter((call)=>call.getExpression().getText() === createRouterImport.localName);
21
+ if (createRouterCalls.length !== 1) {
22
+ return failure('Expected exactly one createRouter() call.');
23
+ }
24
+ const createRouterCall = createRouterCalls[0];
25
+ if (createRouterCall.getArguments().length !== 1) {
26
+ return failure('createRouter() must receive exactly one argument.');
27
+ }
28
+ const routerObject = createRouterCall.getArguments()[0];
29
+ if (!Node.isObjectLiteralExpression(routerObject)) {
30
+ return failure('createRouter() must receive an object literal.');
31
+ }
32
+ if (routerObject.getProperties().some(Node.isSpreadAssignment)) {
33
+ return failure('Router object spreads cannot be transformed safely.');
34
+ }
35
+ const routeTreeProperties = routerObject.getProperties().filter((property)=>getPropertyName(property) === 'routeTree');
36
+ if (routeTreeProperties.length !== 1) {
37
+ return failure('The router must contain exactly one routeTree option.');
38
+ }
39
+ if (!isGeneratedRouteTreeProperty({
40
+ property: routeTreeProperties[0],
41
+ sourceFile
42
+ })) {
43
+ return failure('The routeTree option must reference the generated route tree import.');
44
+ }
45
+ const parseImport = resolvePayloadSearchImport({
46
+ importedName: 'payloadParseSearch',
47
+ sourceFile
48
+ });
49
+ if (!parseImport.success) {
50
+ return parseImport;
51
+ }
52
+ const stringifyImport = resolvePayloadSearchImport({
53
+ importedName: 'payloadStringifySearch',
54
+ sourceFile
55
+ });
56
+ if (!stringifyImport.success) {
57
+ return stringifyImport;
58
+ }
59
+ const parseValidation = validateSearchProperty({
60
+ expectedIdentifier: parseImport.localName,
61
+ propertyName: 'parseSearch',
62
+ routerObject
63
+ });
64
+ if (!parseValidation.success) {
65
+ return parseValidation;
66
+ }
67
+ const stringifyValidation = validateSearchProperty({
68
+ expectedIdentifier: stringifyImport.localName,
69
+ propertyName: 'stringifySearch',
70
+ routerObject
71
+ });
72
+ if (!stringifyValidation.success) {
73
+ return stringifyValidation;
74
+ }
75
+ if (parseValidation.isConfigured && stringifyValidation.isConfigured && parseImport.isPresent && stringifyImport.isPresent) {
76
+ return {
77
+ content,
78
+ modified: false,
79
+ success: true
80
+ };
81
+ }
82
+ const routeTreeIndex = routerObject.getProperties().indexOf(routeTreeProperties[0]);
83
+ if (!parseValidation.isConfigured) {
84
+ routerObject.insertPropertyAssignment(routeTreeIndex, {
85
+ name: 'parseSearch',
86
+ initializer: parseImport.localName
87
+ });
88
+ }
89
+ const currentRouteTreeIndex = routerObject.getProperties().findIndex((property)=>getPropertyName(property) === 'routeTree');
90
+ if (!stringifyValidation.isConfigured) {
91
+ routerObject.insertPropertyAssignment(currentRouteTreeIndex + 1, {
92
+ name: 'stringifySearch',
93
+ initializer: stringifyImport.localName
94
+ });
95
+ }
96
+ ensurePayloadSearchImports({
97
+ importedNames: [
98
+ parseImport,
99
+ stringifyImport
100
+ ].filter((resolvedImport)=>!resolvedImport.isPresent).map((resolvedImport)=>resolvedImport.importedName),
101
+ sourceFile
102
+ });
103
+ sourceFile.formatText({
104
+ indentSize: 2
105
+ });
106
+ return {
107
+ content: sourceFile.getFullText(),
108
+ modified: true,
109
+ success: true
110
+ };
111
+ }
112
+ function bindingNameIncludes({ localName, node }) {
113
+ if (Node.isIdentifier(node)) {
114
+ return node.getText() === localName;
115
+ }
116
+ if (Node.isArrayBindingPattern(node) || Node.isObjectBindingPattern(node)) {
117
+ return node.getElements().some((element)=>Node.isBindingElement(element) && bindingNameIncludes({
118
+ localName,
119
+ node: element.getNameNode()
120
+ }));
121
+ }
122
+ return false;
123
+ }
124
+ function ensurePayloadSearchImports({ importedNames, sourceFile }) {
125
+ if (importedNames.length === 0) {
126
+ return;
127
+ }
128
+ const declaration = sourceFile.getImportDeclarations().find((candidate)=>candidate.getModuleSpecifierValue() === PAYLOAD_SEARCH_MODULE && !candidate.isTypeOnly() && !candidate.getNamespaceImport());
129
+ if (declaration) {
130
+ declaration.addNamedImports(importedNames);
131
+ } else {
132
+ sourceFile.addImportDeclaration({
133
+ moduleSpecifier: PAYLOAD_SEARCH_MODULE,
134
+ namedImports: importedNames
135
+ });
136
+ }
137
+ }
138
+ function failure(reason) {
139
+ return {
140
+ reason,
141
+ success: false
142
+ };
143
+ }
144
+ function getLocalBindings({ localName, sourceFile }) {
145
+ const bindings = [];
146
+ for (const declaration of sourceFile.getImportDeclarations()){
147
+ const moduleSpecifier = declaration.getModuleSpecifierValue();
148
+ const defaultImport = declaration.getDefaultImport();
149
+ if (defaultImport?.getText() === localName) {
150
+ bindings.push({
151
+ importKind: 'default',
152
+ isTypeOnly: declaration.isTypeOnly(),
153
+ kind: 'import',
154
+ moduleSpecifier
155
+ });
156
+ }
157
+ const namespaceImport = declaration.getNamespaceImport();
158
+ if (namespaceImport?.getText() === localName) {
159
+ bindings.push({
160
+ importKind: 'namespace',
161
+ isTypeOnly: declaration.isTypeOnly(),
162
+ kind: 'import',
163
+ moduleSpecifier
164
+ });
165
+ }
166
+ for (const namedImport of declaration.getNamedImports()){
167
+ const namedImportLocalName = namedImport.getAliasNode()?.getText() ?? namedImport.getName();
168
+ if (namedImportLocalName === localName) {
169
+ bindings.push({
170
+ importedName: namedImport.getName(),
171
+ importKind: 'named',
172
+ isTypeOnly: declaration.isTypeOnly() || namedImport.isTypeOnly(),
173
+ kind: 'import',
174
+ moduleSpecifier
175
+ });
176
+ }
177
+ }
178
+ }
179
+ for (const declaration of sourceFile.getVariableDeclarations()){
180
+ if (bindingNameIncludes({
181
+ localName,
182
+ node: declaration.getNameNode()
183
+ })) {
184
+ bindings.push({
185
+ kind: 'variable'
186
+ });
187
+ }
188
+ }
189
+ const hasOtherDeclaration = [
190
+ ...sourceFile.getClasses(),
191
+ ...sourceFile.getEnums(),
192
+ ...sourceFile.getFunctions(),
193
+ ...sourceFile.getModules()
194
+ ].some((declaration)=>declaration.getName() === localName);
195
+ if (hasOtherDeclaration) {
196
+ bindings.push({
197
+ kind: 'other'
198
+ });
199
+ }
200
+ return bindings;
201
+ }
202
+ function getNamedImport({ importedName, moduleSpecifier, sourceFile }) {
203
+ const imports = sourceFile.getImportDeclarations().flatMap((declaration)=>declaration.getModuleSpecifierValue() === moduleSpecifier ? declaration.getNamedImports().filter((namedImport)=>namedImport.getName() === importedName).map((namedImport)=>({
204
+ declaration,
205
+ localName: namedImport.getAliasNode()?.getText() ?? namedImport.getName()
206
+ })) : []);
207
+ if (imports.length !== 1) {
208
+ return undefined;
209
+ }
210
+ const imported = imports[0];
211
+ const bindings = getLocalBindings({
212
+ localName: imported.localName,
213
+ sourceFile
214
+ });
215
+ const binding = bindings[0];
216
+ if (bindings.length !== 1 || binding?.kind !== 'import' || binding.importKind !== 'named' || binding.importedName !== importedName || binding.isTypeOnly || binding.moduleSpecifier !== moduleSpecifier) {
217
+ return undefined;
218
+ }
219
+ return imported;
220
+ }
221
+ function getPropertyName(node) {
222
+ if (Node.isPropertyAssignment(node) || Node.isShorthandPropertyAssignment(node) || Node.isMethodDeclaration(node) || Node.isGetAccessorDeclaration(node) || Node.isSetAccessorDeclaration(node)) {
223
+ return node.getName();
224
+ }
225
+ }
226
+ function isGeneratedRouteTreeProperty({ property, sourceFile }) {
227
+ const initializer = Node.isShorthandPropertyAssignment(property) ? property.getName() : Node.isPropertyAssignment(property) && Node.isIdentifier(property.getInitializer()) ? property.getInitializer().getText() : undefined;
228
+ if (!initializer) {
229
+ return false;
230
+ }
231
+ const generatedImports = sourceFile.getImportDeclarations().flatMap((declaration)=>{
232
+ const moduleSpecifier = declaration.getModuleSpecifierValue();
233
+ if (declaration.isTypeOnly() || !/^\.\/routeTree\.gen(?:\.(?:js|jsx|ts|tsx|mjs|cjs|mts|cts))?$/.test(moduleSpecifier)) {
234
+ return [];
235
+ }
236
+ return declaration.getNamedImports().filter((namedImport)=>!namedImport.isTypeOnly() && namedImport.getName() === 'routeTree' && (namedImport.getAliasNode()?.getText() ?? namedImport.getName()) === initializer).map(()=>moduleSpecifier);
237
+ });
238
+ if (generatedImports.length !== 1) {
239
+ return false;
240
+ }
241
+ const bindings = getLocalBindings({
242
+ localName: initializer,
243
+ sourceFile
244
+ });
245
+ const binding = bindings[0];
246
+ return bindings.length === 1 && binding?.kind === 'import' && binding.importKind === 'named' && binding.importedName === 'routeTree' && !binding.isTypeOnly && binding.moduleSpecifier === generatedImports[0];
247
+ }
248
+ function isCompatiblePayloadBinding({ binding, importedName }) {
249
+ return binding.kind === 'import' && binding.importKind === 'named' && !binding.isTypeOnly && binding.importedName === importedName && binding.moduleSpecifier === PAYLOAD_SEARCH_MODULE;
250
+ }
251
+ function resolvePayloadSearchImport({ importedName, sourceFile }) {
252
+ const matchingImports = sourceFile.getImportDeclarations().flatMap((declaration)=>declaration.getModuleSpecifierValue() === PAYLOAD_SEARCH_MODULE && !declaration.isTypeOnly() ? declaration.getNamedImports().filter((namedImport)=>namedImport.getName() === importedName && !namedImport.isTypeOnly()).map((namedImport)=>namedImport.getAliasNode()?.getText() ?? namedImport.getName()) : []);
253
+ if (matchingImports.length > 1) {
254
+ return {
255
+ reason: `The Payload search module imports ${importedName} more than once.`,
256
+ success: false
257
+ };
258
+ }
259
+ const localName = matchingImports[0] ?? importedName;
260
+ const bindings = getLocalBindings({
261
+ localName,
262
+ sourceFile
263
+ });
264
+ if (bindings.length > 0 && (bindings.length !== 1 || !isCompatiblePayloadBinding({
265
+ binding: bindings[0],
266
+ importedName
267
+ }))) {
268
+ return {
269
+ reason: `Identifier "${localName}" is already bound incompatibly.`,
270
+ success: false
271
+ };
272
+ }
273
+ return {
274
+ importedName,
275
+ isPresent: matchingImports.length === 1,
276
+ localName,
277
+ success: true
278
+ };
279
+ }
280
+ function validateSearchProperty({ expectedIdentifier, propertyName, routerObject }) {
281
+ const properties = routerObject.getProperties().filter((property)=>getPropertyName(property) === propertyName);
282
+ if (properties.length === 0) {
283
+ return {
284
+ isConfigured: false,
285
+ success: true
286
+ };
287
+ }
288
+ const property = properties[0];
289
+ if (properties.length !== 1 || !property || !Node.isPropertyAssignment(property) || property.getInitializer()?.getText() !== expectedIdentifier) {
290
+ return {
291
+ reason: `The router already defines a non-Payload ${propertyName} option.`,
292
+ success: false
293
+ };
294
+ }
295
+ return {
296
+ isConfigured: true,
297
+ success: true
298
+ };
299
+ }
300
+
301
+ //# sourceMappingURL=transform-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/tanstack/transform-router.ts"],"sourcesContent":["import type {\n ImportDeclaration,\n Node as MorphNode,\n ObjectLiteralExpression,\n SourceFile,\n} from 'ts-morph'\n\nimport { Node, Project, QuoteKind, SyntaxKind } from 'ts-morph'\n\nimport type { TextTransformResult } from './transform-vite-config.js'\n\ntype LocalBinding =\n | {\n importedName?: string\n importKind: 'default' | 'named' | 'namespace'\n isTypeOnly: boolean\n kind: 'import'\n moduleSpecifier: string\n }\n | { kind: 'other' | 'variable' }\n\nconst PAYLOAD_SEARCH_MODULE = '@payloadcms/tanstack-start/shared'\nconst ROUTER_MODULE = '@tanstack/react-router'\n\nexport function transformTanStackRouter({ content }: { content: string }): TextTransformResult {\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n useInMemoryFileSystem: true,\n })\n const sourceFile = project.createSourceFile('router.tsx', content)\n const createRouterImport = getNamedImport({\n importedName: 'createRouter',\n moduleSpecifier: ROUTER_MODULE,\n sourceFile,\n })\n\n if (!createRouterImport) {\n return failure('Could not identify the createRouter import.')\n }\n\n const createRouterCalls = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((call) => call.getExpression().getText() === createRouterImport.localName)\n\n if (createRouterCalls.length !== 1) {\n return failure('Expected exactly one createRouter() call.')\n }\n\n const createRouterCall = createRouterCalls[0]!\n if (createRouterCall.getArguments().length !== 1) {\n return failure('createRouter() must receive exactly one argument.')\n }\n\n const routerObject = createRouterCall.getArguments()[0]\n if (!Node.isObjectLiteralExpression(routerObject)) {\n return failure('createRouter() must receive an object literal.')\n }\n\n if (routerObject.getProperties().some(Node.isSpreadAssignment)) {\n return failure('Router object spreads cannot be transformed safely.')\n }\n\n const routeTreeProperties = routerObject\n .getProperties()\n .filter((property) => getPropertyName(property) === 'routeTree')\n\n if (routeTreeProperties.length !== 1) {\n return failure('The router must contain exactly one routeTree option.')\n }\n\n if (!isGeneratedRouteTreeProperty({ property: routeTreeProperties[0]!, sourceFile })) {\n return failure('The routeTree option must reference the generated route tree import.')\n }\n\n const parseImport = resolvePayloadSearchImport({\n importedName: 'payloadParseSearch',\n sourceFile,\n })\n if (!parseImport.success) {\n return parseImport\n }\n\n const stringifyImport = resolvePayloadSearchImport({\n importedName: 'payloadStringifySearch',\n sourceFile,\n })\n if (!stringifyImport.success) {\n return stringifyImport\n }\n\n const parseValidation = validateSearchProperty({\n expectedIdentifier: parseImport.localName,\n propertyName: 'parseSearch',\n routerObject,\n })\n if (!parseValidation.success) {\n return parseValidation\n }\n\n const stringifyValidation = validateSearchProperty({\n expectedIdentifier: stringifyImport.localName,\n propertyName: 'stringifySearch',\n routerObject,\n })\n if (!stringifyValidation.success) {\n return stringifyValidation\n }\n\n if (\n parseValidation.isConfigured &&\n stringifyValidation.isConfigured &&\n parseImport.isPresent &&\n stringifyImport.isPresent\n ) {\n return { content, modified: false, success: true }\n }\n\n const routeTreeIndex = routerObject.getProperties().indexOf(routeTreeProperties[0]!)\n if (!parseValidation.isConfigured) {\n routerObject.insertPropertyAssignment(routeTreeIndex, {\n name: 'parseSearch',\n initializer: parseImport.localName,\n })\n }\n\n const currentRouteTreeIndex = routerObject\n .getProperties()\n .findIndex((property) => getPropertyName(property) === 'routeTree')\n if (!stringifyValidation.isConfigured) {\n routerObject.insertPropertyAssignment(currentRouteTreeIndex + 1, {\n name: 'stringifySearch',\n initializer: stringifyImport.localName,\n })\n }\n\n ensurePayloadSearchImports({\n importedNames: [parseImport, stringifyImport]\n .filter((resolvedImport) => !resolvedImport.isPresent)\n .map((resolvedImport) => resolvedImport.importedName),\n sourceFile,\n })\n sourceFile.formatText({ indentSize: 2 })\n\n return { content: sourceFile.getFullText(), modified: true, success: true }\n}\n\nfunction bindingNameIncludes({ localName, node }: { localName: string; node: MorphNode }): boolean {\n if (Node.isIdentifier(node)) {\n return node.getText() === localName\n }\n\n if (Node.isArrayBindingPattern(node) || Node.isObjectBindingPattern(node)) {\n return node\n .getElements()\n .some(\n (element) =>\n Node.isBindingElement(element) &&\n bindingNameIncludes({ localName, node: element.getNameNode() }),\n )\n }\n\n return false\n}\n\nfunction ensurePayloadSearchImports({\n importedNames,\n sourceFile,\n}: {\n importedNames: string[]\n sourceFile: SourceFile\n}) {\n if (importedNames.length === 0) {\n return\n }\n\n const declaration = sourceFile\n .getImportDeclarations()\n .find(\n (candidate) =>\n candidate.getModuleSpecifierValue() === PAYLOAD_SEARCH_MODULE &&\n !candidate.isTypeOnly() &&\n !candidate.getNamespaceImport(),\n )\n if (declaration) {\n declaration.addNamedImports(importedNames)\n } else {\n sourceFile.addImportDeclaration({\n moduleSpecifier: PAYLOAD_SEARCH_MODULE,\n namedImports: importedNames,\n })\n }\n}\n\nfunction failure(reason: string): TextTransformResult {\n return { reason, success: false }\n}\n\nfunction getLocalBindings({\n localName,\n sourceFile,\n}: {\n localName: string\n sourceFile: SourceFile\n}): LocalBinding[] {\n const bindings: LocalBinding[] = []\n\n for (const declaration of sourceFile.getImportDeclarations()) {\n const moduleSpecifier = declaration.getModuleSpecifierValue()\n const defaultImport = declaration.getDefaultImport()\n if (defaultImport?.getText() === localName) {\n bindings.push({\n importKind: 'default',\n isTypeOnly: declaration.isTypeOnly(),\n kind: 'import',\n moduleSpecifier,\n })\n }\n\n const namespaceImport = declaration.getNamespaceImport()\n if (namespaceImport?.getText() === localName) {\n bindings.push({\n importKind: 'namespace',\n isTypeOnly: declaration.isTypeOnly(),\n kind: 'import',\n moduleSpecifier,\n })\n }\n\n for (const namedImport of declaration.getNamedImports()) {\n const namedImportLocalName = namedImport.getAliasNode()?.getText() ?? namedImport.getName()\n if (namedImportLocalName === localName) {\n bindings.push({\n importedName: namedImport.getName(),\n importKind: 'named',\n isTypeOnly: declaration.isTypeOnly() || namedImport.isTypeOnly(),\n kind: 'import',\n moduleSpecifier,\n })\n }\n }\n }\n\n for (const declaration of sourceFile.getVariableDeclarations()) {\n if (bindingNameIncludes({ localName, node: declaration.getNameNode() })) {\n bindings.push({ kind: 'variable' })\n }\n }\n\n const hasOtherDeclaration = [\n ...sourceFile.getClasses(),\n ...sourceFile.getEnums(),\n ...sourceFile.getFunctions(),\n ...sourceFile.getModules(),\n ].some((declaration) => declaration.getName() === localName)\n\n if (hasOtherDeclaration) {\n bindings.push({ kind: 'other' })\n }\n\n return bindings\n}\n\nfunction getNamedImport({\n importedName,\n moduleSpecifier,\n sourceFile,\n}: {\n importedName: string\n moduleSpecifier: string\n sourceFile: SourceFile\n}): { declaration: ImportDeclaration; localName: string } | undefined {\n const imports = sourceFile.getImportDeclarations().flatMap((declaration) =>\n declaration.getModuleSpecifierValue() === moduleSpecifier\n ? declaration\n .getNamedImports()\n .filter((namedImport) => namedImport.getName() === importedName)\n .map((namedImport) => ({\n declaration,\n localName: namedImport.getAliasNode()?.getText() ?? namedImport.getName(),\n }))\n : [],\n )\n\n if (imports.length !== 1) {\n return undefined\n }\n\n const imported = imports[0]!\n const bindings = getLocalBindings({ localName: imported.localName, sourceFile })\n const binding = bindings[0]\n\n if (\n bindings.length !== 1 ||\n binding?.kind !== 'import' ||\n binding.importKind !== 'named' ||\n binding.importedName !== importedName ||\n binding.isTypeOnly ||\n binding.moduleSpecifier !== moduleSpecifier\n ) {\n return undefined\n }\n\n return imported\n}\n\nfunction getPropertyName(node: MorphNode): string | undefined {\n if (\n Node.isPropertyAssignment(node) ||\n Node.isShorthandPropertyAssignment(node) ||\n Node.isMethodDeclaration(node) ||\n Node.isGetAccessorDeclaration(node) ||\n Node.isSetAccessorDeclaration(node)\n ) {\n return node.getName()\n }\n}\n\nfunction isGeneratedRouteTreeProperty({\n property,\n sourceFile,\n}: {\n property: MorphNode\n sourceFile: SourceFile\n}): boolean {\n const initializer = Node.isShorthandPropertyAssignment(property)\n ? property.getName()\n : Node.isPropertyAssignment(property) && Node.isIdentifier(property.getInitializer())\n ? property.getInitializer()!.getText()\n : undefined\n\n if (!initializer) {\n return false\n }\n\n const generatedImports = sourceFile.getImportDeclarations().flatMap((declaration) => {\n const moduleSpecifier = declaration.getModuleSpecifierValue()\n if (\n declaration.isTypeOnly() ||\n !/^\\.\\/routeTree\\.gen(?:\\.(?:js|jsx|ts|tsx|mjs|cjs|mts|cts))?$/.test(moduleSpecifier)\n ) {\n return []\n }\n\n return declaration\n .getNamedImports()\n .filter(\n (namedImport) =>\n !namedImport.isTypeOnly() &&\n namedImport.getName() === 'routeTree' &&\n (namedImport.getAliasNode()?.getText() ?? namedImport.getName()) === initializer,\n )\n .map(() => moduleSpecifier)\n })\n\n if (generatedImports.length !== 1) {\n return false\n }\n\n const bindings = getLocalBindings({ localName: initializer, sourceFile })\n const binding = bindings[0]\n\n return (\n bindings.length === 1 &&\n binding?.kind === 'import' &&\n binding.importKind === 'named' &&\n binding.importedName === 'routeTree' &&\n !binding.isTypeOnly &&\n binding.moduleSpecifier === generatedImports[0]\n )\n}\n\nfunction isCompatiblePayloadBinding({\n binding,\n importedName,\n}: {\n binding: LocalBinding\n importedName: string\n}) {\n return (\n binding.kind === 'import' &&\n binding.importKind === 'named' &&\n !binding.isTypeOnly &&\n binding.importedName === importedName &&\n binding.moduleSpecifier === PAYLOAD_SEARCH_MODULE\n )\n}\n\nfunction resolvePayloadSearchImport({\n importedName,\n sourceFile,\n}: {\n importedName: 'payloadParseSearch' | 'payloadStringifySearch'\n sourceFile: SourceFile\n}):\n | { importedName: string; isPresent: boolean; localName: string; success: true }\n | { reason: string; success: false } {\n const matchingImports = sourceFile.getImportDeclarations().flatMap((declaration) =>\n declaration.getModuleSpecifierValue() === PAYLOAD_SEARCH_MODULE && !declaration.isTypeOnly()\n ? declaration\n .getNamedImports()\n .filter(\n (namedImport) => namedImport.getName() === importedName && !namedImport.isTypeOnly(),\n )\n .map((namedImport) => namedImport.getAliasNode()?.getText() ?? namedImport.getName())\n : [],\n )\n\n if (matchingImports.length > 1) {\n return {\n reason: `The Payload search module imports ${importedName} more than once.`,\n success: false,\n }\n }\n\n const localName = matchingImports[0] ?? importedName\n const bindings = getLocalBindings({ localName, sourceFile })\n\n if (\n bindings.length > 0 &&\n (bindings.length !== 1 || !isCompatiblePayloadBinding({ binding: bindings[0]!, importedName }))\n ) {\n return {\n reason: `Identifier \"${localName}\" is already bound incompatibly.`,\n success: false,\n }\n }\n\n return { importedName, isPresent: matchingImports.length === 1, localName, success: true }\n}\n\nfunction validateSearchProperty({\n expectedIdentifier,\n propertyName,\n routerObject,\n}: {\n expectedIdentifier: string\n propertyName: 'parseSearch' | 'stringifySearch'\n routerObject: ObjectLiteralExpression\n}): { isConfigured: boolean; success: true } | { reason: string; success: false } {\n const properties = routerObject\n .getProperties()\n .filter((property) => getPropertyName(property) === propertyName)\n\n if (properties.length === 0) {\n return { isConfigured: false, success: true }\n }\n\n const property = properties[0]\n if (\n properties.length !== 1 ||\n !property ||\n !Node.isPropertyAssignment(property) ||\n property.getInitializer()?.getText() !== expectedIdentifier\n ) {\n return {\n reason: `The router already defines a non-Payload ${propertyName} option.`,\n success: false,\n }\n }\n\n return { isConfigured: true, success: true }\n}\n"],"names":["Node","Project","QuoteKind","SyntaxKind","PAYLOAD_SEARCH_MODULE","ROUTER_MODULE","transformTanStackRouter","content","project","manipulationSettings","quoteKind","Single","useInMemoryFileSystem","sourceFile","createSourceFile","createRouterImport","getNamedImport","importedName","moduleSpecifier","failure","createRouterCalls","getDescendantsOfKind","CallExpression","filter","call","getExpression","getText","localName","length","createRouterCall","getArguments","routerObject","isObjectLiteralExpression","getProperties","some","isSpreadAssignment","routeTreeProperties","property","getPropertyName","isGeneratedRouteTreeProperty","parseImport","resolvePayloadSearchImport","success","stringifyImport","parseValidation","validateSearchProperty","expectedIdentifier","propertyName","stringifyValidation","isConfigured","isPresent","modified","routeTreeIndex","indexOf","insertPropertyAssignment","name","initializer","currentRouteTreeIndex","findIndex","ensurePayloadSearchImports","importedNames","resolvedImport","map","formatText","indentSize","getFullText","bindingNameIncludes","node","isIdentifier","isArrayBindingPattern","isObjectBindingPattern","getElements","element","isBindingElement","getNameNode","declaration","getImportDeclarations","find","candidate","getModuleSpecifierValue","isTypeOnly","getNamespaceImport","addNamedImports","addImportDeclaration","namedImports","reason","getLocalBindings","bindings","defaultImport","getDefaultImport","push","importKind","kind","namespaceImport","namedImport","getNamedImports","namedImportLocalName","getAliasNode","getName","getVariableDeclarations","hasOtherDeclaration","getClasses","getEnums","getFunctions","getModules","imports","flatMap","undefined","imported","binding","isPropertyAssignment","isShorthandPropertyAssignment","isMethodDeclaration","isGetAccessorDeclaration","isSetAccessorDeclaration","getInitializer","generatedImports","test","isCompatiblePayloadBinding","matchingImports","properties"],"mappings":"AAOA,SAASA,IAAI,EAAEC,OAAO,EAAEC,SAAS,EAAEC,UAAU,QAAQ,WAAU;AAc/D,MAAMC,wBAAwB;AAC9B,MAAMC,gBAAgB;AAEtB,OAAO,SAASC,wBAAwB,EAAEC,OAAO,EAAuB;IACtE,MAAMC,UAAU,IAAIP,QAAQ;QAC1BQ,sBAAsB;YAAEC,WAAWR,UAAUS,MAAM;QAAC;QACpDC,uBAAuB;IACzB;IACA,MAAMC,aAAaL,QAAQM,gBAAgB,CAAC,cAAcP;IAC1D,MA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,MAAMf,YAAY4F,eAAe,CAAC,EAAE,IAAItG;IACxC,MAAMsE,WAAWD,iBAAiB;QAAE3D;QAAWd;IAAW;IAE1D,IACE0E,SAAS3D,MAAM,GAAG,KACjB2D,CAAAA,SAAS3D,MAAM,KAAK,KAAK,CAAC0F,2BAA2B;QAAET,SAAStB,QAAQ,CAAC,EAAE;QAAGtE;IAAa,EAAC,GAC7F;QACA,OAAO;YACLoE,QAAQ,CAAC,YAAY,EAAE1D,UAAU,gCAAgC,CAAC;YAClEe,SAAS;QACX;IACF;IAEA,OAAO;QAAEzB;QAAciC,WAAWqE,gBAAgB3F,MAAM,KAAK;QAAGD;QAAWe,SAAS;IAAK;AAC3F;AAEA,SAASG,uBAAuB,EAC9BC,kBAAkB,EAClBC,YAAY,EACZhB,YAAY,EAKb;IACC,MAAMyF,aAAazF,aAChBE,aAAa,GACbV,MAAM,CAAC,CAACc,WAAaC,gBAAgBD,cAAcU;IAEtD,IAAIyE,WAAW5F,MAAM,KAAK,GAAG;QAC3B,OAAO;YAAEqB,cAAc;YAAOP,SAAS;QAAK;IAC9C;IAEA,MAAML,WAAWmF,UAAU,CAAC,EAAE;IAC9B,IACEA,WAAW5F,MAAM,KAAK,KACtB,CAACS,YACD,CAACrC,KAAK8G,oBAAoB,CAACzE,aAC3BA,SAAS8E,cAAc,IAAIzF,cAAcoB,oBACzC;QACA,OAAO;YACLuC,QAAQ,CAAC,yCAAyC,EAAEtC,aAAa,QAAQ,CAAC;YAC1EL,SAAS;QACX;IACF;IAEA,OAAO;QAAEO,cAAc;QAAMP,SAAS;IAAK;AAC7C"}
@@ -0,0 +1,14 @@
1
+ import type { TanStackAppDetails } from '../../types.js';
2
+ export type TextTransformResult = {
3
+ content: string;
4
+ modified: boolean;
5
+ success: true;
6
+ } | {
7
+ reason: string;
8
+ success: false;
9
+ };
10
+ export declare function transformTanStackViteConfig({ appDetails, content, }: {
11
+ appDetails: TanStackAppDetails;
12
+ content: string;
13
+ }): TextTransformResult;
14
+ //# sourceMappingURL=transform-vite-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-vite-config.d.ts","sourceRoot":"","sources":["../../../src/lib/tanstack/transform-vite-config.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAExD,MAAM,MAAM,mBAAmB,GAC3B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAAE,GACrD;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAA;AAetC,wBAAgB,2BAA2B,CAAC,EAC1C,UAAU,EACV,OAAO,GACR,EAAE;IACD,UAAU,EAAE,kBAAkB,CAAA;IAC9B,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,mBAAmB,CA6KtB"}