Compare commits

...

2 Commits

Author SHA1 Message Date
SArpnt a36406d8eb
add boots in bed 2024-03-12 14:50:17 -04:00
SArpnt 1d157dd726
tweaks/cleanup 2024-03-12 14:50:03 -04:00
8 changed files with 320 additions and 129 deletions

2
.gitignore vendored
View File

@ -1,4 +1,2 @@
/node_modules
/_site
/coverage
**/rust/target

View File

@ -1,20 +1,20 @@
const esbuild = require("esbuild");
const XXHash = require("xxhash");
//const XXHash = require("xxhash");
const htmlmin = require("html-minifier");
const npath = require("path");
const afs = require("fs/promises");
const minimatch = require("minimatch");
//const npath = require("path");
//const afs = require("fs/promises");
//const minimatch = require("minimatch");
const input = "src";
const output = "_site";
const serve = process.env.ELEVENTY_RUN_MODE === "serve";
// TODO minify html/pug and css and js in html/pug
// TODO minify css and js in html
function getHash(f) {
XXHash.hash(f, 0xe0b52cfa, "base64").replaceAll("=", "");
}
//function getHash(f) {
// XXHash.hash(f, 0xe0b52cfa, "base64").replaceAll("=", "");
//}
module.exports = eleventyConfig => {
eleventyConfig.on("eleventy.after", async ({ dir, results, runMode, outputMode }) => {
@ -35,74 +35,74 @@ module.exports = eleventyConfig => {
});
// proper cachebusting is difficult not doing it right now
if (false && !serve) {
async function getHashOfFile(assetPath, content) {
console.log(`hashing ${assetPath}`);
assetPaths.push({
assetPath: assetPath.replace(dir.output, ""),
assetHash: getHash(content ?? (await afs.readFile(assetPath))),
});
}
//if (!serve) {
// async function getHashOfFile(assetPath, content) {
// console.log(`hashing ${assetPath}`);
// assetPaths.push({
// assetPath: assetPath.replace(dir.output, ""),
// assetHash: getHash(content ?? (await afs.readFile(assetPath))),
// });
// }
const globs = [
`!${dir.output}/library/**`,
`${dir.output}/**/*.{css,js,png,jpg,jpeg,gif,mp4,ico}`,
].map(g => new minimatch.Minimatch(g));
// const globs = [
// `!${dir.output}/library/**`,
// `${dir.output}/**/*.{css,js,png,jpg,jpeg,gif,mp4,ico}`,
// ].map(g => new minimatch.Minimatch(g));
const assetPaths = [];
// const assetPaths = [];
(await Promise.all(await afs.readdir(dir.output, {}))).forEach(relpath => {
const path = npath.join(dir.output, relpath);
if (globs.every(mg => mg.match(path))) {
getHashOfFile(path);
}
});
// (await Promise.all(await afs.readdir(dir.output, {}))).forEach(relpath => {
// const path = npath.join(dir.output, relpath);
// if (globs.every(mg => mg.match(path))) {
// getHashOfFile(path);
// }
// });
const esbuildFiles = [];
// const esbuildFiles = [];
esbuildResult.outputFiles.forEach(({ contents, path: apath }) => {
const path = npath.relative("", apath);
console.log(path);
console.log(globs[1].match(path));
if (globs.every(mg => mg.match(path))) {
const string = Buffer.from(contents).toString();
console.log(string.substring(0, 20).replace(/\n/g, "|"));
assetPaths.push({
assetPath: path.replace(dir.output, ""),
assetHash: getHash(contents),
});
esbuildFiles.push({ contents, path });
} else {
afs.writeFile(path, contents);
}
});
// esbuildResult.outputFiles.forEach(({ contents, path: apath }) => {
// const path = npath.relative("", apath);
// console.log(path);
// console.log(globs[1].match(path));
// if (globs.every(mg => mg.match(path))) {
// const string = Buffer.from(contents).toString();
// console.log(string.substring(0, 20).replace(/\n/g, "|"));
// assetPaths.push({
// assetPath: path.replace(dir.output, ""),
// assetHash: getHash(contents),
// });
// esbuildFiles.push({ contents, path });
// } else {
// afs.writeFile(path, contents);
// }
// });
results.forEach(({ inputPath, outputPath, url, content }) => {
let outputData = ""; // Assigned later
let outputChanged = false; // Check if any hashes have been added
// results.forEach(({ inputPath, outputPath, url, content }) => {
// let outputData = ""; // Assigned later
// let outputChanged = false; // Check if any hashes have been added
// Read the output content
fs.readFile(outputPath, (encoding = "UTF-8"), (err, data) => {
if (err) {
logRed(err);
throw err;
}
// Save the output data
outputData = data;
// // Read the output content
// fs.readFile(outputPath, (encoding = "UTF-8"), (err, data) => {
// if (err) {
// logRed(err);
// throw err;
// }
// // Save the output data
// outputData = data;
assetPaths.forEach(({ assetPath, assetHash }) => {
if (data.includes(assetPath)) {
// TODO very error prone
outputData = outputData.replace(assetPath, assetPath + "?v=" + assetHash);
outputChanged = true;
}
});
});
});
// assetPaths.forEach(({ assetPath, assetHash }) => {
// if (data.includes(assetPath)) {
// // TODO very error prone
// outputData = outputData.replace(assetPath, assetPath + "?v=" + assetHash);
// outputChanged = true;
// }
// });
// });
// });
// TODO replace text in esbuild files
// TODO write esbuild files
}
// // TODO replace text in esbuild files
// // TODO write esbuild files
//}
});
eleventyConfig.addTransform("htmlmin", function (content) {
@ -122,7 +122,6 @@ module.exports = eleventyConfig => {
eleventyConfig.addWatchTarget("src/**/*.js");
eleventyConfig.addWatchTarget("src/**/*.ts");
eleventyConfig.addWatchTarget("src/**/*.json");
// TODO does the css need a watch target?
return {
dir: {
input,

View File

@ -4,32 +4,36 @@
build: 'rm -rf _site && eleventy',
serve: 'eleventy --serve',
debug: 'DEBUG=* eleventy --serve',
test: 'tsc; jest --coverage --passWithNoTests',
test: 'tsc; jest --passWithNoTests',
},
dependencies: {
'@11ty/eleventy': '^2.0.1',
esbuild: '^0.20.1',
'html-minifier': '^4.0.0',
fflate: '^0.8.2',
//'@stdlib/constants-float32-eps': '^0.1.1',
'@codemirror/commands': '^6.3.3',
'@codemirror/lang-javascript': '^6.2.2',
'@codemirror/language': '^6.10.1',
'@codemirror/search': '^6.5.6',
'@codemirror/state': '^6.4.1',
'@codemirror/view': '^6.25.1',
'@jamshop/eleventy-plugin-esbuild': '^1.0.2',
'@lezer/highlight': '^1.2.0',
//'@stdlib/constants-float32-eps': '^0.1.1',
fflate: '^0.8.2',
'html-minifier': '^4.0.0',
minimatch: '^9.0.3',
'ts-essentials': '^9.4.1',
xxhash: '^0.3.0',
//minimatch: '^9.0.3',
//xxhash: '^0.3.0',
},
devDependencies: {
'@prettier/plugin-pug': '^3.0.0',
'@types/jest': '^29.5.12',
jest: '^29.7.0',
'jest-environment-jsdom': '^29.7.0',
prettier: '^3.2.5',
'ts-jest': '^29.1.2',
typescript: '^5.4.2',
'ts-essentials': '^9.4.1',
prettier: '^3.2.5',
'@prettier/plugin-pug': '^3.0.0',
jest: '^29.7.0',
'@types/jest': '^29.5.12',
'ts-jest': '^29.1.2',
'jest-environment-jsdom': '^29.7.0',
},
}

View File

@ -26,27 +26,18 @@ dependencies:
'@codemirror/view':
specifier: ^6.25.1
version: 6.25.1
'@jamshop/eleventy-plugin-esbuild':
specifier: ^1.0.2
version: 1.0.2
'@lezer/highlight':
specifier: ^1.2.0
version: 1.2.0
esbuild:
specifier: ^0.20.1
version: 0.20.1
fflate:
specifier: ^0.8.2
version: 0.8.2
html-minifier:
specifier: ^4.0.0
version: 4.0.0
minimatch:
specifier: ^9.0.3
version: 9.0.3
ts-essentials:
specifier: ^9.4.1
version: 9.4.1(typescript@5.4.2)
xxhash:
specifier: ^0.3.0
version: 0.3.0
devDependencies:
'@prettier/plugin-pug':
@ -64,9 +55,12 @@ devDependencies:
prettier:
specifier: ^3.2.5
version: 3.2.5
ts-essentials:
specifier: ^9.4.1
version: 9.4.1(typescript@5.4.2)
ts-jest:
specifier: ^29.1.2
version: 29.1.2(@babel/core@7.24.0)(jest@29.7.0)(typescript@5.4.2)
version: 29.1.2(@babel/core@7.24.0)(esbuild@0.20.1)(jest@29.7.0)(typescript@5.4.2)
typescript:
specifier: ^5.4.2
version: 5.4.2
@ -567,6 +561,190 @@ packages:
w3c-keyname: 2.2.8
dev: false
/@esbuild/aix-ppc64@0.20.1:
resolution: {integrity: sha512-m55cpeupQ2DbuRGQMMZDzbv9J9PgVelPjlcmM5kxHnrBdBx6REaEd7LamYV7Dm8N7rCyR/XwU6rVP8ploKtIkA==}
engines: {node: '>=12'}
cpu: [ppc64]
os: [aix]
requiresBuild: true
optional: true
/@esbuild/android-arm64@0.20.1:
resolution: {integrity: sha512-hCnXNF0HM6AjowP+Zou0ZJMWWa1VkD77BXe959zERgGJBBxB+sV+J9f/rcjeg2c5bsukD/n17RKWXGFCO5dD5A==}
engines: {node: '>=12'}
cpu: [arm64]
os: [android]
requiresBuild: true
optional: true
/@esbuild/android-arm@0.20.1:
resolution: {integrity: sha512-4j0+G27/2ZXGWR5okcJi7pQYhmkVgb4D7UKwxcqrjhvp5TKWx3cUjgB1CGj1mfdmJBQ9VnUGgUhign+FPF2Zgw==}
engines: {node: '>=12'}
cpu: [arm]
os: [android]
requiresBuild: true
optional: true
/@esbuild/android-x64@0.20.1:
resolution: {integrity: sha512-MSfZMBoAsnhpS+2yMFYIQUPs8Z19ajwfuaSZx+tSl09xrHZCjbeXXMsUF/0oq7ojxYEpsSo4c0SfjxOYXRbpaA==}
engines: {node: '>=12'}
cpu: [x64]
os: [android]
requiresBuild: true
optional: true
/@esbuild/darwin-arm64@0.20.1:
resolution: {integrity: sha512-Ylk6rzgMD8klUklGPzS414UQLa5NPXZD5tf8JmQU8GQrj6BrFA/Ic9tb2zRe1kOZyCbGl+e8VMbDRazCEBqPvA==}
engines: {node: '>=12'}
cpu: [arm64]
os: [darwin]
requiresBuild: true
optional: true
/@esbuild/darwin-x64@0.20.1:
resolution: {integrity: sha512-pFIfj7U2w5sMp52wTY1XVOdoxw+GDwy9FsK3OFz4BpMAjvZVs0dT1VXs8aQm22nhwoIWUmIRaE+4xow8xfIDZA==}
engines: {node: '>=12'}
cpu: [x64]
os: [darwin]
requiresBuild: true
optional: true
/@esbuild/freebsd-arm64@0.20.1:
resolution: {integrity: sha512-UyW1WZvHDuM4xDz0jWun4qtQFauNdXjXOtIy7SYdf7pbxSWWVlqhnR/T2TpX6LX5NI62spt0a3ldIIEkPM6RHw==}
engines: {node: '>=12'}
cpu: [arm64]
os: [freebsd]
requiresBuild: true
optional: true
/@esbuild/freebsd-x64@0.20.1:
resolution: {integrity: sha512-itPwCw5C+Jh/c624vcDd9kRCCZVpzpQn8dtwoYIt2TJF3S9xJLiRohnnNrKwREvcZYx0n8sCSbvGH349XkcQeg==}
engines: {node: '>=12'}
cpu: [x64]
os: [freebsd]
requiresBuild: true
optional: true
/@esbuild/linux-arm64@0.20.1:
resolution: {integrity: sha512-cX8WdlF6Cnvw/DO9/X7XLH2J6CkBnz7Twjpk56cshk9sjYVcuh4sXQBy5bmTwzBjNVZze2yaV1vtcJS04LbN8w==}
engines: {node: '>=12'}
cpu: [arm64]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-arm@0.20.1:
resolution: {integrity: sha512-LojC28v3+IhIbfQ+Vu4Ut5n3wKcgTu6POKIHN9Wpt0HnfgUGlBuyDDQR4jWZUZFyYLiz4RBBBmfU6sNfn6RhLw==}
engines: {node: '>=12'}
cpu: [arm]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-ia32@0.20.1:
resolution: {integrity: sha512-4H/sQCy1mnnGkUt/xszaLlYJVTz3W9ep52xEefGtd6yXDQbz/5fZE5dFLUgsPdbUOQANcVUa5iO6g3nyy5BJiw==}
engines: {node: '>=12'}
cpu: [ia32]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-loong64@0.20.1:
resolution: {integrity: sha512-c0jgtB+sRHCciVXlyjDcWb2FUuzlGVRwGXgI+3WqKOIuoo8AmZAddzeOHeYLtD+dmtHw3B4Xo9wAUdjlfW5yYA==}
engines: {node: '>=12'}
cpu: [loong64]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-mips64el@0.20.1:
resolution: {integrity: sha512-TgFyCfIxSujyuqdZKDZ3yTwWiGv+KnlOeXXitCQ+trDODJ+ZtGOzLkSWngynP0HZnTsDyBbPy7GWVXWaEl6lhA==}
engines: {node: '>=12'}
cpu: [mips64el]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-ppc64@0.20.1:
resolution: {integrity: sha512-b+yuD1IUeL+Y93PmFZDZFIElwbmFfIKLKlYI8M6tRyzE6u7oEP7onGk0vZRh8wfVGC2dZoy0EqX1V8qok4qHaw==}
engines: {node: '>=12'}
cpu: [ppc64]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-riscv64@0.20.1:
resolution: {integrity: sha512-wpDlpE0oRKZwX+GfomcALcouqjjV8MIX8DyTrxfyCfXxoKQSDm45CZr9fanJ4F6ckD4yDEPT98SrjvLwIqUCgg==}
engines: {node: '>=12'}
cpu: [riscv64]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-s390x@0.20.1:
resolution: {integrity: sha512-5BepC2Au80EohQ2dBpyTquqGCES7++p7G+7lXe1bAIvMdXm4YYcEfZtQrP4gaoZ96Wv1Ute61CEHFU7h4FMueQ==}
engines: {node: '>=12'}
cpu: [s390x]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-x64@0.20.1:
resolution: {integrity: sha512-5gRPk7pKuaIB+tmH+yKd2aQTRpqlf1E4f/mC+tawIm/CGJemZcHZpp2ic8oD83nKgUPMEd0fNanrnFljiruuyA==}
engines: {node: '>=12'}
cpu: [x64]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/netbsd-x64@0.20.1:
resolution: {integrity: sha512-4fL68JdrLV2nVW2AaWZBv3XEm3Ae3NZn/7qy2KGAt3dexAgSVT+Hc97JKSZnqezgMlv9x6KV0ZkZY7UO5cNLCg==}
engines: {node: '>=12'}
cpu: [x64]
os: [netbsd]
requiresBuild: true
optional: true
/@esbuild/openbsd-x64@0.20.1:
resolution: {integrity: sha512-GhRuXlvRE+twf2ES+8REbeCb/zeikNqwD3+6S5y5/x+DYbAQUNl0HNBs4RQJqrechS4v4MruEr8ZtAin/hK5iw==}
engines: {node: '>=12'}
cpu: [x64]
os: [openbsd]
requiresBuild: true
optional: true
/@esbuild/sunos-x64@0.20.1:
resolution: {integrity: sha512-ZnWEyCM0G1Ex6JtsygvC3KUUrlDXqOihw8RicRuQAzw+c4f1D66YlPNNV3rkjVW90zXVsHwZYWbJh3v+oQFM9Q==}
engines: {node: '>=12'}
cpu: [x64]
os: [sunos]
requiresBuild: true
optional: true
/@esbuild/win32-arm64@0.20.1:
resolution: {integrity: sha512-QZ6gXue0vVQY2Oon9WyLFCdSuYbXSoxaZrPuJ4c20j6ICedfsDilNPYfHLlMH7vGfU5DQR0czHLmJvH4Nzis/A==}
engines: {node: '>=12'}
cpu: [arm64]
os: [win32]
requiresBuild: true
optional: true
/@esbuild/win32-ia32@0.20.1:
resolution: {integrity: sha512-HzcJa1NcSWTAU0MJIxOho8JftNp9YALui3o+Ny7hCh0v5f90nprly1U3Sj1Ldj/CvKKdvvFsCRvDkpsEMp4DNw==}
engines: {node: '>=12'}
cpu: [ia32]
os: [win32]
requiresBuild: true
optional: true
/@esbuild/win32-x64@0.20.1:
resolution: {integrity: sha512-0MBh53o6XtI6ctDnRMeQ+xoCN8kD2qI1rY1KgF/xdWQwoFeKou7puvDfV8/Wv4Ctx2rRpET/gGdz3YlNtNACSA==}
engines: {node: '>=12'}
cpu: [x64]
os: [win32]
requiresBuild: true
optional: true
/@iarna/toml@2.2.5:
resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==}
dev: false
@ -587,12 +765,6 @@ packages:
engines: {node: '>=8'}
dev: true
/@jamshop/eleventy-plugin-esbuild@1.0.2:
resolution: {integrity: sha512-N0nCxExDVVYslq1jUFqLEweuVOuHPziK352AW1BXVgu5fWXAf/elsdLcfzJLbgFlf4+tU+vJt/pb4fB4A27aqQ==}
dependencies:
esbuild: 0.7.22
dev: false
/@jest/console@29.7.0:
resolution: {integrity: sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
@ -1719,11 +1891,35 @@ packages:
resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==}
engines: {node: '>= 0.4'}
/esbuild@0.7.22:
resolution: {integrity: sha512-B43SYg8LGWYTCv9Gs0RnuLNwjzpuWOoCaZHTWEDEf5AfrnuDMerPVMdCEu7xOdhFvQ+UqfP2MGU9lxEy0JzccA==}
/esbuild@0.20.1:
resolution: {integrity: sha512-OJwEgrpWm/PCMsLVWXKqvcjme3bHNpOgN7Tb6cQnR5n0TPbQx1/Xrn7rqM+wn17bYeT6MGB5sn1Bh5YiGi70nA==}
engines: {node: '>=12'}
hasBin: true
requiresBuild: true
dev: false
optionalDependencies:
'@esbuild/aix-ppc64': 0.20.1
'@esbuild/android-arm': 0.20.1
'@esbuild/android-arm64': 0.20.1
'@esbuild/android-x64': 0.20.1
'@esbuild/darwin-arm64': 0.20.1
'@esbuild/darwin-x64': 0.20.1
'@esbuild/freebsd-arm64': 0.20.1
'@esbuild/freebsd-x64': 0.20.1
'@esbuild/linux-arm': 0.20.1
'@esbuild/linux-arm64': 0.20.1
'@esbuild/linux-ia32': 0.20.1
'@esbuild/linux-loong64': 0.20.1
'@esbuild/linux-mips64el': 0.20.1
'@esbuild/linux-ppc64': 0.20.1
'@esbuild/linux-riscv64': 0.20.1
'@esbuild/linux-s390x': 0.20.1
'@esbuild/linux-x64': 0.20.1
'@esbuild/netbsd-x64': 0.20.1
'@esbuild/openbsd-x64': 0.20.1
'@esbuild/sunos-x64': 0.20.1
'@esbuild/win32-arm64': 0.20.1
'@esbuild/win32-ia32': 0.20.1
'@esbuild/win32-x64': 0.20.1
/escalade@3.1.2:
resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==}
@ -2980,13 +3176,6 @@ packages:
brace-expansion: 2.0.1
dev: false
/minimatch@9.0.3:
resolution: {integrity: sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==}
engines: {node: '>=16 || 14 >=14.17'}
dependencies:
brace-expansion: 2.0.1
dev: false
/minimist@1.2.8:
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
dev: false
@ -3036,10 +3225,6 @@ packages:
hasBin: true
dev: false
/nan@2.19.0:
resolution: {integrity: sha512-nO1xXxfh/RWNxfd/XPfbIfFk5vgLsAxUR9y5O0cHMJu/AW9U95JLXqthYHjEp+8gQ5p96K9jUp8nbVOxCdRbtw==}
dev: false
/natural-compare@1.4.0:
resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==}
dev: true
@ -3728,9 +3913,9 @@ packages:
optional: true
dependencies:
typescript: 5.4.2
dev: false
dev: true
/ts-jest@29.1.2(@babel/core@7.24.0)(jest@29.7.0)(typescript@5.4.2):
/ts-jest@29.1.2(@babel/core@7.24.0)(esbuild@0.20.1)(jest@29.7.0)(typescript@5.4.2):
resolution: {integrity: sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==}
engines: {node: ^16.10.0 || ^18.0.0 || >=20.0.0}
hasBin: true
@ -3753,6 +3938,7 @@ packages:
dependencies:
'@babel/core': 7.24.0
bs-logger: 0.2.6
esbuild: 0.20.1
fast-json-stable-stringify: 2.1.0
jest: 29.7.0
jest-util: 29.7.0
@ -3778,6 +3964,7 @@ packages:
resolution: {integrity: sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==}
engines: {node: '>=14.17'}
hasBin: true
dev: true
/uc.micro@1.0.6:
resolution: {integrity: sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==}
@ -3944,14 +4131,6 @@ packages:
resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==}
dev: true
/xxhash@0.3.0:
resolution: {integrity: sha512-1ud2yyPiR1DJhgyF1ZVMt+Ijrn0VNS/wzej1Z8eSFfkNfRPp8abVZNV2u9tYy9574II0ZayZYZgJm8KJoyGLCw==}
engines: {node: '>=4.0.0'}
requiresBuild: true
dependencies:
nan: 2.19.0
dev: false
/y18n@5.0.8:
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
engines: {node: '>=10'}

View File

@ -241,7 +241,8 @@ class BytebeatProcessor extends AudioWorkletProcessor {
if (this.songData.mode === "Funcbeat") {
this.func = this.func();
}
this.func(0);
this.func(0); // TODO: samplerate is undefined, not good for funcbeat
// this also has side effects
} catch (err) {
// TODO: handle arbitrary thrown objects, and modified Errors
if (errType === "compile") {

View File

@ -622,6 +622,7 @@ function setSampleRate(sampleRate: number) {
const rate = Math.min(Math.max(Math.fround(sampleRate), 2), 2 ** 24 - 1);
elements.sampleRate.value = f32ToRound10(rate);
songData.sampleRate = rate;
// TODO if funcbeat change time so that sec stays the same
audioWorklet.port.postMessage({ songData, updateSampleRatio: true });
toggleTimeCursor();
}

View File

@ -279,7 +279,7 @@ html(lang="en")
h2 SArpnt — code SArpnt created
#library-sarpnt
footer
a.link(target="_blank" href="https://dollchan.net/btb") Dollchan Discussion threads
a.link(target="_blank" href="https://dollchan.net/btb") Dollchan Discussion board
br
a.link(
target="_blank"

View File

@ -3700,6 +3700,15 @@ const library: DeepReadonly<{
codeOriginal:
'(t>>4&t/("SArpnt".charCodeAt(t/2/"76547698"[t>>13&7]*(t>>10&3)%6)+t/(t>>17&1|2)%2))+(t>>12&1?-1:sin(t))',
},
{
description: "boots in bed",
url: "https://dollchan.net/btb/res/141.html#141",
date: "2022-08-14",
mode: "Funcbeat",
sampleRate: 48000,
codeOriginal:
'return s=s=>2**(("023578"[s%7|0]||10)/12+(s/7|0)+7.5),o=(t,b)=>(O=[O=t>12&&sin(b*200)/4+(t*s("0035"[t/3&3])/4%1>t/3%1)/4*b||0,O],(T=>{for(i=0;i<9;i++)(N=t-3/8*i)<0||(n=N*s(N%3*4-(N/3&2)+7),O[i%2]+=N<132&&T(n+N%3/9*T(n/((N/3&3)+1)))*(1-N*4%1)/3*.6**i)})(t=>abs(t%1*4-2)-1),O),t=>t>127?o(t+4):o(t>48?(a=t%1,x=t*2&7,(t/4|0)*3+(t>96?(t&3)+a-(x>3):[a,(t&3)+[a%(1/12),(a-1)**2,a,a-.5,a*3/2,a*2/3,a-1,a-1][x],[a*3/2,a,a*3/2,(a-1)**2,a,a-.5,a*2/3,a*2/4][x]][t/16-3|0])):t,t<24||(t*(t/8-13|0?2:1)%1)**.4)',
},
],
};