@sentry/bundler-plugins 11.11.0 → 11.13.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 (188) 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 -683
  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 +52 -0
  53. package/build/cjs/core/upload-filter.js.map +1 -0
  54. package/build/cjs/core/utils.js +228 -219
  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 +180 -210
  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 +195 -209
  66. package/build/cjs/rollup/index.js.map +1 -1
  67. package/build/cjs/rollup/source-map-handling.js +178 -0
  68. package/build/cjs/rollup/source-map-handling.js.map +1 -0
  69. package/build/cjs/vite/index.js +19 -35
  70. package/build/cjs/vite/index.js.map +1 -1
  71. package/build/cjs/vite/source-map-hooks.js +116 -0
  72. package/build/cjs/vite/source-map-hooks.js.map +1 -0
  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 +277 -234
  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 -664
  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 +50 -0
  129. package/build/esm/core/upload-filter.js.map +1 -0
  130. package/build/esm/core/utils.js +221 -209
  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 +176 -194
  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 +191 -189
  143. package/build/esm/rollup/index.js.map +1 -1
  144. package/build/esm/rollup/source-map-handling.js +173 -0
  145. package/build/esm/rollup/source-map-handling.js.map +1 -0
  146. package/build/esm/vite/index.js +19 -32
  147. package/build/esm/vite/index.js.map +1 -1
  148. package/build/esm/vite/source-map-hooks.js +114 -0
  149. package/build/esm/vite/source-map-hooks.js.map +1 -0
  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 +274 -216
  153. package/build/esm/webpack/index.js.map +1 -1
  154. package/build/types/core/build-plugin-manager.d.ts +33 -10
  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 +4 -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 +32 -1
  168. package/build/types/core/types.d.ts.map +1 -1
  169. package/build/types/core/upload-filter.d.ts +9 -0
  170. package/build/types/core/upload-filter.d.ts.map +1 -0
  171. package/build/types/core/utils.d.ts +4 -0
  172. package/build/types/core/utils.d.ts.map +1 -1
  173. package/build/types/core/version.d.ts +1 -1
  174. package/build/types/esbuild/index.d.ts +2 -2
  175. package/build/types/esbuild/index.d.ts.map +1 -1
  176. package/build/types/rollup/index.d.ts +107 -7
  177. package/build/types/rollup/index.d.ts.map +1 -1
  178. package/build/types/rollup/source-map-handling.d.ts +59 -0
  179. package/build/types/rollup/source-map-handling.d.ts.map +1 -0
  180. package/build/types/vite/index.d.ts +4 -8
  181. package/build/types/vite/index.d.ts.map +1 -1
  182. package/build/types/vite/source-map-hooks.d.ts +45 -0
  183. package/build/types/vite/source-map-hooks.d.ts.map +1 -0
  184. package/build/types/webpack/index.d.ts +7 -3
  185. package/build/types/webpack/index.d.ts.map +1 -1
  186. package/package.json +33 -38
  187. package/build/cjs/loader-utils/index.js.map +0 -1
  188. package/build/esm/loader-utils/index.js.map +0 -1
@@ -1,30 +1,21 @@
1
- import { createOxcComponentNameAnnotateHooks, getOxcParseAstAsync } from './component-annotation-oxc.js';
2
-
1
+ import { createOxcComponentNameAnnotateHooks, getOxcParseAstAsync } from "./component-annotation-oxc.js";
2
+ // src/core/component-annotate-hooks.ts
3
3
  const PARSER_UNAVAILABLE_MESSAGE = "Could not load `oxc-parser` for this platform. React components will not be annotated.";
4
4
  let warnedParserUnavailable = false;
5
5
  function createComponentNameAnnotateHooks(ignoredComponents, injectIntoHtml, options = {}) {
6
- const hooks = createOxcComponentNameAnnotateHooks(
7
- ignoredComponents,
8
- async () => {
9
- const parseAstAsync = await options.getParseAstAsync?.() ?? await getOxcParseAstAsync();
10
- if (!parseAstAsync && !warnedParserUnavailable) {
11
- warnedParserUnavailable = true;
12
- if (options.logger) {
13
- options.logger.warn(PARSER_UNAVAILABLE_MESSAGE);
14
- } else {
15
- console.warn(`[@sentry/bundler-plugins] ${PARSER_UNAVAILABLE_MESSAGE}`);
16
- }
17
- }
18
- return parseAstAsync;
19
- },
20
- injectIntoHtml
21
- );
22
- return {
23
- transform(code, id, meta) {
24
- return hooks.transform(code, id, meta);
25
- }
26
- };
6
+ const hooks = createOxcComponentNameAnnotateHooks(ignoredComponents, async () => {
7
+ const parseAstAsync = await options.getParseAstAsync?.() ?? await getOxcParseAstAsync();
8
+ if (!parseAstAsync && !warnedParserUnavailable) {
9
+ warnedParserUnavailable = true;
10
+ if (options.logger) options.logger.warn(PARSER_UNAVAILABLE_MESSAGE);
11
+ else console.warn(`[@sentry/bundler-plugins] ${PARSER_UNAVAILABLE_MESSAGE}`);
12
+ }
13
+ return parseAstAsync;
14
+ }, injectIntoHtml);
15
+ return { transform(code, id, meta) {
16
+ return hooks.transform(code, id, meta);
17
+ } };
27
18
  }
28
-
29
19
  export { createComponentNameAnnotateHooks };
30
- //# sourceMappingURL=component-annotate-hooks.js.map
20
+
21
+ //# sourceMappingURL=component-annotate-hooks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component-annotate-hooks.js","sources":["../../../src/core/component-annotate-hooks.ts"],"sourcesContent":["import { createOxcComponentNameAnnotateHooks, getOxcParseAstAsync } from './component-annotation-oxc';\nimport type { ComponentAnnotationTransformMeta, ParseAstAsync } from './component-annotation-oxc-ast';\nimport type { Logger } from './logger';\n\nconst PARSER_UNAVAILABLE_MESSAGE =\n 'Could not load `oxc-parser` for this platform. React components will not be annotated.';\n\n// Module level, because the Turbopack loader creates new hooks for\n// every file.\nlet warnedParserUnavailable = false;\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function createComponentNameAnnotateHooks(\n ignoredComponents: string[],\n injectIntoHtml: boolean,\n options: { getParseAstAsync?: () => Promise<ParseAstAsync | null>; logger?: Logger } = {},\n) {\n const hooks = createOxcComponentNameAnnotateHooks(\n ignoredComponents,\n async () => {\n const parseAstAsync = (await options.getParseAstAsync?.()) ?? (await getOxcParseAstAsync());\n\n if (!parseAstAsync && !warnedParserUnavailable) {\n warnedParserUnavailable = true;\n if (options.logger) {\n options.logger.warn(PARSER_UNAVAILABLE_MESSAGE);\n } else {\n // eslint-disable-next-line no-console\n console.warn(`[@sentry/bundler-plugins] ${PARSER_UNAVAILABLE_MESSAGE}`);\n }\n }\n\n return parseAstAsync;\n },\n injectIntoHtml,\n );\n\n return {\n transform(this: void, code: string, id: string, meta?: ComponentAnnotationTransformMeta) {\n return hooks.transform(code, id, meta);\n },\n };\n}\n"],"names":[],"mappings":";;AAIA,MAAM,0BAAA,GACJ,wFAAA;AAIF,IAAI,uBAAA,GAA0B,KAAA;AAGvB,SAAS,gCAAA,CACd,iBAAA,EACA,cAAA,EACA,OAAA,GAAuF,EAAC,EACxF;AACA,EAAA,MAAM,KAAA,GAAQ,mCAAA;AAAA,IACZ,iBAAA;AAAA,IACA,YAAY;AACV,MAAA,MAAM,gBAAiB,MAAM,OAAA,CAAQ,gBAAA,IAAmB,IAAO,MAAM,mBAAA,EAAoB;AAEzF,MAAA,IAAI,CAAC,aAAA,IAAiB,CAAC,uBAAA,EAAyB;AAC9C,QAAA,uBAAA,GAA0B,IAAA;AAC1B,QAAA,IAAI,QAAQ,MAAA,EAAQ;AAClB,UAAA,OAAA,CAAQ,MAAA,CAAO,KAAK,0BAA0B,CAAA;AAAA,QAChD,CAAA,MAAO;AAEL,UAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,0BAAA,EAA6B,0BAA0B,CAAA,CAAE,CAAA;AAAA,QACxE;AAAA,MACF;AAEA,MAAA,OAAO,aAAA;AAAA,IACT,CAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,OAAO;AAAA,IACL,SAAA,CAAsB,IAAA,EAAc,EAAA,EAAY,IAAA,EAAyC;AACvF,MAAA,OAAO,KAAA,CAAM,SAAA,CAAU,IAAA,EAAM,EAAA,EAAI,IAAI,CAAA;AAAA,IACvC;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"component-annotate-hooks.js","names":[],"sources":["../../../src/core/component-annotate-hooks.ts"],"sourcesContent":["import { createOxcComponentNameAnnotateHooks, getOxcParseAstAsync } from './component-annotation-oxc';\nimport type { ComponentAnnotationTransformMeta, ParseAstAsync } from './component-annotation-oxc-ast';\nimport type { Logger } from './logger';\n\nconst PARSER_UNAVAILABLE_MESSAGE =\n 'Could not load `oxc-parser` for this platform. React components will not be annotated.';\n\n// Module level, because the Turbopack loader creates new hooks for\n// every file.\nlet warnedParserUnavailable = false;\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function createComponentNameAnnotateHooks(\n ignoredComponents: string[],\n injectIntoHtml: boolean,\n options: { getParseAstAsync?: () => Promise<ParseAstAsync | null>; logger?: Logger } = {},\n) {\n const hooks = createOxcComponentNameAnnotateHooks(\n ignoredComponents,\n async () => {\n const parseAstAsync = (await options.getParseAstAsync?.()) ?? (await getOxcParseAstAsync());\n\n if (!parseAstAsync && !warnedParserUnavailable) {\n warnedParserUnavailable = true;\n if (options.logger) {\n options.logger.warn(PARSER_UNAVAILABLE_MESSAGE);\n } else {\n // eslint-disable-next-line no-console\n console.warn(`[@sentry/bundler-plugins] ${PARSER_UNAVAILABLE_MESSAGE}`);\n }\n }\n\n return parseAstAsync;\n },\n injectIntoHtml,\n );\n\n return {\n transform(this: void, code: string, id: string, meta?: ComponentAnnotationTransformMeta) {\n return hooks.transform(code, id, meta);\n },\n };\n}\n"],"mappings":";;AAIA,MAAM,6BACJ;AAIF,IAAI,0BAA0B;AAG9B,SAAgB,iCACd,mBACA,gBACA,UAAuF,CAAC,GACxF;CACA,MAAM,QAAQ,oCACZ,mBACA,YAAY;EACV,MAAM,gBAAiB,MAAM,QAAQ,mBAAmB,KAAO,MAAM,oBAAoB;EAEzF,IAAI,CAAC,iBAAiB,CAAC,yBAAyB;GAC9C,0BAA0B;GAC1B,IAAI,QAAQ,QACV,QAAQ,OAAO,KAAK,0BAA0B;QAG9C,QAAQ,KAAK,6BAA6B,4BAA4B;EAE1E;EAEA,OAAO;CACT,GACA,cACF;CAEA,OAAO,EACL,UAAsB,MAAc,IAAY,MAAyC;EACvF,OAAO,MAAM,UAAU,MAAM,IAAI,IAAI;CACvC,EACF;AACF"}
@@ -1,24 +1,14 @@
1
- import { isObjectLike } from '@sentry/core';
2
- export { isObjectLike } from '@sentry/core';
3
-
1
+ import { isObjectLike } from "@sentry/core";
2
+ // src/core/component-annotation-oxc-ast.ts
4
3
  function isAstNode(value) {
5
- return isObjectLike(value) && typeof value.type === "string";
4
+ return isObjectLike(value) && typeof value.type === "string";
6
5
  }
7
6
  function walkAst(node, visit) {
8
- if (!isAstNode(node)) {
9
- return;
10
- }
11
- visit(node);
12
- for (const value of Object.values(node)) {
13
- if (Array.isArray(value)) {
14
- for (const child of value) {
15
- walkAst(child, visit);
16
- }
17
- } else if (isAstNode(value)) {
18
- walkAst(value, visit);
19
- }
20
- }
7
+ if (!isAstNode(node)) return;
8
+ visit(node);
9
+ for (const value of Object.values(node)) if (Array.isArray(value)) for (const child of value) walkAst(child, visit);
10
+ else if (isAstNode(value)) walkAst(value, visit);
21
11
  }
12
+ export { isAstNode, isObjectLike, walkAst };
22
13
 
23
- export { isAstNode, walkAst };
24
- //# sourceMappingURL=component-annotation-oxc-ast.js.map
14
+ //# sourceMappingURL=component-annotation-oxc-ast.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component-annotation-oxc-ast.js","sources":["../../../src/core/component-annotation-oxc-ast.ts"],"sourcesContent":["import { isObjectLike } from '@sentry/core';\nimport type { SourceMap } from 'magic-string';\n\nimport type { ComponentAnnotationAttribute } from '../babel-plugin/component-annotation';\n\nexport { isObjectLike };\n\nexport type AstNode = {\n type: string;\n start?: number;\n end?: number;\n [key: string]: unknown;\n};\n\nexport type JSXElementNode = AstNode & {\n type: 'JSXElement';\n openingElement: JSXOpeningElementNode;\n children?: AstNode[];\n};\n\nexport type JSXFragmentNode = AstNode & {\n type: 'JSXFragment';\n children?: AstNode[];\n};\n\nexport type JSXRootNode = JSXElementNode | JSXFragmentNode;\n\nexport type JSXOpeningElementNode = AstNode & {\n type: 'JSXOpeningElement';\n name: AstNode;\n attributes?: AstNode[];\n selfClosing?: boolean;\n};\n\nexport type FragmentContext = {\n fragmentAliases: Set<string>;\n reactNamespaceAliases: Set<string>;\n};\n\nexport type AttributeInsertion = {\n offset: number;\n attributes: ComponentAnnotationAttribute[];\n};\n\nexport type ParseAstAsync = (code: string, options: { lang: 'jsx' | 'tsx' }) => Promise<unknown>;\n\nexport type MagicStringLike = {\n appendLeft(offset: number, content: string): void;\n toString(): string;\n generateMap?(options: {\n file?: string;\n source?: string;\n includeContent?: boolean;\n hires?: boolean | 'boundary';\n }): SourceMap | string;\n};\n\nexport type ComponentAnnotationTransformMeta = {\n magicString?: MagicStringLike;\n};\n\nexport type ComponentAnnotationTransformResult = {\n code: string;\n map?: SourceMap | string;\n} | null;\n\nexport function isAstNode(value: unknown): value is AstNode {\n return isObjectLike(value) && typeof value.type === 'string';\n}\n\nexport function walkAst(node: unknown, visit: (node: AstNode) => void): void {\n if (!isAstNode(node)) {\n return;\n }\n\n visit(node);\n\n for (const value of Object.values(node)) {\n if (Array.isArray(value)) {\n for (const child of value) {\n walkAst(child, visit);\n }\n } else if (isAstNode(value)) {\n walkAst(value, visit);\n }\n }\n}\n"],"names":[],"mappings":";;;AAkEO,SAAS,UAAU,KAAA,EAAkC;AAC1D,EAAA,OAAO,YAAA,CAAa,KAAK,CAAA,IAAK,OAAO,MAAM,IAAA,KAAS,QAAA;AACtD;AAEO,SAAS,OAAA,CAAQ,MAAe,KAAA,EAAsC;AAC3E,EAAA,IAAI,CAAC,SAAA,CAAU,IAAI,CAAA,EAAG;AACpB,IAAA;AAAA,EACF;AAEA,EAAA,KAAA,CAAM,IAAI,CAAA;AAEV,EAAA,KAAA,MAAW,KAAA,IAAS,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA,EAAG;AACvC,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,MAAA,KAAA,MAAW,SAAS,KAAA,EAAO;AACzB,QAAA,OAAA,CAAQ,OAAO,KAAK,CAAA;AAAA,MACtB;AAAA,IACF,CAAA,MAAA,IAAW,SAAA,CAAU,KAAK,CAAA,EAAG;AAC3B,MAAA,OAAA,CAAQ,OAAO,KAAK,CAAA;AAAA,IACtB;AAAA,EACF;AACF;;;;"}
1
+ {"version":3,"file":"component-annotation-oxc-ast.js","names":[],"sources":["../../../src/core/component-annotation-oxc-ast.ts"],"sourcesContent":["import { isObjectLike } from '@sentry/core';\nimport type { SourceMap } from 'magic-string';\n\nimport type { ComponentAnnotationAttribute } from '../babel-plugin/component-annotation';\n\nexport { isObjectLike };\n\nexport type AstNode = {\n type: string;\n start?: number;\n end?: number;\n [key: string]: unknown;\n};\n\nexport type JSXElementNode = AstNode & {\n type: 'JSXElement';\n openingElement: JSXOpeningElementNode;\n children?: AstNode[];\n};\n\nexport type JSXFragmentNode = AstNode & {\n type: 'JSXFragment';\n children?: AstNode[];\n};\n\nexport type JSXRootNode = JSXElementNode | JSXFragmentNode;\n\nexport type JSXOpeningElementNode = AstNode & {\n type: 'JSXOpeningElement';\n name: AstNode;\n attributes?: AstNode[];\n selfClosing?: boolean;\n};\n\nexport type FragmentContext = {\n fragmentAliases: Set<string>;\n reactNamespaceAliases: Set<string>;\n};\n\nexport type AttributeInsertion = {\n offset: number;\n attributes: ComponentAnnotationAttribute[];\n};\n\nexport type ParseAstAsync = (code: string, options: { lang: 'jsx' | 'tsx' }) => Promise<unknown>;\n\nexport type MagicStringLike = {\n appendLeft(offset: number, content: string): void;\n toString(): string;\n generateMap?(options: {\n file?: string;\n source?: string;\n includeContent?: boolean;\n hires?: boolean | 'boundary';\n }): SourceMap | string;\n};\n\nexport type ComponentAnnotationTransformMeta = {\n magicString?: MagicStringLike;\n};\n\nexport type ComponentAnnotationTransformResult = {\n code: string;\n map?: SourceMap | string;\n} | null;\n\nexport function isAstNode(value: unknown): value is AstNode {\n return isObjectLike(value) && typeof value.type === 'string';\n}\n\nexport function walkAst(node: unknown, visit: (node: AstNode) => void): void {\n if (!isAstNode(node)) {\n return;\n }\n\n visit(node);\n\n for (const value of Object.values(node)) {\n if (Array.isArray(value)) {\n for (const child of value) {\n walkAst(child, visit);\n }\n } else if (isAstNode(value)) {\n walkAst(value, visit);\n }\n }\n}\n"],"mappings":";;AAkEA,SAAgB,UAAU,OAAkC;CAC1D,OAAO,aAAa,KAAK,KAAK,OAAO,MAAM,SAAS;AACtD;AAEA,SAAgB,QAAQ,MAAe,OAAsC;CAC3E,IAAI,CAAC,UAAU,IAAI,GACjB;CAGF,MAAM,IAAI;CAEV,KAAK,MAAM,SAAS,OAAO,OAAO,IAAI,GACpC,IAAI,MAAM,QAAQ,KAAK,GACrB,KAAK,MAAM,SAAS,OAClB,QAAQ,OAAO,KAAK;MAEjB,IAAI,UAAU,KAAK,GACxB,QAAQ,OAAO,KAAK;AAG1B"}
@@ -1,89 +1,61 @@
1
- import { walkAst, isAstNode } from './component-annotation-oxc-ast.js';
2
- import { getStringName } from './component-annotation-oxc-jsx.js';
3
- import { isObjectLike } from '@sentry/core';
4
-
1
+ import { isAstNode, isObjectLike, walkAst } from "./component-annotation-oxc-ast.js";
2
+ import { getStringName } from "./component-annotation-oxc-jsx.js";
3
+ // src/core/component-annotation-oxc-fragments.ts
5
4
  function collectFragmentContext(ast) {
6
- const context = {
7
- fragmentAliases: /* @__PURE__ */ new Set(),
8
- reactNamespaceAliases: /* @__PURE__ */ new Set(["React"])
9
- };
10
- walkAst(ast, (node) => {
11
- collectFragmentAliasesFromImport(node, context);
12
- collectFragmentAliasesFromVariableDeclarator(node, context);
13
- });
14
- return context;
5
+ const context = {
6
+ fragmentAliases: /* @__PURE__ */ new Set(),
7
+ reactNamespaceAliases: /* @__PURE__ */ new Set(["React"])
8
+ };
9
+ walkAst(ast, (node) => {
10
+ collectFragmentAliasesFromImport(node, context);
11
+ collectFragmentAliasesFromVariableDeclarator(node, context);
12
+ });
13
+ return context;
15
14
  }
16
15
  function collectFragmentAliasesFromImport(node, context) {
17
- if (node.type !== "ImportDeclaration" || !isObjectLike(node.source)) {
18
- return;
19
- }
20
- const source = node.source.value;
21
- if (source !== "react" && source !== "React") {
22
- return;
23
- }
24
- const specifiers = Array.isArray(node.specifiers) ? node.specifiers : [];
25
- for (const specifier of specifiers) {
26
- if (!isAstNode(specifier) || !isObjectLike(specifier.local)) {
27
- continue;
28
- }
29
- const localName = getStringName(specifier.local);
30
- if (!localName) {
31
- continue;
32
- }
33
- if (specifier.type === "ImportDefaultSpecifier" || specifier.type === "ImportNamespaceSpecifier") {
34
- context.reactNamespaceAliases.add(localName);
35
- } else if (isImportedReactFragment(specifier)) {
36
- context.fragmentAliases.add(localName);
37
- }
38
- }
16
+ if (node.type !== "ImportDeclaration" || !isObjectLike(node.source)) return;
17
+ const source = node.source.value;
18
+ if (source !== "react" && source !== "React") return;
19
+ const specifiers = Array.isArray(node.specifiers) ? node.specifiers : [];
20
+ for (const specifier of specifiers) {
21
+ if (!isAstNode(specifier) || !isObjectLike(specifier.local)) continue;
22
+ const localName = getStringName(specifier.local);
23
+ if (!localName) continue;
24
+ if (specifier.type === "ImportDefaultSpecifier" || specifier.type === "ImportNamespaceSpecifier") context.reactNamespaceAliases.add(localName);
25
+ else if (isImportedReactFragment(specifier)) context.fragmentAliases.add(localName);
26
+ }
39
27
  }
40
28
  function collectFragmentAliasesFromVariableDeclarator(node, context) {
41
- if (node.type !== "VariableDeclarator" || !isObjectLike(node.id) || !isObjectLike(node.init)) {
42
- return;
43
- }
44
- if (node.id.type === "Identifier") {
45
- collectFragmentAliasFromIdentifier(node.id, node.init, context);
46
- return;
47
- }
48
- if (node.id.type === "ObjectPattern") {
49
- collectFragmentAliasFromObjectPattern(node.id, node.init, context);
50
- }
29
+ if (node.type !== "VariableDeclarator" || !isObjectLike(node.id) || !isObjectLike(node.init)) return;
30
+ if (node.id.type === "Identifier") {
31
+ collectFragmentAliasFromIdentifier(node.id, node.init, context);
32
+ return;
33
+ }
34
+ if (node.id.type === "ObjectPattern") collectFragmentAliasFromObjectPattern(node.id, node.init, context);
51
35
  }
52
36
  function collectFragmentAliasFromIdentifier(id, init, context) {
53
- const localName = getStringName(id);
54
- if (!localName) {
55
- return;
56
- }
57
- if (init.type === "Identifier" && context.fragmentAliases.has(getStringName(init) ?? "")) {
58
- context.fragmentAliases.add(localName);
59
- }
60
- if (isReactFragmentMemberExpression(init, context)) {
61
- context.fragmentAliases.add(localName);
62
- }
37
+ const localName = getStringName(id);
38
+ if (!localName) return;
39
+ if (init.type === "Identifier" && context.fragmentAliases.has(getStringName(init) ?? "")) context.fragmentAliases.add(localName);
40
+ if (isReactFragmentMemberExpression(init, context)) context.fragmentAliases.add(localName);
63
41
  }
64
42
  function collectFragmentAliasFromObjectPattern(id, init, context) {
65
- if (init.type !== "Identifier" || !context.reactNamespaceAliases.has(getStringName(init) ?? "") || !Array.isArray(id.properties)) {
66
- return;
67
- }
68
- for (const property of id.properties) {
69
- if (!isFragmentObjectPatternProperty(property)) {
70
- continue;
71
- }
72
- const localName = getStringName(property.value);
73
- if (localName) {
74
- context.fragmentAliases.add(localName);
75
- }
76
- }
43
+ if (init.type !== "Identifier" || !context.reactNamespaceAliases.has(getStringName(init) ?? "") || !Array.isArray(id.properties)) return;
44
+ for (const property of id.properties) {
45
+ if (!isFragmentObjectPatternProperty(property)) continue;
46
+ const localName = getStringName(property.value);
47
+ if (localName) context.fragmentAliases.add(localName);
48
+ }
77
49
  }
78
50
  function isImportedReactFragment(specifier) {
79
- return specifier.type === "ImportSpecifier" && isObjectLike(specifier.imported) && getStringName(specifier.imported) === "Fragment";
51
+ return specifier.type === "ImportSpecifier" && isObjectLike(specifier.imported) && getStringName(specifier.imported) === "Fragment";
80
52
  }
81
53
  function isReactFragmentMemberExpression(init, context) {
82
- return init.type === "MemberExpression" && isObjectLike(init.object) && isObjectLike(init.property) && context.reactNamespaceAliases.has(getStringName(init.object) ?? "") && getStringName(init.property) === "Fragment";
54
+ return init.type === "MemberExpression" && isObjectLike(init.object) && isObjectLike(init.property) && context.reactNamespaceAliases.has(getStringName(init.object) ?? "") && getStringName(init.property) === "Fragment";
83
55
  }
84
56
  function isFragmentObjectPatternProperty(property) {
85
- return isObjectLike(property) && (property.type === "Property" || property.type === "ObjectProperty") && isObjectLike(property.key) && getStringName(property.key) === "Fragment" && isObjectLike(property.value);
57
+ return isObjectLike(property) && (property.type === "Property" || property.type === "ObjectProperty") && isObjectLike(property.key) && getStringName(property.key) === "Fragment" && isObjectLike(property.value);
86
58
  }
87
-
88
59
  export { collectFragmentContext };
89
- //# sourceMappingURL=component-annotation-oxc-fragments.js.map
60
+
61
+ //# sourceMappingURL=component-annotation-oxc-fragments.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component-annotation-oxc-fragments.js","sources":["../../../src/core/component-annotation-oxc-fragments.ts"],"sourcesContent":["import type { AstNode, FragmentContext } from './component-annotation-oxc-ast';\nimport { isAstNode, isObjectLike, walkAst } from './component-annotation-oxc-ast';\nimport { getStringName } from './component-annotation-oxc-jsx';\n\nexport function collectFragmentContext(ast: AstNode): FragmentContext {\n const context: FragmentContext = {\n fragmentAliases: new Set<string>(),\n reactNamespaceAliases: new Set<string>(['React']),\n };\n\n walkAst(ast, node => {\n collectFragmentAliasesFromImport(node, context);\n collectFragmentAliasesFromVariableDeclarator(node, context);\n });\n\n return context;\n}\n\nfunction collectFragmentAliasesFromImport(node: AstNode, context: FragmentContext): void {\n if (node.type !== 'ImportDeclaration' || !isObjectLike(node.source)) {\n return;\n }\n\n const source = node.source.value;\n if (source !== 'react' && source !== 'React') {\n return;\n }\n\n const specifiers = Array.isArray(node.specifiers) ? node.specifiers : [];\n\n for (const specifier of specifiers) {\n if (!isAstNode(specifier) || !isObjectLike(specifier.local)) {\n continue;\n }\n\n const localName = getStringName(specifier.local);\n if (!localName) {\n continue;\n }\n\n if (specifier.type === 'ImportDefaultSpecifier' || specifier.type === 'ImportNamespaceSpecifier') {\n context.reactNamespaceAliases.add(localName);\n } else if (isImportedReactFragment(specifier)) {\n context.fragmentAliases.add(localName);\n }\n }\n}\n\nfunction collectFragmentAliasesFromVariableDeclarator(node: AstNode, context: FragmentContext): void {\n if (node.type !== 'VariableDeclarator' || !isObjectLike(node.id) || !isObjectLike(node.init)) {\n return;\n }\n\n if (node.id.type === 'Identifier') {\n collectFragmentAliasFromIdentifier(node.id, node.init, context);\n return;\n }\n\n if (node.id.type === 'ObjectPattern') {\n collectFragmentAliasFromObjectPattern(node.id, node.init, context);\n }\n}\n\nfunction collectFragmentAliasFromIdentifier(\n id: Record<string, unknown>,\n init: Record<string, unknown>,\n context: FragmentContext,\n): void {\n const localName = getStringName(id);\n if (!localName) {\n return;\n }\n\n if (init.type === 'Identifier' && context.fragmentAliases.has(getStringName(init) ?? '')) {\n context.fragmentAliases.add(localName);\n }\n\n if (isReactFragmentMemberExpression(init, context)) {\n context.fragmentAliases.add(localName);\n }\n}\n\nfunction collectFragmentAliasFromObjectPattern(\n id: Record<string, unknown>,\n init: Record<string, unknown>,\n context: FragmentContext,\n): void {\n if (\n init.type !== 'Identifier' ||\n !context.reactNamespaceAliases.has(getStringName(init) ?? '') ||\n !Array.isArray(id.properties)\n ) {\n return;\n }\n\n for (const property of id.properties) {\n if (!isFragmentObjectPatternProperty(property)) {\n continue;\n }\n\n const localName = getStringName(property.value);\n if (localName) {\n context.fragmentAliases.add(localName);\n }\n }\n}\n\nfunction isImportedReactFragment(specifier: AstNode): boolean {\n return (\n specifier.type === 'ImportSpecifier' &&\n isObjectLike(specifier.imported) &&\n getStringName(specifier.imported) === 'Fragment'\n );\n}\n\nfunction isReactFragmentMemberExpression(init: Record<string, unknown>, context: FragmentContext): boolean {\n return (\n init.type === 'MemberExpression' &&\n isObjectLike(init.object) &&\n isObjectLike(init.property) &&\n context.reactNamespaceAliases.has(getStringName(init.object) ?? '') &&\n getStringName(init.property) === 'Fragment'\n );\n}\n\nfunction isFragmentObjectPatternProperty(property: unknown): property is { value: unknown } {\n return (\n isObjectLike(property) &&\n (property.type === 'Property' || property.type === 'ObjectProperty') &&\n isObjectLike(property.key) &&\n getStringName(property.key) === 'Fragment' &&\n isObjectLike(property.value)\n );\n}\n"],"names":[],"mappings":";;;;AAIO,SAAS,uBAAuB,GAAA,EAA+B;AACpE,EAAA,MAAM,OAAA,GAA2B;AAAA,IAC/B,eAAA,sBAAqB,GAAA,EAAY;AAAA,IACjC,qBAAA,kBAAuB,IAAI,GAAA,CAAY,CAAC,OAAO,CAAC;AAAA,GAClD;AAEA,EAAA,OAAA,CAAQ,KAAK,CAAA,IAAA,KAAQ;AACnB,IAAA,gCAAA,CAAiC,MAAM,OAAO,CAAA;AAC9C,IAAA,4CAAA,CAA6C,MAAM,OAAO,CAAA;AAAA,EAC5D,CAAC,CAAA;AAED,EAAA,OAAO,OAAA;AACT;AAEA,SAAS,gCAAA,CAAiC,MAAe,OAAA,EAAgC;AACvF,EAAA,IAAI,KAAK,IAAA,KAAS,mBAAA,IAAuB,CAAC,YAAA,CAAa,IAAA,CAAK,MAAM,CAAA,EAAG;AACnE,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,MAAA,GAAS,KAAK,MAAA,CAAO,KAAA;AAC3B,EAAA,IAAI,MAAA,KAAW,OAAA,IAAW,MAAA,KAAW,OAAA,EAAS;AAC5C,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,UAAA,GAAa,MAAM,OAAA,CAAQ,IAAA,CAAK,UAAU,CAAA,GAAI,IAAA,CAAK,aAAa,EAAC;AAEvE,EAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,IAAA,IAAI,CAAC,UAAU,SAAS,CAAA,IAAK,CAAC,YAAA,CAAa,SAAA,CAAU,KAAK,CAAA,EAAG;AAC3D,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,SAAA,GAAY,aAAA,CAAc,SAAA,CAAU,KAAK,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CAAA,IAClE,aAAA,CAAc,IAAA,CAAK,QAAQ,CAAA,KAAM,UAAA;AAErC;AAEA,SAAS,gCAAgC,QAAA,EAAmD;AAC1F,EAAA,OACE,YAAA,CAAa,QAAQ,CAAA,KACpB,QAAA,CAAS,SAAS,UAAA,IAAc,QAAA,CAAS,SAAS,gBAAA,CAAA,IACnD,YAAA,CAAa,SAAS,GAAG,CAAA,IACzB,cAAc,QAAA,CAAS,GAAG,MAAM,UAAA,IAChC,YAAA,CAAa,SAAS,KAAK,CAAA;AAE/B;;;;"}
1
+ {"version":3,"file":"component-annotation-oxc-fragments.js","names":[],"sources":["../../../src/core/component-annotation-oxc-fragments.ts"],"sourcesContent":["import type { AstNode, FragmentContext } from './component-annotation-oxc-ast';\nimport { isAstNode, isObjectLike, walkAst } from './component-annotation-oxc-ast';\nimport { getStringName } from './component-annotation-oxc-jsx';\n\nexport function collectFragmentContext(ast: AstNode): FragmentContext {\n const context: FragmentContext = {\n fragmentAliases: new Set<string>(),\n reactNamespaceAliases: new Set<string>(['React']),\n };\n\n walkAst(ast, node => {\n collectFragmentAliasesFromImport(node, context);\n collectFragmentAliasesFromVariableDeclarator(node, context);\n });\n\n return context;\n}\n\nfunction collectFragmentAliasesFromImport(node: AstNode, context: FragmentContext): void {\n if (node.type !== 'ImportDeclaration' || !isObjectLike(node.source)) {\n return;\n }\n\n const source = node.source.value;\n if (source !== 'react' && source !== 'React') {\n return;\n }\n\n const specifiers = Array.isArray(node.specifiers) ? node.specifiers : [];\n\n for (const specifier of specifiers) {\n if (!isAstNode(specifier) || !isObjectLike(specifier.local)) {\n continue;\n }\n\n const localName = getStringName(specifier.local);\n if (!localName) {\n continue;\n }\n\n if (specifier.type === 'ImportDefaultSpecifier' || specifier.type === 'ImportNamespaceSpecifier') {\n context.reactNamespaceAliases.add(localName);\n } else if (isImportedReactFragment(specifier)) {\n context.fragmentAliases.add(localName);\n }\n }\n}\n\nfunction collectFragmentAliasesFromVariableDeclarator(node: AstNode, context: FragmentContext): void {\n if (node.type !== 'VariableDeclarator' || !isObjectLike(node.id) || !isObjectLike(node.init)) {\n return;\n }\n\n if (node.id.type === 'Identifier') {\n collectFragmentAliasFromIdentifier(node.id, node.init, context);\n return;\n }\n\n if (node.id.type === 'ObjectPattern') {\n collectFragmentAliasFromObjectPattern(node.id, node.init, context);\n }\n}\n\nfunction collectFragmentAliasFromIdentifier(\n id: Record<string, unknown>,\n init: Record<string, unknown>,\n context: FragmentContext,\n): void {\n const localName = getStringName(id);\n if (!localName) {\n return;\n }\n\n if (init.type === 'Identifier' && context.fragmentAliases.has(getStringName(init) ?? '')) {\n context.fragmentAliases.add(localName);\n }\n\n if (isReactFragmentMemberExpression(init, context)) {\n context.fragmentAliases.add(localName);\n }\n}\n\nfunction collectFragmentAliasFromObjectPattern(\n id: Record<string, unknown>,\n init: Record<string, unknown>,\n context: FragmentContext,\n): void {\n if (\n init.type !== 'Identifier' ||\n !context.reactNamespaceAliases.has(getStringName(init) ?? '') ||\n !Array.isArray(id.properties)\n ) {\n return;\n }\n\n for (const property of id.properties) {\n if (!isFragmentObjectPatternProperty(property)) {\n continue;\n }\n\n const localName = getStringName(property.value);\n if (localName) {\n context.fragmentAliases.add(localName);\n }\n }\n}\n\nfunction isImportedReactFragment(specifier: AstNode): boolean {\n return (\n specifier.type === 'ImportSpecifier' &&\n isObjectLike(specifier.imported) &&\n getStringName(specifier.imported) === 'Fragment'\n );\n}\n\nfunction isReactFragmentMemberExpression(init: Record<string, unknown>, context: FragmentContext): boolean {\n return (\n init.type === 'MemberExpression' &&\n isObjectLike(init.object) &&\n isObjectLike(init.property) &&\n context.reactNamespaceAliases.has(getStringName(init.object) ?? '') &&\n getStringName(init.property) === 'Fragment'\n );\n}\n\nfunction isFragmentObjectPatternProperty(property: unknown): property is { value: unknown } {\n return (\n isObjectLike(property) &&\n (property.type === 'Property' || property.type === 'ObjectProperty') &&\n isObjectLike(property.key) &&\n getStringName(property.key) === 'Fragment' &&\n isObjectLike(property.value)\n );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I,cAAc,IAAI,KAAK,EAAE,GACrF,QAAQ,gBAAgB,IAAI,SAAS;CAGvC,IAAI,gCAAgC,MAAM,OAAO,GAC/C,QAAQ,gBAAgB,IAAI,SAAS;AAEzC;AAEA,SAAS,sCACP,IACA,MACA,SACM;CACN,IACE,KAAK,SAAS,gBACd,CAAC,QAAQ,sBAAsB,IAAI,cAAc,IAAI,KAAK,EAAE,KAC5D,CAAC,MAAM,QAAQ,GAAG,UAAU,GAE5B;CAGF,KAAK,MAAM,YAAY,GAAG,YAAY;EACpC,IAAI,CAAC,gCAAgC,QAAQ,GAC3C;EAGF,MAAM,YAAY,cAAc,SAAS,KAAK;EAC9C,IAAI,WACF,QAAQ,gBAAgB,IAAI,SAAS;CAEzC;AACF;AAEA,SAAS,wBAAwB,WAA6B;CAC5D,OACE,UAAU,SAAS,qBACnB,aAAa,UAAU,QAAQ,KAC/B,cAAc,UAAU,QAAQ,MAAM;AAE1C;AAEA,SAAS,gCAAgC,MAA+B,SAAmC;CACzG,OACE,KAAK,SAAS,sBACd,aAAa,KAAK,MAAM,KACxB,aAAa,KAAK,QAAQ,KAC1B,QAAQ,sBAAsB,IAAI,cAAc,KAAK,MAAM,KAAK,EAAE,KAClE,cAAc,KAAK,QAAQ,MAAM;AAErC;AAEA,SAAS,gCAAgC,UAAmD;CAC1F,OACE,aAAa,QAAQ,MACpB,SAAS,SAAS,cAAc,SAAS,SAAS,qBACnD,aAAa,SAAS,GAAG,KACzB,cAAc,SAAS,GAAG,MAAM,cAChC,aAAa,SAAS,KAAK;AAE/B"}
@@ -1,187 +1,148 @@
1
- import { WEB_ELEMENT_NAME, WEB_COMPONENT_NAME, WEB_SOURCE_FILE_NAME, getComponentAnnotationAttributes } from '../babel-plugin/component-annotation.js';
2
- import { isAstNode } from './component-annotation-oxc-ast.js';
3
- import { isObjectLike } from '@sentry/core';
4
-
1
+ import { WEB_COMPONENT_NAME, WEB_ELEMENT_NAME, WEB_SOURCE_FILE_NAME, getComponentAnnotationAttributes } from "../babel-plugin/component-annotation.js";
2
+ import { isAstNode, isObjectLike } from "./component-annotation-oxc-ast.js";
3
+ // src/core/component-annotation-oxc-jsx.ts
5
4
  const UNKNOWN_ELEMENT_NAME = "unknown";
6
5
  const REACT_NATIVE_ELEMENTS = /* @__PURE__ */ new Set([
7
- "Image",
8
- "Text",
9
- "View",
10
- "ScrollView",
11
- "TextInput",
12
- "TouchableOpacity",
13
- "TouchableHighlight",
14
- "TouchableWithoutFeedback",
15
- "FlatList",
16
- "SectionList",
17
- "ActivityIndicator",
18
- "Button",
19
- "Switch",
20
- "Modal",
21
- "SafeAreaView",
22
- "StatusBar",
23
- "KeyboardAvoidingView",
24
- "RefreshControl",
25
- "Picker",
26
- "Slider"
6
+ "Image",
7
+ "Text",
8
+ "View",
9
+ "ScrollView",
10
+ "TextInput",
11
+ "TouchableOpacity",
12
+ "TouchableHighlight",
13
+ "TouchableWithoutFeedback",
14
+ "FlatList",
15
+ "SectionList",
16
+ "ActivityIndicator",
17
+ "Button",
18
+ "Switch",
19
+ "Modal",
20
+ "SafeAreaView",
21
+ "StatusBar",
22
+ "KeyboardAvoidingView",
23
+ "RefreshControl",
24
+ "Picker",
25
+ "Slider"
27
26
  ]);
28
- const WEB_ATTRIBUTE_NAMES = [WEB_ELEMENT_NAME, WEB_COMPONENT_NAME, WEB_SOURCE_FILE_NAME];
27
+ const WEB_ATTRIBUTE_NAMES = [
28
+ WEB_ELEMENT_NAME,
29
+ WEB_COMPONENT_NAME,
30
+ WEB_SOURCE_FILE_NAME
31
+ ];
29
32
  const WEB_ATTRIBUTE_NAME_SET = new Set(WEB_ATTRIBUTE_NAMES);
30
33
  function isJSXElement(value) {
31
- return isAstNode(value) && value.type === "JSXElement";
34
+ return isAstNode(value) && value.type === "JSXElement";
32
35
  }
33
36
  function isJSXFragment(value) {
34
- return isAstNode(value) && value.type === "JSXFragment";
37
+ return isAstNode(value) && value.type === "JSXFragment";
35
38
  }
36
39
  function isJSXRoot(value) {
37
- return isJSXElement(value) || isJSXFragment(value);
40
+ return isJSXElement(value) || isJSXFragment(value);
38
41
  }
39
42
  function getStringName(node) {
40
- return isObjectLike(node) && typeof node.name === "string" ? node.name : null;
43
+ return isObjectLike(node) && typeof node.name === "string" ? node.name : null;
41
44
  }
42
45
  function getJSXName(name) {
43
- if (!isAstNode(name)) {
44
- return UNKNOWN_ELEMENT_NAME;
45
- }
46
- if (name.type === "JSXIdentifier") {
47
- return getStringName(name) ?? UNKNOWN_ELEMENT_NAME;
48
- }
49
- if (name.type === "JSXNamespacedName") {
50
- return getStringName(name.name) ?? UNKNOWN_ELEMENT_NAME;
51
- }
52
- if (name.type === "JSXMemberExpression") {
53
- const objectName = getJSXName(name.object);
54
- const propertyName = getJSXName(name.property);
55
- return `${objectName}.${propertyName}`;
56
- }
57
- return UNKNOWN_ELEMENT_NAME;
46
+ if (!isAstNode(name)) return UNKNOWN_ELEMENT_NAME;
47
+ if (name.type === "JSXIdentifier") return getStringName(name) ?? UNKNOWN_ELEMENT_NAME;
48
+ if (name.type === "JSXNamespacedName") return getStringName(name.name) ?? UNKNOWN_ELEMENT_NAME;
49
+ if (name.type === "JSXMemberExpression") return `${getJSXName(name.object)}.${getJSXName(name.property)}`;
50
+ return UNKNOWN_ELEMENT_NAME;
58
51
  }
59
52
  function getInsertionOffset(code, openingElement) {
60
- if (typeof openingElement.end !== "number") {
61
- return null;
62
- }
63
- if (!openingElement.selfClosing) {
64
- return openingElement.end - 1;
65
- }
66
- let offset = openingElement.end - 2;
67
- while (offset > 0 && /\s/.test(code[offset] ?? "")) {
68
- offset -= 1;
69
- }
70
- return code[offset] === "/" ? offset : openingElement.end - 1;
53
+ if (typeof openingElement.end !== "number") return null;
54
+ if (!openingElement.selfClosing) return openingElement.end - 1;
55
+ let offset = openingElement.end - 2;
56
+ while (offset > 0 && /\s/.test(code[offset] ?? "")) offset -= 1;
57
+ return code[offset] === "/" ? offset : openingElement.end - 1;
71
58
  }
72
59
  function isReactFragment(openingElement, fragmentContext) {
73
- const elementName = getJSXName(openingElement.name);
74
- if (elementName === "Fragment" || elementName === "React.Fragment") {
75
- return true;
76
- }
77
- if (fragmentContext.fragmentAliases.has(elementName)) {
78
- return true;
79
- }
80
- if (isObjectLike(openingElement.name) && openingElement.name.type === "JSXMemberExpression") {
81
- const objectName = getJSXName(openingElement.name.object);
82
- const propertyName = getJSXName(openingElement.name.property);
83
- return propertyName === "Fragment" && (fragmentContext.reactNamespaceAliases.has(objectName) || fragmentContext.fragmentAliases.has(objectName));
84
- }
85
- return false;
60
+ const elementName = getJSXName(openingElement.name);
61
+ if (elementName === "Fragment" || elementName === "React.Fragment") return true;
62
+ if (fragmentContext.fragmentAliases.has(elementName)) return true;
63
+ if (isObjectLike(openingElement.name) && openingElement.name.type === "JSXMemberExpression") {
64
+ const objectName = getJSXName(openingElement.name.object);
65
+ return getJSXName(openingElement.name.property) === "Fragment" && (fragmentContext.reactNamespaceAliases.has(objectName) || fragmentContext.fragmentAliases.has(objectName));
66
+ }
67
+ return false;
86
68
  }
87
69
  function addPendingAttributes(code, openingElement, componentName, ignoredComponents, fragmentContext, sourceFileName, insertionsByOffset) {
88
- const offset = getInsertionOffset(code, openingElement);
89
- if (offset === null) {
90
- return;
91
- }
92
- const pendingInsertion = insertionsByOffset.get(offset);
93
- const existingAttributes = getExistingAttributeNames(openingElement);
94
- for (const attributeName of pendingInsertion?.attributeValues.keys() ?? []) {
95
- existingAttributes.add(attributeName);
96
- }
97
- const attributes = getComponentAnnotationAttributes({
98
- attributeNames: [WEB_COMPONENT_NAME, WEB_ELEMENT_NAME, WEB_SOURCE_FILE_NAME],
99
- componentName,
100
- elementName: getJSXName(openingElement.name),
101
- existingAttributes,
102
- ignoredComponents,
103
- isFragment: isReactFragment(openingElement, fragmentContext),
104
- sourceFileName
105
- });
106
- if (attributes.length === 0) {
107
- return;
108
- }
109
- const insertion = getOrCreateInsertion(insertionsByOffset, offset);
110
- for (const [name, value] of attributes) {
111
- insertion.attributeValues.set(name, value);
112
- }
70
+ const offset = getInsertionOffset(code, openingElement);
71
+ if (offset === null) return;
72
+ const pendingInsertion = insertionsByOffset.get(offset);
73
+ const existingAttributes = getExistingAttributeNames(openingElement);
74
+ for (const attributeName of pendingInsertion?.attributeValues.keys() ?? []) existingAttributes.add(attributeName);
75
+ const attributes = getComponentAnnotationAttributes({
76
+ attributeNames: [
77
+ WEB_COMPONENT_NAME,
78
+ WEB_ELEMENT_NAME,
79
+ WEB_SOURCE_FILE_NAME
80
+ ],
81
+ componentName,
82
+ elementName: getJSXName(openingElement.name),
83
+ existingAttributes,
84
+ ignoredComponents,
85
+ isFragment: isReactFragment(openingElement, fragmentContext),
86
+ sourceFileName
87
+ });
88
+ if (attributes.length === 0) return;
89
+ const insertion = getOrCreateInsertion(insertionsByOffset, offset);
90
+ for (const [name, value] of attributes) insertion.attributeValues.set(name, value);
113
91
  }
92
+ /**
93
+ * Returns `true` when the element is an HTML element, because HTML mode only
94
+ * annotates the first HTML elements below a component root.
95
+ */
114
96
  function addPendingHtmlAttribute(code, openingElement, componentName, ignoredComponents, fragmentContext, insertionsByOffset) {
115
- if (isReactFragment(openingElement, fragmentContext)) {
116
- return false;
117
- }
118
- const elementName = getJSXName(openingElement.name);
119
- if (!isHtmlElement(elementName)) {
120
- return false;
121
- }
122
- if (ignoredComponents.includes(componentName) || ignoredComponents.includes(elementName)) {
123
- return true;
124
- }
125
- const offset = getInsertionOffset(code, openingElement);
126
- if (offset === null) {
127
- return true;
128
- }
129
- if (getExistingAttributeNames(openingElement).has(WEB_COMPONENT_NAME) || insertionsByOffset.get(offset)?.attributeValues.has(WEB_COMPONENT_NAME)) {
130
- return true;
131
- }
132
- getOrCreateInsertion(insertionsByOffset, offset).attributeValues.set(WEB_COMPONENT_NAME, componentName);
133
- return true;
97
+ if (isReactFragment(openingElement, fragmentContext)) return false;
98
+ const elementName = getJSXName(openingElement.name);
99
+ if (!isHtmlElement(elementName)) return false;
100
+ if (ignoredComponents.includes(componentName) || ignoredComponents.includes(elementName)) return true;
101
+ const offset = getInsertionOffset(code, openingElement);
102
+ if (offset === null) return true;
103
+ if (getExistingAttributeNames(openingElement).has("data-sentry-component") || insertionsByOffset.get(offset)?.attributeValues.has("data-sentry-component")) return true;
104
+ getOrCreateInsertion(insertionsByOffset, offset).attributeValues.set(WEB_COMPONENT_NAME, componentName);
105
+ return true;
134
106
  }
135
107
  function isHtmlElement(elementName) {
136
- if (elementName === UNKNOWN_ELEMENT_NAME) {
137
- return false;
138
- }
139
- if (elementName.charAt(0) === elementName.charAt(0).toLowerCase()) {
140
- return true;
141
- }
142
- return REACT_NATIVE_ELEMENTS.has(elementName);
108
+ if (elementName === UNKNOWN_ELEMENT_NAME) return false;
109
+ if (elementName.charAt(0) === elementName.charAt(0).toLowerCase()) return true;
110
+ return REACT_NATIVE_ELEMENTS.has(elementName);
143
111
  }
144
112
  function getOrCreateInsertion(insertionsByOffset, offset) {
145
- let insertion = insertionsByOffset.get(offset);
146
- if (!insertion) {
147
- insertion = { offset, attributeValues: /* @__PURE__ */ new Map() };
148
- insertionsByOffset.set(offset, insertion);
149
- }
150
- return insertion;
113
+ let insertion = insertionsByOffset.get(offset);
114
+ if (!insertion) {
115
+ insertion = {
116
+ offset,
117
+ attributeValues: /* @__PURE__ */ new Map()
118
+ };
119
+ insertionsByOffset.set(offset, insertion);
120
+ }
121
+ return insertion;
151
122
  }
152
123
  function toAttributeInsertions(insertionsByOffset) {
153
- return [...insertionsByOffset.values()].map(({ offset, attributeValues }) => ({
154
- offset,
155
- attributes: getOrderedAttributes(attributeValues)
156
- }));
124
+ return [...insertionsByOffset.values()].map(({ offset, attributeValues }) => ({
125
+ offset,
126
+ attributes: getOrderedAttributes(attributeValues)
127
+ }));
157
128
  }
158
129
  function getExistingAttributeNames(openingElement) {
159
- const names = /* @__PURE__ */ new Set();
160
- for (const attribute of openingElement.attributes ?? []) {
161
- if (attribute.type === "JSXAttribute") {
162
- const name = getStringName(attribute.name);
163
- if (name) {
164
- names.add(name);
165
- }
166
- }
167
- }
168
- return names;
130
+ const names = /* @__PURE__ */ new Set();
131
+ for (const attribute of openingElement.attributes ?? []) if (attribute.type === "JSXAttribute") {
132
+ const name = getStringName(attribute.name);
133
+ if (name) names.add(name);
134
+ }
135
+ return names;
169
136
  }
170
137
  function getOrderedAttributes(attributeValues) {
171
- const attributes = [];
172
- for (const name of WEB_ATTRIBUTE_NAMES) {
173
- const value = attributeValues.get(name);
174
- if (value !== void 0) {
175
- attributes.push([name, value]);
176
- }
177
- }
178
- for (const [name, value] of attributeValues) {
179
- if (!WEB_ATTRIBUTE_NAME_SET.has(name)) {
180
- attributes.push([name, value]);
181
- }
182
- }
183
- return attributes;
138
+ const attributes = [];
139
+ for (const name of WEB_ATTRIBUTE_NAMES) {
140
+ const value = attributeValues.get(name);
141
+ if (value !== void 0) attributes.push([name, value]);
142
+ }
143
+ for (const [name, value] of attributeValues) if (!WEB_ATTRIBUTE_NAME_SET.has(name)) attributes.push([name, value]);
144
+ return attributes;
184
145
  }
185
-
186
146
  export { addPendingAttributes, addPendingHtmlAttribute, getInsertionOffset, getJSXName, getStringName, isJSXElement, isJSXFragment, isJSXRoot, isReactFragment, toAttributeInsertions };
187
- //# sourceMappingURL=component-annotation-oxc-jsx.js.map
147
+
148
+ //# sourceMappingURL=component-annotation-oxc-jsx.js.map