Compare commits

...

3 Commits

4 changed files with 23 additions and 2 deletions

View File

@ -1,5 +1,5 @@
use crate::errors::map_js_error;
use umc_qmc::footer::FooterParseError;
use umc_qmc::footer::{Data as FooterData, FooterParseError};
use umc_qmc::QMCv2Cipher;
use wasm_bindgen::prelude::wasm_bindgen;
use wasm_bindgen::JsError;
@ -57,4 +57,13 @@ impl JsQMCFooter {
pub fn size(&self) -> usize {
self.0.size
}
/// Get media name (MusicEx)
#[wasm_bindgen(getter, js_name=mediaName)]
pub fn get_media_name(&self) -> Option<String> {
match &self.0.data {
FooterData::PCv2MusicEx(metadata) => Some(metadata.media_filename.clone()),
_ => None,
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@unlock-music/crypto",
"version": "0.0.0-alpha.13",
"version": "0.0.0-alpha.14",
"description": "Project Unlock Music: 加解密支持库",
"scripts": {
"build": "node build.js",

View File

@ -2,6 +2,9 @@ import { defineConfig } from 'rollup';
import { wasm } from '@rollup/plugin-wasm';
import replace from '@rollup/plugin-replace';
import { dts } from 'rollup-plugin-dts';
import { readFileSync } from 'node:fs';
const pkgJson = JSON.parse(readFileSync(new URL('package.json', import.meta.url), 'utf-8'));
function makePlugins({ sync }) {
const plugins = [];
@ -16,6 +19,7 @@ function makePlugins({ sync }) {
preventAssignment: true,
values: {
'process.env.UMC_INLINE_BUILD': JSON.stringify(String(sync ? 1 : 0)),
'process.env.UMC_VERSION': JSON.stringify(pkgJson.version),
},
}),
);

View File

@ -21,4 +21,12 @@ function loader() {
}
}
/**
* Get package version.
* @returns {string}
*/
export function getUmcVersion() {
return process.env.UMC_VERSION;
}
export const ready = loader();