freertc 0.1.13 → 0.1.15
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 +1 -1
- package/bin/freertc.mjs +42 -0
- package/package.json +1 -1
- package/public/app.js +29 -0
- package/scripts/non-cloudflare-server.mjs +1 -1
- package/src/index.js +1 -1
package/README.md
CHANGED
|
@@ -216,7 +216,7 @@ Quick checks:
|
|
|
216
216
|
Expected `/health` response includes JSON like:
|
|
217
217
|
|
|
218
218
|
```json
|
|
219
|
-
{"ok":true,"version":"0.1.
|
|
219
|
+
{"ok":true,"version":"0.1.15","protocol_version":"1.0","peers":0}
|
|
220
220
|
```
|
|
221
221
|
|
|
222
222
|
## Auto WebRTC two-tab test
|
package/bin/freertc.mjs
CHANGED
|
@@ -237,8 +237,50 @@ async function assertLatestCliForDeploy() {
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
+
async function maybeHandoffToLatestCli(rawArgs = []) {
|
|
241
|
+
if (process.env.FREERTC_NO_AUTO_HANDOFF === '1') {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Avoid network checks for explicit help output.
|
|
246
|
+
const firstArg = rawArgs[0];
|
|
247
|
+
if (firstArg === '--help' || firstArg === '-h' || firstArg === 'help') {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
try {
|
|
252
|
+
const latestVersion = await fetchLatestCliVersion();
|
|
253
|
+
if (compareVersions(CLI_VERSION, latestVersion) >= 0) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
console.log(`Detected newer freertc version ${latestVersion} (current ${CLI_VERSION}).`);
|
|
258
|
+
console.log('Running command with latest CLI automatically...');
|
|
259
|
+
|
|
260
|
+
const args = ['-y', `freertc@${latestVersion}`, ...rawArgs];
|
|
261
|
+
const result = spawnSync('npx', args, {
|
|
262
|
+
cwd: PROJECT_ROOT,
|
|
263
|
+
stdio: 'inherit',
|
|
264
|
+
env: {
|
|
265
|
+
...process.env,
|
|
266
|
+
FREERTC_NO_AUTO_HANDOFF: '1'
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
if (typeof result.status === 'number') {
|
|
271
|
+
process.exit(result.status);
|
|
272
|
+
}
|
|
273
|
+
process.exit(1);
|
|
274
|
+
} catch {
|
|
275
|
+
// Offline or registry hiccup: continue with local CLI.
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
240
279
|
async function main() {
|
|
241
280
|
const [, , subcommand, ...rest] = process.argv;
|
|
281
|
+
const rawArgs = process.argv.slice(2);
|
|
282
|
+
|
|
283
|
+
await maybeHandoffToLatestCli(rawArgs);
|
|
242
284
|
|
|
243
285
|
if (!subcommand) {
|
|
244
286
|
runInProject(process.execPath, [path.join(PACKAGE_ROOT, 'scripts', 'wrangler-install-wizard.mjs'), '--mode', 'both'], { bootstrap: true });
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -112,6 +112,14 @@ function normalizeText(value) {
|
|
|
112
112
|
return String(value).trim();
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
function deriveNetworkFromSession(sessionIdValue) {
|
|
116
|
+
const session = normalizeText(sessionIdValue);
|
|
117
|
+
if (!session || !isSpecToken(session)) {
|
|
118
|
+
return "";
|
|
119
|
+
}
|
|
120
|
+
return `room:${session}`;
|
|
121
|
+
}
|
|
122
|
+
|
|
115
123
|
createApp({
|
|
116
124
|
setup() {
|
|
117
125
|
const host = window.location.host;
|
|
@@ -673,9 +681,15 @@ createApp({
|
|
|
673
681
|
const params = new URLSearchParams(window.location.search);
|
|
674
682
|
const sessionParam = normalizeText(params.get("session_id") || params.get("sessionId"));
|
|
675
683
|
const instanceParam = normalizeText(params.get("instance_id") || params.get("instanceId"));
|
|
684
|
+
const networkParam = normalizeText(
|
|
685
|
+
params.get("network") ||
|
|
686
|
+
params.get("network_id") ||
|
|
687
|
+
params.get("networkId")
|
|
688
|
+
);
|
|
676
689
|
|
|
677
690
|
const hasValidUrlSession = isSpecToken(sessionParam);
|
|
678
691
|
const hasValidUrlInstance = isSpecToken(instanceParam);
|
|
692
|
+
const hasValidUrlNetwork = isSpecToken(networkParam);
|
|
679
693
|
|
|
680
694
|
if (sessionParam && !hasValidUrlSession) {
|
|
681
695
|
pushLog("ids:error", "Ignoring invalid URL session_id");
|
|
@@ -683,9 +697,24 @@ createApp({
|
|
|
683
697
|
if (instanceParam && !hasValidUrlInstance) {
|
|
684
698
|
pushLog("ids:error", "Ignoring invalid URL instance_id");
|
|
685
699
|
}
|
|
700
|
+
if (networkParam && !hasValidUrlNetwork) {
|
|
701
|
+
pushLog("network:error", "Ignoring invalid URL network");
|
|
702
|
+
}
|
|
686
703
|
|
|
687
704
|
sessionId.value = hasValidUrlSession ? sessionParam : `sess-${Math.random().toString(36).slice(2, 10)}`;
|
|
688
705
|
instanceId.value = hasValidUrlInstance ? instanceParam : `inst-${Math.random().toString(36).slice(2, 10)}`;
|
|
706
|
+
|
|
707
|
+
// Cross-domain links should land in the same room even when each origin has
|
|
708
|
+
// different sessionStorage UI state. URL network wins; otherwise derive from session_id.
|
|
709
|
+
const derivedNetwork = deriveNetworkFromSession(sessionId.value);
|
|
710
|
+
const nextNetwork = hasValidUrlNetwork ? networkParam : (derivedNetwork || normalizedNetworkValue());
|
|
711
|
+
if (nextNetwork && nextNetwork !== network.value) {
|
|
712
|
+
network.value = nextNetwork;
|
|
713
|
+
}
|
|
714
|
+
if (nextNetwork && nextNetwork !== appliedNetwork.value) {
|
|
715
|
+
appliedNetwork.value = nextNetwork;
|
|
716
|
+
}
|
|
717
|
+
|
|
689
718
|
persistSharedIds();
|
|
690
719
|
}
|
|
691
720
|
|
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
7
7
|
import { WebSocketServer } from 'ws';
|
|
8
8
|
|
|
9
9
|
const PSP_VERSION = '1.0';
|
|
10
|
-
const WORKER_VERSION = '0.1.
|
|
10
|
+
const WORKER_VERSION = '0.1.15';
|
|
11
11
|
const DEFAULT_TTL_MS = 30_000;
|
|
12
12
|
const MAX_TTL_MS = 120_000;
|
|
13
13
|
const MAX_MESSAGE_SIZE = 64 * 1024;
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const PSP_VERSION = "1.0";
|
|
2
|
-
const WORKER_VERSION = "0.1.
|
|
2
|
+
const WORKER_VERSION = "0.1.15";
|
|
3
3
|
|
|
4
4
|
const DISCOVERY_TYPES = new Set(["announce", "withdraw", "discover", "peer_list", "redirect"]);
|
|
5
5
|
const NEGOTIATION_TYPES = new Set(["connect_request", "connect_accept", "connect_reject", "offer", "answer", "ice_candidate", "ice_end", "renegotiate"]);
|