diff --git a/.vscode/settings.json b/.vscode/settings.json index f74ed21ae..b98f36f80 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -19,6 +19,6 @@ "packages/@dcl/inspector/hot-reload.js": false }, "[typescript]": { - "editor.defaultFormatter": "dbaeumer.vscode-eslint" + "editor.defaultFormatter": "vscode.typescript-language-features" } } diff --git a/package-lock.json b/package-lock.json index 8d518c91d..697cfc118 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "license": "Apache-2.0", "dependencies": { "@actions/core": "^1.10.0", - "@dcl/protocol": "1.0.0-12415236132.commit-53e881e", + "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791995584.commit-4338852.tgz", "@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1", "@dcl/ts-proto": "1.153.0", "@types/fs-extra": "^9.0.12", @@ -577,9 +577,10 @@ } }, "node_modules/@dcl/protocol": { - "version": "1.0.0-12415236132.commit-53e881e", - "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-12415236132.commit-53e881e.tgz", - "integrity": "sha512-T2xrziqHNmpPWSD0POdnTY33BcPQThOUEIxxdmAcDzX/YMRVfy9sKDhP3PvS0diVDGbjxo+tKBagL75M9WLJxg==", + "version": "1.0.0-12791995584.commit-4338852", + "resolved": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791995584.commit-4338852.tgz", + "integrity": "sha512-JkXkqbquAhQXUUwktn2g5OWDL1vbWTLbKg3xB/BDguWWYCydD9znE8XMTT51FXvVI5mB6lQENsAKuxzaoWOatQ==", + "license": "Apache-2.0", "dependencies": { "@dcl/ts-proto": "1.154.0" } @@ -2471,16 +2472,16 @@ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" }, "node_modules/call-bind": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", - "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", + "integrity": "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==", "dev": true, + "license": "MIT", "dependencies": { + "call-bind-apply-helpers": "^1.0.0", "es-define-property": "^1.0.0", - "es-errors": "^1.3.0", - "function-bind": "^1.1.2", "get-intrinsic": "^1.2.4", - "set-function-length": "^1.2.1" + "set-function-length": "^1.2.2" }, "engines": { "node": ">= 0.4" @@ -4230,13 +4231,15 @@ } }, "node_modules/is-array-buffer": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.4.tgz", - "integrity": "sha512-wcjaerHw0ydZwfhiKbXJWLDY8A7yV7KhjQOpb83hGgGfId/aQa4TOvwyzn2PuswW2gPCYEL/nEAiSVpdOj1lXw==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz", + "integrity": "sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A==", "dev": true, + "license": "MIT", "dependencies": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.2.1" + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" }, "engines": { "node": ">= 0.4" @@ -8360,9 +8363,8 @@ } }, "@dcl/protocol": { - "version": "1.0.0-12415236132.commit-53e881e", - "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-12415236132.commit-53e881e.tgz", - "integrity": "sha512-T2xrziqHNmpPWSD0POdnTY33BcPQThOUEIxxdmAcDzX/YMRVfy9sKDhP3PvS0diVDGbjxo+tKBagL75M9WLJxg==", + "version": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791995584.commit-4338852.tgz", + "integrity": "sha512-JkXkqbquAhQXUUwktn2g5OWDL1vbWTLbKg3xB/BDguWWYCydD9znE8XMTT51FXvVI5mB6lQENsAKuxzaoWOatQ==", "requires": { "@dcl/ts-proto": "1.154.0" }, @@ -9755,16 +9757,15 @@ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" }, "call-bind": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", - "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", + "integrity": "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==", "dev": true, "requires": { + "call-bind-apply-helpers": "^1.0.0", "es-define-property": "^1.0.0", - "es-errors": "^1.3.0", - "function-bind": "^1.1.2", "get-intrinsic": "^1.2.4", - "set-function-length": "^1.2.1" + "set-function-length": "^1.2.2" } }, "call-bind-apply-helpers": { @@ -10937,13 +10938,14 @@ } }, "is-array-buffer": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.4.tgz", - "integrity": "sha512-wcjaerHw0ydZwfhiKbXJWLDY8A7yV7KhjQOpb83hGgGfId/aQa4TOvwyzn2PuswW2gPCYEL/nEAiSVpdOj1lXw==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz", + "integrity": "sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A==", "dev": true, "requires": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.2.1" + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" } }, "is-arrayish": { diff --git a/package.json b/package.json index 2f15d0d2b..b78597dc6 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "bugs": "https://github.com/decentraland/js-sdk-toolchain/issues", "dependencies": { "@actions/core": "^1.10.0", - "@dcl/protocol": "1.0.0-12415236132.commit-53e881e", + "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791995584.commit-4338852.tgz", "@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1", "@dcl/ts-proto": "1.153.0", "@types/fs-extra": "^9.0.12", diff --git a/packages/@dcl/ecs/src/systems/events.ts b/packages/@dcl/ecs/src/systems/events.ts index 9789d2772..62e813ed7 100644 --- a/packages/@dcl/ecs/src/systems/events.ts +++ b/packages/@dcl/ecs/src/systems/events.ts @@ -66,6 +66,27 @@ export interface PointerEventsSystem { */ removeOnPointerHoverLeave(entity: Entity): void + /** + * @public + * Remove the callback for onPointerDrag event + * @param entity - Entity where the callback was attached + */ + removeOnPointerDrag(entity: Entity): void + + /** + * @public + * Remove the callback for onPointerDragLocked event + * @param entity - Entity where the callback was attached + */ + removeOnPointerDragLocked(entity: Entity): void + + /** + * @public + * Remove the callback for onPointerDragEnd event + * @param entity - Entity where the callback was attached + */ + removeOnPointerDragEnd(entity: Entity): void + /** * @internal * Execute callback when the user clicks the entity. @@ -124,6 +145,34 @@ export interface PointerEventsSystem { pointerData: { entity: Entity; opts?: Partial }, cb: EventSystemCallback ): void + + /** + * @public + * Execute callback when the user clicks and drags the pointer from inside the entity + * @param pointerData - Entity to attach the callback - Opts to trigger Feedback and Button + * @param cb - Function to execute when click fires + */ + onPointerDrag(pointerData: { entity: Entity; opts?: Partial }, cb: EventSystemCallback): void + + /** + * @public + * Execute callback when the user clicks and drags the pointer from inside the entity, + * locking the cursor in place + * @param pointerData - Entity to attach the callback - Opts to trigger Feedback and Button + * @param cb - Function to execute when click fires + */ + onPointerDragLocked( + pointerData: { entity: Entity; opts?: Partial }, + cb: EventSystemCallback + ): void + + /** + * @public + * Execute callback when the user releases the button after a drag + * @param pointerData - Entity to attach the callback - Opts to trigger Feedback and Button + * @param cb - Function to execute when click fires + */ + onPointerDragEnd(pointerData: { entity: Entity; opts?: Partial }, cb: EventSystemCallback): void } /** @@ -138,7 +187,10 @@ export function createPointerEventsSystem(engine: IEngine, inputSystem: IInputSy Down, Up, HoverEnter, - HoverLeave + HoverLeave, + Drag, + DragLocked, + DragEnd } type EventMapType = Map @@ -177,6 +229,12 @@ export function createPointerEventsSystem(engine: IEngine, inputSystem: IInputSy return PointerEventType.PET_HOVER_LEAVE } else if (eventType === EventType.HoverEnter) { return PointerEventType.PET_HOVER_ENTER + } else if (eventType === EventType.Drag) { + return PointerEventType.PET_DRAG + } else if (eventType === EventType.DragLocked) { + return PointerEventType.PET_DRAG_LOCKED + } else if (eventType === EventType.DragEnd) { + return PointerEventType.PET_DRAG_END } return PointerEventType.PET_DOWN } @@ -210,7 +268,10 @@ export function createPointerEventsSystem(engine: IEngine, inputSystem: IInputSy eventType === EventType.Down || eventType === EventType.Up || eventType === EventType.HoverEnter || - eventType === EventType.HoverLeave + eventType === EventType.HoverLeave || + eventType === EventType.Drag || + eventType === EventType.DragLocked || + eventType === EventType.DragEnd ) { const command = inputSystem.getInputCommand(opts.button, getPointerEvent(eventType), entity) if (command) { @@ -263,6 +324,33 @@ export function createPointerEventsSystem(engine: IEngine, inputSystem: IInputSy setPointerEvent(entity, PointerEventType.PET_HOVER_LEAVE, options) } + const onPointerDrag: PointerEventsSystem['onPointerDrag'] = (...args) => { + const [data, cb] = args + const { entity, opts } = data + const options = getDefaultOpts(opts) + removeEvent(entity, EventType.Drag) + getEvent(entity).set(EventType.Drag, { cb, opts: options }) + setPointerEvent(entity, PointerEventType.PET_DRAG, options) + } + + const onPointerDragLocked: PointerEventsSystem['onPointerDragLocked'] = (...args) => { + const [data, cb] = args + const { entity, opts } = data + const options = getDefaultOpts(opts) + removeEvent(entity, EventType.DragLocked) + getEvent(entity).set(EventType.DragLocked, { cb, opts: options }) + setPointerEvent(entity, PointerEventType.PET_DRAG_LOCKED, options) + } + + const onPointerDragEnd: PointerEventsSystem['onPointerDragEnd'] = (...args) => { + const [data, cb] = args + const { entity, opts } = data + const options = getDefaultOpts(opts) + removeEvent(entity, EventType.DragEnd) + getEvent(entity).set(EventType.DragEnd, { cb, opts: options }) + setPointerEvent(entity, PointerEventType.PET_DRAG_END, options) + } + return { removeOnClick(entity: Entity) { removeEvent(entity, EventType.Click) @@ -284,6 +372,18 @@ export function createPointerEventsSystem(engine: IEngine, inputSystem: IInputSy removeEvent(entity, EventType.HoverLeave) }, + removeOnPointerDrag(entity: Entity) { + removeEvent(entity, EventType.Drag) + }, + + removeOnPointerDragLocked(entity: Entity) { + removeEvent(entity, EventType.DragLocked) + }, + + removeOnPointerDragEnd(entity: Entity) { + removeEvent(entity, EventType.DragEnd) + }, + onClick(value, cb) { const { entity } = value const options = getDefaultOpts(value.opts) @@ -298,6 +398,9 @@ export function createPointerEventsSystem(engine: IEngine, inputSystem: IInputSy onPointerDown, onPointerUp, onPointerHoverEnter, - onPointerHoverLeave + onPointerHoverLeave, + onPointerDrag, + onPointerDragLocked, + onPointerDragEnd } } diff --git a/packages/@dcl/inspector/build.js b/packages/@dcl/inspector/build.js old mode 100755 new mode 100644 diff --git a/packages/@dcl/inspector/src/components/Toolbar/Gizmos/icons/position.svg b/packages/@dcl/inspector/src/components/Toolbar/Gizmos/icons/position.svg old mode 100755 new mode 100644 diff --git a/packages/@dcl/inspector/src/components/Toolbar/Gizmos/icons/rotation.svg b/packages/@dcl/inspector/src/components/Toolbar/Gizmos/icons/rotation.svg old mode 100755 new mode 100644 diff --git a/packages/@dcl/playground-assets/etc/playground-assets.api.md b/packages/@dcl/playground-assets/etc/playground-assets.api.md index 2b86d94ce..665115d05 100644 --- a/packages/@dcl/playground-assets/etc/playground-assets.api.md +++ b/packages/@dcl/playground-assets/etc/playground-assets.api.md @@ -1144,6 +1144,9 @@ export type EntityComponents = { onMouseUp: Callback; onMouseEnter: Callback; onMouseLeave: Callback; + onMouseDrag: Callback; + onMouseDragLocked: Callback; + onMouseDragEnd: Callback; }; // @public (undocumented) @@ -1644,6 +1647,9 @@ export type Listeners = { onMouseUp?: Callback; onMouseEnter?: Callback; onMouseLeave?: Callback; + onMouseDrag?: Callback; + onMouseDragLocked?: Callback; + onMouseDragEnd?: Callback; }; // @public (undocumented) @@ -3596,6 +3602,18 @@ export interface PointerEventsSystem { }, cb: EventSystemCallback): void; // @deprecated (undocumented) onPointerDown(entity: Entity, cb: EventSystemCallback, opts?: Partial): void; + onPointerDrag(pointerData: { + entity: Entity; + opts?: Partial; + }, cb: EventSystemCallback): void; + onPointerDragEnd(pointerData: { + entity: Entity; + opts?: Partial; + }, cb: EventSystemCallback): void; + onPointerDragLocked(pointerData: { + entity: Entity; + opts?: Partial; + }, cb: EventSystemCallback): void; onPointerHoverEnter(pointerData: { entity: Entity; opts?: Partial; @@ -3611,6 +3629,9 @@ export interface PointerEventsSystem { // @deprecated (undocumented) onPointerUp(entity: Entity, cb: EventSystemCallback, opts?: Partial): void; removeOnPointerDown(entity: Entity): void; + removeOnPointerDrag(entity: Entity): void; + removeOnPointerDragEnd(entity: Entity): void; + removeOnPointerDragLocked(entity: Entity): void; removeOnPointerHoverEnter(entity: Entity): void; removeOnPointerHoverLeave(entity: Entity): void; removeOnPointerUp(entity: Entity): void; diff --git a/packages/@dcl/react-ecs/src/components/Button/index.tsx b/packages/@dcl/react-ecs/src/components/Button/index.tsx index 56ef4a23c..b40ed5ef9 100644 --- a/packages/@dcl/react-ecs/src/components/Button/index.tsx +++ b/packages/@dcl/react-ecs/src/components/Button/index.tsx @@ -35,7 +35,18 @@ function getButtonProps(props: UiButtonProps) { */ /* @__PURE__ */ export function Button(props: UiButtonProps) { - const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, ...otherProps } = props + const { + uiTransform, + uiBackground, + onMouseDown, + onMouseUp, + onMouseEnter, + onMouseLeave, + onMouseDrag, + onMouseDragLocked, + onMouseDragEnd, + ...otherProps + } = props const buttonProps = getButtonProps(props) const uiBackgroundProps = parseUiBackground({ ...buttonProps.uiBackground, @@ -66,6 +77,9 @@ export function Button(props: UiButtonProps) { onMouseUp={!!props.disabled ? undefined : onMouseUp} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} + onMouseDrag={onMouseDrag} + onMouseDragLocked={onMouseDragLocked} + onMouseDragEnd={onMouseDragEnd} uiTransform={uiTransformProps} uiText={textProps} uiBackground={uiBackgroundProps} diff --git a/packages/@dcl/react-ecs/src/components/Dropdown/index.tsx b/packages/@dcl/react-ecs/src/components/Dropdown/index.tsx index d4b305906..6b4b2e8e0 100644 --- a/packages/@dcl/react-ecs/src/components/Dropdown/index.tsx +++ b/packages/@dcl/react-ecs/src/components/Dropdown/index.tsx @@ -39,7 +39,18 @@ function parseUiDropdown(props: UiDropdownProps): PBUiDropdown { */ /* @__PURE__ */ export function Dropdown(props: UiDropdownProps) { - const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, ...otherProps } = props + const { + uiTransform, + uiBackground, + onMouseDown, + onMouseUp, + onMouseEnter, + onMouseLeave, + onMouseDrag, + onMouseDragLocked, + onMouseDragEnd, + ...otherProps + } = props const dropdownProps = parseUiDropdown(otherProps) const commonProps = parseProps({ uiTransform, @@ -47,7 +58,10 @@ export function Dropdown(props: UiDropdownProps) { onMouseDown, onMouseUp, onMouseEnter, - onMouseLeave + onMouseLeave, + onMouseDrag, + onMouseDragLocked, + onMouseDragEnd }) return } diff --git a/packages/@dcl/react-ecs/src/components/Input/index.tsx b/packages/@dcl/react-ecs/src/components/Input/index.tsx index a88f95047..403938107 100644 --- a/packages/@dcl/react-ecs/src/components/Input/index.tsx +++ b/packages/@dcl/react-ecs/src/components/Input/index.tsx @@ -41,7 +41,18 @@ function parseUiInput(props: Partial): PBUiInput { * @category Component */ /* @__PURE__ */ export function Input(props: EntityPropTypes & Partial) { - const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, ...otherProps } = props + const { + uiTransform, + uiBackground, + onMouseDown, + onMouseUp, + onMouseEnter, + onMouseLeave, + onMouseDrag, + onMouseDragLocked, + onMouseDragEnd, + ...otherProps + } = props const inputProps = parseUiInput(otherProps) const commonProps = parseProps({ uiTransform, @@ -49,7 +60,10 @@ export function Input(props: EntityPropTypes & Partial) { onMouseDown, onMouseUp, onMouseEnter, - onMouseLeave + onMouseLeave, + onMouseDrag, + onMouseDragLocked, + onMouseDragEnd }) return } diff --git a/packages/@dcl/react-ecs/src/components/Label/index.tsx b/packages/@dcl/react-ecs/src/components/Label/index.tsx index 5bfea8d06..b871b6254 100644 --- a/packages/@dcl/react-ecs/src/components/Label/index.tsx +++ b/packages/@dcl/react-ecs/src/components/Label/index.tsx @@ -23,7 +23,18 @@ export { scaleFontSize } from './utils' /* @__PURE__ */ export function Label(props: EntityPropTypes & UiLabelProps) { - const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, ...uiTextProps } = props + const { + uiTransform, + uiBackground, + onMouseDown, + onMouseUp, + onMouseEnter, + onMouseLeave, + onMouseDrag, + onMouseDragLocked, + onMouseDragEnd, + ...uiTextProps + } = props const commonProps = parseProps({ uiTransform, @@ -31,7 +42,10 @@ export function Label(props: EntityPropTypes & UiLabelProps) { onMouseDown, onMouseUp, onMouseEnter, - onMouseLeave + onMouseLeave, + onMouseDrag, + onMouseDragLocked, + onMouseDragEnd }) const { font, textAlign, fontSize, textWrap, ...textProps } = uiTextProps const uiText: PBUiText = { diff --git a/packages/@dcl/react-ecs/src/components/listeners/types.ts b/packages/@dcl/react-ecs/src/components/listeners/types.ts index 04fd9a8e9..77f4041a5 100644 --- a/packages/@dcl/react-ecs/src/components/listeners/types.ts +++ b/packages/@dcl/react-ecs/src/components/listeners/types.ts @@ -17,13 +17,22 @@ export type Listeners = { onMouseEnter?: Callback /** triggered on mouse leave event */ onMouseLeave?: Callback + /** triggered on mouse drag event */ + onMouseDrag?: Callback + /** triggered on mouse drag event */ + onMouseDragLocked?: Callback + /** triggered on mouse drag event */ + onMouseDragEnd?: Callback } const listeners: Listeners = { onMouseDown: undefined, onMouseUp: undefined, onMouseEnter: undefined, - onMouseLeave: undefined + onMouseLeave: undefined, + onMouseDrag: undefined, + onMouseDragLocked: undefined, + onMouseDragEnd: undefined } const listenersKey = Object.keys(listeners) diff --git a/packages/@dcl/react-ecs/src/react-ecs.ts b/packages/@dcl/react-ecs/src/react-ecs.ts index f29fcf574..c62195272 100644 --- a/packages/@dcl/react-ecs/src/react-ecs.ts +++ b/packages/@dcl/react-ecs/src/react-ecs.ts @@ -23,6 +23,9 @@ export type EntityComponents = { onMouseUp: Callback onMouseEnter: Callback onMouseLeave: Callback + onMouseDrag: Callback + onMouseDragLocked: Callback + onMouseDragEnd: Callback } /** diff --git a/packages/@dcl/react-ecs/src/reconciler/index.ts b/packages/@dcl/react-ecs/src/reconciler/index.ts index a8a61136d..d21705f37 100644 --- a/packages/@dcl/react-ecs/src/reconciler/index.ts +++ b/packages/@dcl/react-ecs/src/reconciler/index.ts @@ -30,7 +30,10 @@ function getPointerEnum(pointerKey: keyof Listeners): PointerEventType { onMouseDown: PointerEventType.PET_DOWN, onMouseUp: PointerEventType.PET_UP, onMouseEnter: PointerEventType.PET_HOVER_ENTER, - onMouseLeave: PointerEventType.PET_HOVER_LEAVE + onMouseLeave: PointerEventType.PET_HOVER_LEAVE, + onMouseDrag: PointerEventType.PET_DRAG, + onMouseDragLocked: PointerEventType.PET_DRAG_LOCKED, + onMouseDragEnd: PointerEventType.PET_DRAG_END } return pointers[pointerKey] } @@ -94,7 +97,18 @@ export function createReconciler( function upsertListener( instance: Instance, - update: Changes> + update: Changes< + keyof Pick< + Listeners, + | 'onMouseDown' + | 'onMouseUp' + | 'onMouseEnter' + | 'onMouseLeave' + | 'onMouseDrag' + | 'onMouseDragLocked' + | 'onMouseDragEnd' + > + > ) { if (update.type === 'delete' || !update.props) { clickEvents.get(instance.entity)?.delete(getPointerEnum(update.component)) @@ -106,6 +120,12 @@ export function createReconciler( pointerEvents.removeOnPointerHoverEnter(instance.entity) } else if (update.component === 'onMouseLeave') { pointerEvents.removeOnPointerHoverLeave(instance.entity) + } else if (update.component === 'onMouseDrag') { + pointerEvents.removeOnPointerDrag(instance.entity) + } else if (update.component === 'onMouseDragLocked') { + pointerEvents.removeOnPointerDragLocked(instance.entity) + } else if (update.component === 'onMouseDragEnd') { + pointerEvents.removeOnPointerDragEnd(instance.entity) } return } @@ -126,7 +146,13 @@ export function createReconciler( ? pointerEvents.onPointerUp : update.component === 'onMouseEnter' ? pointerEvents.onPointerHoverEnter - : update.component === 'onMouseLeave' && pointerEvents.onPointerHoverLeave + : update.component === 'onMouseLeave' + ? pointerEvents.onPointerHoverLeave + : update.component === 'onMouseDrag' + ? pointerEvents.onPointerDrag + : update.component === 'onMouseDragLocked' + ? pointerEvents.onPointerDragLocked + : update.component === 'onMouseDragEnd' && pointerEvents.onPointerDragEnd if (pointerEventSystem) { pointerEventSystem( diff --git a/packages/@dcl/react-ecs/src/reconciler/utils.ts b/packages/@dcl/react-ecs/src/reconciler/utils.ts index 5f9349b06..8074759e4 100644 --- a/packages/@dcl/react-ecs/src/reconciler/utils.ts +++ b/packages/@dcl/react-ecs/src/reconciler/utils.ts @@ -60,6 +60,9 @@ const entityComponent: EntityComponents = { onMouseUp: undefined as any, onMouseEnter: undefined as any, onMouseLeave: undefined as any, + onMouseDrag: undefined as any, + onMouseDragLocked: undefined as any, + onMouseDragEnd: undefined as any, uiInput: undefined as any, uiDropdown: undefined as any } diff --git a/packages/@dcl/sdk-commands/package-lock.json b/packages/@dcl/sdk-commands/package-lock.json index 6a18863a4..9ce2e0653 100644 --- a/packages/@dcl/sdk-commands/package-lock.json +++ b/packages/@dcl/sdk-commands/package-lock.json @@ -15,7 +15,7 @@ "@dcl/inspector": "file:../inspector", "@dcl/linker-dapp": "^0.14.2", "@dcl/mini-comms": "1.0.1-20230216163137.commit-a4c75be", - "@dcl/protocol": "1.0.0-12415236132.commit-53e881e", + "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791995584.commit-4338852.tgz", "@dcl/quests-client": "^1.0.3", "@dcl/quests-manager": "^0.1.4", "@dcl/rpc": "^1.1.1", @@ -240,9 +240,10 @@ } }, "node_modules/@dcl/protocol": { - "version": "1.0.0-12415236132.commit-53e881e", - "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-12415236132.commit-53e881e.tgz", - "integrity": "sha512-T2xrziqHNmpPWSD0POdnTY33BcPQThOUEIxxdmAcDzX/YMRVfy9sKDhP3PvS0diVDGbjxo+tKBagL75M9WLJxg==", + "version": "1.0.0-12791995584.commit-4338852", + "resolved": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791995584.commit-4338852.tgz", + "integrity": "sha512-JkXkqbquAhQXUUwktn2g5OWDL1vbWTLbKg3xB/BDguWWYCydD9znE8XMTT51FXvVI5mB6lQENsAKuxzaoWOatQ==", + "license": "Apache-2.0", "dependencies": { "@dcl/ts-proto": "1.154.0" } @@ -3711,7 +3712,7 @@ "integrity": "sha512-gRatBUHwYTk9Ko03fVnU6aIpIrPwLVUiJg67MQJ42F/9/W0SONm7SFjuOtSIwNff+Cq6my5K3rbS0itut/TH+w==", "requires": { "@dcl/crypto": "^3.3.1", - "@dcl/protocol": "1.0.0-12415236132.commit-53e881e", + "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791995584.commit-4338852.tgz", "@dcl/rpc": "^1.1.1", "@dcl/schemas": "^6.10.0", "@types/ws": "^8.5.3", @@ -3737,9 +3738,8 @@ } }, "@dcl/protocol": { - "version": "1.0.0-12415236132.commit-53e881e", - "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-12415236132.commit-53e881e.tgz", - "integrity": "sha512-T2xrziqHNmpPWSD0POdnTY33BcPQThOUEIxxdmAcDzX/YMRVfy9sKDhP3PvS0diVDGbjxo+tKBagL75M9WLJxg==", + "version": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791995584.commit-4338852.tgz", + "integrity": "sha512-JkXkqbquAhQXUUwktn2g5OWDL1vbWTLbKg3xB/BDguWWYCydD9znE8XMTT51FXvVI5mB6lQENsAKuxzaoWOatQ==", "requires": { "@dcl/ts-proto": "1.154.0" } @@ -3749,7 +3749,7 @@ "resolved": "https://registry.npmjs.org/@dcl/quests-client/-/quests-client-1.0.3.tgz", "integrity": "sha512-VwZbXuHsRbRcboUUlBrauuR7VQ7IQP31rWI7wNKIYfWroTH4Yw7Bby1au9JBPWPayM/zRDij4uSd9pMJtidsqw==", "requires": { - "@dcl/protocol": "1.0.0-12415236132.commit-53e881e", + "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791995584.commit-4338852.tgz", "@dcl/rpc": "^1.1.2", "@dcl/sdk": "latest", "mitt": "^3.0.1" @@ -3828,7 +3828,7 @@ "@dcl/inspector": "7.3.23", "@dcl/linker-dapp": "^0.11.0", "@dcl/mini-comms": "1.0.1-20230216163137.commit-a4c75be", - "@dcl/protocol": "1.0.0-12415236132.commit-53e881e", + "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791995584.commit-4338852.tgz", "@dcl/quests-manager": "^0.1.2", "@dcl/rpc": "^1.1.1", "@dcl/schemas": "^8.2.3-20230718182824.commit-356025c", diff --git a/packages/@dcl/sdk-commands/package.json b/packages/@dcl/sdk-commands/package.json index 74a37c6a9..e06290a72 100644 --- a/packages/@dcl/sdk-commands/package.json +++ b/packages/@dcl/sdk-commands/package.json @@ -13,7 +13,7 @@ "@dcl/inspector": "file:../inspector", "@dcl/linker-dapp": "^0.14.2", "@dcl/mini-comms": "1.0.1-20230216163137.commit-a4c75be", - "@dcl/protocol": "1.0.0-12415236132.commit-53e881e", + "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791995584.commit-4338852.tgz", "@dcl/quests-client": "^1.0.3", "@dcl/quests-manager": "^0.1.4", "@dcl/rpc": "^1.1.1", @@ -58,7 +58,7 @@ "license": "Apache-2.0", "minCliVersion": "3.14.1", "overrides": { - "@dcl/protocol": "1.0.0-12415236132.commit-53e881e" + "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12791995584.commit-4338852.tgz" }, "repository": { "url": "git+https://github.com/decentraland/js-sdk-toolchain", diff --git a/packages/@dcl/sdk-commands/src/index.ts b/packages/@dcl/sdk-commands/src/index.ts old mode 100755 new mode 100644