diff --git a/index.js b/index.js index 7f42f15..8275819 100644 --- a/index.js +++ b/index.js @@ -126,37 +126,37 @@ export function decodeBinaryString(str) { } // set up buttons const butClickHandlers = { - butDecode: () => { - decodeText(area.value); - }, - butClear: () => { - area.value = ''; - file.value = ''; - tree.innerHTML = ''; - dump.innerHTML = ''; - selectDefs.innerHTML = ''; - hash = window.location.hash = ''; - }, - butExample: () => { - console.log('Loading example:', examples.value); - let request = new XMLHttpRequest(); - request.open('GET', 'examples/' + examples.value, true); - request.onreadystatechange = function () { - if (this.readyState !== 4) return; - if (this.status >= 200 && this.status < 400) { - area.value = this.responseText; - decodeText(this.responseText); - } else { - console.log('Error loading example.'); - } - }; - request.send(); - }, + butDecode: () => { + decodeText(area.value); + }, + butClear: () => { + area.value = ''; + file.value = ''; + tree.innerHTML = ''; + dump.innerHTML = ''; + selectDefs.innerHTML = ''; + hash = window.location.hash = ''; + }, + butExample: () => { + console.log('Loading example:', examples.value); + let request = new XMLHttpRequest(); + request.open('GET', 'examples/' + examples.value, true); + request.onreadystatechange = function () { + if (this.readyState !== 4) return; + if (this.status >= 200 && this.status < 400) { + area.value = this.responseText; + decodeText(this.responseText); + } else { + console.log('Error loading example.'); + } + }; + request.send(); + }, }; for (const [name, onClick] of Object.entries(butClickHandlers)) { - let elem = id(name); - if (elem) - elem.onclick = onClick; + let elem = id(name); + if (elem) + elem.onclick = onClick; } // set dark theme depending on OS settings function setTheme() { diff --git a/package.json b/package.json index 7c5749a..517fe73 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "homepage": "https://lapo.it/asn1js/", "files": [ "asn1.js", "base64.js", "hex.js", "int10.js", "oids.js" ], "scripts": { - "lint": "npx eslint asn1.js base64.js hex.js int10.js oids.js tags.js context.js index.js parseRFC.js dumpASN1.js test.js testDefs.js", + "lint": "npx eslint asn1.js base64.js hex.js int10.js oids.js tags.js context.js index.js parseRFC.js dumpASN1.js test.js testDefs.js vite.config.js", "lint-action": "npx @action-validator/cli .github/workflows/node.js.yml", "build": "vite build", "serve": "echo 'Connect to http://localhost:3000/' ; npx statik --port 3000 .", diff --git a/vite.config.js b/vite.config.js index 3644f78..0d6b44a 100644 --- a/vite.config.js +++ b/vite.config.js @@ -4,40 +4,42 @@ import pluginDom from 'vite-plugin-dom'; import { DomUtils } from 'htmlparser2'; const preventSVGEmit = () => { - return { - generateBundle(opts, bundle) { - for (const key in bundle) - if (key.endsWith('.svg')) - delete bundle[key]; - }, - } -} + return { + generateBundle(opts, bundle) { + for (const key in bundle) + if (key.endsWith('.svg')) + delete bundle[key]; + }, + }; +}; const removeNodes = [ 'theme-select', 'rowExamples' ]; export default defineConfig({ - plugins: [ - preventSVGEmit(), - pluginDom({ - applyOnMode: true, // all modes - handler: node => { - if (removeNodes.includes(node.attribs.id)) - DomUtils.removeElement(node); - }, - }), - viteSingleFile(), - ], - build: { - minify: false, - cssMinify: false, - rollupOptions: { - output: { - assetFileNames: function (file) { - return file.name == 'favicon.svg' - ? file.name - : `assets/[name]-[hash].[ext]`; + plugins: [ + preventSVGEmit(), + pluginDom({ + applyOnMode: true, // all modes + handler: node => { + if (removeNodes.includes(node.attribs.id)) + DomUtils.removeElement(node); + }, + }), + viteSingleFile(), + ], + build: { + minify: false, + cssMinify: false, + rollupOptions: { + output: { + assetFileNames: function (file) { + return file.name == 'favicon.svg' + ? file.name + : 'assets/[name]-[hash].[ext]'; + }, + }, }, - } + assetsInlineLimit: 1000000, + //assetsInlineLimit: path => { throw new Error('XXX'); console.log(path); return true; }, }, - }, });