@vectoriox/iox-ui 5.139.0 → 5.141.0

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.
@@ -862,6 +862,32 @@ const JOINED_SCRIPTS = /[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{S
862
862
  function lettersSplittable(text) {
863
863
  return !JOINED_SCRIPTS.test(text);
864
864
  }
865
+ /** The pieces a letter split makes of `text`: the letters of its words (a letter with its points or a joined emoji is
866
+ * one). The spaces are no piece. */
867
+ function letterCount(text) {
868
+ const words = text.match(/\S+/g) ?? [];
869
+ return words.reduce((n, word) => n + graphemes(word).length, 0);
870
+ }
871
+ /** Why a reveal set to Letter by letter comes in by word for a text (AW10-D2). The values are the panel's words' keys. */
872
+ var LetterRefusal;
873
+ (function (LetterRefusal) {
874
+ /** A script whose letters join (Arabic, Indic, Thai…): pulled apart, each would show its isolated form. */
875
+ LetterRefusal["Joined"] = "letterJoined";
876
+ /** Longer than a display line: over `LETTER_PIECE_CAP` letters. */
877
+ LetterRefusal["Long"] = "letterLong";
878
+ })(LetterRefusal || (LetterRefusal = {}));
879
+ /**
880
+ * THE rule a letter split follows (AW10-D2): why `text` cannot come in letter by letter, or null when it can (an empty
881
+ * text refuses nothing — there is nothing to split). `splitForReveal` asks it before splitting, and the builder's panel
882
+ * asks it to SAY so before the text plays — one rule, so the two never disagree (vectoriox/iox-ui#107).
883
+ */
884
+ function letterRefusalOf(text) {
885
+ if (!text)
886
+ return null;
887
+ if (!lettersSplittable(text))
888
+ return LetterRefusal.Joined;
889
+ return letterCount(text) > LETTER_PIECE_CAP ? LetterRefusal.Long : null;
890
+ }
865
891
  const SKIPPED_TAGS = new Set(['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'SELECT', 'OPTION']);
866
892
  const SHOW_TEXT = 4;
867
893
  /** Hebrew through Arabic Extended, and their presentation forms. */
@@ -934,7 +960,7 @@ function splitText(root, options) {
934
960
  const planned = texts.map(original => ({
935
961
  original, parts: textPieces(original.nodeValue ?? '', keepRuns && !!options.rtl, keepRuns && !options.rtl),
936
962
  }));
937
- const pieceCount = (part) => (!part.word ? 0 : letters ? graphemes(part.text.replace(/\s+/g, '')).length : 1);
963
+ const pieceCount = (part) => (!part.word ? 0 : letters ? letterCount(part.text) : 1);
938
964
  const count = planned.reduce((sum, { parts }) => sum + parts.reduce((n, part) => n + pieceCount(part), 0), 0);
939
965
  if (!count || count > options.cap)
940
966
  return null;
@@ -1037,13 +1063,10 @@ function splitForReveal(el, by, look = TextRevealLook.Rise) {
1037
1063
  return null;
1038
1064
  const rtl = el.ownerDocument.defaultView?.getComputedStyle(el).direction === 'rtl';
1039
1065
  const mask = look === TextRevealLook.Rise;
1040
- let used = by;
1041
- let split = by === TextRevealBy.Letter ? splitText(el, { cap: LETTER_PIECE_CAP, mask, rtl, letters: true }) : null;
1042
- if (!split) {
1043
- if (used === TextRevealBy.Letter)
1044
- used = TextRevealBy.Word;
1045
- split = splitText(el, { cap: REVEAL_PIECE_CAP, mask, rtl });
1046
- }
1066
+ // The text a split reads: its text nodes, apart (a letter never joins across two of them).
1067
+ const used = by === TextRevealBy.Letter && letterRefusalOf(textNodesOf(el).map(t => t.nodeValue ?? '').join(' ')) ? TextRevealBy.Word : by;
1068
+ const letters = used === TextRevealBy.Letter;
1069
+ const split = splitText(el, { cap: letters ? LETTER_PIECE_CAP : REVEAL_PIECE_CAP, mask, rtl, letters });
1047
1070
  if (!split)
1048
1071
  return null;
1049
1072
  const boxes = used === TextRevealBy.Line ? split.pieces.map(piece => (mask ? piece.parentElement : piece).getBoundingClientRect()) : [];
@@ -1602,5 +1625,5 @@ function attachSceneRoots(roots, options = {}) {
1602
1625
  * Generated bundle index. Do not edit.
1603
1626
  */
1604
1627
 
1605
- export { LETTER_PIECE_CAP, LIGHT_UP_PIECE_CAP, PARALLAX_DEPTH_DEFAULT, PARALLAX_PHONE_FACTOR, PARALLAX_REST_DEFAULT, PARALLAX_SPEED, PROGRESS_BAR_FRAMES, ParallaxDepth, ParallaxPhone, REVEAL_PIECE_CAP, SCENE_BUDGET, SCENE_DAMPING, SCENE_FILM_SMOOTH, SCENE_FLOW_RULES, SCENE_LENGTH, SCENE_MAX_SCREENS, SCENE_MIN_SCREENS, SCENE_PHONE_LENGTH, SCENE_PHONE_MAX_WIDTH, SCENE_REDUCED_MOTION_CSS, SCENE_REVEAL_DEFAULT, SCENE_STAGE_HEIGHT, SCENE_TRACK_DEFS, SCENE_WAKE_EVENT, SCENE_WORDS, SCENE_WORD_DIM, SCROLL_RANGE_DEFAULT, SCRUB_PIECES_IN_FLIGHT, SLIDER_HOLD_SHARE, SLIDER_SCROLL_STEP_SCREENS, SceneAttribute, SceneProp, SceneRevealFrom, ScrollActionKind, ScrollDriver, ScrollPlay, ScrollRange, TextRevealBy, TextRevealLook, applySceneFirstFrame, attachSceneRoots, attachScenes, buildSceneRecipe, colourAt, dampToward, gentleFrames, heldProgress, layoutBoxOnScreen, lettersSplittable, lightMotionWanted, lineIndexes, movedSceneKey, normalizeParallaxDepth, normalizeParallaxPhone, normalizeScrollRange, normalizeTracks, outermostNodeOf, parallaxFrames, parallaxOffset, parallaxRest, parallaxShift, playTextReveal, rangeDistance, rangeEnds, rangeProgress, revealClipPath, revealStagger, sceneBudget, sceneColourKeyAt, sceneDisplayValue, sceneFilmDensity, sceneFirstFrame, sceneFrame, sceneFrameDeclarations, sceneHasKeyAt, sceneHeightForScreens, sceneKeyPosition, sceneLayersOf, sceneNodeAttributes, scenePlayed, sceneRevealFromOf, sceneRootOnPath, sceneRootsIn, sceneScreensOf, sceneScrollState, sceneTrackDef, sceneTrackSpan, sceneWordOpacity, sceneWordsLit, scenesIn, scrollPlayFor, scrubPieceProgress, scrubTextReveal, splitForReveal, splitText, syncSceneAttributes, textPieces, textRevealByOf, textRevealLookOf, valueAt, withSceneKey, withScenePlayback, withSceneRevealFrom, withoutSceneKey, withoutScenePlayback };
1628
+ export { LETTER_PIECE_CAP, LIGHT_UP_PIECE_CAP, LetterRefusal, PARALLAX_DEPTH_DEFAULT, PARALLAX_PHONE_FACTOR, PARALLAX_REST_DEFAULT, PARALLAX_SPEED, PROGRESS_BAR_FRAMES, ParallaxDepth, ParallaxPhone, REVEAL_PIECE_CAP, SCENE_BUDGET, SCENE_DAMPING, SCENE_FILM_SMOOTH, SCENE_FLOW_RULES, SCENE_LENGTH, SCENE_MAX_SCREENS, SCENE_MIN_SCREENS, SCENE_PHONE_LENGTH, SCENE_PHONE_MAX_WIDTH, SCENE_REDUCED_MOTION_CSS, SCENE_REVEAL_DEFAULT, SCENE_STAGE_HEIGHT, SCENE_TRACK_DEFS, SCENE_WAKE_EVENT, SCENE_WORDS, SCENE_WORD_DIM, SCROLL_RANGE_DEFAULT, SCRUB_PIECES_IN_FLIGHT, SLIDER_HOLD_SHARE, SLIDER_SCROLL_STEP_SCREENS, SceneAttribute, SceneProp, SceneRevealFrom, ScrollActionKind, ScrollDriver, ScrollPlay, ScrollRange, TextRevealBy, TextRevealLook, applySceneFirstFrame, attachSceneRoots, attachScenes, buildSceneRecipe, colourAt, dampToward, gentleFrames, heldProgress, layoutBoxOnScreen, letterCount, letterRefusalOf, lettersSplittable, lightMotionWanted, lineIndexes, movedSceneKey, normalizeParallaxDepth, normalizeParallaxPhone, normalizeScrollRange, normalizeTracks, outermostNodeOf, parallaxFrames, parallaxOffset, parallaxRest, parallaxShift, playTextReveal, rangeDistance, rangeEnds, rangeProgress, revealClipPath, revealStagger, sceneBudget, sceneColourKeyAt, sceneDisplayValue, sceneFilmDensity, sceneFirstFrame, sceneFrame, sceneFrameDeclarations, sceneHasKeyAt, sceneHeightForScreens, sceneKeyPosition, sceneLayersOf, sceneNodeAttributes, scenePlayed, sceneRevealFromOf, sceneRootOnPath, sceneRootsIn, sceneScreensOf, sceneScrollState, sceneTrackDef, sceneTrackSpan, sceneWordOpacity, sceneWordsLit, scenesIn, scrollPlayFor, scrubPieceProgress, scrubTextReveal, splitForReveal, splitText, syncSceneAttributes, textPieces, textRevealByOf, textRevealLookOf, valueAt, withSceneKey, withScenePlayback, withSceneRevealFrom, withoutSceneKey, withoutScenePlayback };
1606
1629
  //# sourceMappingURL=vectoriox-iox-ui-scene-core.mjs.map