{"version":3,"file":"component-annotation.js","sources":["../../../src/babel-plugin/component-annotation.ts"],"sourcesContent":["import { DEFAULT_IGNORED_ELEMENTS } from './constants';\n\nexport const WEB_COMPONENT_NAME = 'data-sentry-component';\nexport const WEB_ELEMENT_NAME = 'data-sentry-element';\nexport const WEB_SOURCE_FILE_NAME = 'data-sentry-source-file';\n\nexport const NATIVE_COMPONENT_NAME = 'dataSentryComponent';\nexport const NATIVE_ELEMENT_NAME = 'dataSentryElement';\nexport const NATIVE_SOURCE_FILE_NAME = 'dataSentrySourceFile';\n\nexport type ComponentAnnotationAttributeNames = readonly [string, string, string];\n\nexport type ComponentAnnotationAttribute = [string, string];\n\ntype ComponentAnnotationAttributesInput = {\n attributeNames: ComponentAnnotationAttributeNames;\n componentName: string;\n elementName: string;\n existingAttributes: ReadonlySet;\n ignoredComponents: readonly string[];\n isFragment: boolean;\n sourceFileName?: string;\n};\n\nconst DEFAULT_IGNORED_ELEMENTS_SET = new Set(DEFAULT_IGNORED_ELEMENTS);\n\nexport function getComponentAnnotationAttributes({\n attributeNames,\n componentName,\n elementName,\n existingAttributes,\n ignoredComponents,\n isFragment,\n sourceFileName,\n}: ComponentAnnotationAttributesInput): ComponentAnnotationAttribute[] {\n if (isFragment || ignoredComponents.includes(componentName) || ignoredComponents.includes(elementName)) {\n return [];\n }\n\n const [componentAttributeName, elementAttributeName, sourceFileAttributeName] = attributeNames;\n const isIgnoredElement = DEFAULT_IGNORED_ELEMENTS_SET.has(elementName);\n const attributes: ComponentAnnotationAttribute[] = [];\n\n if (!isIgnoredElement && !existingAttributes.has(elementAttributeName)) {\n attributes.push([elementAttributeName, elementName]);\n }\n\n if (componentName && !existingAttributes.has(componentAttributeName)) {\n attributes.push([componentAttributeName, componentName]);\n }\n\n if (sourceFileName && (componentName || !isIgnoredElement) && !existingAttributes.has(sourceFileAttributeName)) {\n attributes.push([sourceFileAttributeName, sourceFileName]);\n }\n\n return attributes;\n}\n"],"names":[],"mappings":";;AAEO,MAAM,kB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