Compare commits
3 Commits
985620d188
...
486f1fe898
Author | SHA1 | Date | |
---|---|---|---|
486f1fe898 | |||
8b628fd6ce | |||
bb9529b877 |
2
.env
2
.env
@ -1,4 +1,4 @@
|
||||
# Example environment file for vite to use.
|
||||
# For more information, see: https://vitejs.dev/guide/env-and-mode.html
|
||||
|
||||
ENABLE_PERF_LOG=0
|
||||
VITE_ENABLE_PERF_LOG=0
|
||||
|
@ -12,12 +12,7 @@ import { TransparentCrypto } from './transparent/transparent';
|
||||
import { QingTingFM$Device } from './qtfm/qtfm_device';
|
||||
|
||||
export const allCryptoFactories: CryptoFactory[] = [
|
||||
// Xiami (*.xm)
|
||||
XiamiCrypto.make,
|
||||
|
||||
// QMCv2 (*.mflac)
|
||||
QMC2CryptoWithKey.make,
|
||||
QMC2Crypto.make,
|
||||
/// File with fixed headers goes first.
|
||||
|
||||
// NCM (*.ncm)
|
||||
NCMCrypto.make,
|
||||
@ -28,6 +23,17 @@ export const allCryptoFactories: CryptoFactory[] = [
|
||||
// KWMv1 (*.kwm)
|
||||
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)
|
||||
MiguCrypto.make,
|
||||
|
||||
|
@ -8,8 +8,13 @@ export class NCMCrypto implements CryptoBase {
|
||||
ncm = new NCMFile();
|
||||
|
||||
async checkBySignature(buffer: ArrayBuffer) {
|
||||
const data = new Uint8Array(buffer);
|
||||
let len = 1024;
|
||||
try {
|
||||
this.ncm.open(new Uint8Array(buffer));
|
||||
while (len !== 0) {
|
||||
console.debug('NCM/open: read %d bytes', len);
|
||||
len = this.ncm.open(data.subarray(0, len));
|
||||
}
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,25 +1,25 @@
|
||||
import { wrapFunctionCall } from './fnWrapper';
|
||||
|
||||
export function timedLogger<R = unknown>(label: string, fn: () => R): R {
|
||||
if (import.meta.env.ENABLE_PERF_LOG !== '1') {
|
||||
if (import.meta.env.VITE_ENABLE_PERF_LOG !== '1') {
|
||||
return fn();
|
||||
} else {
|
||||
return wrapFunctionCall(
|
||||
() => console.time(label),
|
||||
() => console.timeEnd(label),
|
||||
fn
|
||||
fn,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function withGroupedLogs<R = unknown>(label: string, fn: () => R): R {
|
||||
if (import.meta.env.ENABLE_PERF_LOG !== '1') {
|
||||
if (import.meta.env.VITE_ENABLE_PERF_LOG !== '1') {
|
||||
return fn();
|
||||
} else {
|
||||
return wrapFunctionCall(
|
||||
() => console.group(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() {
|
||||
if (import.meta.env.ENABLE_PERF_LOG === '1') {
|
||||
if (import.meta.env.VITE_ENABLE_PERF_LOG === '1') {
|
||||
return window.console;
|
||||
} else {
|
||||
return dummyLogger;
|
||||
|
Loading…
Reference in New Issue
Block a user