@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.
- package/bin/rtc-agent-setup.js +30 -23
- package/package.json +5 -5
package/bin/rtc-agent-setup.js
CHANGED
|
@@ -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
|
-
//
|
|
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
|
-
|
|
106
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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:
|
|
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
|
|
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.
|
|
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/
|
|
37
|
-
"@rtc-agent/
|
|
38
|
-
"@rtc-agent/
|
|
39
|
-
"@rtc-agent/
|
|
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",
|