@open-core/framework 1.0.1-beta.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 (275) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +350 -0
  3. package/dist/client/client-bootstrap.d.ts +1 -0
  4. package/dist/client/client-bootstrap.js +53 -0
  5. package/dist/client/client-container.d.ts +2 -0
  6. package/dist/client/client-container.js +6 -0
  7. package/dist/client/client-core.d.ts +18 -0
  8. package/dist/client/client-core.js +52 -0
  9. package/dist/client/decorators/controller.d.ts +3 -0
  10. package/dist/client/decorators/controller.js +14 -0
  11. package/dist/client/decorators/export.d.ts +7 -0
  12. package/dist/client/decorators/export.js +15 -0
  13. package/dist/client/decorators/gameEvent.d.ts +47 -0
  14. package/dist/client/decorators/gameEvent.js +54 -0
  15. package/dist/client/decorators/index.d.ts +10 -0
  16. package/dist/client/decorators/index.js +26 -0
  17. package/dist/client/decorators/interval.d.ts +7 -0
  18. package/dist/client/decorators/interval.js +15 -0
  19. package/dist/client/decorators/key.d.ts +2 -0
  20. package/dist/client/decorators/key.js +10 -0
  21. package/dist/client/decorators/localEvent.d.ts +7 -0
  22. package/dist/client/decorators/localEvent.js +15 -0
  23. package/dist/client/decorators/nui.d.ts +1 -0
  24. package/dist/client/decorators/nui.js +9 -0
  25. package/dist/client/decorators/onNet.d.ts +1 -0
  26. package/dist/client/decorators/onNet.js +9 -0
  27. package/dist/client/decorators/resourceLifecycle.d.ts +11 -0
  28. package/dist/client/decorators/resourceLifecycle.js +24 -0
  29. package/dist/client/decorators/tick.d.ts +1 -0
  30. package/dist/client/decorators/tick.js +9 -0
  31. package/dist/client/index.d.ts +6 -0
  32. package/dist/client/index.js +22 -0
  33. package/dist/client/loaders/exports.loader.d.ts +1 -0
  34. package/dist/client/loaders/exports.loader.js +13 -0
  35. package/dist/client/player/player.d.ts +262 -0
  36. package/dist/client/player/player.js +480 -0
  37. package/dist/client/player/player.loader.d.ts +1 -0
  38. package/dist/client/player/player.loader.js +22 -0
  39. package/dist/client/services/core/index.d.ts +1 -0
  40. package/dist/client/services/core/index.js +17 -0
  41. package/dist/client/services/core/spawn.service.d.ts +20 -0
  42. package/dist/client/services/core/spawn.service.js +143 -0
  43. package/dist/client/services/index.d.ts +4 -0
  44. package/dist/client/services/index.js +24 -0
  45. package/dist/client/services/streaming/index.d.ts +1 -0
  46. package/dist/client/services/streaming/index.js +17 -0
  47. package/dist/client/services/streaming/streaming.service.d.ts +165 -0
  48. package/dist/client/services/streaming/streaming.service.js +341 -0
  49. package/dist/client/services/ui/index.d.ts +3 -0
  50. package/dist/client/services/ui/index.js +19 -0
  51. package/dist/client/services/ui/notification.service.d.ts +76 -0
  52. package/dist/client/services/ui/notification.service.js +111 -0
  53. package/dist/client/services/ui/progress.service.d.ts +82 -0
  54. package/dist/client/services/ui/progress.service.js +210 -0
  55. package/dist/client/services/ui/textui.service.d.ts +82 -0
  56. package/dist/client/services/ui/textui.service.js +156 -0
  57. package/dist/client/services/world/blip.service.d.ts +112 -0
  58. package/dist/client/services/world/blip.service.js +215 -0
  59. package/dist/client/services/world/index.d.ts +4 -0
  60. package/dist/client/services/world/index.js +20 -0
  61. package/dist/client/services/world/marker.service.d.ts +94 -0
  62. package/dist/client/services/world/marker.service.js +153 -0
  63. package/dist/client/services/world/ped.service.d.ts +182 -0
  64. package/dist/client/services/world/ped.service.js +302 -0
  65. package/dist/client/services/world/vehicle.service.d.ts +168 -0
  66. package/dist/client/services/world/vehicle.service.js +296 -0
  67. package/dist/client/system/metadata-client.keys.d.ts +13 -0
  68. package/dist/client/system/metadata-client.keys.js +16 -0
  69. package/dist/client/system/processors/export.processor.d.ts +7 -0
  70. package/dist/client/system/processors/export.processor.js +39 -0
  71. package/dist/client/system/processors/gameEvent.processor.d.ts +10 -0
  72. package/dist/client/system/processors/gameEvent.processor.js +58 -0
  73. package/dist/client/system/processors/interval.processor.d.ts +7 -0
  74. package/dist/client/system/processors/interval.processor.js +43 -0
  75. package/dist/client/system/processors/key.processor.d.ts +8 -0
  76. package/dist/client/system/processors/key.processor.js +27 -0
  77. package/dist/client/system/processors/localEvent.processor.d.ts +7 -0
  78. package/dist/client/system/processors/localEvent.processor.js +38 -0
  79. package/dist/client/system/processors/netEvent.processor.d.ts +7 -0
  80. package/dist/client/system/processors/netEvent.processor.js +38 -0
  81. package/dist/client/system/processors/nui.processor.d.ts +7 -0
  82. package/dist/client/system/processors/nui.processor.js +40 -0
  83. package/dist/client/system/processors/resourceLifecycle.processor.d.ts +9 -0
  84. package/dist/client/system/processors/resourceLifecycle.processor.js +69 -0
  85. package/dist/client/system/processors/tick.processor.d.ts +5 -0
  86. package/dist/client/system/processors/tick.processor.js +37 -0
  87. package/dist/client/system/processors.register.d.ts +1 -0
  88. package/dist/client/system/processors.register.js +27 -0
  89. package/dist/client/types/game-events.d.ts +126 -0
  90. package/dist/client/types/game-events.js +83 -0
  91. package/dist/client/types/index.d.ts +1 -0
  92. package/dist/client/types/index.js +17 -0
  93. package/dist/client/ui-bridge.d.ts +116 -0
  94. package/dist/client/ui-bridge.js +201 -0
  95. package/dist/index.d.ts +7 -0
  96. package/dist/index.js +46 -0
  97. package/dist/server/bootstrap.d.ts +16 -0
  98. package/dist/server/bootstrap.js +57 -0
  99. package/dist/server/bus/core-event-bus.d.ts +6 -0
  100. package/dist/server/bus/core-event-bus.js +31 -0
  101. package/dist/server/configs/api.config.d.ts +71 -0
  102. package/dist/server/configs/api.config.js +81 -0
  103. package/dist/server/configs/config.base.d.ts +63 -0
  104. package/dist/server/configs/config.base.js +64 -0
  105. package/dist/server/configs/index.d.ts +2 -0
  106. package/dist/server/configs/index.js +18 -0
  107. package/dist/server/container.d.ts +2 -0
  108. package/dist/server/container.js +6 -0
  109. package/dist/server/controllers/chat.controller.d.ts +10 -0
  110. package/dist/server/controllers/chat.controller.js +50 -0
  111. package/dist/server/controllers/command.controller.d.ts +7 -0
  112. package/dist/server/controllers/command.controller.js +47 -0
  113. package/dist/server/core.d.ts +1 -0
  114. package/dist/server/core.js +7 -0
  115. package/dist/server/database/adapters/oxmysql.adapter.d.ts +89 -0
  116. package/dist/server/database/adapters/oxmysql.adapter.js +149 -0
  117. package/dist/server/database/database.contract.d.ts +128 -0
  118. package/dist/server/database/database.contract.js +29 -0
  119. package/dist/server/database/database.service.d.ts +216 -0
  120. package/dist/server/database/database.service.js +301 -0
  121. package/dist/server/database/index.d.ts +53 -0
  122. package/dist/server/database/index.js +70 -0
  123. package/dist/server/database/types.d.ts +67 -0
  124. package/dist/server/database/types.js +7 -0
  125. package/dist/server/database.d.ts +7 -0
  126. package/dist/server/database.js +23 -0
  127. package/dist/server/decorators/bind.d.ts +2 -0
  128. package/dist/server/decorators/bind.js +15 -0
  129. package/dist/server/decorators/command.d.ts +19 -0
  130. package/dist/server/decorators/command.js +18 -0
  131. package/dist/server/decorators/controller.d.ts +3 -0
  132. package/dist/server/decorators/controller.js +14 -0
  133. package/dist/server/decorators/coreEvent.d.ts +2 -0
  134. package/dist/server/decorators/coreEvent.js +9 -0
  135. package/dist/server/decorators/export.d.ts +1 -0
  136. package/dist/server/decorators/export.js +9 -0
  137. package/dist/server/decorators/guard.d.ts +5 -0
  138. package/dist/server/decorators/guard.js +39 -0
  139. package/dist/server/decorators/index.d.ts +10 -0
  140. package/dist/server/decorators/index.js +26 -0
  141. package/dist/server/decorators/netEvent.d.ts +36 -0
  142. package/dist/server/decorators/netEvent.js +40 -0
  143. package/dist/server/decorators/onTick.d.ts +1 -0
  144. package/dist/server/decorators/onTick.js +9 -0
  145. package/dist/server/decorators/public.d.ts +16 -0
  146. package/dist/server/decorators/public.js +25 -0
  147. package/dist/server/decorators/requiresState.d.ts +55 -0
  148. package/dist/server/decorators/requiresState.js +62 -0
  149. package/dist/server/decorators/throttle.d.ts +9 -0
  150. package/dist/server/decorators/throttle.js +36 -0
  151. package/dist/server/decorators/utils.d.ts +7 -0
  152. package/dist/server/decorators/utils.js +13 -0
  153. package/dist/server/entities/index.d.ts +1 -0
  154. package/dist/server/entities/index.js +17 -0
  155. package/dist/server/entities/player.d.ts +157 -0
  156. package/dist/server/entities/player.js +217 -0
  157. package/dist/server/error-handler.d.ts +2 -0
  158. package/dist/server/error-handler.js +43 -0
  159. package/dist/server/index.d.ts +10 -0
  160. package/dist/server/index.js +29 -0
  161. package/dist/server/loaders/exports.loader.d.ts +0 -0
  162. package/dist/server/loaders/exports.loader.js +23 -0
  163. package/dist/server/loaders/playerSession.loader.d.ts +1 -0
  164. package/dist/server/loaders/playerSession.loader.js +42 -0
  165. package/dist/server/services/access-control.service.d.ts +56 -0
  166. package/dist/server/services/access-control.service.js +99 -0
  167. package/dist/server/services/chat.service.d.ts +7 -0
  168. package/dist/server/services/chat.service.js +31 -0
  169. package/dist/server/services/command.service.d.ts +15 -0
  170. package/dist/server/services/command.service.js +74 -0
  171. package/dist/server/services/config.service.d.ts +75 -0
  172. package/dist/server/services/config.service.js +116 -0
  173. package/dist/server/services/default/default-security.handler.d.ts +6 -0
  174. package/dist/server/services/default/default-security.handler.js +26 -0
  175. package/dist/server/services/http/http.service.d.ts +50 -0
  176. package/dist/server/services/http/http.service.js +126 -0
  177. package/dist/server/services/index.d.ts +10 -0
  178. package/dist/server/services/index.js +26 -0
  179. package/dist/server/services/parallel/index.d.ts +49 -0
  180. package/dist/server/services/parallel/index.js +67 -0
  181. package/dist/server/services/parallel/parallel-compute.service.d.ts +132 -0
  182. package/dist/server/services/parallel/parallel-compute.service.js +449 -0
  183. package/dist/server/services/parallel/types.d.ts +188 -0
  184. package/dist/server/services/parallel/types.js +7 -0
  185. package/dist/server/services/parallel/worker-pool.d.ts +83 -0
  186. package/dist/server/services/parallel/worker-pool.js +350 -0
  187. package/dist/server/services/parallel/worker.d.ts +19 -0
  188. package/dist/server/services/parallel/worker.js +49 -0
  189. package/dist/server/services/persistence.service.d.ts +59 -0
  190. package/dist/server/services/persistence.service.js +166 -0
  191. package/dist/server/services/player.service.d.ts +96 -0
  192. package/dist/server/services/player.service.js +132 -0
  193. package/dist/server/services/rate-limiter.service.d.ts +5 -0
  194. package/dist/server/services/rate-limiter.service.js +39 -0
  195. package/dist/server/services/registers.d.ts +1 -0
  196. package/dist/server/services/registers.js +18 -0
  197. package/dist/server/setup.d.ts +9 -0
  198. package/dist/server/setup.js +28 -0
  199. package/dist/server/system/metadata-server.keys.d.ts +9 -0
  200. package/dist/server/system/metadata-server.keys.js +12 -0
  201. package/dist/server/system/processors/command.processor.d.ts +9 -0
  202. package/dist/server/system/processors/command.processor.js +31 -0
  203. package/dist/server/system/processors/coreEvent.processor.d.ts +7 -0
  204. package/dist/server/system/processors/coreEvent.processor.js +38 -0
  205. package/dist/server/system/processors/export.processor.d.ts +7 -0
  206. package/dist/server/system/processors/export.processor.js +26 -0
  207. package/dist/server/system/processors/netEvent.processor.d.ts +11 -0
  208. package/dist/server/system/processors/netEvent.processor.js +100 -0
  209. package/dist/server/system/processors/tick.processor.d.ts +5 -0
  210. package/dist/server/system/processors/tick.processor.js +36 -0
  211. package/dist/server/system/processors.register.d.ts +1 -0
  212. package/dist/server/system/processors.register.js +21 -0
  213. package/dist/server/templates/admin/admin.controller-template.d.ts +10 -0
  214. package/dist/server/templates/admin/admin.controller-template.js +2 -0
  215. package/dist/server/templates/auth/auth-provider.contract.d.ts +58 -0
  216. package/dist/server/templates/auth/auth-provider.contract.js +23 -0
  217. package/dist/server/templates/index.d.ts +8 -0
  218. package/dist/server/templates/index.js +21 -0
  219. package/dist/server/templates/persistence/index.d.ts +30 -0
  220. package/dist/server/templates/persistence/index.js +34 -0
  221. package/dist/server/templates/persistence/player-persistence.contract.d.ts +86 -0
  222. package/dist/server/templates/persistence/player-persistence.contract.js +52 -0
  223. package/dist/server/templates/repository/index.d.ts +57 -0
  224. package/dist/server/templates/repository/index.js +61 -0
  225. package/dist/server/templates/repository/repository.contract.d.ts +224 -0
  226. package/dist/server/templates/repository/repository.contract.js +342 -0
  227. package/dist/server/templates/repository/repository.types.d.ts +51 -0
  228. package/dist/server/templates/repository/repository.types.js +7 -0
  229. package/dist/server/templates/security/permission.types.d.ts +32 -0
  230. package/dist/server/templates/security/permission.types.js +2 -0
  231. package/dist/server/templates/security/principal-provider.contract.d.ts +43 -0
  232. package/dist/server/templates/security/principal-provider.contract.js +19 -0
  233. package/dist/server/templates/security/security-handler.contract.d.ts +5 -0
  234. package/dist/server/templates/security/security-handler.contract.js +6 -0
  235. package/dist/server/types/core-events.d.ts +17 -0
  236. package/dist/server/types/core-events.js +2 -0
  237. package/dist/server/types/security.types.d.ts +7 -0
  238. package/dist/server/types/security.types.js +2 -0
  239. package/dist/shared/index.d.ts +1 -0
  240. package/dist/shared/index.js +17 -0
  241. package/dist/shared/logger/core-logger.d.ts +35 -0
  242. package/dist/shared/logger/core-logger.js +52 -0
  243. package/dist/shared/logger/index.d.ts +11 -0
  244. package/dist/shared/logger/index.js +26 -0
  245. package/dist/shared/logger/logger.config.d.ts +47 -0
  246. package/dist/shared/logger/logger.config.js +33 -0
  247. package/dist/shared/logger/logger.service.d.ts +161 -0
  248. package/dist/shared/logger/logger.service.js +279 -0
  249. package/dist/shared/logger/logger.types.d.ts +85 -0
  250. package/dist/shared/logger/logger.types.js +74 -0
  251. package/dist/shared/logger/transports/buffered.transport.d.ts +88 -0
  252. package/dist/shared/logger/transports/buffered.transport.js +174 -0
  253. package/dist/shared/logger/transports/console.transport.d.ts +37 -0
  254. package/dist/shared/logger/transports/console.transport.js +134 -0
  255. package/dist/shared/logger/transports/index.d.ts +3 -0
  256. package/dist/shared/logger/transports/index.js +19 -0
  257. package/dist/shared/logger/transports/transport.interface.d.ts +40 -0
  258. package/dist/shared/logger/transports/transport.interface.js +2 -0
  259. package/dist/system/class-constructor.d.ts +1 -0
  260. package/dist/system/class-constructor.js +2 -0
  261. package/dist/system/decorator-processor.d.ts +4 -0
  262. package/dist/system/decorator-processor.js +2 -0
  263. package/dist/system/metadata.scanner.d.ts +7 -0
  264. package/dist/system/metadata.scanner.js +45 -0
  265. package/dist/utils/errors.d.ts +14 -0
  266. package/dist/utils/errors.js +25 -0
  267. package/dist/utils/index.d.ts +4 -0
  268. package/dist/utils/index.js +20 -0
  269. package/dist/utils/result.d.ts +12 -0
  270. package/dist/utils/result.js +10 -0
  271. package/dist/utils/rgb.d.ts +5 -0
  272. package/dist/utils/rgb.js +2 -0
  273. package/dist/utils/vector3.d.ts +13 -0
  274. package/dist/utils/vector3.js +27 -0
  275. package/package.json +70 -0
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.NotificationService = void 0;
10
+ const tsyringe_1 = require("tsyringe");
11
+ /**
12
+ * Service for displaying native GTA V notifications.
13
+ */
14
+ let NotificationService = class NotificationService {
15
+ /**
16
+ * Show a simple notification on screen.
17
+ *
18
+ * @param message - The message to display
19
+ * @param blink - Whether the notification should blink
20
+ */
21
+ show(message, blink = false) {
22
+ SetNotificationTextEntry('STRING');
23
+ AddTextComponentString(message);
24
+ DrawNotification(blink, true);
25
+ }
26
+ /**
27
+ * Show a notification with a type indicator using throbber icons.
28
+ *
29
+ * @param message - The message to display
30
+ * @param type - The notification type
31
+ */
32
+ showWithType(message, type = 'info') {
33
+ const iconMap = {
34
+ info: 1,
35
+ success: 2,
36
+ warning: 3,
37
+ error: 4,
38
+ };
39
+ BeginTextCommandThefeedPost('STRING');
40
+ AddTextComponentString(message);
41
+ EndTextCommandThefeedPostMessagetext('CHAR_SOCIAL_CLUB', 'CHAR_SOCIAL_CLUB', true, iconMap[type], '', message);
42
+ }
43
+ /**
44
+ * Show an advanced notification with picture/icon.
45
+ *
46
+ * @param options - Advanced notification options
47
+ */
48
+ showAdvanced(options) {
49
+ const { title, subtitle = '', message, textureDict = 'CHAR_HUMANDEFAULT', textureName = 'CHAR_HUMANDEFAULT', iconType = 1, flash = false, saveToBrief = true, backgroundColor, } = options;
50
+ SetNotificationTextEntry('STRING');
51
+ AddTextComponentString(message);
52
+ if (backgroundColor !== undefined) {
53
+ SetNotificationBackgroundColor(backgroundColor);
54
+ }
55
+ SetNotificationMessage(textureDict, textureName, flash, iconType, title, subtitle);
56
+ DrawNotification(flash, saveToBrief);
57
+ }
58
+ /**
59
+ * Show a help notification (appears at top-left).
60
+ *
61
+ * @param message - The help message
62
+ * @param duration - How long to show in milliseconds (-1 for indefinite)
63
+ * @param beep - Play a beep sound
64
+ * @param looped - Keep showing until cleared
65
+ */
66
+ showHelp(message, duration = 5000, beep = true, looped = false) {
67
+ BeginTextCommandDisplayHelp('STRING');
68
+ AddTextComponentSubstringPlayerName(message);
69
+ EndTextCommandDisplayHelp(0, looped, beep, duration);
70
+ }
71
+ /**
72
+ * Clear all help messages.
73
+ */
74
+ clearHelp() {
75
+ ClearAllHelpMessages();
76
+ }
77
+ /**
78
+ * Show a subtitle (centered at bottom of screen).
79
+ *
80
+ * @param message - The subtitle text
81
+ * @param duration - Duration in milliseconds
82
+ */
83
+ showSubtitle(message, duration = 2500) {
84
+ BeginTextCommandPrint('STRING');
85
+ AddTextComponentSubstringPlayerName(message);
86
+ EndTextCommandPrint(duration, true);
87
+ }
88
+ /**
89
+ * Clear the current subtitle.
90
+ */
91
+ clearSubtitle() {
92
+ ClearPrints();
93
+ }
94
+ /**
95
+ * Show a floating help text above the player's head.
96
+ *
97
+ * @param message - The message to display
98
+ */
99
+ showFloatingHelp(message) {
100
+ const [x, y, z] = GetEntityCoords(PlayerPedId(), true);
101
+ SetFloatingHelpTextWorldPosition(1, x, y, z);
102
+ SetFloatingHelpTextStyle(1, 1, 2, -1, 3, 0);
103
+ BeginTextCommandDisplayHelp('STRING');
104
+ AddTextComponentSubstringPlayerName(message);
105
+ EndTextCommandDisplayHelp(2, false, false, -1);
106
+ }
107
+ };
108
+ exports.NotificationService = NotificationService;
109
+ exports.NotificationService = NotificationService = __decorate([
110
+ (0, tsyringe_1.injectable)()
111
+ ], NotificationService);
@@ -0,0 +1,82 @@
1
+ export interface ProgressOptions {
2
+ /** Progress label/title */
3
+ label: string;
4
+ /** Duration in milliseconds */
5
+ duration: number;
6
+ /** Whether to use a circular indicator */
7
+ useCircular?: boolean;
8
+ /** Whether the player can cancel (usually with a key) */
9
+ canCancel?: boolean;
10
+ /** Disable player controls during progress */
11
+ disableControls?: boolean;
12
+ /** Disable player movement */
13
+ disableMovement?: boolean;
14
+ /** Disable combat actions */
15
+ disableCombat?: boolean;
16
+ /** Animation to play during progress */
17
+ animation?: {
18
+ dict: string;
19
+ anim: string;
20
+ flags?: number;
21
+ };
22
+ /** Prop to attach during progress */
23
+ prop?: {
24
+ model: string;
25
+ bone: number;
26
+ offset: {
27
+ x: number;
28
+ y: number;
29
+ z: number;
30
+ };
31
+ rotation: {
32
+ x: number;
33
+ y: number;
34
+ z: number;
35
+ };
36
+ };
37
+ }
38
+ export interface ProgressState {
39
+ active: boolean;
40
+ progress: number;
41
+ label: string;
42
+ startTime: number;
43
+ duration: number;
44
+ options: ProgressOptions;
45
+ }
46
+ /**
47
+ * Service for displaying progress bars/indicators.
48
+ */
49
+ export declare class ProgressService {
50
+ private state;
51
+ private tickHandle;
52
+ private callback;
53
+ private propHandle;
54
+ /**
55
+ * Start a progress action.
56
+ *
57
+ * @param options - Progress options
58
+ * @returns Promise that resolves with true if completed, false if cancelled
59
+ */
60
+ start(options: ProgressOptions): Promise<boolean>;
61
+ /**
62
+ * Cancel the current progress.
63
+ */
64
+ cancel(): void;
65
+ /**
66
+ * Check if a progress is currently active.
67
+ */
68
+ isActive(): boolean;
69
+ /**
70
+ * Get current progress percentage (0-100).
71
+ */
72
+ getProgress(): number;
73
+ /**
74
+ * Get current progress state.
75
+ */
76
+ getState(): ProgressState | null;
77
+ private startProgress;
78
+ private drawProgressBar;
79
+ private cleanup;
80
+ private loadAnimDict;
81
+ private loadModel;
82
+ }
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.ProgressService = void 0;
10
+ const tsyringe_1 = require("tsyringe");
11
+ /**
12
+ * Service for displaying progress bars/indicators.
13
+ */
14
+ let ProgressService = class ProgressService {
15
+ constructor() {
16
+ this.state = null;
17
+ this.tickHandle = null;
18
+ this.callback = null;
19
+ this.propHandle = null;
20
+ }
21
+ /**
22
+ * Start a progress action.
23
+ *
24
+ * @param options - Progress options
25
+ * @returns Promise that resolves with true if completed, false if cancelled
26
+ */
27
+ async start(options) {
28
+ var _a;
29
+ if ((_a = this.state) === null || _a === void 0 ? void 0 : _a.active) {
30
+ return false;
31
+ }
32
+ return new Promise((resolve) => {
33
+ this.state = {
34
+ active: true,
35
+ progress: 0,
36
+ label: options.label,
37
+ startTime: GetGameTimer(),
38
+ duration: options.duration,
39
+ options,
40
+ };
41
+ this.callback = resolve;
42
+ this.startProgress();
43
+ });
44
+ }
45
+ /**
46
+ * Cancel the current progress.
47
+ */
48
+ cancel() {
49
+ var _a;
50
+ if (!((_a = this.state) === null || _a === void 0 ? void 0 : _a.active))
51
+ return;
52
+ this.cleanup(false);
53
+ }
54
+ /**
55
+ * Check if a progress is currently active.
56
+ */
57
+ isActive() {
58
+ var _a, _b;
59
+ return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.active) !== null && _b !== void 0 ? _b : false;
60
+ }
61
+ /**
62
+ * Get current progress percentage (0-100).
63
+ */
64
+ getProgress() {
65
+ var _a, _b;
66
+ return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.progress) !== null && _b !== void 0 ? _b : 0;
67
+ }
68
+ /**
69
+ * Get current progress state.
70
+ */
71
+ getState() {
72
+ return this.state;
73
+ }
74
+ async startProgress() {
75
+ var _a;
76
+ if (!this.state)
77
+ return;
78
+ const { options } = this.state;
79
+ const ped = PlayerPedId();
80
+ // Load and play animation if specified
81
+ if (options.animation) {
82
+ await this.loadAnimDict(options.animation.dict);
83
+ TaskPlayAnim(ped, options.animation.dict, options.animation.anim, 8.0, -8.0, options.duration, (_a = options.animation.flags) !== null && _a !== void 0 ? _a : 1, 0.0, false, false, false);
84
+ }
85
+ // Attach prop if specified
86
+ if (options.prop) {
87
+ await this.loadModel(options.prop.model);
88
+ const propHash = GetHashKey(options.prop.model);
89
+ const coords = GetEntityCoords(ped, true);
90
+ this.propHandle = CreateObject(propHash, coords[0], coords[1], coords[2], true, true, true);
91
+ AttachEntityToEntity(this.propHandle, ped, GetPedBoneIndex(ped, options.prop.bone), options.prop.offset.x, options.prop.offset.y, options.prop.offset.z, options.prop.rotation.x, options.prop.rotation.y, options.prop.rotation.z, true, true, false, true, 1, true);
92
+ }
93
+ // Start the tick
94
+ this.tickHandle = setTick(() => {
95
+ if (!this.state)
96
+ return;
97
+ const elapsed = GetGameTimer() - this.state.startTime;
98
+ this.state.progress = Math.min((elapsed / this.state.duration) * 100, 100);
99
+ // Handle controls
100
+ if (options.disableControls) {
101
+ DisableAllControlActions(0);
102
+ }
103
+ else {
104
+ if (options.disableMovement) {
105
+ DisableControlAction(0, 30, true); // Move LR
106
+ DisableControlAction(0, 31, true); // Move UD
107
+ DisableControlAction(0, 21, true); // Sprint
108
+ DisableControlAction(0, 22, true); // Jump
109
+ }
110
+ if (options.disableCombat) {
111
+ DisableControlAction(0, 24, true); // Attack
112
+ DisableControlAction(0, 25, true); // Aim
113
+ DisableControlAction(0, 47, true); // Weapon
114
+ DisableControlAction(0, 58, true); // Weapon
115
+ DisableControlAction(0, 263, true); // Melee
116
+ DisableControlAction(0, 264, true); // Melee
117
+ }
118
+ }
119
+ // Check for cancel
120
+ if (options.canCancel && IsControlJustPressed(0, 200)) {
121
+ // ESC key
122
+ this.cancel();
123
+ return;
124
+ }
125
+ // Draw progress bar (native style)
126
+ this.drawProgressBar();
127
+ // Check completion
128
+ if (elapsed >= this.state.duration) {
129
+ this.cleanup(true);
130
+ }
131
+ });
132
+ }
133
+ drawProgressBar() {
134
+ if (!this.state)
135
+ return;
136
+ const { label, progress, options } = this.state;
137
+ if (options.useCircular) {
138
+ // Circular progress indicator
139
+ BeginTextCommandBusyspinnerOn('STRING');
140
+ AddTextComponentString(label);
141
+ EndTextCommandBusyspinnerOn(4);
142
+ }
143
+ else {
144
+ // Bar style progress
145
+ const barWidth = 0.15;
146
+ const barHeight = 0.015;
147
+ const x = 0.5 - barWidth / 2;
148
+ const y = 0.88;
149
+ // Background
150
+ DrawRect(0.5, y + barHeight / 2, barWidth, barHeight, 0, 0, 0, 180);
151
+ // Progress fill
152
+ const fillWidth = (barWidth * progress) / 100;
153
+ DrawRect(x + fillWidth / 2, y + barHeight / 2, fillWidth, barHeight, 255, 255, 255, 255);
154
+ // Label
155
+ SetTextFont(4);
156
+ SetTextScale(0.35, 0.35);
157
+ SetTextColour(255, 255, 255, 255);
158
+ SetTextCentre(true);
159
+ BeginTextCommandDisplayText('STRING');
160
+ AddTextComponentString(`${label} (${Math.floor(progress)}%)`);
161
+ EndTextCommandDisplayText(0.5, y - 0.03);
162
+ }
163
+ }
164
+ cleanup(completed) {
165
+ var _a, _b;
166
+ const ped = PlayerPedId();
167
+ // Stop animation
168
+ if ((_a = this.state) === null || _a === void 0 ? void 0 : _a.options.animation) {
169
+ StopAnimTask(ped, this.state.options.animation.dict, this.state.options.animation.anim, 1.0);
170
+ }
171
+ // Remove prop
172
+ if (this.propHandle) {
173
+ DeleteEntity(this.propHandle);
174
+ this.propHandle = null;
175
+ }
176
+ // Clear tick
177
+ if (this.tickHandle !== null) {
178
+ clearTick(this.tickHandle);
179
+ this.tickHandle = null;
180
+ }
181
+ // Clear busy spinner
182
+ if ((_b = this.state) === null || _b === void 0 ? void 0 : _b.options.useCircular) {
183
+ BusyspinnerOff();
184
+ }
185
+ // Reset state
186
+ this.state = null;
187
+ // Invoke callback
188
+ if (this.callback) {
189
+ this.callback(completed);
190
+ this.callback = null;
191
+ }
192
+ }
193
+ async loadAnimDict(dict) {
194
+ RequestAnimDict(dict);
195
+ while (!HasAnimDictLoaded(dict)) {
196
+ await new Promise((r) => setTimeout(r, 0));
197
+ }
198
+ }
199
+ async loadModel(model) {
200
+ const hash = GetHashKey(model);
201
+ RequestModel(hash);
202
+ while (!HasModelLoaded(hash)) {
203
+ await new Promise((r) => setTimeout(r, 0));
204
+ }
205
+ }
206
+ };
207
+ exports.ProgressService = ProgressService;
208
+ exports.ProgressService = ProgressService = __decorate([
209
+ (0, tsyringe_1.injectable)()
210
+ ], ProgressService);
@@ -0,0 +1,82 @@
1
+ import type { Vector3 } from '../../../utils';
2
+ export interface TextUIOptions {
3
+ /** Font (0-8) */
4
+ font?: number;
5
+ /** Scale (0.0-1.0+) */
6
+ scale?: number;
7
+ /** Color */
8
+ color?: {
9
+ r: number;
10
+ g: number;
11
+ b: number;
12
+ a: number;
13
+ };
14
+ /** Text alignment (0=center, 1=left, 2=right) */
15
+ alignment?: number;
16
+ /** Drop shadow */
17
+ dropShadow?: boolean;
18
+ /** Text outline */
19
+ outline?: boolean;
20
+ /** Word wrap width (0 = no wrap) */
21
+ wrapWidth?: number;
22
+ }
23
+ export interface Text3DOptions extends TextUIOptions {
24
+ /** Whether to draw a background behind text */
25
+ background?: boolean;
26
+ /** Background color */
27
+ backgroundColor?: {
28
+ r: number;
29
+ g: number;
30
+ b: number;
31
+ a: number;
32
+ };
33
+ /** Background padding */
34
+ backgroundPadding?: number;
35
+ }
36
+ /**
37
+ * Service for rendering text UI elements on screen and in 3D world.
38
+ */
39
+ export declare class TextUIService {
40
+ private activeTextUI;
41
+ private tickHandle;
42
+ /**
43
+ * Show persistent text UI at the bottom-right of the screen.
44
+ *
45
+ * @param text - The text to display
46
+ * @param options - Text options
47
+ */
48
+ show(text: string, options?: TextUIOptions): void;
49
+ /**
50
+ * Hide the persistent text UI.
51
+ */
52
+ hide(): void;
53
+ /**
54
+ * Check if text UI is currently visible.
55
+ */
56
+ isVisible(): boolean;
57
+ /**
58
+ * Draw text on screen for one frame.
59
+ * Call this every frame for persistent display.
60
+ *
61
+ * @param text - The text to draw
62
+ * @param x - Screen X position (0.0-1.0)
63
+ * @param y - Screen Y position (0.0-1.0)
64
+ * @param options - Text options
65
+ */
66
+ drawText(text: string, x: number, y: number, options?: TextUIOptions): void;
67
+ /**
68
+ * Draw 3D text in the game world.
69
+ *
70
+ * @param position - World position
71
+ * @param text - The text to draw
72
+ * @param options - Text options
73
+ */
74
+ drawText3D(position: Vector3, text: string, options?: Text3DOptions): void;
75
+ /**
76
+ * Get text width for layout calculations.
77
+ * Note: This is an approximation based on character count and scale.
78
+ */
79
+ getTextWidth(text: string, _font: number, scale: number): number;
80
+ private ensureTickRunning;
81
+ private stopTick;
82
+ }
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.TextUIService = void 0;
10
+ const tsyringe_1 = require("tsyringe");
11
+ const DEFAULT_OPTIONS = {
12
+ font: 4,
13
+ scale: 0.35,
14
+ color: { r: 255, g: 255, b: 255, a: 255 },
15
+ alignment: 0,
16
+ dropShadow: true,
17
+ outline: false,
18
+ wrapWidth: 0,
19
+ };
20
+ const DEFAULT_3D_OPTIONS = Object.assign(Object.assign({}, DEFAULT_OPTIONS), { scale: 0.25, background: false, backgroundColor: { r: 0, g: 0, b: 0, a: 150 }, backgroundPadding: 0.002 });
21
+ /**
22
+ * Service for rendering text UI elements on screen and in 3D world.
23
+ */
24
+ let TextUIService = class TextUIService {
25
+ constructor() {
26
+ this.activeTextUI = null;
27
+ this.tickHandle = null;
28
+ }
29
+ /**
30
+ * Show persistent text UI at the bottom-right of the screen.
31
+ *
32
+ * @param text - The text to display
33
+ * @param options - Text options
34
+ */
35
+ show(text, options = {}) {
36
+ this.activeTextUI = {
37
+ text,
38
+ options: Object.assign(Object.assign({}, DEFAULT_OPTIONS), options),
39
+ };
40
+ this.ensureTickRunning();
41
+ }
42
+ /**
43
+ * Hide the persistent text UI.
44
+ */
45
+ hide() {
46
+ this.activeTextUI = null;
47
+ this.stopTick();
48
+ }
49
+ /**
50
+ * Check if text UI is currently visible.
51
+ */
52
+ isVisible() {
53
+ return this.activeTextUI !== null;
54
+ }
55
+ /**
56
+ * Draw text on screen for one frame.
57
+ * Call this every frame for persistent display.
58
+ *
59
+ * @param text - The text to draw
60
+ * @param x - Screen X position (0.0-1.0)
61
+ * @param y - Screen Y position (0.0-1.0)
62
+ * @param options - Text options
63
+ */
64
+ drawText(text, x, y, options = {}) {
65
+ const opts = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
66
+ SetTextFont(opts.font);
67
+ SetTextScale(opts.scale, opts.scale);
68
+ SetTextColour(opts.color.r, opts.color.g, opts.color.b, opts.color.a);
69
+ SetTextJustification(opts.alignment);
70
+ if (opts.dropShadow) {
71
+ SetTextDropshadow(0, 0, 0, 0, 255);
72
+ SetTextDropShadow();
73
+ }
74
+ if (opts.outline) {
75
+ SetTextOutline();
76
+ }
77
+ if (opts.wrapWidth > 0) {
78
+ SetTextWrap(x, x + opts.wrapWidth);
79
+ }
80
+ if (opts.alignment === 2) {
81
+ SetTextRightJustify(true);
82
+ SetTextWrap(0.0, x);
83
+ }
84
+ BeginTextCommandDisplayText('STRING');
85
+ AddTextComponentString(text);
86
+ EndTextCommandDisplayText(x, y);
87
+ }
88
+ /**
89
+ * Draw 3D text in the game world.
90
+ *
91
+ * @param position - World position
92
+ * @param text - The text to draw
93
+ * @param options - Text options
94
+ */
95
+ drawText3D(position, text, options = {}) {
96
+ const opts = Object.assign(Object.assign({}, DEFAULT_3D_OPTIONS), options);
97
+ const [onScreen, screenX, screenY] = World3dToScreen2d(position.x, position.y, position.z);
98
+ if (!onScreen)
99
+ return;
100
+ // Calculate distance-based scale
101
+ const camCoords = GetGameplayCamCoords();
102
+ const distance = GetDistanceBetweenCoords(camCoords[0], camCoords[1], camCoords[2], position.x, position.y, position.z, true);
103
+ const scale = opts.scale * (1 / distance) * 2;
104
+ const scaledScale = Math.max(scale, 0.15);
105
+ // Draw background if enabled
106
+ if (opts.background) {
107
+ const factor = text.length / 300;
108
+ DrawRect(screenX, screenY + opts.backgroundPadding, factor + opts.backgroundPadding * 2, 0.03 + opts.backgroundPadding * 2, opts.backgroundColor.r, opts.backgroundColor.g, opts.backgroundColor.b, opts.backgroundColor.a);
109
+ }
110
+ // Draw text
111
+ SetTextScale(scaledScale, scaledScale);
112
+ SetTextFont(opts.font);
113
+ SetTextColour(opts.color.r, opts.color.g, opts.color.b, opts.color.a);
114
+ SetTextCentre(true);
115
+ if (opts.dropShadow) {
116
+ SetTextDropshadow(0, 0, 0, 0, 255);
117
+ SetTextDropShadow();
118
+ }
119
+ if (opts.outline) {
120
+ SetTextOutline();
121
+ }
122
+ BeginTextCommandDisplayText('STRING');
123
+ AddTextComponentString(text);
124
+ EndTextCommandDisplayText(screenX, screenY);
125
+ }
126
+ /**
127
+ * Get text width for layout calculations.
128
+ * Note: This is an approximation based on character count and scale.
129
+ */
130
+ getTextWidth(text, _font, scale) {
131
+ // Approximate text width based on character count and scale
132
+ // Average character width at scale 1.0 is approximately 0.01
133
+ return text.length * 0.01 * scale;
134
+ }
135
+ ensureTickRunning() {
136
+ if (this.tickHandle !== null)
137
+ return;
138
+ this.tickHandle = setTick(() => {
139
+ if (!this.activeTextUI)
140
+ return;
141
+ const { text, options } = this.activeTextUI;
142
+ // Draw at bottom-right
143
+ this.drawText(text, 0.985, 0.93, Object.assign(Object.assign({}, options), { alignment: 2 }));
144
+ });
145
+ }
146
+ stopTick() {
147
+ if (this.tickHandle !== null) {
148
+ clearTick(this.tickHandle);
149
+ this.tickHandle = null;
150
+ }
151
+ }
152
+ };
153
+ exports.TextUIService = TextUIService;
154
+ exports.TextUIService = TextUIService = __decorate([
155
+ (0, tsyringe_1.injectable)()
156
+ ], TextUIService);