@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.
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
- package/build/cjs/_virtual/_rolldown/runtime.js +22 -0
- package/build/cjs/babel-plugin/component-annotation.js +14 -32
- package/build/cjs/babel-plugin/component-annotation.js.map +1 -1
- package/build/cjs/babel-plugin/constants.js +140 -122
- package/build/cjs/babel-plugin/constants.js.map +1 -1
- package/build/cjs/babel-plugin/experimental.js +204 -307
- package/build/cjs/babel-plugin/experimental.js.map +1 -1
- package/build/cjs/babel-plugin/index.js +315 -437
- package/build/cjs/babel-plugin/index.js.map +1 -1
- package/build/cjs/bun/index.js +81 -117
- package/build/cjs/bun/index.js.map +1 -1
- package/build/cjs/core/build-plugin-manager.js +626 -702
- package/build/cjs/core/build-plugin-manager.js.map +1 -1
- package/build/cjs/core/cli.js +134 -129
- package/build/cjs/core/cli.js.map +1 -1
- package/build/cjs/core/component-annotate-hooks.js +16 -27
- package/build/cjs/core/component-annotate-hooks.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc-ast.js +10 -21
- package/build/cjs/core/component-annotation-oxc-ast.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc-fragments.js +45 -74
- package/build/cjs/core/component-annotation-oxc-fragments.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc-jsx.js +116 -156
- package/build/cjs/core/component-annotation-oxc-jsx.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc-walk.js +62 -123
- package/build/cjs/core/component-annotation-oxc-walk.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc.js +68 -103
- package/build/cjs/core/component-annotation-oxc.js.map +1 -1
- package/build/cjs/core/debug-id-upload.js +223 -234
- package/build/cjs/core/debug-id-upload.js.map +1 -1
- package/build/cjs/core/get-code-injection-position.js +59 -74
- package/build/cjs/core/get-code-injection-position.js.map +1 -1
- package/build/cjs/core/glob.js +9 -7
- package/build/cjs/core/glob.js.map +1 -1
- package/build/cjs/core/index.js +77 -61
- package/build/cjs/core/index.js.map +1 -1
- package/build/cjs/core/logger.js +17 -26
- package/build/cjs/core/logger.js.map +1 -1
- package/build/cjs/core/options-mapping.js +95 -117
- package/build/cjs/core/options-mapping.js.map +1 -1
- package/build/cjs/core/sentry/telemetry.js +90 -105
- package/build/cjs/core/sentry/telemetry.js.map +1 -1
- package/build/cjs/core/sentry/transports.js +92 -99
- package/build/cjs/core/sentry/transports.js.map +1 -1
- package/build/cjs/core/sourcemap-settings.js +98 -61
- package/build/cjs/core/sourcemap-settings.js.map +1 -1
- package/build/cjs/core/upload-filter.js +41 -46
- package/build/cjs/core/upload-filter.js.map +1 -1
- package/build/cjs/core/utils.js +228 -221
- package/build/cjs/core/utils.js.map +1 -1
- package/build/cjs/core/version.js +4 -5
- package/build/cjs/core/version.js.map +1 -1
- package/build/cjs/esbuild/index.js +183 -213
- package/build/cjs/esbuild/index.js.map +1 -1
- package/build/cjs/loader-utils/index.js +5 -10
- package/build/cjs/rollup/debug-id-injection.js +22 -38
- package/build/cjs/rollup/debug-id-injection.js.map +1 -1
- package/build/cjs/rollup/debug-id-stamping.js +14 -24
- package/build/cjs/rollup/debug-id-stamping.js.map +1 -1
- package/build/cjs/rollup/index.js +192 -246
- package/build/cjs/rollup/index.js.map +1 -1
- package/build/cjs/rollup/source-map-handling.js +151 -175
- package/build/cjs/rollup/source-map-handling.js.map +1 -1
- package/build/cjs/vite/index.js +19 -21
- package/build/cjs/vite/index.js.map +1 -1
- package/build/cjs/vite/source-map-hooks.js +112 -89
- package/build/cjs/vite/source-map-hooks.js.map +1 -1
- package/build/cjs/webpack/component-annotation-transform.js +20 -26
- package/build/cjs/webpack/component-annotation-transform.js.map +1 -1
- package/build/cjs/webpack/index.js +271 -340
- package/build/cjs/webpack/index.js.map +1 -1
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
- package/build/esm/_virtual/_rolldown/runtime.js +2 -0
- package/build/esm/babel-plugin/component-annotation.js +13 -29
- package/build/esm/babel-plugin/component-annotation.js.map +1 -1
- package/build/esm/babel-plugin/constants.js +140 -120
- package/build/esm/babel-plugin/constants.js.map +1 -1
- package/build/esm/babel-plugin/experimental.js +204 -305
- package/build/esm/babel-plugin/experimental.js.map +1 -1
- package/build/esm/babel-plugin/index.js +311 -434
- package/build/esm/babel-plugin/index.js.map +1 -1
- package/build/esm/bun/index.js +76 -101
- package/build/esm/bun/index.js.map +1 -1
- package/build/esm/core/build-plugin-manager.js +621 -683
- package/build/esm/core/build-plugin-manager.js.map +1 -1
- package/build/esm/core/cli.js +134 -127
- package/build/esm/core/cli.js.map +1 -1
- package/build/esm/core/component-annotate-hooks.js +16 -25
- package/build/esm/core/component-annotate-hooks.js.map +1 -1
- package/build/esm/core/component-annotation-oxc-ast.js +9 -19
- package/build/esm/core/component-annotation-oxc-ast.js.map +1 -1
- package/build/esm/core/component-annotation-oxc-fragments.js +44 -72
- package/build/esm/core/component-annotation-oxc-fragments.js.map +1 -1
- package/build/esm/core/component-annotation-oxc-jsx.js +115 -154
- package/build/esm/core/component-annotation-oxc-jsx.js.map +1 -1
- package/build/esm/core/component-annotation-oxc-walk.js +61 -121
- package/build/esm/core/component-annotation-oxc-walk.js.map +1 -1
- package/build/esm/core/component-annotation-oxc.js +65 -96
- package/build/esm/core/component-annotation-oxc.js.map +1 -1
- package/build/esm/core/debug-id-upload.js +218 -213
- package/build/esm/core/debug-id-upload.js.map +1 -1
- package/build/esm/core/get-code-injection-position.js +59 -72
- package/build/esm/core/get-code-injection-position.js.map +1 -1
- package/build/esm/core/glob.js +9 -5
- package/build/esm/core/glob.js.map +1 -1
- package/build/esm/core/index.js +62 -47
- package/build/esm/core/index.js.map +1 -1
- package/build/esm/core/logger.js +17 -24
- package/build/esm/core/logger.js.map +1 -1
- package/build/esm/core/options-mapping.js +95 -115
- package/build/esm/core/options-mapping.js.map +1 -1
- package/build/esm/core/sentry/telemetry.js +89 -102
- package/build/esm/core/sentry/telemetry.js.map +1 -1
- package/build/esm/core/sentry/transports.js +90 -83
- package/build/esm/core/sentry/transports.js.map +1 -1
- package/build/esm/core/sourcemap-settings.js +96 -59
- package/build/esm/core/sourcemap-settings.js.map +1 -1
- package/build/esm/core/upload-filter.js +39 -30
- package/build/esm/core/upload-filter.js.map +1 -1
- package/build/esm/core/utils.js +221 -211
- package/build/esm/core/utils.js.map +1 -1
- package/build/esm/core/version.js +4 -3
- package/build/esm/core/version.js.map +1 -1
- package/build/esm/esbuild/index.js +179 -197
- package/build/esm/esbuild/index.js.map +1 -1
- package/build/esm/loader-utils/index.js +4 -3
- package/build/esm/package.json +1 -1
- package/build/esm/rollup/debug-id-injection.js +22 -36
- package/build/esm/rollup/debug-id-injection.js.map +1 -1
- package/build/esm/rollup/debug-id-stamping.js +14 -22
- package/build/esm/rollup/debug-id-stamping.js.map +1 -1
- package/build/esm/rollup/index.js +189 -226
- package/build/esm/rollup/index.js.map +1 -1
- package/build/esm/rollup/source-map-handling.js +149 -159
- package/build/esm/rollup/source-map-handling.js.map +1 -1
- package/build/esm/vite/index.js +19 -18
- package/build/esm/vite/index.js.map +1 -1
- package/build/esm/vite/source-map-hooks.js +109 -72
- package/build/esm/vite/source-map-hooks.js.map +1 -1
- package/build/esm/webpack/component-annotation-transform.js +17 -24
- package/build/esm/webpack/component-annotation-transform.js.map +1 -1
- package/build/esm/webpack/index.js +268 -322
- package/build/esm/webpack/index.js.map +1 -1
- package/build/types/core/build-plugin-manager.d.ts +16 -5
- package/build/types/core/build-plugin-manager.d.ts.map +1 -1
- package/build/types/core/cli.d.ts +6 -1
- package/build/types/core/cli.d.ts.map +1 -1
- package/build/types/core/debug-id-upload.d.ts +7 -4
- package/build/types/core/debug-id-upload.d.ts.map +1 -1
- package/build/types/core/index.d.ts +3 -3
- package/build/types/core/index.d.ts.map +1 -1
- package/build/types/core/options-mapping.d.ts +4 -3
- package/build/types/core/options-mapping.d.ts.map +1 -1
- package/build/types/core/sentry/telemetry.d.ts.map +1 -1
- package/build/types/core/sourcemap-settings.d.ts +10 -1
- package/build/types/core/sourcemap-settings.d.ts.map +1 -1
- package/build/types/core/types.d.ts +25 -1
- package/build/types/core/types.d.ts.map +1 -1
- package/build/types/core/utils.d.ts +4 -0
- package/build/types/core/utils.d.ts.map +1 -1
- package/build/types/core/version.d.ts +1 -1
- package/build/types/esbuild/index.d.ts +2 -2
- package/build/types/esbuild/index.d.ts.map +1 -1
- package/build/types/rollup/index.d.ts +2 -2
- package/build/types/rollup/index.d.ts.map +1 -1
- package/build/types/rollup/source-map-handling.d.ts.map +1 -1
- package/build/types/vite/index.d.ts +3 -3
- package/build/types/vite/index.d.ts.map +1 -1
- package/build/types/vite/source-map-hooks.d.ts.map +1 -1
- package/build/types/webpack/index.d.ts +7 -3
- package/build/types/webpack/index.d.ts.map +1 -1
- package/package.json +8 -15
- package/build/cjs/loader-utils/index.js.map +0 -1
- package/build/esm/loader-utils/index.js.map +0 -1
|
@@ -1,337 +1,234 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/babel-plugin/experimental.ts
|
|
3
2
|
const REACT_NATIVE_ELEMENTS = [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
3
|
+
"Image",
|
|
4
|
+
"Text",
|
|
5
|
+
"View",
|
|
6
|
+
"ScrollView",
|
|
7
|
+
"TextInput",
|
|
8
|
+
"TouchableOpacity",
|
|
9
|
+
"TouchableHighlight",
|
|
10
|
+
"TouchableWithoutFeedback",
|
|
11
|
+
"FlatList",
|
|
12
|
+
"SectionList",
|
|
13
|
+
"ActivityIndicator",
|
|
14
|
+
"Button",
|
|
15
|
+
"Switch",
|
|
16
|
+
"Modal",
|
|
17
|
+
"SafeAreaView",
|
|
18
|
+
"StatusBar",
|
|
19
|
+
"KeyboardAvoidingView",
|
|
20
|
+
"RefreshControl",
|
|
21
|
+
"Picker",
|
|
22
|
+
"Slider"
|
|
24
23
|
];
|
|
25
24
|
function experimentalComponentNameAnnotatePlugin(babel) {
|
|
26
|
-
|
|
25
|
+
return createPlugin(babel);
|
|
27
26
|
}
|
|
28
27
|
function createPlugin({ types: t }) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return prop.isClassMethod() && prop.get("key").isIdentifier({ name: "render" });
|
|
57
|
-
});
|
|
58
|
-
if (!render?.traverse) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const context = createJSXProcessingContext(state, t, name.node?.name || "");
|
|
62
|
-
render.traverse({
|
|
63
|
-
ReturnStatement(returnStatement) {
|
|
64
|
-
const arg = returnStatement.get("argument");
|
|
65
|
-
if (!arg.isJSXElement() && !arg.isJSXFragment()) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
processJSX(context, arg);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
28
|
+
return { visitor: {
|
|
29
|
+
Program: { enter(path, state) {
|
|
30
|
+
state.sentryFragmentContext = collectFragmentContext(path);
|
|
31
|
+
} },
|
|
32
|
+
FunctionDeclaration(path, state) {
|
|
33
|
+
if (!path.node.id?.name) return;
|
|
34
|
+
functionBodyPushAttributes(createJSXProcessingContext(state, t, path.node.id.name), path);
|
|
35
|
+
},
|
|
36
|
+
ArrowFunctionExpression(path, state) {
|
|
37
|
+
const parent = path.parent;
|
|
38
|
+
if (!parent || !("id" in parent) || !parent.id || !("name" in parent.id) || !parent.id.name) return;
|
|
39
|
+
functionBodyPushAttributes(createJSXProcessingContext(state, t, parent.id.name), path);
|
|
40
|
+
},
|
|
41
|
+
ClassDeclaration(path, state) {
|
|
42
|
+
const name = path.get("id");
|
|
43
|
+
const render = path.get("body").get("body").find((prop) => {
|
|
44
|
+
return prop.isClassMethod() && prop.get("key").isIdentifier({ name: "render" });
|
|
45
|
+
});
|
|
46
|
+
if (!render?.traverse) return;
|
|
47
|
+
const context = createJSXProcessingContext(state, t, name.node?.name || "");
|
|
48
|
+
render.traverse({ ReturnStatement(returnStatement) {
|
|
49
|
+
const arg = returnStatement.get("argument");
|
|
50
|
+
if (!arg.isJSXElement() && !arg.isJSXFragment()) return;
|
|
51
|
+
processJSX(context, arg);
|
|
52
|
+
} });
|
|
53
|
+
}
|
|
54
|
+
} };
|
|
74
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Checks if an element name represents an HTML element (as opposed to a React component).
|
|
58
|
+
* HTML elements include standard lowercase HTML tags and React Native elements.
|
|
59
|
+
*/
|
|
75
60
|
function isHtmlElement(elementName) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
if (REACT_NATIVE_ELEMENTS.includes(elementName)) {
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
return false;
|
|
61
|
+
if (elementName === UNKNOWN_ELEMENT_NAME) return false;
|
|
62
|
+
if (elementName.length > 0 && elementName.charAt(0) === elementName.charAt(0).toLowerCase()) return true;
|
|
63
|
+
if (REACT_NATIVE_ELEMENTS.includes(elementName)) return true;
|
|
64
|
+
return false;
|
|
86
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Creates a JSX processing context from the plugin state
|
|
68
|
+
*/
|
|
87
69
|
function createJSXProcessingContext(state, t, componentName) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
70
|
+
return {
|
|
71
|
+
t,
|
|
72
|
+
componentName,
|
|
73
|
+
attributeName: attributeNamesFromState(state),
|
|
74
|
+
ignoredComponents: state.opts.ignoredComponents ?? [],
|
|
75
|
+
fragmentContext: state.sentryFragmentContext
|
|
76
|
+
};
|
|
95
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Processes the body of a function to add Sentry tracking attributes to JSX elements.
|
|
80
|
+
* Handles various function body structures including direct JSX returns, conditional expressions,
|
|
81
|
+
* and nested JSX elements.
|
|
82
|
+
*/
|
|
96
83
|
function functionBodyPushAttributes(context, path) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
const alternate = arg.get("alternate");
|
|
127
|
-
if (alternate.isJSXFragment() || alternate.isJSXElement()) {
|
|
128
|
-
processJSX(context, alternate);
|
|
129
|
-
}
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
if (!arg.isJSXFragment() && !arg.isJSXElement()) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
jsxNode = arg;
|
|
136
|
-
}
|
|
137
|
-
if (!jsxNode) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
processJSX(context, jsxNode);
|
|
84
|
+
let jsxNode;
|
|
85
|
+
const functionBody = path.get("body").get("body");
|
|
86
|
+
if (!("length" in functionBody) && functionBody.parent && (functionBody.parent.type === "JSXElement" || functionBody.parent.type === "JSXFragment")) {
|
|
87
|
+
const maybeJsxNode = functionBody.find((c) => {
|
|
88
|
+
return c.type === "JSXElement" || c.type === "JSXFragment";
|
|
89
|
+
});
|
|
90
|
+
if (!maybeJsxNode) return;
|
|
91
|
+
jsxNode = maybeJsxNode;
|
|
92
|
+
} else {
|
|
93
|
+
const returnStatement = functionBody.find((c) => {
|
|
94
|
+
return c.type === "ReturnStatement";
|
|
95
|
+
});
|
|
96
|
+
if (!returnStatement) return;
|
|
97
|
+
const arg = returnStatement.get("argument");
|
|
98
|
+
if (!arg) return;
|
|
99
|
+
if (Array.isArray(arg)) return;
|
|
100
|
+
if (arg.isConditionalExpression()) {
|
|
101
|
+
const consequent = arg.get("consequent");
|
|
102
|
+
if (consequent.isJSXFragment() || consequent.isJSXElement()) processJSX(context, consequent);
|
|
103
|
+
const alternate = arg.get("alternate");
|
|
104
|
+
if (alternate.isJSXFragment() || alternate.isJSXElement()) processJSX(context, alternate);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (!arg.isJSXFragment() && !arg.isJSXElement()) return;
|
|
108
|
+
jsxNode = arg;
|
|
109
|
+
}
|
|
110
|
+
if (!jsxNode) return;
|
|
111
|
+
processJSX(context, jsxNode);
|
|
141
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Recursively processes JSX elements to add Sentry tracking attributes.
|
|
115
|
+
* Handles both JSX elements and fragments, applying appropriate attributes
|
|
116
|
+
* based on configuration and component context.
|
|
117
|
+
*/
|
|
142
118
|
function processJSX(context, jsxNode) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
let children = jsxNode.get("children");
|
|
156
|
-
if (children && !("length" in children)) {
|
|
157
|
-
children = [children];
|
|
158
|
-
}
|
|
159
|
-
children.forEach((child) => {
|
|
160
|
-
if (!child.node) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
const openingElement = child.get("openingElement");
|
|
164
|
-
if (Array.isArray(openingElement)) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
processJSX(context, child);
|
|
168
|
-
});
|
|
119
|
+
if (!jsxNode) return;
|
|
120
|
+
const paths = jsxNode.get("openingElement");
|
|
121
|
+
if ((Array.isArray(paths) ? paths : [paths]).reduce((prev, openingElement) => prev || applyAttributes(context, openingElement, context.componentName), false)) return;
|
|
122
|
+
let children = jsxNode.get("children");
|
|
123
|
+
if (children && !("length" in children)) children = [children];
|
|
124
|
+
children.forEach((child) => {
|
|
125
|
+
if (!child.node) return;
|
|
126
|
+
const openingElement = child.get("openingElement");
|
|
127
|
+
if (Array.isArray(openingElement)) return;
|
|
128
|
+
processJSX(context, child);
|
|
129
|
+
});
|
|
169
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Applies Sentry tracking attributes to a JSX opening element.
|
|
133
|
+
* Adds component name, element name, and source file attributes while
|
|
134
|
+
* respecting ignore lists and fragment detection.
|
|
135
|
+
*/
|
|
170
136
|
function applyAttributes(context, openingElement, componentName) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
const elementName = getPathName(t, openingElement);
|
|
183
|
-
if (!isHtmlElement(elementName)) {
|
|
184
|
-
return false;
|
|
185
|
-
}
|
|
186
|
-
const isAnIgnoredComponent = ignoredComponents.some(
|
|
187
|
-
(ignoredComponent) => ignoredComponent === componentName || ignoredComponent === elementName
|
|
188
|
-
);
|
|
189
|
-
if (!isAnIgnoredComponent && !hasAttributeWithName(openingElement, componentAttributeName)) {
|
|
190
|
-
if (componentAttributeName) {
|
|
191
|
-
openingElement.node.attributes.push(
|
|
192
|
-
t.jSXAttribute(t.jSXIdentifier(componentAttributeName), t.stringLiteral(componentName))
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return true;
|
|
137
|
+
const { t, attributeName: componentAttributeName, ignoredComponents, fragmentContext } = context;
|
|
138
|
+
if (!openingElement.node) return false;
|
|
139
|
+
if (isReactFragment(t, openingElement, fragmentContext)) return false;
|
|
140
|
+
if (!openingElement.node.attributes) openingElement.node.attributes = [];
|
|
141
|
+
const elementName = getPathName(t, openingElement);
|
|
142
|
+
if (!isHtmlElement(elementName)) return false;
|
|
143
|
+
if (!ignoredComponents.some((ignoredComponent) => ignoredComponent === componentName || ignoredComponent === elementName) && !hasAttributeWithName(openingElement, componentAttributeName)) {
|
|
144
|
+
if (componentAttributeName) openingElement.node.attributes.push(t.jSXAttribute(t.jSXIdentifier(componentAttributeName), t.stringLiteral(componentName)));
|
|
145
|
+
}
|
|
146
|
+
return true;
|
|
197
147
|
}
|
|
198
148
|
function attributeNamesFromState(state) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
return "data-sentry-component";
|
|
149
|
+
if (state.opts.native) return "dataSentryComponent";
|
|
150
|
+
return "data-sentry-component";
|
|
203
151
|
}
|
|
204
152
|
function collectFragmentContext(programPath) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const properties = varPath.node.id.properties;
|
|
237
|
-
for (const prop of properties) {
|
|
238
|
-
if (prop.type === "ObjectProperty" && prop.key?.type === "Identifier" && prop.value?.type === "Identifier" && prop.key.name === "Fragment") {
|
|
239
|
-
fragmentAliases.add(prop.value.name);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
return { fragmentAliases, reactNamespaceAliases };
|
|
153
|
+
const fragmentAliases = /* @__PURE__ */ new Set();
|
|
154
|
+
const reactNamespaceAliases = /* @__PURE__ */ new Set(["React"]);
|
|
155
|
+
programPath.traverse({
|
|
156
|
+
ImportDeclaration(importPath) {
|
|
157
|
+
const source = importPath.node.source.value;
|
|
158
|
+
if (source === "react" || source === "React") importPath.node.specifiers.forEach((spec) => {
|
|
159
|
+
if (spec.type === "ImportSpecifier" && spec.imported.type === "Identifier") {
|
|
160
|
+
if (spec.imported.name === "Fragment") fragmentAliases.add(spec.local.name);
|
|
161
|
+
} else if (spec.type === "ImportDefaultSpecifier" || spec.type === "ImportNamespaceSpecifier") reactNamespaceAliases.add(spec.local.name);
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
VariableDeclarator(varPath) {
|
|
165
|
+
if (varPath.node.init) {
|
|
166
|
+
const init = varPath.node.init;
|
|
167
|
+
if (varPath.node.id.type === "Identifier") {
|
|
168
|
+
if (init.type === "Identifier" && fragmentAliases.has(init.name)) fragmentAliases.add(varPath.node.id.name);
|
|
169
|
+
if (init.type === "MemberExpression" && init.object.type === "Identifier" && init.property.type === "Identifier" && init.property.name === "Fragment" && reactNamespaceAliases.has(init.object.name)) fragmentAliases.add(varPath.node.id.name);
|
|
170
|
+
}
|
|
171
|
+
if (varPath.node.id.type === "ObjectPattern") {
|
|
172
|
+
if (init.type === "Identifier" && reactNamespaceAliases.has(init.name)) {
|
|
173
|
+
const properties = varPath.node.id.properties;
|
|
174
|
+
for (const prop of properties) if (prop.type === "ObjectProperty" && prop.key?.type === "Identifier" && prop.value?.type === "Identifier" && prop.key.name === "Fragment") fragmentAliases.add(prop.value.name);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
return {
|
|
181
|
+
fragmentAliases,
|
|
182
|
+
reactNamespaceAliases
|
|
183
|
+
};
|
|
248
184
|
}
|
|
249
185
|
function isReactFragment(t, openingElement, context) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
return false;
|
|
273
|
-
}
|
|
274
|
-
const objectName = "name" in nodeNameObject && nodeNameObject.name;
|
|
275
|
-
const propertyName = "name" in nodeNameProperty && nodeNameProperty.name;
|
|
276
|
-
if (objectName === "React" && propertyName === "Fragment") {
|
|
277
|
-
return true;
|
|
278
|
-
}
|
|
279
|
-
if (context) {
|
|
280
|
-
if (context.reactNamespaceAliases.has(objectName) && propertyName === "Fragment") {
|
|
281
|
-
return true;
|
|
282
|
-
}
|
|
283
|
-
if (context.fragmentAliases.has(objectName) && propertyName === "Fragment") {
|
|
284
|
-
return true;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return false;
|
|
186
|
+
if (openingElement.isJSXFragment()) return true;
|
|
187
|
+
const elementName = getPathName(t, openingElement);
|
|
188
|
+
if (elementName === "Fragment" || elementName === "React.Fragment") return true;
|
|
189
|
+
if (context && elementName && context.fragmentAliases.has(elementName)) return true;
|
|
190
|
+
if (openingElement.node && "name" in openingElement.node && openingElement.node.name && typeof openingElement.node.name === "object" && "type" in openingElement.node.name && openingElement.node.name.type === "JSXMemberExpression") {
|
|
191
|
+
const nodeName = openingElement.node.name;
|
|
192
|
+
if (typeof nodeName !== "object" || !nodeName) return false;
|
|
193
|
+
if ("object" in nodeName && "property" in nodeName) {
|
|
194
|
+
const nodeNameObject = nodeName.object;
|
|
195
|
+
const nodeNameProperty = nodeName.property;
|
|
196
|
+
if (typeof nodeNameObject !== "object" || typeof nodeNameProperty !== "object") return false;
|
|
197
|
+
if (!nodeNameObject || !nodeNameProperty) return false;
|
|
198
|
+
const objectName = "name" in nodeNameObject && nodeNameObject.name;
|
|
199
|
+
const propertyName = "name" in nodeNameProperty && nodeNameProperty.name;
|
|
200
|
+
if (objectName === "React" && propertyName === "Fragment") return true;
|
|
201
|
+
if (context) {
|
|
202
|
+
if (context.reactNamespaceAliases.has(objectName) && propertyName === "Fragment") return true;
|
|
203
|
+
if (context.fragmentAliases.has(objectName) && propertyName === "Fragment") return true;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return false;
|
|
290
208
|
}
|
|
291
209
|
function hasAttributeWithName(openingElement, name) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
return node.name.name === name;
|
|
298
|
-
}
|
|
299
|
-
return false;
|
|
300
|
-
});
|
|
210
|
+
if (!name) return false;
|
|
211
|
+
return openingElement.node.attributes.some((node) => {
|
|
212
|
+
if (node.type === "JSXAttribute") return node.name.name === name;
|
|
213
|
+
return false;
|
|
214
|
+
});
|
|
301
215
|
}
|
|
302
216
|
function getPathName(t, path) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (t.isIdentifier(name) || t.isJSXIdentifier(name)) {
|
|
312
|
-
return name.name;
|
|
313
|
-
}
|
|
314
|
-
if (t.isJSXNamespacedName(name)) {
|
|
315
|
-
return name.name.name;
|
|
316
|
-
}
|
|
317
|
-
if (t.isJSXMemberExpression(name)) {
|
|
318
|
-
const objectName = getJSXMemberExpressionObjectName(t, name.object);
|
|
319
|
-
const propertyName = name.property.name;
|
|
320
|
-
return `${objectName}.${propertyName}`;
|
|
321
|
-
}
|
|
322
|
-
return UNKNOWN_ELEMENT_NAME;
|
|
217
|
+
if (!path.node) return UNKNOWN_ELEMENT_NAME;
|
|
218
|
+
if (!("name" in path.node)) return UNKNOWN_ELEMENT_NAME;
|
|
219
|
+
const name = path.node.name;
|
|
220
|
+
if (typeof name === "string") return name;
|
|
221
|
+
if (t.isIdentifier(name) || t.isJSXIdentifier(name)) return name.name;
|
|
222
|
+
if (t.isJSXNamespacedName(name)) return name.name.name;
|
|
223
|
+
if (t.isJSXMemberExpression(name)) return `${getJSXMemberExpressionObjectName(t, name.object)}.${name.property.name}`;
|
|
224
|
+
return UNKNOWN_ELEMENT_NAME;
|
|
323
225
|
}
|
|
324
226
|
function getJSXMemberExpressionObjectName(t, object) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
if (t.isJSXMemberExpression(object)) {
|
|
329
|
-
const objectName = getJSXMemberExpressionObjectName(t, object.object);
|
|
330
|
-
return `${objectName}.${object.property.name}`;
|
|
331
|
-
}
|
|
332
|
-
return UNKNOWN_ELEMENT_NAME;
|
|
227
|
+
if (t.isJSXIdentifier(object)) return object.name;
|
|
228
|
+
if (t.isJSXMemberExpression(object)) return `${getJSXMemberExpressionObjectName(t, object.object)}.${object.property.name}`;
|
|
229
|
+
return UNKNOWN_ELEMENT_NAME;
|
|
333
230
|
}
|
|
334
231
|
const UNKNOWN_ELEMENT_NAME = "unknown";
|
|
335
|
-
|
|
336
232
|
exports.experimentalComponentNameAnnotatePlugin = experimentalComponentNameAnnotatePlugin;
|
|
337
|
-
|
|
233
|
+
|
|
234
|
+
//# sourceMappingURL=experimental.js.map
|