From fe7b1669ed2bd1b6d2e9f57ae944a44106ff4662 Mon Sep 17 00:00:00 2001 From: jiang66-so Date: Thu, 3 Dec 2026 17:59:20 +0800 Subject: [PATCH] Update plugin LX Music v0.1.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - feat: scaffold LX Music ZTools plugin and release tooling - test: verify host loading and prepare official draft publishing - test: cover production ZIP installation in isolated ZTools - fix: use authenticated gh transport for GitHub API on Windows - docs: include upstream attribution and verified framework screenshot - feat: verify native source isolation and ZTools P0 lifecycle - feat: adapt original LX data services and event contracts - feat: run original LX UI and isolated custom source requests - feat: enable native playback and verified local plugin installation - 发布准备:去除 LX 窗口装饰并更新至 0.0.2 开发版 - 修复:适配插件中心 Node 20 的样式构建依赖 - 文档:更新 0.0.2 发布验证范围与上游归属 - 修复:兼容 Windows 下更新已有插件 PR 的 Git 参数引用 - feat: port resumable downloads and metadata - fix: preload download dependencies before UI calls - fix: inject isolated metadata executor for native host - fix: normalize empty audio metadata fields - fix: verify download file identity before recovery and cleanup - 功能:接通下载最终化、开放 API 与事务备份 - feat: preserve LX sync client and server protocol - fix: serialize download cancellation with finalization commits - fix: serialize sync snapshot maintenance and cancellation - fix: ignore stale download URL and startup failures - fix: order sync retries and cancel stale startup preflight - 功能:完成桌面歌词、宿主指令与独立安装包 - 修复歌词尺寸 RPC 异步错误处理 - 串行处理歌词尺寸应用与失败对账 - 文档:交付完整移植包与分层验收记录 - fix: 保持标准音源请求编码与二进制类型契约 - fix: 防止歌词窗口旧轮询覆盖新操作 - fix: 在同步认证应答前原子持久化授权状态 - 文档:记录最终复核修复与新包验收结果 - 完成设置逐项修复与字号缩放,提交 0.1.2 市场更新 - fix: 兼容缺少内置 SQLite 的 ZTools 宿主 --- plugins/lx-music-ztools/CHANGELOG.md | 5 + plugins/lx-music-ztools/README.md | 4 +- .../build-config/ztools/package.cjs | 7 +- .../docs/ztools/host-capabilities.md | 2 +- .../docs/ztools/installation.md | 6 +- plugins/lx-music-ztools/package-lock.json | 4 +- plugins/lx-music-ztools/package.json | 2 +- .../lx-music-ztools/scripts/build-notices.mjs | 3 + .../src-ztools/THIRD-PARTY-NOTICES.txt | 281 ++++++++++++++++++ .../lx-music-ztools/src-ztools/plugin.json | 2 +- .../src-ztools/preload/package-lock.json | 165 ++++++++++ .../src-ztools/preload/package.json | 1 + .../src-ztools/preload/probes.cjs | 7 +- .../src-ztools/preload/runtime/database.cjs | 57 +++- .../preload/runtime/metadata-parser.cjs | 18 +- .../preload/runtime/metadata-parser.mjs | 10 + 16 files changed, 537 insertions(+), 37 deletions(-) create mode 100644 plugins/lx-music-ztools/src-ztools/preload/runtime/metadata-parser.mjs diff --git a/plugins/lx-music-ztools/CHANGELOG.md b/plugins/lx-music-ztools/CHANGELOG.md index bffa204d1..0b215a0ca 100644 --- a/plugins/lx-music-ztools/CHANGELOG.md +++ b/plugins/lx-music-ztools/CHANGELOG.md @@ -1,5 +1,10 @@ # 更新日志 +## 0.1.3 - 2026-12-03 + +- 修复 Windows x64 上部分 ZTools 宿主缺少 `node:sqlite` 时 LX Music 无法启动的问题。安装包自带 SQLite 兼容驱动,继续使用原有的本地曲库文件和事务。 +- 兼容不能通过 CommonJS 加载 ESM 的宿主,保留本地音乐标签读取。 + ## 0.1.2 - 2026-11-11 - 修复“字体大小”只更新根字号、正文和搜索框仍固定像素的问题:恢复上游PostCSS px→rem构建规则,同时保持文字层级及配套间距缩放。 diff --git a/plugins/lx-music-ztools/README.md b/plugins/lx-music-ztools/README.md index 3f3af8aee..255bb5a73 100644 --- a/plugins/lx-music-ztools/README.md +++ b/plugins/lx-music-ztools/README.md @@ -1,6 +1,6 @@ # LX Music for ZTools -LX Music 2.12.6 的第三方 ZTools 原生移植,目标版本 **0.1.2**。保留原 LX 界面、播放器、音源管理、搜索、列表、下载与同步流程,业务服务运行在插件中,无需另装或启动 LX 桌面应用。此项目不是 LX 官方发行版,不附带第三方音源。 +LX Music 2.12.6 的第三方 ZTools 原生移植,目标版本 **0.1.3**。保留原 LX 界面、播放器、音源管理、搜索、列表、下载与同步流程,业务服务运行在插件中,无需另装或启动 LX 桌面应用。此项目不是 LX 官方发行版,不附带第三方音源。 Windows x64 为首验平台。当前已验证原播放器、本地 MP3/FLAC/WAV 与 DSP、受控搜索/榜单/歌单、下载与标签、备份、原桌面歌词、开放 API,以及与官方 LX 2.12.6 的双向同步。真实用户音源样本中已完成一次真实播放和下载;这些结果有明确范围,不能推导所有源或平台均可用。**核心播放/下载检查点已通过30分钟后台与50次进出测试;最终ZIP回归另记。0.1.2通过源码仓库及ZTools插件中心更新流程提交,市场版本以审核合并结果为准。** 完整矩阵见 [功能与验证状态](docs/ztools/compatibility.md)。 @@ -12,7 +12,7 @@ npm run build:ztools npm run pack:ztools ``` -目标 ZIP 为 `dist-ztools/lx-music-ztools-0.1.2.zip`,校验值保存到同名 `.zip.sha256`。版本以包内 `plugin.json` 为准,构建回执为 `build-info.json`。相同构建输入按固定顺序和时间戳打包,可比较 ZIP SHA256;不承诺不同机器或依赖版本产生相同字节。 +目标 ZIP 为 `dist-ztools/lx-music-ztools-0.1.3.zip`,校验值保存到同名 `.zip.sha256`。版本以包内 `plugin.json` 为准,构建回执为 `build-info.json`。相同构建输入按固定顺序和时间戳打包,可比较 ZIP SHA256;不承诺不同机器或依赖版本产生相同字节。 在 ZTools「设置 → 插件应用 → 导入本地插件」选择 ZIP,确认安装并启用,输入「洛雪音乐」「LX Music」或 `lxmusic` 打开。也可把 `src-ztools/plugin.json` 注册为开发项目后安装。隔离测试实例中的安装记录不会自动出现在日常实例。播放器入口是 `dist/lx.html`,运行包包含独立依赖,不需要开发服务器或源码目录的 `node_modules`。 diff --git a/plugins/lx-music-ztools/build-config/ztools/package.cjs b/plugins/lx-music-ztools/build-config/ztools/package.cjs index 9d8e5498a..6cdc7cf54 100644 --- a/plugins/lx-music-ztools/build-config/ztools/package.cjs +++ b/plugins/lx-music-ztools/build-config/ztools/package.cjs @@ -3,7 +3,8 @@ const path = require('node:path') const assert = require('node:assert/strict') const { createHash } = require('node:crypto') const allowed = ['plugin.json', 'logo.png', 'LICENSE', 'NOTICE', 'THIRD-PARTY-NOTICES.txt', 'native-jobs.html', 'dist', 'preload'] -const required = ['plugin.json', 'logo.png', 'LICENSE', 'NOTICE', 'THIRD-PARTY-NOTICES.txt', 'native-jobs.html', 'dist/lx.html', 'dist/lyric.html', 'dist/lx-assets.json', 'dist/source-worker.js', 'dist/pitch_shifter.audioWorklet.js', 'preload/services.js', 'preload/lyric.cjs', 'preload/native-jobs.cjs', 'preload/runtime/index.cjs', 'preload/package-lock.json'] +const sqliteBinding = 'preload/node_modules/@libsql/win32-x64-msvc/index.node' +const required = ['plugin.json', 'logo.png', 'LICENSE', 'NOTICE', 'THIRD-PARTY-NOTICES.txt', 'native-jobs.html', 'dist/lx.html', 'dist/lyric.html', 'dist/lx-assets.json', 'dist/source-worker.js', 'dist/pitch_shifter.audioWorklet.js', 'preload/services.js', 'preload/lyric.cjs', 'preload/native-jobs.cjs', 'preload/runtime/index.cjs', 'preload/package-lock.json', sqliteBinding] function hash(file) { return createHash('sha256').update(fs.readFileSync(file)).digest('hex') } function walk(root, prefix = '') { return fs.readdirSync(path.join(root, prefix), { withFileTypes: true }).flatMap(entry => { @@ -23,7 +24,7 @@ function verifyPackage(root, { receipt = true } = {}) { const assets = JSON.parse(fs.readFileSync(path.join(root, 'dist/lx-assets.json'), 'utf8')) for (const file of assets) assert.ok(fs.existsSync(path.join(root, 'dist', file)), '缺少前端资源:' + file) const files = walk(root) - assert.ok(!files.some(file => /\.(?:node|sqlite(?:-wal|-shm)?|part)$/i.test(file)), '安装包含原生二进制或用户数据') + assert.ok(!files.some(file => file !== sqliteBinding && /\.(?:node|sqlite(?:-wal|-shm)?|part)$/i.test(file)), '安装包含未声明的原生二进制或用户数据') const runtime = path.join(root, 'preload') const findDependency = (from, name) => { let directory = from @@ -59,7 +60,7 @@ function assemble({ source, destination }) { for (const file of allowed) copy(path.join(source, file), path.join(destination, file)) const files = verifyPackage(destination, { receipt: false }).sort() const manifest = JSON.parse(fs.readFileSync(path.join(destination, 'plugin.json'), 'utf8')) - fs.writeFileSync(path.join(destination, 'build-info.json'), JSON.stringify({ plugin: { name: manifest.name, version: manifest.version }, upstream: { version: '2.12.6', baseline: '323e4bac' }, runtime: { sqlite: 'node:sqlite', standalone: true }, files: Object.fromEntries(files.map(file => [file, hash(path.join(destination, file))])) }, null, 2)) + fs.writeFileSync(path.join(destination, 'build-info.json'), JSON.stringify({ plugin: { name: manifest.name, version: manifest.version }, upstream: { version: '2.12.6', baseline: '323e4bac' }, runtime: { sqlite: 'node:sqlite', sqliteFallback: 'libsql (Windows x64)', standalone: true }, files: Object.fromEntries(files.map(file => [file, hash(path.join(destination, file))])) }, null, 2)) verifyPackage(destination) return { root: destination, files: files.length, manifest } } diff --git a/plugins/lx-music-ztools/docs/ztools/host-capabilities.md b/plugins/lx-music-ztools/docs/ztools/host-capabilities.md index fb76f43af..f3da4be50 100644 --- a/plugins/lx-music-ztools/docs/ztools/host-capabilities.md +++ b/plugins/lx-music-ztools/docs/ztools/host-capabilities.md @@ -6,7 +6,7 @@ | --- | --- | --- | | 音乐窗口 | 单实例插件视图,保留原 LX UI;窗口大小/全屏/分离/关闭由宿主管理 | 不复制原 LX 独立应用窗口、托盘和更新器;主页面桌面窗口按钮隐藏 | | 生命周期 | 进入/重入复用实例;隐藏保持播放器和已启用服务;终止清理 | 核心服务已通过41.4.0下30分钟/50次往返;宿主退出/终止不继续播放 | -| 设备本地存储 | `getPath('pluginData')` + 内置 `node:sqlite`,复用原 SQL 模型 | 不附带 better-sqlite3 原生二进制,不依赖 ZTools 账号云数据库;旧宿主需实际能力检测 | +| 设备本地存储 | `getPath('pluginData')` 中的同一个 SQLite 文件。优先使用内置 `node:sqlite`,Windows x64 宿主缺少该能力时使用随包提供的 libSQL 驱动 | 曲库保存在当前设备,跨设备通过 LX 同步或备份迁移 | | 文件操作 | 公开文件/目录对话框授予 canonical 路径能力,可信 preload 操作 | 不把全部硬盘读写权交给音源;导入备份的路径需重新授权 | | 音源 | 可信 loopback frame 创建 CSP 浏览器 Worker,HTTP/取消走消息桥 | 无 Node/宿主 API/DOM;禁止把原始用户音源放进仓库、产品包或第三方许可文件 | | 下载与元数据 | 本地 hard link/rename 与身份校验;隐藏、宿主拥有的临时窗口运行 metadata job | 所有新下载需 hard link;临时元数据窗口不执行用户音源,不能把附加 renderer 算另一个播放器 | diff --git a/plugins/lx-music-ztools/docs/ztools/installation.md b/plugins/lx-music-ztools/docs/ztools/installation.md index f4b742474..2f1ab0bda 100644 --- a/plugins/lx-music-ztools/docs/ztools/installation.md +++ b/plugins/lx-music-ztools/docs/ztools/installation.md @@ -1,11 +1,11 @@ # 安装、使用与数据迁移 -适用目标:0.1.2,Windows x64,第三方原生移植版。实际宿主验证组合及尚未完成的项目见 [兼容矩阵](compatibility.md)。当前版本不作市场已上架声明。 +适用目标:0.1.3,Windows x64,第三方原生移植版。实际宿主验证组合及尚未完成的项目见 [兼容矩阵](compatibility.md)。 ## 安装本地包 1. 源码构建执行 `npm ci`、`npm run build:ztools`、`npm run pack:ztools`。构建安装插件独立运行依赖并检查资源与许可。 -2. 在 `dist-ztools/` 找到 `lx-music-ztools-0.1.2.zip` 及 `.zip.sha256`。用 `Get-FileHash -Algorithm SHA256` 比对旁边校验值;包内 `build-info.json` 记录文件清单与逐文件 SHA256。 +2. 在 `dist-ztools/` 找到 `lx-music-ztools-0.1.3.zip` 及 `.zip.sha256`。用 `Get-FileHash -Algorithm SHA256` 比对旁边校验值。包内 `build-info.json` 记录文件清单与逐文件 SHA256。 3. 打开 ZTools「设置 → 插件应用 → 导入本地插件」,选择 ZIP,确认安装、启用。 4. 搜索 `lxmusic`、「LX Music」或「洛雪音乐」打开。首次阅读并接受原使用协议,再导入自己的音源。 @@ -13,7 +13,7 @@ 从旧版更新后,终止当前已打开的LX插件,再通过`lxmusic`重新进入,确保加载新样式。0.1.2恢复了六档字体大小的实际文字缩放,旧页面不会自动替换内存中的样式。 -运行包自带 `preload/node_modules`,不依赖开发目录或另装 LX 桌面版。不支持内置 `node:sqlite` 或缺少所需公开 API 的宿主会报告错误;当前不承诺所有旧版 ZTools 兼容。 +运行包自带 `preload/node_modules`。宿主缺少可用的 `node:sqlite` 时,插件加载随包提供的 Windows x64 SQLite 兼容驱动,继续读写同一个 `lx-ztools.data.sqlite` 文件。 ## 导入与选择音源 diff --git a/plugins/lx-music-ztools/package-lock.json b/plugins/lx-music-ztools/package-lock.json index 9bf7a2263..881a5a056 100644 --- a/plugins/lx-music-ztools/package-lock.json +++ b/plugins/lx-music-ztools/package-lock.json @@ -1,12 +1,12 @@ { "name": "lx-music-ztools", - "version": "0.1.2", + "version": "0.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lx-music-ztools", - "version": "0.1.2", + "version": "0.1.3", "dependencies": { "@simonwep/pickr": "^1.9.1", "buffer": "^6.0.3", diff --git a/plugins/lx-music-ztools/package.json b/plugins/lx-music-ztools/package.json index aeaa4b6bf..70d8ba840 100644 --- a/plugins/lx-music-ztools/package.json +++ b/plugins/lx-music-ztools/package.json @@ -1,6 +1,6 @@ { "name": "lx-music-ztools", - "version": "0.1.2", + "version": "0.1.3", "description": "LX Music native ZTools port with isolated custom sources, downloads and LX sync", "type": "module", "scripts": { diff --git a/plugins/lx-music-ztools/scripts/build-notices.mjs b/plugins/lx-music-ztools/scripts/build-notices.mjs index df2b8cf92..cc826b219 100644 --- a/plugins/lx-music-ztools/scripts/build-notices.mjs +++ b/plugins/lx-music-ztools/scripts/build-notices.mjs @@ -5,6 +5,7 @@ import { resolve, dirname, join, basename } from 'node:path' // source-worker tools. Runtime modules also retain their own original licenses. const packages = new Map() const missingLicenseFiles = { '@vue/devtools-api@6.6.4': 'build-config/ztools/licenses/vue-devtools-api-6.6.4.txt' } +const sqliteBinding = '@libsql/win32-x64-msvc' function locate(from, name) { let current = from while (true) { @@ -23,6 +24,7 @@ function collect(file) { if (Object.hasOwn(info.optionalDependencies || {}, name)) continue collect(locate(dirname(file), name)) } + if (info.name === 'libsql') collect(locate(dirname(file), sqliteBinding)) } for (const root of ['package.json', 'src-ztools/preload/package.json']) { const file = resolve(root), info = JSON.parse(readFileSync(file, 'utf8')) @@ -40,6 +42,7 @@ for (const [file, info] of packages) { const content = readme && readFileSync(join(dirname(file), readme.name), 'utf8') const license = content && /^#{1,6}\s+Licen[cs]e\s*$/im.exec(content) if (missingLicenseFiles[id]) texts.push(readFileSync(missingLicenseFiles[id], 'utf8').trim()) + else if (info.name === sqliteBinding) texts.push(readFileSync(join(dirname(locate(dirname(file), 'libsql')), 'LICENSE'), 'utf8').trim()) else if (license) texts.push(`--- ${readme.name} (License section) ---\n${content.slice(license.index).trim()}`) else throw new Error('Missing dependency license text: ' + id + ' (' + basename(dirname(file)) + ')') } diff --git a/plugins/lx-music-ztools/src-ztools/THIRD-PARTY-NOTICES.txt b/plugins/lx-music-ztools/src-ztools/THIRD-PARTY-NOTICES.txt index 4b136c638..335d0d45f 100644 --- a/plugins/lx-music-ztools/src-ztools/THIRD-PARTY-NOTICES.txt +++ b/plugins/lx-music-ztools/src-ztools/THIRD-PARTY-NOTICES.txt @@ -139,6 +139,56 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +===== @libsql/win32-x64-msvc@0.5.29 ===== +License: MIT +The MIT License (MIT) + +Copyright (c) 2017 Joshua Wise +Copyright (c) 2023 Pekka Enberg + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +===== @neon-rs/load@0.0.4 ===== +License: MIT +--- LICENSE --- +The MIT License (MIT) + +Copyright (c) 2023 David Herman + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + ===== @simonwep/pickr@1.9.1 ===== License: MIT --- LICENSE --- @@ -1376,6 +1426,211 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +===== detect-libc@2.0.2 ===== +License: Apache-2.0 +--- LICENSE --- +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ===== diffie-hellman@5.0.3 ===== License: MIT --- LICENSE --- @@ -2708,6 +2963,32 @@ necessary. Here is a sample; alter the names: That's all there is to it! +===== libsql@0.5.29 ===== +License: MIT +--- LICENSE --- +The MIT License (MIT) + +Copyright (c) 2017 Joshua Wise +Copyright (c) 2023 Pekka Enberg + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + ===== long@5.3.2 ===== License: Apache-2.0 --- LICENSE --- diff --git a/plugins/lx-music-ztools/src-ztools/plugin.json b/plugins/lx-music-ztools/src-ztools/plugin.json index eb48241b8..f413a2f2f 100644 --- a/plugins/lx-music-ztools/src-ztools/plugin.json +++ b/plugins/lx-music-ztools/src-ztools/plugin.json @@ -3,7 +3,7 @@ "title": "LX Music", "description": "LX Music 原生音乐播放器:自定义音源、搜索播放、歌单榜单、下载、LX 同步和开放 API", "author": "jiang66-so", - "version": "0.1.2", + "version": "0.1.3", "main": "dist/lx.html", "preload": "preload/services.js", "logo": "logo.png", diff --git a/plugins/lx-music-ztools/src-ztools/preload/package-lock.json b/plugins/lx-music-ztools/src-ztools/preload/package-lock.json index f6d536f30..01a80da93 100644 --- a/plugins/lx-music-ztools/src-ztools/preload/package-lock.json +++ b/plugins/lx-music-ztools/src-ztools/preload/package-lock.json @@ -9,6 +9,7 @@ "iconv-lite": "^0.7.3", "image-size": "1.1.0", "jschardet": "^3.1.4", + "libsql": "0.5.29", "message2call": "0.1.3", "music-metadata": "^11.15.0", "needle": "^3.3.1", @@ -27,6 +28,129 @@ "url": "https://github.com/sponsors/Borewit" } }, + "node_modules/@libsql/darwin-arm64": { + "version": "0.5.29", + "resolved": "https://registry.npmmirror.com/@libsql/darwin-arm64/-/darwin-arm64-0.5.29.tgz", + "integrity": "sha512-K+2RIB1OGFPYQbfay48GakLhqf3ArcbHqPFu7EZiaUcRgFcdw8RoltsMyvbj5ix2fY0HV3Q3Ioa/ByvQdaSM0A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@libsql/darwin-x64": { + "version": "0.5.29", + "resolved": "https://registry.npmmirror.com/@libsql/darwin-x64/-/darwin-x64-0.5.29.tgz", + "integrity": "sha512-OtT+KFHsKFy1R5FVadr8FJ2Bb1mghtXTyJkxv0trocq7NuHntSki1eUbxpO5ezJesDvBlqFjnWaYYY516QNLhQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@libsql/linux-arm-gnueabihf": { + "version": "0.5.29", + "resolved": "https://registry.npmmirror.com/@libsql/linux-arm-gnueabihf/-/linux-arm-gnueabihf-0.5.29.tgz", + "integrity": "sha512-CD4n4zj7SJTHso4nf5cuMoWoMSS7asn5hHygsDuhRl8jjjCTT3yE+xdUvI4J7zsyb53VO5ISh4cwwOtf6k2UhQ==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@libsql/linux-arm-musleabihf": { + "version": "0.5.29", + "resolved": "https://registry.npmmirror.com/@libsql/linux-arm-musleabihf/-/linux-arm-musleabihf-0.5.29.tgz", + "integrity": "sha512-2Z9qBVpEJV7OeflzIR3+l5yAd4uTOLxklScYTwpZnkm2vDSGlC1PRlueLaufc4EFITkLKXK2MWBpexuNJfMVcg==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@libsql/linux-arm64-gnu": { + "version": "0.5.29", + "resolved": "https://registry.npmmirror.com/@libsql/linux-arm64-gnu/-/linux-arm64-gnu-0.5.29.tgz", + "integrity": "sha512-gURBqaiXIGGwFNEaUj8Ldk7Hps4STtG+31aEidCk5evMMdtsdfL3HPCpvys+ZF/tkOs2MWlRWoSq7SOuCE9k3w==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@libsql/linux-arm64-musl": { + "version": "0.5.29", + "resolved": "https://registry.npmmirror.com/@libsql/linux-arm64-musl/-/linux-arm64-musl-0.5.29.tgz", + "integrity": "sha512-fwgYZ0H8mUkyVqXZHF3mT/92iIh1N94Owi/f66cPVNsk9BdGKq5gVpoKO+7UxaNzuEH1roJp2QEwsCZMvBLpqg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@libsql/linux-x64-gnu": { + "version": "0.5.29", + "resolved": "https://registry.npmmirror.com/@libsql/linux-x64-gnu/-/linux-x64-gnu-0.5.29.tgz", + "integrity": "sha512-y14V0vY0nmMC6G0pHeJcEarcnGU2H6cm21ZceRkacWHvQAEhAG0latQkCtoS2njFOXiYIg+JYPfAoWKbi82rkg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@libsql/linux-x64-musl": { + "version": "0.5.29", + "resolved": "https://registry.npmmirror.com/@libsql/linux-x64-musl/-/linux-x64-musl-0.5.29.tgz", + "integrity": "sha512-gquqwA/39tH4pFl+J9n3SOMSymjX+6kZ3kWgY3b94nXFTwac9bnFNMffIomgvlFaC4ArVqMnOZD3nuJ3H3VO1w==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@libsql/win32-x64-msvc": { + "version": "0.5.29", + "resolved": "https://registry.npmmirror.com/@libsql/win32-x64-msvc/-/win32-x64-msvc-0.5.29.tgz", + "integrity": "sha512-4/0CvEdhi6+KjMxMaVbFM2n2Z44escBRoEYpR+gZg64DdetzGnYm8mcNLcoySaDJZNaBd6wz5DNdgRmcI4hXcg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@neon-rs/load": { + "version": "0.0.4", + "resolved": "https://registry.npmmirror.com/@neon-rs/load/-/load-0.0.4.tgz", + "integrity": "sha512-kTPhdZyTQxB+2wpiRcFWrDcejc4JI6tkPuS7UZCG4l6Zvc5kU/gGQ/ozvHTh1XR5tS+UlfAfGuPajjzQjCiHCw==", + "license": "MIT" + }, "node_modules/@tokenizer/inflate": { "version": "0.4.1", "resolved": "https://registry.npmmirror.com/@tokenizer/inflate/-/inflate-0.4.1.tgz", @@ -80,6 +204,15 @@ } } }, + "node_modules/detect-libc": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/detect-libc/-/detect-libc-2.0.2.tgz", + "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==", + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, "node_modules/file-type": { "version": "21.3.4", "resolved": "https://registry.npmmirror.com/file-type/-/file-type-21.3.4.tgz", @@ -170,6 +303,38 @@ "node": ">=0.1.90" } }, + "node_modules/libsql": { + "version": "0.5.29", + "resolved": "https://registry.npmmirror.com/libsql/-/libsql-0.5.29.tgz", + "integrity": "sha512-8lMP8iMgiBzzoNbAPQ59qdVcj6UaE/Vnm+fiwX4doX4Narook0a4GPKWBEv+CR8a1OwbfkgL18uBfBjWdF0Fzg==", + "cpu": [ + "x64", + "arm64", + "wasm32", + "arm" + ], + "license": "MIT", + "os": [ + "darwin", + "linux", + "win32" + ], + "dependencies": { + "@neon-rs/load": "^0.0.4", + "detect-libc": "2.0.2" + }, + "optionalDependencies": { + "@libsql/darwin-arm64": "0.5.29", + "@libsql/darwin-x64": "0.5.29", + "@libsql/linux-arm-gnueabihf": "0.5.29", + "@libsql/linux-arm-musleabihf": "0.5.29", + "@libsql/linux-arm64-gnu": "0.5.29", + "@libsql/linux-arm64-musl": "0.5.29", + "@libsql/linux-x64-gnu": "0.5.29", + "@libsql/linux-x64-musl": "0.5.29", + "@libsql/win32-x64-msvc": "0.5.29" + } + }, "node_modules/media-typer": { "version": "2.0.0", "resolved": "https://registry.npmmirror.com/media-typer/-/media-typer-2.0.0.tgz", diff --git a/plugins/lx-music-ztools/src-ztools/preload/package.json b/plugins/lx-music-ztools/src-ztools/preload/package.json index 878cb0503..bff1408ea 100644 --- a/plugins/lx-music-ztools/src-ztools/preload/package.json +++ b/plugins/lx-music-ztools/src-ztools/preload/package.json @@ -5,6 +5,7 @@ "iconv-lite": "^0.7.3", "image-size": "1.1.0", "jschardet": "^3.1.4", + "libsql": "0.5.29", "message2call": "0.1.3", "music-metadata": "^11.15.0", "needle": "^3.3.1", diff --git a/plugins/lx-music-ztools/src-ztools/preload/probes.cjs b/plugins/lx-music-ztools/src-ztools/preload/probes.cjs index fb90c013c..9b49e1653 100644 --- a/plugins/lx-music-ztools/src-ztools/preload/probes.cjs +++ b/plugins/lx-music-ztools/src-ztools/preload/probes.cjs @@ -2,7 +2,7 @@ const { randomUUID } = require('node:crypto') const { pathToFileURL } = require('node:url') const path = require('node:path') const { startWorkerServer } = require('./worker-server.cjs') -const { DatabaseSync } = require('node:sqlite') +const { openDatabase } = require('./runtime/database.cjs') const fs = require('node:fs') /** Characterize actual host storage results rather than assuming PouchDB semantics. */ @@ -22,14 +22,13 @@ function probeCapabilities(ztools) { if (doc) db.remove(doc) } const dbPath = path.join(ztools.getPath('pluginData'), `probe-${randomUUID()}.sqlite`) - fs.mkdirSync(path.dirname(dbPath), { recursive: true }) - let sqlite = new DatabaseSync(dbPath) + let sqlite = openDatabase(dbPath) sqlite.exec('CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT); INSERT INTO test VALUES (1,\'old\')') try { sqlite.exec("BEGIN; UPDATE test SET value='new'; INSERT INTO test VALUES (1,'duplicate'); COMMIT") } catch { sqlite.exec('ROLLBACK') } const rollback = sqlite.prepare('SELECT value FROM test WHERE id=1').get().value === 'old' sqlite.close() - sqlite = new DatabaseSync(dbPath) + sqlite = openDatabase(dbPath) const reopen = sqlite.prepare('SELECT value FROM test WHERE id=1').get().value === 'old' sqlite.close(); fs.unlinkSync(dbPath) return { diff --git a/plugins/lx-music-ztools/src-ztools/preload/runtime/database.cjs b/plugins/lx-music-ztools/src-ztools/preload/runtime/database.cjs index 61ec87b0b..b6e32fda9 100644 --- a/plugins/lx-music-ztools/src-ztools/preload/runtime/database.cjs +++ b/plugins/lx-music-ztools/src-ztools/preload/runtime/database.cjs @@ -1,44 +1,69 @@ -const { DatabaseSync } = require('node:sqlite') const { mkdirSync } = require('node:fs') const path = require('node:path') let current -/** Adapt the subset of better-sqlite3 used by LX without shipping native bindings. */ +function loadBuiltinSQLite() { + try { + const { DatabaseSync, StatementSync } = require('node:sqlite') + if (typeof StatementSync?.prototype.setAllowUnknownNamedParameters === 'function') return DatabaseSync + } catch (error) { + if (!['ERR_UNKNOWN_BUILTIN_MODULE', 'ERR_NO_SQLITE'].includes(error.code)) throw error + } +} + +/** Older ZTools runtimes use the bundled Node-API driver with the same SQLite file. */ function openDatabase(file) { if (file !== ':memory:') mkdirSync(path.dirname(file), { recursive: true }) - const native = new DatabaseSync(file) + const DatabaseSync = loadBuiltinSQLite() + const Driver = DatabaseSync || require('libsql') + const connection = new Driver(file) let depth = 0 const normalize = value => value === undefined ? null : typeof value === 'boolean' ? Number(value) : value - const parameters = args => args.map(arg => arg && Object.getPrototypeOf(arg) === Object.prototype - ? Object.fromEntries(Object.entries(arg).map(([key, value]) => [key, normalize(value)])) : normalize(arg)) + const isNamed = arg => arg && Object.getPrototypeOf(arg) === Object.prototype + const parameters = args => { + const values = args.map(arg => isNamed(arg) + ? Object.fromEntries(Object.entries(arg).map(([key, value]) => [key, normalize(value)])) : normalize(arg)) + // libSQL accepts a single binding object or an array of positional values. + return DatabaseSync || isNamed(args[0]) ? values : [values] + } const db = { - exec(sql) { native.exec(sql) }, - pragma(sql) { return native.prepare(`PRAGMA ${sql}`).all().map(row => ({ ...row })) }, + exec(sql) { connection.exec(sql) }, + pragma(sql) { return db.prepare(`PRAGMA ${sql}`).all() }, prepare(sql) { - const statement = native.prepare(sql) - statement.setAllowUnknownNamedParameters(true) + const statement = connection.prepare(sql) + if (DatabaseSync) statement.setAllowUnknownNamedParameters(true) return { - run(...args) { return statement.run(...parameters(args)) }, - get(...args) { const row = statement.get(...parameters(args)); return row && { ...row } }, + run(...args) { + const { changes, lastInsertRowid } = statement.run(...parameters(args)) + return { changes, lastInsertRowid } + }, + get(...args) { + const row = statement.get(...parameters(args)) + if (!row) return undefined + // libSQL also returns query timing under _metadata. + if (!DatabaseSync) delete row._metadata + return { ...row } + }, all(...args) { return statement.all(...parameters(args)).map(row => ({ ...row })) }, } }, transaction(fn) { return (...args) => { - const savepoint = `lx_${depth++}` - native.exec(`SAVEPOINT ${savepoint}`) + const savepoint = `lx_${depth}` + connection.exec(`SAVEPOINT ${savepoint}`) + depth++ try { const result = fn(...args) if (result && typeof result.then === 'function') throw new TypeError('SQL transaction callbacks must be synchronous') - native.exec(`RELEASE SAVEPOINT ${savepoint}`) + connection.exec(`RELEASE SAVEPOINT ${savepoint}`) return result } catch (error) { - native.exec(`ROLLBACK TO SAVEPOINT ${savepoint}; RELEASE SAVEPOINT ${savepoint}`) + connection.exec(`ROLLBACK TO SAVEPOINT ${savepoint}; RELEASE SAVEPOINT ${savepoint}`) throw error } finally { depth-- } } }, - close() { native.close() }, + close() { connection.close() }, } return db } diff --git a/plugins/lx-music-ztools/src-ztools/preload/runtime/metadata-parser.cjs b/plugins/lx-music-ztools/src-ztools/preload/runtime/metadata-parser.cjs index 6fbb21256..0d68068af 100644 --- a/plugins/lx-music-ztools/src-ztools/preload/runtime/metadata-parser.cjs +++ b/plugins/lx-music-ztools/src-ztools/preload/runtime/metadata-parser.cjs @@ -1,11 +1,21 @@ const path = require('node:path') -const metadata = require('music-metadata') -const lib = path.dirname(require.resolve('music-metadata')) // Electron's shared renderer realm cannot resolve a new ESM filesystem import // from a later UI callback. Resolve the library's own lazy loaders during preload. const loaders = ['aiff/AiffLoader', 'apev2/Apev2Loader', 'asf/AsfLoader', 'dsdiff/DsdiffLoader', 'dsf/DsfLoader', 'flac/FlacLoader', 'matroska/MatroskaLoader', 'mp4/Mp4Loader', 'mpeg/MpegLoader', 'musepack/MusepackLoader', 'ogg/OggLoader', 'wav/WaveLoader', 'wavpack/WavPackLoader'] -const ready = Promise.all(loaders.map(file => Object.values(require(path.join(lib, file + '.js')))[0].load())) + +async function loadMetadata() { + if (!process.features.require_module) { + const { load } = await import('./metadata-parser.mjs') + return load(loaders) + } + const metadata = require('music-metadata') + const lib = path.dirname(require.resolve('music-metadata')) + await Promise.all(loaders.map(file => Object.values(require(path.join(lib, file + '.js')))[0].load())) + return metadata +} + +const ready = loadMetadata() ready.catch(() => {}) -module.exports = { ...metadata, ready, async parseFile(...args) { await ready; return metadata.parseFile(...args) } } +module.exports = { ready, async parseFile(...args) { return (await ready).parseFile(...args) } } diff --git a/plugins/lx-music-ztools/src-ztools/preload/runtime/metadata-parser.mjs b/plugins/lx-music-ztools/src-ztools/preload/runtime/metadata-parser.mjs new file mode 100644 index 000000000..3c885400d --- /dev/null +++ b/plugins/lx-music-ztools/src-ztools/preload/runtime/metadata-parser.mjs @@ -0,0 +1,10 @@ +import * as metadata from 'music-metadata' + +export async function load(loaders) { + const entry = import.meta.resolve('music-metadata') + await Promise.all(loaders.map(async file => { + const module = await import(new URL(file + '.js', entry).href) + await Object.values(module)[0].load() + })) + return metadata +}