Skip to content

Commit 3e83f9b

Browse files
committed
fix(plugins): excel-parser lib/ 404, docs, v1.0.2
- Fix BUNDLED_PLUGINS_DIR path for local dev (Plugins at project root) - Install from URL now downloads lib/ when manifest dependencies reference lib - Update Plugins README: market install auto-downloads lib, commit lib/ to repo - excel-parser: bump to 1.0.2
1 parent 19f573a commit 3e83f9b

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed

Plugins/Plugin_market/excel-parser/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* - Multi-sheet support with statistics
1212
* - Offline-ready with bundled SheetJS
1313
*
14-
* @version 1.0.1
14+
* @version 1.0.2
1515
* @author ChatRaw
1616
* @license Apache-2.0
1717
*/
@@ -672,6 +672,6 @@
672672
});
673673

674674
// Log successful initialization
675-
console.log('[ExcelParser Pro] Plugin loaded successfully (v1.0.1)');
675+
console.log('[ExcelParser Pro] Plugin loaded successfully (v1.0.2)');
676676

677677
})(window.ChatRawPlugin);

Plugins/Plugin_market/excel-parser/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "excel-parser",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"name": {
55
"en": "Excel Parser Pro",
66
"zh": "Excel 增强解析器"

Plugins/Plugin_market/index.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
},
5353
{
5454
"id": "excel-parser",
55-
"version": "1.0.1",
55+
"version": "1.0.2",
5656
"name": {
5757
"en": "Excel Parser Pro",
5858
"zh": "Excel 增强解析器"

Plugins/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ your-plugin/
2525
└── library.min.css
2626
```
2727

28-
**Local Dependencies (lib/ directory)**: For fully offline plugins, you can bundle dependencies locally instead of loading from CDN. Files in the `lib/` directory are served via `/api/plugins/{plugin_id}/lib/{filename}`. Subdirectories are supported (e.g., `lib/fonts/`).
28+
**Local Dependencies (lib/ directory)**: For fully offline plugins, you can bundle dependencies locally instead of loading from CDN. Files in the `lib/` directory are served via `/api/plugins/{plugin_id}/lib/{filename}`. Subdirectories are supported (e.g., `lib/fonts/`). When users install from the plugin market, lib files referenced in manifest `dependencies` (format: `/api/plugins/{plugin_id}/lib/{filename}`) are automatically downloaded. **Ensure your `lib/` folder is committed to the repository.**
2929

3030
### manifest.json
3131

@@ -959,7 +959,7 @@ your-plugin/
959959
└── library.min.css
960960
```
961961
962-
**本地依赖 (lib/ 目录)**:对于需要完全离线运行的插件,可以将依赖库打包到本地,而不是从 CDN 加载。`lib/` 目录下的文件通过 `/api/plugins/{plugin_id}/lib/{filename}` 提供访问。支持子目录(如 `lib/fonts/`)。
962+
**本地依赖 (lib/ 目录)**:对于需要完全离线运行的插件,可以将依赖库打包到本地,而不是从 CDN 加载。`lib/` 目录下的文件通过 `/api/plugins/{plugin_id}/lib/{filename}` 提供访问。支持子目录(如 `lib/fonts/`)。从插件市场安装时,manifest 中 `dependencies` 引用的 lib 文件(格式:`/api/plugins/{plugin_id}/lib/{filename}`)会自动下载。**请确保将 `lib/` 目录提交到仓库。**
963963
964964
### manifest.json
965965

backend/main.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,13 @@ async def parse_url(request: ParseUrlRequest):
17101710
os.makedirs(PLUGINS_INSTALLED_DIR, exist_ok=True)
17111711

17121712
# Auto-install bundled plugins with lib/ directory (offline dependencies)
1713-
BUNDLED_PLUGINS_DIR = os.path.join(os.path.dirname(__file__), "Plugins", "Plugin_market")
1713+
# Resolve path: Docker has /app/Plugins, local dev has Plugins at project root (sibling of backend/)
1714+
_backend_dir = os.path.dirname(os.path.abspath(__file__))
1715+
_candidates = [
1716+
os.path.join(_backend_dir, "Plugins", "Plugin_market"),
1717+
os.path.abspath(os.path.join(_backend_dir, "..", "Plugins", "Plugin_market")),
1718+
]
1719+
BUNDLED_PLUGINS_DIR = next((p for p in _candidates if os.path.exists(p)), _candidates[0])
17141720

17151721
def auto_install_bundled_plugins():
17161722
"""Auto-copy lib/ directory for installed plugins with offline dependencies
@@ -1959,6 +1965,27 @@ async def install_plugin(request: PluginInstallRequest):
19591965
f.write(icon_content)
19601966
except Exception:
19611967
pass # Icon is optional
1968+
1969+
# Download lib/ files for dependencies (e.g. /api/plugins/excel-parser/lib/xlsx.full.min.js -> lib/xlsx.full.min.js)
1970+
deps = manifest.get("dependencies") or {}
1971+
lib_prefix = f"/api/plugins/{plugin_id}/lib/"
1972+
for dep_name, dep_url in deps.items():
1973+
if isinstance(dep_url, str) and dep_url.startswith(lib_prefix):
1974+
lib_path = dep_url[len(lib_prefix):].strip("/")
1975+
if not lib_path or ".." in lib_path:
1976+
continue
1977+
lib_url = f"{source_url}/lib/{lib_path}"
1978+
try:
1979+
async with session.get(lib_url, timeout=aiohttp.ClientTimeout(total=30)) as resp:
1980+
if resp.status == 200:
1981+
lib_target = os.path.join(plugin_dir, "lib", lib_path)
1982+
os.makedirs(os.path.dirname(lib_target), exist_ok=True)
1983+
content = await resp.read()
1984+
with open(lib_target, "wb") as f:
1985+
f.write(content)
1986+
logger.info(f"Downloaded lib for {plugin_id}: {lib_path}")
1987+
except Exception as e:
1988+
logger.warning(f"Failed to download lib {lib_path} for {plugin_id}: {e}")
19621989

19631990
# Add to config
19641991
config = load_plugin_config()

0 commit comments

Comments
 (0)