@aiyiran/myclaw 1.0.220 → 1.0.222
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/assets/myclaw-artifacts.js +6 -4
- package/package.json +1 -1
- package/patches/patch.js +22 -11
|
@@ -285,10 +285,9 @@
|
|
|
285
285
|
row.onclick = function () {
|
|
286
286
|
if (isLatest && !isLatestSeen) localStorage.setItem(latestSeenKey, '1');
|
|
287
287
|
if (isUpdated && !isUpdateSeen) localStorage.setItem(updateSeenKey, '1');
|
|
288
|
+
openPreviewModal(data, asset);
|
|
288
289
|
if (asset.type === 'html') {
|
|
289
290
|
window.open(buildPreviewUrl(data, asset.path), '_blank');
|
|
290
|
-
} else {
|
|
291
|
-
openPreviewModal(data, asset);
|
|
292
291
|
}
|
|
293
292
|
};
|
|
294
293
|
|
|
@@ -416,6 +415,9 @@
|
|
|
416
415
|
function openPublishModal() {
|
|
417
416
|
if (document.querySelector('#myclaw-artifacts-publish-modal')) return;
|
|
418
417
|
if (!cachedData) return;
|
|
418
|
+
console.log('[myclaw-artifacts-publish] cachedData.assets:', cachedData.assets);
|
|
419
|
+
console.log('[myclaw-artifacts-publish] html assets:', cachedData.assets.filter(function (a) { return a.type && a.type.toLowerCase() === 'html'; }));
|
|
420
|
+
console.log('[myclaw-artifacts-publish] image assets:', cachedData.assets.filter(function (a) { return a.type && a.type.toLowerCase() === 'image'; }));
|
|
419
421
|
|
|
420
422
|
var overlay = document.createElement('div');
|
|
421
423
|
overlay.id = 'myclaw-artifacts-publish-modal';
|
|
@@ -505,7 +507,7 @@
|
|
|
505
507
|
coverDefaultOpt.value = '';
|
|
506
508
|
coverDefaultOpt.textContent = '\u4E0D\u9009\u62E9';
|
|
507
509
|
coverSelect.appendChild(coverDefaultOpt);
|
|
508
|
-
var imageAssets = (cachedData.assets || []).filter(function (a) { return a.type === 'image'; });
|
|
510
|
+
var imageAssets = (cachedData.assets || []).filter(function (a) { return a.type && a.type.toLowerCase() === 'image'; });
|
|
509
511
|
imageAssets.forEach(function (asset) {
|
|
510
512
|
var opt = document.createElement('option');
|
|
511
513
|
opt.value = asset.path;
|
|
@@ -543,7 +545,7 @@
|
|
|
543
545
|
entryDefaultOpt.value = '';
|
|
544
546
|
entryDefaultOpt.textContent = '\u4E0D\u9009\u62E9';
|
|
545
547
|
entrySelect.appendChild(entryDefaultOpt);
|
|
546
|
-
var htmlAssets = (cachedData.assets || []).filter(function (a) { return a.type === 'html'; });
|
|
548
|
+
var htmlAssets = (cachedData.assets || []).filter(function (a) { return a.type && a.type.toLowerCase() === 'html'; });
|
|
547
549
|
htmlAssets.forEach(function (asset) {
|
|
548
550
|
var opt = document.createElement('option');
|
|
549
551
|
opt.value = asset.path;
|
package/package.json
CHANGED
package/patches/patch.js
CHANGED
|
@@ -230,11 +230,14 @@ function patch() {
|
|
|
230
230
|
const filePath = path.join(distParent, f);
|
|
231
231
|
let content = fs.readFileSync(filePath, 'utf8');
|
|
232
232
|
|
|
233
|
-
// 检查是否需要 patch
|
|
233
|
+
// 检查是否需要 patch(分别检测每项,避免部分已 patch 导致整体跳过)
|
|
234
234
|
const needsMicrophonePatch = content.includes('microphone=()');
|
|
235
|
-
const
|
|
235
|
+
const needsFrameSrc = !content.includes('"frame-src');
|
|
236
|
+
const needsConnectSrc = content.includes('"connect-src \'self\' ws: wss:"');
|
|
237
|
+
const needsFrameAncestors = content.includes('"frame-ancestors \'none\'"');
|
|
238
|
+
const needsAnyCspPatch = needsFrameSrc || needsConnectSrc || needsFrameAncestors;
|
|
236
239
|
|
|
237
|
-
if (needsMicrophonePatch ||
|
|
240
|
+
if (needsMicrophonePatch || needsAnyCspPatch) {
|
|
238
241
|
// 备份
|
|
239
242
|
const backupFile = filePath + BACKUP_SUFFIX;
|
|
240
243
|
if (!fs.existsSync(backupFile)) {
|
|
@@ -251,31 +254,39 @@ function patch() {
|
|
|
251
254
|
}
|
|
252
255
|
|
|
253
256
|
// Patch 2: CSP - 在 buildControlUiCspHeader 的 CSP 数组中放宽限制
|
|
254
|
-
|
|
255
|
-
//
|
|
256
|
-
if (
|
|
257
|
-
// 添加 frame-src 指令(允许 iframe 加载外部 https 资源)
|
|
257
|
+
const cspPatches = [];
|
|
258
|
+
// 添加 frame-src 指令(允许 iframe 加载外部 https 资源)
|
|
259
|
+
if (needsFrameSrc) {
|
|
258
260
|
content = content.replace(
|
|
259
261
|
'"default-src \'self\'"',
|
|
260
262
|
'"default-src \'self\'",\n\t\t"frame-src \'self\' https:"'
|
|
261
263
|
);
|
|
262
|
-
|
|
264
|
+
cspPatches.push('frame-src');
|
|
265
|
+
}
|
|
266
|
+
// 放开 connect-src,允许 fetch/XHR 到外部 https API
|
|
267
|
+
if (needsConnectSrc) {
|
|
263
268
|
content = content.replace(
|
|
264
269
|
'"connect-src \'self\' ws: wss:"',
|
|
265
270
|
'"connect-src \'self\' https: ws: wss:"'
|
|
266
271
|
);
|
|
267
|
-
|
|
272
|
+
cspPatches.push('connect-src');
|
|
273
|
+
}
|
|
274
|
+
// 放开 frame-ancestors,允许被外部 https 页面嵌入
|
|
275
|
+
if (needsFrameAncestors) {
|
|
268
276
|
content = content.replace(
|
|
269
277
|
'"frame-ancestors \'none\'"',
|
|
270
278
|
'"frame-ancestors \'self\' https:"'
|
|
271
279
|
);
|
|
272
|
-
|
|
280
|
+
cspPatches.push('frame-ancestors');
|
|
281
|
+
}
|
|
282
|
+
if (cspPatches.length > 0) {
|
|
283
|
+
console.log('[myclaw-patch] ✅ 已修复 CSP (' + cspPatches.join(', ') + '): ' + f);
|
|
273
284
|
}
|
|
274
285
|
|
|
275
286
|
fs.writeFileSync(filePath, content, 'utf8');
|
|
276
287
|
patched = true;
|
|
277
288
|
} else {
|
|
278
|
-
console.log('[myclaw-patch] ✅ Permissions-Policy
|
|
289
|
+
console.log('[myclaw-patch] ✅ Permissions-Policy 和 CSP 已是允许状态 (无需修改): ' + f);
|
|
279
290
|
patched = true;
|
|
280
291
|
}
|
|
281
292
|
}
|