feat(plugin): 目录插件支持自带 styles.css(sync 拷贝+manifest.style);gallery 1.5.0 上架
This commit is contained in:
1 parent
f02f18863a
commit
a4aaa547a7
6 files changed
+114
-36
No files matched your search
@@ -14,7 +14,7 @@ const IDS = ['batch-export', 'blank-canvas', 'browser', 'gallery', 'image-annota
|
||||
// v3.25.41(M1):目录化插件试点 —— 这些 id 产出 <id>/{manifest.json,main.js},其余仍是单文件(双轨兼容)
|
||||
// ⚠️ 2026-11-20 修正:桌面包不随包发插件(scripts/strip-plugins.js),插件只能从市场装,
|
||||
// 而市场目前只支持单文件 ⇒ 目录形态暂不用于生产插件,等 M3(zip 安装)落地再启用。
|
||||
const FOLDER_IDS = []
|
||||
const FOLDER_IDS = ['gallery']
|
||||
|
||||
const sha = (buf) => crypto.createHash('sha256').update(buf).digest()
|
||||
const shaHex = (buf) => sha(buf).toString('hex')
|
||||
@@ -39,17 +39,29 @@ for (const id of IDS) {
|
||||
const mainPath = path.join(dir, 'main.js')
|
||||
if (!fs.existsSync(mainPath) || shaHex(fs.readFileSync(mainPath)) !== shaHex(buf)) { fs.writeFileSync(mainPath, buf); copied++ }
|
||||
const meta = metaAll[id] || {}
|
||||
// 可选 styles.css:插件自带样式(宿主 CSS 只在客户端发版时更新,视觉调整走插件更灵活)
|
||||
const files = { 'main.js': shaHex(buf) }
|
||||
let styleName = ''
|
||||
const styleSrc = path.join(srcRoot, id, 'styles.css')
|
||||
if (fs.existsSync(styleSrc)) {
|
||||
const sbuf = fs.readFileSync(styleSrc)
|
||||
const styleDest = path.join(dir, 'styles.css')
|
||||
if (!fs.existsSync(styleDest) || shaHex(fs.readFileSync(styleDest)) !== shaHex(sbuf)) { fs.writeFileSync(styleDest, sbuf); copied++ }
|
||||
styleName = 'styles.css'
|
||||
files['styles.css'] = shaHex(sbuf)
|
||||
}
|
||||
const manifestJson = {
|
||||
id: id,
|
||||
name: meta.name || id,
|
||||
version: pkg.version,
|
||||
apiVersion: Number((pkg.ibwPlugin && pkg.ibwPlugin.apiVersion) || 1),
|
||||
main: 'main.js',
|
||||
...(styleName ? { style: styleName } : {}),
|
||||
description: meta.desc || '',
|
||||
author: meta.author || 'official',
|
||||
icon: meta.icon || '',
|
||||
tags: Array.isArray(meta.tags) ? meta.tags : [],
|
||||
files: { 'main.js': shaHex(buf) },
|
||||
files: files,
|
||||
}
|
||||
fs.writeFileSync(path.join(dir, 'manifest.json'), JSON.stringify(manifestJson, null, 2) + '\n')
|
||||
// 同 id 的旧单文件产物清理(目录优先,留着会造成两份)
|
||||
|
||||
Reference in new issue
Block a user