@number10/phaserjsx 0.5.2 → 0.6.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.
Files changed (30) hide show
  1. package/dist/{TransformOriginView-2QSoN8wM.cjs → TransformOriginView-DsD_qZno.cjs} +242 -247
  2. package/dist/{TransformOriginView-2QSoN8wM.cjs.map → TransformOriginView-DsD_qZno.cjs.map} +1 -1
  3. package/dist/{TransformOriginView-Bh_khdJD.js → TransformOriginView-uYYqbEHW.js} +260 -265
  4. package/dist/{TransformOriginView-Bh_khdJD.js.map → TransformOriginView-uYYqbEHW.js.map} +1 -1
  5. package/dist/colors/color-utils.d.ts +24 -0
  6. package/dist/colors/color-utils.d.ts.map +1 -1
  7. package/dist/colors/index.d.ts +2 -2
  8. package/dist/colors/index.d.ts.map +1 -1
  9. package/dist/components/appliers/applyGestures.d.ts.map +1 -1
  10. package/dist/components/custom/Accordion.d.ts.map +1 -1
  11. package/dist/components/custom/CharText/CharText.d.ts.map +1 -1
  12. package/dist/components/custom/CharTextInput.d.ts.map +1 -1
  13. package/dist/components/custom/Joystick.d.ts.map +1 -1
  14. package/dist/components/custom/NineSliceButton.d.ts.map +1 -1
  15. package/dist/components/custom/RefOriginView.d.ts.map +1 -1
  16. package/dist/components/custom/ScrollView.d.ts.map +1 -1
  17. package/dist/components/custom/Slider.d.ts +1 -2
  18. package/dist/components/custom/Slider.d.ts.map +1 -1
  19. package/dist/components/custom/TransformOriginView.d.ts +1 -2
  20. package/dist/components/custom/TransformOriginView.d.ts.map +1 -1
  21. package/dist/components/custom/WrapText.d.ts.map +1 -1
  22. package/dist/components/custom/index.cjs +1 -1
  23. package/dist/components/custom/index.js +1 -1
  24. package/dist/components/internal/SceneWrapper.d.ts +3 -3
  25. package/dist/components/internal/SceneWrapper.d.ts.map +1 -1
  26. package/dist/index.cjs +3 -3
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.js +22 -22
  29. package/dist/index.js.map +1 -1
  30. package/package.json +1 -1
@@ -8027,7 +8027,7 @@ const strategies = {
8027
8027
  stack: new StackLayoutStrategy()
8028
8028
  };
8029
8029
  const LAYOUT_CYCLE_EPSILON = 0.5;
8030
- const LAYOUT_CYCLE_TIME_MS = 100;
8030
+ const LAYOUT_CYCLE_TIME_MS = 20;
8031
8031
  const LAYOUT_CYCLE_MAX = 5;
8032
8032
  const LAYOUT_MAX_SIZE = 2e5;
8033
8033
  const layoutCycleGuard = /* @__PURE__ */ new WeakMap();
@@ -8496,6 +8496,28 @@ function numberToRgb(num) {
8496
8496
  b: num & 255
8497
8497
  };
8498
8498
  }
8499
+ function rgbToHsl(r, g, b) {
8500
+ const red = r / 255;
8501
+ const green = g / 255;
8502
+ const blue = b / 255;
8503
+ const max = Math.max(red, green, blue);
8504
+ const min = Math.min(red, green, blue);
8505
+ const delta = max - min;
8506
+ const light = (max + min) / 2;
8507
+ if (delta === 0) {
8508
+ return { h: 0, s: 0, l: light };
8509
+ }
8510
+ const saturationValue = light > 0.5 ? delta / (2 - max - min) : delta / (max + min);
8511
+ let hueValue = 0;
8512
+ if (max === red) {
8513
+ hueValue = (green - blue) / delta + (green < blue ? 6 : 0);
8514
+ } else if (max === green) {
8515
+ hueValue = (blue - red) / delta + 2;
8516
+ } else {
8517
+ hueValue = (red - green) / delta + 4;
8518
+ }
8519
+ return { h: hueValue / 6, s: saturationValue, l: light };
8520
+ }
8499
8521
  function lighten(color, amount) {
8500
8522
  const rgb = numberToRgb(color);
8501
8523
  const factor = Math.max(0, Math.min(1, amount));
@@ -12937,15 +12959,11 @@ function Accordion(props) {
12937
12959
  const animated = props.animated ?? themed.animated ?? false;
12938
12960
  const animationConfig = props.animationConfig ?? themed.animationConfig ?? "gentle";
12939
12961
  const [measuredHeight, setMeasuredHeight] = useState(maxHeight);
12940
- useEffect(() => {
12962
+ useLayoutEffect(() => {
12941
12963
  if (autoHeight && isOpen && measurementRef.current) {
12942
- setTimeout(() => {
12943
- if (measurementRef.current) {
12944
- const height = measurementRef.current.height;
12945
- setMeasuredHeight(height);
12946
- setContentHeight(height);
12947
- }
12948
- }, 0);
12964
+ const height = measurementRef.current.height;
12965
+ setMeasuredHeight(height);
12966
+ setContentHeight(height);
12949
12967
  }
12950
12968
  }, [isOpen, autoHeight]);
12951
12969
  const [contentHeight, setContentHeight] = useSpring(
@@ -13397,7 +13415,9 @@ function WrapText(props) {
13397
13415
  if (measureRafRef.current !== null) {
13398
13416
  return;
13399
13417
  }
13400
- measureRafRef.current = requestAnimationFrame(() => {
13418
+ if (!container.scene) return;
13419
+ measureRafRef.current = 1;
13420
+ getRenderContext(container.scene).deferLayout(() => {
13401
13421
  measureRafRef.current = null;
13402
13422
  performMeasure();
13403
13423
  });
@@ -13442,10 +13462,7 @@ function WrapText(props) {
13442
13462
  }, [scene, wrap, measureWidth]);
13443
13463
  useEffect(() => {
13444
13464
  return () => {
13445
- if (measureRafRef.current !== null) {
13446
- cancelAnimationFrame(measureRafRef.current);
13447
- measureRafRef.current = null;
13448
- }
13465
+ measureRafRef.current = null;
13449
13466
  };
13450
13467
  }, []);
13451
13468
  const measuredWidth = containerWidth > 0 ? containerWidth : lastWidthRef.current;
@@ -13896,95 +13913,84 @@ function CharText(props) {
13896
13913
  props.onApiReady(api);
13897
13914
  }
13898
13915
  }, [containerReady, props.onApiReady]);
13899
- useEffect(() => {
13916
+ useLayoutEffect(() => {
13900
13917
  if (!internalRef.current) return;
13901
13918
  const container = internalRef.current;
13902
13919
  const scene = container.scene;
13903
13920
  const prevText = chars.map((c) => c.char).join("");
13904
13921
  if (displayedText === prevText) return;
13905
- const timeoutId = setTimeout(() => {
13906
- const startX = padLeft;
13907
- const startY = padTop;
13908
- const effectiveMaxWidth = multiline && props.maxWidth !== void 0 && typeof props.maxWidth === "number" ? props.maxWidth - horizontalPadding : multiline && props.width !== void 0 && typeof props.width === "number" ? props.width - horizontalPadding : Infinity;
13909
- let lines;
13910
- let allChars;
13911
- if (multiline) {
13912
- lines = breakIntoLines(
13913
- displayedText,
13914
- scene,
13915
- effectiveMaxWidth,
13916
- textStyle,
13917
- charSpacing,
13918
- multiline,
13919
- wordWrap
13920
- );
13921
- positionLinesVertically(lines, lineHeight);
13922
- lines = handleOverflow(lines, maxLines, textOverflow);
13923
- allChars = [];
13924
- for (const line of lines) {
13925
- for (const charInfo of line.chars) {
13926
- allChars.push(charInfo);
13927
- }
13922
+ const startX = padLeft;
13923
+ const startY = padTop;
13924
+ const effectiveMaxWidth = multiline && props.maxWidth !== void 0 && typeof props.maxWidth === "number" ? props.maxWidth - horizontalPadding : multiline && props.width !== void 0 && typeof props.width === "number" ? props.width - horizontalPadding : Infinity;
13925
+ let lines;
13926
+ let allChars;
13927
+ if (multiline) {
13928
+ lines = breakIntoLines(
13929
+ displayedText,
13930
+ scene,
13931
+ effectiveMaxWidth,
13932
+ textStyle,
13933
+ charSpacing,
13934
+ multiline,
13935
+ wordWrap
13936
+ );
13937
+ positionLinesVertically(lines, lineHeight);
13938
+ lines = handleOverflow(lines, maxLines, textOverflow);
13939
+ allChars = [];
13940
+ for (const line of lines) {
13941
+ for (const charInfo of line.chars) {
13942
+ allChars.push(charInfo);
13928
13943
  }
13929
- } else {
13930
- allChars = [];
13931
- let currentX = 0;
13932
- for (let i = 0; i < displayedText.length; i++) {
13933
- const char = displayedText.charAt(i);
13934
- const tempText = scene.add.text(0, 0, char, textStyle ?? {});
13935
- const charWidth = tempText.width;
13936
- const charHeight = tempText.height;
13937
- tempText.destroy();
13938
- allChars.push({
13939
- char,
13940
- textObject: null,
13941
- x: currentX,
13942
- y: 0,
13943
- width: charWidth,
13944
- height: charHeight,
13945
- lineIndex: 0,
13946
- charIndex: i,
13947
- lineCharIndex: i
13948
- });
13949
- currentX += charWidth + charSpacing;
13950
- }
13951
- lines = allChars.length > 0 ? [createLineInfo(allChars, 0, charSpacing)] : [];
13952
- }
13953
- const usedTextObjects = [];
13954
- for (const charInfo of allChars) {
13955
- const textObj = getTextObject(
13956
- scene,
13957
- container,
13958
- textStyle,
13959
- textObjectPool,
13960
- activeTextObjects
13961
- );
13962
- textObj.setText(charInfo.char);
13963
- textObj.setPosition(startX + charInfo.x, startY + charInfo.y);
13964
- charInfo.textObject = textObj;
13965
- usedTextObjects.push(textObj);
13966
13944
  }
13967
- const currentActive = [...activeTextObjects.current];
13968
- for (const textObj of currentActive) {
13969
- if (!usedTextObjects.includes(textObj)) {
13970
- returnToPool(textObj, textObjectPool, activeTextObjects);
13971
- }
13945
+ } else {
13946
+ allChars = [];
13947
+ let currentX = 0;
13948
+ for (let i = 0; i < displayedText.length; i++) {
13949
+ const char = displayedText.charAt(i);
13950
+ const tempText = scene.add.text(0, 0, char, textStyle ?? {});
13951
+ const charWidth = tempText.width;
13952
+ const charHeight = tempText.height;
13953
+ tempText.destroy();
13954
+ allChars.push({
13955
+ char,
13956
+ textObject: null,
13957
+ x: currentX,
13958
+ y: 0,
13959
+ width: charWidth,
13960
+ height: charHeight,
13961
+ lineIndex: 0,
13962
+ charIndex: i,
13963
+ lineCharIndex: i
13964
+ });
13965
+ currentX += charWidth + charSpacing;
13972
13966
  }
13973
- const calculatedWidth = lines.length > 0 ? Math.max(...lines.map((l) => l.width)) : 0;
13974
- let calculatedHeight = 0;
13975
- if (lines.length > 0) {
13976
- const lastLine = lines[lines.length - 1];
13977
- if (lastLine) {
13978
- calculatedHeight = lastLine.y + lastLine.height;
13979
- }
13967
+ lines = allChars.length > 0 ? [createLineInfo(allChars, 0, charSpacing)] : [];
13968
+ }
13969
+ const usedTextObjects = [];
13970
+ for (const charInfo of allChars) {
13971
+ const textObj = getTextObject(scene, container, textStyle, textObjectPool, activeTextObjects);
13972
+ textObj.setText(charInfo.char);
13973
+ textObj.setPosition(startX + charInfo.x, startY + charInfo.y);
13974
+ charInfo.textObject = textObj;
13975
+ usedTextObjects.push(textObj);
13976
+ }
13977
+ const currentActive = [...activeTextObjects.current];
13978
+ for (const textObj of currentActive) {
13979
+ if (!usedTextObjects.includes(textObj)) {
13980
+ returnToPool(textObj, textObjectPool, activeTextObjects);
13980
13981
  }
13981
- setChars(allChars);
13982
- setWidth(calculatedWidth + horizontalPadding);
13983
- setHeight(calculatedHeight + verticalPadding);
13984
- }, 0);
13985
- return () => {
13986
- clearTimeout(timeoutId);
13987
- };
13982
+ }
13983
+ const calculatedWidth = lines.length > 0 ? Math.max(...lines.map((l) => l.width)) : 0;
13984
+ let calculatedHeight = 0;
13985
+ if (lines.length > 0) {
13986
+ const lastLine = lines[lines.length - 1];
13987
+ if (lastLine) {
13988
+ calculatedHeight = lastLine.y + lastLine.height;
13989
+ }
13990
+ }
13991
+ setChars(allChars);
13992
+ setWidth(calculatedWidth + horizontalPadding);
13993
+ setHeight(calculatedHeight + verticalPadding);
13988
13994
  }, [
13989
13995
  displayedText,
13990
13996
  textStyle,
@@ -14001,7 +14007,7 @@ function CharText(props) {
14001
14007
  props.maxWidth,
14002
14008
  props.width
14003
14009
  ]);
14004
- useEffect(() => {
14010
+ useLayoutEffect(() => {
14005
14011
  if (!internalRef.current || !showCursor) {
14006
14012
  if (cursorRef.current) {
14007
14013
  cursorRef.current.setVisible(false);
@@ -14015,97 +14021,95 @@ function CharText(props) {
14015
14021
  const container = internalRef.current;
14016
14022
  const scene = container.scene;
14017
14023
  if (chars.length === 0 && displayedText.length > 0) return;
14018
- setTimeout(() => {
14019
- const startX = padLeft;
14020
- const startY = padTop;
14021
- let cursorX = startX;
14022
- let cursorY = startY;
14023
- const clampedPosition = Math.max(0, Math.min(cursorPosition, displayedText.length));
14024
- let charBeforeCursor = null;
14025
- for (const char of chars) {
14026
- if (char.charIndex < clampedPosition) {
14027
- if (!charBeforeCursor || char.charIndex > charBeforeCursor.charIndex) {
14028
- charBeforeCursor = char;
14029
- }
14030
- }
14031
- }
14032
- const charBeforeCursorInText = clampedPosition > 0 ? displayedText.charAt(clampedPosition - 1) : null;
14033
- const isAfterNewline = charBeforeCursorInText === "\n";
14034
- if (charBeforeCursor) {
14035
- if (isAfterNewline) {
14036
- const nextLineIndex = charBeforeCursor.lineIndex + 1;
14037
- const firstCharOfNextLine = chars.find((c) => c.lineIndex === nextLineIndex);
14038
- if (firstCharOfNextLine) {
14039
- cursorX = startX + firstCharOfNextLine.x;
14040
- cursorY = startY + firstCharOfNextLine.y;
14041
- } else {
14042
- cursorX = startX;
14043
- const lineHeightPx = charBeforeCursor.height * lineHeight;
14044
- cursorY = startY + charBeforeCursor.y + lineHeightPx;
14045
- }
14046
- } else {
14047
- cursorX = startX + charBeforeCursor.x + charBeforeCursor.width + charSpacing;
14048
- cursorY = startY + charBeforeCursor.y;
14049
- }
14050
- } else if (chars.length > 0 && chars[0]) {
14051
- const firstChar = chars[0];
14052
- cursorX = startX + firstChar.x;
14053
- cursorY = startY + firstChar.y;
14054
- } else {
14055
- cursorX = startX;
14056
- cursorY = startY;
14057
- }
14058
- let cursorHeight = 20;
14024
+ const startX = padLeft;
14025
+ const startY = padTop;
14026
+ let cursorX = startX;
14027
+ let cursorY = startY;
14028
+ const clampedPosition = Math.max(0, Math.min(cursorPosition, displayedText.length));
14029
+ let charBeforeCursor = null;
14030
+ for (const char of chars) {
14031
+ if (char.charIndex < clampedPosition) {
14032
+ if (!charBeforeCursor || char.charIndex > charBeforeCursor.charIndex) {
14033
+ charBeforeCursor = char;
14034
+ }
14035
+ }
14036
+ }
14037
+ const charBeforeCursorInText = clampedPosition > 0 ? displayedText.charAt(clampedPosition - 1) : null;
14038
+ const isAfterNewline = charBeforeCursorInText === "\n";
14039
+ if (charBeforeCursor) {
14059
14040
  if (isAfterNewline) {
14060
- const nextLineIndex = charBeforeCursor ? charBeforeCursor.lineIndex + 1 : 0;
14041
+ const nextLineIndex = charBeforeCursor.lineIndex + 1;
14061
14042
  const firstCharOfNextLine = chars.find((c) => c.lineIndex === nextLineIndex);
14062
14043
  if (firstCharOfNextLine) {
14063
- cursorHeight = firstCharOfNextLine.height;
14064
- } else if (charBeforeCursor) {
14065
- cursorHeight = charBeforeCursor.height;
14066
- } else if (chars.length > 0 && chars[0]) {
14067
- cursorHeight = chars[0].height;
14044
+ cursorX = startX + firstCharOfNextLine.x;
14045
+ cursorY = startY + firstCharOfNextLine.y;
14046
+ } else {
14047
+ cursorX = startX;
14048
+ const lineHeightPx = charBeforeCursor.height * lineHeight;
14049
+ cursorY = startY + charBeforeCursor.y + lineHeightPx;
14068
14050
  }
14051
+ } else {
14052
+ cursorX = startX + charBeforeCursor.x + charBeforeCursor.width + charSpacing;
14053
+ cursorY = startY + charBeforeCursor.y;
14054
+ }
14055
+ } else if (chars.length > 0 && chars[0]) {
14056
+ const firstChar = chars[0];
14057
+ cursorX = startX + firstChar.x;
14058
+ cursorY = startY + firstChar.y;
14059
+ } else {
14060
+ cursorX = startX;
14061
+ cursorY = startY;
14062
+ }
14063
+ let cursorHeight = 20;
14064
+ if (isAfterNewline) {
14065
+ const nextLineIndex = charBeforeCursor ? charBeforeCursor.lineIndex + 1 : 0;
14066
+ const firstCharOfNextLine = chars.find((c) => c.lineIndex === nextLineIndex);
14067
+ if (firstCharOfNextLine) {
14068
+ cursorHeight = firstCharOfNextLine.height;
14069
14069
  } else if (charBeforeCursor) {
14070
14070
  cursorHeight = charBeforeCursor.height;
14071
14071
  } else if (chars.length > 0 && chars[0]) {
14072
14072
  cursorHeight = chars[0].height;
14073
14073
  }
14074
- if (!cursorRef.current) {
14075
- cursorRef.current = scene.add.rectangle(
14076
- cursorX,
14077
- cursorY,
14078
- cursorWidth,
14079
- cursorHeight,
14080
- cursorColor
14081
- );
14082
- cursorRef.current.setOrigin(0, 0);
14083
- container.add(cursorRef.current);
14084
- cursorTweenRef.current = scene.tweens.add({
14085
- targets: cursorRef.current,
14086
- alpha: { from: 1, to: 0 },
14087
- duration: cursorBlinkSpeed,
14088
- yoyo: true,
14089
- repeat: -1
14090
- });
14091
- } else {
14092
- cursorRef.current.setPosition(cursorX, cursorY);
14093
- cursorRef.current.setSize(cursorWidth, cursorHeight);
14094
- cursorRef.current.setFillStyle(cursorColor);
14095
- cursorRef.current.setVisible(true);
14096
- if (cursorTweenRef.current) {
14097
- cursorTweenRef.current.stop();
14098
- }
14099
- cursorRef.current.setAlpha(1);
14100
- cursorTweenRef.current = scene.tweens.add({
14101
- targets: cursorRef.current,
14102
- alpha: { from: 1, to: 0 },
14103
- duration: cursorBlinkSpeed,
14104
- yoyo: true,
14105
- repeat: -1
14106
- });
14074
+ } else if (charBeforeCursor) {
14075
+ cursorHeight = charBeforeCursor.height;
14076
+ } else if (chars.length > 0 && chars[0]) {
14077
+ cursorHeight = chars[0].height;
14078
+ }
14079
+ if (!cursorRef.current) {
14080
+ cursorRef.current = scene.add.rectangle(
14081
+ cursorX,
14082
+ cursorY,
14083
+ cursorWidth,
14084
+ cursorHeight,
14085
+ cursorColor
14086
+ );
14087
+ cursorRef.current.setOrigin(0, 0);
14088
+ container.add(cursorRef.current);
14089
+ cursorTweenRef.current = scene.tweens.add({
14090
+ targets: cursorRef.current,
14091
+ alpha: { from: 1, to: 0 },
14092
+ duration: cursorBlinkSpeed,
14093
+ yoyo: true,
14094
+ repeat: -1
14095
+ });
14096
+ } else {
14097
+ cursorRef.current.setPosition(cursorX, cursorY);
14098
+ cursorRef.current.setSize(cursorWidth, cursorHeight);
14099
+ cursorRef.current.setFillStyle(cursorColor);
14100
+ cursorRef.current.setVisible(true);
14101
+ if (cursorTweenRef.current) {
14102
+ cursorTweenRef.current.stop();
14107
14103
  }
14108
- }, 10);
14104
+ cursorRef.current.setAlpha(1);
14105
+ cursorTweenRef.current = scene.tweens.add({
14106
+ targets: cursorRef.current,
14107
+ alpha: { from: 1, to: 0 },
14108
+ duration: cursorBlinkSpeed,
14109
+ yoyo: true,
14110
+ repeat: -1
14111
+ });
14112
+ }
14109
14113
  return () => {
14110
14114
  if (cursorTweenRef.current) {
14111
14115
  cursorTweenRef.current.stop();
@@ -14123,7 +14127,7 @@ function CharText(props) {
14123
14127
  padTop,
14124
14128
  charSpacing
14125
14129
  ]);
14126
- useEffect(() => {
14130
+ useLayoutEffect(() => {
14127
14131
  if (!internalRef.current) return;
14128
14132
  const container = internalRef.current;
14129
14133
  const scene = container.scene;
@@ -14133,43 +14137,41 @@ function CharText(props) {
14133
14137
  return;
14134
14138
  }
14135
14139
  if (chars.length === 0) return;
14136
- setTimeout(() => {
14137
- const startX = padLeft;
14138
- const startY = padTop;
14139
- const lineGroups = /* @__PURE__ */ new Map();
14140
- for (const char of chars) {
14141
- if (char && char.charIndex >= selectionStart && char.charIndex < selectionEnd) {
14142
- const lineIndex = char.lineIndex;
14143
- if (!lineGroups.has(lineIndex)) {
14144
- lineGroups.set(lineIndex, []);
14145
- }
14146
- lineGroups.get(lineIndex)?.push(char);
14147
- }
14148
- }
14149
- for (const [_lineIndex, lineChars] of lineGroups) {
14150
- if (lineChars.length === 0) continue;
14151
- const firstChar = lineChars[0];
14152
- const lastChar = lineChars[lineChars.length - 1];
14153
- if (firstChar && lastChar) {
14154
- const selectionX = startX + firstChar.x;
14155
- const selectionY = startY + firstChar.y;
14156
- const selectionWidth = lastChar.x + lastChar.width - firstChar.x + (lineChars.length > 1 ? charSpacing : 0);
14157
- const selectionHeight = firstChar.height;
14158
- const selectionRect = scene.add.rectangle(
14159
- selectionX,
14160
- selectionY,
14161
- selectionWidth,
14162
- selectionHeight,
14163
- selectionColor,
14164
- selectionAlpha
14165
- );
14166
- selectionRect.setOrigin(0, 0);
14167
- container.add(selectionRect);
14168
- container.moveDown(selectionRect);
14169
- selectionRefs.current.push(selectionRect);
14170
- }
14140
+ const startX = padLeft;
14141
+ const startY = padTop;
14142
+ const lineGroups = /* @__PURE__ */ new Map();
14143
+ for (const char of chars) {
14144
+ if (char && char.charIndex >= selectionStart && char.charIndex < selectionEnd) {
14145
+ const lineIndex = char.lineIndex;
14146
+ if (!lineGroups.has(lineIndex)) {
14147
+ lineGroups.set(lineIndex, []);
14148
+ }
14149
+ lineGroups.get(lineIndex)?.push(char);
14150
+ }
14151
+ }
14152
+ for (const [_lineIndex, lineChars] of lineGroups) {
14153
+ if (lineChars.length === 0) continue;
14154
+ const firstChar = lineChars[0];
14155
+ const lastChar = lineChars[lineChars.length - 1];
14156
+ if (firstChar && lastChar) {
14157
+ const selectionX = startX + firstChar.x;
14158
+ const selectionY = startY + firstChar.y;
14159
+ const selectionWidth = lastChar.x + lastChar.width - firstChar.x + (lineChars.length > 1 ? charSpacing : 0);
14160
+ const selectionHeight = firstChar.height;
14161
+ const selectionRect = scene.add.rectangle(
14162
+ selectionX,
14163
+ selectionY,
14164
+ selectionWidth,
14165
+ selectionHeight,
14166
+ selectionColor,
14167
+ selectionAlpha
14168
+ );
14169
+ selectionRect.setOrigin(0, 0);
14170
+ container.add(selectionRect);
14171
+ container.moveDown(selectionRect);
14172
+ selectionRefs.current.push(selectionRect);
14171
14173
  }
14172
- }, 15);
14174
+ }
14173
14175
  return () => {
14174
14176
  selectionRefs.current.forEach((rect) => rect.destroy());
14175
14177
  selectionRefs.current = [];
@@ -14254,11 +14256,9 @@ function CharTextInput(props) {
14254
14256
  const selectionStart = selectionAnchor >= 0 ? Math.min(selectionAnchor, cursorPosition) : -1;
14255
14257
  const selectionEnd = selectionAnchor >= 0 ? Math.max(selectionAnchor, cursorPosition) : -1;
14256
14258
  const redraw = useRedraw();
14257
- useEffect(() => {
14258
- const timer = setTimeout(() => redraw(), 0);
14259
- return () => {
14260
- clearTimeout(timer);
14261
- };
14259
+ useLayoutEffect(() => {
14260
+ if (!containerRef.current) return;
14261
+ redraw();
14262
14262
  }, [containerRef.current]);
14263
14263
  useEffect(() => {
14264
14264
  if (!containerRef.current) return;
@@ -14733,7 +14733,7 @@ function ScrollView(props) {
14733
14733
  };
14734
14734
  const resolvedSnapThreshold = typeof snap === "object" && "positions" in snap ? snap.threshold ?? snapThreshold : snapThreshold;
14735
14735
  const effectiveSnapThreshold = resolvedSnapThreshold === void 0 || resolvedSnapThreshold < 0 ? Infinity : resolvedSnapThreshold;
14736
- useEffect(() => {
14736
+ useLayoutEffect(() => {
14737
14737
  if (!initialScroll) return;
14738
14738
  const allowAnimate = hasMountedRef.current;
14739
14739
  if (snap && typeof snap === "object" && "positions" in snap) {
@@ -15048,12 +15048,10 @@ function ScrollView(props) {
15048
15048
  };
15049
15049
  const redraw = useRedraw();
15050
15050
  const [visible, setVisible] = useState(false);
15051
- useEffect(() => {
15052
- const timer1 = setTimeout(() => redraw(), 0);
15053
- const timer2 = setTimeout(() => setVisible(true), 2);
15051
+ useLayoutEffect(() => {
15052
+ redraw();
15053
+ setVisible(true);
15054
15054
  return () => {
15055
- clearTimeout(timer1);
15056
- clearTimeout(timer2);
15057
15055
  if (wheelSnapTimeoutRef.current) {
15058
15056
  clearTimeout(wheelSnapTimeoutRef.current);
15059
15057
  }
@@ -15748,22 +15746,19 @@ function Joystick(props) {
15748
15746
  const activeTweenRef = useRef(null);
15749
15747
  const isDraggingRef = useRef(false);
15750
15748
  const currentThumbPosRef = useRef({ x: 0, y: 0 });
15751
- useEffect(() => {
15752
- setTimeout(() => {
15753
- const size2 = getLayoutSize(outerRef.current);
15754
- console.log(`Joystick size: ${JSON.stringify(size2)}`);
15755
- if (size2 != null) {
15756
- const newCenter = { x: size2.width / 2, y: size2.height / 2 };
15757
- setCenter(newCenter);
15758
- setSize({ width: size2.width, height: size2.height });
15759
- if (!isDraggingRef.current && !activeTweenRef.current) {
15760
- currentThumbPosRef.current = newCenter;
15761
- if (thumbRef.current != null) {
15762
- thumbRef.current.setPosition(newCenter.x, newCenter.y);
15763
- }
15749
+ useLayoutEffect(() => {
15750
+ const size2 = getLayoutSize(outerRef.current);
15751
+ if (size2 != null) {
15752
+ const newCenter = { x: size2.width / 2, y: size2.height / 2 };
15753
+ setCenter(newCenter);
15754
+ setSize({ width: size2.width, height: size2.height });
15755
+ if (!isDraggingRef.current && !activeTweenRef.current) {
15756
+ currentThumbPosRef.current = newCenter;
15757
+ if (thumbRef.current != null) {
15758
+ thumbRef.current.setPosition(newCenter.x, newCenter.y);
15764
15759
  }
15765
15760
  }
15766
- }, 0);
15761
+ }
15767
15762
  }, [outerRef]);
15768
15763
  const themeType = props.joystickTheme?.theme;
15769
15764
  const themeTint = props.joystickTheme?.tint;
@@ -15901,11 +15896,8 @@ function NineSliceButton(props) {
15901
15896
  const ref = useRef(null);
15902
15897
  const { applyEffect, stopEffects } = useGameObjectEffect(ref);
15903
15898
  const [show, setShow] = useState(false);
15904
- useEffect(() => {
15905
- const timer = setTimeout(() => setShow(true), 0);
15906
- return () => {
15907
- clearTimeout(timer);
15908
- };
15899
+ useLayoutEffect(() => {
15900
+ setShow(true);
15909
15901
  }, []);
15910
15902
  const innerWidth = (ref.current?.width ?? 0) - leftWidth - rightWidth;
15911
15903
  const innerHeight = (ref.current?.height ?? 0) - (topHeight ?? 0) - (bottomHeight ?? 0);
@@ -15979,14 +15971,14 @@ function RefOriginView({
15979
15971
  const handleOuterRef = (container) => {
15980
15972
  if (!container) return;
15981
15973
  outerRef.current = container;
15982
- setTimeout(() => {
15974
+ getRenderContext(container.scene).deferLayout(() => {
15983
15975
  const width2 = container.width;
15984
15976
  const height2 = container.height;
15985
15977
  const actualWidth = Number.isNaN(width2) ? 0 : width2;
15986
15978
  const actualHeight = Number.isNaN(height2) ? 0 : height2;
15987
15979
  if (actualHeight !== numericDimension.y || actualWidth !== numericDimension.x)
15988
15980
  setNumericWidth({ x: actualWidth, y: actualHeight });
15989
- }, 0);
15981
+ });
15990
15982
  };
15991
15983
  const pivotX = numericDimension.x * originX;
15992
15984
  const pivotY = numericDimension.y * originY;
@@ -16406,11 +16398,13 @@ function BaseSlider(props) {
16406
16398
  height: isHorizontal ? trackHeight : trackLength,
16407
16399
  backgroundColor: themed.trackColor ?? 4473924,
16408
16400
  cornerRadius: themed.trackBorderRadius ?? trackHeight / 2,
16401
+ alignItems: "start",
16402
+ padding: 0,
16409
16403
  direction: "stack",
16410
16404
  onTouch: handleTrackTouch,
16411
16405
  theme: nestedTheme,
16412
16406
  children: [
16413
- props.renderTrack ? /* @__PURE__ */ jsxRuntime.jsx(View, { children: props.renderTrack(fillStartPercentage, isRange ? fillEndPercentage : void 0) }, Math.random()) : /* @__PURE__ */ jsxRuntime.jsx(
16407
+ props.renderTrack ? /* @__PURE__ */ jsxRuntime.jsx(View, { children: props.renderTrack(fillStartPercentage, isRange ? fillEndPercentage : void 0) }) : /* @__PURE__ */ jsxRuntime.jsx(
16414
16408
  View,
16415
16409
  {
16416
16410
  x: isHorizontal ? fillStartPos : 0,
@@ -17086,6 +17080,7 @@ exports.releaseSVGTextures = releaseSVGTextures;
17086
17080
  exports.remountAll = remountAll;
17087
17081
  exports.resolveEffect = resolveEffect;
17088
17082
  exports.resolveSize = resolveSize;
17083
+ exports.rgbToHsl = rgbToHsl;
17089
17084
  exports.rgbToNumber = rgbToNumber;
17090
17085
  exports.shallowEqual = shallowEqual;
17091
17086
  exports.shouldComponentUpdate = shouldComponentUpdate;
@@ -17117,4 +17112,4 @@ exports.useViewportSize = useViewportSize;
17117
17112
  exports.useWorldLayoutRect = useWorldLayoutRect;
17118
17113
  exports.viewportRegistry = viewportRegistry;
17119
17114
  exports.withHooks = withHooks;
17120
- //# sourceMappingURL=TransformOriginView-2QSoN8wM.cjs.map
17115
+ //# sourceMappingURL=TransformOriginView-DsD_qZno.cjs.map