@dcl/react-ecs 7.24.5-29334646366.commit-955c00d → 7.24.5-29428555187.commit-fb197d3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/system.d.ts CHANGED
@@ -21,11 +21,6 @@ export interface ReactBasedUiSystem {
21
21
  destroy(): void;
22
22
  /**
23
23
  * Set the main UI renderer. Optional virtual size defines the global UI scale factor.
24
- *
25
- * When no virtual size is provided, a platform default is used: 1600x720 on
26
- * mobile, 1920x1080 otherwise. Providing an invalid size (values \<= 0)
27
- * disables the virtual screen (no UI scaling). On mobile, a provided 16:9
28
- * virtual size is overridden to 1600x720 to fit phone screens.
29
24
  */
30
25
  setUiRenderer(ui: UiComponent, options?: UiRendererOptions): void;
31
26
  /**
@@ -40,8 +35,7 @@ export interface ReactBasedUiSystem {
40
35
  * @param entity - The entity to associate with this UI renderer. When the entity is removed,
41
36
  * the UI renderer is automatically cleaned up.
42
37
  * @param ui - The UI component to render
43
- * @param options - Optional virtual size used for UI scale factor when main UI has none.
44
- * Defaults and the mobile 16:9 override behave as in {@link ReactBasedUiSystem.setUiRenderer}.
38
+ * @param options - Optional virtual size used for UI scale factor when main UI has none
45
39
  */
46
40
  addUiRenderer(entity: Entity, ui: UiComponent, options?: UiRendererOptions): void;
47
41
  /**
package/dist/system.js CHANGED
@@ -3,23 +3,6 @@ import * as ecsComponents from '@dcl/ecs/dist/components';
3
3
  import React from 'react';
4
4
  import { createReconciler } from './reconciler';
5
5
  import { getUiScaleFactor, resetInteractableArea, resetScreenInsetArea, resetUiScaleFactor, setInteractableArea, setScreenInsetArea, setUiScaleFactor } from './components/utils';
6
- import { isMobile } from './platform';
7
- /**
8
- * Default virtual screen size used on mobile platforms, and the size 16:9
9
- * virtual screens are overridden to on mobile (phone screens are much wider
10
- * than 16:9, so a 16:9 virtual canvas would letterbox the UI).
11
- */
12
- const DEFAULT_MOBILE_VIRTUAL_SIZE = { virtualWidth: 1600, virtualHeight: 720 };
13
- /**
14
- * Default virtual screen size used on non-mobile platforms.
15
- */
16
- const DEFAULT_VIRTUAL_SIZE = { virtualWidth: 1920, virtualHeight: 1080 };
17
- function isValidVirtualSize(options) {
18
- return !!options && options.virtualWidth > 0 && options.virtualHeight > 0;
19
- }
20
- function is16by9(options) {
21
- return options.virtualWidth * 9 === options.virtualHeight * 16;
22
- }
23
6
  /**
24
7
  * @public
25
8
  */
@@ -35,11 +18,6 @@ export function createReactBasedUiSystem(engine, pointerSystem) {
35
18
  const screenInsetAreaOwner = Symbol('react-ecs-screen-inset-area');
36
19
  // Unique owner for the interactable area module variable.
37
20
  const interactableAreaOwner = Symbol('react-ecs-interactable-area');
38
- // Last 16:9 size we already logged the mobile override for, so the log
39
- // fires once per provided size instead of every tick. Tracked as raw numbers
40
- // to avoid allocating a comparison string every tick.
41
- let loggedMobileOverrideW = 0;
42
- let loggedMobileOverrideH = 0;
43
21
  function getActiveVirtualSize() {
44
22
  // Main renderer options win; otherwise use the first additional renderer option.
45
23
  if (virtualSize)
@@ -50,33 +28,6 @@ export function createReactBasedUiSystem(engine, pointerSystem) {
50
28
  }
51
29
  return undefined;
52
30
  }
53
- /**
54
- * Resolves the virtual screen to scale the UI against, or `undefined` when
55
- * the virtual screen is disabled.
56
- */
57
- function resolveVirtualSize() {
58
- const provided = getActiveVirtualSize();
59
- const mobile = isMobile();
60
- // No creator-provided size: fall back to the platform default.
61
- if (!provided) {
62
- return mobile ? DEFAULT_MOBILE_VIRTUAL_SIZE : DEFAULT_VIRTUAL_SIZE;
63
- }
64
- // An explicitly provided but invalid size (values <= 0) disables the
65
- // virtual screen — no UI scaling at all.
66
- if (!isValidVirtualSize(provided)) {
67
- return undefined;
68
- }
69
- // On mobile, 16:9 virtual screens don't fit phone aspect ratios — override them.
70
- if (mobile && is16by9(provided)) {
71
- if (loggedMobileOverrideW !== provided.virtualWidth || loggedMobileOverrideH !== provided.virtualHeight) {
72
- loggedMobileOverrideW = provided.virtualWidth;
73
- loggedMobileOverrideH = provided.virtualHeight;
74
- console.log(`Mobile platform detected: overriding 16:9 virtual screen size ${provided.virtualWidth}x${provided.virtualHeight} with ${DEFAULT_MOBILE_VIRTUAL_SIZE.virtualWidth}x${DEFAULT_MOBILE_VIRTUAL_SIZE.virtualHeight}`);
75
- }
76
- return DEFAULT_MOBILE_VIRTUAL_SIZE;
77
- }
78
- return provided;
79
- }
80
31
  function ReactBasedUiSystem() {
81
32
  const components = [];
82
33
  // Add main UI component
@@ -117,16 +68,9 @@ export function createReactBasedUiSystem(engine, pointerSystem) {
117
68
  if (canvasInfo?.interactableArea) {
118
69
  setInteractableArea(canvasInfo.interactableArea, interactableAreaOwner);
119
70
  }
120
- // The virtual screen (provided or defaulted) only applies while some
121
- // renderer is registered; with no UI at all the scale factor is released.
122
- if (uiComponent === undefined && additionalRenderers.size === 0) {
123
- // Reset only if this system owns the scale factor.
124
- resetUiScaleFactor(uiScaleFactorOwner);
125
- return;
126
- }
127
- const activeVirtualSize = resolveVirtualSize();
71
+ const activeVirtualSize = getActiveVirtualSize();
128
72
  if (!activeVirtualSize) {
129
- // Virtual screen explicitly disabled by an invalid provided size.
73
+ // Reset only if this system owns the scale factor.
130
74
  resetUiScaleFactor(uiScaleFactorOwner);
131
75
  return;
132
76
  }
@@ -134,6 +78,8 @@ export function createReactBasedUiSystem(engine, pointerSystem) {
134
78
  return;
135
79
  const { width, height, devicePixelRatio } = canvasInfo;
136
80
  const { virtualWidth, virtualHeight } = activeVirtualSize;
81
+ if (!virtualWidth || !virtualHeight)
82
+ return;
137
83
  // Normalize by devicePixelRatio so virtual px map to logical px (matching the
138
84
  // vw/vh path); without it the scale was inflated on high-dpr mobile screens.
139
85
  const ratio = devicePixelRatio || 1;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dcl/react-ecs",
3
3
  "description": "Decentraland ECS",
4
- "version": "7.24.5-29334646366.commit-955c00d",
4
+ "version": "7.24.5-29428555187.commit-fb197d3",
5
5
  "author": "DCL",
6
6
  "bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
7
7
  "dependencies": {
8
- "@dcl/ecs": "7.24.5-29334646366.commit-955c00d",
8
+ "@dcl/ecs": "7.24.5-29428555187.commit-fb197d3",
9
9
  "react": "^18.2.0",
10
10
  "react-reconciler": "^0.29.0"
11
11
  },
@@ -40,5 +40,5 @@
40
40
  "tsconfig": "./tsconfig.json"
41
41
  },
42
42
  "types": "./dist/index.d.ts",
43
- "commit": "955c00dcfec264e375fa39058a34039205cf061d"
43
+ "commit": "fb197d38cdaec5a0de8d575b337ab142264644e7"
44
44
  }
@@ -1,12 +0,0 @@
1
- /**
2
- * Injects the function used to detect whether the scene runs on a mobile
3
- * platform. Called by `@dcl/sdk` with its `isMobile()` platform helper.
4
- */
5
- export declare function setIsMobileProvider(provider: () => boolean): void;
6
- /**
7
- * Whether the scene is running on a mobile platform, according to the
8
- * injected provider. Platform detection is asynchronous on the SDK side, so
9
- * this may return false during the first ticks and flip to true once the
10
- * explorer information arrives.
11
- */
12
- export declare function isMobile(): boolean;
package/dist/platform.js DELETED
@@ -1,26 +0,0 @@
1
- /**
2
- * Platform detection hook for the UI scale system.
3
- *
4
- * react-ecs stays independent of the scene runtime (`~system/*` modules), so
5
- * it cannot ask the explorer which platform it runs on. Instead, the host SDK
6
- * injects the check at module-load time (see `@dcl/sdk/react-ecs`). Until a
7
- * provider is injected — or when none ever is — the platform is assumed to be
8
- * non-mobile.
9
- */
10
- let isMobileProvider = () => false;
11
- /**
12
- * Injects the function used to detect whether the scene runs on a mobile
13
- * platform. Called by `@dcl/sdk` with its `isMobile()` platform helper.
14
- */
15
- export function setIsMobileProvider(provider) {
16
- isMobileProvider = provider;
17
- }
18
- /**
19
- * Whether the scene is running on a mobile platform, according to the
20
- * injected provider. Platform detection is asynchronous on the SDK side, so
21
- * this may return false during the first ticks and flip to true once the
22
- * explorer information arrives.
23
- */
24
- export function isMobile() {
25
- return isMobileProvider();
26
- }