@rtc-agent/component 0.2.6-rc.0 → 0.2.6-rc.1

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.
@@ -16,7 +16,7 @@
16
16
  * }
17
17
  */
18
18
 
19
- import { existsSync, mkdirSync, copyFileSync, readFileSync, readdirSync, writeFileSync } from 'fs';
19
+ import { existsSync, mkdirSync, copyFileSync, readFileSync, readdirSync, writeFileSync, unlinkSync } from 'fs';
20
20
  import { join, dirname } from 'path';
21
21
  import { fileURLToPath } from 'url';
22
22
 
@@ -92,7 +92,23 @@ function copyWorkerFiles(targetDir) {
92
92
  console.log(`📁 Created directory: ${targetDir}`);
93
93
  }
94
94
 
95
- // Find and copy shared-worker files
95
+ // Clean up old hashed worker files
96
+ const existingFiles = existsSync(targetDir) ? readdirSync(targetDir) : [];
97
+ const oldWorkerFiles = existingFiles.filter(
98
+ f => f.startsWith('shared-worker-') && f.endsWith('.js') && f !== 'shared-worker.js'
99
+ );
100
+
101
+ for (const oldFile of oldWorkerFiles) {
102
+ const oldPath = join(targetDir, oldFile);
103
+ try {
104
+ unlinkSync(oldPath);
105
+ console.log(`🗑️ Removed old: ${oldFile}`);
106
+ } catch (err) {
107
+ console.warn(`⚠️ Could not remove ${oldFile}: ${err.message}`);
108
+ }
109
+ }
110
+
111
+ // Find the main worker file in dist
96
112
  const distFiles = readdirSync(sourceDir);
97
113
  const workerFiles = distFiles.filter(f => f.startsWith('shared-worker') && f.endsWith('.js'));
98
114
 
@@ -102,28 +118,19 @@ function copyWorkerFiles(targetDir) {
102
118
  return 0;
103
119
  }
104
120
 
105
- let copiedCount = 0;
106
- let mainWorkerFile = null;
121
+ // Find the hashed worker file
122
+ const hashedWorkerFile = workerFiles.find(f => f !== 'shared-worker.js' && f.match(/shared-worker-[A-Za-z0-9]+\.js/));
107
123
 
108
- for (const file of workerFiles) {
109
- const sourcePath = join(sourceDir, file);
110
- const targetPath = join(targetDir, file);
111
- copyFileSync(sourcePath, targetPath);
112
- console.log(`✅ Copied ${file} → ${targetDir}`);
113
- copiedCount++;
114
-
115
- // Track the main worker file (without .map or other extensions)
116
- if (file.endsWith('.js') && !file.includes('.map')) {
117
- mainWorkerFile = file;
118
- }
124
+ if (!hashedWorkerFile) {
125
+ console.warn('⚠️ Warning: No hashed worker file found');
126
+ return 0;
119
127
  }
120
128
 
121
- // Create a stable symlink or copy without hash for easy reference
122
- if (mainWorkerFile && mainWorkerFile !== 'shared-worker.js') {
123
- const stablePath = join(targetDir, 'shared-worker.js');
124
- copyFileSync(join(targetDir, mainWorkerFile), stablePath);
125
- console.log(`✅ Created stable link: shared-worker.js → ${mainWorkerFile}`);
126
- }
129
+ // Copy as shared-worker.js (stable name, no hash)
130
+ const sourcePath = join(sourceDir, hashedWorkerFile);
131
+ const targetPath = join(targetDir, 'shared-worker.js');
132
+ copyFileSync(sourcePath, targetPath);
133
+ console.log(`✅ Copied ${hashedWorkerFile} → shared-worker.js`);
127
134
 
128
135
  // Create manifest.json with version info
129
136
  const packageJsonPath = join(__dirname, '..', 'package.json');
@@ -131,7 +138,7 @@ function copyWorkerFiles(targetDir) {
131
138
 
132
139
  const manifest = {
133
140
  version: packageJson.version,
134
- workerFile: mainWorkerFile,
141
+ workerFile: 'shared-worker.js',
135
142
  stableWorkerUrl: '/rtc-agent/shared-worker.js',
136
143
  timestamp: new Date().toISOString(),
137
144
  };
@@ -142,7 +149,7 @@ function copyWorkerFiles(targetDir) {
142
149
  );
143
150
  console.log(`✅ Created manifest.json (version ${packageJson.version})`);
144
151
 
145
- return copiedCount;
152
+ return 1;
146
153
  }
147
154
 
148
155
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-agent/component",
3
- "version": "0.2.6-rc.0",
3
+ "version": "0.2.6-rc.1",
4
4
  "description": "RTC Agent Web Components(基于 Lit)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -33,10 +33,10 @@
33
33
  "lit": "^3.1.0",
34
34
  "marked": "^18.0.11",
35
35
  "zod": "^3.23.8",
36
- "@rtc-agent/client": "0.2.6-rc.0",
37
- "@rtc-agent/persistence": "0.2.6-rc.0",
38
- "@rtc-agent/worker": "0.2.6-rc.0",
39
- "@rtc-agent/protocol": "0.2.6-rc.0"
36
+ "@rtc-agent/persistence": "0.2.6-rc.1",
37
+ "@rtc-agent/protocol": "0.2.6-rc.1",
38
+ "@rtc-agent/client": "0.2.6-rc.1",
39
+ "@rtc-agent/worker": "0.2.6-rc.1"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@lit/localize-tools": "^0.8.2",