fetta 1.5.1 → 1.5.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/README.md CHANGED
@@ -27,10 +27,10 @@ npm install fetta
27
27
  ```
28
28
 
29
29
  **Bundle size** (minified + brotli)
30
- - `fetta`: ~7.17 kB
31
- - `fetta/react`: ~8.66 kB
32
- - `fetta/motion`: ~15.93 kB
33
- - `fetta/helpers`: ~765 B
30
+ - `fetta`: ~7.04 kB
31
+ - `fetta/react`: ~8.21 kB
32
+ - `fetta/motion`: ~13.68 kB
33
+ - `fetta/helpers`: ~742 B
34
34
 
35
35
  ## Quick Start
36
36
 
@@ -59,10 +59,9 @@ function isSafari() {
59
59
  }
60
60
  var kerningMeasureRoots = /* @__PURE__ */ new WeakMap();
61
61
  function getKerningMeasureRoot(doc) {
62
- var _a;
63
62
  const existing = kerningMeasureRoots.get(doc);
64
63
  if (existing && existing.isConnected) return existing;
65
- const host = (_a = doc.body) != null ? _a : doc.documentElement;
64
+ const host = doc.body ?? doc.documentElement;
66
65
  if (!host) return null;
67
66
  const root = doc.createElement("div");
68
67
  root.setAttribute("data-fetta-kerning-root", "true");
@@ -89,7 +88,7 @@ function measureKerningDOM(measureRoot, styleSource, chars, styles) {
89
88
  visibility: hidden;
90
89
  white-space: pre;
91
90
  `;
92
- const computedStyles = styles != null ? styles : getComputedStyle(styleSource);
91
+ const computedStyles = styles ?? getComputedStyle(styleSource);
93
92
  copyKerningStyles(measurer, computedStyles);
94
93
  const webkitSmoothing = computedStyles.webkitFontSmoothing || computedStyles["-webkit-font-smoothing"];
95
94
  const mozSmoothing = computedStyles.MozOsxFontSmoothing || computedStyles["-moz-osx-font-smoothing"];
@@ -124,7 +123,7 @@ function measureKerningRange(measureRoot, styleSource, chars, styles) {
124
123
  const doc = styleSource.ownerDocument;
125
124
  const measurer = doc.createElement("span");
126
125
  measurer.style.cssText = "position:absolute;visibility:hidden;white-space:pre;";
127
- const computedStyles = styles != null ? styles : getComputedStyle(styleSource);
126
+ const computedStyles = styles ?? getComputedStyle(styleSource);
128
127
  copyKerningStyles(measurer, computedStyles);
129
128
  measureRoot.appendChild(measurer);
130
129
  const range = doc.createRange();
@@ -160,7 +159,7 @@ function measureKerning(container, styleSource, chars, styles, isolateKerningMea
160
159
  );
161
160
  return /* @__PURE__ */ new Map();
162
161
  }
163
- const computedStyles = styles != null ? styles : getComputedStyle(styleSource);
162
+ const computedStyles = styles ?? getComputedStyle(styleSource);
164
163
  if (!isolateKerningMeasurement) {
165
164
  if (!container.isConnected) {
166
165
  console.warn(
@@ -233,7 +232,7 @@ function clearKerningCompensation(allWords, charClass, splitChars, splitWords, m
233
232
  }
234
233
  }
235
234
  function applyKerningCompensation(element, allWords, charClass, splitChars, splitWords, options) {
236
- if (options == null ? void 0 : options.disableKerning) return;
235
+ if (options?.disableKerning) return;
237
236
  if (splitChars && allWords.length > 0) {
238
237
  const charSelector = classSelector(charClass);
239
238
  if (!charSelector) return;
@@ -273,12 +272,12 @@ function applyKerningCompensation(element, allWords, charClass, splitChars, spli
273
272
  group.styleSource,
274
273
  charStrings,
275
274
  group.styles,
276
- (options == null ? void 0 : options.isolateKerningMeasurement) !== false
275
+ options?.isolateKerningMeasurement !== false
277
276
  );
278
277
  for (const [charIndex, kerning] of kerningMap) {
279
278
  const charSpan = group.chars[charIndex];
280
279
  if (charSpan && Math.abs(kerning) < 20) {
281
- const targetElement = getCharKerningTarget(charSpan, options == null ? void 0 : options.mask);
280
+ const targetElement = getCharKerningTarget(charSpan, options?.mask);
282
281
  targetElement.style.marginLeft = `${kerning}px`;
283
282
  }
284
283
  }
@@ -309,13 +308,13 @@ function applyKerningCompensation(element, allWords, charClass, splitChars, spli
309
308
  firstCharSpan,
310
309
  [lastChar, " ", firstChar],
311
310
  styles,
312
- (options == null ? void 0 : options.isolateKerningMeasurement) !== false
311
+ options?.isolateKerningMeasurement !== false
313
312
  );
314
313
  let totalKerning = 0;
315
314
  if (kerningMap.has(1)) totalKerning += kerningMap.get(1);
316
315
  if (kerningMap.has(2)) totalKerning += kerningMap.get(2);
317
316
  if (Math.abs(totalKerning) > 1e-3 && Math.abs(totalKerning) < 20) {
318
- const targetElement = getCharKerningTarget(firstCharSpan, options == null ? void 0 : options.mask);
317
+ const targetElement = getCharKerningTarget(firstCharSpan, options?.mask);
319
318
  targetElement.style.marginLeft = `${totalKerning}px`;
320
319
  }
321
320
  }
@@ -340,13 +339,13 @@ function applyKerningCompensation(element, allWords, charClass, splitChars, spli
340
339
  currWord,
341
340
  [lastChar, " ", firstChar],
342
341
  styles,
343
- (options == null ? void 0 : options.isolateKerningMeasurement) !== false
342
+ options?.isolateKerningMeasurement !== false
344
343
  );
345
344
  let totalKerning = 0;
346
345
  if (kerningMap.has(1)) totalKerning += kerningMap.get(1);
347
346
  if (kerningMap.has(2)) totalKerning += kerningMap.get(2);
348
347
  if (Math.abs(totalKerning) > 1e-3 && Math.abs(totalKerning) < 20) {
349
- const targetElement = getWordKerningTarget(currWord, options == null ? void 0 : options.mask);
348
+ const targetElement = getWordKerningTarget(currWord, options?.mask);
350
349
  targetElement.style.marginLeft = `${totalKerning}px`;
351
350
  }
352
351
  }
@@ -382,8 +381,7 @@ function resolveAutoSplitTargets(splitElement) {
382
381
  return Array.from(new Set(targets));
383
382
  }
384
383
  function getObservedWidth(entry, target) {
385
- var _a;
386
- const entryWidth = (_a = entry == null ? void 0 : entry.contentRect) == null ? void 0 : _a.width;
384
+ const entryWidth = entry?.contentRect?.width;
387
385
  if (typeof entryWidth === "number" && Number.isFinite(entryWidth)) {
388
386
  return entryWidth;
389
387
  }
@@ -420,6 +418,30 @@ function resolveAutoSplitWidth(targets, widthByTarget, changedTarget) {
420
418
  return 0;
421
419
  }
422
420
 
421
+ // src/internal/lineFingerprint.ts
422
+ function normalizeLineFingerprintText(value) {
423
+ return value.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
424
+ }
425
+ function collectNodeText(node) {
426
+ if (node.type === "text") return node.text;
427
+ return node.children.map((child) => collectNodeText(child)).join("");
428
+ }
429
+ function collectLineTextsFromData(nodes, lineTexts) {
430
+ for (const node of nodes) {
431
+ if (node.type !== "element") continue;
432
+ if (node.split === "line") {
433
+ lineTexts.push(normalizeLineFingerprintText(collectNodeText(node)));
434
+ continue;
435
+ }
436
+ collectLineTextsFromData(node.children, lineTexts);
437
+ }
438
+ }
439
+ function buildLineFingerprintFromData(data) {
440
+ const lineTexts = [];
441
+ collectLineTextsFromData(data.nodes, lineTexts);
442
+ return lineTexts.join("\n");
443
+ }
444
+
423
445
  // src/core/splitText.ts
424
446
  var ARIA_LABEL_ALLOWED_TAGS = /* @__PURE__ */ new Set([
425
447
  "h1",
@@ -449,7 +471,6 @@ var ARIA_LABEL_ALLOWED_TAGS = /* @__PURE__ */ new Set([
449
471
  "main"
450
472
  ]);
451
473
  function splitTextData(element, rawOptions = {}) {
452
- var _a, _b;
453
474
  const options = rawOptions;
454
475
  const {
455
476
  type = "chars,words,lines",
@@ -466,7 +487,7 @@ function splitTextData(element, rawOptions = {}) {
466
487
  if (!(element instanceof HTMLElement)) {
467
488
  throw new Error("splitTextData: element must be an HTMLElement");
468
489
  }
469
- const text = (_b = (_a = element.textContent) == null ? void 0 : _a.trim()) != null ? _b : "";
490
+ const text = element.textContent?.trim() ?? "";
470
491
  if (!text) {
471
492
  console.warn("splitTextData: element has no text content");
472
493
  return {
@@ -709,11 +730,10 @@ function getSplitRole(element, classInfo) {
709
730
  return void 0;
710
731
  }
711
732
  function serializeNode(node, classInfo) {
712
- var _a;
713
733
  if (node.nodeType === Node.TEXT_NODE) {
714
734
  return {
715
735
  type: "text",
716
- text: (_a = node.textContent) != null ? _a : ""
736
+ text: node.textContent ?? ""
717
737
  };
718
738
  }
719
739
  if (node.nodeType !== Node.ELEMENT_NODE) return null;
@@ -920,7 +940,7 @@ function createSpan(className, index, display = "inline-block", options) {
920
940
  if (className) {
921
941
  span.className = className;
922
942
  }
923
- if (index !== void 0 && (options == null ? void 0 : options.propName)) {
943
+ if (index !== void 0 && options?.propName) {
924
944
  span.setAttribute(`data-${options.propName}-index`, index.toString());
925
945
  if (options.propIndex) {
926
946
  span.style.setProperty(`--${options.propName}-index`, index.toString());
@@ -929,7 +949,7 @@ function createSpan(className, index, display = "inline-block", options) {
929
949
  span.style.display = display;
930
950
  span.style.position = "relative";
931
951
  span.style.textDecoration = "inherit";
932
- if (options == null ? void 0 : options.ariaHidden) {
952
+ if (options?.ariaHidden) {
933
953
  span.setAttribute("aria-hidden", "true");
934
954
  }
935
955
  return span;
@@ -993,7 +1013,6 @@ function groupIntoLines(elements, element) {
993
1013
  return lineGroups;
994
1014
  }
995
1015
  function performSplit(element, measuredWords, charClass, wordClass, lineClass, splitChars, splitWords, splitLines, options) {
996
- var _a, _b;
997
1016
  element.textContent = "";
998
1017
  const allChars = [];
999
1018
  const allWords = [];
@@ -1005,9 +1024,9 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1005
1024
  let globalCharIndex = 0;
1006
1025
  measuredWords.forEach((measuredWord, wordIndex) => {
1007
1026
  const wordSpan = createSpan(wordClass, wordIndex, "inline-block", {
1008
- propIndex: options == null ? void 0 : options.propIndex,
1027
+ propIndex: options?.propIndex,
1009
1028
  propName: "word",
1010
- ariaHidden: options == null ? void 0 : options.ariaHidden
1029
+ ariaHidden: options?.ariaHidden
1011
1030
  });
1012
1031
  if (measuredWord.noSpaceBefore) {
1013
1032
  noSpaceBeforeSet.add(wordSpan);
@@ -1022,13 +1041,13 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1022
1041
  if (!hasAnyAncestors) {
1023
1042
  measuredWord.chars.forEach((measuredChar, charIndexInWord) => {
1024
1043
  const charSpan = createSpan(charClass, globalCharIndex, "inline-block", {
1025
- propIndex: options == null ? void 0 : options.propIndex,
1044
+ propIndex: options?.propIndex,
1026
1045
  propName: "char",
1027
- ariaHidden: options == null ? void 0 : options.ariaHidden
1046
+ ariaHidden: options?.ariaHidden
1028
1047
  });
1029
1048
  charSpan.textContent = measuredChar.char;
1030
1049
  globalCharIndex++;
1031
- if ((options == null ? void 0 : options.mask) === "chars") {
1050
+ if (options?.mask === "chars") {
1032
1051
  const charWrapper = createMaskWrapper("inline-block");
1033
1052
  charWrapper.appendChild(charSpan);
1034
1053
  wordSpan.appendChild(charWrapper);
@@ -1046,12 +1065,12 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1046
1065
  charGroups.forEach((group) => {
1047
1066
  group.chars.forEach((measuredChar) => {
1048
1067
  const charSpan = createSpan(charClass, globalCharIndex, "inline-block", {
1049
- propIndex: options == null ? void 0 : options.propIndex,
1068
+ propIndex: options?.propIndex,
1050
1069
  propName: "char"
1051
1070
  });
1052
1071
  charSpan.textContent = measuredChar.char;
1053
1072
  globalCharIndex++;
1054
- if ((options == null ? void 0 : options.mask) === "chars") {
1073
+ if (options?.mask === "chars") {
1055
1074
  const charWrapper = createMaskWrapper("inline-block");
1056
1075
  charWrapper.appendChild(charSpan);
1057
1076
  wordSpan.appendChild(charWrapper);
@@ -1126,7 +1145,7 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1126
1145
  }
1127
1146
  const fragment = document.createDocumentFragment();
1128
1147
  wordGroup.forEach((ws, idx) => {
1129
- if ((options == null ? void 0 : options.mask) === "words") {
1148
+ if (options?.mask === "words") {
1130
1149
  const wordWrapper = createMaskWrapper("inline-block");
1131
1150
  wordWrapper.appendChild(ws);
1132
1151
  fragment.appendChild(wordWrapper);
@@ -1144,7 +1163,7 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1144
1163
  }
1145
1164
  i = j;
1146
1165
  } else {
1147
- if ((options == null ? void 0 : options.mask) === "words") {
1166
+ if (options?.mask === "words") {
1148
1167
  const wordWrapper = createMaskWrapper("inline-block");
1149
1168
  wordWrapper.appendChild(wordSpan);
1150
1169
  element.appendChild(wordWrapper);
@@ -1164,9 +1183,9 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1164
1183
  splitChars,
1165
1184
  splitWords,
1166
1185
  {
1167
- disableKerning: options == null ? void 0 : options.disableKerning,
1168
- isolateKerningMeasurement: options == null ? void 0 : options.isolateKerningMeasurement,
1169
- mask: options == null ? void 0 : options.mask
1186
+ disableKerning: options?.disableKerning,
1187
+ isolateKerningMeasurement: options?.isolateKerningMeasurement,
1188
+ mask: options?.mask
1170
1189
  }
1171
1190
  );
1172
1191
  if (splitLines) {
@@ -1181,9 +1200,9 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1181
1200
  const allLines = [];
1182
1201
  lineGroups.forEach((words, lineIndex) => {
1183
1202
  const lineSpan = createSpan(lineClass, lineIndex, "block", {
1184
- propIndex: options == null ? void 0 : options.propIndex,
1203
+ propIndex: options?.propIndex,
1185
1204
  propName: "line",
1186
- ariaHidden: options == null ? void 0 : options.ariaHidden
1205
+ ariaHidden: options?.ariaHidden
1187
1206
  });
1188
1207
  allLines.push(lineSpan);
1189
1208
  let wi = 0;
@@ -1205,7 +1224,7 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1205
1224
  }
1206
1225
  const fragment = document.createDocumentFragment();
1207
1226
  wordGroup.forEach((ws, idx) => {
1208
- if ((options == null ? void 0 : options.mask) === "words") {
1227
+ if (options?.mask === "words") {
1209
1228
  const wordWrapper = createMaskWrapper("inline-block");
1210
1229
  wordWrapper.appendChild(ws);
1211
1230
  fragment.appendChild(wordWrapper);
@@ -1223,7 +1242,7 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1223
1242
  }
1224
1243
  wi = wj;
1225
1244
  } else {
1226
- if ((options == null ? void 0 : options.mask) === "words") {
1245
+ if (options?.mask === "words") {
1227
1246
  const wordWrapper = createMaskWrapper("inline-block");
1228
1247
  wordWrapper.appendChild(wordSpan);
1229
1248
  lineSpan.appendChild(wordWrapper);
@@ -1236,7 +1255,7 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1236
1255
  wi++;
1237
1256
  }
1238
1257
  }
1239
- if ((options == null ? void 0 : options.mask) === "lines") {
1258
+ if (options?.mask === "lines") {
1240
1259
  const lineWrapper = createMaskWrapper("block");
1241
1260
  lineWrapper.appendChild(lineSpan);
1242
1261
  element.appendChild(lineWrapper);
@@ -1244,13 +1263,13 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1244
1263
  element.appendChild(lineSpan);
1245
1264
  }
1246
1265
  });
1247
- if (options == null ? void 0 : options.initialStyles) {
1266
+ if (options?.initialStyles) {
1248
1267
  const { chars, words, lines } = options.initialStyles;
1249
1268
  if (chars) applyInitialStyles(allChars, chars);
1250
1269
  if (words) applyInitialStyles(allWords, words);
1251
1270
  if (lines) applyInitialStyles(allLines, lines);
1252
1271
  }
1253
- if (options == null ? void 0 : options.initialClasses) {
1272
+ if (options?.initialClasses) {
1254
1273
  const { chars, words, lines } = options.initialClasses;
1255
1274
  if (chars) applyInitialClasses(allChars, chars);
1256
1275
  if (words) applyInitialClasses(allWords, words);
@@ -1262,12 +1281,12 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1262
1281
  lines: allLines
1263
1282
  };
1264
1283
  }
1265
- if (options == null ? void 0 : options.initialStyles) {
1284
+ if (options?.initialStyles) {
1266
1285
  const { chars, words } = options.initialStyles;
1267
1286
  if (chars) applyInitialStyles(allChars, chars);
1268
1287
  if (words) applyInitialStyles(allWords, words);
1269
1288
  }
1270
- if (options == null ? void 0 : options.initialClasses) {
1289
+ if (options?.initialClasses) {
1271
1290
  const { chars, words } = options.initialClasses;
1272
1291
  if (chars) applyInitialClasses(allChars, chars);
1273
1292
  if (words) applyInitialClasses(allWords, words);
@@ -1308,7 +1327,7 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1308
1327
  const allLines = [];
1309
1328
  lineGroups.forEach((wrappers, lineIndex) => {
1310
1329
  const lineSpan = createSpan(lineClass, lineIndex, "block", {
1311
- propIndex: options == null ? void 0 : options.propIndex,
1330
+ propIndex: options?.propIndex,
1312
1331
  propName: "line"
1313
1332
  });
1314
1333
  allLines.push(lineSpan);
@@ -1324,7 +1343,7 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1324
1343
  }
1325
1344
  }
1326
1345
  });
1327
- if ((options == null ? void 0 : options.mask) === "lines") {
1346
+ if (options?.mask === "lines") {
1328
1347
  const lineWrapper = createMaskWrapper("block");
1329
1348
  lineWrapper.appendChild(lineSpan);
1330
1349
  element.appendChild(lineWrapper);
@@ -1332,10 +1351,10 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1332
1351
  element.appendChild(lineSpan);
1333
1352
  }
1334
1353
  });
1335
- if ((_a = options == null ? void 0 : options.initialStyles) == null ? void 0 : _a.lines) {
1354
+ if (options?.initialStyles?.lines) {
1336
1355
  applyInitialStyles(allLines, options.initialStyles.lines);
1337
1356
  }
1338
- if ((_b = options == null ? void 0 : options.initialClasses) == null ? void 0 : _b.lines) {
1357
+ if (options?.initialClasses?.lines) {
1339
1358
  applyInitialClasses(allLines, options.initialClasses.lines);
1340
1359
  }
1341
1360
  return { chars: [], words: [], lines: allLines };
@@ -1346,37 +1365,11 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
1346
1365
  }
1347
1366
  }
1348
1367
  }
1349
- function normalizeLineFingerprintText(value) {
1350
- return value.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
1351
- }
1352
1368
  function buildLineFingerprintFromElements(lines) {
1353
1369
  if (lines.length === 0) return "";
1354
- return lines.map((line) => {
1355
- var _a;
1356
- return normalizeLineFingerprintText((_a = line.textContent) != null ? _a : "");
1357
- }).join("\n");
1358
- }
1359
- function collectNodeText(node) {
1360
- if (node.type === "text") return node.text;
1361
- return node.children.map((child) => collectNodeText(child)).join("");
1362
- }
1363
- function collectLineTextsFromData(nodes, lineTexts) {
1364
- for (const node of nodes) {
1365
- if (node.type !== "element") continue;
1366
- if (node.split === "line") {
1367
- lineTexts.push(normalizeLineFingerprintText(collectNodeText(node)));
1368
- continue;
1369
- }
1370
- collectLineTextsFromData(node.children, lineTexts);
1371
- }
1372
- }
1373
- function buildLineFingerprintFromData(data) {
1374
- const lineTexts = [];
1375
- collectLineTextsFromData(data.nodes, lineTexts);
1376
- return lineTexts.join("\n");
1370
+ return lines.map((line) => normalizeLineFingerprintText(line.textContent ?? "")).join("\n");
1377
1371
  }
1378
1372
  function splitText(element, rawOptions = {}) {
1379
- var _a;
1380
1373
  const options = rawOptions;
1381
1374
  const {
1382
1375
  type = "chars,words,lines",
@@ -1397,7 +1390,7 @@ function splitText(element, rawOptions = {}) {
1397
1390
  if (!(element instanceof HTMLElement)) {
1398
1391
  throw new Error("splitText: element must be an HTMLElement");
1399
1392
  }
1400
- const text = (_a = element.textContent) == null ? void 0 : _a.trim();
1393
+ const text = element.textContent?.trim();
1401
1394
  if (!text) {
1402
1395
  console.warn("splitText: element has no text content");
1403
1396
  return {
@@ -1759,4 +1752,4 @@ function splitText(element, rawOptions = {}) {
1759
1752
  };
1760
1753
  }
1761
1754
 
1762
- export { applyKerningCompensation, buildKerningStyleKey, clearKerningCompensation, getObservedWidth, normalizeToPromise, querySplitWords, recordWidthChange, resolveAutoSplitTargets, resolveAutoSplitWidth, splitText, splitTextData };
1755
+ export { applyKerningCompensation, buildKerningStyleKey, buildLineFingerprintFromData, clearKerningCompensation, getObservedWidth, normalizeToPromise, querySplitWords, recordWidthChange, resolveAutoSplitTargets, resolveAutoSplitWidth, splitText, splitTextData };
@@ -32,11 +32,11 @@ function reapplyInitialClasses(elements, className) {
32
32
  async function waitForFontsReady(waitForFonts) {
33
33
  if (!waitForFonts) return;
34
34
  const fonts = document.fonts;
35
- const ready = fonts == null ? void 0 : fonts.ready;
35
+ const ready = fonts?.ready;
36
36
  if (!ready || typeof ready.then !== "function") return;
37
37
  try {
38
38
  await ready;
39
- } catch (e) {
39
+ } catch {
40
40
  }
41
41
  }
42
42
 
package/dist/helpers.js CHANGED
@@ -1,5 +1,3 @@
1
- import './chunk-ORMEWXMH.js';
2
-
3
1
  // src/helpers/createSplitClones.ts
4
2
  function resolveDisplay(display, unit) {
5
3
  if (display && display !== "auto") return display;
@@ -31,10 +29,9 @@ function normalizeOffset(direction, distance) {
31
29
  return trimmed.startsWith("-") ? trimmed.slice(1) : trimmed;
32
30
  }
33
31
  function applyCloneOffset(clone, cloneOffset) {
34
- var _a, _b, _c;
35
- const axis = (_a = cloneOffset == null ? void 0 : cloneOffset.axis) != null ? _a : "y";
36
- const direction = (_b = cloneOffset == null ? void 0 : cloneOffset.direction) != null ? _b : "start";
37
- const distance = (_c = cloneOffset == null ? void 0 : cloneOffset.distance) != null ? _c : "100%";
32
+ const axis = cloneOffset?.axis ?? "y";
33
+ const direction = cloneOffset?.direction ?? "start";
34
+ const distance = cloneOffset?.distance ?? "100%";
38
35
  const offset = normalizeOffset(direction, distance);
39
36
  clone.style.position = "absolute";
40
37
  if (axis === "y") {
@@ -52,9 +49,8 @@ function resolveOriginals(split, unit) {
52
49
  throw new Error(`createSplitClones: unsupported unit "${unit}"`);
53
50
  }
54
51
  function createSplitClones(split, options) {
55
- var _a;
56
52
  const unit = options.unit;
57
- const wrap = (_a = options.wrap) != null ? _a : false;
53
+ const wrap = options.wrap ?? false;
58
54
  const originals = resolveOriginals(split, unit);
59
55
  const clones = [];
60
56
  const tracks = [];
@@ -104,7 +100,7 @@ function createSplitClones(split, options) {
104
100
  }
105
101
  item.track.remove();
106
102
  }
107
- if (cleanupOptions == null ? void 0 : cleanupOptions.revertSplit) {
103
+ if (cleanupOptions?.revertSplit) {
108
104
  split.revert();
109
105
  }
110
106
  };
package/dist/index.js CHANGED
@@ -1,2 +1 @@
1
- export { splitText } from './chunk-UPF3IYHC.js';
2
- import './chunk-ORMEWXMH.js';
1
+ export { splitText } from './chunk-OUXSJF3P.js';