Skip to content

Commit 7bb4ee2

Browse files
committed
fix incorrect update from main issue with onChange
1 parent 3001941 commit 7bb4ee2

File tree

14 files changed

+76
-107
lines changed

14 files changed

+76
-107
lines changed

packages/@dcl/react-ecs/src/reconciler/index.ts

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,16 @@ export function createReconciler(
151151
update.component === 'onMouseDown'
152152
? pointerEvents.onPointerDown
153153
: update.component === 'onMouseUp'
154-
? pointerEvents.onPointerUp
155-
: update.component === 'onMouseEnter'
156-
? pointerEvents.onPointerHoverEnter
157-
: update.component === 'onMouseLeave'
158-
? pointerEvents.onPointerHoverLeave
159-
: update.component === 'onMouseDrag'
160-
? pointerEvents.onPointerDrag
161-
: update.component === 'onMouseDragLocked'
162-
? pointerEvents.onPointerDragLocked
163-
: update.component === 'onMouseDragEnd' && pointerEvents.onPointerDragEnd
154+
? pointerEvents.onPointerUp
155+
: update.component === 'onMouseEnter'
156+
? pointerEvents.onPointerHoverEnter
157+
: update.component === 'onMouseLeave'
158+
? pointerEvents.onPointerHoverLeave
159+
: update.component === 'onMouseDrag'
160+
? pointerEvents.onPointerDrag
161+
: update.component === 'onMouseDragLocked'
162+
? pointerEvents.onPointerDragLocked
163+
: update.component === 'onMouseDragEnd' && pointerEvents.onPointerDragEnd
164164

165165
if (pointerEventSystem) {
166166
pointerEventSystem(
@@ -408,43 +408,12 @@ export function createReconciler(
408408
null,
409409
'',
410410
/* istanbul ignore next */
411-
function () { },
411+
function () {},
412412
null
413413
)
414414

415-
// Maybe this could be something similar to Input system, but since we
416-
// are going to use this only here, i prefer to scope it here.
417-
function handleOnChange(
418-
componentId: number,
419-
resultComponent: typeof UiDropdownResult | typeof UiInputResult | typeof UiScrollResult
420-
) {
421-
for (const [entity, Result] of engine.getEntitiesWith(resultComponent)) {
422-
const entityState = changeEvents.get(entity)?.get(componentId)
423-
const isSubmit = !!(Result as any).isSubmit
424-
if (entityState?.onChangeCallback && Result.value !== entityState.value) {
425-
entityState.onChangeCallback(Result.value)
426-
}
427-
if (entityState?.onSubmitCallback && isSubmit && !entityState.isSubmit) {
428-
entityState.onSubmitCallback(Result.value)
429-
}
430-
431-
updateOnChange(entity, componentId, {
432-
onChangeCallback: entityState?.onChangeCallback,
433-
onSubmitCallback: entityState?.onSubmitCallback,
434-
value: Result.value,
435-
isSubmit
436-
})
437-
}
438-
}
439-
440415
return {
441416
update: function (component: ReactEcs.JSX.ReactNode) {
442-
if (changeEvents.size) {
443-
handleOnChange(UiInput.componentId, UiInputResult)
444-
handleOnChange(UiDropdown.componentId, UiDropdownResult)
445-
// TODO: maybe as componentId could be a virtual id since the scroll input doesn't exist
446-
handleOnChange(UiTransform.componentId, UiScrollResult)
447-
}
448417
return reconciler.updateContainer(component as any, root, null)
449418
},
450419
getEntities: () => Array.from(entities)

test/snapshots/development-bundles/static-scene.test.ts.crdt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SCENE_COMPILED_JS_SIZE_PROD=462.7k bytes
1+
SCENE_COMPILED_JS_SIZE_PROD=517.6k bytes
22
THE BUNDLE HAS SOURCEMAPS
33
(start empty vm 0.21.0-3680274614.commit-1808aa1)
44
OPCODES ~= 0k
@@ -10,9 +10,9 @@ EVAL test/snapshots/development-bundles/static-scene.test.js
1010
REQUIRE: ~system/Testing
1111
REQUIRE: ~system/EngineApi
1212
REQUIRE: ~system/EngineApi
13-
OPCODES ~= 54k
14-
MALLOC_COUNT = 13727
15-
ALIVE_OBJS_DELTA ~= 2.70k
13+
OPCODES ~= 59k
14+
MALLOC_COUNT = 14983
15+
ALIVE_OBJS_DELTA ~= 2.98k
1616
CALL onStart()
1717
main.crdt: PUT_COMPONENT e=0x200 c=1 t=0 data={"position":{"x":5.880000114440918,"y":2.7916901111602783,"z":7.380000114440918},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":1,"y":1,"z":1},"parent":0}
1818
main.crdt: PUT_COMPONENT e=0x202 c=1 t=0 data={"position":{"x":4,"y":0.800000011920929,"z":8},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":1,"y":1,"z":1},"parent":0}
@@ -56,4 +56,4 @@ CALL onUpdate(0.1)
5656
OPCODES ~= 3k
5757
MALLOC_COUNT = -5
5858
ALIVE_OBJS_DELTA ~= 0.00k
59-
MEMORY_USAGE_COUNT ~= 1209.35k bytes
59+
MEMORY_USAGE_COUNT ~= 1319.47k bytes

test/snapshots/development-bundles/testing-fw.test.ts.crdt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SCENE_COMPILED_JS_SIZE_PROD=463.2k bytes
1+
SCENE_COMPILED_JS_SIZE_PROD=517.9k bytes
22
THE BUNDLE HAS SOURCEMAPS
33
(start empty vm 0.21.0-3680274614.commit-1808aa1)
44
OPCODES ~= 0k
@@ -10,9 +10,9 @@ EVAL test/snapshots/development-bundles/testing-fw.test.js
1010
REQUIRE: ~system/Testing
1111
REQUIRE: ~system/EngineApi
1212
REQUIRE: ~system/EngineApi
13-
OPCODES ~= 63k
14-
MALLOC_COUNT = 14248
15-
ALIVE_OBJS_DELTA ~= 2.85k
13+
OPCODES ~= 68k
14+
MALLOC_COUNT = 15498
15+
ALIVE_OBJS_DELTA ~= 3.13k
1616
CALL onStart()
1717
LOG: ["Adding one to position.y=0"]
1818
Renderer: PUT_COMPONENT e=0x0 c=1 t=1 data={"position":{"x":1,"y":0,"z":0},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":9,"y":9,"z":9},"parent":0}
@@ -61,4 +61,4 @@ CALL onUpdate(0.1)
6161
OPCODES ~= 5k
6262
MALLOC_COUNT = -40
6363
ALIVE_OBJS_DELTA ~= -0.01k
64-
MEMORY_USAGE_COUNT ~= 1217.97k bytes
64+
MEMORY_USAGE_COUNT ~= 1327.45k bytes

test/snapshots/development-bundles/two-way-crdt.test.ts.crdt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SCENE_COMPILED_JS_SIZE_PROD=463.3k bytes
1+
SCENE_COMPILED_JS_SIZE_PROD=517.9k bytes
22
THE BUNDLE HAS SOURCEMAPS
33
(start empty vm 0.21.0-3680274614.commit-1808aa1)
44
OPCODES ~= 0k
@@ -10,9 +10,9 @@ EVAL test/snapshots/development-bundles/two-way-crdt.test.js
1010
REQUIRE: ~system/Testing
1111
REQUIRE: ~system/EngineApi
1212
REQUIRE: ~system/EngineApi
13-
OPCODES ~= 63k
14-
MALLOC_COUNT = 14248
15-
ALIVE_OBJS_DELTA ~= 2.85k
13+
OPCODES ~= 68k
14+
MALLOC_COUNT = 15498
15+
ALIVE_OBJS_DELTA ~= 3.13k
1616
CALL onStart()
1717
LOG: ["Adding one to position.y=0"]
1818
Renderer: PUT_COMPONENT e=0x0 c=1 t=1 data={"position":{"x":1,"y":0,"z":0},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":9,"y":9,"z":9},"parent":0}
@@ -61,4 +61,4 @@ CALL onUpdate(0.1)
6161
OPCODES ~= 5k
6262
MALLOC_COUNT = -40
6363
ALIVE_OBJS_DELTA ~= -0.01k
64-
MEMORY_USAGE_COUNT ~= 1217.97k bytes
64+
MEMORY_USAGE_COUNT ~= 1327.45k bytes

test/snapshots/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/snapshots/production-bundles/append-value-crdt.ts.crdt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SCENE_COMPILED_JS_SIZE_PROD=203k bytes
1+
SCENE_COMPILED_JS_SIZE_PROD=228.1k bytes
22
(start empty vm 0.21.0-3680274614.commit-1808aa1)
33
OPCODES ~= 0k
44
MALLOC_COUNT = 1005
@@ -8,9 +8,9 @@ EVAL test/snapshots/production-bundles/append-value-crdt.js
88
REQUIRE: long
99
REQUIRE: ~system/EngineApi
1010
REQUIRE: ~system/EngineApi
11-
OPCODES ~= 65k
12-
MALLOC_COUNT = 12773
13-
ALIVE_OBJS_DELTA ~= 2.85k
11+
OPCODES ~= 71k
12+
MALLOC_COUNT = 13939
13+
ALIVE_OBJS_DELTA ~= 3.12k
1414
CALL onStart()
1515
Renderer: APPEND_VALUE e=0x200 c=1063 t=0 data={"button":0,"hit":{"position":{"x":1,"y":2,"z":3},"globalOrigin":{"x":1,"y":2,"z":3},"direction":{"x":1,"y":2,"z":3},"normalHit":{"x":1,"y":2,"z":3},"length":10,"meshName":"mesh","entityId":512},"state":1,"timestamp":1,"analog":5,"tickNumber":0}
1616
OPCODES ~= 8k
@@ -55,4 +55,4 @@ CALL onUpdate(0.1)
5555
OPCODES ~= 14k
5656
MALLOC_COUNT = 31
5757
ALIVE_OBJS_DELTA ~= 0.01k
58-
MEMORY_USAGE_COUNT ~= 909.46k bytes
58+
MEMORY_USAGE_COUNT ~= 994.33k bytes

test/snapshots/production-bundles/billboard.ts.crdt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SCENE_COMPILED_JS_SIZE_PROD=236k bytes
1+
SCENE_COMPILED_JS_SIZE_PROD=261.2k bytes
22
(start empty vm 0.21.0-3680274614.commit-1808aa1)
33
OPCODES ~= 0k
44
MALLOC_COUNT = 1005
@@ -8,9 +8,9 @@ EVAL test/snapshots/production-bundles/billboard.js
88
REQUIRE: long
99
REQUIRE: ~system/EngineApi
1010
REQUIRE: ~system/EngineApi
11-
OPCODES ~= 66k
12-
MALLOC_COUNT = 14885
13-
ALIVE_OBJS_DELTA ~= 3.25k
11+
OPCODES ~= 72k
12+
MALLOC_COUNT = 16057
13+
ALIVE_OBJS_DELTA ~= 3.52k
1414
CALL onStart()
1515
OPCODES ~= 0k
1616
MALLOC_COUNT = 4
@@ -77,4 +77,4 @@ CALL onUpdate(0.1)
7777
OPCODES ~= 10k
7878
MALLOC_COUNT = 0
7979
ALIVE_OBJS_DELTA ~= 0.00k
80-
MEMORY_USAGE_COUNT ~= 1051.90k bytes
80+
MEMORY_USAGE_COUNT ~= 1137.32k bytes

test/snapshots/production-bundles/cube-deleted.ts.crdt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SCENE_COMPILED_JS_SIZE_PROD=199.2k bytes
1+
SCENE_COMPILED_JS_SIZE_PROD=224.3k bytes
22
(start empty vm 0.21.0-3680274614.commit-1808aa1)
33
OPCODES ~= 0k
44
MALLOC_COUNT = 1005
@@ -8,9 +8,9 @@ EVAL test/snapshots/production-bundles/cube-deleted.js
88
REQUIRE: long
99
REQUIRE: ~system/EngineApi
1010
REQUIRE: ~system/EngineApi
11-
OPCODES ~= 55k
12-
MALLOC_COUNT = 11927
13-
ALIVE_OBJS_DELTA ~= 2.63k
11+
OPCODES ~= 61k
12+
MALLOC_COUNT = 13099
13+
ALIVE_OBJS_DELTA ~= 2.90k
1414
CALL onStart()
1515
OPCODES ~= 0k
1616
MALLOC_COUNT = 6
@@ -42,4 +42,4 @@ CALL onUpdate(0.1)
4242
OPCODES ~= 5k
4343
MALLOC_COUNT = 1
4444
ALIVE_OBJS_DELTA ~= 0.00k
45-
MEMORY_USAGE_COUNT ~= 872.22k bytes
45+
MEMORY_USAGE_COUNT ~= 957.19k bytes

test/snapshots/production-bundles/cube.ts.crdt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SCENE_COMPILED_JS_SIZE_PROD=199.1k bytes
1+
SCENE_COMPILED_JS_SIZE_PROD=224.2k bytes
22
(start empty vm 0.21.0-3680274614.commit-1808aa1)
33
OPCODES ~= 0k
44
MALLOC_COUNT = 1005
@@ -8,9 +8,9 @@ EVAL test/snapshots/production-bundles/cube.js
88
REQUIRE: long
99
REQUIRE: ~system/EngineApi
1010
REQUIRE: ~system/EngineApi
11-
OPCODES ~= 55k
12-
MALLOC_COUNT = 11900
13-
ALIVE_OBJS_DELTA ~= 2.62k
11+
OPCODES ~= 61k
12+
MALLOC_COUNT = 13069
13+
ALIVE_OBJS_DELTA ~= 2.89k
1414
CALL onStart()
1515
OPCODES ~= 0k
1616
MALLOC_COUNT = 6
@@ -32,4 +32,4 @@ CALL onUpdate(0.1)
3232
OPCODES ~= 1k
3333
MALLOC_COUNT = 0
3434
ALIVE_OBJS_DELTA ~= 0.00k
35-
MEMORY_USAGE_COUNT ~= 862.13k bytes
35+
MEMORY_USAGE_COUNT ~= 947.04k bytes

test/snapshots/production-bundles/cubes.ts.crdt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SCENE_COMPILED_JS_SIZE_PROD=236.4k bytes
1+
SCENE_COMPILED_JS_SIZE_PROD=261.6k bytes
22
(start empty vm 0.21.0-3680274614.commit-1808aa1)
33
OPCODES ~= 0k
44
MALLOC_COUNT = 1005
@@ -8,9 +8,9 @@ EVAL test/snapshots/production-bundles/cubes.js
88
REQUIRE: long
99
REQUIRE: ~system/EngineApi
1010
REQUIRE: ~system/EngineApi
11-
OPCODES ~= 105k
12-
MALLOC_COUNT = 18228
13-
ALIVE_OBJS_DELTA ~= 4.53k
11+
OPCODES ~= 111k
12+
MALLOC_COUNT = 19399
13+
ALIVE_OBJS_DELTA ~= 4.81k
1414
CALL onStart()
1515
OPCODES ~= 0k
1616
MALLOC_COUNT = 6
@@ -1652,4 +1652,4 @@ CALL onUpdate(0.1)
16521652
OPCODES ~= 694k
16531653
MALLOC_COUNT = 0
16541654
ALIVE_OBJS_DELTA ~= 0.00k
1655-
MEMORY_USAGE_COUNT ~= 1187.85k bytes
1655+
MEMORY_USAGE_COUNT ~= 1273.25k bytes

0 commit comments

Comments
 (0)