@bentolabs/sdk 1.2.1 → 1.2.2

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
@@ -9133,6 +9133,22 @@ function getDirectText$1(element) {
9133
9133
  }
9134
9134
  return text.replace(/\s+/g, " ").trim();
9135
9135
  }
9136
+ function getFullText$1(element) {
9137
+ return (element.textContent || "").replace(/\s+/g, " ").trim();
9138
+ }
9139
+ function getChildSignature(element) {
9140
+ const tags = Array.from(element.children).map(
9141
+ (c2) => c2.tagName.toLowerCase()
9142
+ );
9143
+ return tags.join(",");
9144
+ }
9145
+ function quickHash(str) {
9146
+ let hash = 5381;
9147
+ for (let i2 = 0; i2 < str.length; i2++) {
9148
+ hash = (hash << 5) + hash ^ str.charCodeAt(i2);
9149
+ }
9150
+ return (hash >>> 0).toString(16);
9151
+ }
9136
9152
  function buildBentoSelector(element) {
9137
9153
  const parts = [];
9138
9154
  const tag = element.tagName.toLowerCase();
@@ -9185,13 +9201,41 @@ function buildBentoSelector(element) {
9185
9201
  if (title) {
9186
9202
  parts.push(`title=${escapeValue(truncate(title, 50))}`);
9187
9203
  }
9188
- const interactiveTags = ["button", "a", "label", "span", "div", "li", "td", "th", "h1", "h2", "h3", "h4", "h5", "h6", "p"];
9204
+ const interactiveTags = [
9205
+ "button",
9206
+ "a",
9207
+ "label",
9208
+ "span",
9209
+ "div",
9210
+ "li",
9211
+ "td",
9212
+ "th",
9213
+ "h1",
9214
+ "h2",
9215
+ "h3",
9216
+ "h4",
9217
+ "h5",
9218
+ "h6",
9219
+ "p"
9220
+ ];
9189
9221
  if (interactiveTags.includes(tag)) {
9190
- const text = getDirectText$1(element);
9222
+ let text = getDirectText$1(element);
9223
+ if (!text) {
9224
+ text = getFullText$1(element);
9225
+ }
9191
9226
  if (text) {
9192
9227
  parts.push(`text=${escapeValue(truncate(text, 50))}`);
9193
9228
  }
9194
9229
  }
9230
+ if (parts.length === 1) {
9231
+ const childSig = getChildSignature(element);
9232
+ if (childSig) {
9233
+ parts.push(`children=${childSig}`);
9234
+ } else {
9235
+ const attrs = Array.from(element.attributes).map((a2) => `${a2.name}=${a2.value}`).sort().join(";");
9236
+ parts.push(`hash=${quickHash(tag + attrs)}`);
9237
+ }
9238
+ }
9195
9239
  return parts.join("|");
9196
9240
  }
9197
9241
  function generateSelector(outerHTML) {