@truewatchtech/react-native-mobile-babel-plugin 0.4.3-alpha.1

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 (80) hide show
  1. package/README.md +185 -0
  2. package/lib/commonjs/actions/global.js +19 -0
  3. package/lib/commonjs/actions/global.js.map +1 -0
  4. package/lib/commonjs/actions/rum/components.js +81 -0
  5. package/lib/commonjs/actions/rum/components.js.map +1 -0
  6. package/lib/commonjs/actions/rum/content.js +168 -0
  7. package/lib/commonjs/actions/rum/content.js.map +1 -0
  8. package/lib/commonjs/actions/rum/index.js +68 -0
  9. package/lib/commonjs/actions/rum/index.js.map +1 -0
  10. package/lib/commonjs/actions/rum/memoization.js +88 -0
  11. package/lib/commonjs/actions/rum/memoization.js.map +1 -0
  12. package/lib/commonjs/actions/rum/metadata.js +63 -0
  13. package/lib/commonjs/actions/rum/metadata.js.map +1 -0
  14. package/lib/commonjs/actions/rum/tap.js +45 -0
  15. package/lib/commonjs/actions/rum/tap.js.map +1 -0
  16. package/lib/commonjs/constants.js +25 -0
  17. package/lib/commonjs/constants.js.map +1 -0
  18. package/lib/commonjs/index.js +48 -0
  19. package/lib/commonjs/index.js.map +1 -0
  20. package/lib/commonjs/options.js +23 -0
  21. package/lib/commonjs/options.js.map +1 -0
  22. package/lib/commonjs/state.js +32 -0
  23. package/lib/commonjs/state.js.map +1 -0
  24. package/lib/commonjs/types.js +6 -0
  25. package/lib/commonjs/types.js.map +1 -0
  26. package/lib/commonjs/utils/jsx.js +43 -0
  27. package/lib/commonjs/utils/jsx.js.map +1 -0
  28. package/lib/module/actions/global.js +13 -0
  29. package/lib/module/actions/global.js.map +1 -0
  30. package/lib/module/actions/rum/components.js +73 -0
  31. package/lib/module/actions/rum/components.js.map +1 -0
  32. package/lib/module/actions/rum/content.js +161 -0
  33. package/lib/module/actions/rum/content.js.map +1 -0
  34. package/lib/module/actions/rum/index.js +61 -0
  35. package/lib/module/actions/rum/index.js.map +1 -0
  36. package/lib/module/actions/rum/memoization.js +82 -0
  37. package/lib/module/actions/rum/memoization.js.map +1 -0
  38. package/lib/module/actions/rum/metadata.js +56 -0
  39. package/lib/module/actions/rum/metadata.js.map +1 -0
  40. package/lib/module/actions/rum/tap.js +38 -0
  41. package/lib/module/actions/rum/tap.js.map +1 -0
  42. package/lib/module/constants.js +19 -0
  43. package/lib/module/constants.js.map +1 -0
  44. package/lib/module/index.js +42 -0
  45. package/lib/module/index.js.map +1 -0
  46. package/lib/module/options.js +17 -0
  47. package/lib/module/options.js.map +1 -0
  48. package/lib/module/state.js +25 -0
  49. package/lib/module/state.js.map +1 -0
  50. package/lib/module/types.js +2 -0
  51. package/lib/module/types.js.map +1 -0
  52. package/lib/module/utils/jsx.js +36 -0
  53. package/lib/module/utils/jsx.js.map +1 -0
  54. package/lib/typescript/actions/global.d.ts +2 -0
  55. package/lib/typescript/actions/rum/components.d.ts +5 -0
  56. package/lib/typescript/actions/rum/content.d.ts +6 -0
  57. package/lib/typescript/actions/rum/index.d.ts +4 -0
  58. package/lib/typescript/actions/rum/memoization.d.ts +4 -0
  59. package/lib/typescript/actions/rum/metadata.d.ts +4 -0
  60. package/lib/typescript/actions/rum/tap.d.ts +6 -0
  61. package/lib/typescript/constants.d.ts +4 -0
  62. package/lib/typescript/index.d.ts +5 -0
  63. package/lib/typescript/options.d.ts +2 -0
  64. package/lib/typescript/state.d.ts +5 -0
  65. package/lib/typescript/types.d.ts +56 -0
  66. package/lib/typescript/utils/jsx.d.ts +4 -0
  67. package/package.json +68 -0
  68. package/src/actions/global.ts +48 -0
  69. package/src/actions/rum/components.ts +128 -0
  70. package/src/actions/rum/content.ts +274 -0
  71. package/src/actions/rum/index.ts +154 -0
  72. package/src/actions/rum/memoization.ts +136 -0
  73. package/src/actions/rum/metadata.ts +147 -0
  74. package/src/actions/rum/tap.ts +148 -0
  75. package/src/constants.ts +21 -0
  76. package/src/index.ts +50 -0
  77. package/src/options.ts +26 -0
  78. package/src/state.ts +39 -0
  79. package/src/types.ts +72 -0
  80. package/src/utils/jsx.ts +50 -0
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.wrapMemoizedHandler = wrapMemoizedHandler;
7
+ var _content = require("./content");
8
+ var _tap = require("./tap");
9
+ /*
10
+ * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel
11
+ * interaction tracking implementation, licensed under Apache-2.0.
12
+ */
13
+
14
+ function getMemoizationName(t, callee) {
15
+ if (t.isIdentifier(callee)) {
16
+ return callee.name;
17
+ }
18
+ if (t.isMemberExpression(callee) && t.isIdentifier(callee.property)) {
19
+ return callee.property.name;
20
+ }
21
+ return null;
22
+ }
23
+ function getVariableDeclaratorPath(bindingPath) {
24
+ if (bindingPath.isVariableDeclarator()) {
25
+ return bindingPath;
26
+ }
27
+ return bindingPath.findParent(parent => parent.isVariableDeclarator()) || null;
28
+ }
29
+ function isLocalFunctionReference(path, expression) {
30
+ if (!expression || expression.type !== 'Identifier') {
31
+ return true;
32
+ }
33
+ const binding = path.scope.getBinding(expression.name);
34
+ if (!binding) {
35
+ return false;
36
+ }
37
+ return !(binding.path.isImportSpecifier() || binding.path.isImportDefaultSpecifier() || binding.path.isImportNamespaceSpecifier());
38
+ }
39
+
40
+ /** Wraps the hook callback once so JSX references retain their memoized identity. */
41
+ function wrapMemoizedHandler(t, path, expression, metadata, state, mode, actionType) {
42
+ var _path$parentPath;
43
+ if (!t.isIdentifier(expression)) {
44
+ return false;
45
+ }
46
+ const binding = path.scope.getBinding(expression.name);
47
+ if (!binding) {
48
+ return false;
49
+ }
50
+ const declaratorPath = getVariableDeclaratorPath(binding.path);
51
+ if (!declaratorPath) {
52
+ return false;
53
+ }
54
+ const initPath = declaratorPath.get('init');
55
+ if (!initPath.isCallExpression()) {
56
+ return false;
57
+ }
58
+ const memoizationName = getMemoizationName(t, initPath.node.callee);
59
+ if (!memoizationName || !['useCallback', 'useMemo'].includes(memoizationName)) {
60
+ return false;
61
+ }
62
+ if (state._ftMemoizedHandlers.has(declaratorPath.node)) {
63
+ return true;
64
+ }
65
+ const argumentPaths = initPath.get('arguments');
66
+ const callbackPath = argumentPaths[0];
67
+ if (!callbackPath || callbackPath.isSpreadElement()) {
68
+ return false;
69
+ }
70
+ const callback = callbackPath.node;
71
+ if (!t.isArrowFunctionExpression(callback) && !t.isFunctionExpression(callback) && !t.isIdentifier(callback)) {
72
+ return false;
73
+ }
74
+ if (!isLocalFunctionReference(path, callback)) {
75
+ state._ftMemoizedHandlers.add(declaratorPath.node);
76
+ return true;
77
+ }
78
+ const elementPath = (_path$parentPath = path.parentPath) === null || _path$parentPath === void 0 ? void 0 : _path$parentPath.parentPath;
79
+ const metadataAtMemoDefinition = metadata.getContent && elementPath !== null && elementPath !== void 0 && elementPath.isJSXElement() && !(0, _content.isContentVisibleFromScope)(t, elementPath, metadata.component, initPath.scope) ? {
80
+ ...metadata,
81
+ getContent: null
82
+ } : metadata;
83
+ callbackPath.replaceWith((0, _tap.buildHandlerWrapper)(t, callback, metadataAtMemoDefinition, state, callbackPath.scope, memoizationName === 'useMemo' ? 'delayed' : mode, actionType));
84
+ state._ftMemoizedHandlers.add(declaratorPath.node);
85
+ state._ftHasWrappedAction = true;
86
+ return true;
87
+ }
88
+ //# sourceMappingURL=memoization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_content","require","_tap","getMemoizationName","t","callee","isIdentifier","name","isMemberExpression","property","getVariableDeclaratorPath","bindingPath","isVariableDeclarator","findParent","parent","isLocalFunctionReference","path","expression","type","binding","scope","getBinding","isImportSpecifier","isImportDefaultSpecifier","isImportNamespaceSpecifier","wrapMemoizedHandler","metadata","state","mode","actionType","_path$parentPath","declaratorPath","initPath","get","isCallExpression","memoizationName","node","includes","_ftMemoizedHandlers","has","argumentPaths","callbackPath","isSpreadElement","callback","isArrowFunctionExpression","isFunctionExpression","add","elementPath","parentPath","metadataAtMemoDefinition","getContent","isJSXElement","isContentVisibleFromScope","component","replaceWith","buildHandlerWrapper","_ftHasWrappedAction"],"sources":["memoization.ts"],"sourcesContent":["/*\n * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel\n * interaction tracking implementation, licensed under Apache-2.0.\n */\n\nimport type * as Babel from '@babel/core';\nimport type { ActionMetadata, PluginState, TrackedHandler } from '../../types';\nimport { isContentVisibleFromScope } from './content';\nimport { buildHandlerWrapper } from './tap';\n\nfunction getMemoizationName(\n t: typeof Babel.types,\n callee: Babel.types.Expression | Babel.types.V8IntrinsicIdentifier\n): string | null {\n if (t.isIdentifier(callee)) {\n return callee.name;\n }\n if (t.isMemberExpression(callee) && t.isIdentifier(callee.property)) {\n return callee.property.name;\n }\n return null;\n}\n\nfunction getVariableDeclaratorPath(\n bindingPath: Babel.NodePath\n): Babel.NodePath<Babel.types.VariableDeclarator> | null {\n if (bindingPath.isVariableDeclarator()) {\n return bindingPath;\n }\n return (\n (bindingPath.findParent((parent) =>\n parent.isVariableDeclarator()\n ) as Babel.NodePath<Babel.types.VariableDeclarator> | null) || null\n );\n}\n\nfunction isLocalFunctionReference(\n path: Babel.NodePath,\n expression: Babel.types.Expression\n): boolean {\n if (!expression || expression.type !== 'Identifier') {\n return true;\n }\n const binding = path.scope.getBinding(expression.name);\n if (!binding) {\n return false;\n }\n return !(\n binding.path.isImportSpecifier() ||\n binding.path.isImportDefaultSpecifier() ||\n binding.path.isImportNamespaceSpecifier()\n );\n}\n\n/** Wraps the hook callback once so JSX references retain their memoized identity. */\nexport function wrapMemoizedHandler(\n t: typeof Babel.types,\n path: Babel.NodePath<Babel.types.JSXAttribute>,\n expression: Babel.types.Expression,\n metadata: ActionMetadata,\n state: PluginState,\n mode: TrackedHandler['mode'],\n actionType: TrackedHandler['actionType']\n): boolean {\n if (!t.isIdentifier(expression)) {\n return false;\n }\n const binding = path.scope.getBinding(expression.name);\n if (!binding) {\n return false;\n }\n const declaratorPath = getVariableDeclaratorPath(binding.path);\n if (!declaratorPath) {\n return false;\n }\n const initPath = declaratorPath.get('init');\n if (!initPath.isCallExpression()) {\n return false;\n }\n const memoizationName = getMemoizationName(t, initPath.node.callee);\n if (\n !memoizationName ||\n !['useCallback', 'useMemo'].includes(memoizationName)\n ) {\n return false;\n }\n if (state._ftMemoizedHandlers.has(declaratorPath.node)) {\n return true;\n }\n\n const argumentPaths = initPath.get('arguments');\n const callbackPath = argumentPaths[0];\n if (!callbackPath || callbackPath.isSpreadElement()) {\n return false;\n }\n const callback = callbackPath.node;\n if (\n !t.isArrowFunctionExpression(callback) &&\n !t.isFunctionExpression(callback) &&\n !t.isIdentifier(callback)\n ) {\n return false;\n }\n if (!isLocalFunctionReference(path, callback)) {\n state._ftMemoizedHandlers.add(declaratorPath.node);\n return true;\n }\n\n const elementPath = path.parentPath?.parentPath;\n const metadataAtMemoDefinition =\n metadata.getContent &&\n elementPath?.isJSXElement() &&\n !isContentVisibleFromScope(\n t,\n elementPath,\n metadata.component,\n initPath.scope\n )\n ? { ...metadata, getContent: null }\n : metadata;\n\n callbackPath.replaceWith(\n buildHandlerWrapper(\n t,\n callback,\n metadataAtMemoDefinition,\n state,\n callbackPath.scope,\n memoizationName === 'useMemo' ? 'delayed' : mode,\n actionType\n )\n );\n state._ftMemoizedHandlers.add(declaratorPath.node);\n state._ftHasWrappedAction = true;\n return true;\n}\n"],"mappings":";;;;;;AAOA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AARA;AACA;AACA;AACA;;AAOA,SAASE,kBAAkBA,CACzBC,CAAqB,EACrBC,MAAkE,EACnD;EACf,IAAID,CAAC,CAACE,YAAY,CAACD,MAAM,CAAC,EAAE;IAC1B,OAAOA,MAAM,CAACE,IAAI;EACpB;EACA,IAAIH,CAAC,CAACI,kBAAkB,CAACH,MAAM,CAAC,IAAID,CAAC,CAACE,YAAY,CAACD,MAAM,CAACI,QAAQ,CAAC,EAAE;IACnE,OAAOJ,MAAM,CAACI,QAAQ,CAACF,IAA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AAU,IACnBH,WAAW,aAAXA,WAAW,eAAXA,WAAW,CAAEI,YAAY,CAAC,CAAC,IAC3B,CAAC,IAAAC,kCAAyB,EACxBhD,CAAC,EACD2C,WAAW,EACXrB,QAAQ,CAAC2B,SAAS,EAClBrB,QAAQ,CAACZ,KACX,CAAC,GACG;IAAE,GAAGM,QAAQ;IAAEwB,UAAU,EAAE;EAAK,CAAC,GACjCxB,QAAQ;EAEde,YAAY,CAACa,WAAW,CACtB,IAAAC,wBAAmB,EACjBnD,CAAC,EACDuC,QAAQ,EACRM,wBAAwB,EACxBtB,KAAK,EACLc,YAAY,CAACrB,KAAK,EAClBe,eAAe,KAAK,SAAS,GAAG,SAAS,GAAGP,IAAI,EAChDC,UACF,CACF,CAAC;EACDF,KAAK,CAACW,mBAAmB,CAACQ,GAAG,CAACf,cAAc,CAACK,IAAI,CAAC;EAClDT,KAAK,CAAC6B,mBAAmB,GAAG,IAAI;EAChC,OAAO,IAAI;AACb","ignoreList":[]}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.buildMetadata = buildMetadata;
7
+ exports.buildTargetObject = buildTargetObject;
8
+ var _constants = require("../../constants");
9
+ var _jsx = require("../../utils/jsx");
10
+ var _content = require("./content");
11
+ /*
12
+ * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel
13
+ * interaction tracking implementation, licensed under Apache-2.0.
14
+ */
15
+
16
+ function collectStaticActionNames(t, path, customAttribute) {
17
+ const values = {
18
+ actionNames: [],
19
+ customActionNames: [],
20
+ accessibilityLabels: []
21
+ };
22
+ path.traverse({
23
+ JSXAttribute(attributePath) {
24
+ if (!t.isStringLiteral(attributePath.node.value)) {
25
+ return;
26
+ }
27
+ const name = (0, _jsx.getNodeName)(t, attributePath.node.name);
28
+ const field = name === _constants.ACTION_NAME_ATTRIBUTE ? values.actionNames : name === 'accessibilityLabel' ? values.accessibilityLabels : name === customAttribute ? values.customActionNames : null;
29
+ if (field) {
30
+ field.push(t.cloneNode(attributePath.node.value, true));
31
+ }
32
+ }
33
+ });
34
+ return values;
35
+ }
36
+ function buildMetadata(t, path, componentName, component, options, state) {
37
+ const names = collectStaticActionNames(t, path, options.actionNameAttribute);
38
+ const hasStaticName = Object.values(names).some(values => values.some(value => value.value.trim().length > 0));
39
+ return {
40
+ ...names,
41
+ component,
42
+ componentName,
43
+ getContent: hasStaticName ? null : (0, _content.buildContentGetter)(t, path, component, state)
44
+ };
45
+ }
46
+ function buildTargetObject(t, metadata, handlerArgsIdentifier, state) {
47
+ const properties = [t.objectProperty(t.identifier('options'), t.objectExpression([t.objectProperty(t.identifier('useContent'), t.booleanLiteral(metadata.component.useContent)), t.objectProperty(t.identifier('useNamePrefix'), t.booleanLiteral(metadata.component.useNamePrefix))])), t.objectProperty(t.identifier('handlerArgs'), t.cloneNode(handlerArgsIdentifier)), t.objectProperty(t.identifier('componentName'), t.stringLiteral(metadata.componentName))];
48
+ if (metadata.actionNames.length > 0) {
49
+ properties.push(t.objectProperty(t.stringLiteral(_constants.ACTION_NAME_ATTRIBUTE), t.arrayExpression(metadata.actionNames.map(value => t.cloneNode(value, true)))));
50
+ }
51
+ if (metadata.customActionNames.length > 0) {
52
+ properties.push(t.objectProperty(t.identifier('customActionName'), t.arrayExpression(metadata.customActionNames.map(value => t.cloneNode(value, true)))));
53
+ }
54
+ if (metadata.accessibilityLabels.length > 0) {
55
+ properties.push(t.objectProperty(t.identifier('accessibilityLabel'), t.arrayExpression(metadata.accessibilityLabels.map(value => t.cloneNode(value, true)))));
56
+ }
57
+ if (metadata.getContent) {
58
+ state._ftNeedsContentRuntime = true;
59
+ properties.push(t.objectProperty(t.identifier('getContent'), t.cloneNode(metadata.getContent, true)));
60
+ }
61
+ return t.objectExpression(properties);
62
+ }
63
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_constants","require","_jsx","_content","collectStaticActionNames","t","path","customAttribute","values","actionNames","customActionNames","accessibilityLabels","traverse","JSXAttribute","attributePath","isStringLiteral","node","value","name","getNodeName","field","ACTION_NAME_ATTRIBUTE","push","cloneNode","buildMetadata","componentName","component","options","state","names","actionNameAttribute","hasStaticName","Object","some","trim","length","getContent","buildContentGetter","buildTargetObject","metadata","handlerArgsIdentifier","properties","objectProperty","identifier","objectExpression","booleanLiteral","useContent","useNamePrefix","stringLiteral","arrayExpression","map","_ftNeedsContentRuntime"],"sources":["metadata.ts"],"sourcesContent":["/*\n * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel\n * interaction tracking implementation, licensed under Apache-2.0.\n */\n\nimport type * as Babel from '@babel/core';\nimport { ACTION_NAME_ATTRIBUTE } from '../../constants';\nimport type {\n ActionMetadata,\n NormalizedPluginOptions,\n PluginState,\n TrackedComponentData,\n} from '../../types';\nimport { getNodeName } from '../../utils/jsx';\nimport { buildContentGetter } from './content';\n\nfunction collectStaticActionNames(\n t: typeof Babel.types,\n path: Babel.NodePath<Babel.types.JSXElement>,\n customAttribute: string | undefined\n): Pick<\n ActionMetadata,\n 'actionNames' | 'customActionNames' | 'accessibilityLabels'\n> {\n const values: Pick<\n ActionMetadata,\n 'actionNames' | 'customActionNames' | 'accessibilityLabels'\n > = {\n actionNames: [],\n customActionNames: [],\n accessibilityLabels: [],\n };\n path.traverse({\n JSXAttribute(attributePath) {\n if (!t.isStringLiteral(attributePath.node.value)) {\n return;\n }\n const name = getNodeName(t, attributePath.node.name);\n const field =\n name === ACTION_NAME_ATTRIBUTE\n ? values.actionNames\n : name === 'accessibilityLabel'\n ? values.accessibilityLabels\n : name === customAttribute\n ? values.customActionNames\n : null;\n if (field) {\n field.push(t.cloneNode(attributePath.node.value, true));\n }\n },\n });\n return values;\n}\n\nexport function buildMetadata(\n t: typeof Babel.types,\n path: Babel.NodePath<Babel.types.JSXElement>,\n componentName: string,\n component: TrackedComponentData,\n options: NormalizedPluginOptions,\n state: PluginState\n): ActionMetadata {\n const names = collectStaticActionNames(t, path, options.actionNameAttribute);\n const hasStaticName = Object.values(names).some((values) =>\n values.some((value) => value.value.trim().length > 0)\n );\n return {\n ...names,\n component,\n componentName,\n getContent: hasStaticName\n ? null\n : buildContentGetter(t, path, component, state),\n };\n}\n\nexport function buildTargetObject(\n t: typeof Babel.types,\n metadata: ActionMetadata,\n handlerArgsIdentifier: Babel.types.Identifier,\n state: PluginState\n): Babel.types.ObjectExpression {\n const properties: Babel.types.ObjectProperty[] = [\n t.objectProperty(\n t.identifier('options'),\n t.objectExpression([\n t.objectProperty(\n t.identifier('useContent'),\n t.booleanLiteral(metadata.component.useContent)\n ),\n t.objectProperty(\n t.identifier('useNamePrefix'),\n t.booleanLiteral(metadata.component.useNamePrefix)\n ),\n ])\n ),\n t.objectProperty(\n t.identifier('handlerArgs'),\n t.cloneNode(handlerArgsIdentifier)\n ),\n t.objectProperty(\n t.identifier('componentName'),\n t.stringLiteral(metadata.componentName)\n ),\n ];\n\n if (metadata.actionNames.length > 0) {\n properties.push(\n t.objectProperty(\n t.stringLiteral(ACTION_NAME_ATTRIBUTE),\n t.arrayExpression(\n metadata.actionNames.map((value) => t.cloneNode(value, true))\n )\n )\n );\n }\n if (metadata.customActionNames.length > 0) {\n properties.push(\n t.objectProperty(\n t.identifier('customActionName'),\n t.arrayExpression(\n metadata.customActionNames.map((value) => t.cloneNode(value, true))\n )\n )\n );\n }\n if (metadata.accessibilityLabels.length > 0) {\n properties.push(\n t.objectProperty(\n t.identifier('accessibilityLabel'),\n t.arrayExpression(\n metadata.accessibilityLabels.map((value) => t.cloneNode(value, true))\n )\n )\n );\n }\n if (metadata.getContent) {\n state._ftNeedsContentRuntime = true;\n properties.push(\n t.objectProperty(\n t.identifier('getContent'),\n t.cloneNode(metadata.getContent, true)\n )\n );\n }\n return t.objectExpression(properties);\n}\n"],"mappings":";;;;;;;AAMA,IAAAA,UAAA,GAAAC,OAAA;AAOA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AA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true
5
+ });
6
+ exports.buildGuardedHandlerWrapper = buildGuardedHandlerWrapper;
7
+ exports.buildHandlerWrapper = buildHandlerWrapper;
8
+ var _metadata = require("./metadata");
9
+ /*
10
+ * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel
11
+ * interaction tracking implementation, licensed under Apache-2.0.
12
+ */
13
+
14
+ const DEFAULT_ACTION_TYPE = 'click';
15
+ function normalizeActionType(actionType) {
16
+ return typeof actionType === 'string' && actionType.trim() ? actionType.trim() : DEFAULT_ACTION_TYPE;
17
+ }
18
+ function buildOriginalInvocation(t, originalExpression, argsIdentifier) {
19
+ return t.optionalCallExpression(t.cloneNode(originalExpression, true), [t.spreadElement(t.cloneNode(argsIdentifier))], true);
20
+ }
21
+ function buildImmediateHandlerWrapper(t, originalExpression, metadata, state, scope, actionType) {
22
+ const handlerArgsIdentifier = scope.generateUidIdentifier('ftHandlerArgs');
23
+ const originalArgsIdentifier = scope.generateUidIdentifier('ftOriginalArgs');
24
+ const originalInvoker = t.arrowFunctionExpression([t.restElement(originalArgsIdentifier)], buildOriginalInvocation(t, originalExpression, originalArgsIdentifier));
25
+ const instanceCall = t.callExpression(t.memberExpression(t.cloneNode(state._ftTrackingIdentifier), t.identifier('getInstance')), []);
26
+ const wrappedHandler = t.callExpression(t.memberExpression(instanceCall, t.identifier('wrapRumAction')), [originalInvoker, t.stringLiteral(normalizeActionType(actionType)), (0, _metadata.buildTargetObject)(t, metadata, handlerArgsIdentifier, state)]);
27
+ return t.arrowFunctionExpression([t.restElement(handlerArgsIdentifier)], t.callExpression(wrappedHandler, [t.spreadElement(t.cloneNode(handlerArgsIdentifier))]));
28
+ }
29
+
30
+ /** Wraps a handler, or a handler factory when delayed mode is configured. */
31
+ function buildHandlerWrapper(t, originalExpression, metadata, state, scope, mode = 'default', actionType) {
32
+ if (mode !== 'delayed') {
33
+ return buildImmediateHandlerWrapper(t, originalExpression, metadata, state, scope, actionType);
34
+ }
35
+ const factoryArgsIdentifier = scope.generateUidIdentifier('ftFactoryArgs');
36
+ const handlerIdentifier = scope.generateUidIdentifier('ftDelayedHandler');
37
+ return t.arrowFunctionExpression([t.restElement(factoryArgsIdentifier)], t.blockStatement([t.variableDeclaration('const', [t.variableDeclarator(handlerIdentifier, buildOriginalInvocation(t, originalExpression, factoryArgsIdentifier))]), t.returnStatement(buildImmediateHandlerWrapper(t, handlerIdentifier, metadata, state, scope, actionType))]));
38
+ }
39
+
40
+ /** Resolves a conditional handler once at render time, preserving non-functions. */
41
+ function buildGuardedHandlerWrapper(t, originalExpression, metadata, state, scope, mode = 'default', actionType) {
42
+ const resolvedHandlerIdentifier = scope.generateUidIdentifier('ftResolvedHandler');
43
+ return t.callExpression(t.arrowFunctionExpression([resolvedHandlerIdentifier], t.conditionalExpression(t.binaryExpression('===', t.unaryExpression('typeof', t.cloneNode(resolvedHandlerIdentifier)), t.stringLiteral('function')), buildHandlerWrapper(t, resolvedHandlerIdentifier, metadata, state, scope, mode, actionType), t.cloneNode(resolvedHandlerIdentifier))), [t.cloneNode(originalExpression, true)]);
44
+ }
45
+ //# sourceMappingURL=tap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_metadata","require","DEFAULT_ACTION_TYPE","normalizeActionType","actionType","trim","buildOriginalInvocation","t","originalExpression","argsIdentifier","optionalCallExpression","cloneNode","spreadElement","buildImmediateHandlerWrapper","metadata","state","scope","handlerArgsIdentifier","generateUidIdentifier","originalArgsIdentifier","originalInvoker","arrowFunctionExpression","restElement","instanceCall","callExpression","memberExpression","_ftTrackingIdentifier","identifier","wrappedHandler","stringLiteral","buildTargetObject","buildHandlerWrapper","mode","factoryArgsIdentifier","handlerIdentifier","blockStatement","variableDeclaration","variableDeclarator","returnStatement","buildGuardedHandlerWrapper","resolvedHandlerIdentifier","conditionalExpression","binaryExpression","unaryExpression"],"sources":["tap.ts"],"sourcesContent":["/*\n * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel\n * interaction tracking implementation, licensed under Apache-2.0.\n */\n\nimport type * as Babel from '@babel/core';\nimport type { ActionMetadata, PluginState, TrackedHandler } from '../../types';\nimport { buildTargetObject } from './metadata';\n\nconst DEFAULT_ACTION_TYPE = 'click';\n\nfunction normalizeActionType(actionType: TrackedHandler['actionType']): string {\n return typeof actionType === 'string' && actionType.trim()\n ? actionType.trim()\n : DEFAULT_ACTION_TYPE;\n}\n\nfunction buildOriginalInvocation(\n t: typeof Babel.types,\n originalExpression: Babel.types.Expression,\n argsIdentifier: Babel.types.Identifier\n): Babel.types.OptionalCallExpression {\n return t.optionalCallExpression(\n t.cloneNode(originalExpression, true),\n [t.spreadElement(t.cloneNode(argsIdentifier))],\n true\n );\n}\n\nfunction buildImmediateHandlerWrapper(\n t: typeof Babel.types,\n originalExpression: Babel.types.Expression,\n metadata: ActionMetadata,\n state: PluginState,\n scope: Babel.NodePath['scope'],\n actionType: TrackedHandler['actionType']\n): Babel.types.ArrowFunctionExpression {\n const handlerArgsIdentifier = scope.generateUidIdentifier('ftHandlerArgs');\n const originalArgsIdentifier = scope.generateUidIdentifier('ftOriginalArgs');\n const originalInvoker = t.arrowFunctionExpression(\n [t.restElement(originalArgsIdentifier)],\n buildOriginalInvocation(t, originalExpression, originalArgsIdentifier)\n );\n const instanceCall = t.callExpression(\n t.memberExpression(\n t.cloneNode(state._ftTrackingIdentifier),\n t.identifier('getInstance')\n ),\n []\n );\n const wrappedHandler = t.callExpression(\n t.memberExpression(instanceCall, t.identifier('wrapRumAction')),\n [\n originalInvoker,\n t.stringLiteral(normalizeActionType(actionType)),\n buildTargetObject(t, metadata, handlerArgsIdentifier, state),\n ]\n );\n return t.arrowFunctionExpression(\n [t.restElement(handlerArgsIdentifier)],\n t.callExpression(wrappedHandler, [\n t.spreadElement(t.cloneNode(handlerArgsIdentifier)),\n ])\n );\n}\n\n/** Wraps a handler, or a handler factory when delayed mode is configured. */\nexport function buildHandlerWrapper(\n t: typeof Babel.types,\n originalExpression: Babel.types.Expression,\n metadata: ActionMetadata,\n state: PluginState,\n scope: Babel.NodePath['scope'],\n mode: TrackedHandler['mode'] = 'default',\n actionType?: TrackedHandler['actionType']\n): Babel.types.ArrowFunctionExpression {\n if (mode !== 'delayed') {\n return buildImmediateHandlerWrapper(\n t,\n originalExpression,\n metadata,\n state,\n scope,\n actionType\n );\n }\n\n const factoryArgsIdentifier = scope.generateUidIdentifier('ftFactoryArgs');\n const handlerIdentifier = scope.generateUidIdentifier('ftDelayedHandler');\n return t.arrowFunctionExpression(\n [t.restElement(factoryArgsIdentifier)],\n t.blockStatement([\n t.variableDeclaration('const', [\n t.variableDeclarator(\n handlerIdentifier,\n buildOriginalInvocation(t, originalExpression, factoryArgsIdentifier)\n ),\n ]),\n t.returnStatement(\n buildImmediateHandlerWrapper(\n t,\n handlerIdentifier,\n metadata,\n state,\n scope,\n actionType\n )\n ),\n ])\n );\n}\n\n/** Resolves a conditional handler once at render time, preserving non-functions. */\nexport function buildGuardedHandlerWrapper(\n t: typeof Babel.types,\n originalExpression: Babel.types.Expression,\n metadata: ActionMetadata,\n state: PluginState,\n scope: Babel.NodePath['scope'],\n mode: TrackedHandler['mode'] = 'default',\n actionType?: TrackedHandler['actionType']\n): Babel.types.CallExpression {\n const resolvedHandlerIdentifier =\n scope.generateUidIdentifier('ftResolvedHandler');\n return t.callExpression(\n t.arrowFunctionExpression(\n [resolvedHandlerIdentifier],\n t.conditionalExpression(\n t.binaryExpression(\n '===',\n t.unaryExpression('typeof', t.cloneNode(resolvedHandlerIdentifier)),\n t.stringLiteral('function')\n ),\n buildHandlerWrapper(\n t,\n resolvedHandlerIdentifier,\n metadata,\n state,\n scope,\n mode,\n actionType\n ),\n t.cloneNode(resolvedHandlerIdentifier)\n )\n ),\n [t.cloneNode(originalExpression, true)]\n );\n}\n"],"mappings":";;;;;;;AAOA,IAAAA,SAAA,GAAAC,OAAA;AAPA;AACA;AACA;AACA;;AAMA,MAAMC,mBAAmB,GAAG,OAAO;AAEnC,SAASC,mBAAmBA,CAACC,UAAwC,EAAU;EAC7E,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ACLZ,UACF,CACF,CAAC,CACF,CACH,CAAC;AACH;;AAEA;AACO,SAASmC,0BAA0BA,CACxChC,CAAqB,EACrBC,kBAA0C,EAC1CM,QAAwB,EACxBC,KAAkB,EAClBC,KAA8B,EAC9BgB,IAA4B,GAAG,SAAS,EACxC5B,UAAyC,EACb;EAC5B,MAAMoC,yBAAyB,GAC7BxB,KAAK,CAACE,qBAAqB,CAAC,mBAAmB,CAAC;EAClD,OAAOX,CAAC,CAACiB,cAAc,CACrBjB,CAAC,CAACc,uBAAuB,CACvB,CAACmB,yBAAyB,CAAC,EAC3BjC,CAAC,CAACkC,qBAAqB,CACrBlC,CAAC,CAACmC,gBAAgB,CAChB,KAAK,EACLnC,CAAC,CAACoC,eAAe,CAAC,QAAQ,EAAEpC,CAAC,CAACI,SAAS,CAAC6B,yBAAyB,CAAC,CAAC,EACnEjC,CAAC,CAACsB,aAAa,CAAC,UAAU,CAC5B,CAAC,EACDE,mBAAmB,CACjBxB,CAAC,EACDiC,yBAAyB,EACzB1B,QAAQ,EACRC,KAAK,EACLC,KAAK,EACLgB,IAAI,EACJ5B,UACF,CAAC,EACDG,CAAC,CAACI,SAAS,CAAC6B,yBAAyB,CACvC,CACF,CAAC,EACD,CAACjC,CAAC,CAACI,SAAS,CAACH,kBAAkB,EAAE,IAAI,CAAC,CACxC,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RUNTIME_PACKAGE = exports.PLUGIN_ENABLED_FLAG = exports.NATIVE_COMPONENT_HANDLERS = exports.ACTION_NAME_ATTRIBUTE = void 0;
7
+ /*
8
+ * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel
9
+ * interaction tracking implementation, licensed under Apache-2.0.
10
+ */
11
+
12
+ const RUNTIME_PACKAGE = exports.RUNTIME_PACKAGE = '@truewatchtech/react-native-mobile';
13
+ const ACTION_NAME_ATTRIBUTE = exports.ACTION_NAME_ATTRIBUTE = 'ft-action-name';
14
+ const PLUGIN_ENABLED_FLAG = exports.PLUGIN_ENABLED_FLAG = '__FT_RN_BABEL_PLUGIN_ENABLED__';
15
+ const NATIVE_COMPONENT_HANDLERS = exports.NATIVE_COMPONENT_HANDLERS = {
16
+ Button: ['onPress'],
17
+ Pressable: ['onPress', 'onLongPress'],
18
+ TouchableOpacity: ['onPress'],
19
+ TouchableHighlight: ['onPress'],
20
+ TouchableWithoutFeedback: ['onPress'],
21
+ TouchableNativeFeedback: ['onPress'],
22
+ Switch: ['onValueChange'],
23
+ TextInput: ['onFocus']
24
+ };
25
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["RUNTIME_PACKAGE","exports","ACTION_NAME_ATTRIBUTE","PLUGIN_ENABLED_FLAG","NATIVE_COMPONENT_HANDLERS","Button","Pressable","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","TouchableNativeFeedback","Switch","TextInput"],"sources":["constants.ts"],"sourcesContent":["/*\n * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel\n * interaction tracking implementation, licensed under Apache-2.0.\n */\n\nexport const RUNTIME_PACKAGE = '@truewatchtech/react-native-mobile';\n\nexport const ACTION_NAME_ATTRIBUTE = 'ft-action-name';\n\nexport const PLUGIN_ENABLED_FLAG = '__FT_RN_BABEL_PLUGIN_ENABLED__';\n\nexport const NATIVE_COMPONENT_HANDLERS: Record<string, string[]> = {\n Button: ['onPress'],\n Pressable: ['onPress', 'onLongPress'],\n TouchableOpacity: ['onPress'],\n TouchableHighlight: ['onPress'],\n TouchableWithoutFeedback: ['onPress'],\n TouchableNativeFeedback: ['onPress'],\n Switch: ['onValueChange'],\n TextInput: ['onFocus'],\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;;AAEO,MAAMA,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG,oCAAoC;AAE5D,MAAME,qBAAqB,GAAAD,OAAA,CAAAC,qBAAA,GAAG,gBAAgB;AAE9C,MAAMC,mBAAmB,GAAAF,OAAA,CAAAE,mBAAA,GAAG,gCAAgC;AAE5D,MAAMC,yBAAmD,GAAAH,OAAA,CAAAG,yBAAA,GAAG;EACjEC,MAAM,EAAE,CAAC,SAAS,CAAC;EACnBC,SAAS,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC;EACrCC,gBAAgB,EAAE,CAAC,SAAS,CAAC;EAC7BC,kBAAkB,EAAE,CAAC,SAAS,CAAC;EAC/BC,wBAAwB,EAAE,CAAC,SAAS,CAAC;EACrCC,uBAAuB,EAAE,CAAC,SAAS,CAAC;EACpCC,MAAM,EAAE,CAAC,eAAe,CAAC;EACzBC,SAAS,EAAE,CAAC,SAAS;AACvB,CAAC","ignoreList":[]}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _helperPluginUtils = require("@babel/helper-plugin-utils");
8
+ var _global = require("./actions/global");
9
+ var _rum = require("./actions/rum");
10
+ var _options = require("./options");
11
+ var _state = require("./state");
12
+ /*
13
+ * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel
14
+ * interaction tracking implementation, licensed under Apache-2.0.
15
+ */
16
+
17
+ const plugin = (0, _helperPluginUtils.declare)((api, rawOptions) => {
18
+ api.assertVersion(7);
19
+ const t = api.types;
20
+ const options = (0, _options.mergeOptions)(rawOptions);
21
+ return {
22
+ name: 'truewatch-react-native-action-name',
23
+ visitor: {
24
+ Program: {
25
+ enter(programPath, state) {
26
+ state._ftSkip = (0, _state.isSkippedFile)(state);
27
+ if (state._ftSkip) {
28
+ return;
29
+ }
30
+ (0, _state.initializePluginState)(t, programPath, state, options);
31
+ (0, _global.insertPluginEnabledFlag)(t, programPath);
32
+ },
33
+ exit(programPath, state) {
34
+ if (!state._ftSkip) {
35
+ (0, _rum.insertRuntimeImports)(t, programPath, state);
36
+ }
37
+ }
38
+ },
39
+ JSXElement(path, state) {
40
+ if (!state._ftSkip) {
41
+ (0, _rum.handleJSXElement)(t, path, state, options);
42
+ }
43
+ }
44
+ }
45
+ };
46
+ });
47
+ var _default = exports.default = plugin;
48
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_helperPluginUtils","require","_global","_rum","_options","_state","plugin","declare","api","rawOptions","assertVersion","t","types","options","mergeOptions","name","visitor","Program","enter","programPath","state","_ftSkip","isSkippedFile","initializePluginState","insertPluginEnabledFlag","exit","insertRuntimeImports","JSXElement","path","handleJSXElement","_default","exports","default"],"sources":["index.ts"],"sourcesContent":["/*\n * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel\n * interaction tracking implementation, licensed under Apache-2.0.\n */\n\nimport type * as Babel from '@babel/core';\nimport { declare } from '@babel/helper-plugin-utils';\nimport { insertPluginEnabledFlag } from './actions/global';\nimport { handleJSXElement, insertRuntimeImports } from './actions/rum';\nimport { mergeOptions } from './options';\nimport { initializePluginState, isSkippedFile } from './state';\nimport type { PluginAPI, PluginOptions, PluginState } from './types';\n\nexport type { PluginOptions, TrackedComponent, TrackedHandler } from './types';\n\nconst plugin = declare(\n (api: PluginAPI, rawOptions: PluginOptions): Babel.PluginObj<PluginState> => {\n api.assertVersion(7);\n const t = api.types;\n const options = mergeOptions(rawOptions);\n\n return {\n name: 'truewatch-react-native-action-name',\n visitor: {\n Program: {\n enter(programPath, state) {\n state._ftSkip = isSkippedFile(state);\n if (state._ftSkip) {\n return;\n }\n initializePluginState(t, programPath, state, options);\n insertPluginEnabledFlag(t, programPath);\n },\n exit(programPath, state) {\n if (!state._ftSkip) {\n insertRuntimeImports(t, programPath, state);\n }\n },\n },\n JSXElement(path, state) {\n if (!state._ftSkip) {\n handleJSXElement(t, path, state, options);\n }\n },\n },\n };\n }\n);\n\nexport default plugin;\n"],"mappings":";;;;;;AAMA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE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Module", {
4
+ value: true
5
+ });
6
+ exports.mergeOptions = mergeOptions;
7
+ /*
8
+ * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel
9
+ * interaction tracking implementation, licensed under Apache-2.0.
10
+ */
11
+
12
+ function mergeOptions(options = {}) {
13
+ const componentOptions = options.components || {};
14
+ return {
15
+ actionNameAttribute: options.actionNameAttribute,
16
+ components: {
17
+ tracked: componentOptions.tracked || [],
18
+ useContent: componentOptions.useContent === undefined ? true : componentOptions.useContent,
19
+ useNamePrefix: componentOptions.useNamePrefix === undefined ? true : componentOptions.useNamePrefix
20
+ }
21
+ };
22
+ }
23
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["mergeOptions","options","componentOptions","components","actionNameAttribute","tracked","useContent","undefined","useNamePrefix"],"sources":["options.ts"],"sourcesContent":["/*\n * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel\n * interaction tracking implementation, licensed under Apache-2.0.\n */\n\nimport type { NormalizedPluginOptions, PluginOptions } from './types';\n\nexport function mergeOptions(\n options: PluginOptions = {}\n): NormalizedPluginOptions {\n const componentOptions = options.components || {};\n return {\n actionNameAttribute: options.actionNameAttribute,\n components: {\n tracked: componentOptions.tracked || [],\n useContent:\n componentOptions.useContent === undefined\n ? true\n : componentOptions.useContent,\n useNamePrefix:\n componentOptions.useNamePrefix === undefined\n ? true\n : componentOptions.useNamePrefix,\n },\n };\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;;AAIO,SAASA,YAAYA,CAC1BC,OAAsB,GAAG,CAAC,CAAC,EACF;EACzB,MAAMC,gBAAgB,GAAGD,OAAO,CAACE,UAAU,IAAI,CAAC,CAAC;EACjD,OAAO;IACLC,mBAAmB,EAAEH,OAAO,CAACG,mBAAmB;IAChDD,UAAU,EAAE;MACVE,OAAO,EAAEH,gBAAgB,CAACG,OAAO,IAAI,EAAE;MACvCC,UAAU,EACRJ,gBAAgB,CAACI,UAAU,KAAKC,SAAS,GACrC,IAAI,GACJL,gBAAgB,CAACI,UAAU;MACjCE,aAAa,EACXN,gBAAgB,CAACM,aAAa,KAAKD,SAAS,GACxC,IAAI,GACJL,gBAAgB,CAACM;IACzB;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.initializePluginState = initializePluginState;
7
+ exports.isSkippedFile = isSkippedFile;
8
+ var _components = require("./actions/rum/components");
9
+ /*
10
+ * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel
11
+ * interaction tracking implementation, licensed under Apache-2.0.
12
+ */
13
+
14
+ function isSkippedFile(state) {
15
+ var _state$file, _state$file2;
16
+ const caller = (_state$file = state.file) === null || _state$file === void 0 || (_state$file = _state$file.opts) === null || _state$file === void 0 ? void 0 : _state$file.caller;
17
+ const filename = state.filename || ((_state$file2 = state.file) === null || _state$file2 === void 0 || (_state$file2 = _state$file2.opts) === null || _state$file2 === void 0 ? void 0 : _state$file2.filename);
18
+ return (caller === null || caller === void 0 ? void 0 : caller.platform) === 'web' || Boolean(filename && filename.includes('node_modules'));
19
+ }
20
+
21
+ /** Initializes per-file state; identifiers and memoization never leak across files. */
22
+ function initializePluginState(t, programPath, state, options) {
23
+ state._ftTrackedComponents = (0, _components.createTrackedComponents)(t, programPath, options);
24
+ state._ftCustomNames = new Set(options.components.tracked.map(component => component.name));
25
+ state._ftMemoizedHandlers = new Set();
26
+ state._ftHasWrappedAction = false;
27
+ state._ftNeedsContentRuntime = false;
28
+ state._ftExtractTextIdentifier = programPath.scope.generateUidIdentifier('ftExtractText');
29
+ state._ftReactIdentifier = programPath.scope.generateUidIdentifier('FTReact');
30
+ state._ftTrackingIdentifier = programPath.scope.generateUidIdentifier('FTBabelInteractionTracking');
31
+ }
32
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_components","require","isSkippedFile","state","_state$file","_state$file2","caller","file","opts","filename","platform","Boolean","includes","initializePluginState","t","programPath","options","_ftTrackedComponents","createTrackedComponents","_ftCustomNames","Set","components","tracked","map","component","name","_ftMemoizedHandlers","_ftHasWrappedAction","_ftNeedsContentRuntime","_ftExtractTextIdentifier","scope","generateUidIdentifier","_ftReactIdentifier","_ftTrackingIdentifier"],"sources":["state.ts"],"sourcesContent":["/*\n * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel\n * interaction tracking implementation, licensed under Apache-2.0.\n */\n\nimport type * as Babel from '@babel/core';\nimport { createTrackedComponents } from './actions/rum/components';\nimport type { NormalizedPluginOptions, PluginState } from './types';\n\nexport function isSkippedFile(state: PluginState): boolean {\n const caller = state.file?.opts?.caller as { platform?: string } | undefined;\n const filename = state.filename || state.file?.opts?.filename;\n return (\n caller?.platform === 'web' ||\n Boolean(filename && filename.includes('node_modules'))\n );\n}\n\n/** Initializes per-file state; identifiers and memoization never leak across files. */\nexport function initializePluginState(\n t: typeof Babel.types,\n programPath: Babel.NodePath<Babel.types.Program>,\n state: PluginState,\n options: NormalizedPluginOptions\n): void {\n state._ftTrackedComponents = createTrackedComponents(t, programPath, options);\n state._ftCustomNames = new Set(\n options.components.tracked.map((component) => component.name)\n );\n state._ftMemoizedHandlers = new Set();\n state._ftHasWrappedAction = false;\n state._ftNeedsContentRuntime = false;\n state._ftExtractTextIdentifier =\n programPath.scope.generateUidIdentifier('ftExtractText');\n state._ftReactIdentifier = programPath.scope.generateUidIdentifier('FTReact');\n state._ftTrackingIdentifier = programPath.scope.generateUidIdentifier(\n 'FTBabelInteractionTracking'\n );\n}\n"],"mappings":";;;;;;;AAMA,IAAAA,WAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;;AAMO,SAASC,aAAaA,CAACC,KAAkB,EAAW;EAAA,IAAAC,WAAA,EAAAC,YAAA;EACzD,MAAMC,MAAM,IAAAF,WAAA,GAAGD,KAAK,CAACI,IAAI,cAAAH,WAAA,gBAAAA,WAAA,GAAVA,WAAA,CAAYI,IAAI,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", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["/*\n * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel\n * interaction tracking implementation, licensed under Apache-2.0.\n */\n\nimport type * as Babel from '@babel/core';\n\nexport type TrackedHandler = {\n event: string;\n actionType?: string;\n mode?: 'default' | 'delayed';\n};\n\nexport type TrackedComponent = {\n name: string;\n useContent?: boolean;\n useNamePrefix?: boolean;\n contentProp?: string;\n handlers: TrackedHandler[];\n};\n\nexport type PluginOptions = {\n actionNameAttribute?: string;\n components?: {\n useContent?: boolean;\n useNamePrefix?: boolean;\n tracked?: TrackedComponent[];\n };\n};\n\nexport type NormalizedPluginOptions = {\n actionNameAttribute?: string;\n components: {\n useContent: boolean;\n useNamePrefix: boolean;\n tracked: TrackedComponent[];\n };\n};\n\nexport type TrackedComponentData = Omit<TrackedComponent, 'name'> & {\n importedName?: string;\n isCustom: boolean;\n useContent: boolean;\n useNamePrefix: boolean;\n};\n\nexport type ActionMetadata = {\n accessibilityLabels: Babel.types.StringLiteral[];\n actionNames: Babel.types.StringLiteral[];\n component: TrackedComponentData;\n componentName: string;\n customActionNames: Babel.types.StringLiteral[];\n getContent: Babel.types.ArrowFunctionExpression | null;\n};\n\nexport type PluginState = Babel.PluginPass & {\n _ftCustomNames: Set<string>;\n _ftExtractTextIdentifier: Babel.types.Identifier;\n _ftHasWrappedAction: boolean;\n _ftMemoizedHandlers: Set<Babel.types.Node>;\n _ftNeedsContentRuntime: boolean;\n _ftReactIdentifier: Babel.types.Identifier;\n _ftSkip: boolean;\n _ftTrackedComponents: Record<string, TrackedComponentData>;\n _ftTrackingIdentifier: Babel.types.Identifier;\n};\n\nexport type PluginAPI = typeof Babel & Babel.ConfigAPI;\n\nexport type JSXAttributePath = Babel.NodePath<\n Babel.types.JSXAttribute | Babel.types.JSXSpreadAttribute\n>;\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getDirectAttributePaths = getDirectAttributePaths;
7
+ exports.getNodeName = getNodeName;
8
+ /*
9
+ * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel
10
+ * interaction tracking implementation, licensed under Apache-2.0.
11
+ */
12
+
13
+ function getNodeName(t, node) {
14
+ if (!node) {
15
+ return null;
16
+ }
17
+ if (t.isIdentifier(node) || t.isJSXIdentifier(node)) {
18
+ return node.name;
19
+ }
20
+ if (t.isStringLiteral(node)) {
21
+ return node.value;
22
+ }
23
+ if (t.isJSXNamespacedName(node)) {
24
+ return `${node.namespace.name}:${node.name.name}`;
25
+ }
26
+ if (t.isJSXMemberExpression(node)) {
27
+ let nodeName = node.property.name;
28
+ let nodeTracker = node.object;
29
+ while (t.isJSXMemberExpression(nodeTracker)) {
30
+ nodeName = `${nodeTracker.property.name}.${nodeName}`;
31
+ nodeTracker = nodeTracker.object;
32
+ }
33
+ return t.isJSXIdentifier(nodeTracker) ? `${nodeTracker.name}.${nodeName}` : null;
34
+ }
35
+ if ('name' in node && node.name && typeof node.name !== 'string') {
36
+ return getNodeName(t, node.name);
37
+ }
38
+ return null;
39
+ }
40
+ function getDirectAttributePaths(path) {
41
+ return path.get('openingElement.attributes');
42
+ }
43
+ //# sourceMappingURL=jsx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getNodeName","t","node","isIdentifier","isJSXIdentifier","name","isStringLiteral","value","isJSXNamespacedName","namespace","isJSXMemberExpression","nodeName","property","nodeTracker","object","getDirectAttributePaths","path","get"],"sources":["jsx.ts"],"sourcesContent":["/*\n * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel\n * interaction tracking implementation, licensed under Apache-2.0.\n */\n\nimport type * as Babel from '@babel/core';\nimport type { JSXAttributePath } from '../types';\n\nexport function getNodeName(\n t: typeof Babel.types,\n node: Babel.types.Node | null | undefined\n): string | null {\n if (!node) {\n return null;\n }\n if (t.isIdentifier(node) || t.isJSXIdentifier(node)) {\n return node.name;\n }\n if (t.isStringLiteral(node)) {\n return node.value;\n }\n if (t.isJSXNamespacedName(node)) {\n return `${node.namespace.name}:${node.name.name}`;\n }\n if (t.isJSXMemberExpression(node)) {\n let nodeName = node.property.name;\n let nodeTracker:\n | Babel.types.JSXIdentifier\n | Babel.types.JSXMemberExpression = node.object;\n\n while (t.isJSXMemberExpression(nodeTracker)) {\n nodeName = `${nodeTracker.property.name}.${nodeName}`;\n nodeTracker = nodeTracker.object;\n }\n\n return t.isJSXIdentifier(nodeTracker)\n ? `${nodeTracker.name}.${nodeName}`\n : null;\n }\n if ('name' in node && node.name && typeof node.name !== 'string') {\n return getNodeName(t, node.name);\n }\n return null;\n}\n\nexport function getDirectAttributePaths(\n path: Babel.NodePath<Babel.types.JSXElement>\n): JSXAttributePath[] {\n return path.get('openingElement.attributes') as JSXAttributePath[];\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;;AAKO,SAASA,WAAWA,CACzBC,CAAqB,EACrBC,IAAyC,EAC1B;EACf,IAAI,CAACA,IAAI,EAAE;IACT,OAAO,IAAI;EACb;EACA,IAAID,CAAC,CAACE,YAAY,CAACD,IAAI,CAAC,IAAID,CAAC,CAACG,eAAe,CAACF,IAAI,CAAC,EAAE;IACnD,OAAOA,IAAI,CAACG,IAAI;EAClB;EACA,IAAIJ,CAAC,CAACK,eAAe,CAACJ,IAAI,CAAC,EAAE;IAC3B,OAAOA,IAAI,CAACK,KAAK;EACnB;EACA,IAAIN,CAAC,CAACO,mBAAmB,CAACN,IAAI,CAAC,EAAE;IAC/B,OAAO,GAAGA,IAAI,CAACO,SAAS,CAACJ,IAAI,IAAIH,IAAI,CAACG,IAAI,CAACA,IAAI,EAAE;EACnD;EACA,IAAIJ,CAAC,CAACS,qBAAqB,CAACR,IAAI,CAAC,EAAE;IACjC,IAAIS,QAAQ,GAAGT,IAAI,CAACU,QAAQ,CAACP,IAAI;IACjC,IAAIQ,WAE+B,GAAGX,IAAI,CAACY,MAAM;IAEjD,OAAOb,CAAC,CAACS,qBAAqB,CAACG,WAAW,CAAC,EAAE;MAC3CF,QAAQ,GAAG,GAAGE,WAAW,CAACD,QAAQ,CAACP,IAAI,IAAIM,QAAQ,EAAE;MACrDE,WAAW,GAAGA,WAAW,CAACC,MAAM;IAClC;IAEA,OAAOb,CAAC,CAACG,eAAe,CAACS,WAAW,CAAC,GACjC,GAAGA,WAAW,CAACR,IAAI,IAAIM,QAAQ,EAAE,GACjC,IAAI;EACV;EACA,IAAI,MAAM,IAAIT,IAAI,IAAIA,IAAI,CAACG,IAAI,IAAI,OAAOH,IAAI,CAACG,IAAI,KAAK,QAAQ,EAAE;IAChE,OAAOL,WAAW,CAACC,CAAC,EAAEC,IAAI,CAACG,IAAI,CAAC;EAClC;EACA,OAAO,IAAI;AACb;AAEO,SAASU,uBAAuBA,CACrCC,IAA4C,EACxB;EACpB,OAAOA,IAAI,CAACC,GAAG,CAAC,2BAA2B,CAAC;AAC9C","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ /*
2
+ * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel
3
+ * interaction tracking implementation, licensed under Apache-2.0.
4
+ */
5
+
6
+ import { PLUGIN_ENABLED_FLAG } from '../constants';
7
+ export function insertPluginEnabledFlag(t, programPath) {
8
+ const createFlagAssignment = globalIdentifier => t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.cloneNode(globalIdentifier), t.identifier(PLUGIN_ENABLED_FLAG)), t.booleanLiteral(true)));
9
+ const globalThisIdentifier = t.identifier('globalThis');
10
+ const reactNativeGlobalIdentifier = t.identifier('global');
11
+ programPath.unshiftContainer('body', t.ifStatement(t.binaryExpression('!==', t.unaryExpression('typeof', t.cloneNode(globalThisIdentifier)), t.stringLiteral('undefined')), t.blockStatement([createFlagAssignment(globalThisIdentifier)]), t.ifStatement(t.binaryExpression('!==', t.unaryExpression('typeof', t.cloneNode(reactNativeGlobalIdentifier)), t.stringLiteral('undefined')), t.blockStatement([createFlagAssignment(reactNativeGlobalIdentifier)]))));
12
+ }
13
+ //# sourceMappingURL=global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PLUGIN_ENABLED_FLAG","insertPluginEnabledFlag","t","programPath","createFlagAssignment","globalIdentifier","expressionStatement","assignmentExpression","memberExpression","cloneNode","identifier","booleanLiteral","globalThisIdentifier","reactNativeGlobalIdentifier","unshiftContainer","ifStatement","binaryExpression","unaryExpression","stringLiteral","blockStatement"],"sources":["global.ts"],"sourcesContent":["/*\n * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel\n * interaction tracking implementation, licensed under Apache-2.0.\n */\n\nimport type * as Babel from '@babel/core';\nimport { PLUGIN_ENABLED_FLAG } from '../constants';\n\nexport function insertPluginEnabledFlag(\n t: typeof Babel.types,\n programPath: Babel.NodePath<Babel.types.Program>\n): void {\n const createFlagAssignment = (\n globalIdentifier: Babel.types.Identifier\n ): Babel.types.ExpressionStatement =>\n t.expressionStatement(\n t.assignmentExpression(\n '=',\n t.memberExpression(\n t.cloneNode(globalIdentifier),\n t.identifier(PLUGIN_ENABLED_FLAG)\n ),\n t.booleanLiteral(true)\n )\n );\n const globalThisIdentifier = t.identifier('globalThis');\n const reactNativeGlobalIdentifier = t.identifier('global');\n\n programPath.unshiftContainer(\n 'body',\n t.ifStatement(\n t.binaryExpression(\n '!==',\n t.unaryExpression('typeof', t.cloneNode(globalThisIdentifier)),\n t.stringLiteral('undefined')\n ),\n t.blockStatement([createFlagAssignment(globalThisIdentifier)]),\n t.ifStatement(\n t.binaryExpression(\n '!==',\n t.unaryExpression('typeof', t.cloneNode(reactNativeGlobalIdentifier)),\n t.stringLiteral('undefined')\n ),\n t.blockStatement([createFlagAssignment(reactNativeGlobalIdentifier)])\n )\n )\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;;AAGA,SAASA,mBAAmB,QAAQ,cAAc;AAElD,OAAO,SAASC,uBAAuBA,CACrCC,CAAqB,EACrBC,WAAgD,EAC1C;EACN,MAAMC,oBAAoB,GACxBC,gBAAwC,IAExCH,CAAC,CAACI,mBAAmB,CACnBJ,CAAC,CAACK,oBAAoB,CACpB,GAAG,EACHL,CAAC,CAACM,gBAAgB,CAChBN,CAAC,CAACO,SAAS,CAACJ,gBAAgB,CAAC,EAC7BH,CAAC,CAACQ,UAAU,CAACV,mBAAmB,CAClC,CAAC,EACDE,CAAC,CAACS,cAAc,CAAC,IAAI,CACvB,CACF,CAAC;EACH,MAAMC,oBAAoB,GAAGV,CAAC,CAACQ,UAAU,CAAC,YAAY,CAAC;EACvD,MAAMG,2BAA2B,GAAGX,CAAC,CAACQ,UAAU,CAAC,QAAQ,CAAC;EAE1DP,WAAW,CAACW,gBAAgB,CAC1B,MAAM,EACNZ,CAAC,CAACa,WAAW,CACXb,CAAC,CAACc,gBAAgB,CAChB,KAAK,EACLd,CAAC,CAACe,eAAe,CAAC,QAAQ,EAAEf,CAAC,CAACO,SAAS,CAACG,oBAAoB,CAAC,CAAC,EAC9DV,CAAC,CAACgB,aAAa,CAAC,WAAW,CAC7B,CAAC,EACDhB,CAAC,CAACiB,cAAc,CAAC,CAACf,oBAAoB,CAACQ,oBAAoB,CAAC,CAAC,CAAC,EAC9DV,CAAC,CAACa,WAAW,CACXb,CAAC,CAACc,gBAAgB,CAChB,KAAK,EACLd,CAAC,CAACe,eAAe,CAAC,QAAQ,EAAEf,CAAC,CAACO,SAAS,CAACI,2BAA2B,CAAC,CAAC,EACrEX,CAAC,CAACgB,aAAa,CAAC,WAAW,CAC7B,CAAC,EACDhB,CAAC,CAACiB,cAAc,CAAC,CAACf,oBAAoB,CAACS,2BAA2B,CAAC,CAAC,CACtE,CACF,CACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,73 @@
1
+ /*
2
+ * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel
3
+ * interaction tracking implementation, licensed under Apache-2.0.
4
+ */
5
+
6
+ import { NATIVE_COMPONENT_HANDLERS } from '../../constants';
7
+ import { getDirectAttributePaths, getNodeName } from '../../utils/jsx';
8
+ export function createTrackedComponents(t, programPath, options) {
9
+ const tracked = {};
10
+ for (const statement of programPath.node.body) {
11
+ if (!t.isImportDeclaration(statement) || statement.source.value !== 'react-native') {
12
+ continue;
13
+ }
14
+ for (const specifier of statement.specifiers) {
15
+ if (!t.isImportSpecifier(specifier)) {
16
+ continue;
17
+ }
18
+ const importedName = getNodeName(t, specifier.imported);
19
+ const localName = getNodeName(t, specifier.local);
20
+ const events = importedName ? NATIVE_COMPONENT_HANDLERS[importedName] : undefined;
21
+ if (!events || !importedName || !localName) {
22
+ continue;
23
+ }
24
+ tracked[localName] = {
25
+ handlers: events.map(event => ({
26
+ event
27
+ })),
28
+ importedName,
29
+ isCustom: false,
30
+ useContent: options.components.useContent,
31
+ useNamePrefix: options.components.useNamePrefix
32
+ };
33
+ }
34
+ }
35
+ for (const component of options.components.tracked) {
36
+ tracked[component.name] = {
37
+ ...(component.contentProp ? {
38
+ contentProp: component.contentProp
39
+ } : {}),
40
+ handlers: component.handlers || [],
41
+ isCustom: true,
42
+ useContent: component.useContent === undefined ? options.components.useContent : component.useContent,
43
+ useNamePrefix: component.useNamePrefix === undefined ? options.components.useNamePrefix : component.useNamePrefix
44
+ };
45
+ }
46
+ return tracked;
47
+ }
48
+ export function isInsideConfiguredComponent(t, path, customComponentNames) {
49
+ let current = path.parentPath;
50
+ while (current && !current.isProgram()) {
51
+ if (current.isFunctionDeclaration() || current.isClassDeclaration() || current.isVariableDeclarator()) {
52
+ const name = getNodeName(t, current.node.id);
53
+ if (name && customComponentNames.has(name)) {
54
+ return true;
55
+ }
56
+ }
57
+ current = current.parentPath;
58
+ }
59
+ return false;
60
+ }
61
+ export function addRequiredTextInputHandler(t, path, component, componentName) {
62
+ if (component.isCustom || component.importedName !== 'TextInput' || componentName !== 'TextInput') {
63
+ return;
64
+ }
65
+ const attributes = getDirectAttributePaths(path);
66
+ const hasSpread = attributes.some(attribute => attribute.isJSXSpreadAttribute());
67
+ const hasOnFocus = attributes.some(attribute => attribute.isJSXAttribute() && getNodeName(t, attribute.node.name) === 'onFocus');
68
+ if (!hasSpread && !hasOnFocus) {
69
+ const openingElementPath = path.get('openingElement');
70
+ openingElementPath.pushContainer('attributes', t.jsxAttribute(t.jsxIdentifier('onFocus'), t.jsxExpressionContainer(t.arrowFunctionExpression([], t.blockStatement([])))));
71
+ }
72
+ }
73
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NATIVE_COMPONENT_HANDLERS","getDirectAttributePaths","getNodeName","createTrackedComponents","t","programPath","options","tracked","statement","node","body","isImportDeclaration","source","value","specifier","specifiers","isImportSpecifier","importedName","imported","localName","local","events","undefined","handlers","map","event","isCustom","useContent","components","useNamePrefix","component","name","contentProp","isInsideConfiguredComponent","path","customComponentNames","current","parentPath","isProgram","isFunctionDeclaration","isClassDeclaration","isVariableDeclarator","id","has","addRequiredTextInputHandler","componentName","attributes","hasSpread","some","attribute","isJSXSpreadAttribute","hasOnFocus","isJSXAttribute","openingElementPath","get","pushContainer","jsxAttribute","jsxIdentifier","jsxExpressionContainer","arrowFunctionExpression","blockStatement"],"sources":["components.ts"],"sourcesContent":["/*\n * Portions of this file are adapted from Datadog's dd-sdk-reactnative Babel\n * interaction tracking implementation, licensed under Apache-2.0.\n */\n\nimport type * as Babel from '@babel/core';\nimport { NATIVE_COMPONENT_HANDLERS } from '../../constants';\nimport type {\n NormalizedPluginOptions,\n TrackedComponentData,\n} from '../../types';\nimport { getDirectAttributePaths, getNodeName } from '../../utils/jsx';\n\nexport function createTrackedComponents(\n t: typeof Babel.types,\n programPath: Babel.NodePath<Babel.types.Program>,\n options: NormalizedPluginOptions\n): Record<string, TrackedComponentData> {\n const tracked: Record<string, TrackedComponentData> = {};\n\n for (const statement of programPath.node.body) {\n if (\n !t.isImportDeclaration(statement) ||\n statement.source.value !== 'react-native'\n ) {\n continue;\n }\n\n for (const specifier of statement.specifiers) {\n if (!t.isImportSpecifier(specifier)) {\n continue;\n }\n const importedName = getNodeName(t, specifier.imported);\n const localName = getNodeName(t, specifier.local);\n const events = importedName\n ? NATIVE_COMPONENT_HANDLERS[importedName]\n : undefined;\n if (!events || !importedName || !localName) {\n continue;\n }\n tracked[localName] = {\n handlers: events.map((event) => ({ event })),\n importedName,\n isCustom: false,\n useContent: options.components.useContent,\n useNamePrefix: options.components.useNamePrefix,\n };\n }\n }\n\n for (const component of options.components.tracked) {\n tracked[component.name] = {\n ...(component.contentProp ? { contentProp: component.contentProp } : {}),\n handlers: component.handlers || [],\n isCustom: true,\n useContent:\n component.useContent === undefined\n ? options.components.useContent\n : component.useContent,\n useNamePrefix:\n component.useNamePrefix === undefined\n ? options.components.useNamePrefix\n : component.useNamePrefix,\n };\n }\n\n return tracked;\n}\n\nexport function isInsideConfiguredComponent(\n t: typeof Babel.types,\n path: Babel.NodePath<Babel.types.JSXElement>,\n customComponentNames: Set<string>\n): boolean {\n let current: Babel.NodePath | null = path.parentPath;\n while (current && !current.isProgram()) {\n if (\n current.isFunctionDeclaration() ||\n current.isClassDeclaration() ||\n current.isVariableDeclarator()\n ) {\n const name = getNodeName(t, current.node.id);\n if (name && customComponentNames.has(name)) {\n return true;\n }\n }\n current = current.parentPath;\n }\n return false;\n}\n\nexport function addRequiredTextInputHandler(\n t: typeof Babel.types,\n path: Babel.NodePath<Babel.types.JSXElement>,\n component: TrackedComponentData,\n componentName: string\n): void {\n if (\n component.isCustom ||\n component.importedName !== 'TextInput' ||\n componentName !== 'TextInput'\n ) {\n return;\n }\n const attributes = getDirectAttributePaths(path);\n const hasSpread = attributes.some((attribute) =>\n attribute.isJSXSpreadAttribute()\n );\n const hasOnFocus = attributes.some(\n (attribute) =>\n attribute.isJSXAttribute() &&\n getNodeName(t, attribute.node.name) === 'onFocus'\n );\n if (!hasSpread && !hasOnFocus) {\n const openingElementPath = path.get(\n 'openingElement'\n ) as Babel.NodePath<Babel.types.JSXOpeningElement>;\n openingElementPath.pushContainer(\n 'attributes',\n t.jsxAttribute(\n t.jsxIdentifier('onFocus'),\n t.jsxExpressionContainer(\n t.arrowFunctionExpression([], t.blockStatement([]))\n )\n )\n );\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;;AAGA,SAASA,yBAAyB,QAAQ,iBAAiB;AAK3D,SAASC,uBAAuB,EAAEC,WAAW,QAAQ,iBAAiB;AAEtE,OAAO,SAASC,uBAAuBA,CACrCC,CAAqB,EACrBC,WAAgD,EAChDC,OAAgC,EACM;EACtC,MAAMC,OAA6C,GAAG,CAAC,CAAC;EAExD,KAAK,MAAMC,SAAS,IAAIH,WAAW,CAACI,IAAI,CAACC,IAAI,EAAE;IAC7C,IACE,CAACN,CAAC,CAACO,mBAAmB,CAACH,SAAS,CAAC,IACjCA,SAAS,CAACI,MAAM,CAACC,KAAK,KAAK,cAAc,EACzC;MACA;IACF;IAEA,KAAK,MAAMC,SAAS,IAAIN,SAAS,CAACO,UAAU,EAAE;MAC5C,IAAI,CAACX,CAAC,CAACY,iBAAiB,CAACF,SAAS,CAAC,EAAE;QACnC;MACF;MACA,MAAMG,YAAY,GAAGf,WAAW,CAACE,CAAC,EAAEU,SAAS,CAACI,QAAQ,CAAC;MACvD,MAAMC,SAAS,GAAGjB,WAAW,CAACE,CAAC,EAAEU,SAAS,CAACM,KAAK,CAAC;MACjD,MAAMC,MAAM,GAAGJ,YAAY,GACvBjB,yBAAyB,CAACiB,YAAY,CAAC,GACvCK,SAAS;MACb,IAAI,CAACD,MAAM,IAAI,CAACJ,YAAY,IAAI,CAACE,SAAS,EAAE;QAC1C;MACF;MACAZ,OAAO,CAACY,SAAS,CAAC,GAAG;QACnBI,QAAQ,EAAEF,MAAM,CAACG,GAAG,CAAEC,KAAK,KAAM;UAAEA;QAAM,CAAC,CAAC,CAAC;QAC5CR,YAAY;QACZS,QAAQ,EAAE,KAAK;QACfC,UAAU,EAAErB,OAAO,CAACsB,UAAU,CAACD,UAAU;QACzC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