From 8a589f0e1724da38624db802c3261c6b8572aa78 Mon Sep 17 00:00:00 2001 From: dockfries Date: Sat, 2 Dec 2023 12:39:49 +0800 Subject: [PATCH] feat(core): event constant `object.freeze` --- packages/core/src/controllers/gangzone/event.ts | 4 ++-- packages/core/src/controllers/menu/event.ts | 4 ++-- packages/core/src/controllers/npc/event.ts | 4 ++-- packages/core/src/controllers/player/index.ts | 4 ++-- packages/core/src/controllers/textdraw/event.ts | 5 ++++- packages/core/src/controllers/vehicle/event.ts | 4 ++-- packages/core/src/wrapper/streamer/3dtext/event.ts | 4 ++-- packages/core/src/wrapper/streamer/actor/event.ts | 4 ++-- packages/core/src/wrapper/streamer/area/event.ts | 4 ++-- packages/core/src/wrapper/streamer/checkpoint/event.ts | 4 ++-- packages/core/src/wrapper/streamer/mapIcon/event.ts | 4 ++-- packages/core/src/wrapper/streamer/object/event.ts | 4 ++-- packages/core/src/wrapper/streamer/pickup/event.ts | 4 ++-- packages/core/src/wrapper/streamer/raceCP/event.ts | 4 ++-- 14 files changed, 30 insertions(+), 27 deletions(-) diff --git a/packages/core/src/controllers/gangzone/event.ts b/packages/core/src/controllers/gangzone/event.ts index 3758971..b1a6506 100644 --- a/packages/core/src/controllers/gangzone/event.ts +++ b/packages/core/src/controllers/gangzone/event.ts @@ -49,9 +49,9 @@ const [onPlayerLeavePlayer] = defineEvent({ }, }); -export const GangZoneEvent = { +export const GangZoneEvent = Object.freeze({ onPlayerEnterGlobal, onPlayerLeaveGlobal, onPlayerEnterPlayer, onPlayerLeavePlayer, -}; +}); diff --git a/packages/core/src/controllers/menu/event.ts b/packages/core/src/controllers/menu/event.ts index 73066f4..a8c5ad4 100644 --- a/packages/core/src/controllers/menu/event.ts +++ b/packages/core/src/controllers/menu/event.ts @@ -26,7 +26,7 @@ const [onPlayerSelectedRow] = defineEvent({ }, }); -export const MenuEvent = { +export const MenuEvent = Object.freeze({ onPlayerExited, onPlayerSelectedRow, -}; +}); diff --git a/packages/core/src/controllers/npc/event.ts b/packages/core/src/controllers/npc/event.ts index 92b74f6..883d9e6 100644 --- a/packages/core/src/controllers/npc/event.ts +++ b/packages/core/src/controllers/npc/event.ts @@ -39,11 +39,11 @@ const [onClientMessage] = defineEvent({ }, }); -export const NpcEvent = { +export const NpcEvent = Object.freeze({ onConnect, onDisconnect, onModeInit, onModeExit, onSpawn, onClientMessage, -}; +}); diff --git a/packages/core/src/controllers/player/index.ts b/packages/core/src/controllers/player/index.ts index 5d1e1b6..2d41bc5 100644 --- a/packages/core/src/controllers/player/index.ts +++ b/packages/core/src/controllers/player/index.ts @@ -34,7 +34,7 @@ import { onCheckResponse } from "./entity"; export { Player } from "./entity"; -export const PlayerEvent = { +export const PlayerEvent = Object.freeze({ onConnect, onDisconnect, onPause, @@ -64,7 +64,7 @@ export const PlayerEvent = { onCommandText: CmdBus.on, offCommandText: CmdBus.off, onDialogResponse, -}; +}); export { Dialog }; diff --git a/packages/core/src/controllers/textdraw/event.ts b/packages/core/src/controllers/textdraw/event.ts index 728eefe..9425a52 100644 --- a/packages/core/src/controllers/textdraw/event.ts +++ b/packages/core/src/controllers/textdraw/event.ts @@ -35,4 +35,7 @@ const [onPlayerClickPlayer] = defineEvent({ }, }); -export const TextDrawEvent = { onPlayerClickGlobal, onPlayerClickPlayer }; +export const TextDrawEvent = Object.freeze({ + onPlayerClickGlobal, + onPlayerClickPlayer, +}); diff --git a/packages/core/src/controllers/vehicle/event.ts b/packages/core/src/controllers/vehicle/event.ts index 7032a7c..5c95c6f 100644 --- a/packages/core/src/controllers/vehicle/event.ts +++ b/packages/core/src/controllers/vehicle/event.ts @@ -145,7 +145,7 @@ const [onTrailerUpdate] = defineEvent({ }, }); -export const VehicleEvent = { +export const VehicleEvent = Object.freeze({ onDamageStatusUpdate, onDeath, onMod, @@ -160,4 +160,4 @@ export const VehicleEvent = { onNpcEnter, onNpcExit, onTrailerUpdate, -}; +}); diff --git a/packages/core/src/wrapper/streamer/3dtext/event.ts b/packages/core/src/wrapper/streamer/3dtext/event.ts index 1bb2e48..75555b1 100644 --- a/packages/core/src/wrapper/streamer/3dtext/event.ts +++ b/packages/core/src/wrapper/streamer/3dtext/event.ts @@ -42,7 +42,7 @@ onItemStreamOut(({ type, id, forPlayer, next }) => { return next(); }); -export const Dynamic3DTextLabelEvent = { +export const Dynamic3DTextLabelEvent = Object.freeze({ onStreamIn, onStreamOut, -}; +}); diff --git a/packages/core/src/wrapper/streamer/actor/event.ts b/packages/core/src/wrapper/streamer/actor/event.ts index 0424503..a24b816 100644 --- a/packages/core/src/wrapper/streamer/actor/event.ts +++ b/packages/core/src/wrapper/streamer/actor/event.ts @@ -52,8 +52,8 @@ const [onPlayerGiveDamageDynamicActor] = defineEvent({ }, }); -export const DynamicActorEvent = { +export const DynamicActorEvent = Object.freeze({ onStreamIn: onDynamicActorStreamIn, onStreamOut: onDynamicActorStreamOut, onPlayerGiveDamage: onPlayerGiveDamageDynamicActor, -}; +}); diff --git a/packages/core/src/wrapper/streamer/area/event.ts b/packages/core/src/wrapper/streamer/area/event.ts index 3271643..243507f 100644 --- a/packages/core/src/wrapper/streamer/area/event.ts +++ b/packages/core/src/wrapper/streamer/area/event.ts @@ -63,9 +63,9 @@ const [onPlayerLeaveDynamicArea] = defineEvent({ }, }); -export const DynamicAreaEvent = { +export const DynamicAreaEvent = Object.freeze({ onStreamIn, onStreamOut, onPlayerEnter: onPlayerEnterDynamicArea, onPlayerLeave: onPlayerLeaveDynamicArea, -}; +}); diff --git a/packages/core/src/wrapper/streamer/checkpoint/event.ts b/packages/core/src/wrapper/streamer/checkpoint/event.ts index cc50244..74bd476 100644 --- a/packages/core/src/wrapper/streamer/checkpoint/event.ts +++ b/packages/core/src/wrapper/streamer/checkpoint/event.ts @@ -63,9 +63,9 @@ const [onPlayerLeaveDynamicCP] = defineEvent({ }, }); -export const DynamicCheckPointEvent = { +export const DynamicCheckPointEvent = Object.freeze({ onPlayerEnter: onPlayerEnterDynamicCP, onPlayerLeave: onPlayerLeaveDynamicCP, onStreamIn, onStreamOut, -}; +}); diff --git a/packages/core/src/wrapper/streamer/mapIcon/event.ts b/packages/core/src/wrapper/streamer/mapIcon/event.ts index 265c968..aad3615 100644 --- a/packages/core/src/wrapper/streamer/mapIcon/event.ts +++ b/packages/core/src/wrapper/streamer/mapIcon/event.ts @@ -41,7 +41,7 @@ onItemStreamOut(({ type, id, forPlayer, next }) => { return next(); }); -export const DynamicMapIconEvent = { +export const DynamicMapIconEvent = Object.freeze({ onStreamIn, onStreamOut, -}; +}); diff --git a/packages/core/src/wrapper/streamer/object/event.ts b/packages/core/src/wrapper/streamer/object/event.ts index 68c73bd..297c465 100644 --- a/packages/core/src/wrapper/streamer/object/event.ts +++ b/packages/core/src/wrapper/streamer/object/event.ts @@ -159,7 +159,7 @@ const [onPlayerEditAttachedObject] = defineEvent({ }, }); -export const DynamicObjectEvent = { +export const DynamicObjectEvent = Object.freeze({ onMoved: onDynamicObjectMoved, onPlayerEdit: onPlayerEditDynamicObject, onPlayerSelect: onPlayerSelectDynamicObject, @@ -167,4 +167,4 @@ export const DynamicObjectEvent = { onPlayerEditAttached: onPlayerEditAttachedObject, onStreamIn, onStreamOut, -}; +}); diff --git a/packages/core/src/wrapper/streamer/pickup/event.ts b/packages/core/src/wrapper/streamer/pickup/event.ts index 15a7c9f..cb83d6f 100644 --- a/packages/core/src/wrapper/streamer/pickup/event.ts +++ b/packages/core/src/wrapper/streamer/pickup/event.ts @@ -52,8 +52,8 @@ const [onPlayerPickUpDynamicPickup] = defineEvent({ }, }); -export const DynamicPickupEvent = { +export const DynamicPickupEvent = Object.freeze({ onPlayerPickUp: onPlayerPickUpDynamicPickup, onStreamIn, onStreamOut, -}; +}); diff --git a/packages/core/src/wrapper/streamer/raceCP/event.ts b/packages/core/src/wrapper/streamer/raceCP/event.ts index 7c14483..79685f4 100644 --- a/packages/core/src/wrapper/streamer/raceCP/event.ts +++ b/packages/core/src/wrapper/streamer/raceCP/event.ts @@ -63,9 +63,9 @@ const [onPlayerLeaveDynamicRaceCP] = defineEvent({ }, }); -export const DynamicRaceCPEvent = { +export const DynamicRaceCPEvent = Object.freeze({ onPlayerEnter: onPlayerEnterDynamicRaceCP, onPlayerLeave: onPlayerLeaveDynamicRaceCP, onStreamIn, onStreamOut, -}; +});