freertc 0.1.19 → 0.1.20

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 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.19","protocol_version":"1.0","peers":0}
219
+ {"ok":true,"version":"0.1.20","protocol_version":"1.0","peers":0}
220
220
  ```
221
221
 
222
222
  ## Auto WebRTC two-tab test
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freertc",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Cloudflare Worker signaling relay for WebRTC peers with D1 storage.",
5
5
  "keywords": [
6
6
  "webrtc",
@@ -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.19';
10
+ const WORKER_VERSION = '0.1.20';
11
11
  const DEFAULT_TTL_MS = 30_000;
12
12
  const MAX_TTL_MS = 120_000;
13
13
  const MAX_MESSAGE_SIZE = 64 * 1024;
@@ -52,7 +52,15 @@ async function maybeSelfHealInstall() {
52
52
  const projectRoot = process.env.INIT_CWD ? path.resolve(process.env.INIT_CWD) : null;
53
53
  if (!projectRoot) return;
54
54
  if (projectRoot === PACKAGE_ROOT) return;
55
- if (!fs.existsSync(path.join(projectRoot, 'package.json'))) return;
55
+ const projectPackagePath = path.join(projectRoot, 'package.json');
56
+ if (!fs.existsSync(projectPackagePath)) return;
57
+
58
+ let hostPackage;
59
+ try {
60
+ hostPackage = JSON.parse(fs.readFileSync(projectPackagePath, 'utf8'));
61
+ } catch {
62
+ return;
63
+ }
56
64
 
57
65
  let latestVersion;
58
66
  try {
@@ -61,15 +69,30 @@ async function maybeSelfHealInstall() {
61
69
  return;
62
70
  }
63
71
 
64
- if (compareVersions(CLI_VERSION, latestVersion) >= 0) {
72
+ let dependencyRewritten = false;
73
+ for (const section of ['dependencies', 'devDependencies', 'optionalDependencies']) {
74
+ const table = hostPackage?.[section];
75
+ if (table && typeof table === 'object' && Object.prototype.hasOwnProperty.call(table, 'freertc') && table.freertc !== 'latest') {
76
+ table.freertc = 'latest';
77
+ dependencyRewritten = true;
78
+ }
79
+ }
80
+
81
+ if (dependencyRewritten) {
82
+ fs.writeFileSync(projectPackagePath, `${JSON.stringify(hostPackage, null, 2)}\n`, 'utf8');
83
+ console.log('freertc postinstall updated host package.json dependency to "latest".');
84
+ }
85
+
86
+ const needsUpgrade = compareVersions(CLI_VERSION, latestVersion) < 0;
87
+ if (!needsUpgrade && !dependencyRewritten) {
65
88
  return;
66
89
  }
67
90
 
68
- console.log(`freertc postinstall detected stale version ${CLI_VERSION}; upgrading host project to ${latestVersion}...`);
91
+ console.log(`freertc postinstall syncing host project to latest (${latestVersion})...`);
69
92
 
70
93
  const installResult = spawnSync(
71
94
  'npm',
72
- ['install', `freertc@${latestVersion}`],
95
+ ['install'],
73
96
  {
74
97
  cwd: projectRoot,
75
98
  stdio: 'inherit',
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const PSP_VERSION = "1.0";
2
- const WORKER_VERSION = "0.1.19";
2
+ const WORKER_VERSION = "0.1.20";
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"]);