tempo-sdk 0.0.7 → 0.0.8

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/dist/index.js CHANGED
@@ -77,6 +77,19 @@ function formatProps(props) {
77
77
  return ` ${key}={${formatted}}`;
78
78
  }).filter((s) => s !== null).join("");
79
79
  }
80
+ function getExistingAttributeNames(element) {
81
+ const names = /* @__PURE__ */ new Set();
82
+ for (const attr of element.openingElement.attributes ?? []) {
83
+ if (attr.type !== "JSXAttribute") continue;
84
+ names.add(getTagName(attr.name));
85
+ }
86
+ return names;
87
+ }
88
+ function removeExistingProps(props, existingNames) {
89
+ return Object.fromEntries(
90
+ Object.entries(props).filter(([key]) => !existingNames.has(key))
91
+ );
92
+ }
80
93
  var FRAGMENT_TAG_NAMES = /* @__PURE__ */ new Set(["Fragment", "React.Fragment"]);
81
94
  function annotateFile(source, filename, computeAnnotatedProps) {
82
95
  const parseResult = parseSync2(filename, source);
@@ -86,7 +99,10 @@ function annotateFile(source, filename, computeAnnotatedProps) {
86
99
  const element = node;
87
100
  const tagName = getTagName(element.openingElement.name);
88
101
  if (FRAGMENT_TAG_NAMES.has(tagName)) return;
89
- const props = computeAnnotatedProps({ element, tagName });
102
+ const props = removeExistingProps(
103
+ computeAnnotatedProps({ element, tagName }),
104
+ getExistingAttributeNames(element)
105
+ );
90
106
  if (Object.keys(props).length === 0) return;
91
107
  const openingElement = element.openingElement;
92
108
  let insertPos = openingElement.end - 1;