fix polyfills

This commit is contained in:
2024-08-16 16:15:45 +02:00
parent 4ae05bd060
commit bd2e4cdac4
4 changed files with 1348 additions and 116 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,6 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"dependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@jridgewell/sourcemap-codec": "^1.4.15",
"@melloware/coloris": "^0.24.0",
@@ -23,6 +22,7 @@
"musickit-typescript": "^1.2.4",
"pinia": "^2.1.7",
"socket.io-client": "^4.7.5",
"vite-plugin-node-polyfills": "^0.22.0",
"vue": "^3.4.15",
"vue-router": "^4.2.5"
},
@@ -38,6 +38,6 @@
"npm-run-all2": "^6.1.1",
"typescript": "~5.3.0",
"vite": "^5.0.11",
"vue-tsc": "^1.8.27"
"vue-tsc": "^2.0.29"
}
}

View File

@@ -315,30 +315,53 @@
if ( res.status === 200 ) {
res.blob().then( blob => {
parseBlob( blob ).then( data => {
player.findSongOnAppleMusic( data.common.title ?? songDetails.filename.split( '.' )[ 0 ] ).then( d => {
let url = d.data.results.songs.data[ 0 ].attributes.artwork.url;
url = url.replace( '{w}', String( d.data.results.songs.data[ 0 ].attributes.artwork.width ) );
url = url.replace( '{h}', String( d.data.results.songs.data[ 0 ].attributes.artwork.height ) );
const song: Song = {
artist: data.common.artist ?? d.data.results.songs.data[ 0 ].attributes.artistName,
title: data.common.title ?? d.data.results.songs.data[ 0 ].attributes.name,
duration: data.format.duration ?? ( d.data.results.songs.data[ 0 ].attributes.durationInMillis / 1000 ),
id: songDetails.url,
origin: 'disk',
cover: url
}
resolve( song );
} ).catch( e => {
reject( e );
} );
try {
player.findSongOnAppleMusic( data.common.title ?? songDetails.filename.split( '.' )[ 0 ] ).then( d => {
let url = d.data.results.songs.data[ 0 ].attributes.artwork.url;
url = url.replace( '{w}', String( d.data.results.songs.data[ 0 ].attributes.artwork.width ) );
url = url.replace( '{h}', String( d.data.results.songs.data[ 0 ].attributes.artwork.height ) );
const song: Song = {
artist: data.common.artist ?? d.data.results.songs.data[ 0 ].attributes.artistName,
title: data.common.title ?? d.data.results.songs.data[ 0 ].attributes.name,
duration: data.format.duration ?? ( d.data.results.songs.data[ 0 ].attributes.durationInMillis / 1000 ),
id: songDetails.url,
origin: 'disk',
cover: url
}
resolve( song );
} ).catch( e => {
console.error( e );
const song: Song = {
artist: data.common.artist ?? 'Unknown artist',
title: data.common.title ?? 'Unknown song title',
duration: data.format.duration ?? 1000,
id: songDetails.url,
origin: 'disk',
cover: ''
}
resolve( song );
} );
} catch ( err ) {
console.error( err );
alert( 'One of your songs was not loadable. (finalization-error)' )
}
} ).catch( e => {
console.error( e );
alert( 'One of your songs was not loadable. (parser-error)' );
reject( e );
} );
} ).catch( e => {
console.error( e );
alert( 'One of your songs was not loadable. (converter-error)' );
reject( e );
} );
} else {
console.error( res.status );
alert( 'One of your songs was not loadable. (invalid-response-code)' );
}
} ).catch( e => {
console.error( e );
alert( 'One of your songs was not loadable. (could-not-connect)' );
reject( e );
} );
} );

View File

@@ -2,30 +2,19 @@ import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
nodePolyfills(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
optimizeDeps: {
esbuildOptions: {
define: {
global: 'globalThis',
},
plugins: [
NodeGlobalsPolyfillPlugin({
buffer: true,
}),
],
},
},
server: {
port: 8081
}