@sentry/bundler-plugins 11.12.0 → 11.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
  2. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
  3. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
  4. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
  5. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
  6. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
  7. package/build/cjs/_virtual/_rolldown/runtime.js +22 -0
  8. package/build/cjs/babel-plugin/component-annotation.js +14 -32
  9. package/build/cjs/babel-plugin/component-annotation.js.map +1 -1
  10. package/build/cjs/babel-plugin/constants.js +140 -122
  11. package/build/cjs/babel-plugin/constants.js.map +1 -1
  12. package/build/cjs/babel-plugin/experimental.js +204 -307
  13. package/build/cjs/babel-plugin/experimental.js.map +1 -1
  14. package/build/cjs/babel-plugin/index.js +315 -437
  15. package/build/cjs/babel-plugin/index.js.map +1 -1
  16. package/build/cjs/bun/index.js +81 -117
  17. package/build/cjs/bun/index.js.map +1 -1
  18. package/build/cjs/core/build-plugin-manager.js +626 -702
  19. package/build/cjs/core/build-plugin-manager.js.map +1 -1
  20. package/build/cjs/core/cli.js +134 -129
  21. package/build/cjs/core/cli.js.map +1 -1
  22. package/build/cjs/core/component-annotate-hooks.js +16 -27
  23. package/build/cjs/core/component-annotate-hooks.js.map +1 -1
  24. package/build/cjs/core/component-annotation-oxc-ast.js +10 -21
  25. package/build/cjs/core/component-annotation-oxc-ast.js.map +1 -1
  26. package/build/cjs/core/component-annotation-oxc-fragments.js +45 -74
  27. package/build/cjs/core/component-annotation-oxc-fragments.js.map +1 -1
  28. package/build/cjs/core/component-annotation-oxc-jsx.js +116 -156
  29. package/build/cjs/core/component-annotation-oxc-jsx.js.map +1 -1
  30. package/build/cjs/core/component-annotation-oxc-walk.js +62 -123
  31. package/build/cjs/core/component-annotation-oxc-walk.js.map +1 -1
  32. package/build/cjs/core/component-annotation-oxc.js +68 -103
  33. package/build/cjs/core/component-annotation-oxc.js.map +1 -1
  34. package/build/cjs/core/debug-id-upload.js +223 -234
  35. package/build/cjs/core/debug-id-upload.js.map +1 -1
  36. package/build/cjs/core/get-code-injection-position.js +59 -74
  37. package/build/cjs/core/get-code-injection-position.js.map +1 -1
  38. package/build/cjs/core/glob.js +9 -7
  39. package/build/cjs/core/glob.js.map +1 -1
  40. package/build/cjs/core/index.js +77 -61
  41. package/build/cjs/core/index.js.map +1 -1
  42. package/build/cjs/core/logger.js +17 -26
  43. package/build/cjs/core/logger.js.map +1 -1
  44. package/build/cjs/core/options-mapping.js +95 -117
  45. package/build/cjs/core/options-mapping.js.map +1 -1
  46. package/build/cjs/core/sentry/telemetry.js +90 -105
  47. package/build/cjs/core/sentry/telemetry.js.map +1 -1
  48. package/build/cjs/core/sentry/transports.js +92 -99
  49. package/build/cjs/core/sentry/transports.js.map +1 -1
  50. package/build/cjs/core/sourcemap-settings.js +98 -61
  51. package/build/cjs/core/sourcemap-settings.js.map +1 -1
  52. package/build/cjs/core/upload-filter.js +41 -46
  53. package/build/cjs/core/upload-filter.js.map +1 -1
  54. package/build/cjs/core/utils.js +228 -221
  55. package/build/cjs/core/utils.js.map +1 -1
  56. package/build/cjs/core/version.js +4 -5
  57. package/build/cjs/core/version.js.map +1 -1
  58. package/build/cjs/esbuild/index.js +183 -213
  59. package/build/cjs/esbuild/index.js.map +1 -1
  60. package/build/cjs/loader-utils/index.js +5 -10
  61. package/build/cjs/rollup/debug-id-injection.js +22 -38
  62. package/build/cjs/rollup/debug-id-injection.js.map +1 -1
  63. package/build/cjs/rollup/debug-id-stamping.js +14 -24
  64. package/build/cjs/rollup/debug-id-stamping.js.map +1 -1
  65. package/build/cjs/rollup/index.js +192 -246
  66. package/build/cjs/rollup/index.js.map +1 -1
  67. package/build/cjs/rollup/source-map-handling.js +151 -175
  68. package/build/cjs/rollup/source-map-handling.js.map +1 -1
  69. package/build/cjs/vite/index.js +19 -21
  70. package/build/cjs/vite/index.js.map +1 -1
  71. package/build/cjs/vite/source-map-hooks.js +112 -89
  72. package/build/cjs/vite/source-map-hooks.js.map +1 -1
  73. package/build/cjs/webpack/component-annotation-transform.js +20 -26
  74. package/build/cjs/webpack/component-annotation-transform.js.map +1 -1
  75. package/build/cjs/webpack/index.js +271 -340
  76. package/build/cjs/webpack/index.js.map +1 -1
  77. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
  78. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
  79. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
  80. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
  81. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
  82. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
  83. package/build/esm/_virtual/_rolldown/runtime.js +2 -0
  84. package/build/esm/babel-plugin/component-annotation.js +13 -29
  85. package/build/esm/babel-plugin/component-annotation.js.map +1 -1
  86. package/build/esm/babel-plugin/constants.js +140 -120
  87. package/build/esm/babel-plugin/constants.js.map +1 -1
  88. package/build/esm/babel-plugin/experimental.js +204 -305
  89. package/build/esm/babel-plugin/experimental.js.map +1 -1
  90. package/build/esm/babel-plugin/index.js +311 -434
  91. package/build/esm/babel-plugin/index.js.map +1 -1
  92. package/build/esm/bun/index.js +76 -101
  93. package/build/esm/bun/index.js.map +1 -1
  94. package/build/esm/core/build-plugin-manager.js +621 -683
  95. package/build/esm/core/build-plugin-manager.js.map +1 -1
  96. package/build/esm/core/cli.js +134 -127
  97. package/build/esm/core/cli.js.map +1 -1
  98. package/build/esm/core/component-annotate-hooks.js +16 -25
  99. package/build/esm/core/component-annotate-hooks.js.map +1 -1
  100. package/build/esm/core/component-annotation-oxc-ast.js +9 -19
  101. package/build/esm/core/component-annotation-oxc-ast.js.map +1 -1
  102. package/build/esm/core/component-annotation-oxc-fragments.js +44 -72
  103. package/build/esm/core/component-annotation-oxc-fragments.js.map +1 -1
  104. package/build/esm/core/component-annotation-oxc-jsx.js +115 -154
  105. package/build/esm/core/component-annotation-oxc-jsx.js.map +1 -1
  106. package/build/esm/core/component-annotation-oxc-walk.js +61 -121
  107. package/build/esm/core/component-annotation-oxc-walk.js.map +1 -1
  108. package/build/esm/core/component-annotation-oxc.js +65 -96
  109. package/build/esm/core/component-annotation-oxc.js.map +1 -1
  110. package/build/esm/core/debug-id-upload.js +218 -213
  111. package/build/esm/core/debug-id-upload.js.map +1 -1
  112. package/build/esm/core/get-code-injection-position.js +59 -72
  113. package/build/esm/core/get-code-injection-position.js.map +1 -1
  114. package/build/esm/core/glob.js +9 -5
  115. package/build/esm/core/glob.js.map +1 -1
  116. package/build/esm/core/index.js +62 -47
  117. package/build/esm/core/index.js.map +1 -1
  118. package/build/esm/core/logger.js +17 -24
  119. package/build/esm/core/logger.js.map +1 -1
  120. package/build/esm/core/options-mapping.js +95 -115
  121. package/build/esm/core/options-mapping.js.map +1 -1
  122. package/build/esm/core/sentry/telemetry.js +89 -102
  123. package/build/esm/core/sentry/telemetry.js.map +1 -1
  124. package/build/esm/core/sentry/transports.js +90 -83
  125. package/build/esm/core/sentry/transports.js.map +1 -1
  126. package/build/esm/core/sourcemap-settings.js +96 -59
  127. package/build/esm/core/sourcemap-settings.js.map +1 -1
  128. package/build/esm/core/upload-filter.js +39 -30
  129. package/build/esm/core/upload-filter.js.map +1 -1
  130. package/build/esm/core/utils.js +221 -211
  131. package/build/esm/core/utils.js.map +1 -1
  132. package/build/esm/core/version.js +4 -3
  133. package/build/esm/core/version.js.map +1 -1
  134. package/build/esm/esbuild/index.js +179 -197
  135. package/build/esm/esbuild/index.js.map +1 -1
  136. package/build/esm/loader-utils/index.js +4 -3
  137. package/build/esm/package.json +1 -1
  138. package/build/esm/rollup/debug-id-injection.js +22 -36
  139. package/build/esm/rollup/debug-id-injection.js.map +1 -1
  140. package/build/esm/rollup/debug-id-stamping.js +14 -22
  141. package/build/esm/rollup/debug-id-stamping.js.map +1 -1
  142. package/build/esm/rollup/index.js +189 -226
  143. package/build/esm/rollup/index.js.map +1 -1
  144. package/build/esm/rollup/source-map-handling.js +149 -159
  145. package/build/esm/rollup/source-map-handling.js.map +1 -1
  146. package/build/esm/vite/index.js +19 -18
  147. package/build/esm/vite/index.js.map +1 -1
  148. package/build/esm/vite/source-map-hooks.js +109 -72
  149. package/build/esm/vite/source-map-hooks.js.map +1 -1
  150. package/build/esm/webpack/component-annotation-transform.js +17 -24
  151. package/build/esm/webpack/component-annotation-transform.js.map +1 -1
  152. package/build/esm/webpack/index.js +268 -322
  153. package/build/esm/webpack/index.js.map +1 -1
  154. package/build/types/core/build-plugin-manager.d.ts +16 -5
  155. package/build/types/core/build-plugin-manager.d.ts.map +1 -1
  156. package/build/types/core/cli.d.ts +6 -1
  157. package/build/types/core/cli.d.ts.map +1 -1
  158. package/build/types/core/debug-id-upload.d.ts +7 -4
  159. package/build/types/core/debug-id-upload.d.ts.map +1 -1
  160. package/build/types/core/index.d.ts +3 -3
  161. package/build/types/core/index.d.ts.map +1 -1
  162. package/build/types/core/options-mapping.d.ts +4 -3
  163. package/build/types/core/options-mapping.d.ts.map +1 -1
  164. package/build/types/core/sentry/telemetry.d.ts.map +1 -1
  165. package/build/types/core/sourcemap-settings.d.ts +10 -1
  166. package/build/types/core/sourcemap-settings.d.ts.map +1 -1
  167. package/build/types/core/types.d.ts +25 -1
  168. package/build/types/core/types.d.ts.map +1 -1
  169. package/build/types/core/utils.d.ts +4 -0
  170. package/build/types/core/utils.d.ts.map +1 -1
  171. package/build/types/core/version.d.ts +1 -1
  172. package/build/types/esbuild/index.d.ts +2 -2
  173. package/build/types/esbuild/index.d.ts.map +1 -1
  174. package/build/types/rollup/index.d.ts +2 -2
  175. package/build/types/rollup/index.d.ts.map +1 -1
  176. package/build/types/rollup/source-map-handling.d.ts.map +1 -1
  177. package/build/types/vite/index.d.ts +3 -3
  178. package/build/types/vite/index.d.ts.map +1 -1
  179. package/build/types/vite/source-map-hooks.d.ts.map +1 -1
  180. package/build/types/webpack/index.d.ts +7 -3
  181. package/build/types/webpack/index.d.ts.map +1 -1
  182. package/package.json +8 -15
  183. package/build/cjs/loader-utils/index.js.map +0 -1
  184. package/build/esm/loader-utils/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"component-annotation-oxc-jsx.js","sources":["../../../src/core/component-annotation-oxc-jsx.ts"],"sourcesContent":["import {\n getComponentAnnotationAttributes,\n WEB_COMPONENT_NAME,\n WEB_ELEMENT_NAME,\n WEB_SOURCE_FILE_NAME,\n} from '../babel-plugin/component-annotation';\nimport type { ComponentAnnotationAttribute } from '../babel-plugin/component-annotation';\nimport type {\n AttributeInsertion,\n FragmentContext,\n JSXElementNode,\n JSXFragmentNode,\n JSXOpeningElementNode,\n JSXRootNode,\n} from './component-annotation-oxc-ast';\nimport { isAstNode, isObjectLike } from './component-annotation-oxc-ast';\n\nconst UNKNOWN_ELEMENT_NAME = 'unknown';\nconst REACT_NATIVE_ELEMENTS = new Set([\n 'Image',\n 'Text',\n 'View',\n 'ScrollView',\n 'TextInput',\n 'TouchableOpacity',\n 'TouchableHighlight',\n 'TouchableWithoutFeedback',\n 'FlatList',\n 'SectionList',\n 'ActivityIndicator',\n 'Button',\n 'Switch',\n 'Modal',\n 'SafeAreaView',\n 'StatusBar',\n 'KeyboardAvoidingView',\n 'RefreshControl',\n 'Picker',\n 'Slider',\n]);\nconst WEB_ATTRIBUTE_NAMES = [WEB_ELEMENT_NAME, WEB_COMPONENT_NAME, WEB_SOURCE_FILE_NAME] as const;\nconst WEB_ATTRIBUTE_NAME_SET = new Set<string>(WEB_ATTRIBUTE_NAMES);\n\ntype PendingInsertion = {\n offset: number;\n attributeValues: Map<string, string>;\n};\n\nexport function isJSXElement(value: unknown): value is JSXElementNode {\n return isAstNode(value) && value.type === 'JSXElement';\n}\n\nexport function isJSXFragment(value: unknown): value is JSXFragmentNode {\n return isAstNode(value) && value.type === 'JSXFragment';\n}\n\nexport function isJSXRoot(value: unknown): value is JSXRootNode {\n return isJSXElement(value) || isJSXFragment(value);\n}\n\nexport function getStringName(node: unknown): string | null {\n return isObjectLike(node) && typeof node.name === 'string' ? node.name : null;\n}\n\nexport function getJSXName(name: unknown): string {\n if (!isAstNode(name)) {\n return UNKNOWN_ELEMENT_NAME;\n }\n\n if (name.type === 'JSXIdentifier') {\n return getStringName(name) ?? UNKNOWN_ELEMENT_NAME;\n }\n\n if (name.type === 'JSXNamespacedName') {\n return getStringName(name.name) ?? UNKNOWN_ELEMENT_NAME;\n }\n\n if (name.type === 'JSXMemberExpression') {\n const objectName = getJSXName(name.object);\n const propertyName = getJSXName(name.property);\n\n return `${objectName}.${propertyName}`;\n }\n\n return UNKNOWN_ELEMENT_NAME;\n}\n\nexport function getInsertionOffset(code: string, openingElement: JSXOpeningElementNode): number | null {\n if (typeof openingElement.end !== 'number') {\n return null;\n }\n\n if (!openingElement.selfClosing) {\n return openingElement.end - 1;\n }\n\n let offset = openingElement.end - 2;\n\n while (offset > 0 && /\\s/.test(code[offset] ?? '')) {\n offset -= 1;\n }\n\n return code[offset] === '/' ? offset : openingElement.end - 1;\n}\n\nexport function isReactFragment(openingElement: JSXOpeningElementNode, fragmentContext: FragmentContext): boolean {\n const elementName = getJSXName(openingElement.name);\n\n if (elementName === 'Fragment' || elementName === 'React.Fragment') {\n return true;\n }\n\n if (fragmentContext.fragmentAliases.has(elementName)) {\n return true;\n }\n\n if (isObjectLike(openingElement.name) && openingElement.name.type === 'JSXMemberExpression') {\n const objectName = getJSXName(openingElement.name.object);\n const propertyName = getJSXName(openingElement.name.property);\n\n return (\n propertyName === 'Fragment' &&\n (fragmentContext.reactNamespaceAliases.has(objectName) || fragmentContext.fragmentAliases.has(objectName))\n );\n }\n\n return false;\n}\n\nexport function addPendingAttributes(\n code: string,\n openingElement: JSXOpeningElementNode,\n componentName: string,\n ignoredComponents: string[],\n fragmentContext: FragmentContext,\n sourceFileName: string,\n insertionsByOffset: Map<number, PendingInsertion>,\n): void {\n const offset = getInsertionOffset(code, openingElement);\n if (offset === null) {\n return;\n }\n\n const pendingInsertion = insertionsByOffset.get(offset);\n const existingAttributes = getExistingAttributeNames(openingElement);\n\n for (const attributeName of pendingInsertion?.attributeValues.keys() ?? []) {\n existingAttributes.add(attributeName);\n }\n\n const attributes = getComponentAnnotationAttributes({\n attributeNames: [WEB_COMPONENT_NAME, WEB_ELEMENT_NAME, WEB_SOURCE_FILE_NAME],\n componentName,\n elementName: getJSXName(openingElement.name),\n existingAttributes,\n ignoredComponents,\n isFragment: isReactFragment(openingElement, fragmentContext),\n sourceFileName,\n });\n\n if (attributes.length === 0) {\n return;\n }\n\n const insertion = getOrCreateInsertion(insertionsByOffset, offset);\n\n for (const [name, value] of attributes) {\n insertion.attributeValues.set(name, value);\n }\n}\n\n/**\n * Returns `true` when the element is an HTML element, because HTML mode only\n * annotates the first HTML elements below a component root.\n */\nexport function addPendingHtmlAttribute(\n code: string,\n openingElement: JSXOpeningElementNode,\n componentName: string,\n ignoredComponents: string[],\n fragmentContext: FragmentContext,\n insertionsByOffset: Map<number, PendingInsertion>,\n): boolean {\n if (isReactFragment(openingElement, fragmentContext)) {\n return false;\n }\n\n const elementName = getJSXName(openingElement.name);\n\n if (!isHtmlElement(elementName)) {\n return false;\n }\n\n if (ignoredComponents.includes(componentName) || ignoredComponents.includes(elementName)) {\n return true;\n }\n\n const offset = getInsertionOffset(code, openingElement);\n if (offset === null) {\n return true;\n }\n\n if (\n getExistingAttributeNames(openingElement).has(WEB_COMPONENT_NAME) ||\n insertionsByOffset.get(offset)?.attributeValues.has(WEB_COMPONENT_NAME)\n ) {\n return true;\n }\n\n getOrCreateInsertion(insertionsByOffset, offset).attributeValues.set(WEB_COMPONENT_NAME, componentName);\n\n return true;\n}\n\nfunction isHtmlElement(elementName: string): boolean {\n if (elementName === UNKNOWN_ELEMENT_NAME) {\n return false;\n }\n\n if (elementName.charAt(0) === elementName.charAt(0).toLowerCase()) {\n return true;\n }\n\n return REACT_NATIVE_ELEMENTS.has(elementName);\n}\n\nfunction getOrCreateInsertion(insertionsByOffset: Map<number, PendingInsertion>, offset: number): PendingInsertion {\n let insertion = insertionsByOffset.get(offset);\n\n if (!insertion) {\n insertion = { offset, attributeValues: new Map() };\n insertionsByOffset.set(offset, insertion);\n }\n\n return insertion;\n}\n\nexport function toAttributeInsertions(insertionsByOffset: Map<number, PendingInsertion>): AttributeInsertion[] {\n return [...insertionsByOffset.values()].map(({ offset, attributeValues }) => ({\n offset,\n attributes: getOrderedAttributes(attributeValues),\n }));\n}\n\nfunction getExistingAttributeNames(openingElement: JSXOpeningElementNode): Set<string> {\n const names = new Set<string>();\n\n for (const attribute of openingElement.attributes ?? []) {\n if (attribute.type === 'JSXAttribute') {\n const name = getStringName(attribute.name);\n if (name) {\n names.add(name);\n }\n }\n }\n\n return names;\n}\n\nfunction getOrderedAttributes(attributeValues: ReadonlyMap<string, string>): ComponentAnnotationAttribute[] {\n const attributes: ComponentAnnotationAttribute[] = [];\n\n for (const name of WEB_ATTRIBUTE_NAMES) {\n const value = attributeValues.get(name);\n // HTML mode writes an empty component name for anonymous classes.\n if (value !== undefined) {\n attributes.push([name, value]);\n }\n }\n\n for (const [name, value] of attributeValues) {\n if (!WEB_ATTRIBUTE_NAME_SET.has(name)) {\n attributes.push([name, value]);\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AAC,EAAG;AACvD,IAAA,IAAI,SAAA,CAAU,SAAS,cAAA,EAAgB;AACrC,MAAA,MAAM,IAAA,GAAO,aAAA,CAAc,SAAA,CAAU,IAAI,CAAA;AACzC,MAAA,IAAI,IAAA,EAAM;AACR,QAAA,KAAA,CAAM,IAAI,IAAI,CAAA;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,qBAAqB,eAAA,EAA8E;AAC1G,EAAA,MAAM,aAA6C,EAAC;AAEpD,EAAA,KAAA,MAAW,QAAQ,mBAAA,EAAqB;AACtC,IAAA,MAAM,KAAA,GAAQ,eAAA,CAAgB,GAAA,CAAI,IAAI,CAAA;AAEtC,IAAA,IAAI,UAAU,MAAA,EAAW;AACvB,MAAA,UAAA,CAAW,IAAA,CAAK,CAAC,IAAA,EAAM,KAAK,CAAC,CAAA;AAAA,IAC/B;AAAA,EACF;AAEA,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,CAAA,IAAK,eAAA,EAAiB;AAC3C,IAAA,IAAI,CAAC,sBAAA,CAAuB,GAAA,CAAI,IAAI,CAAA,EAAG;AACrC,MAAA,UAAA,CAAW,IAAA,CAAK,CAAC,IAAA,EAAM,KAAK,CAAC,CAAA;AAAA,IAC/B;AAAA,EACF;AAEA,EAAA,OAAO,UAAA;AACT;;;;"}
1
+ {"version":3,"file":"component-annotation-oxc-jsx.js","names":[],"sources":["../../../src/core/component-annotation-oxc-jsx.ts"],"sourcesContent":["import {\n getComponentAnnotationAttributes,\n WEB_COMPONENT_NAME,\n WEB_ELEMENT_NAME,\n WEB_SOURCE_FILE_NAME,\n} from '../babel-plugin/component-annotation';\nimport type { ComponentAnnotationAttribute } from '../babel-plugin/component-annotation';\nimport type {\n AttributeInsertion,\n FragmentContext,\n JSXElementNode,\n JSXFragmentNode,\n JSXOpeningElementNode,\n JSXRootNode,\n} from './component-annotation-oxc-ast';\nimport { isAstNode, isObjectLike } from './component-annotation-oxc-ast';\n\nconst UNKNOWN_ELEMENT_NAME = 'unknown';\nconst REACT_NATIVE_ELEMENTS = new Set([\n 'Image',\n 'Text',\n 'View',\n 'ScrollView',\n 'TextInput',\n 'TouchableOpacity',\n 'TouchableHighlight',\n 'TouchableWithoutFeedback',\n 'FlatList',\n 'SectionList',\n 'ActivityIndicator',\n 'Button',\n 'Switch',\n 'Modal',\n 'SafeAreaView',\n 'StatusBar',\n 'KeyboardAvoidingView',\n 'RefreshControl',\n 'Picker',\n 'Slider',\n]);\nconst WEB_ATTRIBUTE_NAMES = [WEB_ELEMENT_NAME, WEB_COMPONENT_NAME, WEB_SOURCE_FILE_NAME] as const;\nconst WEB_ATTRIBUTE_NAME_SET = new Set<string>(WEB_ATTRIBUTE_NAMES);\n\ntype PendingInsertion = {\n offset: number;\n attributeValues: Map<string, string>;\n};\n\nexport function isJSXElement(value: unknown): value is JSXElementNode {\n return isAstNode(value) && value.type === 'JSXElement';\n}\n\nexport function isJSXFragment(value: unknown): value is JSXFragmentNode {\n return isAstNode(value) && value.type === 'JSXFragment';\n}\n\nexport function isJSXRoot(value: unknown): value is JSXRootNode {\n return isJSXElement(value) || isJSXFragment(value);\n}\n\nexport function getStringName(node: unknown): string | null {\n return isObjectLike(node) && typeof node.name === 'string' ? node.name : null;\n}\n\nexport function getJSXName(name: unknown): string {\n if (!isAstNode(name)) {\n return UNKNOWN_ELEMENT_NAME;\n }\n\n if (name.type === 'JSXIdentifier') {\n return getStringName(name) ?? UNKNOWN_ELEMENT_NAME;\n }\n\n if (name.type === 'JSXNamespacedName') {\n return getStringName(name.name) ?? UNKNOWN_ELEMENT_NAME;\n }\n\n if (name.type === 'JSXMemberExpression') {\n const objectName = getJSXName(name.object);\n const propertyName = getJSXName(name.property);\n\n return `${objectName}.${propertyName}`;\n }\n\n return UNKNOWN_ELEMENT_NAME;\n}\n\nexport function getInsertionOffset(code: string, openingElement: JSXOpeningElementNode): number | null {\n if (typeof openingElement.end !== 'number') {\n return null;\n }\n\n if (!openingElement.selfClosing) {\n return openingElement.end - 1;\n }\n\n let offset = openingElement.end - 2;\n\n while (offset > 0 && /\\s/.test(code[offset] ?? '')) {\n offset -= 1;\n }\n\n return code[offset] === '/' ? offset : openingElement.end - 1;\n}\n\nexport function isReactFragment(openingElement: JSXOpeningElementNode, fragmentContext: FragmentContext): boolean {\n const elementName = getJSXName(openingElement.name);\n\n if (elementName === 'Fragment' || elementName === 'React.Fragment') {\n return true;\n }\n\n if (fragmentContext.fragmentAliases.has(elementName)) {\n return true;\n }\n\n if (isObjectLike(openingElement.name) && openingElement.name.type === 'JSXMemberExpression') {\n const objectName = getJSXName(openingElement.name.object);\n const propertyName = getJSXName(openingElement.name.property);\n\n return (\n propertyName === 'Fragment' &&\n (fragmentContext.reactNamespaceAliases.has(objectName) || fragmentContext.fragmentAliases.has(objectName))\n );\n }\n\n return false;\n}\n\nexport function addPendingAttributes(\n code: string,\n openingElement: JSXOpeningElementNode,\n componentName: string,\n ignoredComponents: string[],\n fragmentContext: FragmentContext,\n sourceFileName: string,\n insertionsByOffset: Map<number, PendingInsertion>,\n): void {\n const offset = getInsertionOffset(code, openingElement);\n if (offset === null) {\n return;\n }\n\n const pendingInsertion = insertionsByOffset.get(offset);\n const existingAttributes = getExistingAttributeNames(openingElement);\n\n for (const attributeName of pendingInsertion?.attributeValues.keys() ?? []) {\n existingAttributes.add(attributeName);\n }\n\n const attributes = getComponentAnnotationAttributes({\n attributeNames: [WEB_COMPONENT_NAME, WEB_ELEMENT_NAME, WEB_SOURCE_FILE_NAME],\n componentName,\n elementName: getJSXName(openingElement.name),\n existingAttributes,\n ignoredComponents,\n isFragment: isReactFragment(openingElement, fragmentContext),\n sourceFileName,\n });\n\n if (attributes.length === 0) {\n return;\n }\n\n const insertion = getOrCreateInsertion(insertionsByOffset, offset);\n\n for (const [name, value] of attributes) {\n insertion.attributeValues.set(name, value);\n }\n}\n\n/**\n * Returns `true` when the element is an HTML element, because HTML mode only\n * annotates the first HTML elements below a component root.\n */\nexport function addPendingHtmlAttribute(\n code: string,\n openingElement: JSXOpeningElementNode,\n componentName: string,\n ignoredComponents: string[],\n fragmentContext: FragmentContext,\n insertionsByOffset: Map<number, PendingInsertion>,\n): boolean {\n if (isReactFragment(openingElement, fragmentContext)) {\n return false;\n }\n\n const elementName = getJSXName(openingElement.name);\n\n if (!isHtmlElement(elementName)) {\n return false;\n }\n\n if (ignoredComponents.includes(componentName) || ignoredComponents.includes(elementName)) {\n return true;\n }\n\n const offset = getInsertionOffset(code, openingElement);\n if (offset === null) {\n return true;\n }\n\n if (\n getExistingAttributeNames(openingElement).has(WEB_COMPONENT_NAME) ||\n insertionsByOffset.get(offset)?.attributeValues.has(WEB_COMPONENT_NAME)\n ) {\n return true;\n }\n\n getOrCreateInsertion(insertionsByOffset, offset).attributeValues.set(WEB_COMPONENT_NAME, componentName);\n\n return true;\n}\n\nfunction isHtmlElement(elementName: string): boolean {\n if (elementName === UNKNOWN_ELEMENT_NAME) {\n return false;\n }\n\n if (elementName.charAt(0) === elementName.charAt(0).toLowerCase()) {\n return true;\n }\n\n return REACT_NATIVE_ELEMENTS.has(elementName);\n}\n\nfunction getOrCreateInsertion(insertionsByOffset: Map<number, PendingInsertion>, offset: number): PendingInsertion {\n let insertion = insertionsByOffset.get(offset);\n\n if (!insertion) {\n insertion = { offset, attributeValues: new Map() };\n insertionsByOffset.set(offset, insertion);\n }\n\n return insertion;\n}\n\nexport function toAttributeInsertions(insertionsByOffset: Map<number, PendingInsertion>): AttributeInsertion[] {\n return [...insertionsByOffset.values()].map(({ offset, attributeValues }) => ({\n offset,\n attributes: getOrderedAttributes(attributeValues),\n }));\n}\n\nfunction getExistingAttributeNames(openingElement: JSXOpeningElementNode): Set<string> {\n const names = new Set<string>();\n\n for (const attribute of openingElement.attributes ?? []) {\n if (attribute.type === 'JSXAttribute') {\n const name = getStringName(attribute.name);\n if (name) {\n names.add(name);\n }\n }\n }\n\n return names;\n}\n\nfunction getOrderedAttributes(attributeValues: ReadonlyMap<string, string>): ComponentAnnotationAttribute[] {\n const attributes: ComponentAnnotationAttribute[] = [];\n\n for (const name of WEB_ATTRIBUTE_NAMES) {\n const value = attributeValues.get(name);\n // HTML mode writes an empty component name for anonymous classes.\n if (value !== undefined) {\n attributes.push([name, value]);\n }\n }\n\n for (const [name, value] of attributeValues) {\n if (!WEB_ATTRIBUTE_NAME_SET.has(name)) {\n attributes.push([name, value]);\n }\n }\n\n return attributes;\n}\n"],"mappings":";;;AAiBA,MAAM,uBAAuB;AAC7B,MAAM,wCAAwB,IAAI,IAAI;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,sBAAsB;CAAC;CAAkB;CAAoB;AAAoB;AACvF,MAAM,yBAAyB,IAAI,IAAY,mBAAmB;AAOlE,SAAgB,aAAa,OAAyC;CACpE,OAAO,UAAU,KAAK,KAAK,MAAM,SAAS;AAC5C;AAEA,SAAgB,cAAc,OAA0C;CACtE,OAAO,UAAU,KAAK,KAAK,MAAM,SAAS;AAC5C;AAEA,SAAgB,UAAU,OAAsC;CAC9D,OAAO,aAAa,KAAK,KAAK,cAAc,KAAK;AACnD;AAEA,SAAgB,cAAc,MAA8B;CAC1D,OAAO,aAAa,IAAI,KAAK,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO;AAC3E;AAEA,SAAgB,WAAW,MAAuB;CAChD,IAAI,CAAC,UAAU,IAAI,GACjB,OAAO;CAGT,IAAI,KAAK,SAAS,iBAChB,OAAO,cAAc,IAAI,KAAK;CAGhC,IAAI,KAAK,SAAS,qBAChB,OAAO,cAAc,KAAK,IAAI,KAAK;CAGrC,IAAI,KAAK,SAAS,uBAIhB,OAAO,GAHY,WAAW,KAAK,MAGhB,EAAE,GAFA,WAAW,KAAK,QAEF;CAGrC,OAAO;AACT;AAEA,SAAgB,mBAAmB,MAAc,gBAAsD;CACrG,IAAI,OAAO,eAA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UAAU,SAAS,gBAAgB;EACrC,MAAM,OAAO,cAAc,UAAU,IAAI;EACzC,IAAI,MACF,MAAM,IAAI,IAAI;CAElB;CAGF,OAAO;AACT;AAEA,SAAS,qBAAqB,iBAA8E;CAC1G,MAAM,aAA6C,CAAC;CAEpD,KAAK,MAAM,QAAQ,qBAAqB;EACtC,MAAM,QAAQ,gBAAgB,IAAI,IAAI;EAEtC,IAAI,UAAU,KAAA,GACZ,WAAW,KAAK,CAAC,MAAM,KAAK,CAAC;CAEjC;CAEA,KAAK,MAAM,CAAC,MAAM,UAAU,iBAC1B,IAAI,CAAC,uBAAuB,IAAI,IAAI,GAClC,WAAW,KAAK,CAAC,MAAM,KAAK,CAAC;CAIjC,OAAO;AACT"}
@@ -1,140 +1,80 @@
1
- import { toAttributeInsertions, isJSXElement, addPendingHtmlAttribute, isJSXRoot, addPendingAttributes, getStringName } from './component-annotation-oxc-jsx.js';
2
- import { walkAst, isAstNode } from './component-annotation-oxc-ast.js';
3
- import { collectFragmentContext } from './component-annotation-oxc-fragments.js';
4
- import { isObjectLike } from '@sentry/core';
5
-
1
+ import { addPendingAttributes, addPendingHtmlAttribute, getStringName, isJSXElement, isJSXRoot, toAttributeInsertions } from "./component-annotation-oxc-jsx.js";
2
+ import { isAstNode, isObjectLike, walkAst } from "./component-annotation-oxc-ast.js";
3
+ import { collectFragmentContext } from "./component-annotation-oxc-fragments.js";
4
+ // src/core/component-annotation-oxc-walk.ts
6
5
  function collectOxcComponentAnnotationInsertions(code, ast, ignoredComponents, sourceFileName, injectIntoHtml) {
7
- const fragmentContext = collectFragmentContext(ast);
8
- const components = collectComponentJSXRoots(ast);
9
- const insertionsByOffset = /* @__PURE__ */ new Map();
10
- for (const component of components) {
11
- for (const root of component.roots) {
12
- if (injectIntoHtml) {
13
- processHtmlJSX(code, root, component.name, ignoredComponents, fragmentContext, insertionsByOffset);
14
- } else {
15
- processJSX(code, root, component.name, ignoredComponents, fragmentContext, sourceFileName, insertionsByOffset);
16
- }
17
- }
18
- }
19
- return toAttributeInsertions(insertionsByOffset);
6
+ const fragmentContext = collectFragmentContext(ast);
7
+ const components = collectComponentJSXRoots(ast);
8
+ const insertionsByOffset = /* @__PURE__ */ new Map();
9
+ for (const component of components) for (const root of component.roots) if (injectIntoHtml) processHtmlJSX(code, root, component.name, ignoredComponents, fragmentContext, insertionsByOffset);
10
+ else processJSX(code, root, component.name, ignoredComponents, fragmentContext, sourceFileName, insertionsByOffset);
11
+ return toAttributeInsertions(insertionsByOffset);
20
12
  }
21
13
  function processHtmlJSX(code, node, componentName, ignoredComponents, fragmentContext, insertionsByOffset) {
22
- if (isJSXElement(node) && addPendingHtmlAttribute(
23
- code,
24
- node.openingElement,
25
- componentName,
26
- ignoredComponents,
27
- fragmentContext,
28
- insertionsByOffset
29
- )) {
30
- return;
31
- }
32
- for (const child of node.children ?? []) {
33
- if (isJSXRoot(child)) {
34
- processHtmlJSX(code, child, componentName, ignoredComponents, fragmentContext, insertionsByOffset);
35
- }
36
- }
14
+ if (isJSXElement(node) && addPendingHtmlAttribute(code, node.openingElement, componentName, ignoredComponents, fragmentContext, insertionsByOffset)) return;
15
+ for (const child of node.children ?? []) if (isJSXRoot(child)) processHtmlJSX(code, child, componentName, ignoredComponents, fragmentContext, insertionsByOffset);
37
16
  }
38
17
  function getJSXRootsFromReturnArgument(argument) {
39
- if (isJSXRoot(argument)) {
40
- return [argument];
41
- }
42
- if (isObjectLike(argument) && argument.type === "ConditionalExpression") {
43
- return [argument.consequent, argument.alternate].filter(isJSXRoot);
44
- }
45
- return [];
18
+ if (isJSXRoot(argument)) return [argument];
19
+ if (isObjectLike(argument) && argument.type === "ConditionalExpression") return [argument.consequent, argument.alternate].filter(isJSXRoot);
20
+ return [];
46
21
  }
47
22
  function getReturnedJSXFromFunction(functionNode) {
48
- const body = functionNode.body;
49
- if (isJSXRoot(body)) {
50
- return [body];
51
- }
52
- if (!isObjectLike(body) || body.type !== "BlockStatement") {
53
- return [];
54
- }
55
- const bodyStatements = Array.isArray(body.body) ? body.body : [];
56
- const returnStatement = bodyStatements.find((statement) => {
57
- return isAstNode(statement) && statement.type === "ReturnStatement";
58
- });
59
- return isObjectLike(returnStatement) ? getJSXRootsFromReturnArgument(returnStatement.argument) : [];
23
+ const body = functionNode.body;
24
+ if (isJSXRoot(body)) return [body];
25
+ if (!isObjectLike(body) || body.type !== "BlockStatement") return [];
26
+ const returnStatement = (Array.isArray(body.body) ? body.body : []).find((statement) => {
27
+ return isAstNode(statement) && statement.type === "ReturnStatement";
28
+ });
29
+ return isObjectLike(returnStatement) ? getJSXRootsFromReturnArgument(returnStatement.argument) : [];
60
30
  }
61
31
  function pushFunctionComponent(components, nameNode, functionNode) {
62
- const name = getStringName(nameNode);
63
- if (name) {
64
- components.push({
65
- name,
66
- roots: getReturnedJSXFromFunction(functionNode)
67
- });
68
- }
32
+ const name = getStringName(nameNode);
33
+ if (name) components.push({
34
+ name,
35
+ roots: getReturnedJSXFromFunction(functionNode)
36
+ });
69
37
  }
70
38
  function collectComponentJSXRoots(ast) {
71
- const components = [];
72
- walkAst(ast, (node) => {
73
- if (node.type === "FunctionDeclaration" && isObjectLike(node.id)) {
74
- pushFunctionComponent(components, node.id, node);
75
- return;
76
- }
77
- if (node.type === "VariableDeclarator" && isObjectLike(node.id)) {
78
- if (isAstNode(node.init) && node.init.type === "ArrowFunctionExpression") {
79
- pushFunctionComponent(components, node.id, node.init);
80
- }
81
- return;
82
- }
83
- if (node.type === "ClassDeclaration") {
84
- pushClassComponent(components, node);
85
- }
86
- });
87
- return components;
39
+ const components = [];
40
+ walkAst(ast, (node) => {
41
+ if (node.type === "FunctionDeclaration" && isObjectLike(node.id)) {
42
+ pushFunctionComponent(components, node.id, node);
43
+ return;
44
+ }
45
+ if (node.type === "VariableDeclarator" && isObjectLike(node.id)) {
46
+ if (isAstNode(node.init) && node.init.type === "ArrowFunctionExpression") pushFunctionComponent(components, node.id, node.init);
47
+ return;
48
+ }
49
+ if (node.type === "ClassDeclaration") pushClassComponent(components, node);
50
+ });
51
+ return components;
88
52
  }
89
53
  function pushClassComponent(components, node) {
90
- const renderMethodBody = getClassRenderMethodBody(node);
91
- if (!renderMethodBody) {
92
- return;
93
- }
94
- const roots = [];
95
- walkAst(renderMethodBody, (child) => {
96
- if (child.type === "ReturnStatement" && isJSXRoot(child.argument)) {
97
- roots.push(child.argument);
98
- }
99
- });
100
- components.push({
101
- name: getStringName(node.id) ?? "",
102
- roots
103
- });
54
+ const renderMethodBody = getClassRenderMethodBody(node);
55
+ if (!renderMethodBody) return;
56
+ const roots = [];
57
+ walkAst(renderMethodBody, (child) => {
58
+ if (child.type === "ReturnStatement" && isJSXRoot(child.argument)) roots.push(child.argument);
59
+ });
60
+ components.push({
61
+ name: getStringName(node.id) ?? "",
62
+ roots
63
+ });
104
64
  }
105
65
  function getClassRenderMethodBody(node) {
106
- if (!isObjectLike(node.body) || !Array.isArray(node.body.body)) {
107
- return null;
108
- }
109
- const renderMethod = node.body.body.find((member) => {
110
- return isObjectLike(member) && isObjectLike(member.key) && getStringName(member.key) === "render" && (isObjectLike(member.value) || isObjectLike(member.body));
111
- });
112
- if (!isObjectLike(renderMethod)) {
113
- return null;
114
- }
115
- if (isAstNode(renderMethod.value)) {
116
- return renderMethod.value;
117
- }
118
- return isAstNode(renderMethod) ? renderMethod : null;
66
+ if (!isObjectLike(node.body) || !Array.isArray(node.body.body)) return null;
67
+ const renderMethod = node.body.body.find((member) => {
68
+ return isObjectLike(member) && isObjectLike(member.key) && getStringName(member.key) === "render" && (isObjectLike(member.value) || isObjectLike(member.body));
69
+ });
70
+ if (!isObjectLike(renderMethod)) return null;
71
+ if (isAstNode(renderMethod.value)) return renderMethod.value;
72
+ return isAstNode(renderMethod) ? renderMethod : null;
119
73
  }
120
74
  function processJSX(code, node, componentName, ignoredComponents, fragmentContext, sourceFileName, insertionsByOffset) {
121
- if (isJSXElement(node)) {
122
- addPendingAttributes(
123
- code,
124
- node.openingElement,
125
- componentName,
126
- ignoredComponents,
127
- fragmentContext,
128
- sourceFileName,
129
- insertionsByOffset
130
- );
131
- }
132
- for (const child of node.children ?? []) {
133
- if (isJSXRoot(child)) {
134
- processJSX(code, child, "", ignoredComponents, fragmentContext, sourceFileName, insertionsByOffset);
135
- }
136
- }
75
+ if (isJSXElement(node)) addPendingAttributes(code, node.openingElement, componentName, ignoredComponents, fragmentContext, sourceFileName, insertionsByOffset);
76
+ for (const child of node.children ?? []) if (isJSXRoot(child)) processJSX(code, child, "", ignoredComponents, fragmentContext, sourceFileName, insertionsByOffset);
137
77
  }
138
-
139
78
  export { collectOxcComponentAnnotationInsertions };
140
- //# sourceMappingURL=component-annotation-oxc-walk.js.map
79
+
80
+ //# sourceMappingURL=component-annotation-oxc-walk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component-annotation-oxc-walk.js","sources":["../../../src/core/component-annotation-oxc-walk.ts"],"sourcesContent":["import type { AstNode, AttributeInsertion, FragmentContext, JSXRootNode } from './component-annotation-oxc-ast';\nimport {\n addPendingAttributes,\n addPendingHtmlAttribute,\n getStringName,\n isJSXElement,\n isJSXRoot,\n toAttributeInsertions,\n} from './component-annotation-oxc-jsx';\nimport { isAstNode, isObjectLike, walkAst } from './component-annotation-oxc-ast';\nimport { collectFragmentContext } from './component-annotation-oxc-fragments';\n\ntype ComponentJSXRoots = { name: string; roots: JSXRootNode[] };\n\nexport function collectOxcComponentAnnotationInsertions(\n code: string,\n ast: AstNode,\n ignoredComponents: string[],\n sourceFileName: string,\n injectIntoHtml: boolean,\n): AttributeInsertion[] {\n const fragmentContext = collectFragmentContext(ast);\n const components = collectComponentJSXRoots(ast);\n const insertionsByOffset = new Map<number, { offset: number; attributeValues: Map<string, string> }>();\n\n for (const component of components) {\n for (const root of component.roots) {\n if (injectIntoHtml) {\n processHtmlJSX(code, root, component.name, ignoredComponents, fragmentContext, insertionsByOffset);\n } else {\n processJSX(code, root, component.name, ignoredComponents, fragmentContext, sourceFileName, insertionsByOffset);\n }\n }\n }\n\n return toAttributeInsertions(insertionsByOffset);\n}\n\nfunction processHtmlJSX(\n code: string,\n node: JSXRootNode,\n componentName: string,\n ignoredComponents: string[],\n fragmentContext: FragmentContext,\n insertionsByOffset: Map<number, { offset: number; attributeValues: Map<string, string> }>,\n): void {\n if (\n isJSXElement(node) &&\n addPendingHtmlAttribute(\n code,\n node.openingElement,\n componentName,\n ignoredComponents,\n fragmentContext,\n insertionsByOffset,\n )\n ) {\n return;\n }\n\n for (const child of node.children ?? []) {\n if (isJSXRoot(child)) {\n processHtmlJSX(code, child, componentName, ignoredComponents, fragmentContext, insertionsByOffset);\n }\n }\n}\n\nfunction getJSXRootsFromReturnArgument(argument: unknown): JSXRootNode[] {\n if (isJSXRoot(argument)) {\n return [argument];\n }\n\n if (isObjectLike(argument) && argument.type === 'ConditionalExpression') {\n return [argument.consequent, argument.alternate].filter(isJSXRoot);\n }\n\n return [];\n}\n\nfunction getReturnedJSXFromFunction(functionNode: AstNode): JSXRootNode[] {\n const body = functionNode.body;\n\n if (isJSXRoot(body)) {\n return [body];\n }\n\n if (!isObjectLike(body) || body.type !== 'BlockStatement') {\n return [];\n }\n\n const bodyStatements = Array.isArray(body.body) ? body.body : [];\n const returnStatement = bodyStatements.find(statement => {\n return isAstNode(statement) && statement.type === 'ReturnStatement';\n });\n\n return isObjectLike(returnStatement) ? getJSXRootsFromReturnArgument(returnStatement.argument) : [];\n}\n\nfunction pushFunctionComponent(components: ComponentJSXRoots[], nameNode: unknown, functionNode: AstNode): void {\n const name = getStringName(nameNode);\n\n if (name) {\n components.push({\n name,\n roots: getReturnedJSXFromFunction(functionNode),\n });\n }\n}\n\nfunction collectComponentJSXRoots(ast: AstNode): ComponentJSXRoots[] {\n const components: ComponentJSXRoots[] = [];\n\n walkAst(ast, node => {\n if (node.type === 'FunctionDeclaration' && isObjectLike(node.id)) {\n pushFunctionComponent(components, node.id, node);\n return;\n }\n\n if (node.type === 'VariableDeclarator' && isObjectLike(node.id)) {\n if (isAstNode(node.init) && node.init.type === 'ArrowFunctionExpression') {\n pushFunctionComponent(components, node.id, node.init);\n }\n\n return;\n }\n\n if (node.type === 'ClassDeclaration') {\n pushClassComponent(components, node);\n }\n });\n\n return components;\n}\n\nfunction pushClassComponent(components: ComponentJSXRoots[], node: AstNode): void {\n const renderMethodBody = getClassRenderMethodBody(node);\n\n if (!renderMethodBody) {\n return;\n }\n\n const roots: JSXRootNode[] = [];\n\n walkAst(renderMethodBody, child => {\n if (child.type === 'ReturnStatement' && isJSXRoot(child.argument)) {\n roots.push(child.argument);\n }\n });\n\n components.push({\n name: getStringName(node.id) ?? '',\n roots,\n });\n}\n\nfunction getClassRenderMethodBody(node: AstNode): AstNode | null {\n if (!isObjectLike(node.body) || !Array.isArray(node.body.body)) {\n return null;\n }\n\n const renderMethod = node.body.body.find(member => {\n return (\n isObjectLike(member) &&\n isObjectLike(member.key) &&\n getStringName(member.key) === 'render' &&\n (isObjectLike(member.value) || isObjectLike(member.body))\n );\n });\n\n if (!isObjectLike(renderMethod)) {\n return null;\n }\n\n if (isAstNode(renderMethod.value)) {\n return renderMethod.value;\n }\n\n return isAstNode(renderMethod) ? renderMethod : null;\n}\n\nfunction processJSX(\n code: string,\n node: JSXRootNode,\n componentName: string,\n ignoredComponents: string[],\n fragmentContext: FragmentContext,\n sourceFileName: string,\n insertionsByOffset: Map<number, { offset: number; attributeValues: Map<string, string> }>,\n): void {\n if (isJSXElement(node)) {\n addPendingAttributes(\n code,\n node.openingElement,\n componentName,\n ignoredComponents,\n fragmentContext,\n sourceFileName,\n insertionsByOffset,\n );\n }\n\n for (const child of node.children ?? []) {\n if (isJSXRoot(child)) {\n processJSX(code, child, '', ignoredComponents, fragmentContext, sourceFileName, insertionsByOffset);\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAcO,SAAS,uCAAA,CACd,IAAA,EACA,GAAA,EACA,iBAAA,EACA,gBACA,cAAA,EACsB;AACtB,EAAA,MAAM,eAAA,GAAkB,uBAAuB,GAAG,CAAA;AAClD,EAAA,M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A,EAAO,EAAA,EAAI,iBAAA,EAAmB,eAAA,EAAiB,gBAAgB,kBAAkB,CAAA;AAAA,IACpG;AAAA,EACF;AACF;;;;"}
1
+ {"version":3,"file":"component-annotation-oxc-walk.js","names":[],"sources":["../../../src/core/component-annotation-oxc-walk.ts"],"sourcesContent":["import type { AstNode, AttributeInsertion, FragmentContext, JSXRootNode } from './component-annotation-oxc-ast';\nimport {\n addPendingAttributes,\n addPendingHtmlAttribute,\n getStringName,\n isJSXElement,\n isJSXRoot,\n toAttributeInsertions,\n} from './component-annotation-oxc-jsx';\nimport { isAstNode, isObjectLike, walkAst } from './component-annotation-oxc-ast';\nimport { collectFragmentContext } from './component-annotation-oxc-fragments';\n\ntype ComponentJSXRoots = { name: string; roots: JSXRootNode[] };\n\nexport function collectOxcComponentAnnotationInsertions(\n code: string,\n ast: AstNode,\n ignoredComponents: string[],\n sourceFileName: string,\n injectIntoHtml: boolean,\n): AttributeInsertion[] {\n const fragmentContext = collectFragmentContext(ast);\n const components = collectComponentJSXRoots(ast);\n const insertionsByOffset = new Map<number, { offset: number; attributeValues: Map<string, string> }>();\n\n for (const component of components) {\n for (const root of component.roots) {\n if (injectIntoHtml) {\n processHtmlJSX(code, root, component.name, ignoredComponents, fragmentContext, insertionsByOffset);\n } else {\n processJSX(code, root, component.name, ignoredComponents, fragmentContext, sourceFileName, insertionsByOffset);\n }\n }\n }\n\n return toAttributeInsertions(insertionsByOffset);\n}\n\nfunction processHtmlJSX(\n code: string,\n node: JSXRootNode,\n componentName: string,\n ignoredComponents: string[],\n fragmentContext: FragmentContext,\n insertionsByOffset: Map<number, { offset: number; attributeValues: Map<string, string> }>,\n): void {\n if (\n isJSXElement(node) &&\n addPendingHtmlAttribute(\n code,\n node.openingElement,\n componentName,\n ignoredComponents,\n fragmentContext,\n insertionsByOffset,\n )\n ) {\n return;\n }\n\n for (const child of node.children ?? []) {\n if (isJSXRoot(child)) {\n processHtmlJSX(code, child, componentName, ignoredComponents, fragmentContext, insertionsByOffset);\n }\n }\n}\n\nfunction getJSXRootsFromReturnArgument(argument: unknown): JSXRootNode[] {\n if (isJSXRoot(argument)) {\n return [argument];\n }\n\n if (isObjectLike(argument) && argument.type === 'ConditionalExpression') {\n return [argument.consequent, argument.alternate].filter(isJSXRoot);\n }\n\n return [];\n}\n\nfunction getReturnedJSXFromFunction(functionNode: AstNode): JSXRootNode[] {\n const body = functionNode.body;\n\n if (isJSXRoot(body)) {\n return [body];\n }\n\n if (!isObjectLike(body) || body.type !== 'BlockStatement') {\n return [];\n }\n\n const bodyStatements = Array.isArray(body.body) ? body.body : [];\n const returnStatement = bodyStatements.find(statement => {\n return isAstNode(statement) && statement.type === 'ReturnStatement';\n });\n\n return isObjectLike(returnStatement) ? getJSXRootsFromReturnArgument(returnStatement.argument) : [];\n}\n\nfunction pushFunctionComponent(components: ComponentJSXRoots[], nameNode: unknown, functionNode: AstNode): void {\n const name = getStringName(nameNode);\n\n if (name) {\n components.push({\n name,\n roots: getReturnedJSXFromFunction(functionNode),\n });\n }\n}\n\nfunction collectComponentJSXRoots(ast: AstNode): ComponentJSXRoots[] {\n const components: ComponentJSXRoots[] = [];\n\n walkAst(ast, node => {\n if (node.type === 'FunctionDeclaration' && isObjectLike(node.id)) {\n pushFunctionComponent(components, node.id, node);\n return;\n }\n\n if (node.type === 'VariableDeclarator' && isObjectLike(node.id)) {\n if (isAstNode(node.init) && node.init.type === 'ArrowFunctionExpression') {\n pushFunctionComponent(components, node.id, node.init);\n }\n\n return;\n }\n\n if (node.type === 'ClassDeclaration') {\n pushClassComponent(components, node);\n }\n });\n\n return components;\n}\n\nfunction pushClassComponent(components: ComponentJSXRoots[], node: AstNode): void {\n const renderMethodBody = getClassRenderMethodBody(node);\n\n if (!renderMethodBody) {\n return;\n }\n\n const roots: JSXRootNode[] = [];\n\n walkAst(renderMethodBody, child => {\n if (child.type === 'ReturnStatement' && isJSXRoot(child.argument)) {\n roots.push(child.argument);\n }\n });\n\n components.push({\n name: getStringName(node.id) ?? '',\n roots,\n });\n}\n\nfunction getClassRenderMethodBody(node: AstNode): AstNode | null {\n if (!isObjectLike(node.body) || !Array.isArray(node.body.body)) {\n return null;\n }\n\n const renderMethod = node.body.body.find(member => {\n return (\n isObjectLike(member) &&\n isObjectLike(member.key) &&\n getStringName(member.key) === 'render' &&\n (isObjectLike(member.value) || isObjectLike(member.body))\n );\n });\n\n if (!isObjectLike(renderMethod)) {\n return null;\n }\n\n if (isAstNode(renderMethod.value)) {\n return renderMethod.value;\n }\n\n return isAstNode(renderMethod) ? renderMethod : null;\n}\n\nfunction processJSX(\n code: string,\n node: JSXRootNode,\n componentName: string,\n ignoredComponents: string[],\n fragmentContext: FragmentContext,\n sourceFileName: string,\n insertionsByOffset: Map<number, { offset: number; attributeValues: Map<string, string> }>,\n): void {\n if (isJSXElement(node)) {\n addPendingAttributes(\n code,\n node.openingElement,\n componentName,\n ignoredComponents,\n fragmentContext,\n sourceFileName,\n insertionsByOffset,\n );\n }\n\n for (const child of node.children ?? []) {\n if (isJSXRoot(child)) {\n processJSX(code, child, '', ignoredComponents, fragmentContext, sourceFileName, insertionsByOffset);\n }\n }\n}\n"],"mappings":";;;;AAcA,SAAgB,wCACd,MACA,KACA,mBACA,gBACA,gBACsB;CACtB,MAAM,kBAAkB,uBAAuB,GAAG;CAClD,MAAM,aAAa,yBAAyB,GAAG;CAC/C,MAAM,qCAAqB,IAAI,IAAsE;CAErG,KAAK,MAAM,aAAa,YACtB,KAAK,MAAM,QAAQ,UAAU,OAC3B,IAAI,gBACF,eAAe,MAAM,MAAM,UAAU,MAAM,mBAAmB,iBAAiB,kBAAkB;MAEjG,WAAW,MAAM,MAAM,UAAU,MAAM,mBAAmB,iBAAiB,gBAAgB,kBAAkB;CAKnH,OAAO,sBAAsB,kBAAkB;AACjD;AAEA,SAAS,eACP,MACA,MACA,eACA,mBACA,iBACA,oBACM;CACN,IACE,aAAa,IAAI,KACjB,wBACE,MACA,KAAK,gBACL,eACA,mBACA,iBACA,kBACF,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AI;GAGtD;EACF;EAEA,IAAI,KAAK,SAAS,oBAChB,mBAAmB,YAAY,IAAI;CAEvC,CAAC;CAED,OAAO;AACT;AAEA,SAAS,mBAAmB,YAAiC,MAAqB;CAChF,MAAM,mBAAmB,yBAAyB,IAAI;CAEtD,IAAI,CAAC,kBACH;CAGF,MAAM,QAAuB,CAAC;CAE9B,QAAQ,mBAAkB,UAAS;EACjC,IAAI,MAAM,SAAS,qBAAqB,UAAU,MAAM,QAAQ,GAC9D,MAAM,KAAK,MAAM,QAAQ;CAE7B,CAAC;CAED,WAAW,KAAK;EACd,MAAM,cAAc,KAAK,EAAE,KAAK;EAChC;CACF,CAAC;AACH;AAEA,SAAS,yBAAyB,MAA+B;CAC/D,IAAI,CAAC,aAAa,KAAK,IAAI,KAAK,CAAC,MAAM,QAAQ,KAAK,KAAK,IAAI,GAC3D,OAAO;CAGT,MAAM,eAAe,KAAK,KAAK,KAAK,MAAK,WAAU;EACjD,OACE,aAAa,MAAM,KACnB,aAAa,OAAO,GAAG,KACvB,cAAc,OAAO,GAAG,MAAM,aAC7B,aAAa,OAAO,KAAK,KAAK,aAAa,OAAO,IAAI;CAE3D,CAAC;CAED,IAAI,CAAC,aAAa,YAAY,GAC5B,OAAO;CAGT,IAAI,UAAU,aAAa,KAAK,GAC9B,OAAO,aAAa;CAGtB,OAAO,UAAU,YAAY,IAAI,eAAe;AAClD;AAEA,SAAS,WACP,MACA,MACA,eACA,mBACA,iBACA,gBACA,oBACM;CACN,IAAI,aAAa,IAAI,GACnB,qBACE,MACA,KAAK,gBACL,eACA,mBACA,iBACA,gBACA,kBACF;CAGF,KAAK,MAAM,SAAS,KAAK,YAAY,CAAC,GACpC,IAAI,UAAU,KAAK,GACjB,WAAW,MAAM,OAAO,IAAI,mBAAmB,iBAAiB,gBAAgB,kBAAkB;AAGxG"}
@@ -1,118 +1,87 @@
1
- import path__default from 'node:path';
2
- import MagicString from 'magic-string';
3
- import { KNOWN_INCOMPATIBLE_PLUGINS } from '../babel-plugin/constants.js';
4
- import { stripQueryAndHashFromPath } from './utils.js';
5
- import { isAstNode } from './component-annotation-oxc-ast.js';
6
- import { collectOxcComponentAnnotationInsertions } from './component-annotation-oxc-walk.js';
7
-
1
+ import { KNOWN_INCOMPATIBLE_PLUGINS } from "../babel-plugin/constants.js";
2
+ import { stripQueryAndHashFromPath } from "./utils.js";
3
+ import { isAstNode } from "./component-annotation-oxc-ast.js";
4
+ import { collectOxcComponentAnnotationInsertions } from "./component-annotation-oxc-walk.js";
5
+ import MagicString from "magic-string";
6
+ import path from "node:path";
7
+ // src/core/component-annotation-oxc.ts
8
8
  let oxcParseAstAsyncPromise;
9
9
  function getOxcParseAstAsync() {
10
- if (!oxcParseAstAsyncPromise) {
11
- oxcParseAstAsyncPromise = import('oxc-parser').then(({ parse }) => {
12
- return async (code, { lang }) => {
13
- const { program, errors } = await parse(`component.${lang}`, code, { lang, preserveParens: false });
14
- if (errors.length > 0) {
15
- throw new Error(errors[0]?.message);
16
- }
17
- return program;
18
- };
19
- }).catch(() => null);
20
- }
21
- return oxcParseAstAsyncPromise;
10
+ if (!oxcParseAstAsyncPromise) oxcParseAstAsyncPromise = import("oxc-parser").then(({ parse }) => {
11
+ return async (code, { lang }) => {
12
+ const { program, errors } = await parse(`component.${lang}`, code, {
13
+ lang,
14
+ preserveParens: false
15
+ });
16
+ if (errors.length > 0) throw new Error(errors[0]?.message);
17
+ return program;
18
+ };
19
+ }).catch(() => null);
20
+ return oxcParseAstAsyncPromise;
22
21
  }
23
22
  const JSX_TAG_START_REGEXP = /<[$_\p{ID_Start}][$_\u200c\u200d\p{ID_Continue}.:-]*|<>/u;
24
23
  const JSX_FILE_REGEXP = /\.[jt]sx$/;
25
24
  function isAnnotationFile(idWithoutQueryAndHash) {
26
- if (idWithoutQueryAndHash.match(/\\node_modules\\|\/node_modules\//)) {
27
- return false;
28
- }
29
- return JSX_FILE_REGEXP.test(idWithoutQueryAndHash);
25
+ if (idWithoutQueryAndHash.match(/\\node_modules\\|\/node_modules\//)) return false;
26
+ return JSX_FILE_REGEXP.test(idWithoutQueryAndHash);
30
27
  }
31
28
  function shouldTryParse(code) {
32
- return JSX_TAG_START_REGEXP.test(code);
29
+ return JSX_TAG_START_REGEXP.test(code);
33
30
  }
34
31
  function shouldSkipIncompatibleFile(idWithoutQueryAndHash) {
35
- return KNOWN_INCOMPATIBLE_PLUGINS.some((pluginName) => {
36
- return idWithoutQueryAndHash.includes(`/node_modules/${pluginName}/`) || idWithoutQueryAndHash.includes(`\\node_modules\\${pluginName}\\`);
37
- });
32
+ return KNOWN_INCOMPATIBLE_PLUGINS.some((pluginName) => {
33
+ return idWithoutQueryAndHash.includes(`/node_modules/${pluginName}/`) || idWithoutQueryAndHash.includes(`\\node_modules\\${pluginName}\\`);
34
+ });
38
35
  }
39
36
  function escapeAttributeValue(value) {
40
- return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
37
+ return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
41
38
  }
42
39
  function makeAttributeText(code, insertionOffset, attributes) {
43
- const previousCharIsWhitespace = insertionOffset > 0 && /\s/.test(code[insertionOffset - 1] ?? "");
44
- const prefix = previousCharIsWhitespace ? "" : " ";
45
- const suffix = previousCharIsWhitespace && code[insertionOffset] === "/" ? " " : "";
46
- const attributeText = attributes.map(([name, value]) => `${name}="${escapeAttributeValue(value)}"`).join(" ");
47
- return `${prefix}${attributeText}${suffix}`;
40
+ const previousCharIsWhitespace = insertionOffset > 0 && /\s/.test(code[insertionOffset - 1] ?? "");
41
+ const prefix = previousCharIsWhitespace ? "" : " ";
42
+ const suffix = previousCharIsWhitespace && code[insertionOffset] === "/" ? " " : "";
43
+ return `${prefix}${attributes.map(([name, value]) => `${name}="${escapeAttributeValue(value)}"`).join(" ")}${suffix}`;
48
44
  }
49
45
  function getMagicString(code, meta) {
50
- if (meta?.magicString) {
51
- return { magicString: meta.magicString, isNative: true };
52
- }
53
- return { magicString: new MagicString(code), isNative: false };
46
+ if (meta?.magicString) return {
47
+ magicString: meta.magicString,
48
+ isNative: true
49
+ };
50
+ return {
51
+ magicString: new MagicString(code),
52
+ isNative: false
53
+ };
54
54
  }
55
55
  async function annotateWithOxcParser(code, idWithoutQueryAndHash, ignoredComponents, parseAstAsync, injectIntoHtml, meta) {
56
- const ast = await parseAstAsync(code, {
57
- lang: idWithoutQueryAndHash.endsWith(".jsx") ? "jsx" : "tsx"
58
- });
59
- if (!isAstNode(ast)) {
60
- return null;
61
- }
62
- const insertions = collectOxcComponentAnnotationInsertions(
63
- code,
64
- ast,
65
- ignoredComponents,
66
- path__default.basename(idWithoutQueryAndHash),
67
- injectIntoHtml
68
- );
69
- if (insertions.length === 0) {
70
- return null;
71
- }
72
- const { magicString, isNative } = getMagicString(code, meta);
73
- for (const insertion of insertions) {
74
- magicString.appendLeft(insertion.offset, makeAttributeText(code, insertion.offset, insertion.attributes));
75
- }
76
- if (isNative) {
77
- return { code: magicString };
78
- }
79
- return {
80
- code: magicString.toString(),
81
- // No `file`, because magic-string would then make `source` relative to it
82
- // and drop the directory from `sources`.
83
- map: magicString.generateMap?.({
84
- source: idWithoutQueryAndHash,
85
- includeContent: true,
86
- hires: true
87
- })
88
- };
56
+ const ast = await parseAstAsync(code, { lang: idWithoutQueryAndHash.endsWith(".jsx") ? "jsx" : "tsx" });
57
+ if (!isAstNode(ast)) return null;
58
+ const insertions = collectOxcComponentAnnotationInsertions(code, ast, ignoredComponents, path.basename(idWithoutQueryAndHash), injectIntoHtml);
59
+ if (insertions.length === 0) return null;
60
+ const { magicString, isNative } = getMagicString(code, meta);
61
+ for (const insertion of insertions) magicString.appendLeft(insertion.offset, makeAttributeText(code, insertion.offset, insertion.attributes));
62
+ if (isNative) return { code: magicString };
63
+ return {
64
+ code: magicString.toString(),
65
+ map: magicString.generateMap?.({
66
+ source: idWithoutQueryAndHash,
67
+ includeContent: true,
68
+ hires: true
69
+ })
70
+ };
89
71
  }
90
72
  function createOxcComponentNameAnnotateHooks(ignoredComponents, getParseAstAsync, injectIntoHtml = false) {
91
- return {
92
- async transform(code, id, meta) {
93
- const idWithoutQueryAndHash = stripQueryAndHashFromPath(id);
94
- if (!idWithoutQueryAndHash || !isAnnotationFile(idWithoutQueryAndHash) || !shouldTryParse(code) || shouldSkipIncompatibleFile(idWithoutQueryAndHash)) {
95
- return null;
96
- }
97
- try {
98
- const parseAstAsync = await getParseAstAsync();
99
- if (!parseAstAsync) {
100
- return null;
101
- }
102
- return await annotateWithOxcParser(
103
- code,
104
- idWithoutQueryAndHash,
105
- ignoredComponents,
106
- parseAstAsync,
107
- injectIntoHtml,
108
- meta
109
- );
110
- } catch {
111
- return null;
112
- }
113
- }
114
- };
73
+ return { async transform(code, id, meta) {
74
+ const idWithoutQueryAndHash = stripQueryAndHashFromPath(id);
75
+ if (!idWithoutQueryAndHash || !isAnnotationFile(idWithoutQueryAndHash) || !shouldTryParse(code) || shouldSkipIncompatibleFile(idWithoutQueryAndHash)) return null;
76
+ try {
77
+ const parseAstAsync = await getParseAstAsync();
78
+ if (!parseAstAsync) return null;
79
+ return await annotateWithOxcParser(code, idWithoutQueryAndHash, ignoredComponents, parseAstAsync, injectIntoHtml, meta);
80
+ } catch {
81
+ return null;
82
+ }
83
+ } };
115
84
  }
116
-
117
85
  export { createOxcComponentNameAnnotateHooks, getOxcParseAstAsync };
118
- //# sourceMappingURL=component-annotation-oxc.js.map
86
+
87
+ //# sourceMappingURL=component-annotation-oxc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component-annotation-oxc.js","sources":["../../../src/core/component-annotation-oxc.ts"],"sourcesContent":["import path from 'node:path';\n\nimport MagicString from 'magic-string';\n\nimport { KNOWN_INCOMPATIBLE_PLUGINS } from '../babel-plugin/constants';\nimport { stripQueryAndHashFromPath } from './utils';\nimport { isAstNode } from './component-annotation-oxc-ast';\nimport { collectOxcComponentAnnotationInsertions } from './component-annotation-oxc-walk';\nimport type {\n AttributeInsertion,\n ComponentAnnotationTransformMeta,\n ComponentAnnotationTransformResult,\n MagicStringLike,\n ParseAstAsync,\n} from './component-annotation-oxc-ast';\n\nexport type {\n ComponentAnnotationTransformMeta,\n ComponentAnnotationTransformResult,\n} from './component-annotation-oxc-ast';\n\nlet oxcParseAstAsyncPromise: Promise<ParseAstAsync | null> | undefined;\n\nexport function getOxcParseAstAsync(): Promise<ParseAstAsync | null> {\n if (!oxcParseAstAsyncPromise) {\n oxcParseAstAsyncPromise = import('oxc-parser')\n .then(({ parse }): ParseAstAsync => {\n return async (code, { lang }) => {\n // preserveParens: false matches the AST Vite 8 produces. The walker\n // does not look through ParenthesizedExpression nodes.\n const { program, errors } = await parse(`component.${lang}`, code, { lang, preserveParens: false });\n\n if (errors.length > 0) {\n throw new Error(errors[0]?.message);\n }\n\n return program;\n };\n })\n .catch(() => null);\n }\n\n return oxcParseAstAsyncPromise;\n}\n\n// Keep this as a superset of all JSX tag starts, because a miss skips the file.\nconst JSX_TAG_START_REGEXP = /<[$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}.:-]*|<>/u;\nconst JSX_FILE_REGEXP = /\\.[jt]sx$/;\n\nfunction isAnnotationFile(idWithoutQueryAndHash: string): boolean {\n if (idWithoutQueryAndHash.match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n return false;\n }\n\n return JSX_FILE_REGEXP.test(idWithoutQueryAndHash);\n}\n\nfunction shouldTryParse(code: string): boolean {\n return JSX_TAG_START_REGEXP.test(code);\n}\n\nfunction shouldSkipIncompatibleFile(idWithoutQueryAndHash: string): boolean {\n return KNOWN_INCOMPATIBLE_PLUGINS.some(pluginName => {\n return (\n idWithoutQueryAndHash.includes(`/node_modules/${pluginName}/`) ||\n idWithoutQueryAndHash.includes(`\\\\node_modules\\\\${pluginName}\\\\`)\n );\n });\n}\n\nfunction escapeAttributeValue(value: string): string {\n return value.replace(/&/g, '&amp;').replace(/\"/g, '&quot;');\n}\n\nfunction makeAttributeText(\n code: string,\n insertionOffset: number,\n attributes: AttributeInsertion['attributes'],\n): string {\n const previousCharIsWhitespace = insertionOffset > 0 && /\\s/.test(code[insertionOffset - 1] ?? '');\n const prefix = previousCharIsWhitespace ? '' : ' ';\n const suffix = previousCharIsWhitespace && code[insertionOffset] === '/' ? ' ' : '';\n const attributeText = attributes.map(([name, value]) => `${name}=\"${escapeAttributeValue(value)}\"`).join(' ');\n\n return `${prefix}${attributeText}${suffix}`;\n}\n\nfunction getMagicString(\n code: string,\n meta?: ComponentAnnotationTransformMeta,\n): { magicString: MagicStringLike; isNative: boolean } {\n if (meta?.magicString) {\n return { magicString: meta.magicString, isNative: true };\n }\n\n return { magicString: new MagicString(code), isNative: false };\n}\n\nasync function annotateWithOxcParser(\n code: string,\n idWithoutQueryAndHash: string,\n ignoredComponents: string[],\n parseAstAsync: ParseAstAsync,\n injectIntoHtml: boolean,\n meta?: ComponentAnnotationTransformMeta,\n): Promise<ComponentAnnotationTransformResult> {\n const ast = await parseAstAsync(code, {\n lang: idWithoutQueryAndHash.endsWith('.jsx') ? 'jsx' : 'tsx',\n });\n\n if (!isAstNode(ast)) {\n return null;\n }\n\n const insertions = collectOxcComponentAnnotationInsertions(\n code,\n ast,\n ignoredComponents,\n path.basename(idWithoutQueryAndHash),\n injectIntoHtml,\n );\n\n if (insertions.length === 0) {\n return null;\n }\n\n const { magicString, isNative } = getMagicString(code, meta);\n\n for (const insertion of insertions) {\n magicString.appendLeft(insertion.offset, makeAttributeText(code, insertion.offset, insertion.attributes));\n }\n\n if (isNative) {\n return { code: magicString as unknown as string };\n }\n\n return {\n code: magicString.toString(),\n // No `file`, because magic-string would then make `source` relative to it\n // and drop the directory from `sources`.\n map: magicString.generateMap?.({\n source: idWithoutQueryAndHash,\n includeContent: true,\n hires: true,\n }),\n };\n}\n\nexport function createOxcComponentNameAnnotateHooks(\n ignoredComponents: string[],\n getParseAstAsync: () => Promise<ParseAstAsync | null>,\n injectIntoHtml = false,\n): {\n transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<ComponentAnnotationTransformResult>;\n} {\n return {\n async transform(code, id, meta) {\n const idWithoutQueryAndHash = stripQueryAndHashFromPath(id);\n\n if (\n !idWithoutQueryAndHash ||\n !isAnnotationFile(idWithoutQueryAndHash) ||\n !shouldTryParse(code) ||\n shouldSkipIncompatibleFile(idWithoutQueryAndHash)\n ) {\n return null;\n }\n\n try {\n const parseAstAsync = await getParseAstAsync();\n\n if (!parseAstAsync) {\n return null;\n }\n\n return await annotateWithOxcParser(\n code,\n idWithoutQueryAndHash,\n ignoredComponents,\n parseAstAsync,\n injectIntoHtml,\n meta,\n );\n } catch {\n // Leave files the parser cannot read unchanged. The bundler reports the syntax error.\n return null;\n }\n },\n };\n}\n"],"names":["path"],"mappings":";;;;;;;AAqBA,IAAI,uBAAA;AAEG,SAAS,mBAAA,GAAqD;AACnE,EAAA,IAAI,CAAC,uBAAA,EAAyB;AAC5B,IAAA,uBAAA,GAA0B,OAAO,YAAY,CAAA,CAC1C,KAAK,CAAC,EAAE,OAAM,KAAqB;AAClC,MAAA,OAAO,OAAO,IAAA,EAAM,EAAE,IAAA,EAAK,KAAM;AAG/B,QAAA,MAAM,EAAE,OAAA,EAAS,MAAA,EAAO,GAAI,MAAM,KAAA,CAAM,CAAA,UAAA,EAAa,IAAI,CAAA,CAAA,EAAI,IAAA,EAAM,EAAE,IAAA,EAAM,cAAA,EAAgB,OAAO,CAAA;AAElG,QAAA,IAAI,MAAA,CAAO,SAAS,CAAA,EAAG;AACrB,UAAA,MAAM,IAAI,KAAA,CAAM,MAAA,CAAO,CAAC,GAAG,OAAO,CAAA;AAAA,QACpC;AAEA,QAAA,OAAO,OAAA;AAAA,MACT,CAAA;AAAA,IACF,CAAC,CAAA,CACA,KAAA,CAAM,MAAM,IAAI,CAAA;AAAA,EACrB;AAEA,EAAA,OAAO,uBAAA;AACT;AAGA,MAAM,oBAAA,GAAuB,0DAAA;AAC7B,MAAM,eAAA,GAAkB,WAAA;AAExB,SAAS,iBAAiB,qBAAA,EAAwC;AAChE,EAA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,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,YAAY,QAAA,EAAS;AAAA;AAAA;AAAA,IAG3B,GAAA,EAAK,YAAY,WAAA,GAAc;AAAA,MAC7B,MAAA,EAAQ,qBAAA;AAAA,MACR,cAAA,EAAgB,IAAA;AAAA,MAChB,KAAA,EAAO;AAAA,KACR;AAAA,GACH;AACF;AAEO,SAAS,mCAAA,CACd,iBAAA,EACA,gBAAA,EACA,cAAA,GAAiB,KAAA,EAOjB;AACA,EAAA,OAAO;AAAA,IACL,MAAM,SAAA,CAAU,IAAA,EAAM,EAAA,EAAI,IAAA,EAAM;AAC9B,MAAA,MAAM,qBAAA,GAAwB,0BAA0B,EAAE,CAAA;AAE1D,MAAA,IACE,CAAC,qBAAA,IACD,CAAC,gBAAA,CAAiB,qBAAqB,CAAA,IACvC,CAAC,cAAA,CAAe,IAAI,CAAA,IACpB,0BAAA,CAA2B,qBAAqB,CAAA,EAChD;AACA,QAAA,OAAO,IAAA;AAAA,MACT;AAEA,MAAA,IAAI;AACF,QAAA,MAAM,aAAA,GAAgB,MAAM,gBAAA,EAAiB;AAE7C,QAAA,IAAI,CAAC,aAAA,EAAe;AAClB,UAAA,OAAO,IAAA;AAAA,QACT;AAEA,QAAA,OAAO,MAAM,qBAAA;AAAA,UACX,IAAA;AAAA,UACA,qBAAA;AAAA,UACA,iBAAA;AAAA,UACA,aAAA;AAAA,UACA,cAAA;AAAA,UACA;AAAA,SACF;AAAA,MACF,CAAA,CAAA,MAAQ;AAEN,QAAA,OAAO,IAAA;AAAA,MACT;AAAA,IACF;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"component-annotation-oxc.js","names":[],"sources":["../../../src/core/component-annotation-oxc.ts"],"sourcesContent":["import path from 'node:path';\n\nimport MagicString from 'magic-string';\n\nimport { KNOWN_INCOMPATIBLE_PLUGINS } from '../babel-plugin/constants';\nimport { stripQueryAndHashFromPath } from './utils';\nimport { isAstNode } from './component-annotation-oxc-ast';\nimport { collectOxcComponentAnnotationInsertions } from './component-annotation-oxc-walk';\nimport type {\n AttributeInsertion,\n ComponentAnnotationTransformMeta,\n ComponentAnnotationTransformResult,\n MagicStringLike,\n ParseAstAsync,\n} from './component-annotation-oxc-ast';\n\nexport type {\n ComponentAnnotationTransformMeta,\n ComponentAnnotationTransformResult,\n} from './component-annotation-oxc-ast';\n\nlet oxcParseAstAsyncPromise: Promise<ParseAstAsync | null> | undefined;\n\nexport function getOxcParseAstAsync(): Promise<ParseAstAsync | null> {\n if (!oxcParseAstAsyncPromise) {\n oxcParseAstAsyncPromise = import('oxc-parser')\n .then(({ parse }): ParseAstAsync => {\n return async (code, { lang }) => {\n // preserveParens: false matches the AST Vite 8 produces. The walker\n // does not look through ParenthesizedExpression nodes.\n const { program, errors } = await parse(`component.${lang}`, code, { lang, preserveParens: false });\n\n if (errors.length > 0) {\n throw new Error(errors[0]?.message);\n }\n\n return program;\n };\n })\n .catch(() => null);\n }\n\n return oxcParseAstAsyncPromise;\n}\n\n// Keep this as a superset of all JSX tag starts, because a miss skips the file.\nconst JSX_TAG_START_REGEXP = /<[$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}.:-]*|<>/u;\nconst JSX_FILE_REGEXP = /\\.[jt]sx$/;\n\nfunction isAnnotationFile(idWithoutQueryAndHash: string): boolean {\n if (idWithoutQueryAndHash.match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n return false;\n }\n\n return JSX_FILE_REGEXP.test(idWithoutQueryAndHash);\n}\n\nfunction shouldTryParse(code: string): boolean {\n return JSX_TAG_START_REGEXP.test(code);\n}\n\nfunction shouldSkipIncompatibleFile(idWithoutQueryAndHash: string): boolean {\n return KNOWN_INCOMPATIBLE_PLUGINS.some(pluginName => {\n return (\n idWithoutQueryAndHash.includes(`/node_modules/${pluginName}/`) ||\n idWithoutQueryAndHash.includes(`\\\\node_modules\\\\${pluginName}\\\\`)\n );\n });\n}\n\nfunction escapeAttributeValue(value: string): string {\n return value.replace(/&/g, '&amp;').replace(/\"/g, '&quot;');\n}\n\nfunction makeAttributeText(\n code: string,\n insertionOffset: number,\n attributes: AttributeInsertion['attributes'],\n): string {\n const previousCharIsWhitespace = insertionOffset > 0 && /\\s/.test(code[insertionOffset - 1] ?? '');\n const prefix = previousCharIsWhitespace ? '' : ' ';\n const suffix = previousCharIsWhitespace && code[insertionOffset] === '/' ? ' ' : '';\n const attributeText = attributes.map(([name, value]) => `${name}=\"${escapeAttributeValue(value)}\"`).join(' ');\n\n return `${prefix}${attributeText}${suffix}`;\n}\n\nfunction getMagicString(\n code: string,\n meta?: ComponentAnnotationTransformMeta,\n): { magicString: MagicStringLike; isNative: boolean } {\n if (meta?.magicString) {\n return { magicString: meta.magicString, isNative: true };\n }\n\n return { magicString: new MagicString(code), isNative: false };\n}\n\nasync function annotateWithOxcParser(\n code: string,\n idWithoutQueryAndHash: string,\n ignoredComponents: string[],\n parseAstAsync: ParseAstAsync,\n injectIntoHtml: boolean,\n meta?: ComponentAnnotationTransformMeta,\n): Promise<ComponentAnnotationTransformResult> {\n const ast = await parseAstAsync(code, {\n lang: idWithoutQueryAndHash.endsWith('.jsx') ? 'jsx' : 'tsx',\n });\n\n if (!isAstNode(ast)) {\n return null;\n }\n\n const insertions = collectOxcComponentAnnotationInsertions(\n code,\n ast,\n ignoredComponents,\n path.basename(idWithoutQueryAndHash),\n injectIntoHtml,\n );\n\n if (insertions.length === 0) {\n return null;\n }\n\n const { magicString, isNative } = getMagicString(code, meta);\n\n for (const insertion of insertions) {\n magicString.appendLeft(insertion.offset, makeAttributeText(code, insertion.offset, insertion.attributes));\n }\n\n if (isNative) {\n return { code: magicString as unknown as string };\n }\n\n return {\n code: magicString.toString(),\n // No `file`, because magic-string would then make `source` relative to it\n // and drop the directory from `sources`.\n map: magicString.generateMap?.({\n source: idWithoutQueryAndHash,\n includeContent: true,\n hires: true,\n }),\n };\n}\n\nexport function createOxcComponentNameAnnotateHooks(\n ignoredComponents: string[],\n getParseAstAsync: () => Promise<ParseAstAsync | null>,\n injectIntoHtml = false,\n): {\n transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<ComponentAnnotationTransformResult>;\n} {\n return {\n async transform(code, id, meta) {\n const idWithoutQueryAndHash = stripQueryAndHashFromPath(id);\n\n if (\n !idWithoutQueryAndHash ||\n !isAnnotationFile(idWithoutQueryAndHash) ||\n !shouldTryParse(code) ||\n shouldSkipIncompatibleFile(idWithoutQueryAndHash)\n ) {\n return null;\n }\n\n try {\n const parseAstAsync = await getParseAstAsync();\n\n if (!parseAstAsync) {\n return null;\n }\n\n return await annotateWithOxcParser(\n code,\n idWithoutQueryAndHash,\n ignoredComponents,\n parseAstAsync,\n injectIntoHtml,\n meta,\n );\n } catch {\n // Leave files the parser cannot read unchanged. The bundler reports the syntax error.\n return null;\n }\n },\n };\n}\n"],"mappings":";;;;;;;AAqBA,IAAI;AAEJ,SAAgB,sBAAqD;CACnE,IAAI,CAAC,yBACH,0BAA0B,OAAO,aAAa,CAC3C,MAAM,EAAE,YAA2B;EAClC,OAAO,OAAO,MAAM,EAAE,WAAW;GAG/B,MAAM,EAAE,SAAS,WAAW,MAAM,MAAM,aAAa,QAAQ,MAAM;IAAE;IAAM,gBAAgB;GAAM,CAAC;GAElG,IAAI,OAAO,SAAS,GAClB,MAAM,IAAI,MAAM,OAAO,EAAE,EAAE,OAAO;GAGpC,OAAO;EACT;CACF,CAAC,CAAC,CACD,YAAY,IAAI;CAGrB,OAAO;AACT;AAGA,MAAM,uBAAuB;AAC7B,MAAM,kBAAkB;AAExB,SAAS,iBAAiB,uBAAwC;CAChE,IAAI,sBAAsB,MAAM,mCAAmC,GACjE,OAAO;CAGT,OAAO,gBAAgB,KAAK,qBAAqB;AACnD;AAEA,SAAS,eAAe,MAAuB;CAC7C,OAAO,qBAAqB,KAAK,IAAI;AACvC;AAEA,SAAS,2BAA2B,uBAAwC;CAC1E,OAAO,2BAA2B,MAAK,eAAc;EACnD,OACE,sBAAsB,SAAS,iBAAi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