Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: OmniacDev/MCBE-IPC
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.4.0
Choose a base ref
...
head repository: OmniacDev/MCBE-IPC
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
Showing with 1,517 additions and 258 deletions.
  1. +1 −1 LICENSE
  2. +1 −71 README.md
  3. +3 −3 package-lock.json
  4. +19 −4 package.json
  5. +475 −0 src/direct.ipc.ts
  6. +593 −179 src/ipc.ts
  7. +425 −0 src/proto.ts
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 OmniacDev
Copyright (c) 2025 OmniacDev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
72 changes: 1 addition & 71 deletions README.md
Original file line number Diff line number Diff line change
@@ -17,74 +17,4 @@ An IPC[^1] system for MCBE Script API projects

**TypeScript**
1. Download `ipc.ts` from the latest [release](https://github.com/OmniacDev/MCBE-IPC/releases/latest)
2. Copy file into your project

## Usage

### Sending & Receiving

`IPC.send()` and `IPC.on()` can be used to send messages or data between packs.

_Pack 1_
```js
import IPC from 'ipc.js'

IPC.on('message_channel', (args) => {
console.log(`Message: ${args}`)
})

IPC.on('data_channel', (args) => {
console.log(`Data: ${args.example_bool}, ${args.example_number}`)
})
```
_Pack 2_
```js
import IPC from 'ipc.js'

IPC.send('message_channel', 'Example Message')

IPC.send('data_channel', { example_number: 100, example_bool: true })
```
_Console Output_
```
Message: Example Message
Data: true, 100
```

### Requesting & Serving

`IPC.invoke()` and `IPC.handle()` can be used to request and serve data between packs.

_Pack 1_
```js
import IPC from 'ipc.js'

IPC.handle('request_channel', (args) => {
switch (args) {
case 'status':
return 'inactive'
case 'size':
return 100
}
})
```
_Pack 2_
```js
import IPC from 'ipc.js'

IPC.invoke('request_channel', 'status').then(result => {
console.log(`Status: ${result}`)
})

IPC.invoke('request_channel', 'size').then(result => {
console.log(`Size: ${result}`)
})
```
_Console Output_
```
Status: inactive
Size: 100
```



2. Copy file into your project
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 19 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
{
"name": "mcbe-ipc",
"author": "OmniacDev",
"description": "Experimental IPC system for MCBE Script API projects",
"license": "Apache-2.0",
"version": "1.0.0",
"description": "IPC system for MCBE Script API projects",
"license": "MIT",
"version": "3.0.4",
"repository": {
"type": "git",
"url": "git+https://github.com/OmniacDev/mcbe-ipc.git"
},
"bugs": {
"url": "https://github.com/OmniacDev/mcbe-ipc/issues"
},
"homepage": "https://github.com/OmniacDev/mcbe-ipc",
"type": "module",
"main": "dist/ipc.js",
"types": "dist/ipc.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsc",
"format": "prettier --write src"
"format": "prettier --write src",
"prepublishOnly": "npm run build"
},
"devDependencies": {
"prettier": "^3.3.3",
Loading