@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
@@ -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));
@@ -12112,13 +12134,14 @@ function Particles(props) {
12112
12134
  return /* @__PURE__ */ jsxRuntime.jsx("particles", { ...props });
12113
12135
  }
12114
12136
  function preprocessSvgForTinting(svg) {
12115
- 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'");
12137
+ 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'");
12116
12138
  }
12117
12139
  async function svgToTexture(scene, key, svgOrUrl, width = 32, height = 32) {
12118
12140
  const trimmed = svgOrUrl.trim();
12119
12141
  let finalUrl;
12120
12142
  let shouldRevokeUrl = false;
12121
- if (trimmed.startsWith("<svg")) {
12143
+ const isSvgString = trimmed.startsWith("<svg") || trimmed.startsWith("<!--");
12144
+ if (isSvgString && trimmed.includes("<svg")) {
12122
12145
  const processedSvg = preprocessSvgForTinting(trimmed);
12123
12146
  const blob = new Blob([processedSvg], { type: "image/svg+xml" });
12124
12147
  finalUrl = URL.createObjectURL(blob);
@@ -12937,15 +12960,11 @@ function Accordion(props) {
12937
12960
  const animated = props.animated ?? themed.animated ?? false;
12938
12961
  const animationConfig = props.animationConfig ?? themed.animationConfig ?? "gentle";
12939
12962
  const [measuredHeight, setMeasuredHeight] = useState(maxHeight);
12940
- useEffect(() => {
12963
+ useLayoutEffect(() => {
12941
12964
  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);
12965
+ const height = measurementRef.current.height;
12966
+ setMeasuredHeight(height);
12967
+ setContentHeight(height);
12949
12968
  }
12950
12969
  }, [isOpen, autoHeight]);
12951
12970
  const [contentHeight, setContentHeight] = useSpring(
@@ -13397,7 +13416,9 @@ function WrapText(props) {
13397
13416
  if (measureRafRef.current !== null) {
13398
13417
  return;
13399
13418
  }
13400
- measureRafRef.current = requestAnimationFrame(() => {
13419
+ if (!container.scene) return;
13420
+ measureRafRef.current = 1;
13421
+ getRenderContext(container.scene).deferLayout(() => {
13401
13422
  measureRafRef.current = null;
13402
13423
  performMeasure();
13403
13424
  });
@@ -13442,10 +13463,7 @@ function WrapText(props) {
13442
13463
  }, [scene, wrap, measureWidth]);
13443
13464
  useEffect(() => {
13444
13465
  return () => {
13445
- if (measureRafRef.current !== null) {
13446
- cancelAnimationFrame(measureRafRef.current);
13447
- measureRafRef.current = null;
13448
- }
13466
+ measureRafRef.current = null;
13449
13467
  };
13450
13468
  }, []);
13451
13469
  const measuredWidth = containerWidth > 0 ? containerWidth : lastWidthRef.current;
@@ -13896,95 +13914,84 @@ function CharText(props) {
13896
13914
  props.onApiReady(api);
13897
13915
  }
13898
13916
  }, [containerReady, props.onApiReady]);
13899
- useEffect(() => {
13917
+ useLayoutEffect(() => {
13900
13918
  if (!internalRef.current) return;
13901
13919
  const container = internalRef.current;
13902
13920
  const scene = container.scene;
13903
13921
  const prevText = chars.map((c) => c.char).join("");
13904
13922
  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
- }
13923
+ const startX = padLeft;
13924
+ const startY = padTop;
13925
+ 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;
13926
+ let lines;
13927
+ let allChars;
13928
+ if (multiline) {
13929
+ lines = breakIntoLines(
13930
+ displayedText,
13931
+ scene,
13932
+ effectiveMaxWidth,
13933
+ textStyle,
13934
+ charSpacing,
13935
+ multiline,
13936
+ wordWrap
13937
+ );
13938
+ positionLinesVertically(lines, lineHeight);
13939
+ lines = handleOverflow(lines, maxLines, textOverflow);
13940
+ allChars = [];
13941
+ for (const line of lines) {
13942
+ for (const charInfo of line.chars) {
13943
+ allChars.push(charInfo);
13928
13944
  }
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
13945
  }
13967
- const currentActive = [...activeTextObjects.current];
13968
- for (const textObj of currentActive) {
13969
- if (!usedTextObjects.includes(textObj)) {
13970
- returnToPool(textObj, textObjectPool, activeTextObjects);
13971
- }
13946
+ } else {
13947
+ allChars = [];
13948
+ let currentX = 0;
13949
+ for (let i = 0; i < displayedText.length; i++) {
13950
+ const char = displayedText.charAt(i);
13951
+ const tempText = scene.add.text(0, 0, char, textStyle ?? {});
13952
+ const charWidth = tempText.width;
13953
+ const charHeight = tempText.height;
13954
+ tempText.destroy();
13955
+ allChars.push({
13956
+ char,
13957
+ textObject: null,
13958
+ x: currentX,
13959
+ y: 0,
13960
+ width: charWidth,
13961
+ height: charHeight,
13962
+ lineIndex: 0,
13963
+ charIndex: i,
13964
+ lineCharIndex: i
13965
+ });
13966
+ currentX += charWidth + charSpacing;
13972
13967
  }
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
- }
13968
+ lines = allChars.length > 0 ? [createLineInfo(allChars, 0, charSpacing)] : [];
13969
+ }
13970
+ const usedTextObjects = [];
13971
+ for (const charInfo of allChars) {
13972
+ const textObj = getTextObject(scene, container, textStyle, textObjectPool, activeTextObjects);
13973
+ textObj.setText(charInfo.char);
13974
+ textObj.setPosition(startX + charInfo.x, startY + charInfo.y);
13975
+ charInfo.textObject = textObj;
13976
+ usedTextObjects.push(textObj);
13977
+ }
13978
+ const currentActive = [...activeTextObjects.current];
13979
+ for (const textObj of currentActive) {
13980
+ if (!usedTextObjects.includes(textObj)) {
13981
+ returnToPool(textObj, textObjectPool, activeTextObjects);
13980
13982
  }
13981
- setChars(allChars);
13982
- setWidth(calculatedWidth + horizontalPadding);
13983
- setHeight(calculatedHeight + verticalPadding);
13984
- }, 0);
13985
- return () => {
13986
- clearTimeout(timeoutId);
13987
- };
13983
+ }
13984
+ const calculatedWidth = lines.length > 0 ? Math.max(...lines.map((l) => l.width)) : 0;
13985
+ let calculatedHeight = 0;
13986
+ if (lines.length > 0) {
13987
+ const lastLine = lines[lines.length - 1];
13988
+ if (lastLine) {
13989
+ calculatedHeight = lastLine.y + lastLine.height;
13990
+ }
13991
+ }
13992
+ setChars(allChars);
13993
+ setWidth(calculatedWidth + horizontalPadding);
13994
+ setHeight(calculatedHeight + verticalPadding);
13988
13995
  }, [
13989
13996
  displayedText,
13990
13997
  textStyle,
@@ -14001,7 +14008,7 @@ function CharText(props) {
14001
14008
  props.maxWidth,
14002
14009
  props.width
14003
14010
  ]);
14004
- useEffect(() => {
14011
+ useLayoutEffect(() => {
14005
14012
  if (!internalRef.current || !showCursor) {
14006
14013
  if (cursorRef.current) {
14007
14014
  cursorRef.current.setVisible(false);
@@ -14015,97 +14022,95 @@ function CharText(props) {
14015
14022
  const container = internalRef.current;
14016
14023
  const scene = container.scene;
14017
14024
  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;
14025
+ const startX = padLeft;
14026
+ const startY = padTop;
14027
+ let cursorX = startX;
14028
+ let cursorY = startY;
14029
+ const clampedPosition = Math.max(0, Math.min(cursorPosition, displayedText.length));
14030
+ let charBeforeCursor = null;
14031
+ for (const char of chars) {
14032
+ if (char.charIndex < clampedPosition) {
14033
+ if (!charBeforeCursor || char.charIndex > charBeforeCursor.charIndex) {
14034
+ charBeforeCursor = char;
14035
+ }
14036
+ }
14037
+ }
14038
+ const charBeforeCursorInText = clampedPosition > 0 ? displayedText.charAt(clampedPosition - 1) : null;
14039
+ const isAfterNewline = charBeforeCursorInText === "\n";
14040
+ if (charBeforeCursor) {
14059
14041
  if (isAfterNewline) {
14060
- const nextLineIndex = charBeforeCursor ? charBeforeCursor.lineIndex + 1 : 0;
14042
+ const nextLineIndex = charBeforeCursor.lineIndex + 1;
14061
14043
  const firstCharOfNextLine = chars.find((c) => c.lineIndex === nextLineIndex);
14062
14044
  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;
14045
+ cursorX = startX + firstCharOfNextLine.x;
14046
+ cursorY = startY + firstCharOfNextLine.y;
14047
+ } else {
14048
+ cursorX = startX;
14049
+ const lineHeightPx = charBeforeCursor.height * lineHeight;
14050
+ cursorY = startY + charBeforeCursor.y + lineHeightPx;
14068
14051
  }
14052
+ } else {
14053
+ cursorX = startX + charBeforeCursor.x + charBeforeCursor.width + charSpacing;
14054
+ cursorY = startY + charBeforeCursor.y;
14055
+ }
14056
+ } else if (chars.length > 0 && chars[0]) {
14057
+ const firstChar = chars[0];
14058
+ cursorX = startX + firstChar.x;
14059
+ cursorY = startY + firstChar.y;
14060
+ } else {
14061
+ cursorX = startX;
14062
+ cursorY = startY;
14063
+ }
14064
+ let cursorHeight = 20;
14065
+ if (isAfterNewline) {
14066
+ const nextLineIndex = charBeforeCursor ? charBeforeCursor.lineIndex + 1 : 0;
14067
+ const firstCharOfNextLine = chars.find((c) => c.lineIndex === nextLineIndex);
14068
+ if (firstCharOfNextLine) {
14069
+ cursorHeight = firstCharOfNextLine.height;
14069
14070
  } else if (charBeforeCursor) {
14070
14071
  cursorHeight = charBeforeCursor.height;
14071
14072
  } else if (chars.length > 0 && chars[0]) {
14072
14073
  cursorHeight = chars[0].height;
14073
14074
  }
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
- });
14075
+ } else if (charBeforeCursor) {
14076
+ cursorHeight = charBeforeCursor.height;
14077
+ } else if (chars.length > 0 && chars[0]) {
14078
+ cursorHeight = chars[0].height;
14079
+ }
14080
+ if (!cursorRef.current) {
14081
+ cursorRef.current = scene.add.rectangle(
14082
+ cursorX,
14083
+ cursorY,
14084
+ cursorWidth,
14085
+ cursorHeight,
14086
+ cursorColor
14087
+ );
14088
+ cursorRef.current.setOrigin(0, 0);
14089
+ container.add(cursorRef.current);
14090
+ cursorTweenRef.current = scene.tweens.add({
14091
+ targets: cursorRef.current,
14092
+ alpha: { from: 1, to: 0 },
14093
+ duration: cursorBlinkSpeed,
14094
+ yoyo: true,
14095
+ repeat: -1
14096
+ });
14097
+ } else {
14098
+ cursorRef.current.setPosition(cursorX, cursorY);
14099
+ cursorRef.current.setSize(cursorWidth, cursorHeight);
14100
+ cursorRef.current.setFillStyle(cursorColor);
14101
+ cursorRef.current.setVisible(true);
14102
+ if (cursorTweenRef.current) {
14103
+ cursorTweenRef.current.stop();
14107
14104
  }
14108
- }, 10);
14105
+ cursorRef.current.setAlpha(1);
14106
+ cursorTweenRef.current = scene.tweens.add({
14107
+ targets: cursorRef.current,
14108
+ alpha: { from: 1, to: 0 },
14109
+ duration: cursorBlinkSpeed,
14110
+ yoyo: true,
14111
+ repeat: -1
14112
+ });
14113
+ }
14109
14114
  return () => {
14110
14115
  if (cursorTweenRef.current) {
14111
14116
  cursorTweenRef.current.stop();
@@ -14123,7 +14128,7 @@ function CharText(props) {
14123
14128
  padTop,
14124
14129
  charSpacing
14125
14130
  ]);
14126
- useEffect(() => {
14131
+ useLayoutEffect(() => {
14127
14132
  if (!internalRef.current) return;
14128
14133
  const container = internalRef.current;
14129
14134
  const scene = container.scene;
@@ -14133,43 +14138,41 @@ function CharText(props) {
14133
14138
  return;
14134
14139
  }
14135
14140
  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
- }
14141
+ const startX = padLeft;
14142
+ const startY = padTop;
14143
+ const lineGroups = /* @__PURE__ */ new Map();
14144
+ for (const char of chars) {
14145
+ if (char && char.charIndex >= selectionStart && char.charIndex < selectionEnd) {
14146
+ const lineIndex = char.lineIndex;
14147
+ if (!lineGroups.has(lineIndex)) {
14148
+ lineGroups.set(lineIndex, []);
14149
+ }
14150
+ lineGroups.get(lineIndex)?.push(char);
14151
+ }
14152
+ }
14153
+ for (const [_lineIndex, lineChars] of lineGroups) {
14154
+ if (lineChars.length === 0) continue;
14155
+ const firstChar = lineChars[0];
14156
+ const lastChar = lineChars[lineChars.length - 1];
14157
+ if (firstChar && lastChar) {
14158
+ const selectionX = startX + firstChar.x;
14159
+ const selectionY = startY + firstChar.y;
14160
+ const selectionWidth = lastChar.x + lastChar.width - firstChar.x + (lineChars.length > 1 ? charSpacing : 0);
14161
+ const selectionHeight = firstChar.height;
14162
+ const selectionRect = scene.add.rectangle(
14163
+ selectionX,
14164
+ selectionY,
14165
+ selectionWidth,
14166
+ selectionHeight,
14167
+ selectionColor,
14168
+ selectionAlpha
14169
+ );
14170
+ selectionRect.setOrigin(0, 0);
14171
+ container.add(selectionRect);
14172
+ container.moveDown(selectionRect);
14173
+ selectionRefs.current.push(selectionRect);
14171
14174
  }
14172
- }, 15);
14175
+ }
14173
14176
  return () => {
14174
14177
  selectionRefs.current.forEach((rect) => rect.destroy());
14175
14178
  selectionRefs.current = [];
@@ -14254,11 +14257,9 @@ function CharTextInput(props) {
14254
14257
  const selectionStart = selectionAnchor >= 0 ? Math.min(selectionAnchor, cursorPosition) : -1;
14255
14258
  const selectionEnd = selectionAnchor >= 0 ? Math.max(selectionAnchor, cursorPosition) : -1;
14256
14259
  const redraw = useRedraw();
14257
- useEffect(() => {
14258
- const timer = setTimeout(() => redraw(), 0);
14259
- return () => {
14260
- clearTimeout(timer);
14261
- };
14260
+ useLayoutEffect(() => {
14261
+ if (!containerRef.current) return;
14262
+ redraw();
14262
14263
  }, [containerRef.current]);
14263
14264
  useEffect(() => {
14264
14265
  if (!containerRef.current) return;
@@ -14733,7 +14734,7 @@ function ScrollView(props) {
14733
14734
  };
14734
14735
  const resolvedSnapThreshold = typeof snap === "object" && "positions" in snap ? snap.threshold ?? snapThreshold : snapThreshold;
14735
14736
  const effectiveSnapThreshold = resolvedSnapThreshold === void 0 || resolvedSnapThreshold < 0 ? Infinity : resolvedSnapThreshold;
14736
- useEffect(() => {
14737
+ useLayoutEffect(() => {
14737
14738
  if (!initialScroll) return;
14738
14739
  const allowAnimate = hasMountedRef.current;
14739
14740
  if (snap && typeof snap === "object" && "positions" in snap) {
@@ -15048,12 +15049,10 @@ function ScrollView(props) {
15048
15049
  };
15049
15050
  const redraw = useRedraw();
15050
15051
  const [visible, setVisible] = useState(false);
15051
- useEffect(() => {
15052
- const timer1 = setTimeout(() => redraw(), 0);
15053
- const timer2 = setTimeout(() => setVisible(true), 2);
15052
+ useLayoutEffect(() => {
15053
+ redraw();
15054
+ setVisible(true);
15054
15055
  return () => {
15055
- clearTimeout(timer1);
15056
- clearTimeout(timer2);
15057
15056
  if (wheelSnapTimeoutRef.current) {
15058
15057
  clearTimeout(wheelSnapTimeoutRef.current);
15059
15058
  }
@@ -15748,22 +15747,19 @@ function Joystick(props) {
15748
15747
  const activeTweenRef = useRef(null);
15749
15748
  const isDraggingRef = useRef(false);
15750
15749
  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
- }
15750
+ useLayoutEffect(() => {
15751
+ const size2 = getLayoutSize(outerRef.current);
15752
+ if (size2 != null) {
15753
+ const newCenter = { x: size2.width / 2, y: size2.height / 2 };
15754
+ setCenter(newCenter);
15755
+ setSize({ width: size2.width, height: size2.height });
15756
+ if (!isDraggingRef.current && !activeTweenRef.current) {
15757
+ currentThumbPosRef.current = newCenter;
15758
+ if (thumbRef.current != null) {
15759
+ thumbRef.current.setPosition(newCenter.x, newCenter.y);
15764
15760
  }
15765
15761
  }
15766
- }, 0);
15762
+ }
15767
15763
  }, [outerRef]);
15768
15764
  const themeType = props.joystickTheme?.theme;
15769
15765
  const themeTint = props.joystickTheme?.tint;
@@ -15901,11 +15897,8 @@ function NineSliceButton(props) {
15901
15897
  const ref = useRef(null);
15902
15898
  const { applyEffect, stopEffects } = useGameObjectEffect(ref);
15903
15899
  const [show, setShow] = useState(false);
15904
- useEffect(() => {
15905
- const timer = setTimeout(() => setShow(true), 0);
15906
- return () => {
15907
- clearTimeout(timer);
15908
- };
15900
+ useLayoutEffect(() => {
15901
+ setShow(true);
15909
15902
  }, []);
15910
15903
  const innerWidth = (ref.current?.width ?? 0) - leftWidth - rightWidth;
15911
15904
  const innerHeight = (ref.current?.height ?? 0) - (topHeight ?? 0) - (bottomHeight ?? 0);
@@ -15979,14 +15972,14 @@ function RefOriginView({
15979
15972
  const handleOuterRef = (container) => {
15980
15973
  if (!container) return;
15981
15974
  outerRef.current = container;
15982
- setTimeout(() => {
15975
+ getRenderContext(container.scene).deferLayout(() => {
15983
15976
  const width2 = container.width;
15984
15977
  const height2 = container.height;
15985
15978
  const actualWidth = Number.isNaN(width2) ? 0 : width2;
15986
15979
  const actualHeight = Number.isNaN(height2) ? 0 : height2;
15987
15980
  if (actualHeight !== numericDimension.y || actualWidth !== numericDimension.x)
15988
15981
  setNumericWidth({ x: actualWidth, y: actualHeight });
15989
- }, 0);
15982
+ });
15990
15983
  };
15991
15984
  const pivotX = numericDimension.x * originX;
15992
15985
  const pivotY = numericDimension.y * originY;
@@ -16406,11 +16399,13 @@ function BaseSlider(props) {
16406
16399
  height: isHorizontal ? trackHeight : trackLength,
16407
16400
  backgroundColor: themed.trackColor ?? 4473924,
16408
16401
  cornerRadius: themed.trackBorderRadius ?? trackHeight / 2,
16402
+ alignItems: "start",
16403
+ padding: 0,
16409
16404
  direction: "stack",
16410
16405
  onTouch: handleTrackTouch,
16411
16406
  theme: nestedTheme,
16412
16407
  children: [
16413
- props.renderTrack ? /* @__PURE__ */ jsxRuntime.jsx(View, { children: props.renderTrack(fillStartPercentage, isRange ? fillEndPercentage : void 0) }, Math.random()) : /* @__PURE__ */ jsxRuntime.jsx(
16408
+ props.renderTrack ? /* @__PURE__ */ jsxRuntime.jsx(View, { children: props.renderTrack(fillStartPercentage, isRange ? fillEndPercentage : void 0) }) : /* @__PURE__ */ jsxRuntime.jsx(
16414
16409
  View,
16415
16410
  {
16416
16411
  x: isHorizontal ? fillStartPos : 0,
@@ -17086,6 +17081,7 @@ exports.releaseSVGTextures = releaseSVGTextures;
17086
17081
  exports.remountAll = remountAll;
17087
17082
  exports.resolveEffect = resolveEffect;
17088
17083
  exports.resolveSize = resolveSize;
17084
+ exports.rgbToHsl = rgbToHsl;
17089
17085
  exports.rgbToNumber = rgbToNumber;
17090
17086
  exports.shallowEqual = shallowEqual;
17091
17087
  exports.shouldComponentUpdate = shouldComponentUpdate;
@@ -17117,4 +17113,4 @@ exports.useViewportSize = useViewportSize;
17117
17113
  exports.useWorldLayoutRect = useWorldLayoutRect;
17118
17114
  exports.viewportRegistry = viewportRegistry;
17119
17115
  exports.withHooks = withHooks;
17120
- //# sourceMappingURL=TransformOriginView-2QSoN8wM.cjs.map
17116
+ //# sourceMappingURL=TransformOriginView-Dw_HKnFH.cjs.map