mirror of
https://git.unlock-music.dev/um/um-react.git
synced 2024-11-24 02:02:17 +00:00
Compare commits
No commits in common. "486f1fe8988376c380fd3ef7b136814120b1759f" and "985620d18887255834244107f7308bfd1a2bcd2f" have entirely different histories.
486f1fe898
...
985620d188
2
.env
2
.env
@ -1,4 +1,4 @@
|
|||||||
# Example environment file for vite to use.
|
# Example environment file for vite to use.
|
||||||
# For more information, see: https://vitejs.dev/guide/env-and-mode.html
|
# For more information, see: https://vitejs.dev/guide/env-and-mode.html
|
||||||
|
|
||||||
VITE_ENABLE_PERF_LOG=0
|
ENABLE_PERF_LOG=0
|
||||||
|
@ -12,7 +12,12 @@ import { TransparentCrypto } from './transparent/transparent';
|
|||||||
import { QingTingFM$Device } from './qtfm/qtfm_device';
|
import { QingTingFM$Device } from './qtfm/qtfm_device';
|
||||||
|
|
||||||
export const allCryptoFactories: CryptoFactory[] = [
|
export const allCryptoFactories: CryptoFactory[] = [
|
||||||
/// File with fixed headers goes first.
|
// Xiami (*.xm)
|
||||||
|
XiamiCrypto.make,
|
||||||
|
|
||||||
|
// QMCv2 (*.mflac)
|
||||||
|
QMC2CryptoWithKey.make,
|
||||||
|
QMC2Crypto.make,
|
||||||
|
|
||||||
// NCM (*.ncm)
|
// NCM (*.ncm)
|
||||||
NCMCrypto.make,
|
NCMCrypto.make,
|
||||||
@ -23,17 +28,6 @@ export const allCryptoFactories: CryptoFactory[] = [
|
|||||||
// KWMv1 (*.kwm)
|
// KWMv1 (*.kwm)
|
||||||
KWMCrypto.make,
|
KWMCrypto.make,
|
||||||
|
|
||||||
// Xiami (*.xm)
|
|
||||||
XiamiCrypto.make,
|
|
||||||
|
|
||||||
/// File with a fixed footer goes second
|
|
||||||
|
|
||||||
// QMCv2 (*.mflac)
|
|
||||||
QMC2CryptoWithKey.make,
|
|
||||||
QMC2Crypto.make,
|
|
||||||
|
|
||||||
/// File without an obvious header or footer goes last.
|
|
||||||
|
|
||||||
// Migu3D/Keyless (*.wav; *.m4a)
|
// Migu3D/Keyless (*.wav; *.m4a)
|
||||||
MiguCrypto.make,
|
MiguCrypto.make,
|
||||||
|
|
||||||
|
@ -8,13 +8,8 @@ export class NCMCrypto implements CryptoBase {
|
|||||||
ncm = new NCMFile();
|
ncm = new NCMFile();
|
||||||
|
|
||||||
async checkBySignature(buffer: ArrayBuffer) {
|
async checkBySignature(buffer: ArrayBuffer) {
|
||||||
const data = new Uint8Array(buffer);
|
|
||||||
let len = 1024;
|
|
||||||
try {
|
try {
|
||||||
while (len !== 0) {
|
this.ncm.open(new Uint8Array(buffer));
|
||||||
console.debug('NCM/open: read %d bytes', len);
|
|
||||||
len = this.ncm.open(data.subarray(0, len));
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
import { wrapFunctionCall } from './fnWrapper';
|
import { wrapFunctionCall } from './fnWrapper';
|
||||||
|
|
||||||
export function timedLogger<R = unknown>(label: string, fn: () => R): R {
|
export function timedLogger<R = unknown>(label: string, fn: () => R): R {
|
||||||
if (import.meta.env.VITE_ENABLE_PERF_LOG !== '1') {
|
if (import.meta.env.ENABLE_PERF_LOG !== '1') {
|
||||||
return fn();
|
return fn();
|
||||||
} else {
|
} else {
|
||||||
return wrapFunctionCall(
|
return wrapFunctionCall(
|
||||||
() => console.time(label),
|
() => console.time(label),
|
||||||
() => console.timeEnd(label),
|
() => console.timeEnd(label),
|
||||||
fn,
|
fn
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function withGroupedLogs<R = unknown>(label: string, fn: () => R): R {
|
export function withGroupedLogs<R = unknown>(label: string, fn: () => R): R {
|
||||||
if (import.meta.env.VITE_ENABLE_PERF_LOG !== '1') {
|
if (import.meta.env.ENABLE_PERF_LOG !== '1') {
|
||||||
return fn();
|
return fn();
|
||||||
} else {
|
} else {
|
||||||
return wrapFunctionCall(
|
return wrapFunctionCall(
|
||||||
() => console.group(label),
|
() => console.group(label),
|
||||||
() => (console.groupEnd as (label: string) => void)(label),
|
() => (console.groupEnd as (label: string) => void)(label),
|
||||||
() => timedLogger(`${label}/total`, fn),
|
() => timedLogger(`${label}/total`, fn)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ const dummyLogger = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function getLogger() {
|
export function getLogger() {
|
||||||
if (import.meta.env.VITE_ENABLE_PERF_LOG === '1') {
|
if (import.meta.env.ENABLE_PERF_LOG === '1') {
|
||||||
return window.console;
|
return window.console;
|
||||||
} else {
|
} else {
|
||||||
return dummyLogger;
|
return dummyLogger;
|
||||||
|
Loading…
Reference in New Issue
Block a user