@cybermp-community/browser-types 1.0.6 โ 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.
- package/README.md +33 -16
- package/package.json +2 -1
- package/src/index.ts +1 -1
- package/src/mp.d.ts +1 -1
package/README.md
CHANGED
|
@@ -1,33 +1,50 @@
|
|
|
1
1
|
# CyberMP Browser Types
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@cybermp-community/browser-types` types the global `mp` of the CEF page. The page exchanges events with the client script.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
18
|
+
## Usage
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
30
|
+
`browser/main.ts` runs in the page the client opened with `mp.cef.setUrl`:
|
|
22
31
|
|
|
23
|
-
```
|
|
24
|
-
|
|
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
|
-
|
|
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
|
|
46
|
+
This repository is developed by [CyberMP Community Developers](https://gitlab.com/cybermp) and is separate from CyberMP (cyber.mp).
|
|
30
47
|
|
|
31
|
-
##
|
|
48
|
+
## License
|
|
32
49
|
|
|
33
|
-
|
|
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.
|
|
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": {
|
|
@@ -49,3 +49,4 @@
|
|
|
49
49
|
"@biomejs/biome": "^2.0.0"
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
+
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './mp';
|
package/src/mp.d.ts
CHANGED