@number10/phaserjsx 0.5.2 → 0.6.1

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 (31) hide show
  1. package/dist/{TransformOriginView-2QSoN8wM.cjs → TransformOriginView-Dw_HKnFH.cjs} +245 -249
  2. package/dist/{TransformOriginView-2QSoN8wM.cjs.map → TransformOriginView-Dw_HKnFH.cjs.map} +1 -1
  3. package/dist/{TransformOriginView-Bh_khdJD.js → TransformOriginView-i8uVBHb1.js} +263 -267
  4. package/dist/{TransformOriginView-Bh_khdJD.js.map → TransformOriginView-i8uVBHb1.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/dist/utils/svg-texture.d.ts.map +1 -1
  31. package/package.json +1 -1
@@ -8009,7 +8009,7 @@ const strategies = {
8009
8009
  stack: new StackLayoutStrategy()
8010
8010
  };
8011
8011
  const LAYOUT_CYCLE_EPSILON = 0.5;
8012
- const LAYOUT_CYCLE_TIME_MS = 100;
8012
+ const LAYOUT_CYCLE_TIME_MS = 20;
8013
8013
  const LAYOUT_CYCLE_MAX = 5;
8014
8014
  const LAYOUT_MAX_SIZE = 2e5;
8015
8015
  const layoutCycleGuard = /* @__PURE__ */ new WeakMap();
@@ -8478,6 +8478,28 @@ function numberToRgb(num) {
8478
8478
  b: num & 255
8479
8479
  };
8480
8480
  }
8481
+ function rgbToHsl(r, g, b) {
8482
+ const red = r / 255;
8483
+ const green = g / 255;
8484
+ const blue = b / 255;
8485
+ const max = Math.max(red, green, blue);
8486
+ const min = Math.min(red, green, blue);
8487
+ const delta = max - min;
8488
+ const light = (max + min) / 2;
8489
+ if (delta === 0) {
8490
+ return { h: 0, s: 0, l: light };
8491
+ }
8492
+ const saturationValue = light > 0.5 ? delta / (2 - max - min) : delta / (max + min);
8493
+ let hueValue = 0;
8494
+ if (max === red) {
8495
+ hueValue = (green - blue) / delta + (green < blue ? 6 : 0);
8496
+ } else if (max === green) {
8497
+ hueValue = (blue - red) / delta + 2;
8498
+ } else {
8499
+ hueValue = (red - green) / delta + 4;
8500
+ }
8501
+ return { h: hueValue / 6, s: saturationValue, l: light };
8502
+ }
8481
8503
  function lighten(color, amount) {
8482
8504
  const rgb = numberToRgb(color);
8483
8505
  const factor = Math.max(0, Math.min(1, amount));
@@ -12094,13 +12116,14 @@ function Particles(props) {
12094
12116
  return /* @__PURE__ */ jsx("particles", { ...props });
12095
12117
  }
12096
12118
  function preprocessSvgForTinting(svg) {
12097
- return svg.replace(/fill="currentColor"/gi, 'fill="#FFFFFF"').replace(/fill='currentColor'/gi, "fill='#FFFFFF'").replace(/fill:\s*currentColor/gi, "fill: #FFFFFF").replace(/fill="#000000"/gi, 'fill="#FFFFFF"').replace(/fill="#000"/gi, 'fill="#FFFFFF"').replace(/fill='#000000'/gi, "fill='#FFFFFF'").replace(/fill='#000'/gi, "fill='#FFFFFF'");
12119
+ return svg.replace(/fill="currentColor"/gi, 'fill="#FFFFFF"').replace(/fill='currentColor'/gi, "fill='#FFFFFF'").replace(/fill:\s*currentColor/gi, "fill: #FFFFFF").replace(/stroke="currentColor"/gi, 'stroke="#FFFFFF"').replace(/stroke='currentColor'/gi, "stroke='#FFFFFF'").replace(/stroke:\s*currentColor/gi, "stroke: #FFFFFF").replace(/fill="#000000"/gi, 'fill="#FFFFFF"').replace(/fill="#000"/gi, 'fill="#FFFFFF"').replace(/fill='#000000'/gi, "fill='#FFFFFF'").replace(/fill='#000'/gi, "fill='#FFFFFF'").replace(/stroke="#000000"/gi, 'stroke="#FFFFFF"').replace(/stroke="#000"/gi, 'stroke="#FFFFFF"').replace(/stroke='#000000'/gi, "stroke='#FFFFFF'").replace(/stroke='#000'/gi, "stroke='#FFFFFF'");
12098
12120
  }
12099
12121
  async function svgToTexture(scene, key, svgOrUrl, width = 32, height = 32) {
12100
12122
  const trimmed = svgOrUrl.trim();
12101
12123
  let finalUrl;
12102
12124
  let shouldRevokeUrl = false;
12103
- if (trimmed.startsWith("<svg")) {
12125
+ const isSvgString = trimmed.startsWith("<svg") || trimmed.startsWith("<!--");
12126
+ if (isSvgString && trimmed.includes("<svg")) {
12104
12127
  const processedSvg = preprocessSvgForTinting(trimmed);
12105
12128
  const blob = new Blob([processedSvg], { type: "image/svg+xml" });
12106
12129
  finalUrl = URL.createObjectURL(blob);
@@ -12919,15 +12942,11 @@ function Accordion(props) {
12919
12942
  const animated = props.animated ?? themed.animated ?? false;
12920
12943
  const animationConfig = props.animationConfig ?? themed.animationConfig ?? "gentle";
12921
12944
  const [measuredHeight, setMeasuredHeight] = useState(maxHeight);
12922
- useEffect(() => {
12945
+ useLayoutEffect(() => {
12923
12946
  if (autoHeight && isOpen && measurementRef.current) {
12924
- setTimeout(() => {
12925
- if (measurementRef.current) {
12926
- const height = measurementRef.current.height;
12927
- setMeasuredHeight(height);
12928
- setContentHeight(height);
12929
- }
12930
- }, 0);
12947
+ const height = measurementRef.current.height;
12948
+ setMeasuredHeight(height);
12949
+ setContentHeight(height);
12931
12950
  }
12932
12951
  }, [isOpen, autoHeight]);
12933
12952
  const [contentHeight, setContentHeight] = useSpring(
@@ -13379,7 +13398,9 @@ function WrapText(props) {
13379
13398
  if (measureRafRef.current !== null) {
13380
13399
  return;
13381
13400
  }
13382
- measureRafRef.current = requestAnimationFrame(() => {
13401
+ if (!container.scene) return;
13402
+ measureRafRef.current = 1;
13403
+ getRenderContext(container.scene).deferLayout(() => {
13383
13404
  measureRafRef.current = null;
13384
13405
  performMeasure();
13385
13406
  });
@@ -13424,10 +13445,7 @@ function WrapText(props) {
13424
13445
  }, [scene, wrap, measureWidth]);
13425
13446
  useEffect(() => {
13426
13447
  return () => {
13427
- if (measureRafRef.current !== null) {
13428
- cancelAnimationFrame(measureRafRef.current);
13429
- measureRafRef.current = null;
13430
- }
13448
+ measureRafRef.current = null;
13431
13449
  };
13432
13450
  }, []);
13433
13451
  const measuredWidth = containerWidth > 0 ? containerWidth : lastWidthRef.current;
@@ -13878,95 +13896,84 @@ function CharText(props) {
13878
13896
  props.onApiReady(api);
13879
13897
  }
13880
13898
  }, [containerReady, props.onApiReady]);
13881
- useEffect(() => {
13899
+ useLayoutEffect(() => {
13882
13900
  if (!internalRef.current) return;
13883
13901
  const container = internalRef.current;
13884
13902
  const scene = container.scene;
13885
13903
  const prevText = chars.map((c) => c.char).join("");
13886
13904
  if (displayedText === prevText) return;
13887
- const timeoutId = setTimeout(() => {
13888
- const startX = padLeft;
13889
- const startY = padTop;
13890
- 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;
13891
- let lines;
13892
- let allChars;
13893
- if (multiline) {
13894
- lines = breakIntoLines(
13895
- displayedText,
13896
- scene,
13897
- effectiveMaxWidth,
13898
- textStyle,
13899
- charSpacing,
13900
- multiline,
13901
- wordWrap
13902
- );
13903
- positionLinesVertically(lines, lineHeight);
13904
- lines = handleOverflow(lines, maxLines, textOverflow);
13905
- allChars = [];
13906
- for (const line of lines) {
13907
- for (const charInfo of line.chars) {
13908
- allChars.push(charInfo);
13909
- }
13905
+ const startX = padLeft;
13906
+ const startY = padTop;
13907
+ 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;
13908
+ let lines;
13909
+ let allChars;
13910
+ if (multiline) {
13911
+ lines = breakIntoLines(
13912
+ displayedText,
13913
+ scene,
13914
+ effectiveMaxWidth,
13915
+ textStyle,
13916
+ charSpacing,
13917
+ multiline,
13918
+ wordWrap
13919
+ );
13920
+ positionLinesVertically(lines, lineHeight);
13921
+ lines = handleOverflow(lines, maxLines, textOverflow);
13922
+ allChars = [];
13923
+ for (const line of lines) {
13924
+ for (const charInfo of line.chars) {
13925
+ allChars.push(charInfo);
13910
13926
  }
13911
- } else {
13912
- allChars = [];
13913
- let currentX = 0;
13914
- for (let i = 0; i < displayedText.length; i++) {
13915
- const char = displayedText.charAt(i);
13916
- const tempText = scene.add.text(0, 0, char, textStyle ?? {});
13917
- const charWidth = tempText.width;
13918
- const charHeight = tempText.height;
13919
- tempText.destroy();
13920
- allChars.push({
13921
- char,
13922
- textObject: null,
13923
- x: currentX,
13924
- y: 0,
13925
- width: charWidth,
13926
- height: charHeight,
13927
- lineIndex: 0,
13928
- charIndex: i,
13929
- lineCharIndex: i
13930
- });
13931
- currentX += charWidth + charSpacing;
13932
- }
13933
- lines = allChars.length > 0 ? [createLineInfo(allChars, 0, charSpacing)] : [];
13934
- }
13935
- const usedTextObjects = [];
13936
- for (const charInfo of allChars) {
13937
- const textObj = getTextObject(
13938
- scene,
13939
- container,
13940
- textStyle,
13941
- textObjectPool,
13942
- activeTextObjects
13943
- );
13944
- textObj.setText(charInfo.char);
13945
- textObj.setPosition(startX + charInfo.x, startY + charInfo.y);
13946
- charInfo.textObject = textObj;
13947
- usedTextObjects.push(textObj);
13948
13927
  }
13949
- const currentActive = [...activeTextObjects.current];
13950
- for (const textObj of currentActive) {
13951
- if (!usedTextObjects.includes(textObj)) {
13952
- returnToPool(textObj, textObjectPool, activeTextObjects);
13953
- }
13928
+ } else {
13929
+ allChars = [];
13930
+ let currentX = 0;
13931
+ for (let i = 0; i < displayedText.length; i++) {
13932
+ const char = displayedText.charAt(i);
13933
+ const tempText = scene.add.text(0, 0, char, textStyle ?? {});
13934
+ const charWidth = tempText.width;
13935
+ const charHeight = tempText.height;
13936
+ tempText.destroy();
13937
+ allChars.push({
13938
+ char,
13939
+ textObject: null,
13940
+ x: currentX,
13941
+ y: 0,
13942
+ width: charWidth,
13943
+ height: charHeight,
13944
+ lineIndex: 0,
13945
+ charIndex: i,
13946
+ lineCharIndex: i
13947
+ });
13948
+ currentX += charWidth + charSpacing;
13954
13949
  }
13955
- const calculatedWidth = lines.length > 0 ? Math.max(...lines.map((l) => l.width)) : 0;
13956
- let calculatedHeight = 0;
13957
- if (lines.length > 0) {
13958
- const lastLine = lines[lines.length - 1];
13959
- if (lastLine) {
13960
- calculatedHeight = lastLine.y + lastLine.height;
13961
- }
13950
+ lines = allChars.length > 0 ? [createLineInfo(allChars, 0, charSpacing)] : [];
13951
+ }
13952
+ const usedTextObjects = [];
13953
+ for (const charInfo of allChars) {
13954
+ const textObj = getTextObject(scene, container, textStyle, textObjectPool, activeTextObjects);
13955
+ textObj.setText(charInfo.char);
13956
+ textObj.setPosition(startX + charInfo.x, startY + charInfo.y);
13957
+ charInfo.textObject = textObj;
13958
+ usedTextObjects.push(textObj);
13959
+ }
13960
+ const currentActive = [...activeTextObjects.current];
13961
+ for (const textObj of currentActive) {
13962
+ if (!usedTextObjects.includes(textObj)) {
13963
+ returnToPool(textObj, textObjectPool, activeTextObjects);
13962
13964
  }
13963
- setChars(allChars);
13964
- setWidth(calculatedWidth + horizontalPadding);
13965
- setHeight(calculatedHeight + verticalPadding);
13966
- }, 0);
13967
- return () => {
13968
- clearTimeout(timeoutId);
13969
- };
13965
+ }
13966
+ const calculatedWidth = lines.length > 0 ? Math.max(...lines.map((l) => l.width)) : 0;
13967
+ let calculatedHeight = 0;
13968
+ if (lines.length > 0) {
13969
+ const lastLine = lines[lines.length - 1];
13970
+ if (lastLine) {
13971
+ calculatedHeight = lastLine.y + lastLine.height;
13972
+ }
13973
+ }
13974
+ setChars(allChars);
13975
+ setWidth(calculatedWidth + horizontalPadding);
13976
+ setHeight(calculatedHeight + verticalPadding);
13970
13977
  }, [
13971
13978
  displayedText,
13972
13979
  textStyle,
@@ -13983,7 +13990,7 @@ function CharText(props) {
13983
13990
  props.maxWidth,
13984
13991
  props.width
13985
13992
  ]);
13986
- useEffect(() => {
13993
+ useLayoutEffect(() => {
13987
13994
  if (!internalRef.current || !showCursor) {
13988
13995
  if (cursorRef.current) {
13989
13996
  cursorRef.current.setVisible(false);
@@ -13997,97 +14004,95 @@ function CharText(props) {
13997
14004
  const container = internalRef.current;
13998
14005
  const scene = container.scene;
13999
14006
  if (chars.length === 0 && displayedText.length > 0) return;
14000
- setTimeout(() => {
14001
- const startX = padLeft;
14002
- const startY = padTop;
14003
- let cursorX = startX;
14004
- let cursorY = startY;
14005
- const clampedPosition = Math.max(0, Math.min(cursorPosition, displayedText.length));
14006
- let charBeforeCursor = null;
14007
- for (const char of chars) {
14008
- if (char.charIndex < clampedPosition) {
14009
- if (!charBeforeCursor || char.charIndex > charBeforeCursor.charIndex) {
14010
- charBeforeCursor = char;
14011
- }
14012
- }
14013
- }
14014
- const charBeforeCursorInText = clampedPosition > 0 ? displayedText.charAt(clampedPosition - 1) : null;
14015
- const isAfterNewline = charBeforeCursorInText === "\n";
14016
- if (charBeforeCursor) {
14017
- if (isAfterNewline) {
14018
- const nextLineIndex = charBeforeCursor.lineIndex + 1;
14019
- const firstCharOfNextLine = chars.find((c) => c.lineIndex === nextLineIndex);
14020
- if (firstCharOfNextLine) {
14021
- cursorX = startX + firstCharOfNextLine.x;
14022
- cursorY = startY + firstCharOfNextLine.y;
14023
- } else {
14024
- cursorX = startX;
14025
- const lineHeightPx = charBeforeCursor.height * lineHeight;
14026
- cursorY = startY + charBeforeCursor.y + lineHeightPx;
14027
- }
14028
- } else {
14029
- cursorX = startX + charBeforeCursor.x + charBeforeCursor.width + charSpacing;
14030
- cursorY = startY + charBeforeCursor.y;
14031
- }
14032
- } else if (chars.length > 0 && chars[0]) {
14033
- const firstChar = chars[0];
14034
- cursorX = startX + firstChar.x;
14035
- cursorY = startY + firstChar.y;
14036
- } else {
14037
- cursorX = startX;
14038
- cursorY = startY;
14039
- }
14040
- let cursorHeight = 20;
14007
+ const startX = padLeft;
14008
+ const startY = padTop;
14009
+ let cursorX = startX;
14010
+ let cursorY = startY;
14011
+ const clampedPosition = Math.max(0, Math.min(cursorPosition, displayedText.length));
14012
+ let charBeforeCursor = null;
14013
+ for (const char of chars) {
14014
+ if (char.charIndex < clampedPosition) {
14015
+ if (!charBeforeCursor || char.charIndex > charBeforeCursor.charIndex) {
14016
+ charBeforeCursor = char;
14017
+ }
14018
+ }
14019
+ }
14020
+ const charBeforeCursorInText = clampedPosition > 0 ? displayedText.charAt(clampedPosition - 1) : null;
14021
+ const isAfterNewline = charBeforeCursorInText === "\n";
14022
+ if (charBeforeCursor) {
14041
14023
  if (isAfterNewline) {
14042
- const nextLineIndex = charBeforeCursor ? charBeforeCursor.lineIndex + 1 : 0;
14024
+ const nextLineIndex = charBeforeCursor.lineIndex + 1;
14043
14025
  const firstCharOfNextLine = chars.find((c) => c.lineIndex === nextLineIndex);
14044
14026
  if (firstCharOfNextLine) {
14045
- cursorHeight = firstCharOfNextLine.height;
14046
- } else if (charBeforeCursor) {
14047
- cursorHeight = charBeforeCursor.height;
14048
- } else if (chars.length > 0 && chars[0]) {
14049
- cursorHeight = chars[0].height;
14027
+ cursorX = startX + firstCharOfNextLine.x;
14028
+ cursorY = startY + firstCharOfNextLine.y;
14029
+ } else {
14030
+ cursorX = startX;
14031
+ const lineHeightPx = charBeforeCursor.height * lineHeight;
14032
+ cursorY = startY + charBeforeCursor.y + lineHeightPx;
14050
14033
  }
14034
+ } else {
14035
+ cursorX = startX + charBeforeCursor.x + charBeforeCursor.width + charSpacing;
14036
+ cursorY = startY + charBeforeCursor.y;
14037
+ }
14038
+ } else if (chars.length > 0 && chars[0]) {
14039
+ const firstChar = chars[0];
14040
+ cursorX = startX + firstChar.x;
14041
+ cursorY = startY + firstChar.y;
14042
+ } else {
14043
+ cursorX = startX;
14044
+ cursorY = startY;
14045
+ }
14046
+ let cursorHeight = 20;
14047
+ if (isAfterNewline) {
14048
+ const nextLineIndex = charBeforeCursor ? charBeforeCursor.lineIndex + 1 : 0;
14049
+ const firstCharOfNextLine = chars.find((c) => c.lineIndex === nextLineIndex);
14050
+ if (firstCharOfNextLine) {
14051
+ cursorHeight = firstCharOfNextLine.height;
14051
14052
  } else if (charBeforeCursor) {
14052
14053
  cursorHeight = charBeforeCursor.height;
14053
14054
  } else if (chars.length > 0 && chars[0]) {
14054
14055
  cursorHeight = chars[0].height;
14055
14056
  }
14056
- if (!cursorRef.current) {
14057
- cursorRef.current = scene.add.rectangle(
14058
- cursorX,
14059
- cursorY,
14060
- cursorWidth,
14061
- cursorHeight,
14062
- cursorColor
14063
- );
14064
- cursorRef.current.setOrigin(0, 0);
14065
- container.add(cursorRef.current);
14066
- cursorTweenRef.current = scene.tweens.add({
14067
- targets: cursorRef.current,
14068
- alpha: { from: 1, to: 0 },
14069
- duration: cursorBlinkSpeed,
14070
- yoyo: true,
14071
- repeat: -1
14072
- });
14073
- } else {
14074
- cursorRef.current.setPosition(cursorX, cursorY);
14075
- cursorRef.current.setSize(cursorWidth, cursorHeight);
14076
- cursorRef.current.setFillStyle(cursorColor);
14077
- cursorRef.current.setVisible(true);
14078
- if (cursorTweenRef.current) {
14079
- cursorTweenRef.current.stop();
14080
- }
14081
- cursorRef.current.setAlpha(1);
14082
- cursorTweenRef.current = scene.tweens.add({
14083
- targets: cursorRef.current,
14084
- alpha: { from: 1, to: 0 },
14085
- duration: cursorBlinkSpeed,
14086
- yoyo: true,
14087
- repeat: -1
14088
- });
14057
+ } else if (charBeforeCursor) {
14058
+ cursorHeight = charBeforeCursor.height;
14059
+ } else if (chars.length > 0 && chars[0]) {
14060
+ cursorHeight = chars[0].height;
14061
+ }
14062
+ if (!cursorRef.current) {
14063
+ cursorRef.current = scene.add.rectangle(
14064
+ cursorX,
14065
+ cursorY,
14066
+ cursorWidth,
14067
+ cursorHeight,
14068
+ cursorColor
14069
+ );
14070
+ cursorRef.current.setOrigin(0, 0);
14071
+ container.add(cursorRef.current);
14072
+ cursorTweenRef.current = scene.tweens.add({
14073
+ targets: cursorRef.current,
14074
+ alpha: { from: 1, to: 0 },
14075
+ duration: cursorBlinkSpeed,
14076
+ yoyo: true,
14077
+ repeat: -1
14078
+ });
14079
+ } else {
14080
+ cursorRef.current.setPosition(cursorX, cursorY);
14081
+ cursorRef.current.setSize(cursorWidth, cursorHeight);
14082
+ cursorRef.current.setFillStyle(cursorColor);
14083
+ cursorRef.current.setVisible(true);
14084
+ if (cursorTweenRef.current) {
14085
+ cursorTweenRef.current.stop();
14089
14086
  }
14090
- }, 10);
14087
+ cursorRef.current.setAlpha(1);
14088
+ cursorTweenRef.current = scene.tweens.add({
14089
+ targets: cursorRef.current,
14090
+ alpha: { from: 1, to: 0 },
14091
+ duration: cursorBlinkSpeed,
14092
+ yoyo: true,
14093
+ repeat: -1
14094
+ });
14095
+ }
14091
14096
  return () => {
14092
14097
  if (cursorTweenRef.current) {
14093
14098
  cursorTweenRef.current.stop();
@@ -14105,7 +14110,7 @@ function CharText(props) {
14105
14110
  padTop,
14106
14111
  charSpacing
14107
14112
  ]);
14108
- useEffect(() => {
14113
+ useLayoutEffect(() => {
14109
14114
  if (!internalRef.current) return;
14110
14115
  const container = internalRef.current;
14111
14116
  const scene = container.scene;
@@ -14115,43 +14120,41 @@ function CharText(props) {
14115
14120
  return;
14116
14121
  }
14117
14122
  if (chars.length === 0) return;
14118
- setTimeout(() => {
14119
- const startX = padLeft;
14120
- const startY = padTop;
14121
- const lineGroups = /* @__PURE__ */ new Map();
14122
- for (const char of chars) {
14123
- if (char && char.charIndex >= selectionStart && char.charIndex < selectionEnd) {
14124
- const lineIndex = char.lineIndex;
14125
- if (!lineGroups.has(lineIndex)) {
14126
- lineGroups.set(lineIndex, []);
14127
- }
14128
- lineGroups.get(lineIndex)?.push(char);
14129
- }
14130
- }
14131
- for (const [_lineIndex, lineChars] of lineGroups) {
14132
- if (lineChars.length === 0) continue;
14133
- const firstChar = lineChars[0];
14134
- const lastChar = lineChars[lineChars.length - 1];
14135
- if (firstChar && lastChar) {
14136
- const selectionX = startX + firstChar.x;
14137
- const selectionY = startY + firstChar.y;
14138
- const selectionWidth = lastChar.x + lastChar.width - firstChar.x + (lineChars.length > 1 ? charSpacing : 0);
14139
- const selectionHeight = firstChar.height;
14140
- const selectionRect = scene.add.rectangle(
14141
- selectionX,
14142
- selectionY,
14143
- selectionWidth,
14144
- selectionHeight,
14145
- selectionColor,
14146
- selectionAlpha
14147
- );
14148
- selectionRect.setOrigin(0, 0);
14149
- container.add(selectionRect);
14150
- container.moveDown(selectionRect);
14151
- selectionRefs.current.push(selectionRect);
14152
- }
14123
+ const startX = padLeft;
14124
+ const startY = padTop;
14125
+ const lineGroups = /* @__PURE__ */ new Map();
14126
+ for (const char of chars) {
14127
+ if (char && char.charIndex >= selectionStart && char.charIndex < selectionEnd) {
14128
+ const lineIndex = char.lineIndex;
14129
+ if (!lineGroups.has(lineIndex)) {
14130
+ lineGroups.set(lineIndex, []);
14131
+ }
14132
+ lineGroups.get(lineIndex)?.push(char);
14133
+ }
14134
+ }
14135
+ for (const [_lineIndex, lineChars] of lineGroups) {
14136
+ if (lineChars.length === 0) continue;
14137
+ const firstChar = lineChars[0];
14138
+ const lastChar = lineChars[lineChars.length - 1];
14139
+ if (firstChar && lastChar) {
14140
+ const selectionX = startX + firstChar.x;
14141
+ const selectionY = startY + firstChar.y;
14142
+ const selectionWidth = lastChar.x + lastChar.width - firstChar.x + (lineChars.length > 1 ? charSpacing : 0);
14143
+ const selectionHeight = firstChar.height;
14144
+ const selectionRect = scene.add.rectangle(
14145
+ selectionX,
14146
+ selectionY,
14147
+ selectionWidth,
14148
+ selectionHeight,
14149
+ selectionColor,
14150
+ selectionAlpha
14151
+ );
14152
+ selectionRect.setOrigin(0, 0);
14153
+ container.add(selectionRect);
14154
+ container.moveDown(selectionRect);
14155
+ selectionRefs.current.push(selectionRect);
14153
14156
  }
14154
- }, 15);
14157
+ }
14155
14158
  return () => {
14156
14159
  selectionRefs.current.forEach((rect) => rect.destroy());
14157
14160
  selectionRefs.current = [];
@@ -14236,11 +14239,9 @@ function CharTextInput(props) {
14236
14239
  const selectionStart = selectionAnchor >= 0 ? Math.min(selectionAnchor, cursorPosition) : -1;
14237
14240
  const selectionEnd = selectionAnchor >= 0 ? Math.max(selectionAnchor, cursorPosition) : -1;
14238
14241
  const redraw = useRedraw();
14239
- useEffect(() => {
14240
- const timer = setTimeout(() => redraw(), 0);
14241
- return () => {
14242
- clearTimeout(timer);
14243
- };
14242
+ useLayoutEffect(() => {
14243
+ if (!containerRef.current) return;
14244
+ redraw();
14244
14245
  }, [containerRef.current]);
14245
14246
  useEffect(() => {
14246
14247
  if (!containerRef.current) return;
@@ -14715,7 +14716,7 @@ function ScrollView(props) {
14715
14716
  };
14716
14717
  const resolvedSnapThreshold = typeof snap === "object" && "positions" in snap ? snap.threshold ?? snapThreshold : snapThreshold;
14717
14718
  const effectiveSnapThreshold = resolvedSnapThreshold === void 0 || resolvedSnapThreshold < 0 ? Infinity : resolvedSnapThreshold;
14718
- useEffect(() => {
14719
+ useLayoutEffect(() => {
14719
14720
  if (!initialScroll) return;
14720
14721
  const allowAnimate = hasMountedRef.current;
14721
14722
  if (snap && typeof snap === "object" && "positions" in snap) {
@@ -15030,12 +15031,10 @@ function ScrollView(props) {
15030
15031
  };
15031
15032
  const redraw = useRedraw();
15032
15033
  const [visible, setVisible] = useState(false);
15033
- useEffect(() => {
15034
- const timer1 = setTimeout(() => redraw(), 0);
15035
- const timer2 = setTimeout(() => setVisible(true), 2);
15034
+ useLayoutEffect(() => {
15035
+ redraw();
15036
+ setVisible(true);
15036
15037
  return () => {
15037
- clearTimeout(timer1);
15038
- clearTimeout(timer2);
15039
15038
  if (wheelSnapTimeoutRef.current) {
15040
15039
  clearTimeout(wheelSnapTimeoutRef.current);
15041
15040
  }
@@ -15730,22 +15729,19 @@ function Joystick(props) {
15730
15729
  const activeTweenRef = useRef(null);
15731
15730
  const isDraggingRef = useRef(false);
15732
15731
  const currentThumbPosRef = useRef({ x: 0, y: 0 });
15733
- useEffect(() => {
15734
- setTimeout(() => {
15735
- const size2 = getLayoutSize(outerRef.current);
15736
- console.log(`Joystick size: ${JSON.stringify(size2)}`);
15737
- if (size2 != null) {
15738
- const newCenter = { x: size2.width / 2, y: size2.height / 2 };
15739
- setCenter(newCenter);
15740
- setSize({ width: size2.width, height: size2.height });
15741
- if (!isDraggingRef.current && !activeTweenRef.current) {
15742
- currentThumbPosRef.current = newCenter;
15743
- if (thumbRef.current != null) {
15744
- thumbRef.current.setPosition(newCenter.x, newCenter.y);
15745
- }
15732
+ useLayoutEffect(() => {
15733
+ const size2 = getLayoutSize(outerRef.current);
15734
+ if (size2 != null) {
15735
+ const newCenter = { x: size2.width / 2, y: size2.height / 2 };
15736
+ setCenter(newCenter);
15737
+ setSize({ width: size2.width, height: size2.height });
15738
+ if (!isDraggingRef.current && !activeTweenRef.current) {
15739
+ currentThumbPosRef.current = newCenter;
15740
+ if (thumbRef.current != null) {
15741
+ thumbRef.current.setPosition(newCenter.x, newCenter.y);
15746
15742
  }
15747
15743
  }
15748
- }, 0);
15744
+ }
15749
15745
  }, [outerRef]);
15750
15746
  const themeType = props.joystickTheme?.theme;
15751
15747
  const themeTint = props.joystickTheme?.tint;
@@ -15883,11 +15879,8 @@ function NineSliceButton(props) {
15883
15879
  const ref = useRef(null);
15884
15880
  const { applyEffect, stopEffects } = useGameObjectEffect(ref);
15885
15881
  const [show, setShow] = useState(false);
15886
- useEffect(() => {
15887
- const timer = setTimeout(() => setShow(true), 0);
15888
- return () => {
15889
- clearTimeout(timer);
15890
- };
15882
+ useLayoutEffect(() => {
15883
+ setShow(true);
15891
15884
  }, []);
15892
15885
  const innerWidth = (ref.current?.width ?? 0) - leftWidth - rightWidth;
15893
15886
  const innerHeight = (ref.current?.height ?? 0) - (topHeight ?? 0) - (bottomHeight ?? 0);
@@ -15961,14 +15954,14 @@ function RefOriginView({
15961
15954
  const handleOuterRef = (container) => {
15962
15955
  if (!container) return;
15963
15956
  outerRef.current = container;
15964
- setTimeout(() => {
15957
+ getRenderContext(container.scene).deferLayout(() => {
15965
15958
  const width2 = container.width;
15966
15959
  const height2 = container.height;
15967
15960
  const actualWidth = Number.isNaN(width2) ? 0 : width2;
15968
15961
  const actualHeight = Number.isNaN(height2) ? 0 : height2;
15969
15962
  if (actualHeight !== numericDimension.y || actualWidth !== numericDimension.x)
15970
15963
  setNumericWidth({ x: actualWidth, y: actualHeight });
15971
- }, 0);
15964
+ });
15972
15965
  };
15973
15966
  const pivotX = numericDimension.x * originX;
15974
15967
  const pivotY = numericDimension.y * originY;
@@ -16388,11 +16381,13 @@ function BaseSlider(props) {
16388
16381
  height: isHorizontal ? trackHeight : trackLength,
16389
16382
  backgroundColor: themed.trackColor ?? 4473924,
16390
16383
  cornerRadius: themed.trackBorderRadius ?? trackHeight / 2,
16384
+ alignItems: "start",
16385
+ padding: 0,
16391
16386
  direction: "stack",
16392
16387
  onTouch: handleTrackTouch,
16393
16388
  theme: nestedTheme,
16394
16389
  children: [
16395
- props.renderTrack ? /* @__PURE__ */ jsx(View, { children: props.renderTrack(fillStartPercentage, isRange ? fillEndPercentage : void 0) }, Math.random()) : /* @__PURE__ */ jsx(
16390
+ props.renderTrack ? /* @__PURE__ */ jsx(View, { children: props.renderTrack(fillStartPercentage, isRange ? fillEndPercentage : void 0) }) : /* @__PURE__ */ jsx(
16396
16391
  View,
16397
16392
  {
16398
16393
  x: isHorizontal ? fillStartPos : 0,
@@ -17040,16 +17035,17 @@ export {
17040
17035
  createElement as b7,
17041
17036
  mount as b8,
17042
17037
  unmount as b9,
17043
- getContrastRatio as bA,
17044
- applyDarkMode as bB,
17045
- applyLightMode as bC,
17046
- forestGreenPreset as bD,
17047
- generateColorScale as bE,
17048
- getPreset as bF,
17049
- midnightPreset as bG,
17050
- oceanBluePreset as bH,
17051
- presets as bI,
17052
- defaultTextStyleTokens as bJ,
17038
+ ensureContrast as bA,
17039
+ getContrastRatio as bB,
17040
+ applyDarkMode as bC,
17041
+ applyLightMode as bD,
17042
+ forestGreenPreset as bE,
17043
+ generateColorScale as bF,
17044
+ getPreset as bG,
17045
+ midnightPreset as bH,
17046
+ oceanBluePreset as bI,
17047
+ presets as bJ,
17048
+ defaultTextStyleTokens as bK,
17053
17049
  patchVNode as ba,
17054
17050
  unmountJSX as bb,
17055
17051
  Graphics as bc,
@@ -17068,14 +17064,14 @@ export {
17068
17064
  hexToNumber as bp,
17069
17065
  numberToHex as bq,
17070
17066
  numberToRgb as br,
17071
- rgbToNumber as bs,
17072
- darken as bt,
17073
- darkenHex as bu,
17074
- hex as bv,
17075
- lighten as bw,
17076
- lightenHex as bx,
17077
- createTextStyle as by,
17078
- ensureContrast as bz,
17067
+ rgbToHsl as bs,
17068
+ rgbToNumber as bt,
17069
+ darken as bu,
17070
+ darkenHex as bv,
17071
+ hex as bw,
17072
+ lighten as bx,
17073
+ lightenHex as by,
17074
+ createTextStyle as bz,
17079
17075
  Divider as c,
17080
17076
  Dropdown as d,
17081
17077
  createIconComponent as e,
@@ -17101,4 +17097,4 @@ export {
17101
17097
  getGestureManager as y,
17102
17098
  calculateLayout as z
17103
17099
  };
17104
- //# sourceMappingURL=TransformOriginView-Bh_khdJD.js.map
17100
+ //# sourceMappingURL=TransformOriginView-i8uVBHb1.js.map