diff --git a/index.html b/index.html index 224b9c6..0294bd9 100644 --- a/index.html +++ b/index.html @@ -116,10 +116,10 @@

import SoundFont from '/src/index'; /** sf2synth.js Option */ - const options = { + let options = { ...{ // URL to SoundFont File - // url: 'Yamaha XG Sound Set.sf2', + // url: 'https://cdn.jsdelivr.net/npm/@logue/sf2synth@latest/dist/Yamaha XG Sound Set.sf2', // Show Keyboard drawSynth: true, // Target dom id @@ -128,8 +128,12 @@

colorMode: 'auto', }, ...qs.parse(window.location.search), + ...qs.parse(window.location.hash), }; + /** @type {typeof import("./src/wml").WebMidiLink } WebMidiLink */ + const wml = new SoundFont.WebMidiLink(options); + document.addEventListener( 'DOMContentLoaded', event => { @@ -144,19 +148,17 @@

/** @type {HTMLSelectElement} */ // const selector = document.getElementById('selector'); - // Apply build time - build.dateTime = SoundFont.build; - build.innerText = new Date(SoundFont.build).toLocaleString(); - - /** @type {typeof import("./src/wml").WebMidiLink } WebMidiLink */ - const wml = new SoundFont.WebMidiLink(options); - wml.setLoadCallback(() => { dragArea.classList.remove('bg-info'); document.getElementById('soundfont').innerText = decodeURIComponent( wml.getUrl() ).match('.+/(.+?)([?#;].*)?$')[1]; }); + + // Apply build time + build.dateTime = SoundFont.build; + build.innerText = new Date(SoundFont.build).toLocaleString(); + wml.setup(); // Keep an eye out for System Light/Dark Mode Changes @@ -250,6 +252,17 @@

}, false ); + + window.addEventListener( + 'hashchange', + () => { + const url = qs.parse(window.location.hash); + if (url) { + wml.setup(url); + } + }, + false + ); diff --git a/package.json b/package.json index 0cb53cc..861cb1c 100644 --- a/package.json +++ b/package.json @@ -84,20 +84,20 @@ "lodash": "^4.17.21" }, "devDependencies": { - "@types/node": "^20.8.2", + "@types/node": "^20.8.6", "@types/webmidi": "^2.0.8", - "eslint": "^8.50.0", + "eslint": "^8.51.0", "eslint-config-google": "^0.14.0", "eslint-config-prettier": "^9.0.0", "eslint-import-resolver-alias": "^1.1.2", "eslint-plugin-import": "^2.28.1", - "eslint-plugin-prettier": "^5.0.0", + "eslint-plugin-prettier": "^5.0.1", "husky": "^8.0.3", - "lint-staged": "^14.0.1", + "lint-staged": "^15.0.1", "prettier": "^3.0.3", "query-string": "^8.1.0", "rimraf": "^5.0.5", - "sass": "1.69.0", + "sass": "1.69.3", "stylelint": "^15.10.3", "stylelint-config-recommended-scss": "^13.0.0", "stylelint-order": "^6.0.3", diff --git a/src/loader.js b/src/loader.js index 0bc987d..5fc6542 100644 --- a/src/loader.js +++ b/src/loader.js @@ -83,15 +83,12 @@ export default class Loader { * @private */ onError(error = undefined) { - requestAnimationFrame(function () { + requestAnimationFrame(() => { this.alert.className = 'alert alert-danger'; this.message.innerText = 'An error occurred while loading SoundFont. See the console log for details. In addition, it may be cured by deleting the cache of the browser.'; this.progressOuter.style.display = 'none'; }); - if (error) { - throw Error(error.message); - } } /** diff --git a/src/wml.js b/src/wml.js index 51c0ce1..51f31ee 100644 --- a/src/wml.js +++ b/src/wml.js @@ -37,6 +37,7 @@ export default class WebMidiLink { this.option.colorMode = option.colorMode ?? 'auto'; /** @type {string} SoundFont URL */ this.url = + option.url ?? 'https://cdn.jsdelivr.net/npm/@logue/sf2synth@latest/dist/Yamaha XG Sound Set.sf2'; /** @type {HTMLDivElement} */ @@ -63,7 +64,7 @@ export default class WebMidiLink { * @param {string?} url SoundFont URL * @public */ - async setup(url) { + async setup(url = undefined) { // DOMをクリア while (this.placeholder.firstChild) { this.placeholder.removeChild(this.placeholder.firstChild); @@ -78,7 +79,7 @@ export default class WebMidiLink { this.url, this.placeholder, this.option.cache, - buffer => this.setupByBuffer(buffer) + (/** @type {ArrayBuffer} */ buffer) => this.setupByBuffer(buffer) ); await loader.fetch(); } diff --git a/yarn.lock b/yarn.lock index 1e0106b..81855bd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -263,10 +263,10 @@ __metadata: languageName: node linkType: hard -"@eslint/js@npm:8.50.0": - version: 8.50.0 - resolution: "@eslint/js@npm:8.50.0" - checksum: 302478f2acaaa7228729ec6a04f56641590185e1d8cd1c836a6db8a6b8009f80a57349341be9fbb9aa1721a7a569d1be3ffc598a33300d22816f11832095386c +"@eslint/js@npm:8.51.0": + version: 8.51.0 + resolution: "@eslint/js@npm:8.51.0" + checksum: 0228bf1e1e0414843e56d9ff362a2a72d579c078f93174666f29315690e9e30a8633ad72c923297f7fd7182381b5a476805ff04dac8debe638953eb1ded3ac73 languageName: node linkType: hard @@ -331,22 +331,22 @@ __metadata: resolution: "@logue/sf2synth@workspace:." dependencies: "@logue/reverb": ^1.3.3 - "@types/node": ^20.8.2 + "@types/node": ^20.8.6 "@types/webmidi": ^2.0.8 bootstrap: ^5.3.2 - eslint: ^8.50.0 + eslint: ^8.51.0 eslint-config-google: ^0.14.0 eslint-config-prettier: ^9.0.0 eslint-import-resolver-alias: ^1.1.2 eslint-plugin-import: ^2.28.1 - eslint-plugin-prettier: ^5.0.0 + eslint-plugin-prettier: ^5.0.1 husky: ^8.0.3 - lint-staged: ^14.0.1 + lint-staged: ^15.0.1 lodash: ^4.17.21 prettier: ^3.0.3 query-string: ^8.1.0 rimraf: ^5.0.5 - sass: 1.69.0 + sass: 1.69.3 stylelint: ^15.10.3 stylelint-config-recommended-scss: ^13.0.0 stylelint-order: ^6.0.3 @@ -572,10 +572,12 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:^20.8.2": - version: 20.8.2 - resolution: "@types/node@npm:20.8.2" - checksum: 3da73e25d821bfcdb7de98589027e08bb4848e55408671c4a83ec0341e124b5313a0b20e1e4b4eff1168ea17a86f622ad73fcb04b761abd77496b9a27cbd5de5 +"@types/node@npm:^20.8.6": + version: 20.8.6 + resolution: "@types/node@npm:20.8.6" + dependencies: + undici-types: ~5.25.1 + checksum: ccfb7ac482c5a96edeb239893c5c099f5257fcc2ed9ae62fefdfbc782b79e16dbc2af9a85b379665237bf759904b44ca2be68e75d239e0297882aad42f61905c languageName: node linkType: hard @@ -1152,10 +1154,10 @@ __metadata: languageName: node linkType: hard -"commander@npm:11.0.0": - version: 11.0.0 - resolution: "commander@npm:11.0.0" - checksum: 6621954e1e1d078b4991c1f5bbd9439ad37aa7768d6ab4842de1dbd4d222c8a27e1b8e62108b3a92988614af45031d5bb2a2aaa92951f4d0c934d1a1ac564bb4 +"commander@npm:11.1.0": + version: 11.1.0 + resolution: "commander@npm:11.1.0" + checksum: fd1a8557c6b5b622c89ecdfde703242ab7db3b628ea5d1755784c79b8e7cb0d74d65b4a262289b533359cd58e1bfc0bf50245dfbcd2954682a6f367c828b79ef languageName: node linkType: hard @@ -1751,9 +1753,9 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-prettier@npm:^5.0.0": - version: 5.0.0 - resolution: "eslint-plugin-prettier@npm:5.0.0" +"eslint-plugin-prettier@npm:^5.0.1": + version: 5.0.1 + resolution: "eslint-plugin-prettier@npm:5.0.1" dependencies: prettier-linter-helpers: ^1.0.0 synckit: ^0.8.5 @@ -1766,7 +1768,7 @@ __metadata: optional: true eslint-config-prettier: optional: true - checksum: 84e88744b9050f2d5ef31b94e85294dda16f3a53c2449f9d33eac8ae6264889b459bf35a68e438fb6b329c2a1d6491aac4bfa00d86317e7009de3dad0311bec6 + checksum: c2261033b97bafe99ccb7cc47c2fac6fa85b8bbc8b128042e52631f906b69e12afed2cdd9d7e3021cc892ee8dd4204a3574e1f32a0b718b4bb3b440944b6983b languageName: node linkType: hard @@ -1801,14 +1803,14 @@ __metadata: languageName: node linkType: hard -"eslint@npm:^8.50.0": - version: 8.50.0 - resolution: "eslint@npm:8.50.0" +"eslint@npm:^8.51.0": + version: 8.51.0 + resolution: "eslint@npm:8.51.0" dependencies: "@eslint-community/eslint-utils": ^4.2.0 "@eslint-community/regexpp": ^4.6.1 "@eslint/eslintrc": ^2.1.2 - "@eslint/js": 8.50.0 + "@eslint/js": 8.51.0 "@humanwhocodes/config-array": ^0.11.11 "@humanwhocodes/module-importer": ^1.0.1 "@nodelib/fs.walk": ^1.2.8 @@ -1844,7 +1846,7 @@ __metadata: text-table: ^0.2.0 bin: eslint: bin/eslint.js - checksum: 9ebfe5615dc84700000d218e32ddfdcfc227ca600f65f18e5541ec34f8902a00356a9a8804d9468fd6c8637a5ef6a3897291dad91ba6579d5b32ffeae5e31768 + checksum: 214fa5d1fcb67af1b8992ce9584ccd85e1aa7a482f8b8ea5b96edc28fa838a18a3b69456db45fc1ed3ef95f1e9efa9714f737292dc681e572d471d02fda9649c languageName: node linkType: hard @@ -1898,20 +1900,20 @@ __metadata: languageName: node linkType: hard -"execa@npm:7.2.0": - version: 7.2.0 - resolution: "execa@npm:7.2.0" +"execa@npm:8.0.1": + version: 8.0.1 + resolution: "execa@npm:8.0.1" dependencies: cross-spawn: ^7.0.3 - get-stream: ^6.0.1 - human-signals: ^4.3.0 + get-stream: ^8.0.1 + human-signals: ^5.0.0 is-stream: ^3.0.0 merge-stream: ^2.0.0 npm-run-path: ^5.1.0 onetime: ^6.0.0 - signal-exit: ^3.0.7 + signal-exit: ^4.1.0 strip-final-newline: ^3.0.0 - checksum: 14fd17ba0ca8c87b277584d93b1d9fc24f2a65e5152b31d5eb159a3b814854283eaae5f51efa9525e304447e2f757c691877f7adff8fde5746aae67eb1edd1cc + checksum: cac1bf86589d1d9b73bdc5dda65c52012d1a9619c44c526891956745f7b366ca2603d29fe3f7460bacc2b48c6eab5d6a4f7afe0534b31473d3708d1265545e1f languageName: node linkType: hard @@ -2232,6 +2234,13 @@ __metadata: languageName: node linkType: hard +"get-stream@npm:^8.0.1": + version: 8.0.1 + resolution: "get-stream@npm:8.0.1" + checksum: 01e3d3cf29e1393f05f44d2f00445c5f9ec3d1c49e8179b31795484b9c117f4c695e5e07b88b50785d5c8248a788c85d9913a79266fc77e3ef11f78f10f1b974 + languageName: node + linkType: hard + "get-symbol-description@npm:^1.0.0": version: 1.0.0 resolution: "get-symbol-description@npm:1.0.0" @@ -2532,6 +2541,13 @@ __metadata: languageName: node linkType: hard +"human-signals@npm:^5.0.0": + version: 5.0.0 + resolution: "human-signals@npm:5.0.0" + checksum: 6504560d5ed91444f16bea3bd9dfc66110a339442084e56c3e7fa7bbdf3f406426d6563d662bdce67064b165eac31eeabfc0857ed170aaa612cf14ec9f9a464c + languageName: node + linkType: hard + "humanize-ms@npm:^1.2.1": version: 1.2.1 resolution: "humanize-ms@npm:1.2.1" @@ -3121,29 +3137,29 @@ __metadata: languageName: node linkType: hard -"lint-staged@npm:^14.0.1": - version: 14.0.1 - resolution: "lint-staged@npm:14.0.1" +"lint-staged@npm:^15.0.1": + version: 15.0.1 + resolution: "lint-staged@npm:15.0.1" dependencies: chalk: 5.3.0 - commander: 11.0.0 + commander: 11.1.0 debug: 4.3.4 - execa: 7.2.0 + execa: 8.0.1 lilconfig: 2.1.0 - listr2: 6.6.1 + listr2: 7.0.1 micromatch: 4.0.5 pidtree: 0.6.0 string-argv: 0.3.2 - yaml: 2.3.1 + yaml: 2.3.2 bin: lint-staged: bin/lint-staged.js - checksum: 8c5d740cb3c90fab2d970fa6bbffe5ddf35ec66ed374a52caf3a3cf83d8f4d5fd01a949994822bce5ea18c0b8dc8fa4ce087ef886a8c11db674139a063cdfe4f + checksum: 4ef972b8fb246fa047e2f819833e675a816bfe1dd1fa4130d1b75cb6af2a51abc54eb7047a7b82403d9d4f8aefe1e71532a999161d180fb5ec019d360988b7bf languageName: node linkType: hard -"listr2@npm:6.6.1": - version: 6.6.1 - resolution: "listr2@npm:6.6.1" +"listr2@npm:7.0.1": + version: 7.0.1 + resolution: "listr2@npm:7.0.1" dependencies: cli-truncate: ^3.1.0 colorette: ^2.0.20 @@ -3151,12 +3167,7 @@ __metadata: log-update: ^5.0.1 rfdc: ^1.3.0 wrap-ansi: ^8.1.0 - peerDependencies: - enquirer: ">= 2.3.0 < 3" - peerDependenciesMeta: - enquirer: - optional: true - checksum: 99600e8a51f838f7208bce7e16d6b3d91d361f13881e6aa91d0b561a9a093ddcf63b7bc2a7b47aec7fdbff9d0e8c9f68cb66e6dfe2d857e5b1df8ab045c26ce8 + checksum: ad6a64b952505c54f18f2c18d7bc4cf92a236b2742bf5bc514994dfadd48d9dacc5abd4f599ba7cd5bd0343da1ad0a0c3f3faa034597e8905b751b75c2a6b2e8 languageName: node linkType: hard @@ -4274,16 +4285,16 @@ __metadata: languageName: node linkType: hard -"sass@npm:1.69.0": - version: 1.69.0 - resolution: "sass@npm:1.69.0" +"sass@npm:1.69.3": + version: 1.69.3 + resolution: "sass@npm:1.69.3" dependencies: chokidar: ">=3.0.0 <4.0.0" immutable: ^4.0.0 source-map-js: ">=0.6.2 <2.0.0" bin: sass: sass.js - checksum: eabea31ea3b1dd529c7eff345c8b6468afe6ab8011bd4f95caa2cffb8fb115cc055ea21de425be6197f7ed22516f5652eccb98d315d592ea152ada553f964b8a + checksum: b89a3370c7ede462b344e2136bf1407bf375855c1ec54f73b6257b18fe59dae5377eb9f7b25f21ae4a25d8f0bc41a165d8d7e5f693d8285b1aa51ac6056c4d19 languageName: node linkType: hard @@ -4346,6 +4357,13 @@ __metadata: languageName: node linkType: hard +"signal-exit@npm:^4.1.0": + version: 4.1.0 + resolution: "signal-exit@npm:4.1.0" + checksum: 64c757b498cb8629ffa5f75485340594d2f8189e9b08700e69199069c8e3070fb3e255f7ab873c05dc0b3cec412aea7402e10a5990cb6a050bd33ba062a6c549 + languageName: node + linkType: hard + "slash@npm:^3.0.0": version: 3.0.0 resolution: "slash@npm:3.0.0" @@ -4966,6 +4984,13 @@ __metadata: languageName: node linkType: hard +"undici-types@npm:~5.25.1": + version: 5.25.3 + resolution: "undici-types@npm:5.25.3" + checksum: ec9d2cc36520cbd9fbe3b3b6c682a87fe5be214699e1f57d1e3d9a2cb5be422e62735f06e0067dc325fd3dd7404c697e4d479f9147dc8a804e049e29f357f2ff + languageName: node + linkType: hard + "unique-filename@npm:^1.1.1": version: 1.1.1 resolution: "unique-filename@npm:1.1.1"