@cybermp-community/browser-types 1.0.7 โ†’ 1.0.8

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 (2) hide show
  1. package/README.md +33 -16
  2. package/package.json +3 -2
package/README.md CHANGED
@@ -1,33 +1,50 @@
1
1
  # CyberMP Browser Types
2
2
 
3
- This repository contains the TypeScript type definitions for the **[CyberMP](https://cyber.mp) user interface (CEF)** environment, providing comprehensive type safety for creating the game's UI in a browser context.
3
+ `@cybermp-community/browser-types` types the global `mp` of the CEF page. The page exchanges events with the client script.
4
4
 
5
- These types allow for robust communication between the UI and the client, as well as access to any browser-side APIs provided by the CyberMP mod.
6
-
7
- ## ๐Ÿ“ฆ Installation
8
-
9
- Using NPM:
5
+ ## Installation
10
6
 
11
7
  ```bash
8
+ # npm
12
9
  npm install -D @cybermp-community/browser-types
10
+
11
+ # pnpm
12
+ pnpm add -D @cybermp-community/browser-types
13
+
14
+ # bun
15
+ bun add -d @cybermp-community/browser-types
13
16
  ```
14
17
 
15
- Using PNPM:
18
+ ## Usage
16
19
 
17
- ```bash
18
- pnpm install -D @cybermp-community/browser-types
20
+ `browser/global.d.ts`:
21
+
22
+ ```ts
23
+ import type { MpBrowser } from "@cybermp-community/browser-types";
24
+
25
+ declare global {
26
+ const mp: MpBrowser;
27
+ }
19
28
  ```
20
29
 
21
- Using Bun:
30
+ `browser/main.ts` runs in the page the client opened with `mp.cef.setUrl`:
22
31
 
23
- ```bash
24
- bun add -d @cybermp-community/browser-types
32
+ ```ts
33
+ mp.events.emit("ui:ready");
34
+
35
+ mp.events.on("ui:close", () => {
36
+ mp.events.emit("ui:closed");
37
+ });
25
38
  ```
26
39
 
27
- ## ๐Ÿ“œ Disclaimer
40
+ `mp.events.emit` arrives on the client as `mp.events.onCef`. `mp.events.on` receives events the client sent with `mp.events.emitCef`.
41
+
42
+ Put `global.d.ts` next to the page scripts so `include` in `tsconfig.json` picks it up.
43
+
44
+ ## Disclaimer
28
45
 
29
- This repository is developed by [CyberMP Community Developers](https://gitlab.com/cybermp) and is not directly related to CyberMP (cyber.mp).
46
+ This repository is developed by [CyberMP Community Developers](https://gitlab.com/cybermp) and is separate from CyberMP (cyber.mp).
30
47
 
31
- ## โš–๏ธ License
48
+ ## License
32
49
 
33
- This project is licensed under the ะกะก BY-SA 4.0 License - see the [LICENSE](LICENSE) file for details.
50
+ CC BY-SA 4.0. See the [LICENSE](LICENSE) file for details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cybermp-community/browser-types",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "TypeScript type definitions for the CyberMP browser environment (CEF).",
5
5
  "license": "CC BY-SA 4.0",
6
6
  "author": {
@@ -12,7 +12,7 @@
12
12
  ],
13
13
  "repository": {
14
14
  "type": "gitlab",
15
- "url": "git+https://gitlab.com/cybermp/types/browser.git"
15
+ "url": "https://gitlab.com/cybermp/types/browser"
16
16
  },
17
17
  "publishConfig": {
18
18
  "access": "public"
@@ -49,3 +49,4 @@
49
49
  "@biomejs/biome": "^2.0.0"
50
50
  }
51
51
  }
52
+