Compare commits
5 Commits
a96d7e28c8
...
bobbyd-den
| Author | SHA1 | Date | |
|---|---|---|---|
| ed9dfb990f | |||
| 83debdace8 | |||
| 2a71830258 | |||
| 234c45059f | |||
| d0fd041f7e |
@@ -293,7 +293,7 @@ function connectWebsocket(request: Request) {
|
||||
}
|
||||
|
||||
async function devServerWatchFiles() {
|
||||
const watcher = Deno.watchFs("../static/");
|
||||
const watcher = Deno.watchFs(["../static/", "../src/"]);
|
||||
for await (const event of watcher) {
|
||||
if (event.kind === "modify") {
|
||||
for (const path of event.paths) {
|
||||
@@ -320,6 +320,10 @@ function handler(request: Request, info: any): Promise<Response> | Response {
|
||||
return new Response("Not serving video", { status: 404 });
|
||||
}
|
||||
|
||||
if (url.pathname.includes("/src")) {
|
||||
return serveFile(url.pathname);
|
||||
}
|
||||
|
||||
if (url.pathname === "/") {
|
||||
return serveFile("/static/index.html")
|
||||
}
|
||||
|
||||
2
deno_bootstrap/compile.sh
Executable file
2
deno_bootstrap/compile.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
deno compile --allow-scripts --allow-all --no-check ddln_bootstrap.ts
|
||||
BIN
deno_bootstrap/ddln_bootstrap
Executable file
BIN
deno_bootstrap/ddln_bootstrap
Executable file
Binary file not shown.
58
deno_bootstrap/ddln_bootstrap.ts
Normal file
58
deno_bootstrap/ddln_bootstrap.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { PeerManager } from "../src/PeerManager.ts";
|
||||
import { generateID } from "IDUtils";
|
||||
import nodeDataChannel from 'npm:node-datachannel';
|
||||
import nodeDatachannelPolyfill from 'npm:node-datachannel/polyfill';
|
||||
|
||||
nodeDataChannel.initLogger('Info');
|
||||
|
||||
// import {RTCPeerConnection} from 'npm:node-datachannel/polyfill';
|
||||
|
||||
// deno install --allow-scripts=npm:node-datachannel --entrypoint ddln_bootstrap.ts
|
||||
// constructor(userID: string, peerID: string, isBootstrapPeer: boolean) {
|
||||
|
||||
declare type ID = string;
|
||||
|
||||
interface Config {
|
||||
userID:ID
|
||||
peerID:ID
|
||||
}
|
||||
|
||||
let configJSON;
|
||||
let config:Config;
|
||||
let configFilename = 'ddln_bootstrap_config.json';
|
||||
try {
|
||||
configJSON = Deno.readTextFileSync(configFilename);
|
||||
config = JSON.parse(configJSON) as Config;
|
||||
console.log("Loaded config file: ", config);
|
||||
} catch (e) {
|
||||
console.log("Config file not found, creating...");
|
||||
const initialConfig = {
|
||||
userID: generateID(),
|
||||
peerID: generateID()
|
||||
};
|
||||
|
||||
console.log(initialConfig);
|
||||
|
||||
Deno.writeTextFileSync(configFilename, JSON.stringify(initialConfig));
|
||||
|
||||
config = initialConfig;
|
||||
}
|
||||
|
||||
// Polyfill RTCPeerConnection and friends
|
||||
const global = (globalThis as any);
|
||||
for (const [functionName, func] of Object.entries(nodeDatachannelPolyfill)) {
|
||||
global[functionName] = func;
|
||||
}
|
||||
|
||||
console.log("ddln bootstrap peer starting...");
|
||||
|
||||
// console.log(nodeDatachannelPolyfill);
|
||||
|
||||
const isBootstrapPeer = true;
|
||||
const peerManager = new PeerManager(config.userID, config.peerID, isBootstrapPeer);
|
||||
|
||||
peerManager.registerRPC('announceUsers', (sendingPeerID: string, userIDs: string[]) => {
|
||||
console.log(`Got announceUsers from ${sendingPeerID} ${userIDs}`);
|
||||
});
|
||||
|
||||
peerManager.connect();
|
||||
11
deno_bootstrap/deno.json
Normal file
11
deno_bootstrap/deno.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"imports": {
|
||||
"log": "../src/log.ts",
|
||||
"IDUtils": "../src/IDUtils.ts",
|
||||
"App": "../src/App.ts"
|
||||
},
|
||||
"nodeModulesDir": "auto",
|
||||
"lock": {
|
||||
"frozen": true
|
||||
}
|
||||
}
|
||||
207
deno_bootstrap/deno.lock
generated
Normal file
207
deno_bootstrap/deno.lock
generated
Normal file
@@ -0,0 +1,207 @@
|
||||
{
|
||||
"version": "5",
|
||||
"specifiers": {
|
||||
"npm:@types/node@*": "22.15.15",
|
||||
"npm:node-datachannel@*": "0.26.0"
|
||||
},
|
||||
"npm": {
|
||||
"@types/node@22.15.15": {
|
||||
"integrity": "sha512-R5muMcZob3/Jjchn5LcO8jdKwSCbzqmPB6ruBxMcf9kbxtniZHP327s6C37iOfuw8mbKK3cAQa7sEl7afLrQ8A==",
|
||||
"dependencies": [
|
||||
"undici-types"
|
||||
]
|
||||
},
|
||||
"base64-js@1.5.1": {
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
|
||||
},
|
||||
"bl@4.1.0": {
|
||||
"integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==",
|
||||
"dependencies": [
|
||||
"buffer",
|
||||
"inherits",
|
||||
"readable-stream"
|
||||
]
|
||||
},
|
||||
"buffer@5.7.1": {
|
||||
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
|
||||
"dependencies": [
|
||||
"base64-js",
|
||||
"ieee754"
|
||||
]
|
||||
},
|
||||
"chownr@1.1.4": {
|
||||
"integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg=="
|
||||
},
|
||||
"decompress-response@6.0.0": {
|
||||
"integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==",
|
||||
"dependencies": [
|
||||
"mimic-response"
|
||||
]
|
||||
},
|
||||
"deep-extend@0.6.0": {
|
||||
"integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA=="
|
||||
},
|
||||
"detect-libc@2.0.4": {
|
||||
"integrity": "sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA=="
|
||||
},
|
||||
"end-of-stream@1.4.4": {
|
||||
"integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
|
||||
"dependencies": [
|
||||
"once"
|
||||
]
|
||||
},
|
||||
"expand-template@2.0.3": {
|
||||
"integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg=="
|
||||
},
|
||||
"fs-constants@1.0.0": {
|
||||
"integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow=="
|
||||
},
|
||||
"github-from-package@0.0.0": {
|
||||
"integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw=="
|
||||
},
|
||||
"ieee754@1.2.1": {
|
||||
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="
|
||||
},
|
||||
"inherits@2.0.4": {
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||
},
|
||||
"ini@1.3.8": {
|
||||
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="
|
||||
},
|
||||
"mimic-response@3.1.0": {
|
||||
"integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ=="
|
||||
},
|
||||
"minimist@1.2.8": {
|
||||
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="
|
||||
},
|
||||
"mkdirp-classic@0.5.3": {
|
||||
"integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A=="
|
||||
},
|
||||
"napi-build-utils@2.0.0": {
|
||||
"integrity": "sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA=="
|
||||
},
|
||||
"node-abi@3.74.0": {
|
||||
"integrity": "sha512-c5XK0MjkGBrQPGYG24GBADZud0NCbznxNx0ZkS+ebUTrmV1qTDxPxSL8zEAPURXSbLRWVexxmP4986BziahL5w==",
|
||||
"dependencies": [
|
||||
"semver"
|
||||
]
|
||||
},
|
||||
"node-datachannel@0.26.0": {
|
||||
"integrity": "sha512-i9ZcFNszK1HeV6Ym2AoQokmRHE5jk0L5023CdRLzbQl8rqyjJkOGecMxEjo1WSjNHDvRO3I3ay9waclBdD3jRQ==",
|
||||
"dependencies": [
|
||||
"prebuild-install"
|
||||
],
|
||||
"scripts": true
|
||||
},
|
||||
"once@1.4.0": {
|
||||
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
|
||||
"dependencies": [
|
||||
"wrappy"
|
||||
]
|
||||
},
|
||||
"prebuild-install@7.1.3": {
|
||||
"integrity": "sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==",
|
||||
"dependencies": [
|
||||
"detect-libc",
|
||||
"expand-template",
|
||||
"github-from-package",
|
||||
"minimist",
|
||||
"mkdirp-classic",
|
||||
"napi-build-utils",
|
||||
"node-abi",
|
||||
"pump",
|
||||
"rc",
|
||||
"simple-get",
|
||||
"tar-fs",
|
||||
"tunnel-agent"
|
||||
],
|
||||
"bin": true
|
||||
},
|
||||
"pump@3.0.2": {
|
||||
"integrity": "sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==",
|
||||
"dependencies": [
|
||||
"end-of-stream",
|
||||
"once"
|
||||
]
|
||||
},
|
||||
"rc@1.2.8": {
|
||||
"integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==",
|
||||
"dependencies": [
|
||||
"deep-extend",
|
||||
"ini",
|
||||
"minimist",
|
||||
"strip-json-comments"
|
||||
],
|
||||
"bin": true
|
||||
},
|
||||
"readable-stream@3.6.2": {
|
||||
"integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
|
||||
"dependencies": [
|
||||
"inherits",
|
||||
"string_decoder",
|
||||
"util-deprecate"
|
||||
]
|
||||
},
|
||||
"safe-buffer@5.2.1": {
|
||||
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
|
||||
},
|
||||
"semver@7.7.1": {
|
||||
"integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==",
|
||||
"bin": true
|
||||
},
|
||||
"simple-concat@1.0.1": {
|
||||
"integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q=="
|
||||
},
|
||||
"simple-get@4.0.1": {
|
||||
"integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==",
|
||||
"dependencies": [
|
||||
"decompress-response",
|
||||
"once",
|
||||
"simple-concat"
|
||||
]
|
||||
},
|
||||
"string_decoder@1.3.0": {
|
||||
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
|
||||
"dependencies": [
|
||||
"safe-buffer"
|
||||
]
|
||||
},
|
||||
"strip-json-comments@2.0.1": {
|
||||
"integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ=="
|
||||
},
|
||||
"tar-fs@2.1.2": {
|
||||
"integrity": "sha512-EsaAXwxmx8UB7FRKqeozqEPop69DXcmYwTQwXvyAPF352HJsPdkVhvTaDPYqfNgruveJIJy3TA2l+2zj8LJIJA==",
|
||||
"dependencies": [
|
||||
"chownr",
|
||||
"mkdirp-classic",
|
||||
"pump",
|
||||
"tar-stream"
|
||||
]
|
||||
},
|
||||
"tar-stream@2.2.0": {
|
||||
"integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==",
|
||||
"dependencies": [
|
||||
"bl",
|
||||
"end-of-stream",
|
||||
"fs-constants",
|
||||
"inherits",
|
||||
"readable-stream"
|
||||
]
|
||||
},
|
||||
"tunnel-agent@0.6.0": {
|
||||
"integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==",
|
||||
"dependencies": [
|
||||
"safe-buffer"
|
||||
]
|
||||
},
|
||||
"undici-types@6.21.0": {
|
||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="
|
||||
},
|
||||
"util-deprecate@1.0.2": {
|
||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
|
||||
},
|
||||
"wrappy@1.0.2": {
|
||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="
|
||||
}
|
||||
}
|
||||
}
|
||||
2
deno_bootstrap/dev.sh
Executable file
2
deno_bootstrap/dev.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
deno --allow-scripts --allow-all ddln_bootstrap.ts
|
||||
29
src/App.ts
29
src/App.ts
@@ -60,35 +60,35 @@ class StatusBar {
|
||||
peerStatus = new Map();
|
||||
headless = false;
|
||||
|
||||
setMessageHTML(html:string) {
|
||||
setMessageHTML(html: string) {
|
||||
let statusBarElement = document.getElementById('status_bar');
|
||||
|
||||
if (!statusBarElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
statusBarElement.innerHTML = html;
|
||||
statusBarElement.innerHTML = html;
|
||||
|
||||
}
|
||||
|
||||
setHeadless(headless:boolean) {
|
||||
setHeadless(headless: boolean) {
|
||||
this.headless = headless;
|
||||
}
|
||||
updatePeerMessage(peerID: string, message: string) {
|
||||
this.peerStatus.set(peerID, {message, data:this.peerStatus.get(peerID)?.data});
|
||||
this.peerStatus.set(peerID, { message, data: this.peerStatus.get(peerID)?.data });
|
||||
this.render();
|
||||
}
|
||||
|
||||
updatePeerData(peerID:PeerID, data:any) {
|
||||
this.peerStatus.set(peerID, {message:this.peerStatus.get(peerID)?.message, data:data});
|
||||
updatePeerData(peerID: PeerID, data: any) {
|
||||
this.peerStatus.set(peerID, { message: this.peerStatus.get(peerID)?.message, data: data });
|
||||
}
|
||||
|
||||
updatePeerStatus(peerID:PeerID, message:string="", data={}) {
|
||||
this.peerStatus.set(peerID, {message, data});
|
||||
updatePeerStatus(peerID: PeerID, message: string = "", data = {}) {
|
||||
this.peerStatus.set(peerID, { message, data });
|
||||
this.render();
|
||||
}
|
||||
|
||||
getPeerData(peerID:PeerID) {
|
||||
getPeerData(peerID: PeerID) {
|
||||
let status = this.peerStatus.get(peerID);
|
||||
if (status) {
|
||||
return status.data;
|
||||
@@ -105,8 +105,8 @@ class StatusBar {
|
||||
|
||||
let newStatus = "";
|
||||
for (let [peerID, status] of this.peerStatus.entries()) {
|
||||
let statusBarItem = `<span>(${logID(peerID)} | ${status.message}) </span>`;
|
||||
newStatus += statusBarItem;
|
||||
let statusBarItem = `<span>(${logID(peerID)} | ${status.message}) </span>`;
|
||||
newStatus += statusBarItem;
|
||||
}
|
||||
|
||||
this.setMessageHTML(newStatus);
|
||||
@@ -187,7 +187,7 @@ export class App {
|
||||
if (neededPostIDs.length > 0) {
|
||||
console.log.apply(null, log(`[app] Need (${neededPostIDs.length}) posts for user ${logID(userID)} from peer ${logID(peerID)}`));
|
||||
let neededPostCount = neededPostIDs.length;
|
||||
this.statusBar.updatePeerStatus(peerID, `need(${logID(userID)} | ${neededPostCount})`, {havePostCount:0, neededPostCount:neededPostCount});
|
||||
this.statusBar.updatePeerStatus(peerID, `need(${logID(userID)} | ${neededPostCount})`, { havePostCount: 0, neededPostCount: neededPostCount });
|
||||
|
||||
let neededPosts = await this.peerManager?.rpc.getPostsForUser(peerID, this.peerID, userID, neededPostIDs);
|
||||
}
|
||||
@@ -272,8 +272,9 @@ export class App {
|
||||
}
|
||||
|
||||
let knownUsers = await this.sync.getKnownUsers();
|
||||
this.peerManager.rpc.announceUsers(event.peerID, this.peerID, knownUsers);
|
||||
|
||||
// rpc saying what peers we have
|
||||
this.peerManager.rpc.announceUsers(event.peerID, this.peerID, knownUsers);
|
||||
});
|
||||
|
||||
this.peerManager.addEventListener(PeerEventTypes.PEER_DISCONNECTED, async (event: any) => {
|
||||
@@ -310,7 +311,7 @@ export class App {
|
||||
this.peerManager.registerRPC('getPostsForUser', async (requestingPeerID: string, userID: string, postIDs: string[]) => {
|
||||
let posts = await this.sync.getPostsForUser(userID, postIDs);
|
||||
|
||||
let i=0;
|
||||
let i = 0;
|
||||
for (let post of posts) {
|
||||
console.log.apply(null, log(`[app] sendPostForUser sending post [${logID(post.post_id)}] to [${logID(requestingPeerID)}]`, userID, post.author, post.text));
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import { generateID } from "IDUtils";
|
||||
import { log, logID } from "log";
|
||||
import { App } from "./App";
|
||||
// import { App } from "./App";
|
||||
|
||||
// Use a broadcast channel to only have one peer manager for multiple tabs,
|
||||
// then we won't need to have a session ID as all queries for a peerID will be coming from the same peer manager
|
||||
@@ -26,7 +26,7 @@ export class PeerManager {
|
||||
searchQueryFunctions: Map<string, Function> = new Map();
|
||||
RPC_remote: Map<string, Function> = new Map();
|
||||
rpc: { [key: string]: Function } = {};
|
||||
isBootstrapPeer: boolean = false;
|
||||
_isBootstrapPeer: boolean = false;
|
||||
bootstrapPeerConnections: Map<string, PeerConnection> | null = null;
|
||||
sessionID = generateID();
|
||||
userID: string;
|
||||
@@ -84,6 +84,11 @@ export class PeerManager {
|
||||
return peername;
|
||||
}
|
||||
|
||||
isBootstrapPeer(peerID: string) {
|
||||
return this.bootstrapPeerIDs?.has(peerID)
|
||||
}
|
||||
|
||||
|
||||
websocketSend(message: any) {
|
||||
if (!this.websocket) {
|
||||
throw new Error();
|
||||
@@ -118,7 +123,7 @@ export class PeerManager {
|
||||
|
||||
if (message.type === "hello2") {
|
||||
|
||||
if (!this.isBootstrapPeer && Array.isArray(message?.bootstrapPeers)) {
|
||||
if (!this._isBootstrapPeer && Array.isArray(message?.bootstrapPeers)) {
|
||||
this.bootstrapPeerIDs = new Set(message.bootstrapPeers);
|
||||
}
|
||||
|
||||
@@ -144,7 +149,7 @@ export class PeerManager {
|
||||
if (!peerConnection) {
|
||||
let remotePeerID = message.from;
|
||||
let newPeer = new PeerConnection(this, remotePeerID, this.websocketSendPeerMessage.bind(this));
|
||||
if (this.isBootstrapPeer) {
|
||||
if (this._isBootstrapPeer) {
|
||||
newPeer.setPolite(false);
|
||||
}
|
||||
peerConnection = newPeer;
|
||||
@@ -177,7 +182,7 @@ export class PeerManager {
|
||||
|
||||
async onHello2Received(bootstrapPeerIDs: Set<string> | null) {
|
||||
|
||||
if (this.isBootstrapPeer) {
|
||||
if (this._isBootstrapPeer) {
|
||||
this.connectPromiseCallbacks?.resolve();
|
||||
return;
|
||||
}
|
||||
@@ -195,7 +200,7 @@ export class PeerManager {
|
||||
// this.bootstrapPeerConnection = await this.connectToPeer(peerID);
|
||||
|
||||
|
||||
let bootstrapPeerConnectionPromise = new Promise( async (resolve, reject)=>{
|
||||
let bootstrapPeerConnectionPromise = new Promise(async (resolve, reject) => {
|
||||
let peerConnection = await this.connectToPeer(peerID);
|
||||
if (!peerConnection) {
|
||||
reject(peerConnection);
|
||||
@@ -221,7 +226,7 @@ export class PeerManager {
|
||||
peer_id: this.peerID,
|
||||
session_id: this.sessionID,
|
||||
// peer_name: app.peername,
|
||||
is_bootstrap_peer: this.isBootstrapPeer,
|
||||
is_bootstrap_peer: this._isBootstrapPeer,
|
||||
// peer_description: this.rtcPeerDescription
|
||||
});
|
||||
}
|
||||
@@ -246,7 +251,7 @@ export class PeerManager {
|
||||
}
|
||||
|
||||
constructor(userID: string, peerID: string, isBootstrapPeer: boolean) {
|
||||
this.isBootstrapPeer = isBootstrapPeer;
|
||||
this._isBootstrapPeer = isBootstrapPeer;
|
||||
this.peers = new Map();
|
||||
this.routingTable = new Map();
|
||||
this.userID = userID;
|
||||
@@ -324,7 +329,7 @@ export class PeerManager {
|
||||
}
|
||||
|
||||
|
||||
if (!this.isBootstrapPeer && numActive === 0) {
|
||||
if (!this._isBootstrapPeer && numActive === 0) {
|
||||
console.log.apply(null, log(`No peers connected, will attempt to reconnect in ${this.reconnectPeriod} seconds...`));
|
||||
|
||||
// Websocket reconnect
|
||||
@@ -342,6 +347,13 @@ export class PeerManager {
|
||||
let output = `Current status:` + "\n" + `[${logID(this.peerID)}]${this.getPeername(this.peerID)}[local]` + "\n";
|
||||
for (let [peerID, peer] of this.peers) {
|
||||
output += `[${logID(peerID)}]${peer.rtcPeer?.connectionState}:${this.getPeername(peerID)}${this.bootstrapPeerIDs?.has(peerID) ? "[Bootstrap]" : ""}` + "\n";
|
||||
|
||||
if (peer.rpcSuperlog) {
|
||||
for (let transactionID of peer.pendingRPCs.keys()) {
|
||||
output += `[${logID(transactionID)}]`;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
output += `numActivePeers: ${numActive}` + "\n";
|
||||
@@ -521,8 +533,8 @@ class PeerConnection {
|
||||
private ignoreOffer: boolean = false;
|
||||
private isSettingRemoteAnswerPending: boolean = false;
|
||||
private polite = true;
|
||||
private webRTCSuperlog = false;
|
||||
private dataChannelSuperlog = false;
|
||||
private webRTCSuperlog = true;
|
||||
private dataChannelSuperlog = true;
|
||||
private chunkSize = (16 * 1024) - 100;
|
||||
messageSuperlog: boolean = false;
|
||||
sendQueueSuperLog: boolean = false;
|
||||
@@ -588,7 +600,7 @@ class PeerConnection {
|
||||
|
||||
// console.log.apply(null, log([...this.peerManager.peers.keys()]));
|
||||
|
||||
if (this.peerManager.isBootstrapPeer) {
|
||||
if (this.peerManager._isBootstrapPeer) {
|
||||
this.send({ type: 'initial_peers', from: this.peerManager.peerID, peers: [...this.peerManager.peers.keys()].filter(entry => entry !== this.remotePeerID) });
|
||||
// this.dataChannel.send(JSON.stringify());
|
||||
}
|
||||
@@ -616,6 +628,11 @@ class PeerConnection {
|
||||
|
||||
async connect() {
|
||||
let connectionPromise = new Promise((resolve, reject) => { this.connectionPromise = { resolve, reject } });
|
||||
|
||||
if (!(typeof RTCPeerConnection === "function")) {
|
||||
throw new Error("RTCPeerConnection is not a function, exiting.");
|
||||
}
|
||||
|
||||
this.rtcPeer = new RTCPeerConnection(PeerConnection.config);
|
||||
|
||||
this.rtcPeer.onconnectionstatechange = async (e: any) => {
|
||||
@@ -720,7 +737,11 @@ class PeerConnection {
|
||||
|
||||
async onWebsocketMessage(message: any) {
|
||||
if (message.type == "rtc_connect") {
|
||||
this.rtcPeer?.setRemoteDescription(message.description);
|
||||
try {
|
||||
this.rtcPeer?.setRemoteDescription(message.description);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -734,7 +755,7 @@ class PeerConnection {
|
||||
|
||||
|
||||
if (!this.rtcPeer) {
|
||||
throw new Error();
|
||||
throw new Error("Unable to instantiate RTCPeerConnection, exiting.");
|
||||
}
|
||||
|
||||
let description = null;
|
||||
@@ -760,7 +781,12 @@ class PeerConnection {
|
||||
return;
|
||||
}
|
||||
this.isSettingRemoteAnswerPending = description.type == "answer";
|
||||
await this.rtcPeer.setRemoteDescription(description);
|
||||
|
||||
try {
|
||||
await this.rtcPeer.setRemoteDescription(description);
|
||||
} catch (e) {
|
||||
console.log("PeerConnection:setRemoteDescription:failed:", e, description);
|
||||
}
|
||||
this.isSettingRemoteAnswerPending = false;
|
||||
if (description.type === "offer") {
|
||||
await this.rtcPeer.setLocalDescription();
|
||||
@@ -769,9 +795,11 @@ class PeerConnection {
|
||||
} else if (candidate) {
|
||||
try {
|
||||
await this.rtcPeer.addIceCandidate(candidate);
|
||||
} catch (err) {
|
||||
} catch (e) {
|
||||
if (!this.ignoreOffer) {
|
||||
throw err;
|
||||
console.log("PeerConnection:addIceCandidate:failed:", e, candidate);
|
||||
throw e;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -869,7 +897,7 @@ class PeerConnection {
|
||||
// Think about a timeout here to auto reject it after a while.
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
this.pendingRPCs.set(transactionID, { resolve, reject, functionName });
|
||||
// setTimeout(() => reject("bad"), 1000);
|
||||
setTimeout(() => reject(`function:${functionName}[${transactionID}] failed to resolve after 10 seconds.`), 10_000);
|
||||
});
|
||||
|
||||
let message = {
|
||||
@@ -909,6 +937,7 @@ class PeerConnection {
|
||||
}
|
||||
|
||||
pendingRPC.resolve(message.response);
|
||||
this.pendingRPCs.delete(message.transaction_id);
|
||||
}
|
||||
|
||||
if (type === "rpc_call") {
|
||||
@@ -920,12 +949,6 @@ class PeerConnection {
|
||||
|
||||
this.rpcSuperlog && console.log.apply(null, log(`[rpc] call: response:`, response));
|
||||
|
||||
|
||||
|
||||
if (response === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
let responseMessage = { type: 'rpc_response', function_name: message.function_name, transaction_id: message.transaction_id, response: response };
|
||||
this.send(responseMessage);
|
||||
|
||||
|
||||
@@ -161,6 +161,7 @@ export class Sync {
|
||||
following.push(...[
|
||||
'b38b623c-c3fa-4351-9cab-50233c99fa4e', // Rob
|
||||
'05a495a0-0dd8-4186-94c3-b8309ba6fc4c', // Martin
|
||||
'622ecc28-2eff-44b9-b89d-fdea7c8dd2d5', // Hazel
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -199,8 +199,8 @@ export class App {
|
||||
return;
|
||||
}
|
||||
let knownUsers = await this.sync.getKnownUsers();
|
||||
this.peerManager.rpc.announceUsers(event.peerID, this.peerID, knownUsers);
|
||||
// rpc saying what peers we have
|
||||
this.peerManager.rpc.announceUsers(event.peerID, this.peerID, knownUsers);
|
||||
});
|
||||
this.peerManager.addEventListener(PeerEventTypes.PEER_DISCONNECTED, async (event) => {
|
||||
console.log.apply(null, log(`[app]: peer disconnected:${event.peerID}`));
|
||||
@@ -1183,3 +1183,4 @@ export class App {
|
||||
})(Route = App.Route || (App.Route = {}));
|
||||
})(App || (App = {}));
|
||||
;
|
||||
//# sourceMappingURL=App.js.map
|
||||
1
static/App.js.map
Normal file
1
static/App.js.map
Normal file
File diff suppressed because one or more lines are too long
@@ -7,3 +7,4 @@ export function generateID() {
|
||||
}
|
||||
return uuidv4();
|
||||
}
|
||||
//# sourceMappingURL=IDUtils.js.map
|
||||
1
static/IDUtils.js.map
Normal file
1
static/IDUtils.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"IDUtils.js","sourceRoot":"","sources":["../src/IDUtils.ts"],"names":[],"mappings":"AAAA,SAAS,MAAM;IACX,OAAO,sCAAsC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAM,EAAE,EAAE,CACvE,CAAC,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAChF,CAAC;AACN,CAAC;AAED,MAAM,UAAU,UAAU;IACtB,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IACpC,CAAC;IAED,OAAO,MAAM,EAAE,CAAC;AACpB,CAAC"}
|
||||
@@ -33,6 +33,9 @@ export class PeerManager {
|
||||
let peername = `${adjective}_${snake}`;
|
||||
return peername;
|
||||
}
|
||||
isBootstrapPeer(peerID) {
|
||||
return this.bootstrapPeerIDs?.has(peerID);
|
||||
}
|
||||
websocketSend(message) {
|
||||
if (!this.websocket) {
|
||||
throw new Error();
|
||||
@@ -60,7 +63,7 @@ export class PeerManager {
|
||||
}
|
||||
this.messageSuperlog && console.log.apply(null, log("->signaler:", message));
|
||||
if (message.type === "hello2") {
|
||||
if (!this.isBootstrapPeer && Array.isArray(message?.bootstrapPeers)) {
|
||||
if (!this._isBootstrapPeer && Array.isArray(message?.bootstrapPeers)) {
|
||||
this.bootstrapPeerIDs = new Set(message.bootstrapPeers);
|
||||
}
|
||||
this.onHello2Received(this.bootstrapPeerIDs);
|
||||
@@ -79,7 +82,7 @@ export class PeerManager {
|
||||
if (!peerConnection) {
|
||||
let remotePeerID = message.from;
|
||||
let newPeer = new PeerConnection(this, remotePeerID, this.websocketSendPeerMessage.bind(this));
|
||||
if (this.isBootstrapPeer) {
|
||||
if (this._isBootstrapPeer) {
|
||||
newPeer.setPolite(false);
|
||||
}
|
||||
peerConnection = newPeer;
|
||||
@@ -105,7 +108,7 @@ export class PeerManager {
|
||||
return newPeer;
|
||||
}
|
||||
async onHello2Received(bootstrapPeerIDs) {
|
||||
if (this.isBootstrapPeer) {
|
||||
if (this._isBootstrapPeer) {
|
||||
this.connectPromiseCallbacks?.resolve();
|
||||
return;
|
||||
}
|
||||
@@ -139,7 +142,7 @@ export class PeerManager {
|
||||
peer_id: this.peerID,
|
||||
session_id: this.sessionID,
|
||||
// peer_name: app.peername,
|
||||
is_bootstrap_peer: this.isBootstrapPeer,
|
||||
is_bootstrap_peer: this._isBootstrapPeer,
|
||||
// peer_description: this.rtcPeerDescription
|
||||
});
|
||||
}
|
||||
@@ -164,7 +167,7 @@ export class PeerManager {
|
||||
this.searchQueryFunctions = new Map();
|
||||
this.RPC_remote = new Map();
|
||||
this.rpc = {};
|
||||
this.isBootstrapPeer = false;
|
||||
this._isBootstrapPeer = false;
|
||||
this.bootstrapPeerConnections = null;
|
||||
this.sessionID = generateID();
|
||||
this.websocket = null;
|
||||
@@ -188,7 +191,7 @@ export class PeerManager {
|
||||
this.animals = ['shrew', 'jerboa', 'lemur', 'weasel', 'possum', 'possum', 'marmoset', 'planigale', 'mole', 'narwhal'];
|
||||
this.adjectives = ['snazzy', 'whimsical', 'jazzy', 'bonkers', 'wobbly', 'spiffy', 'chirpy', 'zesty', 'bubbly', 'perky', 'sassy'];
|
||||
this.snakes = ['mamba', 'cobra', 'python', 'viper', 'krait', 'sidewinder', 'constrictor', 'boa', 'asp', 'anaconda', 'krait'];
|
||||
this.isBootstrapPeer = isBootstrapPeer;
|
||||
this._isBootstrapPeer = isBootstrapPeer;
|
||||
this.peers = new Map();
|
||||
this.routingTable = new Map();
|
||||
this.userID = userID;
|
||||
@@ -244,7 +247,7 @@ export class PeerManager {
|
||||
}
|
||||
numActive++;
|
||||
}
|
||||
if (!this.isBootstrapPeer && numActive === 0) {
|
||||
if (!this._isBootstrapPeer && numActive === 0) {
|
||||
console.log.apply(null, log(`No peers connected, will attempt to reconnect in ${this.reconnectPeriod} seconds...`));
|
||||
// Websocket reconnect
|
||||
if (this.websocket?.readyState === WebSocket.OPEN) {
|
||||
@@ -257,6 +260,11 @@ export class PeerManager {
|
||||
let output = `Current status:` + "\n" + `[${logID(this.peerID)}]${this.getPeername(this.peerID)}[local]` + "\n";
|
||||
for (let [peerID, peer] of this.peers) {
|
||||
output += `[${logID(peerID)}]${peer.rtcPeer?.connectionState}:${this.getPeername(peerID)}${this.bootstrapPeerIDs?.has(peerID) ? "[Bootstrap]" : ""}` + "\n";
|
||||
if (peer.rpcSuperlog) {
|
||||
for (let transactionID of peer.pendingRPCs.keys()) {
|
||||
output += `[${logID(transactionID)}]`;
|
||||
}
|
||||
}
|
||||
}
|
||||
output += `numActivePeers: ${numActive}` + "\n";
|
||||
console.log.apply(null, log(output));
|
||||
@@ -386,8 +394,8 @@ class PeerConnection {
|
||||
this.ignoreOffer = false;
|
||||
this.isSettingRemoteAnswerPending = false;
|
||||
this.polite = true;
|
||||
this.webRTCSuperlog = false;
|
||||
this.dataChannelSuperlog = false;
|
||||
this.webRTCSuperlog = true;
|
||||
this.dataChannelSuperlog = true;
|
||||
this.chunkSize = (16 * 1024) - 100;
|
||||
this.messageSuperlog = false;
|
||||
this.sendQueueSuperLog = false;
|
||||
@@ -421,7 +429,7 @@ class PeerConnection {
|
||||
this.send({ type: "hello datachannel", from: this.peerManager.peerID, to: this.remotePeerID });
|
||||
// this.dataChannel?.send(`{typeHello datachannel from: ${this.peerManager.peerID}`);
|
||||
// console.log.apply(null, log([...this.peerManager.peers.keys()]));
|
||||
if (this.peerManager.isBootstrapPeer) {
|
||||
if (this.peerManager._isBootstrapPeer) {
|
||||
this.send({ type: 'initial_peers', from: this.peerManager.peerID, peers: [...this.peerManager.peers.keys()].filter(entry => entry !== this.remotePeerID) });
|
||||
// this.dataChannel.send(JSON.stringify());
|
||||
}
|
||||
@@ -442,6 +450,9 @@ class PeerConnection {
|
||||
}
|
||||
async connect() {
|
||||
let connectionPromise = new Promise((resolve, reject) => { this.connectionPromise = { resolve, reject }; });
|
||||
if (!(typeof RTCPeerConnection === "function")) {
|
||||
throw new Error("RTCPeerConnection is not a function, exiting.");
|
||||
}
|
||||
this.rtcPeer = new RTCPeerConnection(PeerConnection.config);
|
||||
this.rtcPeer.onconnectionstatechange = async (e) => {
|
||||
this.webRTCSuperlog && console.log.apply(null, log(`rtcPeer: onconnectionstatechange: ${this.rtcPeer?.connectionState}: ${this.remotePeerID}`));
|
||||
@@ -519,14 +530,19 @@ class PeerConnection {
|
||||
}
|
||||
async onWebsocketMessage(message) {
|
||||
if (message.type == "rtc_connect") {
|
||||
this.rtcPeer?.setRemoteDescription(message.description);
|
||||
try {
|
||||
this.rtcPeer?.setRemoteDescription(message.description);
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
// /*
|
||||
// let ignoreOffer = false;
|
||||
// let isSettingRemoteAnswerPending = false;
|
||||
// signaler.onmessage = async ({ data: { description, candidate } }) => {
|
||||
if (!this.rtcPeer) {
|
||||
throw new Error();
|
||||
throw new Error("Unable to instantiate RTCPeerConnection, exiting.");
|
||||
}
|
||||
let description = null;
|
||||
if (message.type == "rtc_description") {
|
||||
@@ -547,7 +563,12 @@ class PeerConnection {
|
||||
return;
|
||||
}
|
||||
this.isSettingRemoteAnswerPending = description.type == "answer";
|
||||
await this.rtcPeer.setRemoteDescription(description);
|
||||
try {
|
||||
await this.rtcPeer.setRemoteDescription(description);
|
||||
}
|
||||
catch (e) {
|
||||
console.log("PeerConnection:setRemoteDescription:failed:", e, description);
|
||||
}
|
||||
this.isSettingRemoteAnswerPending = false;
|
||||
if (description.type === "offer") {
|
||||
await this.rtcPeer.setLocalDescription();
|
||||
@@ -558,9 +579,10 @@ class PeerConnection {
|
||||
try {
|
||||
await this.rtcPeer.addIceCandidate(candidate);
|
||||
}
|
||||
catch (err) {
|
||||
catch (e) {
|
||||
if (!this.ignoreOffer) {
|
||||
throw err;
|
||||
console.log("PeerConnection:addIceCandidate:failed:", e, candidate);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -632,7 +654,7 @@ class PeerConnection {
|
||||
// Think about a timeout here to auto reject it after a while.
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
this.pendingRPCs.set(transactionID, { resolve, reject, functionName });
|
||||
// setTimeout(() => reject("bad"), 1000);
|
||||
setTimeout(() => reject(`function:${functionName}[${transactionID}] failed to resolve after 10 seconds.`), 10000);
|
||||
});
|
||||
let message = {
|
||||
type: "rpc_call",
|
||||
@@ -661,14 +683,12 @@ class PeerConnection {
|
||||
throw new Error();
|
||||
}
|
||||
pendingRPC.resolve(message.response);
|
||||
this.pendingRPCs.delete(message.transaction_id);
|
||||
}
|
||||
if (type === "rpc_call") {
|
||||
this.rpcSuperlog && console.log.apply(null, log(`[${logID(this.remotePeerID)}]->[rpc][${logID(this.peerManager.peerID)}] call: `, message.function_name, message.transaction_id, JSON.stringify(message.args, null, 2)));
|
||||
let response = await this.peerManager.callFromRemote(message.function_name, message.args);
|
||||
this.rpcSuperlog && console.log.apply(null, log(`[rpc] call: response:`, response));
|
||||
if (response === undefined) {
|
||||
return;
|
||||
}
|
||||
let responseMessage = { type: 'rpc_response', function_name: message.function_name, transaction_id: message.transaction_id, response: response };
|
||||
this.send(responseMessage);
|
||||
}
|
||||
@@ -715,3 +735,4 @@ PeerConnection.config = {
|
||||
{ urls: "stun:stun4.l.google.com" },
|
||||
],
|
||||
};
|
||||
//# sourceMappingURL=PeerManager.js.map
|
||||
1
static/PeerManager.js.map
Normal file
1
static/PeerManager.js.map
Normal file
File diff suppressed because one or more lines are too long
@@ -144,6 +144,7 @@ export class Sync {
|
||||
following.push(...[
|
||||
'b38b623c-c3fa-4351-9cab-50233c99fa4e', // Rob
|
||||
'05a495a0-0dd8-4186-94c3-b8309ba6fc4c', // Martin
|
||||
'622ecc28-2eff-44b9-b89d-fdea7c8dd2d5', // Hazel
|
||||
]);
|
||||
}
|
||||
return following;
|
||||
@@ -224,3 +225,4 @@ export class Sync {
|
||||
await mergeDataArray(userID, [post]);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Sync.js.map
|
||||
1
static/Sync.js.map
Normal file
1
static/Sync.js.map
Normal file
File diff suppressed because one or more lines are too long
@@ -69,3 +69,4 @@ export async function compressString(input) {
|
||||
// const bytes = uuidToBytes(uuid);
|
||||
// return encodeBase58(bytes);
|
||||
// }
|
||||
//# sourceMappingURL=dataUtils.js.map
|
||||
1
static/dataUtils.js.map
Normal file
1
static/dataUtils.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"dataUtils.js","sourceRoot":"","sources":["../src/dataUtils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,KAAiB,EAAE,IAAI,GAAG,0BAA0B;IAC7F,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,E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EAAE,CAAC;IAErF,8CAA8C;IAC9C,OAAO,IAAI,UAAU,CAAC,eAAe,CAAC,CAAC;AACzC,CAAC;AAED,uBAAuB;AACvB,wFAAwF;AACxF,kBAAkB;AAClB,kBAAkB;AAClB,sDAAsD;AACtD,eAAe;AACf,wBAAwB;AAExB,iCAAiC;AACjC,oBAAoB;AACpB,gDAAgD;AAChD,iCAAiC;AACjC,gCAAgC;AAChC,wCAAwC;AACxC,QAAQ;AACR,0BAA0B;AAC1B,iCAAiC;AACjC,wCAAwC;AACxC,QAAQ;AACR,MAAM;AAEN,qBAAqB;AACrB,4CAA4C;AAC5C,wCAAwC;AACxC,MAAM;AAEN,iCAAiC;AACjC,iCAAiC;AACjC,2BAA2B;AAC3B,8CAA8C;AAC9C,eAAe;AACf,eAAe;AACf,QAAQ;AACR,MAAM;AAEN,mBAAmB;AACnB,IAAI;AAEJ,4BAA4B;AAC5B,gDAAgD;AAChD,qCAAqC;AACrC,gCAAgC;AAChC,IAAI"}
|
||||
@@ -345,3 +345,4 @@ export async function getPostsByIds(userID, postIDs) {
|
||||
}
|
||||
return posts; // Return the array of posts
|
||||
}
|
||||
//# sourceMappingURL=db.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -37,3 +37,4 @@ export function log(...args) {
|
||||
renderLog();
|
||||
return [logLine]; // [...args];
|
||||
}
|
||||
//# sourceMappingURL=log.js.map
|
||||
1
static/log.js.map
Normal file
1
static/log.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA,IAAI,QAAQ,GAAa,EAAE,CAAC;AAC5B,IAAI,SAAS,GAAG,GAAG,CAAC;AACpB,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,EAAE,CAAC,SAAS,CAAC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EZ,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA,aAAa;AAChC,CAAC"}
|
||||
@@ -1577,3 +1577,4 @@ class App {
|
||||
})(App || (App = {}));
|
||||
let app = new App();
|
||||
window.addEventListener("load", app.main.bind(app));
|
||||
//# sourceMappingURL=main.js.map
|
||||
@@ -39,3 +39,4 @@ window.addEventListener('scroll', () => {
|
||||
});
|
||||
let app = new App();
|
||||
window.addEventListener("load", app.main.bind(app));
|
||||
//# sourceMappingURL=main2.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -121,3 +121,4 @@ addEventListener("message", async (e) => {
|
||||
break;
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=sw.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"sw.js","sourceRoot":"","sources":["../src/sw.ts"],"names":[],"mappings":";AAAA,MAAM,QAAQ,GAAG,KAAK,CAAC;AACvB,yBAAyB;AACzB,MAAM,SAAS,GAAG,oBAAoB,CAAC;AAEvC,MAAM,cAAc,GAAG;IACrB,oBAAoB;IACpB,kBAAkB;IAClB,kBAAkB;IAClB,2BAA2B;IAC3B,2BAA2B;IAC3B,eAAe;IACf,wBAAwB;IACxB,oBAAoB;IACpB,qBAAqB;CACtB,CAAC;AAEF,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,CAAM,EAAE,EAAE;IAC1C,CAAC,CAAC,SAAS,CACT,CAAC,KAAK,IAAI,EAAE;QACV,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3C,OAAO,CAAC,GAAG,CACT,qDAAqD,EACrD,cAAc,CACf,CAAC;QAEF,IAAI,CAAC;YACH,MAAM,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC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AAM,CAAC,cAAc,CAAC,CAAC;YACnC,MAAM;IACV,CAAC;AACH,CAAC,CAAC,CAAC"}
|
||||
1
static/tests.js.map
Normal file
1
static/tests.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"tests.js","sourceRoot":"","sources":["../src/tests.ts"],"names":[],"mappings":";AAAA,kDAAkD;AAGlD,oBAAoB;AACpB,6BAA6B;AAC7B,4BAA4B;AAE5B,yCAAyC;AACzC,gFAAgF;AAChF,0CAA0C;AAE1C,6DAA6D;AAC7D,QAAQ;AACR,IAAI"}
|
||||
@@ -12,7 +12,7 @@
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
|
||||
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
"sourceMap": false, /* Generates corresponding '.map' file. */
|
||||
"sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
"outDir": "./static", /* Redirect output structure to the directory. */
|
||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
|
||||
83
webRTC.js
83
webRTC.js
@@ -1,83 +0,0 @@
|
||||
// https://web.dev/articles/webrtc-basics
|
||||
|
||||
// handles JSON.stringify/parse
|
||||
|
||||
class SignalingChannel {
|
||||
send(message) {
|
||||
console.log(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function createPeerConnection(targetPeer) {
|
||||
|
||||
const signaling = new SignalingChannel();
|
||||
|
||||
// const constraints = {audio: true, video: true};
|
||||
const configuration = { iceServers: [{ urls: 'stun:stunserver2024.stunprotocol.org' }] };
|
||||
const peerConnection = new RTCPeerConnection(configuration);
|
||||
const sendChannel = peerConnection.createDataChannel('default');
|
||||
|
||||
|
||||
// Send any ice candidates to the other peer.
|
||||
peerConnection.onicecandidate = ({ candidate }) => signaling.send({ candidate });
|
||||
|
||||
// Let the "negotiationneeded" event trigger offer generation.
|
||||
peerConnection.onnegotiationneeded = async () => {
|
||||
try {
|
||||
await peerConnection.setLocalDescription(await peerConnection.createOffer());
|
||||
// Send the offer to the other peer.
|
||||
signaling.send({ desc: peerConnection.localDescription });
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
// // Once remote track media arrives, show it in remote video element.
|
||||
// peerConnection.ontrack = (event) => {
|
||||
// // Don't set srcObject again if it is already set.
|
||||
// if (remoteView.srcObject) return;
|
||||
// remoteView.srcObject = event.streams[0];
|
||||
// };
|
||||
|
||||
// Call start() to initiate.
|
||||
async function start() {
|
||||
// try {
|
||||
// Get local stream, show it in self-view, and add it to be sent.
|
||||
// const stream =
|
||||
// await navigator.mediaDevices.getUserMedia(constraints);
|
||||
// stream.getTracks().forEach((track) =>
|
||||
// peerConnection.addTrack(track, stream));
|
||||
// selfView.srcObject = stream;
|
||||
// } catch (err) {
|
||||
// console.error(err);
|
||||
// }
|
||||
}
|
||||
|
||||
signaling.onmessage = async ({ desc, candidate }) => {
|
||||
try {
|
||||
if (desc) {
|
||||
// If you get an offer, you need to reply with an answer.
|
||||
if (desc.type === 'offer') {
|
||||
await peerConnection.setRemoteDescription(desc);
|
||||
// const stream =
|
||||
// await navigator.mediaDevices.getUserMedia(constraints);
|
||||
// stream.getTracks().forEach((track) =>
|
||||
// peerConnection.addTrack(track, stream));
|
||||
await peerConnection.setLocalDescription(await peerConnection.createAnswer());
|
||||
signaling.send({ desc: peerConnection.localDescription });
|
||||
} else if (desc.type === 'answer') {
|
||||
await peerConnection.setRemoteDescription(desc);
|
||||
} else {
|
||||
console.log('Unsupported SDP type.');
|
||||
}
|
||||
} else if (candidate) {
|
||||
await peerConnection.addIceCandidate(candidate);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"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