iosignal 3.3.0 → 4.5.0
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/.vscode/settings.json +3 -0
- package/README.md +38 -559
- package/dist/io.d.ts +16 -9
- package/dist/io.js +5 -5
- package/dist/io.js.map +1 -1
- package/dist/io.min.js +5 -5
- package/dist/io.min.js.map +1 -1
- package/dist/iosignal.js +339 -268
- package/dist/types/client/IOCore.d.ts +17 -10
- package/dist/types/common/constants.d.ts +27 -37
- package/index.js +4 -3
- package/package.json +3 -4
- package/src/auth/BohoAuth.js +48 -11
- package/src/auth/{Auth_File.js → key_providers/FileKeyProvider.js} +8 -20
- package/src/auth/{Auth_Redis.js → key_providers/RedisKeyProvider.js} +4 -7
- package/src/auth/key_providers/StringKeyProvider.js +54 -0
- package/src/client/IOCongSocket.js +5 -3
- package/src/client/IOCore.js +118 -89
- package/src/client/IOWS.js +5 -3
- package/src/client/browser/IOWebSocket.js +5 -3
- package/src/common/constants.js +31 -44
- package/src/common/util.js +3 -0
- package/src/server/Manager.js +13 -12
- package/src/server/Remote.js +4 -1
- package/src/server/RemoteCore.js +23 -17
- package/src/server/Server.js +7 -7
- package/README.ko.md +0 -566
- package/auth_file.js +0 -23
- package/auth_file.json +0 -13
- package/docs/iosignal_architecture.png +0 -0
- package/examples/react-chat-js/dist/assets/index-Cy4qaVcJ.js +0 -56
- package/examples/react-chat-js/dist/assets/index-NETrjYhz.css +0 -1
- package/examples/react-chat-js/dist/assets/index-e2KOTYW8.js +0 -65
- package/examples/react-chat-js/dist/index.html +0 -14
- package/examples/react-chat-js/index.html +0 -13
- package/examples/react-chat-js/package-lock.json +0 -1723
- package/examples/react-chat-js/package.json +0 -20
- package/examples/react-chat-js/src/App.css +0 -61
- package/examples/react-chat-js/src/App.jsx +0 -125
- package/examples/react-chat-js/src/index.css +0 -13
- package/examples/react-chat-js/src/main.jsx +0 -13
- package/examples/react-chat-js/src/shared_io.js +0 -12
- package/examples/react-chat-js/vite.config.js +0 -7
- package/examples/server/index.js +0 -65
- package/examples/server/package-lock.json +0 -878
- package/examples/server/package.json +0 -13
- package/examples/server/public/index.html +0 -26
- package/examples/svelte-chat-js/.devtools +0 -3
- package/examples/svelte-chat-js/README.md +0 -38
- package/examples/svelte-chat-js/package-lock.json +0 -1421
- package/examples/svelte-chat-js/package.json +0 -23
- package/examples/svelte-chat-js/src/app.css +0 -105
- package/examples/svelte-chat-js/src/app.d.ts +0 -13
- package/examples/svelte-chat-js/src/app.html +0 -13
- package/examples/svelte-chat-js/src/lib/images/github.svg +0 -1
- package/examples/svelte-chat-js/src/lib/images/svelte-logo.svg +0 -1
- package/examples/svelte-chat-js/src/lib/images/svelte-welcome.png +0 -0
- package/examples/svelte-chat-js/src/lib/images/svelte-welcome.webp +0 -0
- package/examples/svelte-chat-js/src/lib/shared_io.js +0 -12
- package/examples/svelte-chat-js/src/routes/+layout.svelte +0 -5
- package/examples/svelte-chat-js/src/routes/+page.js +0 -3
- package/examples/svelte-chat-js/src/routes/+page.svelte +0 -167
- package/examples/svelte-chat-js/static/favicon.svg +0 -1
- package/examples/svelte-chat-js/static/global.css +0 -19
- package/examples/svelte-chat-js/static/robots.txt +0 -3
- package/examples/svelte-chat-js/svelte.config.js +0 -23
- package/examples/svelte-chat-js/vite.config.js +0 -6
- package/src/auth/Auth_Env.js +0 -76
- package/test-browser/favicon.ico +0 -0
- package/test-browser/index.html +0 -95
- package/test-browser/server.js +0 -12
- package/test-nodejs/client-playToggle.js +0 -19
- package/test-nodejs/client.js +0 -17
- package/test-nodejs/client_api_reply.js +0 -15
- package/test-nodejs/server-Auth_Env.js +0 -19
- package/test-nodejs/server-Auth_File.js +0 -12
- package/test-nodejs/server-api_reply.js +0 -6
- package/test-nodejs/server-api_sudo.js +0 -7
- package/test-nodejs/server.js +0 -20
- package/test-nodejs/signalPack.js +0 -34
- package/test-nodejs/signaling.js +0 -61
- package/test-nodejs/simple-server.js +0 -13
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "svelte-chat-js",
|
|
3
|
-
"private": true,
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "vite dev",
|
|
8
|
-
"build": "vite build",
|
|
9
|
-
"preview": "vite preview",
|
|
10
|
-
"prepare": "svelte-kit sync || echo ''"
|
|
11
|
-
},
|
|
12
|
-
"devDependencies": {
|
|
13
|
-
"@sveltejs/adapter-auto": "^6.0.0",
|
|
14
|
-
"@sveltejs/kit": "^2.22.0",
|
|
15
|
-
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
|
16
|
-
"svelte": "^5.0.0",
|
|
17
|
-
"vite": "^7.0.4"
|
|
18
|
-
},
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"@sveltejs/adapter-static": "^3.0.10",
|
|
21
|
-
"iosignal": "file:../.."
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
@import '@fontsource/fira-mono';
|
|
2
|
-
|
|
3
|
-
:root {
|
|
4
|
-
--font-body:
|
|
5
|
-
Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
|
|
6
|
-
'Open Sans', 'Helvetica Neue', sans-serif;
|
|
7
|
-
--font-mono: 'Fira Mono', monospace;
|
|
8
|
-
--color-bg-0: rgb(202, 216, 228);
|
|
9
|
-
--color-bg-1: hsl(209, 36%, 86%);
|
|
10
|
-
--color-bg-2: hsl(224, 44%, 95%);
|
|
11
|
-
--color-theme-1: #ff3e00;
|
|
12
|
-
--color-theme-2: #4075a6;
|
|
13
|
-
--color-text: rgba(0, 0, 0, 0.7);
|
|
14
|
-
--column-width: 42rem;
|
|
15
|
-
--column-margin-top: 4rem;
|
|
16
|
-
font-family: var(--font-body);
|
|
17
|
-
color: var(--color-text);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
body {
|
|
21
|
-
min-height: 100vh;
|
|
22
|
-
margin: 0;
|
|
23
|
-
background-attachment: fixed;
|
|
24
|
-
background-color: var(--color-bg-1);
|
|
25
|
-
background-size: 100vw 100vh;
|
|
26
|
-
background-image:
|
|
27
|
-
radial-gradient(50% 50% at 50% 50%, rgba(255, 255, 255, 0.75) 0%, rgba(255, 255, 255, 0) 100%),
|
|
28
|
-
linear-gradient(180deg, var(--color-bg-0) 0%, var(--color-bg-1) 15%, var(--color-bg-2) 50%);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
h1,
|
|
32
|
-
h2,
|
|
33
|
-
p {
|
|
34
|
-
font-weight: 400;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
p {
|
|
38
|
-
line-height: 1.5;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
a {
|
|
42
|
-
color: var(--color-theme-1);
|
|
43
|
-
text-decoration: none;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
a:hover {
|
|
47
|
-
text-decoration: underline;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
h1 {
|
|
51
|
-
font-size: 2rem;
|
|
52
|
-
text-align: center;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
h2 {
|
|
56
|
-
font-size: 1rem;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
pre {
|
|
60
|
-
font-size: 16px;
|
|
61
|
-
font-family: var(--font-mono);
|
|
62
|
-
background-color: rgba(255, 255, 255, 0.45);
|
|
63
|
-
border-radius: 3px;
|
|
64
|
-
box-shadow: 2px 2px 6px rgb(255 255 255 / 25%);
|
|
65
|
-
padding: 0.5em;
|
|
66
|
-
overflow-x: auto;
|
|
67
|
-
color: var(--color-text);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.text-column {
|
|
71
|
-
display: flex;
|
|
72
|
-
max-width: 48rem;
|
|
73
|
-
flex: 0.6;
|
|
74
|
-
flex-direction: column;
|
|
75
|
-
justify-content: center;
|
|
76
|
-
margin: 0 auto;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
input,
|
|
80
|
-
button {
|
|
81
|
-
font-size: inherit;
|
|
82
|
-
font-family: inherit;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
button:focus:not(:focus-visible) {
|
|
86
|
-
outline: none;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@media (min-width: 720px) {
|
|
90
|
-
h1 {
|
|
91
|
-
font-size: 2.4rem;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.visually-hidden {
|
|
96
|
-
border: 0;
|
|
97
|
-
clip: rect(0 0 0 0);
|
|
98
|
-
height: auto;
|
|
99
|
-
margin: 0;
|
|
100
|
-
overflow: hidden;
|
|
101
|
-
padding: 0;
|
|
102
|
-
position: absolute;
|
|
103
|
-
width: 1px;
|
|
104
|
-
white-space: nowrap;
|
|
105
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// See https://svelte.dev/docs/kit/types#app.d.ts
|
|
2
|
-
// for information about these interfaces
|
|
3
|
-
declare global {
|
|
4
|
-
namespace App {
|
|
5
|
-
// interface Error {}
|
|
6
|
-
// interface Locals {}
|
|
7
|
-
// interface PageData {}
|
|
8
|
-
// interface PageState {}
|
|
9
|
-
// interface Platform {}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<link rel="icon" href="%sveltekit.assets%/favicon.svg" />
|
|
6
|
-
<link rel="stylesheet" href="%sveltekit.assets%/global.css" />
|
|
7
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
8
|
-
%sveltekit.head%
|
|
9
|
-
</head>
|
|
10
|
-
<body data-sveltekit-preload-data="hover">
|
|
11
|
-
<div style="display: contents">%sveltekit.body%</div>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg width="98" height="96" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z" fill="#24292f"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="107" height="128" viewBox="0 0 107 128"><title>svelte-logo</title><path d="M94.1566,22.8189c-10.4-14.8851-30.94-19.2971-45.7914-9.8348L22.2825,29.6078A29.9234,29.9234,0,0,0,8.7639,49.6506a31.5136,31.5136,0,0,0,3.1076,20.2318A30.0061,30.0061,0,0,0,7.3953,81.0653a31.8886,31.8886,0,0,0,5.4473,24.1157c10.4022,14.8865,30.9423,19.2966,45.7914,9.8348L84.7167,98.3921A29.9177,29.9177,0,0,0,98.2353,78.3493,31.5263,31.5263,0,0,0,95.13,58.117a30,30,0,0,0,4.4743-11.1824,31.88,31.88,0,0,0-5.4473-24.1157" style="fill:#ff3e00"/><path d="M45.8171,106.5815A20.7182,20.7182,0,0,1,23.58,98.3389a19.1739,19.1739,0,0,1-3.2766-14.5025,18.1886,18.1886,0,0,1,.6233-2.4357l.4912-1.4978,1.3363.9815a33.6443,33.6443,0,0,0,10.203,5.0978l.9694.2941-.0893.9675a5.8474,5.8474,0,0,0,1.052,3.8781,6.2389,6.2389,0,0,0,6.6952,2.485,5.7449,5.7449,0,0,0,1.6021-.7041L69.27,76.281a5.4306,5.4306,0,0,0,2.4506-3.631,5.7948,5.7948,0,0,0-.9875-4.3712,6.2436,6.2436,0,0,0-6.6978-2.4864,5.7427,5.7427,0,0,0-1.6.7036l-9.9532,6.3449a19.0329,19.0329,0,0,1-5.2965,2.3259,20.7181,20.7181,0,0,1-22.2368-8.2427,19.1725,19.1725,0,0,1-3.2766-14.5024,17.9885,17.9885,0,0,1,8.13-12.0513L55.8833,23.7472a19.0038,19.0038,0,0,1,5.3-2.3287A20.7182,20.7182,0,0,1,83.42,29.6611a19.1739,19.1739,0,0,1,3.2766,14.5025,18.4,18.4,0,0,1-.6233,2.4357l-.4912,1.4978-1.3356-.98a33.6175,33.6175,0,0,0-10.2037-5.1l-.9694-.2942.0893-.9675a5.8588,5.8588,0,0,0-1.052-3.878,6.2389,6.2389,0,0,0-6.6952-2.485,5.7449,5.7449,0,0,0-1.6021.7041L37.73,51.719a5.4218,5.4218,0,0,0-2.4487,3.63,5.7862,5.7862,0,0,0,.9856,4.3717,6.2437,6.2437,0,0,0,6.6978,2.4864,5.7652,5.7652,0,0,0,1.602-.7041l9.9519-6.3425a18.978,18.978,0,0,1,5.2959-2.3278,20.7181,20.7181,0,0,1,22.2368,8.2427,19.1725,19.1725,0,0,1,3.2766,14.5024,17.9977,17.9977,0,0,1-8.13,12.0532L51.1167,104.2528a19.0038,19.0038,0,0,1-5.3,2.3287" style="fill:#fff"/></svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { dev, browser } from "$app/environment";
|
|
3
|
-
import IO from "iosignal/io.js";
|
|
4
|
-
|
|
5
|
-
// const url = 'ws://192.168.0.15:7777';
|
|
6
|
-
const url = "ws://localhost:7777";
|
|
7
|
-
const channel_tag = "channel#topic";
|
|
8
|
-
|
|
9
|
-
let messages = $state([]);
|
|
10
|
-
let input = $state("Hello, World!");
|
|
11
|
-
let ioState = $state(null);
|
|
12
|
-
let cid = $state(null);
|
|
13
|
-
let counts = $state({ instances: 0, websockets: 0 });
|
|
14
|
-
let io = null;
|
|
15
|
-
let messagesEnd;
|
|
16
|
-
|
|
17
|
-
const scrollToBottom = () => {
|
|
18
|
-
messagesEnd?.scrollIntoView({ behavior: "smooth" });
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
if (browser) {
|
|
22
|
-
let wsURL = new URL( document.URL )
|
|
23
|
-
wsURL.protocol = 'ws'
|
|
24
|
-
console.log( 'ws url:', wsURL.href)
|
|
25
|
-
|
|
26
|
-
// io = new IO(wsURL.href);
|
|
27
|
-
io = new IO(url);
|
|
28
|
-
if (dev)
|
|
29
|
-
console.log("new io:", IO.version, IO.instanceCount, IO.webSocketCount);
|
|
30
|
-
|
|
31
|
-
counts = { instances: IO.instanceCount, websockets: IO.webSocketCount };
|
|
32
|
-
|
|
33
|
-
const handleReady = () => {
|
|
34
|
-
console.log("ready cid:", io.cid);
|
|
35
|
-
cid = io.cid;
|
|
36
|
-
io.subscribe(channel_tag);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const handleChange = (state) => {
|
|
40
|
-
ioState = state;
|
|
41
|
-
counts = { instances: IO.instanceCount, websockets: IO.webSocketCount };
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const handleChannelMessage = (msgObj, tag) => {
|
|
45
|
-
console.log("Received message in App:", msgObj, tag);
|
|
46
|
-
messages = [...messages, `${msgObj.cid} : ${msgObj.text}`];
|
|
47
|
-
scrollToBottom();
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const handleError = (error) => {
|
|
51
|
-
console.error("IO Error in App:", error);
|
|
52
|
-
ioState = `Error: ${error.message}`;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
io.on("ready", handleReady);
|
|
56
|
-
io.on("change", handleChange);
|
|
57
|
-
io.on(channel_tag, handleChannelMessage);
|
|
58
|
-
io.on("error", handleError);
|
|
59
|
-
|
|
60
|
-
$effect(() => {
|
|
61
|
-
return () => {
|
|
62
|
-
io.destroy();
|
|
63
|
-
io = null;
|
|
64
|
-
};
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const sendMessage = () => {
|
|
69
|
-
if (input.trim()) {
|
|
70
|
-
// console.log('Sending message:', input);
|
|
71
|
-
const msgObj = { text: input, cid: io.cid };
|
|
72
|
-
// console.log('Sending message object:', msgObj);
|
|
73
|
-
io.signal(channel_tag, msgObj);
|
|
74
|
-
input = "date" + Date.now();
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
let ioStateStyle = $derived(
|
|
79
|
-
`color: ${ioState === "ready" ? "green" : "red"}; font-weight: bold;`,
|
|
80
|
-
);
|
|
81
|
-
</script>
|
|
82
|
-
|
|
83
|
-
<div class="App">
|
|
84
|
-
<h1>Svelte 5 Chat Example</h1>
|
|
85
|
-
<div>URL: {url}</div>
|
|
86
|
-
<div>Channel: {channel_tag}</div>
|
|
87
|
-
<div>IO State: <span style={ioStateStyle}>{ioState}</span></div>
|
|
88
|
-
<div>Client ID: {cid}</div>
|
|
89
|
-
<div>IO Instances: {counts.instances}</div>
|
|
90
|
-
<div>WebSockets Created: {counts.websockets}</div>
|
|
91
|
-
<div class="messages">
|
|
92
|
-
{#each messages as msg, index (index)}
|
|
93
|
-
<div>{msg}</div>
|
|
94
|
-
{/each}
|
|
95
|
-
<div bind:this={messagesEnd}></div>
|
|
96
|
-
</div>
|
|
97
|
-
<div class="input-area">
|
|
98
|
-
<input
|
|
99
|
-
type="text"
|
|
100
|
-
bind:value={input}
|
|
101
|
-
onkeyup={(e) => e.key === "Enter" && sendMessage()}
|
|
102
|
-
disabled={ioState !== "ready"}
|
|
103
|
-
/>
|
|
104
|
-
<button onclick={sendMessage} disabled={ioState !== "ready"}> Send </button>
|
|
105
|
-
</div>
|
|
106
|
-
</div>
|
|
107
|
-
|
|
108
|
-
<style>
|
|
109
|
-
.App {
|
|
110
|
-
height: 100%;
|
|
111
|
-
margin: 0;
|
|
112
|
-
display: flex;
|
|
113
|
-
flex-direction: column;
|
|
114
|
-
padding: 20px;
|
|
115
|
-
box-sizing: border-box;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
h1 {
|
|
119
|
-
margin-top: 0;
|
|
120
|
-
color: #333;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.messages {
|
|
124
|
-
flex-grow: 1;
|
|
125
|
-
border: 1px solid #ccc;
|
|
126
|
-
padding: 10px;
|
|
127
|
-
overflow-y: auto;
|
|
128
|
-
margin-bottom: 10px;
|
|
129
|
-
display: flex;
|
|
130
|
-
flex-direction: column;
|
|
131
|
-
justify-content: flex-end;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.messages div {
|
|
135
|
-
background-color: #f0f0f0;
|
|
136
|
-
padding: 8px;
|
|
137
|
-
margin-bottom: 5px;
|
|
138
|
-
border-radius: 5px;
|
|
139
|
-
text-align: left;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.input-area {
|
|
143
|
-
display: flex;
|
|
144
|
-
gap: 10px;
|
|
145
|
-
margin-top: auto;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.input-area input {
|
|
149
|
-
flex-grow: 1;
|
|
150
|
-
padding: 10px;
|
|
151
|
-
border: 1px solid #ccc;
|
|
152
|
-
border-radius: 5px;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.input-area button {
|
|
156
|
-
padding: 10px 15px;
|
|
157
|
-
background-color: #007bff;
|
|
158
|
-
color: white;
|
|
159
|
-
border: none;
|
|
160
|
-
border-radius: 5px;
|
|
161
|
-
cursor: pointer;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.input-area button:hover {
|
|
165
|
-
background-color: #0056b3;
|
|
166
|
-
}
|
|
167
|
-
</style>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="107" height="128" viewBox="0 0 107 128"><title>svelte-logo</title><path d="M94.157 22.819c-10.4-14.885-30.94-19.297-45.792-9.835L22.282 29.608A29.92 29.92 0 0 0 8.764 49.65a31.5 31.5 0 0 0 3.108 20.231 30 30 0 0 0-4.477 11.183 31.9 31.9 0 0 0 5.448 24.116c10.402 14.887 30.942 19.297 45.791 9.835l26.083-16.624A29.92 29.92 0 0 0 98.235 78.35a31.53 31.53 0 0 0-3.105-20.232 30 30 0 0 0 4.474-11.182 31.88 31.88 0 0 0-5.447-24.116" style="fill:#ff3e00"/><path d="M45.817 106.582a20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.503 18 18 0 0 1 .624-2.435l.49-1.498 1.337.981a33.6 33.6 0 0 0 10.203 5.098l.97.294-.09.968a5.85 5.85 0 0 0 1.052 3.878 6.24 6.24 0 0 0 6.695 2.485 5.8 5.8 0 0 0 1.603-.704L69.27 76.28a5.43 5.43 0 0 0 2.45-3.631 5.8 5.8 0 0 0-.987-4.371 6.24 6.24 0 0 0-6.698-2.487 5.7 5.7 0 0 0-1.6.704l-9.953 6.345a19 19 0 0 1-5.296 2.326 20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.502 17.99 17.99 0 0 1 8.13-12.052l26.081-16.623a19 19 0 0 1 5.3-2.329 20.72 20.72 0 0 1 22.237 8.243 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-.624 2.435l-.49 1.498-1.337-.98a33.6 33.6 0 0 0-10.203-5.1l-.97-.294.09-.968a5.86 5.86 0 0 0-1.052-3.878 6.24 6.24 0 0 0-6.696-2.485 5.8 5.8 0 0 0-1.602.704L37.73 51.72a5.42 5.42 0 0 0-2.449 3.63 5.79 5.79 0 0 0 .986 4.372 6.24 6.24 0 0 0 6.698 2.486 5.8 5.8 0 0 0 1.602-.704l9.952-6.342a19 19 0 0 1 5.295-2.328 20.72 20.72 0 0 1 22.237 8.242 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-8.13 12.053l-26.081 16.622a19 19 0 0 1-5.3 2.328" style="fill:#fff"/></svg>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
html, body, #root, .App {
|
|
2
|
-
height: 100%;
|
|
3
|
-
margin: 0;
|
|
4
|
-
display: flex;
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
body {
|
|
9
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
10
|
-
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
11
|
-
sans-serif;
|
|
12
|
-
-webkit-font-smoothing: antialiased;
|
|
13
|
-
-moz-osx-font-smoothing: grayscale;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
code {
|
|
17
|
-
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
|
18
|
-
monospace;
|
|
19
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import adapter from '@sveltejs/adapter-static';
|
|
2
|
-
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
3
|
-
|
|
4
|
-
/** @type {import('@sveltejs/kit').Config} */
|
|
5
|
-
const config = {
|
|
6
|
-
compilerOptions: {
|
|
7
|
-
runes: true
|
|
8
|
-
},
|
|
9
|
-
kit: {
|
|
10
|
-
adapter: adapter({
|
|
11
|
-
// default options are shown. On some platforms
|
|
12
|
-
// these options are set automatically — see below
|
|
13
|
-
pages: 'build',
|
|
14
|
-
assets: 'build',
|
|
15
|
-
// fallback: 'index.html',
|
|
16
|
-
precompress: false,
|
|
17
|
-
strict: true
|
|
18
|
-
})
|
|
19
|
-
},
|
|
20
|
-
preprocess: vitePreprocess()
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default config;
|
package/src/auth/Auth_Env.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auth_Env.js
|
|
3
|
-
*
|
|
4
|
-
* You can use environment variable BOHO_AUTH.
|
|
5
|
-
*
|
|
6
|
-
* BOHO_AUTH=id1.key1.level,id2:key2.level
|
|
7
|
-
*
|
|
8
|
-
* or constructor parameter.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* [ authInfo ]
|
|
12
|
-
* id: <String> max 8chars
|
|
13
|
-
* key: <String>
|
|
14
|
-
* level: <Numbrer> range: 0~255
|
|
15
|
-
* separator: ','
|
|
16
|
-
*
|
|
17
|
-
* example => process.env.BOHO_AUTH=id1.key1.255,id2.key2.200
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { BohoAuth } from './BohoAuth.js';
|
|
21
|
-
import Boho from 'boho'
|
|
22
|
-
|
|
23
|
-
export class Auth_Env extends BohoAuth {
|
|
24
|
-
constructor(authInfo) {
|
|
25
|
-
super()
|
|
26
|
-
let id_keys;
|
|
27
|
-
if (authInfo) {
|
|
28
|
-
id_keys = authInfo.split(',')
|
|
29
|
-
} else if (process.env.BOHO_AUTH) {
|
|
30
|
-
authInfo = process.env.BOHO_AUTH
|
|
31
|
-
id_keys = process.env.BOHO_AUTH.split(',')
|
|
32
|
-
} else {
|
|
33
|
-
console.log("Auth_Env: None of process.env.BOHO_AUTH or authInfo")
|
|
34
|
-
process.exit()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
this.AUTH = new Map();
|
|
38
|
-
|
|
39
|
-
if (id_keys.length >= 1) {
|
|
40
|
-
id_keys.forEach(v => {
|
|
41
|
-
|
|
42
|
-
let did = v.split('.')[0]
|
|
43
|
-
let key = v.split('.')[1]
|
|
44
|
-
let level = v.split('.')[2]
|
|
45
|
-
level = parseInt(level)
|
|
46
|
-
|
|
47
|
-
if (did && key && typeof level == 'number') {
|
|
48
|
-
let cid = did;
|
|
49
|
-
this.addAuth(did, key, cid, level)
|
|
50
|
-
} else {
|
|
51
|
-
console.log("Wrong process.env.BOHO_AUTH authentication value.", id, key, level)
|
|
52
|
-
process.exit();
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
} else {
|
|
57
|
-
console.log("Wrong process.env.BOHO_AUTH authentication value.")
|
|
58
|
-
process.exit();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async getAuth(id) {
|
|
64
|
-
return this.AUTH.get(id)
|
|
65
|
-
}
|
|
66
|
-
async getAuthIdList() {
|
|
67
|
-
return Array.from(this.AUTH.keys())
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
addAuth(id, keyStr, cid, level = 0) {
|
|
71
|
-
let Base64hashKey = Buffer.from(Boho.sha256.hash(keyStr)).toString('base64')
|
|
72
|
-
this.AUTH.set(id, { key: Base64hashKey, cid: cid, level: level })
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
package/test-browser/favicon.ico
DELETED
|
Binary file
|
package/test-browser/index.html
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8">
|
|
6
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
8
|
-
<title>Document</title>
|
|
9
|
-
<style>
|
|
10
|
-
#messageView {
|
|
11
|
-
border: 1px solid red;
|
|
12
|
-
padding: 2em;
|
|
13
|
-
}
|
|
14
|
-
</style>
|
|
15
|
-
</head>
|
|
16
|
-
|
|
17
|
-
<body>
|
|
18
|
-
<h2>Simple pub sub example.</h2>
|
|
19
|
-
<p>you should start server first.</p>
|
|
20
|
-
<p>this index.html load two types of modules. </p>
|
|
21
|
-
<h5>1. UMD(IIFE): io.min.js</h5>
|
|
22
|
-
<p>use global name: IO </p>
|
|
23
|
-
<p>IO has props: Boho, MBP, Buffer,, </p>
|
|
24
|
-
<h5>2. ESM: io.js</h5>
|
|
25
|
-
<p> check the console.</p>
|
|
26
|
-
<h2>message log</h2>
|
|
27
|
-
<div id="messageView">...</div>
|
|
28
|
-
<script src="../dist/io.min.js"></script>
|
|
29
|
-
<script>
|
|
30
|
-
console.log('IO.version: ', IO.version)
|
|
31
|
-
console.log('MBP', IO.MBP)
|
|
32
|
-
console.log('Buffer', IO.Buffer)
|
|
33
|
-
console.log('Boho', IO.Boho)
|
|
34
|
-
console.log('sha256.hash("hi")', IO.Boho.sha256.hash('hi'))
|
|
35
|
-
|
|
36
|
-
var ESM_IO;
|
|
37
|
-
IO.binaryType = "blob"
|
|
38
|
-
var io1 = new IO('ws://localhost:7777')
|
|
39
|
-
var io2 = new IO('ws://localhost:7777')
|
|
40
|
-
var io3 = new IO('ws://localhost:7777')
|
|
41
|
-
|
|
42
|
-
io1.on('error', errorHandler)
|
|
43
|
-
io2.on('error', errorHandler)
|
|
44
|
-
io3.on('error', errorHandler)
|
|
45
|
-
|
|
46
|
-
let channelName = 'io'
|
|
47
|
-
// classic style subsribing
|
|
48
|
-
io1.on('ready', e => {
|
|
49
|
-
io1.subscribe(channelName)
|
|
50
|
-
io1.on(channelName, (...args) => {
|
|
51
|
-
// console.log('io1 received', args )
|
|
52
|
-
let msg = '[io1] ' + JSON.stringify(args)
|
|
53
|
-
addMessage(msg)
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
// modern style subscribing
|
|
58
|
-
io2.listen(channelName, (...args) => {
|
|
59
|
-
// console.log('io2 receive', args )
|
|
60
|
-
let msg = '[io2] ' + JSON.stringify(args)
|
|
61
|
-
addMessage(msg)
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
setInterval(e => {
|
|
65
|
-
io3.signal(channelName, 'single string') // single string payload
|
|
66
|
-
io3.signal(channelName, Date.now(), 'a', 2, { key: 3 }) //multiple payload
|
|
67
|
-
io3.signal(channelName) // pure signal without payload.
|
|
68
|
-
}, 3000)
|
|
69
|
-
|
|
70
|
-
function addMessage(msg) {
|
|
71
|
-
|
|
72
|
-
let p = document.createElement('p')
|
|
73
|
-
p.textContent = msg
|
|
74
|
-
let v = document.querySelector('#messageView')
|
|
75
|
-
if (v.childElementCount > 20) v.innerHTML = ""
|
|
76
|
-
v.prepend(p)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function errorHandler(e) {
|
|
80
|
-
console.log(e.target)
|
|
81
|
-
addMessage('ws.error')
|
|
82
|
-
}
|
|
83
|
-
</script>
|
|
84
|
-
<script type="module">
|
|
85
|
-
import IO from "../dist/io.js"
|
|
86
|
-
ESM_IO = IO
|
|
87
|
-
console.log('ESM IO.version: ', IO.version)
|
|
88
|
-
console.log('Boho', IO.Boho )
|
|
89
|
-
console.log('MBP', IO.MBP )
|
|
90
|
-
console.log('Buffer', IO.Buffer)
|
|
91
|
-
console.log('sha256.hash("hi")', IO.Boho.sha256.hash('hi'))
|
|
92
|
-
</script>
|
|
93
|
-
</body>
|
|
94
|
-
|
|
95
|
-
</html>
|
package/test-browser/server.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { IO } from "iosignal"
|
|
3
|
-
|
|
4
|
-
const io = new IO('wss://io.iosignal.net/ws')
|
|
5
|
-
|
|
6
|
-
// io.auth('id','key')
|
|
7
|
-
|
|
8
|
-
io.on('ready', () => {
|
|
9
|
-
console.log('ready cid:', io.cid)
|
|
10
|
-
io.signal('#screen', 'playToggle')
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
io.listen('#notify', (...args) => {
|
|
14
|
-
console.log(args)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
io.on('error', err => {
|
|
18
|
-
console.log('err', err)
|
|
19
|
-
})
|
package/test-nodejs/client.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { IO } from "iosignal"
|
|
3
|
-
|
|
4
|
-
const io = new IO('ws://localhost:7777')
|
|
5
|
-
|
|
6
|
-
io.on('ready', () => {
|
|
7
|
-
console.log('ready cid:', io.cid)
|
|
8
|
-
io.signal('#screen', 'playToggle')
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
io.listen('#notify', (...args) => {
|
|
12
|
-
console.log(args)
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
io.on('error', err => {
|
|
16
|
-
console.log('err', err)
|
|
17
|
-
})
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { IO } from "iosignal"
|
|
3
|
-
|
|
4
|
-
const io = new IO('ws://localhost:7777')
|
|
5
|
-
|
|
6
|
-
io.on('ready', async () => {
|
|
7
|
-
let res_echo = await io.req('reply', 'echo', 'hello')
|
|
8
|
-
let res_date = await io.req('reply', 'date')
|
|
9
|
-
let res_unixtime = await io.req('reply', 'unixtime')
|
|
10
|
-
|
|
11
|
-
if (res_echo.ok) console.log(res_echo.body)
|
|
12
|
-
if (res_date.ok) console.log(res_date.body)
|
|
13
|
-
if (res_unixtime.ok) console.log(res_unixtime.body)
|
|
14
|
-
|
|
15
|
-
});
|