Merge branch 'main' into VorTechnix

This commit is contained in:
VorTechnix 2022-09-18 12:33:20 -07:00
commit 0e2076e6f9
47 changed files with 969 additions and 54 deletions

View File

@ -7,8 +7,15 @@ const path = require("path");
const debug = require("debug");
const htmlentities = require("html-entities");
const phin = require("phin");
const CleanCSS = require("clean-css");
const { minify: minify_html } = require("html-minifier-terser");
const HTMLPicture = require("./lib/HTMLPicture.js");
const FileFetcher = require("./lib/FileFetcher.js");
const file_fetcher = new FileFetcher();
const is_production = typeof process.env.NODE_ENV === "string" && process.env.NODE_ENV === "production";
var nextid = 0;
@ -60,10 +67,6 @@ async function shortcode_gallerybox(content, src, idthis, idprev, idnext) {
}
async function fetch(url) {
const pkg_obj = JSON.parse(await fs.promises.readFile(
path.join(__dirname, "package.json"), "utf8"
));
return (await phin({
url,
headers: {
@ -74,9 +77,56 @@ async function fetch(url) {
})).body;
}
function fetch_file(url) {
return file_fetcher.fetch_file(url);
}
function do_minifycss(source, output_path) {
if(!output_path.endsWith(".css") || !is_production) return source;
const result = new CleanCSS({
level: 2
}).minify(source).styles.trim();
console.log(`MINIFY ${output_path}`, source.length, ``, result.length, `(${((1 - (result.length / source.length)) * 100).toFixed(2)}% reduction)`);
return result;
}
async function do_minifyhtml(source, output_path) {
if(!output_path.endsWith(".html") || !is_production) return source;
const result = await minify_html(source, {
collapseBooleanAttributes: true,
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
continueOnParseError: true,
decodeEntities: true,
keepClosingSlash: true,
minifyCSS: true,
quoteCharacter: `"`,
removeComments: true,
removeAttributeQuotes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
sortAttributes: true,
sortClassName: true,
useShortDoctype: true
});
console.log(`MINIFY ${output_path}`, source.length, ``, result.length, `(${((1 - (result.length / source.length)) * 100).toFixed(2)}% reduction)`);
return result;
}
if(is_production) console.log("Production environment detected, minifying content");
module.exports = function(eleventyConfig) {
eleventyConfig.addTransform("cssmin", do_minifycss);
eleventyConfig.addTransform("htmlmin", do_minifyhtml);
eleventyConfig.addPassthroughCopy("img2brush/img2brush.js");
eleventyConfig.addAsyncShortcode("fetch", fetch);
eleventyConfig.addFilter("fetch_file", fetch_file);
// eleventyConfig.addPassthroughCopy("images");
// eleventyConfig.addPassthroughCopy("css");

View File

@ -45,11 +45,11 @@
{{ content | safe }}
<footer class="shadow-top">
<p>WorldEditAdditions built with ❤️ by these awesome people:</p>
<p>WorldEditAdditions is built with ❤️ by these awesome people:</p>
<ul class="contributor-list">
{% for contributor in contributors %}
<li><a href="{{ contributor.profile_url }}">
<img class="icon large" src="{{ contributor.avatar_url }}" alt="{{ contributor.name }}" />
<img class="icon large" src="{{ contributor.avatar_url | fetch_file }}" alt="{{ contributor.name }}" />
<span>{{ contributor.name }}</span>
</a></li>
{% endfor %}

View File

@ -1,13 +1,13 @@
---
permalink: theme.css
---
{% include "css/patterns.css" %}
{% include "css/theme.css" %}
{% include "css/gallerybox.css" %}
{% include "css/smallscreens.css" %}
{% include "css/prism-custom.css" %}
{# {% fetch "https://unpkg.com/prismjs/themes/prism-okaidia.css" %} #}
{# {% fetch "https://raw.githubusercontent.com/PrismJS/prism-themes/master/themes/prism-shades-of-purple.css" %} #}
{# {% fetch "https://raw.githubusercontent.com/PrismJS/prism-themes/master/themes/prism-material-light.css" %} #}

65
.docs/lib/FileFetcher.js Normal file
View File

@ -0,0 +1,65 @@
"use strict";
const path = require("path");
const fs = require("fs");
const os = require("os");
const phin = require("phin");
const a = require("./Ansi.js");
const pretty_ms = require("pretty-ms");
class FileFetcher {
#cache = [];
#pkg_obj = null;
constructor() {
}
fetch_file(url) {
let target_client = path.join(`/img`, path.basename(url));
if(this.#cache.includes(url)) return target_client;
this.#cache.push(url);
this.download_file(url); // Returns a promise! We fire-and-forget it though 'cause this function *must* be synchronous :-/
return target_client;
}
async download_file(url) {
const time_start = new Date();
if(this.#pkg_obj === null) {
this.#pkg_obj = JSON.parse(await fs.promises.readFile(
path.join(path.dirname(__dirname), "package.json"), "utf8"
));
}
let target_download = path.join(`_site/img`, path.basename(url));
const response = await phin({
url,
headers: {
"user-agent": `WorldEditAdditionsStaticBuilder/${this.#pkg_obj.version} (Node.js/${process.version}; ${os.platform()} ${os.arch()}) eleventy/${this.#pkg_obj.dependencies["@11ty/eleventy"].replace(/\^/, "")}`
},
followRedirects: true,
parse: 'none' // Returns a Buffer
// If we stream and pipe to a file, the build never ends :-/
});
await fs.promises.writeFile(target_download, response.body);
console.log([
`${a.fred}${a.hicol}FETCH_FILE${a.reset}`,
`${a.fyellow}${pretty_ms(new Date() - time_start)}${a.reset}`,
`${a.fgreen}${url}${a.reset}`
].join("\t"));
}
}
module.exports = FileFetcher;

View File

@ -74,7 +74,7 @@ async function srcset(source_image, target_dir, urlpath, format = "__AUTO__", si
quality,
strip
});
console.log(`IMAGE\t${a.fcyan}${queue.size}/${queue.pending} tasks${a.reset}\t${a.fyellow}${pretty_ms(new Date() - start)}${a.reset}\t${a.fgreen}${target_current}${a.reset}`);
console.log(`${a.fmagenta}${a.hicol}IMAGE${a.reset}\t${a.fcyan}${queue.size}/${queue.pending} tasks${a.reset}\t${a.fyellow}${pretty_ms(new Date() - start)}${a.reset}\t${a.fgreen}${target_current}${a.reset}`);
});
// const size_target = await imagickal.dimensions(target_current);

466
.docs/package-lock.json generated
View File

@ -9,7 +9,9 @@
"version": "1.0.0",
"license": "MPL-2.0",
"dependencies": {
"html-entities": "^2.3.3"
"clean-css": "^5.3.1",
"html-entities": "^2.3.3",
"html-minifier-terser": "^7.0.0-beta.0"
},
"devDependencies": {
"@11ty/eleventy": "^1.0.1",
@ -18,8 +20,8 @@
"debug": "^4.3.4",
"imagickal": "^5.0.1",
"markdown-it-prism": "^2.2.4",
"p-memoize": "^6.0.1",
"p-queue": "^7.2.0",
"p-memoize": "^7.1.0",
"p-queue": "^7.3.0",
"phin": "^3.6.1",
"pretty-ms": "^7.0.1"
}
@ -99,10 +101,13 @@
}
},
"node_modules/@babel/helper-validator-identifier": {
"version": "7.14.0",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.0.tgz",
"integrity": "sha512-V3ts7zMSu5lfiwWDVWzRDGIN+lnCEUdaXgtVHJgLb1rGaA6jMrtB9EmE7L18foXJIE8Un/A/h6NJfGQp/e1J4A==",
"dev": true
"version": "7.18.6",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz",
"integrity": "sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==",
"dev": true,
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/parser": {
"version": "7.14.4",
@ -132,6 +137,58 @@
"integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==",
"dev": true
},
"node_modules/@jridgewell/gen-mapping": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz",
"integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==",
"dependencies": {
"@jridgewell/set-array": "^1.0.1",
"@jridgewell/sourcemap-codec": "^1.4.10",
"@jridgewell/trace-mapping": "^0.3.9"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@jridgewell/resolve-uri": {
"version": "3.0.8",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.8.tgz",
"integrity": "sha512-YK5G9LaddzGbcucK4c8h5tWFmMPBvRZ/uyWmN1/SbBdIvqGUdWGkJ5BAaccgs6XbzVLsqbPJrBSFwKv3kT9i7w==",
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@jridgewell/set-array": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz",
"integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==",
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@jridgewell/source-map": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz",
"integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==",
"dependencies": {
"@jridgewell/gen-mapping": "^0.3.0",
"@jridgewell/trace-mapping": "^0.3.9"
}
},
"node_modules/@jridgewell/sourcemap-codec": {
"version": "1.4.14",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz",
"integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw=="
},
"node_modules/@jridgewell/trace-mapping": {
"version": "0.3.14",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz",
"integrity": "sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ==",
"dependencies": {
"@jridgewell/resolve-uri": "^3.0.3",
"@jridgewell/sourcemap-codec": "^1.4.10"
}
},
"node_modules/@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@ -554,6 +611,11 @@
"integrity": "sha1-YbU5PxH1JVntEgaTEANDtu2wTdU=",
"dev": true
},
"node_modules/buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
@ -576,6 +638,15 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/camel-case": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz",
"integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==",
"dependencies": {
"pascal-case": "^3.1.2",
"tslib": "^2.0.3"
}
},
"node_modules/centra": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/centra/-/centra-2.4.2.tgz",
@ -640,6 +711,17 @@
"integrity": "sha512-U9eDw6+wt7V8z5NncY2jJfZa+hUH8XEj8FQHgFJTrUFnJfXYf4Ml4adI2vXZOjqRDpFWtYVWypDfZwnJ+HIR4A==",
"dev": true
},
"node_modules/clean-css": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.1.tgz",
"integrity": "sha512-lCr8OHhiWCTw4v8POJovCoh4T7I9U11yVsPjMWWnnMmp9ZowCxyad1Pathle/9HjaDp+fdQKjO9fQydE6RHTZg==",
"dependencies": {
"source-map": "~0.6.0"
},
"engines": {
"node": ">= 10.0"
}
},
"node_modules/cliui": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",
@ -907,6 +989,15 @@
"integrity": "sha1-6oCxBqh1OHdOijpKWv4pPeSJ4Kk=",
"dev": true
},
"node_modules/dot-case": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz",
"integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==",
"dependencies": {
"no-case": "^3.0.4",
"tslib": "^2.0.3"
}
},
"node_modules/easy-extender": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/easy-extender/-/easy-extender-2.3.4.tgz",
@ -1456,6 +1547,56 @@
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.3.tgz",
"integrity": "sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA=="
},
"node_modules/html-minifier-terser": {
"version": "7.0.0-beta.0",
"resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-7.0.0-beta.0.tgz",
"integrity": "sha512-+yXD10PBrTJdwTQ0QhEVnixsYkeUtQM5GKubazGKW9v3yOoyBM6bIbFDZZZ9A0zwjv5O8ZmgQHrupd7DqW7BrA==",
"dependencies": {
"camel-case": "^4.1.2",
"clean-css": "5.2.0",
"commander": "^9.3.0",
"entities": "^4.3.0",
"param-case": "^3.0.4",
"relateurl": "^0.2.7",
"terser": "^5.14.0"
},
"bin": {
"html-minifier-terser": "cli.js"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}
},
"node_modules/html-minifier-terser/node_modules/clean-css": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.2.0.tgz",
"integrity": "sha512-2639sWGa43EMmG7fn8mdVuBSs6HuWaSor+ZPoFWzenBc6oN+td8YhTfghWXZ25G1NiiSvz8bOFBS7PdSbTiqEA==",
"dependencies": {
"source-map": "~0.6.0"
},
"engines": {
"node": ">= 10.0"
}
},
"node_modules/html-minifier-terser/node_modules/commander": {
"version": "9.3.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-9.3.0.tgz",
"integrity": "sha512-hv95iU5uXPbK83mjrJKuZyFM/LBAoCV/XhVGkS5Je6tl7sxr6A0ITMw5WoRV46/UaJ46Nllm3Xt7IaJhXTIkzw==",
"engines": {
"node": "^12.20.0 || >=14"
}
},
"node_modules/html-minifier-terser/node_modules/entities": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/entities/-/entities-4.3.1.tgz",
"integrity": "sha512-o4q/dYJlmyjP2zfnaWDUC6A3BQFmVTX+tZPezK7k0GLSU9QYCauscf5Y+qcEPzKL+EixVouYDgLQK5H9GrLpkg==",
"engines": {
"node": ">=0.12"
},
"funding": {
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/http-errors": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
@ -1919,6 +2060,14 @@
"integrity": "sha1-+4m2WpqAKBgz8LdHizpRBPiY67M=",
"dev": true
},
"node_modules/lower-case": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz",
"integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==",
"dependencies": {
"tslib": "^2.0.3"
}
},
"node_modules/lru-cache": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz",
@ -2178,6 +2327,15 @@
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
"dev": true
},
"node_modules/no-case": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz",
"integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==",
"dependencies": {
"lower-case": "^2.0.2",
"tslib": "^2.0.3"
}
},
"node_modules/nopt": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz",
@ -2276,24 +2434,24 @@
}
},
"node_modules/p-memoize": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/p-memoize/-/p-memoize-6.0.1.tgz",
"integrity": "sha512-DG0wxA5fIYor0ypRltebDEZs45ZFRvgztFGv/+glYMdUCIaI9eZKIsNJ2IVihw6LYVUgfhIHtPG5XUgvN+pLtQ==",
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/p-memoize/-/p-memoize-7.1.0.tgz",
"integrity": "sha512-CvZTCSwDg0JBLhZtvY5jSfrHwNAFrQfL+0X0GPVgwtTpruhHGTmdGkx8NSA5WNkti9N8FrHfsseFX1GW4guLww==",
"dev": true,
"dependencies": {
"mimic-fn": "^4.0.0"
},
"engines": {
"node": ">=12.20"
"node": ">=14.16"
},
"funding": {
"url": "https://github.com/sindresorhus/p-memoize?sponsor=1"
}
},
"node_modules/p-queue": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/p-queue/-/p-queue-7.2.0.tgz",
"integrity": "sha512-Kvv7p13M46lTYLQ/PsZdaj/1Vj6u/8oiIJgyQyx4oVkOfHdd7M2EZvXigDvcsSzRwanCzQirV5bJPQFoSQt5MA==",
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/p-queue/-/p-queue-7.3.0.tgz",
"integrity": "sha512-5fP+yVQ0qp0rEfZoDTlP2c3RYBgxvRsw30qO+VtPPc95lyvSG+x6USSh1TuLB4n96IO6I8/oXQGsTgtna4q2nQ==",
"dev": true,
"dependencies": {
"eventemitter3": "^4.0.7",
@ -2318,6 +2476,15 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/param-case": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz",
"integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==",
"dependencies": {
"dot-case": "^3.0.4",
"tslib": "^2.0.3"
}
},
"node_modules/parse-ms": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-2.1.0.tgz",
@ -2336,6 +2503,15 @@
"node": ">= 0.8"
}
},
"node_modules/pascal-case": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz",
"integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==",
"dependencies": {
"no-case": "^3.0.4",
"tslib": "^2.0.3"
}
},
"node_modules/path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
@ -2711,6 +2887,14 @@
"mkdirp": "bin/cmd.js"
}
},
"node_modules/relateurl": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz",
"integrity": "sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
@ -3191,11 +3375,19 @@
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/source-map-support": {
"version": "0.5.21",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
"dependencies": {
"buffer-from": "^1.0.0",
"source-map": "^0.6.0"
}
},
"node_modules/sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
@ -3289,6 +3481,39 @@
"node": ">=0.10.0"
}
},
"node_modules/terser": {
"version": "5.14.2",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.14.2.tgz",
"integrity": "sha512-oL0rGeM/WFQCUd0y2QrWxYnq7tfSuKBiqTjRPWrRgB46WD/kiwHwF8T23z78H6Q6kGCuuHcPB+KULHRdxvVGQA==",
"dependencies": {
"@jridgewell/source-map": "^0.3.2",
"acorn": "^8.5.0",
"commander": "^2.20.0",
"source-map-support": "~0.5.20"
},
"bin": {
"terser": "bin/terser"
},
"engines": {
"node": ">=10"
}
},
"node_modules/terser/node_modules/acorn": {
"version": "8.7.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz",
"integrity": "sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A==",
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/terser/node_modules/commander": {
"version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ=="
},
"node_modules/tfunk": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/tfunk/-/tfunk-4.0.0.tgz",
@ -3399,6 +3624,11 @@
"integrity": "sha1-zCAOqyYT9BZtJ/+a/HylbUnfbrQ=",
"dev": true
},
"node_modules/tslib": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
"integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ=="
},
"node_modules/ua-parser-js": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.2.tgz",
@ -3682,9 +3912,9 @@
}
},
"@babel/helper-validator-identifier": {
"version": "7.14.0",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.0.tgz",
"integrity": "sha512-V3ts7zMSu5lfiwWDVWzRDGIN+lnCEUdaXgtVHJgLb1rGaA6jMrtB9EmE7L18foXJIE8Un/A/h6NJfGQp/e1J4A==",
"version": "7.18.6",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz",
"integrity": "sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==",
"dev": true
},
"@babel/parser": {
@ -3709,6 +3939,49 @@
"integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==",
"dev": true
},
"@jridgewell/gen-mapping": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz",
"integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==",
"requires": {
"@jridgewell/set-array": "^1.0.1",
"@jridgewell/sourcemap-codec": "^1.4.10",
"@jridgewell/trace-mapping": "^0.3.9"
}
},
"@jridgewell/resolve-uri": {
"version": "3.0.8",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.8.tgz",
"integrity": "sha512-YK5G9LaddzGbcucK4c8h5tWFmMPBvRZ/uyWmN1/SbBdIvqGUdWGkJ5BAaccgs6XbzVLsqbPJrBSFwKv3kT9i7w=="
},
"@jridgewell/set-array": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz",
"integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw=="
},
"@jridgewell/source-map": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz",
"integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==",
"requires": {
"@jridgewell/gen-mapping": "^0.3.0",
"@jridgewell/trace-mapping": "^0.3.9"
}
},
"@jridgewell/sourcemap-codec": {
"version": "1.4.14",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz",
"integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw=="
},
"@jridgewell/trace-mapping": {
"version": "0.3.14",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz",
"integrity": "sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ==",
"requires": {
"@jridgewell/resolve-uri": "^3.0.3",
"@jridgewell/sourcemap-codec": "^1.4.10"
}
},
"@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@ -4052,6 +4325,11 @@
"integrity": "sha1-YbU5PxH1JVntEgaTEANDtu2wTdU=",
"dev": true
},
"buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="
},
"bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
@ -4068,6 +4346,15 @@
"get-intrinsic": "^1.0.2"
}
},
"camel-case": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz",
"integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==",
"requires": {
"pascal-case": "^3.1.2",
"tslib": "^2.0.3"
}
},
"centra": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/centra/-/centra-2.4.2.tgz",
@ -4115,6 +4402,14 @@
"integrity": "sha512-U9eDw6+wt7V8z5NncY2jJfZa+hUH8XEj8FQHgFJTrUFnJfXYf4Ml4adI2vXZOjqRDpFWtYVWypDfZwnJ+HIR4A==",
"dev": true
},
"clean-css": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.1.tgz",
"integrity": "sha512-lCr8OHhiWCTw4v8POJovCoh4T7I9U11yVsPjMWWnnMmp9ZowCxyad1Pathle/9HjaDp+fdQKjO9fQydE6RHTZg==",
"requires": {
"source-map": "~0.6.0"
}
},
"cliui": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",
@ -4333,6 +4628,15 @@
"integrity": "sha1-6oCxBqh1OHdOijpKWv4pPeSJ4Kk=",
"dev": true
},
"dot-case": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz",
"integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==",
"requires": {
"no-case": "^3.0.4",
"tslib": "^2.0.3"
}
},
"easy-extender": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/easy-extender/-/easy-extender-2.3.4.tgz",
@ -4755,6 +5059,40 @@
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.3.tgz",
"integrity": "sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA=="
},
"html-minifier-terser": {
"version": "7.0.0-beta.0",
"resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-7.0.0-beta.0.tgz",
"integrity": "sha512-+yXD10PBrTJdwTQ0QhEVnixsYkeUtQM5GKubazGKW9v3yOoyBM6bIbFDZZZ9A0zwjv5O8ZmgQHrupd7DqW7BrA==",
"requires": {
"camel-case": "^4.1.2",
"clean-css": "5.2.0",
"commander": "^9.3.0",
"entities": "^4.3.0",
"param-case": "^3.0.4",
"relateurl": "^0.2.7",
"terser": "^5.14.0"
},
"dependencies": {
"clean-css": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.2.0.tgz",
"integrity": "sha512-2639sWGa43EMmG7fn8mdVuBSs6HuWaSor+ZPoFWzenBc6oN+td8YhTfghWXZ25G1NiiSvz8bOFBS7PdSbTiqEA==",
"requires": {
"source-map": "~0.6.0"
}
},
"commander": {
"version": "9.3.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-9.3.0.tgz",
"integrity": "sha512-hv95iU5uXPbK83mjrJKuZyFM/LBAoCV/XhVGkS5Je6tl7sxr6A0ITMw5WoRV46/UaJ46Nllm3Xt7IaJhXTIkzw=="
},
"entities": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/entities/-/entities-4.3.1.tgz",
"integrity": "sha512-o4q/dYJlmyjP2zfnaWDUC6A3BQFmVTX+tZPezK7k0GLSU9QYCauscf5Y+qcEPzKL+EixVouYDgLQK5H9GrLpkg=="
}
}
},
"http-errors": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
@ -5116,6 +5454,14 @@
"integrity": "sha1-+4m2WpqAKBgz8LdHizpRBPiY67M=",
"dev": true
},
"lower-case": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz",
"integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==",
"requires": {
"tslib": "^2.0.3"
}
},
"lru-cache": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz",
@ -5316,6 +5662,15 @@
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
"dev": true
},
"no-case": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz",
"integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==",
"requires": {
"lower-case": "^2.0.2",
"tslib": "^2.0.3"
}
},
"nopt": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz",
@ -5382,18 +5737,18 @@
}
},
"p-memoize": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/p-memoize/-/p-memoize-6.0.1.tgz",
"integrity": "sha512-DG0wxA5fIYor0ypRltebDEZs45ZFRvgztFGv/+glYMdUCIaI9eZKIsNJ2IVihw6LYVUgfhIHtPG5XUgvN+pLtQ==",
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/p-memoize/-/p-memoize-7.1.0.tgz",
"integrity": "sha512-CvZTCSwDg0JBLhZtvY5jSfrHwNAFrQfL+0X0GPVgwtTpruhHGTmdGkx8NSA5WNkti9N8FrHfsseFX1GW4guLww==",
"dev": true,
"requires": {
"mimic-fn": "^4.0.0"
}
},
"p-queue": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/p-queue/-/p-queue-7.2.0.tgz",
"integrity": "sha512-Kvv7p13M46lTYLQ/PsZdaj/1Vj6u/8oiIJgyQyx4oVkOfHdd7M2EZvXigDvcsSzRwanCzQirV5bJPQFoSQt5MA==",
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/p-queue/-/p-queue-7.3.0.tgz",
"integrity": "sha512-5fP+yVQ0qp0rEfZoDTlP2c3RYBgxvRsw30qO+VtPPc95lyvSG+x6USSh1TuLB4n96IO6I8/oXQGsTgtna4q2nQ==",
"dev": true,
"requires": {
"eventemitter3": "^4.0.7",
@ -5406,6 +5761,15 @@
"integrity": "sha512-sEmji9Yaq+Tw+STwsGAE56hf7gMy9p0tQfJojIAamB7WHJYJKf1qlsg9jqBWG8q9VCxKPhZaP/AcXwEoBcYQhQ==",
"dev": true
},
"param-case": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz",
"integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==",
"requires": {
"dot-case": "^3.0.4",
"tslib": "^2.0.3"
}
},
"parse-ms": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-2.1.0.tgz",
@ -5418,6 +5782,15 @@
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"dev": true
},
"pascal-case": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz",
"integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==",
"requires": {
"no-case": "^3.0.4",
"tslib": "^2.0.3"
}
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
@ -5734,6 +6107,11 @@
}
}
},
"relateurl": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz",
"integrity": "sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog=="
},
"require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
@ -6127,8 +6505,16 @@
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
},
"source-map-support": {
"version": "0.5.21",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
"requires": {
"buffer-from": "^1.0.0",
"source-map": "^0.6.0"
}
},
"sprintf-js": {
"version": "1.0.3",
@ -6201,6 +6587,29 @@
"integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ=",
"dev": true
},
"terser": {
"version": "5.14.2",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.14.2.tgz",
"integrity": "sha512-oL0rGeM/WFQCUd0y2QrWxYnq7tfSuKBiqTjRPWrRgB46WD/kiwHwF8T23z78H6Q6kGCuuHcPB+KULHRdxvVGQA==",
"requires": {
"@jridgewell/source-map": "^0.3.2",
"acorn": "^8.5.0",
"commander": "^2.20.0",
"source-map-support": "~0.5.20"
},
"dependencies": {
"acorn": {
"version": "8.7.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz",
"integrity": "sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A=="
},
"commander": {
"version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ=="
}
}
},
"tfunk": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/tfunk/-/tfunk-4.0.0.tgz",
@ -6286,6 +6695,11 @@
"integrity": "sha1-zCAOqyYT9BZtJ/+a/HylbUnfbrQ=",
"dev": true
},
"tslib": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
"integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ=="
},
"ua-parser-js": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.2.tgz",

View File

@ -19,19 +19,19 @@
"url": "https://github.com/sbrl/Minetest-WorldEditAdditions/issues"
},
"homepage": "https://github.com/sbrl/Minetest-WorldEditAdditions#readme",
"devDependencies": {
"dependencies": {
"@11ty/eleventy": "^1.0.1",
"chroma-js": "^2.4.2",
"columnify": "^1.6.0",
"debug": "^4.3.4",
"imagickal": "^5.0.1",
"markdown-it-prism": "^2.2.4",
"p-memoize": "^6.0.1",
"p-queue": "^7.2.0",
"p-memoize": "^7.1.0",
"p-queue": "^7.3.0",
"phin": "^3.6.1",
"pretty-ms": "^7.0.1"
},
"dependencies": {
"html-entities": "^2.3.3"
"pretty-ms": "^7.0.1",
"clean-css": "^5.3.1",
"html-entities": "^2.3.3",
"html-minifier-terser": "^7.0.0-beta.0"
}
}

View File

@ -9,6 +9,8 @@ Note to self: See the bottom of this file for the release template text.
- Add `//metaball`, which renders 2 or more [metaballs](https://en.wikipedia.org/wiki/Metaballs) in Minetest
- Migrate from `depends.txt` to `mod.conf`
- `//sculpt`: Fix undefined `default` brush
- Commands that modify the terrain now ignore liquids
- [API] Add new `EventEmitter` class modelled on `EventEmitter` from Node.js
## v1.13: The transformational update (2nd January 2022)

157
bresenham.lua Normal file
View File

@ -0,0 +1,157 @@
local Vector3 = dofile("worldeditadditions/utils/vector3.lua")
local function make_grid(size)
local grid = {}
for y=1,size.y do
for x=1,size.x do
grid[(size.x * y) + x] = 0
end
end
return {
size = size,
data = grid
}
end
local function index(grid, pos)
return (grid.size.x * pos.y) + pos.x
end
local function grid_to_string(grid)
local result = {}
for y=1,grid.size.y do
for x=1,grid.size.x do
local i = index(grid, Vector3.new(x, y))
if grid.data[i] == 0 then
table.insert(result, "#")
elseif grid.data[i] == 1 then
table.insert(result, " ")
elseif grid.data[i] < 10 then
table.insert(result, tostring(grid.data[i]))
else
table.insert(result, "?")
end
end
table.insert(result, "\n")
end
return table.concat(result, "")
end
--- Draws a line using Bresenham's algorithm in 2d.
-- Implemented ported from https://github.com/anushaihalapathirana/Bresenham-line-drawing-algorithm/blob/f51f153459a1656bfb1f433edc75e6644a052bb2/src/index.js
-- @param grid Grid The grid to draw on.
-- @param pos1 Vector3 The starting point of the line.
-- @param pos2 Vector3 The ending point of the line.
-- @param value number The number to fill in grid cells we draw in.
-- @returns void
local function draw_line_2d(grid, pos1, pos2, value)
if not value then value = 1 end
if pos1 == pos2 then
grid.data[index(grid, pos1)] = value
return
end
grid.data[index(grid, pos1)] = value -- plot pos1
local delta = pos2 - pos1
local absdelta = delta:abs()
local delta_error = (2 * absdelta.y) - absdelta.x -- d
if absdelta.x <= absdelta.y then delta_error = (2 * absdelta.x) - absdelta.y end
local pos_current = pos1:clone()
local steps = 0
local limit = absdelta.y
if absdelta.x > absdelta.y then limit = absdelta.x end
for _=1,limit do
local do_x = false
local do_y = false
if absdelta.x > absdelta.y then
do_x = true
if delta_error < 0 then
delta_error = delta_error + 2*absdelta.y
else
do_y = true
delta_error = delta_error + (2*absdelta.y - 2*absdelta.x)
end
else
do_y = true
if delta_error < 0 then
delta_error = delta_error + 2*absdelta.x
else
do_x = true
delta_error = delta_error + (2*absdelta.x) - (2*absdelta.y)
end
end
if do_x then
local acc = 1
if delta.x < 0 then acc = -1 end
pos_current.x = pos_current.x + acc
end
if do_y then
local acc = 1
if delta.y < 0 then acc = -1 end
pos_current.y = pos_current.y + acc
end
local i = index(grid, pos_current)
grid.data[i] = value
steps = steps + 1
end
end
local size = Vector3.new(120, 40)
local grid = make_grid(size)
-- draw_line_2d(grid, Vector3.new(10, 10), Vector3.new(40, 10))
-- draw_line_2d(grid, Vector3.new(70, 10), Vector3.new(70, 10))
draw_line_2d(grid, Vector3.new(75, 10), Vector3.new(75, 40))
draw_line_2d(grid, Vector3.new(80, 40), Vector3.new(80, 10))
-- local centre = Vector3.new(25, 25)
-- draw_line_2d(grid, centre, Vector3.new(0, 0))
-- draw_line_2d(grid, centre, Vector3.new(5, 0))
-- draw_line_2d(grid, centre, Vector3.new(10, 0))
-- draw_line_2d(grid, centre, Vector3.new(15, 0))
-- draw_line_2d(grid, centre, Vector3.new(20, 0))
-- draw_line_2d(grid, centre, Vector3.new(25, 0))
-- draw_line_2d(grid, centre, Vector3.new(30, 0), 3)
for i=1,9 do
print("LINE", i)
local pos1 = Vector3.new(
math.random(0, size.x),
math.random(0, size.y)
)
local pos2 = Vector3.new(
math.random(0, size.x),
math.random(0, size.y)
)
draw_line_2d(grid, pos1, pos2)
end
-- draw_line_2d(grid,
-- Vector3.new(3, 4),
-- Vector3.new(8, 9)
-- )
-- draw_line_2d(grid,
-- Vector3.new(10, 9),
-- Vector3.new(15, 4)
-- )
-- draw_line_2d(grid,
-- Vector3.new(20, 10),
-- Vector3.new(40, 20)
-- )
-- draw_line_2d(grid,
-- Vector3.new(10, 9),
-- Vector3.new(55, 4)
-- )
print(grid_to_string(grid))

View File

@ -91,6 +91,9 @@ npm install;
log_msg "Building website";
# This causes the eleventy docs site to minify stuff
# Note that this is NOT before the npm install, as npm doesn't install everything if we do that
export NODE_ENV=production;
npm run build;
if [[ ! -d "_site" ]]; then

View File

@ -35,7 +35,7 @@ function worldeditadditions.conv.kernel_gaussian(dimension, sigma)
-- http://en.wikipedia.org/w/index.php?title=Gaussian_blur&oldid=608793634#Mechanics
local gaussian = (1 / math.sqrt(
math.pi * two_sigma_square
)) * math.exp((-1) * (math.pow(distance, 2) / two_sigma_square));
)) * math.exp((-1) * ((distance ^ 2) / two_sigma_square));
sum = sum + gaussian
kernel[i*dimension + j] = gaussian

View File

@ -23,7 +23,7 @@ else
powtab = { 1 }
}
for b = 1, bit_local.bits - 1 do
bit_local.powtab[#bit_local.powtab + 1] = math.pow(2, b)
bit_local.powtab[#bit_local.powtab + 1] = 2 ^ b
end
end
@ -68,7 +68,7 @@ end
-- bit_local.bnot
if not bit_local.bnot then
bit_local.bnot = function(x)
return bit_local.bxor(x, math.pow((bit_local.bits or math.floor(math.log(x, 2))), 2) - 1)
return bit_local.bxor(x, (bit_local.bits or math.floor(math.log(x, 2)) ^ 2) - 1)
end
end

View File

@ -8,6 +8,6 @@ function worldeditadditions.format.human_size(n, decimals)
local sizes = { "", "K", "M", "G", "T", "P", "E", "Y", "Z" }
local factor = math.floor((#tostring(n) - 1) / 3)
local multiplier = 10^(decimals or 0)
local result = math.floor(0.5 + (n / math.pow(1000, factor)) * multiplier) / multiplier
local result = math.floor(0.5 + (n / (1000 ^ factor)) * multiplier) / multiplier
return result .. sizes[factor+1]
end

View File

@ -5,8 +5,8 @@ function worldeditadditions.round(num, numDecimalPlaces)
end
function worldeditadditions.hypotenuse(x1, y1, x2, y2)
local xSquare = math.pow(x1 - x2, 2);
local ySquare = math.pow(y1 - y2, 2);
local xSquare = (x1 - x2) ^ 2;
local ySquare = (y1 - y2) ^ 2;
return math.sqrt(xSquare + ySquare);
end

View File

@ -4,7 +4,9 @@
-- This is needed because in Lua 5.1 it's the global unpack(), but in Lua 5.4
-- it's moved to table.unpack().
local function table_unpack(tbl, offset, count)
---@diagnostic disable-next-line: deprecated
if type(unpack) == "function" then
---@diagnostic disable-next-line: deprecated
return unpack(tbl, offset, count)
else
return table.unpack(tbl, offset, count)

View File

@ -23,7 +23,7 @@ local function make_heightmap(pos1, pos2, manip, area, data)
-- Scan each column top to bottom
for y = pos2.y+1, pos1.y, -1 do
local i = area:index(x, y, z)
if not (wea.is_airlike(data[i]) or wea.is_liquidlike(data[i])) then
if not (wea.is_airlike(data[i]) and not wea.is_liquidlike(data[i])) then
-- It's the first non-airlike node in this column
-- Start heightmap values from 1 (i.e. there's at least 1 node in the column)
heightmap[hi] = (y - pos1.y) + 1

View File

@ -15,6 +15,6 @@ worldeditadditions_core.register_command("basename", {
end,
func = function(name, params_text)
if name == nil then return end
return true, worldedit.normalize_nodename(params_text) or 'Error 404: "'..params_text..'" not found!'
return true, worldedit.normalize_nodename(params_text) or ('Error 404: "'..params_text..'" not found!')
end
})

View File

@ -53,7 +53,7 @@ worldeditadditions_core.register_command("ellipsoidapply", {
worldedit.pos1[name], worldedit.pos2[name],
function()
cmd.func(name, worldeditadditions.table.unpack(args_parsed))
end, args_parsed
end --, args_parsed
)
local time_overhead = 100 - worldeditadditions.round((stats_time.fn / stats_time.all) * 100, 3)

View File

@ -0,0 +1,80 @@
--- Event manager object.
-- @class
local EventEmitter = {}
EventEmitter.__index = EventEmitter
EventEmitter.__name = "EventEmitter" -- A hack to allow identification in wea.inspect
--- Create a new event emitter.
-- @param tbl table|nil Optional. A table to base the new EventEmitter object on. EventEmitter will attach ann instance of itself to this object. The 'events' property on the object MUST NOT be set. IT WILL BE OVERWRITTEN!
-- @returns table The new EventEmitter object. If a table is passed in, a new table is NOT created.
function EventEmitter.new(tbl)
if not tbl then tbl = {} end
tbl.events = {}
setmetatable(tbl, EventEmitter)
return tbl
end
--- Add a new listener to the given named event.
-- @param this EventEmitter The EventEmitter instance to add the listener to.
-- @param event_name string The name of the event to listen on.
-- @param func function The callback function to call when the event is emitted.
-- @returns number The number of listeners attached to that event.
function EventEmitter.addEventListener(this, event_name, func)
if this.events[event_name] == nil then this.events[event_name] = {} end
table.insert(this.events[event_name], func)
local count = #this.events[event_name]
if count > 10 then
minetest.log("warning", count.." listeners registered for event "..event_name..", possible leak? You MUST remove listeners when you're done with them!")
end
return count
end
function EventEmitter.on(this, event_name, func)
return EventEmitter.addEventListener(this, event_name, func)
end
--- Remove an existing listener from the given named event.
-- @param this EventEmitter The EventEmitter instance to remove the listener from.
-- @param event_name string The name of the event to remove from.
-- @param func function The callback function to remove from the list of listeners for the given named event.
-- @return bool Whether it was actually removed or not. False means it failed to find the given listener function.
function EventEmitter.removeEventListener(this, event_name, func)
if this.events[event_name] == nil then return false end
for index, next_func in ipairs(this.events[event_name]) do
if next_func == func then
table.remove(this.events[event_name], index)
break
end
end
return true
end
function EventEmitter.off(this, event_name, func)
return EventEmitter.removeEventListener(this, event_name, func)
end
--- Emit an event.
-- @param this EventEmitter The EventEmitter instance to emit the event from.
-- @param event_name string The name of the event to emit.
-- @param args table|any The argument(s) to pass to listener functions. It is strongly advised you pass a table here.
function EventEmitter.emit(this, event_name, args)
if this.events[event_name] == nil then return end
for index,next_func in ipairs(this.events[event_name]) do
next_func(args)
end
-- TODO: Monitor execution time, log if it's slow? We'll need to move WEA utils over to wea_c first though...
end
--- Clear all listeners from a given event name.
-- @param this EventEmitter The EventEmitter instance to clear listeners from.
-- @param event_name string The name of the event to clear the listeners from.
function EventEmitter.clear(this, event_name)
this.events[event_name] = nil
end
--- Clear all listeners.
-- @param this EventEmitter The EventEmitter instance to clear listeners from.
function EventEmitter.clear_all(this, event_name)
this.events = {}
end
return EventEmitter

View File

@ -10,7 +10,7 @@ local function human_size(n, decimals)
local sizes = { "", "K", "M", "G", "T", "P", "E", "Y", "Z" }
local factor = math.floor((#tostring(n) - 1) / 3)
local multiplier = 10^(decimals or 0)
local result = math.floor(0.5 + (n / math.pow(1000, factor)) * multiplier) / multiplier
local result = math.floor(0.5 + (n / (1000 ^ factor)) * multiplier) / multiplier
return result .. sizes[factor+1]
end

View File

@ -0,0 +1,83 @@
local wea_c = worldeditadditions_core
local positions_count_limit = 999
local positions = {}
local anchor = nil
local function ensure_player(player_name)
if player_name == nil then
minetest.log("error", "[wea core:pos:ensure_player] player_name is nil")
end
if not positions[player_name] then
positions[player_name] = {}
end
end
--- Gets the position with the given index for the given player.
-- @param player_name string The name of the player to fetch the position for.
-- @param
local function get_pos(player_name, i)
ensure_player(player_name)
return positions[player_name][i]
end
local function get_pos1(player_name) return get_pos(player_name, 1) end
local function get_pos2(player_name) return get_pos(player_name, 2) end
local function get_pos_all(player_name)
ensure_player(player_name)
return positions[player_name]
end
local function pos_count(player_name)
ensure_player(player_name)
return #positions[player_name]
end
local function set_pos(player_name, i, pos)
if i > positions_count_limit then return false end
ensure_player(player_name)
positions[player_name][i] = pos
anchor:emit("set", { i = i, pos = pos })
return true
end
local function set_pos_all(player_name, i, pos_list)
if #pos_list > positions_count_limit then return false end
positions[player_name] = pos_list
for _i,pos_new in ipairs(positions[player_name]) do
anchor:emit("push", { pos = pos_new })
end
end
local function clear(player_name)
if positions[player_name] then
positions[player_name] = nil
end
anchor:emit("clear")
end
local function pop_pos(player_name)
ensure_player(player_name)
if #positions[player_name] <= 0 then return nil end
local last_pos = table.remove(positions[player_name])
anchor:emit("pop", { pos = last_pos })
return last_pos
end
local function push_pos(player_name, pos)
ensure_player(player_name)
table.insert(positions[player_name], pos)
anchor:emit("push", { pos = pos })
end
anchor = wea_c.EventEmitter.new({
get = get_pos,
get1 = get_pos1,
get2 = get_pos2,
get_all = get_pos_all,
count = pos_count,
clear = clear,
pop = pop_pos,
push = push_pos,
set = set_pos,
set_all = set_pos_all
})
return anchor

View File

@ -21,12 +21,14 @@ worldeditadditions_core = {
-- The default limit for new players on the number of potential nodes changed before safe_region kicks in.
safe_region_limit_default = 100000,
}
local wea_c = worldeditadditions_core
wea_c.EventEmitter = dofile(modpath.."/core/lib/EventEmitter.lua")
wea_c.pos = dofile(modpath.."/core/pos.lua")
wea_c.register_command = dofile(modpath.."/core/register_command.lua")
wea_c.fetch_command_def = dofile(modpath.."/core/fetch_command_def.lua")
wea_c.register_alias = dofile(modpath.."/core/register_alias.lua")
print("WEA_C pos", wea_c.pos.push)
-- Initialise WorldEdit stuff if the WorldEdit mod is not present
if minetest.global_exists("worldedit") then

View File

@ -1 +1 @@
{"modelVersion":2,"piskel":{"name":"worldedit_wand","description":"","fps":0,"height":16,"width":16,"layers":["{\"name\":\"Layer 1\",\"opacity\":1,\"frameCount\":4,\"chunks\":[{\"layout\":[[0],[1],[2],[3]],\"base64PNG\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAYAAACm53kpAAACy0lEQVRYR92XXUhTYRzGn5M7083NMks2FxGmYp9Wal2ERhBE0Ad5EUIQfRh6mRT5ERJiX3bRx42BdBMjKkgpI28qLE3KEimlC5kbmugmms6d6dqX/ziLI1aa77sYjM71nv/7/H7vOe/ZEcwCSJ8JvPMZUGt1CAjjmnmZQoJNQnBKgqoUXDMMxbGkXaXGMt0bON27YKuSuPJKXSIi+4gbU9MBpKcmMs8QmjcJ9L6XsOVAPgoaWpmDsws36Sk46UeMRwwJgA9QlbFL2G+2klNyh8ZNe4PoKt3G3WHYIVFCggYulwfjTg82ZiYzzxDK04yUlbka3W0dyNi+Bide9DOH5dJUrydFRrgCLN+y4ZeCiBFf4dizfFS1f+fqYLFNULxWxb37cu/Zhe7kGcjucEC7PgflTzuZCwRuYlaAvPtXm+K4ALY+TCav5EdwiuAbe4STLYe48vKt/6V3FLFqEUP2MTidE+i5wi7xF9DbhXlk62rDutwslNz/zC6h9qcEGT7HqEan3ccFIWdrdsaFZvDmX7dbyGRcAa/Pjz5rf0jAYB27xD8gq/cYyDU5Bm1aNmoedDBLUB4DGYQXYu65y5t/8vwDydDHj+4VwpE4L+C5giwyLHFB0Ohw1twT9RJ+f3HxSFwQrmKfkRI0ImaWr8WFuy3/rYS/gl0u2k3iuA0BQURlQ19YEgxLNXBMerjPBOVciHR+Uai6Uzk0PGCFaNqAi/feLvr7+W5HGcIy6sH1j3yvt7kSIpVnAqoszKUUlRsj4y7UNA8xZeaKOJ8bR+krw5cQyTwzzKXDqaQVBXwNxONWYzdzThERSQiWf+8Lrc8FcqZgM5nUEtyBGVQ/HuDKyiWjUQI3RNlBAyUn6TAU0OGG+RN3PtokcAPIO1lRtIO89h5kmJJQUj/IPSOaJHCXV563a0f0lBiQUNzI/uU338F4unkirA6KxH/N/wCTFeDHmzMoJgAAAABJRU5ErkJggg==\"}]}"]}}
{"modelVersion":2,"piskel":{"name":"worldedit_wand","description":"","fps":0,"height":16,"width":16,"layers":["{\"name\":\"Layer 1\",\"opacity\":1,\"frameCount\":5,\"chunks\":[{\"layout\":[[0],[1],[2],[3],[4]],\"base64PNG\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAAQCAYAAACBSfjBAAADRElEQVRYR+3YW0hTcRwH8O9Jp25uml1kupBIG+tqF60gVIoigi7kQwhBdK/Hoig1JMJuFtjlwUh6CYkuVHQhCSoqSypbdhlFZo7M1mYtnTu7uO3MX5zFxErr/18PDek87eF8f+e3z/9y/ptQI4A0BuChX4uKFpuACK6eW+kkmEUE3SJit4CrhnZjPKlGxWGo+h4crgKYy0SufLhdIiJruwtuj4SxY1K4aySfT6LAIwmeSg9XVqidJNCjJsKUxfkovFjHFZabp6saCnYFEONVhADhB2J3sCMuqmkhh+gKOXh8QTRumcbdwyebSElJSjidXnQ4vJhoSGWuYZ87lxwmE6aWeCEDfpxlhL+pC+knZjPVEIqz0ijbkIGX9x9DP2M0Vt98zxTsHflqDYU/RwrY/HU6AmIQMYrbWHktH2X13Vw9NJs7KVEVG9Hs+6zX02u7HQWHlDC3WqCJeYZuox0Z1+Yz9dB70/E8LVltNqjG56D4ipEpLMNJh9ELKM++/VcTuACmnk0lnxhA0E3w289hzZ2lXHl56b5q+oL4OAUsVjscjk6Y9rEPwoYrrWS0eNHgM6DODNQ38vX/A9TRojwyN97HuNxsbDr9gh2x4juijJeTFgej1c+FIGfLZyeEavDm79Y3ky5tBHz+AN61vA8BtlWxD4K8hbxta8eSY1VIzrzA/fxfkHbP05Kzyw5V1nSUn3nMjBhexjIEL0Lf9xZv/vL1BpLRVq1YIEQ6CJUZm+mp+w1Of70RqsHTf79A2wqzSTvECUGpxtYaU9Qj/nxw4EX4m/yAOCUL0yhJqUDPsEzsPHnnP+IAx7vfwuxdN4cUHWZIggKlF99FhKhNVsLW5eXeE8P7YrTn/4hStTaHPrW2QKGbgF2nHvzx/v6Wg4zQ/MWLg0/4jid9EaM1zwRSWpRL6bEutHc4UV5rYcr0hdyem0BjR0aOGM15Zow9y8aQSiHgg5SII5deMufCkNGMwPLrdaD+uSA2F04mXZwIl9SD3RdaubJyk4MRkRthxxItpQ5XwyKpUVnznDs/2BC5AeSZVLJuJvmsJuh1w7Gpuo27xmBC5P7y4f3iwHINpUgiNl5i/+elvxfL+trOiHoID8K/zn8DbQVu1uI+550AAAAASUVORK5CYII=\"}]}"]}}

View File

@ -7,5 +7,6 @@ local modpath = minetest.get_modpath("worldeditadditions_farwand")
dofile(modpath.."/lib/do_raycast.lua")
dofile(modpath.."/lib/farwand.lua")
dofile(modpath.."/lib/cloudwand.lua")
dofile(modpath.."/lib/multiwand.lua")
dofile(modpath.."/lib/chatcommand.lua")
dofile(modpath.."/lib/settings.lua")

View File

@ -0,0 +1,56 @@
local wea_c = worldeditadditions_core
local wea = worldeditadditions
local Vector3 = wea.Vector3
local function push_pos(player_name, pos)
if player_name == nil then return end
if pos == nil then
worldedit.player_notify(player_name, "[multi wand] Error: Too far away (try raising your maxdist with //farwand maxdist <number>)")
else
pos = Vector3.clone(pos)
wea_c.pos.push(player_name, pos)
worldedit.player_notify(player_name, "[multi wand] Added "..pos..". "..wea_c.pos.count(player_name).." points now registered.")
end
end
local function pop_pos(player_name)
if player_name == nil then return end
local count_before = wea_c.pos.count(player_name)
wea_c.pos.pop(player_name)
local count_after = wea_c.pos.count(player_name)
if count_before > 0 then
worldedit.player_notify(player_name, "[multi wand] "..count_before.." -> "..count_after.." points registered")
else
worldedit.player_notify(player_name, "[multi wand] No points registered")
end
end
minetest.register_tool(":worldeditadditions:multiwand", {
description = "WorldEditAdditions multi-point wand",
inventory_image = "worldeditadditions_multiwand.png",
on_place = function(itemstack, player, pointed_thing)
-- Right click when pointing at something
-- Pointed thing: https://rubenwardy.com/minetest_modding_book/lua_api.html#pointed_thing
-- print("[farwand] on_place", name)
local name = player:get_player_name()
pop_pos(name)
end,
on_use = function(itemstack, player, pointed_thing)
-- Left click when pointing at something or nothing
local name = player:get_player_name()
-- print("[farwand] on_use", name)
local looking_pos, node_id = wea.farwand.do_raycast(player)
push_pos(name, looking_pos)
end,
on_secondary_use = function(itemstack, player, pointed_thing)
-- Right click when pointing at nothing
-- print("[farwand] on_secondary_use", name)
local name = player:get_player_name()
-- local looking_pos, node_id = do_raycast(player)
pop_pos(name)
end
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B