Skip to content

Commit

Permalink
fix : fix working module version 0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
nuzulul committed Jun 4, 2024
1 parent 7507966 commit 8a26716
Show file tree
Hide file tree
Showing 12 changed files with 44,381 additions and 61 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
WebpeerJS enables browser to browser connectivity without a central server.

[Demo](https://nuzulul.github.io/webpeerjs/demo/)

## Example

```
Expand All @@ -16,25 +18,32 @@ void async function main() {
const [send,listen,members] = node.joinRoom('myroom')
send('hello')
listen((message,id) => {
console.log(`Message from ${id} : ${message}`)
})
members((data) => {
console.log(`Members : ${data}`)
send('hello')
})
}()
```

## Install

NPM :

```
npm i webpeerjs
```

CDN :

```
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/webpeerjs.min.js"></script>
```

## API

- `createWebpeer()` Create a new local node.
Expand Down
3 changes: 1 addition & 2 deletions config/rollup.config.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ export default [
file: 'dist/esm/webpeerjs.js',
format: 'es',
}
],
plugins: [nodeResolve({browser: true}), commonjs()]
]
},
{
input: 'src/umd.js',
Expand Down
6 changes: 3 additions & 3 deletions config/tsconfig-esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"extends": "./tsconfig-base.json",
"compilerOptions": {
"module": "esnext",
"outDir": "./../src",
"outDir": "./../dist/esm",
"target": "esnext",
"emitDeclarationOnly": true,
"rootDir": "./../src"
"rootDir": "./../dist/esm"
},
"include": ["./../src/webpeerjs.js"],
"include": ["./../dist/esm/webpeerjs.js"],
"exclude": ["./../node_modules"],
}
44 changes: 44 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>WebpeerJS</title>
</head>
<body>
<div id="app"><ul id="myList"></ul></div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/webpeerjs.min.js"></script>
<script type="module">
void async function main() {

function write(input){
const node = document.createElement("li")
const textnode = document.createTextNode(input)
node.appendChild(textnode)
document.getElementById("myList").appendChild(node)
}

const node = await webpeerjs.createWebpeer()

write(`My node id : ${node.id}`)

const room = 'myroom'

write(`joinRoom : ${room}`)

const [send,listen,members] = node.joinRoom(room)

listen((message,id) => {
write(`Message from ${id} : ${message}`)
})

members((data) => {
write(`Members update : ${data}`)
send('hello')
})

}()
</script>
</body>
</html>
Loading

0 comments on commit 8a26716

Please sign in to comment.