first commit
This commit is contained in:
commit
817b7cf4bc
838 changed files with 730686 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
/target
|
||||
node_modules
|
||||
95
Cargo.lock
generated
Normal file
95
Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "frontend-compiler-example"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"minijinja",
|
||||
"minijinja-embed",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memo-map"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38d1115007560874e373613744c6fba374c17688327a71c1476d1a5954cc857b"
|
||||
|
||||
[[package]]
|
||||
name = "minijinja"
|
||||
version = "2.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98642a6dfca91122779a307b77cd07a4aa951fbe32232aaf5bad9febc66be754"
|
||||
dependencies = [
|
||||
"memo-map",
|
||||
"self_cell",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minijinja-embed"
|
||||
version = "2.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9afe707213910fda251ba541a34dd5592bec3432a5beb987a32e9ccb8eb6d6ae"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "self_cell"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f7d95a54511e0c7be3f51e8867aa8cf35148d7b9445d44de2f943e2b206e749"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.219"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.219"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||
10
Cargo.toml
Normal file
10
Cargo.toml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "frontend-compiler-example"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
minijinja = { version = "2.7.0", features = ["loader"] }
|
||||
minijinja-embed = "2.7.0"
|
||||
|
||||
[dev-dependencies]
|
||||
34
build.rs
Normal file
34
build.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
use core::panic;
|
||||
use std::io::Write;
|
||||
use std::process::Command;
|
||||
use std::{env, io};
|
||||
|
||||
fn cmd(cmd: &mut Command) {
|
||||
let output = cmd.output().unwrap();
|
||||
|
||||
let _ = io::stdout().write_all(&output.stdout);
|
||||
if !output.status.success() {
|
||||
let _ = io::stderr().write_all(&output.stderr);
|
||||
panic!("\nFailed to run command\n");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
|
||||
cmd(Command::new("bun").args(["install"]));
|
||||
cmd(Command::new("bun").args([
|
||||
"run",
|
||||
"scripts/build.ts",
|
||||
"--outdir",
|
||||
out_dir.as_str(),
|
||||
"--globs",
|
||||
"static/**/*.html",
|
||||
]));
|
||||
|
||||
println!("Build completed successfully!");
|
||||
|
||||
println!("cargo::rerun-if-changed=build.rs");
|
||||
println!("cargo::rerun-if-changed=package.json");
|
||||
println!("cargo::rerun-if-changed=static");
|
||||
}
|
||||
93
bun.lock
Normal file
93
bun.lock
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
{
|
||||
"lockfileVersion": 1,
|
||||
"workspaces": {
|
||||
"": {
|
||||
"name": "frontend-compiler-example",
|
||||
"devDependencies": {
|
||||
"@alecodes/bun-plugin-sass": "^0.1.3",
|
||||
"@alecodes/bun-static-builder": "^0.1.0",
|
||||
"@types/bun": "latest",
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5",
|
||||
},
|
||||
},
|
||||
},
|
||||
"packages": {
|
||||
"@alecodes/bun-plugin-sass": ["@alecodes/bun-plugin-sass@0.1.3", "https://git.alecodes.page/api/packages/alecodes/npm/%40alecodes%2Fbun-plugin-sass/-/0.1.3/bun-plugin-sass-0.1.3.tgz", { "dependencies": { "sass": "^1.85.0" }, "peerDependencies": { "typescript": "^5" } }, "sha512-CzI6BCcy6Io5aRFXY0DkyeXfwdM7twqmQwBrjSL81OQl2F6b7ZTN4yt5tjezlKohdF53lKrtJ78K16xE577zXA=="],
|
||||
|
||||
"@alecodes/bun-static-builder": ["@alecodes/bun-static-builder@0.1.0", "https://git.alecodes.page/api/packages/alecodes/npm/%40alecodes%2Fbun-static-builder/-/0.1.0/bun-static-builder-0.1.0.tgz", { "dependencies": { "sass": "^1.85.0", "slug": "^10.0.0" }, "peerDependencies": { "typescript": "^5.0.0" }, "bin": { "@alecodes/bun-static-builder": "src/cli.ts" } }, "sha512-1droOGfCr25rnVZCr7WhrECrk/03Y7gAGzhj0hr3h9ECMwIELT8B0nrL/K7j8IxmqfkOvA50l4uxRzgXHpOjGQ=="],
|
||||
|
||||
"@parcel/watcher": ["@parcel/watcher@2.5.1", "", { "dependencies": { "detect-libc": "^1.0.3", "is-glob": "^4.0.3", "micromatch": "^4.0.5", "node-addon-api": "^7.0.0" }, "optionalDependencies": { "@parcel/watcher-android-arm64": "2.5.1", "@parcel/watcher-darwin-arm64": "2.5.1", "@parcel/watcher-darwin-x64": "2.5.1", "@parcel/watcher-freebsd-x64": "2.5.1", "@parcel/watcher-linux-arm-glibc": "2.5.1", "@parcel/watcher-linux-arm-musl": "2.5.1", "@parcel/watcher-linux-arm64-glibc": "2.5.1", "@parcel/watcher-linux-arm64-musl": "2.5.1", "@parcel/watcher-linux-x64-glibc": "2.5.1", "@parcel/watcher-linux-x64-musl": "2.5.1", "@parcel/watcher-win32-arm64": "2.5.1", "@parcel/watcher-win32-ia32": "2.5.1", "@parcel/watcher-win32-x64": "2.5.1" } }, "sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg=="],
|
||||
|
||||
"@parcel/watcher-android-arm64": ["@parcel/watcher-android-arm64@2.5.1", "", { "os": "android", "cpu": "arm64" }, "sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA=="],
|
||||
|
||||
"@parcel/watcher-darwin-arm64": ["@parcel/watcher-darwin-arm64@2.5.1", "", { "os": "darwin", "cpu": "arm64" }, "sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw=="],
|
||||
|
||||
"@parcel/watcher-darwin-x64": ["@parcel/watcher-darwin-x64@2.5.1", "", { "os": "darwin", "cpu": "x64" }, "sha512-1ZXDthrnNmwv10A0/3AJNZ9JGlzrF82i3gNQcWOzd7nJ8aj+ILyW1MTxVk35Db0u91oD5Nlk9MBiujMlwmeXZg=="],
|
||||
|
||||
"@parcel/watcher-freebsd-x64": ["@parcel/watcher-freebsd-x64@2.5.1", "", { "os": "freebsd", "cpu": "x64" }, "sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ=="],
|
||||
|
||||
"@parcel/watcher-linux-arm-glibc": ["@parcel/watcher-linux-arm-glibc@2.5.1", "", { "os": "linux", "cpu": "arm" }, "sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA=="],
|
||||
|
||||
"@parcel/watcher-linux-arm-musl": ["@parcel/watcher-linux-arm-musl@2.5.1", "", { "os": "linux", "cpu": "arm" }, "sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q=="],
|
||||
|
||||
"@parcel/watcher-linux-arm64-glibc": ["@parcel/watcher-linux-arm64-glibc@2.5.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w=="],
|
||||
|
||||
"@parcel/watcher-linux-arm64-musl": ["@parcel/watcher-linux-arm64-musl@2.5.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg=="],
|
||||
|
||||
"@parcel/watcher-linux-x64-glibc": ["@parcel/watcher-linux-x64-glibc@2.5.1", "", { "os": "linux", "cpu": "x64" }, "sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A=="],
|
||||
|
||||
"@parcel/watcher-linux-x64-musl": ["@parcel/watcher-linux-x64-musl@2.5.1", "", { "os": "linux", "cpu": "x64" }, "sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg=="],
|
||||
|
||||
"@parcel/watcher-win32-arm64": ["@parcel/watcher-win32-arm64@2.5.1", "", { "os": "win32", "cpu": "arm64" }, "sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw=="],
|
||||
|
||||
"@parcel/watcher-win32-ia32": ["@parcel/watcher-win32-ia32@2.5.1", "", { "os": "win32", "cpu": "ia32" }, "sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ=="],
|
||||
|
||||
"@parcel/watcher-win32-x64": ["@parcel/watcher-win32-x64@2.5.1", "", { "os": "win32", "cpu": "x64" }, "sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA=="],
|
||||
|
||||
"@types/bun": ["@types/bun@1.2.9", "", { "dependencies": { "bun-types": "1.2.9" } }, "sha512-epShhLGQYc4Bv/aceHbmBhOz1XgUnuTZgcxjxk+WXwNyDXavv5QHD1QEFV0FwbTSQtNq6g4ZcV6y0vZakTjswg=="],
|
||||
|
||||
"@types/node": ["@types/node@22.14.0", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-Kmpl+z84ILoG+3T/zQFyAJsU6EPTmOCj8/2+83fSN6djd6I4o7uOuGIH6vq3PrjY5BGitSbFuMN18j3iknubbA=="],
|
||||
|
||||
"@types/ws": ["@types/ws@8.18.1", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="],
|
||||
|
||||
"braces": ["braces@3.0.3", "", { "dependencies": { "fill-range": "^7.1.1" } }, "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA=="],
|
||||
|
||||
"bun-types": ["bun-types@1.2.9", "", { "dependencies": { "@types/node": "*", "@types/ws": "*" } }, "sha512-dk/kOEfQbajENN/D6FyiSgOKEuUi9PWfqKQJEgwKrCMWbjS/S6tEXp178mWvWAcUSYm9ArDlWHZKO3T/4cLXiw=="],
|
||||
|
||||
"chokidar": ["chokidar@4.0.3", "", { "dependencies": { "readdirp": "^4.0.1" } }, "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA=="],
|
||||
|
||||
"detect-libc": ["detect-libc@1.0.3", "", { "bin": { "detect-libc": "./bin/detect-libc.js" } }, "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg=="],
|
||||
|
||||
"fill-range": ["fill-range@7.1.1", "", { "dependencies": { "to-regex-range": "^5.0.1" } }, "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg=="],
|
||||
|
||||
"immutable": ["immutable@5.1.1", "", {}, "sha512-3jatXi9ObIsPGr3N5hGw/vWWcTkq6hUYhpQz4k0wLC+owqWi/LiugIw9x0EdNZ2yGedKN/HzePiBvaJRXa0Ujg=="],
|
||||
|
||||
"is-extglob": ["is-extglob@2.1.1", "", {}, "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ=="],
|
||||
|
||||
"is-glob": ["is-glob@4.0.3", "", { "dependencies": { "is-extglob": "^2.1.1" } }, "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg=="],
|
||||
|
||||
"is-number": ["is-number@7.0.0", "", {}, "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="],
|
||||
|
||||
"micromatch": ["micromatch@4.0.8", "", { "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" } }, "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA=="],
|
||||
|
||||
"node-addon-api": ["node-addon-api@7.1.1", "", {}, "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ=="],
|
||||
|
||||
"picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
|
||||
|
||||
"readdirp": ["readdirp@4.1.2", "", {}, "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg=="],
|
||||
|
||||
"sass": ["sass@1.86.3", "", { "dependencies": { "chokidar": "^4.0.0", "immutable": "^5.0.2", "source-map-js": ">=0.6.2 <2.0.0" }, "optionalDependencies": { "@parcel/watcher": "^2.4.1" }, "bin": { "sass": "sass.js" } }, "sha512-iGtg8kus4GrsGLRDLRBRHY9dNVA78ZaS7xr01cWnS7PEMQyFtTqBiyCrfpTYTZXRWM94akzckYjh8oADfFNTzw=="],
|
||||
|
||||
"slug": ["slug@10.0.0", "", { "bin": { "slug": "cli.js" } }, "sha512-M8s2PWOUeSCdD4S1NH5lCzXg2zFV1fozrtfr0FSKl65x+EF1rUowj+/vyFlnHgxPxWzT+DL0VXKfYc1DHJoymg=="],
|
||||
|
||||
"source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="],
|
||||
|
||||
"to-regex-range": ["to-regex-range@5.0.1", "", { "dependencies": { "is-number": "^7.0.0" } }, "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="],
|
||||
|
||||
"typescript": ["typescript@5.8.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ=="],
|
||||
|
||||
"undici-types": ["undici-types@6.21.0", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
|
||||
}
|
||||
}
|
||||
7
bunfig.toml
Normal file
7
bunfig.toml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[serve.static]
|
||||
plugins = ["bun-plugin-sass"]
|
||||
|
||||
[install.scopes]
|
||||
|
||||
"@alecodes" = { url = "https://git.alecodes.page/api/packages/alecodes/npm/" }
|
||||
"@mini-strap" = { url = "https://git.alecodes.page/api/packages/alecodes/npm/" }
|
||||
0
dist/main-c13rsdee.js
vendored
Normal file
0
dist/main-c13rsdee.js
vendored
Normal file
15
dist/main.html
vendored
Normal file
15
dist/main.html
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="color-scheme" content="light dark">
|
||||
<link rel="stylesheet" href="./style-y1kzbynz.scss">
|
||||
<title>Hello world!</title>
|
||||
<script type="module" crossorigin src="./main-c13rsdee.js"></script></head>
|
||||
<body>
|
||||
<main class="container">
|
||||
<h1>Hello world!</h1>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
5
dist/minijinja_templates_main.rs
vendored
Normal file
5
dist/minijinja_templates_main.rs
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
|env: &mut minijinja::Environment| {
|
||||
env.add_template("assets/main-5d5yeb75.js", "").expect("Embedded an invalid template");
|
||||
env.add_template("main.html", "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <meta name=\"color-scheme\" content=\"light dark\">\n \n <title>Hello world!</title>\n <link rel=\"stylesheet\" crossorigin href=\"/assets/main-an4p6yc8.css\"><script type=\"module\" crossorigin src=\"/assets/main-5d5yeb75.js\"></script></head>\n <body>\n <main class=\"container\">\n <h1>Hello world!</h1>\n </main>\n </body>\n</html>\n").expect("Embedded an invalid template");
|
||||
env.add_template("assets/main-an4p6yc8.css", "main{background-color:red}\n").expect("Embedded an invalid template");
|
||||
}
|
||||
3
dist/style-y1kzbynz.scss
vendored
Normal file
3
dist/style-y1kzbynz.scss
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
main {
|
||||
background-color: red;
|
||||
}
|
||||
1
node_modules/.bin/bun-static-builder
generated
vendored
Symbolic link
1
node_modules/.bin/bun-static-builder
generated
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../@alecodes/bun-static-builder/src/cli.ts
|
||||
1
node_modules/.bin/detect-libc
generated
vendored
Symbolic link
1
node_modules/.bin/detect-libc
generated
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../detect-libc/bin/detect-libc.js
|
||||
1
node_modules/.bin/sass
generated
vendored
Symbolic link
1
node_modules/.bin/sass
generated
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../sass/sass.js
|
||||
1
node_modules/.bin/slug
generated
vendored
Symbolic link
1
node_modules/.bin/slug
generated
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../slug/cli.js
|
||||
1
node_modules/.bin/tsc
generated
vendored
Symbolic link
1
node_modules/.bin/tsc
generated
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../typescript/bin/tsc
|
||||
1
node_modules/.bin/tsserver
generated
vendored
Symbolic link
1
node_modules/.bin/tsserver
generated
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../typescript/bin/tsserver
|
||||
0
node_modules/@alecodes/bun-plugin-sass/.devfiles/bin/.gitkeep
generated
vendored
Normal file
0
node_modules/@alecodes/bun-plugin-sass/.devfiles/bin/.gitkeep
generated
vendored
Normal file
0
node_modules/@alecodes/bun-plugin-sass/.devfiles/hooks/.gitkeep
generated
vendored
Normal file
0
node_modules/@alecodes/bun-plugin-sass/.devfiles/hooks/.gitkeep
generated
vendored
Normal file
5
node_modules/@alecodes/bun-plugin-sass/.devfiles/hooks/commit-msg.sh
generated
vendored
Normal file
5
node_modules/@alecodes/bun-plugin-sass/.devfiles/hooks/commit-msg.sh
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
cog verify --file "$1"
|
||||
14
node_modules/@alecodes/bun-plugin-sass/.devfiles/hooks/pre-commit.sh
generated
vendored
Normal file
14
node_modules/@alecodes/bun-plugin-sass/.devfiles/hooks/pre-commit.sh
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
root="$(git rev-parse --show-toplevel)"
|
||||
|
||||
cd "$root"
|
||||
|
||||
gitleaks git
|
||||
|
||||
# Only validate encrypted files if we are tracking any
|
||||
if [[ -e .ageboxreg.yml ]]; then
|
||||
agebox validate --no-decrypt
|
||||
fi
|
||||
43
node_modules/@alecodes/bun-plugin-sass/.devfiles/justfile
generated
vendored
Normal file
43
node_modules/@alecodes/bun-plugin-sass/.devfiles/justfile
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
set dotenv-load := true
|
||||
|
||||
export PATH := source_dir() + "/bin:" + source_dir() + "/scripts:" + env("PATH")
|
||||
export AGEBOX_DEBUG := "0"
|
||||
export AGEBOX_PUBLIC_KEYS := source_dir() + "/public_keys.txt"
|
||||
|
||||
# Install agebox from the latest github realse
|
||||
install-agebox:
|
||||
curl -sSL "https://github.com/slok/agebox/releases/latest/download/agebox-linux-amd64" -o .devfiles/bin/agebox
|
||||
chmod + x .devfiles/bin/agebox
|
||||
|
||||
[no-cd]
|
||||
install-hooks:
|
||||
cog install-hook --all
|
||||
|
||||
# Easy and simple file repository encryption tool based on Age.
|
||||
agebox +ARGS="--help":
|
||||
@.devfiles/bin/agebox {{ ARGS }}
|
||||
|
||||
# Encrypt the provided files, relative to project root.
|
||||
encrypt +FILES: (agebox "encrypt " + FILES)
|
||||
|
||||
# Encrypt all the tracked files.
|
||||
encrypt-all: (agebox "encrypt --all")
|
||||
|
||||
# Decrypt the provided files, relative to project root.
|
||||
decrypt +FILES: (agebox "decrypt " + FILES)
|
||||
|
||||
# Decrypt all the tracked files.
|
||||
decrypt-all: (agebox "decrypt --all --force")
|
||||
|
||||
# Reencrypt all the tracked files with the new public keys.
|
||||
reencrypt: (agebox "reencrypt")
|
||||
|
||||
# Show the content of an encrypted file to stdout.
|
||||
crypt-peek +FILES: (agebox "cat " + FILES)
|
||||
|
||||
# Validate that all tracked files are encrypted.
|
||||
crypt-check:(agebox "validate --no-decrypt ")
|
||||
|
||||
# Validate no credentials are pushed to git
|
||||
leaks:
|
||||
@gitleaks git --verbose --redact
|
||||
2
node_modules/@alecodes/bun-plugin-sass/.devfiles/public_keys.txt
generated
vendored
Normal file
2
node_modules/@alecodes/bun-plugin-sass/.devfiles/public_keys.txt
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# anavarro
|
||||
age1gj7hj894l0a0lvu3fsndlkdkyc0da7963kcqhpfe43reflx3gafqnm058u
|
||||
0
node_modules/@alecodes/bun-plugin-sass/.devfiles/scripts/.gitkeep
generated
vendored
Normal file
0
node_modules/@alecodes/bun-plugin-sass/.devfiles/scripts/.gitkeep
generated
vendored
Normal file
30
node_modules/@alecodes/bun-plugin-sass/.devfiles/scripts/dependecy-check.sh
generated
vendored
Executable file
30
node_modules/@alecodes/bun-plugin-sass/.devfiles/scripts/dependecy-check.sh
generated
vendored
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
root="$(git rev-parse --show-toplevel)"
|
||||
|
||||
export PATH=$root/.devfiles/bin:$root/.devfiles/scripts:$PATH
|
||||
|
||||
devtools=(
|
||||
age
|
||||
agebox
|
||||
cog
|
||||
gitleaks
|
||||
)
|
||||
|
||||
missing_tools=()
|
||||
|
||||
for cmd in "${devtools[@]}"; do
|
||||
if ! command -v "$cmd" &>/dev/null; then
|
||||
missing_tools+=("$cmd")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${#missing_tools[@]} != 0 ]]; then
|
||||
echo "The following tools where not found:"
|
||||
printf "%s\n" "${missing_tools[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "All tools are installed!"
|
||||
fi
|
||||
42
node_modules/@alecodes/bun-plugin-sass/.devfiles/scripts/gitignore.sh
generated
vendored
Executable file
42
node_modules/@alecodes/bun-plugin-sass/.devfiles/scripts/gitignore.sh
generated
vendored
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
root="$(git rev-parse --show-toplevel)"
|
||||
|
||||
base_url="https://git.alecodes.page/api/v1/gitignore/templates"
|
||||
|
||||
query="$*"
|
||||
|
||||
list_available() {
|
||||
curl -Ssl $base_url | jq -r '.[]'
|
||||
}
|
||||
|
||||
if [[ -z $query ]]; then
|
||||
list_available
|
||||
exit 0
|
||||
fi
|
||||
|
||||
tmp_file="$(mktemp)"
|
||||
|
||||
for template in $query; do
|
||||
# Capitalize the string
|
||||
template=${template,,}
|
||||
template=${template^}
|
||||
|
||||
response="$(curl -Ssl "$base_url/$template")"
|
||||
name="$(echo "$response" | jq -r '.name')"
|
||||
content="$(echo "$response" | jq -r '.source')"
|
||||
|
||||
if [[ "$content" == "null" ]]; then
|
||||
echo "Template not found, available options:"
|
||||
list_available
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "\n### %s\n\n%s\n\n" "$name" "$content" >>"$tmp_file"
|
||||
done
|
||||
|
||||
sed -i -ne "/#### -- TEMPLATES BEGIN -- ####/ {p; r $tmp_file" -e ':a; n; /#### -- TEMPLATES END -- ####/ {p; b}; ba}; p' "$root/.gitignore"
|
||||
|
||||
rm "$tmp_file"
|
||||
60
node_modules/@alecodes/bun-plugin-sass/.forgejo/issue_template/01-feature.yml
generated
vendored
Normal file
60
node_modules/@alecodes/bun-plugin-sass/.forgejo/issue_template/01-feature.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
name: Feature request
|
||||
about: Request a new feature to be added
|
||||
title: '[Feature]: '
|
||||
ref: 'development'
|
||||
assignees:
|
||||
- aleidk
|
||||
labels:
|
||||
- Priority/Low
|
||||
- Severity/Low
|
||||
- Status/Pending
|
||||
- Type/Feature
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
We appreciate your feedback on how to improve this project. Please be sure to include as much details and any resources if possible!
|
||||
|
||||
- type: dropdown
|
||||
attributes:
|
||||
multiple: false
|
||||
label: Type of Feature
|
||||
default: 0
|
||||
options:
|
||||
- "✨ New Feature"
|
||||
- "📝 Documentation"
|
||||
- "🎨 Style and UI"
|
||||
- "🔨 Code Refactor"
|
||||
- "⚡ Performance Improvements"
|
||||
- "✅ New Test"
|
||||
- "🪢 Architecture"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: Give us a brief description of the feature or enhancement you would like.
|
||||
placeholder: As <who> <when> <where>, I want <what> because <why>
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: completion-criteria
|
||||
attributes:
|
||||
label: Completion criteria
|
||||
description: Tell us what this feature needs to do to be considered completed using verificable items.
|
||||
placeholder: |
|
||||
- [ ] Read the configuration file using the yaml format
|
||||
- [ ] Fetch data from an the json-placehoder API
|
||||
- [ ] Save the data in the database
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: additional-information
|
||||
attributes:
|
||||
label: Additional Information
|
||||
description: |
|
||||
Please leave any additional information on the feature request that could be helpful! like proposed solutions, examples, links, screenshots, etc.
|
||||
93
node_modules/@alecodes/bun-plugin-sass/.forgejo/issue_template/02-bug-report.yml
generated
vendored
Normal file
93
node_modules/@alecodes/bun-plugin-sass/.forgejo/issue_template/02-bug-report.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
name: Bug report
|
||||
about: Something isn't working as expected
|
||||
title: '[Bug]: '
|
||||
ref: 'development'
|
||||
assignees:
|
||||
- aleidk
|
||||
labels:
|
||||
- Priority/Low
|
||||
- Severity/Low
|
||||
- Status/Pending
|
||||
- Type/Bug
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
We appreciate your feedback on how to improve this project. Please be sure to include as much details and any resources if possible!
|
||||
|
||||
- type: checkboxes
|
||||
id: terms
|
||||
attributes:
|
||||
label: Before submitting, I checked...
|
||||
options:
|
||||
- label: The [issue tracker](../) in case this has been reported before
|
||||
required: true
|
||||
- label: The severity of the bug
|
||||
required: true
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: "Expected behavior:"
|
||||
description: A clear and concise description of what you expected to happen. Include screenshots and/or logs if relevant.
|
||||
placeholder: As <who> <when> <where>, I want <what> because <why>
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: current
|
||||
attributes:
|
||||
label: "Current behavior:"
|
||||
description: A clear and concise description of what actually happened. Include screenshots and/or logs if relevant.
|
||||
placeholder: As <who> <when> <where>, I want <what> because <why>
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: reproduce
|
||||
attributes:
|
||||
label: "Steps to reproduce:"
|
||||
description: Anambiguous set of steps to reproduce this bug. Include code snippets if relevant.
|
||||
placeholder: |
|
||||
1. Use x argument / navigate to
|
||||
2. Fill this information
|
||||
3. Go to...
|
||||
4. See error
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
attributes:
|
||||
multiple: false
|
||||
label: Is this a regresion?
|
||||
description: Did this behaviour used to work in the previous version?
|
||||
default: 0
|
||||
options:
|
||||
- "I don't know"
|
||||
- "This is a new feature"
|
||||
- "Yes"
|
||||
- "No"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: environment
|
||||
attributes:
|
||||
label: "Your environment:"
|
||||
description: Tell us details about the environment you experienced the bug in. A minimal/isolated enviroment to reproduce would be apreciated.
|
||||
placeholder: |
|
||||
- Version used:
|
||||
- Browser Name and version:
|
||||
- Operating System and version (desktop or mobile):
|
||||
- Link to your project:
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: additional-information
|
||||
attributes:
|
||||
label: "Additional Information:"
|
||||
description: |
|
||||
Please leave any additional information on the bug that could be helpful! like proposed solutions, examples, links, screenshots, etc.
|
||||
20
node_modules/@alecodes/bun-plugin-sass/.forgejo/workflows/create.yml
generated
vendored
Normal file
20
node_modules/@alecodes/bun-plugin-sass/.forgejo/workflows/create.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
name: Template migration
|
||||
|
||||
# The workflow will run only when `use this template` is used
|
||||
on: create
|
||||
|
||||
jobs:
|
||||
create:
|
||||
runs-on: docker
|
||||
|
||||
steps:
|
||||
- name: "Check out the repo"
|
||||
uses: "actions/checkout@v4"
|
||||
|
||||
- name: "Update commit"
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: "chore: initial commit"
|
||||
commit_options: "--amend"
|
||||
push_options: "--force"
|
||||
skip_fetch: true
|
||||
5
node_modules/@alecodes/bun-plugin-sass/.justfile
generated
vendored
Normal file
5
node_modules/@alecodes/bun-plugin-sass/.justfile
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Repo management tasks
|
||||
mod repo ".devfiles/justfile"
|
||||
|
||||
dev:
|
||||
@echo "Edit the .justfile to setup the dev task!"
|
||||
33
node_modules/@alecodes/bun-plugin-sass/CHANGELOG.md
generated
vendored
Normal file
33
node_modules/@alecodes/bun-plugin-sass/CHANGELOG.md
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Changelog
|
||||
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.
|
||||
|
||||
- - -
|
||||
## v0.1.3 - 2025-04-11
|
||||
#### Bug Fixes
|
||||
- add support for sass extension - (b032ab7) - aleidk
|
||||
|
||||
- - -
|
||||
|
||||
## v0.1.2 - 2025-02-19
|
||||
#### Bug Fixes
|
||||
- change package to scope to prevent resolution issues between registries - (2ca1ee5) - aleidk
|
||||
|
||||
- - -
|
||||
|
||||
## v0.1.1 - 2025-02-19
|
||||
#### Bug Fixes
|
||||
- add sass as a dependency - (a90901c) - aleidk
|
||||
|
||||
- - -
|
||||
|
||||
## v0.1.0 - 2025-02-19
|
||||
#### Features
|
||||
- add plugin - (fa09b9e) - aleidk
|
||||
#### Miscellaneous Chores
|
||||
- add npm registry - (e933fd5) - aleidk
|
||||
- update cocogitto config - (9949e70) - aleidk
|
||||
- initial commit - (b7452c7) - alecodes
|
||||
|
||||
- - -
|
||||
|
||||
Changelog generated by [cocogitto](https://github.com/cocogitto/cocogitto).
|
||||
235
node_modules/@alecodes/bun-plugin-sass/LICENSE
generated
vendored
Normal file
235
node_modules/@alecodes/bun-plugin-sass/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
base-template
|
||||
Copyright (C) 2024 alecodes
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>.
|
||||
3
node_modules/@alecodes/bun-plugin-sass/README.md
generated
vendored
Normal file
3
node_modules/@alecodes/bun-plugin-sass/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# base-template
|
||||
|
||||
Base template to create new repositories
|
||||
36
node_modules/@alecodes/bun-plugin-sass/cog.toml
generated
vendored
Normal file
36
node_modules/@alecodes/bun-plugin-sass/cog.toml
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
from_latest_tag = false
|
||||
ignore_merge_commits = true
|
||||
tag_prefix = "v"
|
||||
disable_changelog = false
|
||||
disable_bump_commit = false
|
||||
generate_mono_repository_global_tag = true
|
||||
generate_mono_repository_package_tags = true
|
||||
branch_whitelist = []
|
||||
skip_ci = "[skip ci]"
|
||||
skip_untracked = false
|
||||
pre_bump_hooks = [
|
||||
"echo 'bump package to {{version}}'",
|
||||
"sed -E -i 's/(\"version\":) \"[0-9.]{5}\"/\\1 \"{{version}}\"/gi' package.json",
|
||||
"bun run ci:publish",
|
||||
]
|
||||
post_bump_hooks = ["git push", "git push origin {{version_tag}}"]
|
||||
pre_package_bump_hooks = []
|
||||
post_package_bump_hooks = []
|
||||
|
||||
[git_hooks]
|
||||
|
||||
[git_hooks.pre-commit]
|
||||
path = ".devfiles/hooks/pre-commit.sh"
|
||||
|
||||
[git_hooks.commit-msg]
|
||||
path = ".devfiles/hooks/commit-msg.sh"
|
||||
|
||||
[commit_types]
|
||||
|
||||
[changelog]
|
||||
path = "CHANGELOG.md"
|
||||
authors = []
|
||||
|
||||
[bump_profiles]
|
||||
|
||||
[packages]
|
||||
32
node_modules/@alecodes/bun-plugin-sass/index.ts
generated
vendored
Normal file
32
node_modules/@alecodes/bun-plugin-sass/index.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import type { BunPlugin, PluginBuilder } from "bun";
|
||||
import type { FileImporter } from "sass";
|
||||
|
||||
const nodeModuleImporter: FileImporter<"async"> = {
|
||||
findFileUrl(url: string) {
|
||||
if (url.startsWith("@")) {
|
||||
return new URL(import.meta.resolve(url));
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
};
|
||||
|
||||
const sassPlugin: BunPlugin = {
|
||||
name: "Sass Loader",
|
||||
async setup(build: PluginBuilder) {
|
||||
const sass = await import("sass");
|
||||
|
||||
build.onLoad({ filter: /\.scss|sass$/ }, async ({ path }) => {
|
||||
const result = await sass.compileAsync(path, {
|
||||
importers: [nodeModuleImporter],
|
||||
});
|
||||
|
||||
return {
|
||||
loader: "css",
|
||||
contents: result.css,
|
||||
};
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default sassPlugin;
|
||||
18
node_modules/@alecodes/bun-plugin-sass/package.json
generated
vendored
Normal file
18
node_modules/@alecodes/bun-plugin-sass/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "@alecodes/bun-plugin-sass",
|
||||
"version": "0.1.3",
|
||||
"module": "index.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"ci:publish": "bun publish --production --frozen-lockfile --silent"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5"
|
||||
},
|
||||
"dependencies": {
|
||||
"sass": "^1.85.0"
|
||||
}
|
||||
}
|
||||
27
node_modules/@alecodes/bun-plugin-sass/tsconfig.json
generated
vendored
Normal file
27
node_modules/@alecodes/bun-plugin-sass/tsconfig.json
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable latest features
|
||||
"lib": ["ESNext", "DOM"],
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"allowJs": true,
|
||||
|
||||
// Bundler mode
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true,
|
||||
|
||||
// Best practices
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
|
||||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noPropertyAccessFromIndexSignature": false
|
||||
}
|
||||
}
|
||||
0
node_modules/@alecodes/bun-static-builder/.devfiles/bin/.gitkeep
generated
vendored
Normal file
0
node_modules/@alecodes/bun-static-builder/.devfiles/bin/.gitkeep
generated
vendored
Normal file
0
node_modules/@alecodes/bun-static-builder/.devfiles/hooks/.gitkeep
generated
vendored
Normal file
0
node_modules/@alecodes/bun-static-builder/.devfiles/hooks/.gitkeep
generated
vendored
Normal file
5
node_modules/@alecodes/bun-static-builder/.devfiles/hooks/commit-msg.sh
generated
vendored
Normal file
5
node_modules/@alecodes/bun-static-builder/.devfiles/hooks/commit-msg.sh
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
cog verify --file "$1"
|
||||
14
node_modules/@alecodes/bun-static-builder/.devfiles/hooks/pre-commit.sh
generated
vendored
Normal file
14
node_modules/@alecodes/bun-static-builder/.devfiles/hooks/pre-commit.sh
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
root="$(git rev-parse --show-toplevel)"
|
||||
|
||||
cd "$root"
|
||||
|
||||
gitleaks git
|
||||
|
||||
# Only validate encrypted files if we are tracking any
|
||||
if [[ -e .ageboxreg.yml ]]; then
|
||||
agebox validate --no-decrypt
|
||||
fi
|
||||
43
node_modules/@alecodes/bun-static-builder/.devfiles/justfile
generated
vendored
Normal file
43
node_modules/@alecodes/bun-static-builder/.devfiles/justfile
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
set dotenv-load := true
|
||||
|
||||
export PATH := source_dir() + "/bin:" + source_dir() + "/scripts:" + env("PATH")
|
||||
export AGEBOX_DEBUG := "0"
|
||||
export AGEBOX_PUBLIC_KEYS := source_dir() + "/public_keys.txt"
|
||||
|
||||
# Install agebox from the latest github realse
|
||||
install-agebox:
|
||||
curl -sSL "https://github.com/slok/agebox/releases/latest/download/agebox-linux-amd64" -o .devfiles/bin/agebox
|
||||
chmod + x .devfiles/bin/agebox
|
||||
|
||||
[no-cd]
|
||||
install-hooks:
|
||||
cog install-hook --all
|
||||
|
||||
# Easy and simple file repository encryption tool based on Age.
|
||||
agebox +ARGS="--help":
|
||||
@.devfiles/bin/agebox {{ ARGS }}
|
||||
|
||||
# Encrypt the provided files, relative to project root.
|
||||
encrypt +FILES: (agebox "encrypt " + FILES)
|
||||
|
||||
# Encrypt all the tracked files.
|
||||
encrypt-all: (agebox "encrypt --all")
|
||||
|
||||
# Decrypt the provided files, relative to project root.
|
||||
decrypt +FILES: (agebox "decrypt " + FILES)
|
||||
|
||||
# Decrypt all the tracked files.
|
||||
decrypt-all: (agebox "decrypt --all --force")
|
||||
|
||||
# Reencrypt all the tracked files with the new public keys.
|
||||
reencrypt: (agebox "reencrypt")
|
||||
|
||||
# Show the content of an encrypted file to stdout.
|
||||
crypt-peek +FILES: (agebox "cat " + FILES)
|
||||
|
||||
# Validate that all tracked files are encrypted.
|
||||
crypt-check:(agebox "validate --no-decrypt ")
|
||||
|
||||
# Validate no credentials are pushed to git
|
||||
leaks:
|
||||
@gitleaks git --verbose --redact
|
||||
2
node_modules/@alecodes/bun-static-builder/.devfiles/public_keys.txt
generated
vendored
Normal file
2
node_modules/@alecodes/bun-static-builder/.devfiles/public_keys.txt
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# anavarro
|
||||
age1gj7hj894l0a0lvu3fsndlkdkyc0da7963kcqhpfe43reflx3gafqnm058u
|
||||
0
node_modules/@alecodes/bun-static-builder/.devfiles/scripts/.gitkeep
generated
vendored
Normal file
0
node_modules/@alecodes/bun-static-builder/.devfiles/scripts/.gitkeep
generated
vendored
Normal file
30
node_modules/@alecodes/bun-static-builder/.devfiles/scripts/dependecy-check.sh
generated
vendored
Executable file
30
node_modules/@alecodes/bun-static-builder/.devfiles/scripts/dependecy-check.sh
generated
vendored
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
root="$(git rev-parse --show-toplevel)"
|
||||
|
||||
export PATH=$root/.devfiles/bin:$root/.devfiles/scripts:$PATH
|
||||
|
||||
devtools=(
|
||||
age
|
||||
agebox
|
||||
cog
|
||||
gitleaks
|
||||
)
|
||||
|
||||
missing_tools=()
|
||||
|
||||
for cmd in "${devtools[@]}"; do
|
||||
if ! command -v "$cmd" &>/dev/null; then
|
||||
missing_tools+=("$cmd")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${#missing_tools[@]} != 0 ]]; then
|
||||
echo "The following tools where not found:"
|
||||
printf "%s\n" "${missing_tools[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "All tools are installed!"
|
||||
fi
|
||||
42
node_modules/@alecodes/bun-static-builder/.devfiles/scripts/gitignore.sh
generated
vendored
Executable file
42
node_modules/@alecodes/bun-static-builder/.devfiles/scripts/gitignore.sh
generated
vendored
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
root="$(git rev-parse --show-toplevel)"
|
||||
|
||||
base_url="https://git.alecodes.page/api/v1/gitignore/templates"
|
||||
|
||||
query="$*"
|
||||
|
||||
list_available() {
|
||||
curl -Ssl $base_url | jq -r '.[]'
|
||||
}
|
||||
|
||||
if [[ -z $query ]]; then
|
||||
list_available
|
||||
exit 0
|
||||
fi
|
||||
|
||||
tmp_file="$(mktemp)"
|
||||
|
||||
for template in $query; do
|
||||
# Capitalize the string
|
||||
template=${template,,}
|
||||
template=${template^}
|
||||
|
||||
response="$(curl -Ssl "$base_url/$template")"
|
||||
name="$(echo "$response" | jq -r '.name')"
|
||||
content="$(echo "$response" | jq -r '.source')"
|
||||
|
||||
if [[ "$content" == "null" ]]; then
|
||||
echo "Template not found, available options:"
|
||||
list_available
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "\n### %s\n\n%s\n\n" "$name" "$content" >>"$tmp_file"
|
||||
done
|
||||
|
||||
sed -i -ne "/#### -- TEMPLATES BEGIN -- ####/ {p; r $tmp_file" -e ':a; n; /#### -- TEMPLATES END -- ####/ {p; b}; ba}; p' "$root/.gitignore"
|
||||
|
||||
rm "$tmp_file"
|
||||
60
node_modules/@alecodes/bun-static-builder/.forgejo/issue_template/01-feature.yml
generated
vendored
Normal file
60
node_modules/@alecodes/bun-static-builder/.forgejo/issue_template/01-feature.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
name: Feature request
|
||||
about: Request a new feature to be added
|
||||
title: '[Feature]: '
|
||||
ref: 'development'
|
||||
assignees:
|
||||
- aleidk
|
||||
labels:
|
||||
- Priority/Low
|
||||
- Severity/Low
|
||||
- Status/Pending
|
||||
- Type/Feature
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
We appreciate your feedback on how to improve this project. Please be sure to include as much details and any resources if possible!
|
||||
|
||||
- type: dropdown
|
||||
attributes:
|
||||
multiple: false
|
||||
label: Type of Feature
|
||||
default: 0
|
||||
options:
|
||||
- "✨ New Feature"
|
||||
- "📝 Documentation"
|
||||
- "🎨 Style and UI"
|
||||
- "🔨 Code Refactor"
|
||||
- "⚡ Performance Improvements"
|
||||
- "✅ New Test"
|
||||
- "🪢 Architecture"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: Give us a brief description of the feature or enhancement you would like.
|
||||
placeholder: As <who> <when> <where>, I want <what> because <why>
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: completion-criteria
|
||||
attributes:
|
||||
label: Completion criteria
|
||||
description: Tell us what this feature needs to do to be considered completed using verificable items.
|
||||
placeholder: |
|
||||
- [ ] Read the configuration file using the yaml format
|
||||
- [ ] Fetch data from an the json-placehoder API
|
||||
- [ ] Save the data in the database
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: additional-information
|
||||
attributes:
|
||||
label: Additional Information
|
||||
description: |
|
||||
Please leave any additional information on the feature request that could be helpful! like proposed solutions, examples, links, screenshots, etc.
|
||||
93
node_modules/@alecodes/bun-static-builder/.forgejo/issue_template/02-bug-report.yml
generated
vendored
Normal file
93
node_modules/@alecodes/bun-static-builder/.forgejo/issue_template/02-bug-report.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
name: Bug report
|
||||
about: Something isn't working as expected
|
||||
title: '[Bug]: '
|
||||
ref: 'development'
|
||||
assignees:
|
||||
- aleidk
|
||||
labels:
|
||||
- Priority/Low
|
||||
- Severity/Low
|
||||
- Status/Pending
|
||||
- Type/Bug
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
We appreciate your feedback on how to improve this project. Please be sure to include as much details and any resources if possible!
|
||||
|
||||
- type: checkboxes
|
||||
id: terms
|
||||
attributes:
|
||||
label: Before submitting, I checked...
|
||||
options:
|
||||
- label: The [issue tracker](../) in case this has been reported before
|
||||
required: true
|
||||
- label: The severity of the bug
|
||||
required: true
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: "Expected behavior:"
|
||||
description: A clear and concise description of what you expected to happen. Include screenshots and/or logs if relevant.
|
||||
placeholder: As <who> <when> <where>, I want <what> because <why>
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: current
|
||||
attributes:
|
||||
label: "Current behavior:"
|
||||
description: A clear and concise description of what actually happened. Include screenshots and/or logs if relevant.
|
||||
placeholder: As <who> <when> <where>, I want <what> because <why>
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: reproduce
|
||||
attributes:
|
||||
label: "Steps to reproduce:"
|
||||
description: Anambiguous set of steps to reproduce this bug. Include code snippets if relevant.
|
||||
placeholder: |
|
||||
1. Use x argument / navigate to
|
||||
2. Fill this information
|
||||
3. Go to...
|
||||
4. See error
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
attributes:
|
||||
multiple: false
|
||||
label: Is this a regresion?
|
||||
description: Did this behaviour used to work in the previous version?
|
||||
default: 0
|
||||
options:
|
||||
- "I don't know"
|
||||
- "This is a new feature"
|
||||
- "Yes"
|
||||
- "No"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: environment
|
||||
attributes:
|
||||
label: "Your environment:"
|
||||
description: Tell us details about the environment you experienced the bug in. A minimal/isolated enviroment to reproduce would be apreciated.
|
||||
placeholder: |
|
||||
- Version used:
|
||||
- Browser Name and version:
|
||||
- Operating System and version (desktop or mobile):
|
||||
- Link to your project:
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: additional-information
|
||||
attributes:
|
||||
label: "Additional Information:"
|
||||
description: |
|
||||
Please leave any additional information on the bug that could be helpful! like proposed solutions, examples, links, screenshots, etc.
|
||||
20
node_modules/@alecodes/bun-static-builder/.forgejo/workflows/create.yml
generated
vendored
Normal file
20
node_modules/@alecodes/bun-static-builder/.forgejo/workflows/create.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
name: Template migration
|
||||
|
||||
# The workflow will run only when `use this template` is used
|
||||
on: create
|
||||
|
||||
jobs:
|
||||
create:
|
||||
runs-on: docker
|
||||
|
||||
steps:
|
||||
- name: "Check out the repo"
|
||||
uses: "actions/checkout@v4"
|
||||
|
||||
- name: "Update commit"
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: "chore: initial commit"
|
||||
commit_options: "--amend"
|
||||
push_options: "--force"
|
||||
skip_fetch: true
|
||||
45
node_modules/@alecodes/bun-static-builder/.forgejo/workflows/publish.yml
generated
vendored
Normal file
45
node_modules/@alecodes/bun-static-builder/.forgejo/workflows/publish.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
name: Publish package
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
env:
|
||||
NPM_TAG: ${{ github.ref == 'refs/heads/main' && 'latest' || 'next' }}
|
||||
|
||||
# Variables reference: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#about-contexts
|
||||
# Syntax reference: https://forgejo.org/docs/latest/user/actions/
|
||||
jobs:
|
||||
build_and_publish:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Cache Bun dependencies
|
||||
id: cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-bun-
|
||||
|
||||
- name: Setup Bun
|
||||
id: "setup_bun"
|
||||
uses: oven-sh/setup-bun@v2
|
||||
|
||||
- name: Install dependencies
|
||||
run: "bun install --production"
|
||||
|
||||
- name: Bump version and publish
|
||||
uses: https://github.com/cocogitto/cocogitto-action@v3.10
|
||||
env:
|
||||
NPM_REGISTRY_TOKEN: ${{ secrets.NPM_TOKEN_FORGEJO }}
|
||||
with:
|
||||
release: true
|
||||
check-latest-tag-only: true
|
||||
git-user: 'Cog Bot'
|
||||
git-user-email: 'cog@alecodes.page'
|
||||
5
node_modules/@alecodes/bun-static-builder/.justfile
generated
vendored
Normal file
5
node_modules/@alecodes/bun-static-builder/.justfile
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Repo management tasks
|
||||
mod repo ".devfiles/justfile"
|
||||
|
||||
dev:
|
||||
watchexec --restart --clear --watch ./src bun run ./src/cli.ts
|
||||
14
node_modules/@alecodes/bun-static-builder/CHANGELOG.md
generated
vendored
Normal file
14
node_modules/@alecodes/bun-static-builder/CHANGELOG.md
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Changelog
|
||||
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.
|
||||
|
||||
- - -
|
||||
## 0.1.0 - 2025-02-18
|
||||
#### Features
|
||||
- add build logic - (8ef4d84) - aleidk
|
||||
#### Miscellaneous Chores
|
||||
- add build step - (74d0f81) - aleidk
|
||||
- initial commit - (e23a81c) - alecodes
|
||||
|
||||
- - -
|
||||
|
||||
Changelog generated by [cocogitto](https://github.com/cocogitto/cocogitto).
|
||||
235
node_modules/@alecodes/bun-static-builder/LICENSE
generated
vendored
Normal file
235
node_modules/@alecodes/bun-static-builder/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
base-template
|
||||
Copyright (C) 2024 alecodes
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>.
|
||||
3
node_modules/@alecodes/bun-static-builder/README.md
generated
vendored
Normal file
3
node_modules/@alecodes/bun-static-builder/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# base-template
|
||||
|
||||
Base template to create new repositories
|
||||
35
node_modules/@alecodes/bun-static-builder/cog.toml
generated
vendored
Normal file
35
node_modules/@alecodes/bun-static-builder/cog.toml
generated
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
from_latest_tag = false
|
||||
ignore_merge_commits = true
|
||||
disable_changelog = false
|
||||
disable_bump_commit = false
|
||||
generate_mono_repository_global_tag = true
|
||||
generate_mono_repository_package_tags = true
|
||||
branch_whitelist = []
|
||||
skip_ci = "[skip ci]"
|
||||
skip_untracked = false
|
||||
pre_bump_hooks = [
|
||||
"echo 'bump package to {{version}}'",
|
||||
"sed -E -i 's/(\"version\":) \"[0-9.]{5}\"/\\1 \"{{version}}\"/gi' package.json",
|
||||
"bun run ci:publish",
|
||||
]
|
||||
post_bump_hooks = ["git push", "git push origin {{version_tag}}"]
|
||||
pre_package_bump_hooks = []
|
||||
post_package_bump_hooks = []
|
||||
|
||||
[git_hooks]
|
||||
|
||||
[git_hooks.pre-commit]
|
||||
path = ".devfiles/hooks/pre-commit.sh"
|
||||
|
||||
[git_hooks.commit-msg]
|
||||
path = ".devfiles/hooks/commit-msg.sh"
|
||||
|
||||
[commit_types]
|
||||
|
||||
[changelog]
|
||||
path = "CHANGELOG.md"
|
||||
authors = []
|
||||
|
||||
[bump_profiles]
|
||||
|
||||
[packages]
|
||||
22
node_modules/@alecodes/bun-static-builder/package.json
generated
vendored
Normal file
22
node_modules/@alecodes/bun-static-builder/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "@alecodes/bun-static-builder",
|
||||
"version": "0.1.0",
|
||||
"module": "src/index.ts",
|
||||
"bin": "src/cli.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"ci:publish": "bun publish --production --frozen-lockfile --silent"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mini-strap/core": "^0.1.2",
|
||||
"@types/bun": "latest",
|
||||
"@types/slug": "^5.0.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"sass": "^1.85.0",
|
||||
"slug": "^10.0.0"
|
||||
}
|
||||
}
|
||||
25
node_modules/@alecodes/bun-static-builder/src/cli.ts
generated
vendored
Executable file
25
node_modules/@alecodes/bun-static-builder/src/cli.ts
generated
vendored
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
import Plugin, { LogType } from "./index.ts";
|
||||
import { EntrypointType, type Config, type Entrypoint } from "./types.ts";
|
||||
|
||||
const config: Config = {
|
||||
production: false,
|
||||
outdir: "dist",
|
||||
root: "testfiles",
|
||||
};
|
||||
|
||||
const entrypoints: Entrypoint[] = [
|
||||
{
|
||||
path: "./testfiles/style.css",
|
||||
type: EntrypointType.Css,
|
||||
},
|
||||
{
|
||||
path: "./testfiles/index.ts",
|
||||
type: EntrypointType.Js,
|
||||
},
|
||||
{
|
||||
path: "@mini-strap/core",
|
||||
type: EntrypointType.Package,
|
||||
},
|
||||
];
|
||||
|
||||
await Plugin.build(config, entrypoints);
|
||||
205
node_modules/@alecodes/bun-static-builder/src/index.ts
generated
vendored
Normal file
205
node_modules/@alecodes/bun-static-builder/src/index.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
import type { BuildConfig, BunPlugin, PluginBuilder } from "bun";
|
||||
import type { FileImporter } from "sass";
|
||||
import { type Config, type Entrypoint, EntrypointType, LogType } from "./types";
|
||||
|
||||
import { basename, join, normalize } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { rm } from "node:fs/promises";
|
||||
import slug from "slug";
|
||||
|
||||
// This is used to prevent creating folders with external packages names
|
||||
slug.extend({ "/": "-" });
|
||||
|
||||
const nodeModuleImporter: FileImporter<"async"> = {
|
||||
findFileUrl(url) {
|
||||
if (url.startsWith("@")) {
|
||||
return new URL(import.meta.resolve(url));
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
};
|
||||
|
||||
const sassPlugin: BunPlugin = {
|
||||
name: "Sass Loader",
|
||||
async setup(build: PluginBuilder) {
|
||||
const sass = await import("sass");
|
||||
|
||||
build.onLoad({ filter: /\.scss$/ }, async ({ path }) => {
|
||||
const result = await sass.compileAsync(path, {
|
||||
importers: [nodeModuleImporter],
|
||||
});
|
||||
|
||||
return {
|
||||
loader: "css",
|
||||
contents: result.css,
|
||||
};
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
function log(logtype: LogType, msg: string) {
|
||||
const reset = "\x1b[0m";
|
||||
let color = Bun.color("white", "ansi");
|
||||
|
||||
switch (logtype) {
|
||||
case LogType.Success:
|
||||
color = Bun.color("green", "ansi");
|
||||
break;
|
||||
case LogType.Error:
|
||||
color = Bun.color("#f24444", "ansi");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!color) {
|
||||
color = reset;
|
||||
}
|
||||
|
||||
console.log(color + msg + reset);
|
||||
}
|
||||
|
||||
// Packages needs to exist in the package.json file for this to work
|
||||
function resolvePackage(pkg: string): Entrypoint {
|
||||
const path = normalize(fileURLToPath(import.meta.resolve(pkg)));
|
||||
const file = Bun.file(import.meta.resolve(pkg));
|
||||
const mimetype = file.type.split(";").at(0);
|
||||
|
||||
let type: EntrypointType;
|
||||
|
||||
switch (mimetype) {
|
||||
case "text/x-scss":
|
||||
type = EntrypointType.Sass;
|
||||
break;
|
||||
case "text/javascript":
|
||||
type = EntrypointType.Js;
|
||||
break;
|
||||
default:
|
||||
throw new Error(`No loader found for type ${mimetype} at path ${path}`);
|
||||
}
|
||||
|
||||
return {
|
||||
path,
|
||||
type,
|
||||
};
|
||||
}
|
||||
|
||||
export default {
|
||||
log,
|
||||
|
||||
build: async (config: Config, entrypoints: Entrypoint[]) => {
|
||||
// Resolve external packages
|
||||
|
||||
const external_cache: string[] = [];
|
||||
const resolved_entrypoints = entrypoints.map((item) => {
|
||||
if (item.type !== EntrypointType.Package) {
|
||||
return item;
|
||||
}
|
||||
|
||||
external_cache.push(item.path);
|
||||
return resolvePackage(item.path);
|
||||
});
|
||||
|
||||
const baseConfig = {
|
||||
minify: config.production,
|
||||
outdir: `${config.outdir}/js`,
|
||||
packages: "external",
|
||||
root: config.root,
|
||||
splitting: config.production,
|
||||
};
|
||||
|
||||
// Apply build config per type
|
||||
const loaders = {
|
||||
assetLoader: {
|
||||
entrypoints: resolved_entrypoints
|
||||
.filter((entry) => entry.type === EntrypointType.Asset)
|
||||
.map((entry) => entry.path),
|
||||
outdir: `${config.outdir}/asset`,
|
||||
},
|
||||
stylesLoader: {
|
||||
...baseConfig,
|
||||
entrypoints: resolved_entrypoints
|
||||
.filter((entry) =>
|
||||
[EntrypointType.Css, EntrypointType.Sass].includes(entry.type),
|
||||
)
|
||||
.map((entry) => entry.path),
|
||||
outdir: `${config.outdir}/css`,
|
||||
plugins: [sassPlugin],
|
||||
},
|
||||
jsLoader: {
|
||||
...baseConfig,
|
||||
entrypoints: resolved_entrypoints
|
||||
.filter((entry) => entry.type === EntrypointType.Js)
|
||||
.map((entry) => entry.path),
|
||||
target: "browser",
|
||||
},
|
||||
};
|
||||
|
||||
// Transform into a list to later use Promise.all
|
||||
const assets = Object.values(loaders).filter(
|
||||
(item) => item.entrypoints.length !== 0,
|
||||
);
|
||||
|
||||
log(LogType.Info, "Building assets...");
|
||||
|
||||
const out = await Promise.all(
|
||||
assets.map(async (item) => {
|
||||
const result = await Bun.build(item as BuildConfig);
|
||||
|
||||
if (!result.success) {
|
||||
throw new AggregateError(result.logs, "Build failed");
|
||||
}
|
||||
|
||||
// Normalize external packages folder structure
|
||||
for (const out of result.outputs) {
|
||||
if (!out.path.includes("node_modules")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let package_name = external_cache.find((pkg) =>
|
||||
out.path.includes(pkg),
|
||||
);
|
||||
|
||||
if (!package_name) {
|
||||
throw new Error(
|
||||
`Could not normilize path for external package: ${out.path}`,
|
||||
);
|
||||
}
|
||||
|
||||
package_name = slug(package_name);
|
||||
|
||||
if (!package_name) {
|
||||
throw new Error(
|
||||
`Could not normilize path for external package: ${out.path}`,
|
||||
);
|
||||
}
|
||||
|
||||
const new_path = join(
|
||||
config.outdir,
|
||||
"pkgs",
|
||||
package_name,
|
||||
basename(out.path),
|
||||
);
|
||||
|
||||
await Bun.write(new_path, out);
|
||||
}
|
||||
|
||||
return result;
|
||||
}),
|
||||
);
|
||||
|
||||
if (out.some((item) => !item.success)) {
|
||||
throw new Error(`Some entrypoint failed to build: ${out}`);
|
||||
}
|
||||
|
||||
await rm(join(config.outdir, "node_modules"), {
|
||||
recursive: true,
|
||||
force: true,
|
||||
});
|
||||
|
||||
log(LogType.Success, "Complete!");
|
||||
},
|
||||
};
|
||||
26
node_modules/@alecodes/bun-static-builder/src/types.ts
generated
vendored
Normal file
26
node_modules/@alecodes/bun-static-builder/src/types.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
export enum LogType {
|
||||
Info = 1,
|
||||
Success = 2,
|
||||
Error = 3,
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
production: boolean;
|
||||
outdir: string;
|
||||
root?: string;
|
||||
}
|
||||
|
||||
// Try to match mime types
|
||||
export enum EntrypointType {
|
||||
Asset = "asset",
|
||||
Js = "javascript",
|
||||
Css = "css",
|
||||
Sass = "scss",
|
||||
Package = "pkg",
|
||||
}
|
||||
|
||||
export interface Entrypoint {
|
||||
path: string;
|
||||
type: EntrypointType;
|
||||
outdir?: string;
|
||||
}
|
||||
1
node_modules/@alecodes/bun-static-builder/testfiles/index.ts
generated
vendored
Normal file
1
node_modules/@alecodes/bun-static-builder/testfiles/index.ts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
console.log("Hello World!");
|
||||
3
node_modules/@alecodes/bun-static-builder/testfiles/style.css
generated
vendored
Normal file
3
node_modules/@alecodes/bun-static-builder/testfiles/style.css
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
* {
|
||||
background-color: red;
|
||||
}
|
||||
27
node_modules/@alecodes/bun-static-builder/tsconfig.json
generated
vendored
Normal file
27
node_modules/@alecodes/bun-static-builder/tsconfig.json
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable latest features
|
||||
"lib": ["ESNext", "DOM"],
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"allowJs": true,
|
||||
|
||||
// Bundler mode
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true,
|
||||
|
||||
// Best practices
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
|
||||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noPropertyAccessFromIndexSignature": false
|
||||
}
|
||||
}
|
||||
21
node_modules/@parcel/watcher-linux-x64-glibc/LICENSE
generated
vendored
Normal file
21
node_modules/@parcel/watcher-linux-x64-glibc/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017-present Devon Govett
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
1
node_modules/@parcel/watcher-linux-x64-glibc/README.md
generated
vendored
Normal file
1
node_modules/@parcel/watcher-linux-x64-glibc/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
This is the linux-x64-glibc build of @parcel/watcher. See https://github.com/parcel-bundler/watcher for details.
|
||||
33
node_modules/@parcel/watcher-linux-x64-glibc/package.json
generated
vendored
Normal file
33
node_modules/@parcel/watcher-linux-x64-glibc/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "@parcel/watcher-linux-x64-glibc",
|
||||
"version": "2.5.1",
|
||||
"main": "watcher.node",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/parcel-bundler/watcher.git"
|
||||
},
|
||||
"description": "A native C++ Node module for querying and subscribing to filesystem events. Used by Parcel 2.",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
},
|
||||
"files": [
|
||||
"watcher.node"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"libc": [
|
||||
"glibc"
|
||||
]
|
||||
}
|
||||
BIN
node_modules/@parcel/watcher-linux-x64-glibc/watcher.node
generated
vendored
Normal file
BIN
node_modules/@parcel/watcher-linux-x64-glibc/watcher.node
generated
vendored
Normal file
Binary file not shown.
21
node_modules/@parcel/watcher-linux-x64-musl/LICENSE
generated
vendored
Normal file
21
node_modules/@parcel/watcher-linux-x64-musl/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017-present Devon Govett
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
1
node_modules/@parcel/watcher-linux-x64-musl/README.md
generated
vendored
Normal file
1
node_modules/@parcel/watcher-linux-x64-musl/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
This is the linux-x64-musl build of @parcel/watcher. See https://github.com/parcel-bundler/watcher for details.
|
||||
33
node_modules/@parcel/watcher-linux-x64-musl/package.json
generated
vendored
Normal file
33
node_modules/@parcel/watcher-linux-x64-musl/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "@parcel/watcher-linux-x64-musl",
|
||||
"version": "2.5.1",
|
||||
"main": "watcher.node",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/parcel-bundler/watcher.git"
|
||||
},
|
||||
"description": "A native C++ Node module for querying and subscribing to filesystem events. Used by Parcel 2.",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
},
|
||||
"files": [
|
||||
"watcher.node"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"libc": [
|
||||
"musl"
|
||||
]
|
||||
}
|
||||
BIN
node_modules/@parcel/watcher-linux-x64-musl/watcher.node
generated
vendored
Normal file
BIN
node_modules/@parcel/watcher-linux-x64-musl/watcher.node
generated
vendored
Normal file
Binary file not shown.
21
node_modules/@parcel/watcher/LICENSE
generated
vendored
Normal file
21
node_modules/@parcel/watcher/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017-present Devon Govett
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
135
node_modules/@parcel/watcher/README.md
generated
vendored
Normal file
135
node_modules/@parcel/watcher/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
# @parcel/watcher
|
||||
|
||||
A native C++ Node module for querying and subscribing to filesystem events. Used by [Parcel 2](https://github.com/parcel-bundler/parcel).
|
||||
|
||||
## Features
|
||||
|
||||
- **Watch** - subscribe to realtime recursive directory change notifications when files or directories are created, updated, or deleted.
|
||||
- **Query** - performantly query for historical change events in a directory, even when your program is not running.
|
||||
- **Native** - implemented in C++ for performance and low-level integration with the operating system.
|
||||
- **Cross platform** - includes backends for macOS, Linux, Windows, FreeBSD, and Watchman.
|
||||
- **Performant** - events are throttled in C++ so the JavaScript thread is not overwhelmed during large filesystem changes (e.g. `git checkout` or `npm install`).
|
||||
- **Scalable** - tens of thousands of files can be watched or queried at once with good performance.
|
||||
|
||||
## Example
|
||||
|
||||
```javascript
|
||||
const watcher = require('@parcel/watcher');
|
||||
const path = require('path');
|
||||
|
||||
// Subscribe to events
|
||||
let subscription = await watcher.subscribe(process.cwd(), (err, events) => {
|
||||
console.log(events);
|
||||
});
|
||||
|
||||
// later on...
|
||||
await subscription.unsubscribe();
|
||||
|
||||
// Get events since some saved snapshot in the past
|
||||
let snapshotPath = path.join(process.cwd(), 'snapshot.txt');
|
||||
let events = await watcher.getEventsSince(process.cwd(), snapshotPath);
|
||||
|
||||
// Save a snapshot for later
|
||||
await watcher.writeSnapshot(process.cwd(), snapshotPath);
|
||||
```
|
||||
|
||||
## Watching
|
||||
|
||||
`@parcel/watcher` supports subscribing to realtime notifications of changes in a directory. It works recursively, so changes in sub-directories will also be emitted.
|
||||
|
||||
Events are throttled and coalesced for performance during large changes like `git checkout` or `npm install`, and a single notification will be emitted with all of the events at the end.
|
||||
|
||||
Only one notification will be emitted per file. For example, if a file was both created and updated since the last event, you'll get only a `create` event. If a file is both created and deleted, you will not be notifed of that file. Renames cause two events: a `delete` for the old name, and a `create` for the new name.
|
||||
|
||||
```javascript
|
||||
let subscription = await watcher.subscribe(process.cwd(), (err, events) => {
|
||||
console.log(events);
|
||||
});
|
||||
```
|
||||
|
||||
Events have two properties:
|
||||
|
||||
- `type` - the event type: `create`, `update`, or `delete`.
|
||||
- `path` - the absolute path to the file or directory.
|
||||
|
||||
To unsubscribe from change notifications, call the `unsubscribe` method on the returned subscription object.
|
||||
|
||||
```javascript
|
||||
await subscription.unsubscribe();
|
||||
```
|
||||
|
||||
`@parcel/watcher` has the following watcher backends, listed in priority order:
|
||||
|
||||
- [FSEvents](https://developer.apple.com/documentation/coreservices/file_system_events) on macOS
|
||||
- [Watchman](https://facebook.github.io/watchman/) if installed
|
||||
- [inotify](http://man7.org/linux/man-pages/man7/inotify.7.html) on Linux
|
||||
- [ReadDirectoryChangesW](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365465%28v%3Dvs.85%29.aspx) on Windows
|
||||
- [kqueue](https://man.freebsd.org/cgi/man.cgi?kqueue) on FreeBSD, or as an alternative to FSEvents on macOS
|
||||
|
||||
You can specify the exact backend you wish to use by passing the `backend` option. If that backend is not available on the current platform, the default backend will be used instead. See below for the list of backend names that can be passed to the options.
|
||||
|
||||
## Querying
|
||||
|
||||
`@parcel/watcher` also supports querying for historical changes made in a directory, even when your program is not running. This makes it easy to invalidate a cache and re-build only the files that have changed, for example. It can be **significantly** faster than traversing the entire filesystem to determine what files changed, depending on the platform.
|
||||
|
||||
In order to query for historical changes, you first need a previous snapshot to compare to. This can be saved to a file with the `writeSnapshot` function, e.g. just before your program exits.
|
||||
|
||||
```javascript
|
||||
await watcher.writeSnapshot(dirPath, snapshotPath);
|
||||
```
|
||||
|
||||
When your program starts up, you can query for changes that have occurred since that snapshot using the `getEventsSince` function.
|
||||
|
||||
```javascript
|
||||
let events = await watcher.getEventsSince(dirPath, snapshotPath);
|
||||
```
|
||||
|
||||
The events returned are exactly the same as the events that would be passed to the `subscribe` callback (see above).
|
||||
|
||||
`@parcel/watcher` has the following watcher backends, listed in priority order:
|
||||
|
||||
- [FSEvents](https://developer.apple.com/documentation/coreservices/file_system_events) on macOS
|
||||
- [Watchman](https://facebook.github.io/watchman/) if installed
|
||||
- [fts](http://man7.org/linux/man-pages/man3/fts.3.html) (brute force) on Linux and FreeBSD
|
||||
- [FindFirstFile](https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-findfirstfilea) (brute force) on Windows
|
||||
|
||||
The FSEvents (macOS) and Watchman backends are significantly more performant than the brute force backends used by default on Linux and Windows, for example returning results in miliseconds instead of seconds for large directory trees. This is because a background daemon monitoring filesystem changes on those platforms allows us to query cached data rather than traversing the filesystem manually (brute force).
|
||||
|
||||
macOS has good performance with FSEvents by default. For the best performance on other platforms, install [Watchman](https://facebook.github.io/watchman/) and it will be used by `@parcel/watcher` automatically.
|
||||
|
||||
You can specify the exact backend you wish to use by passing the `backend` option. If that backend is not available on the current platform, the default backend will be used instead. See below for the list of backend names that can be passed to the options.
|
||||
|
||||
## Options
|
||||
|
||||
All of the APIs in `@parcel/watcher` support the following options, which are passed as an object as the last function argument.
|
||||
|
||||
- `ignore` - an array of paths or glob patterns to ignore. uses [`is-glob`](https://github.com/micromatch/is-glob) to distinguish paths from globs. glob patterns are parsed with [`micromatch`](https://github.com/micromatch/micromatch) (see [features](https://github.com/micromatch/micromatch#matching-features)).
|
||||
- paths can be relative or absolute and can either be files or directories. No events will be emitted about these files or directories or their children.
|
||||
- glob patterns match on relative paths from the root that is watched. No events will be emitted for matching paths.
|
||||
- `backend` - the name of an explicitly chosen backend to use. Allowed options are `"fs-events"`, `"watchman"`, `"inotify"`, `"kqueue"`, `"windows"`, or `"brute-force"` (only for querying). If the specified backend is not available on the current platform, the default backend will be used instead.
|
||||
|
||||
## WASM
|
||||
|
||||
The `@parcel/watcher-wasm` package can be used in place of `@parcel/watcher` on unsupported platforms. It relies on the Node `fs` module, so in non-Node environments such as browsers, an `fs` polyfill will be needed.
|
||||
|
||||
**Note**: the WASM implementation is significantly less efficient than the native implementations because it must crawl the file system to watch each directory individually. Use the native `@parcel/watcher` package wherever possible.
|
||||
|
||||
```js
|
||||
import {subscribe} from '@parcel/watcher-wasm';
|
||||
|
||||
// Use the module as documented above.
|
||||
subscribe(/* ... */);
|
||||
```
|
||||
|
||||
## Who is using this?
|
||||
|
||||
- [Parcel 2](https://parceljs.org/)
|
||||
- [VSCode](https://code.visualstudio.com/updates/v1_62#_file-watching-changes)
|
||||
- [Tailwind CSS Intellisense](https://github.com/tailwindlabs/tailwindcss-intellisense)
|
||||
- [Gatsby Cloud](https://twitter.com/chatsidhartha/status/1435647412828196867)
|
||||
- [Nx](https://nx.dev)
|
||||
- [Nuxt](https://nuxt.com)
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
93
node_modules/@parcel/watcher/binding.gyp
generated
vendored
Normal file
93
node_modules/@parcel/watcher/binding.gyp
generated
vendored
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
{
|
||||
"targets": [
|
||||
{
|
||||
"target_name": "watcher",
|
||||
"defines": [ "NAPI_DISABLE_CPP_EXCEPTIONS" ],
|
||||
"sources": [ "src/binding.cc", "src/Watcher.cc", "src/Backend.cc", "src/DirTree.cc", "src/Glob.cc", "src/Debounce.cc" ],
|
||||
"include_dirs" : ["<!(node -p \"require('node-addon-api').include_dir\")"],
|
||||
'cflags!': [ '-fno-exceptions', '-std=c++17' ],
|
||||
'cflags_cc!': [ '-fno-exceptions', '-std=c++17' ],
|
||||
"conditions": [
|
||||
['OS=="mac"', {
|
||||
"sources": [
|
||||
"src/watchman/BSER.cc",
|
||||
"src/watchman/WatchmanBackend.cc",
|
||||
"src/shared/BruteForceBackend.cc",
|
||||
"src/unix/fts.cc",
|
||||
"src/macos/FSEventsBackend.cc",
|
||||
"src/kqueue/KqueueBackend.cc"
|
||||
],
|
||||
"link_settings": {
|
||||
"libraries": ["CoreServices.framework"]
|
||||
},
|
||||
"defines": [
|
||||
"WATCHMAN",
|
||||
"BRUTE_FORCE",
|
||||
"FS_EVENTS",
|
||||
"KQUEUE"
|
||||
],
|
||||
"xcode_settings": {
|
||||
"GCC_ENABLE_CPP_EXCEPTIONS": "YES"
|
||||
}
|
||||
}],
|
||||
['OS=="mac" and target_arch=="arm64"', {
|
||||
"xcode_settings": {
|
||||
"ARCHS": ["arm64"]
|
||||
}
|
||||
}],
|
||||
['OS=="linux" or OS=="android"', {
|
||||
"sources": [
|
||||
"src/watchman/BSER.cc",
|
||||
"src/watchman/WatchmanBackend.cc",
|
||||
"src/shared/BruteForceBackend.cc",
|
||||
"src/linux/InotifyBackend.cc",
|
||||
"src/unix/legacy.cc"
|
||||
],
|
||||
"defines": [
|
||||
"WATCHMAN",
|
||||
"INOTIFY",
|
||||
"BRUTE_FORCE"
|
||||
]
|
||||
}],
|
||||
['OS=="win"', {
|
||||
"sources": [
|
||||
"src/watchman/BSER.cc",
|
||||
"src/watchman/WatchmanBackend.cc",
|
||||
"src/shared/BruteForceBackend.cc",
|
||||
"src/windows/WindowsBackend.cc",
|
||||
"src/windows/win_utils.cc"
|
||||
],
|
||||
"defines": [
|
||||
"WATCHMAN",
|
||||
"WINDOWS",
|
||||
"BRUTE_FORCE"
|
||||
],
|
||||
"msvs_settings": {
|
||||
"VCCLCompilerTool": {
|
||||
"ExceptionHandling": 1, # /EHsc
|
||||
"AdditionalOptions": ['-std:c++17']
|
||||
}
|
||||
}
|
||||
}],
|
||||
['OS=="freebsd"', {
|
||||
"sources": [
|
||||
"src/watchman/BSER.cc",
|
||||
"src/watchman/WatchmanBackend.cc",
|
||||
"src/shared/BruteForceBackend.cc",
|
||||
"src/unix/fts.cc",
|
||||
"src/kqueue/KqueueBackend.cc"
|
||||
],
|
||||
"defines": [
|
||||
"WATCHMAN",
|
||||
"BRUTE_FORCE",
|
||||
"KQUEUE"
|
||||
]
|
||||
}]
|
||||
]
|
||||
}
|
||||
],
|
||||
"variables": {
|
||||
"openssl_fips": "",
|
||||
"node_use_dtrace": "false"
|
||||
}
|
||||
}
|
||||
49
node_modules/@parcel/watcher/index.d.ts
generated
vendored
Normal file
49
node_modules/@parcel/watcher/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
declare type FilePath = string;
|
||||
declare type GlobPattern = string;
|
||||
|
||||
declare namespace ParcelWatcher {
|
||||
export type BackendType =
|
||||
| 'fs-events'
|
||||
| 'watchman'
|
||||
| 'inotify'
|
||||
| 'windows'
|
||||
| 'brute-force';
|
||||
export type EventType = 'create' | 'update' | 'delete';
|
||||
export interface Options {
|
||||
ignore?: (FilePath|GlobPattern)[];
|
||||
backend?: BackendType;
|
||||
}
|
||||
export type SubscribeCallback = (
|
||||
err: Error | null,
|
||||
events: Event[]
|
||||
) => unknown;
|
||||
export interface AsyncSubscription {
|
||||
unsubscribe(): Promise<void>;
|
||||
}
|
||||
export interface Event {
|
||||
path: FilePath;
|
||||
type: EventType;
|
||||
}
|
||||
export function getEventsSince(
|
||||
dir: FilePath,
|
||||
snapshot: FilePath,
|
||||
opts?: Options
|
||||
): Promise<Event[]>;
|
||||
export function subscribe(
|
||||
dir: FilePath,
|
||||
fn: SubscribeCallback,
|
||||
opts?: Options
|
||||
): Promise<AsyncSubscription>;
|
||||
export function unsubscribe(
|
||||
dir: FilePath,
|
||||
fn: SubscribeCallback,
|
||||
opts?: Options
|
||||
): Promise<void>;
|
||||
export function writeSnapshot(
|
||||
dir: FilePath,
|
||||
snapshot: FilePath,
|
||||
opts?: Options
|
||||
): Promise<FilePath>;
|
||||
}
|
||||
|
||||
export = ParcelWatcher;
|
||||
41
node_modules/@parcel/watcher/index.js
generated
vendored
Normal file
41
node_modules/@parcel/watcher/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
const {createWrapper} = require('./wrapper');
|
||||
|
||||
let name = `@parcel/watcher-${process.platform}-${process.arch}`;
|
||||
if (process.platform === 'linux') {
|
||||
const { MUSL, family } = require('detect-libc');
|
||||
if (family === MUSL) {
|
||||
name += '-musl';
|
||||
} else {
|
||||
name += '-glibc';
|
||||
}
|
||||
}
|
||||
|
||||
let binding;
|
||||
try {
|
||||
binding = require(name);
|
||||
} catch (err) {
|
||||
handleError(err);
|
||||
try {
|
||||
binding = require('./build/Release/watcher.node');
|
||||
} catch (err) {
|
||||
handleError(err);
|
||||
try {
|
||||
binding = require('./build/Debug/watcher.node');
|
||||
} catch (err) {
|
||||
handleError(err);
|
||||
throw new Error(`No prebuild or local build of @parcel/watcher found. Tried ${name}. Please ensure it is installed (don't use --no-optional when installing with npm). Otherwise it is possible we don't support your platform yet. If this is the case, please report an issue to https://github.com/parcel-bundler/watcher.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleError(err) {
|
||||
if (err?.code !== 'MODULE_NOT_FOUND') {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
const wrapper = createWrapper(binding);
|
||||
exports.writeSnapshot = wrapper.writeSnapshot;
|
||||
exports.getEventsSince = wrapper.getEventsSince;
|
||||
exports.subscribe = wrapper.subscribe;
|
||||
exports.unsubscribe = wrapper.unsubscribe;
|
||||
48
node_modules/@parcel/watcher/index.js.flow
generated
vendored
Normal file
48
node_modules/@parcel/watcher/index.js.flow
generated
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// @flow
|
||||
declare type FilePath = string;
|
||||
declare type GlobPattern = string;
|
||||
|
||||
export type BackendType =
|
||||
| 'fs-events'
|
||||
| 'watchman'
|
||||
| 'inotify'
|
||||
| 'windows'
|
||||
| 'brute-force';
|
||||
export type EventType = 'create' | 'update' | 'delete';
|
||||
export interface Options {
|
||||
ignore?: Array<FilePath | GlobPattern>,
|
||||
backend?: BackendType
|
||||
}
|
||||
export type SubscribeCallback = (
|
||||
err: ?Error,
|
||||
events: Array<Event>
|
||||
) => mixed;
|
||||
export interface AsyncSubscription {
|
||||
unsubscribe(): Promise<void>
|
||||
}
|
||||
export interface Event {
|
||||
path: FilePath,
|
||||
type: EventType
|
||||
}
|
||||
declare module.exports: {
|
||||
getEventsSince(
|
||||
dir: FilePath,
|
||||
snapshot: FilePath,
|
||||
opts?: Options
|
||||
): Promise<Array<Event>>,
|
||||
subscribe(
|
||||
dir: FilePath,
|
||||
fn: SubscribeCallback,
|
||||
opts?: Options
|
||||
): Promise<AsyncSubscription>,
|
||||
unsubscribe(
|
||||
dir: FilePath,
|
||||
fn: SubscribeCallback,
|
||||
opts?: Options
|
||||
): Promise<void>,
|
||||
writeSnapshot(
|
||||
dir: FilePath,
|
||||
snapshot: FilePath,
|
||||
opts?: Options
|
||||
): Promise<FilePath>
|
||||
}
|
||||
88
node_modules/@parcel/watcher/package.json
generated
vendored
Normal file
88
node_modules/@parcel/watcher/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
{
|
||||
"name": "@parcel/watcher",
|
||||
"version": "2.5.1",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/parcel-bundler/watcher.git"
|
||||
},
|
||||
"description": "A native C++ Node module for querying and subscribing to filesystem events. Used by Parcel 2.",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.js.flow",
|
||||
"index.d.ts",
|
||||
"wrapper.js",
|
||||
"package.json",
|
||||
"README.md",
|
||||
"LICENSE",
|
||||
"src",
|
||||
"scripts/build-from-source.js",
|
||||
"binding.gyp"
|
||||
],
|
||||
"scripts": {
|
||||
"prebuild": "prebuildify --napi --strip --tag-libc",
|
||||
"format": "prettier --write \"./**/*.{js,json,md}\"",
|
||||
"build": "node-gyp rebuild",
|
||||
"install": "node scripts/build-from-source.js",
|
||||
"test": "mocha"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,json,md}": [
|
||||
"prettier --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"detect-libc": "^1.0.3",
|
||||
"is-glob": "^4.0.3",
|
||||
"micromatch": "^4.0.5",
|
||||
"node-addon-api": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.19.8",
|
||||
"fs-extra": "^10.0.0",
|
||||
"husky": "^7.0.2",
|
||||
"lint-staged": "^11.1.2",
|
||||
"mocha": "^9.1.1",
|
||||
"napi-wasm": "^1.1.0",
|
||||
"prebuildify": "^6.0.1",
|
||||
"prettier": "^2.3.2"
|
||||
},
|
||||
"binary": {
|
||||
"napi_versions": [
|
||||
3
|
||||
]
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@parcel/watcher-darwin-x64": "2.5.1",
|
||||
"@parcel/watcher-darwin-arm64": "2.5.1",
|
||||
"@parcel/watcher-win32-x64": "2.5.1",
|
||||
"@parcel/watcher-win32-arm64": "2.5.1",
|
||||
"@parcel/watcher-win32-ia32": "2.5.1",
|
||||
"@parcel/watcher-linux-x64-glibc": "2.5.1",
|
||||
"@parcel/watcher-linux-x64-musl": "2.5.1",
|
||||
"@parcel/watcher-linux-arm64-glibc": "2.5.1",
|
||||
"@parcel/watcher-linux-arm64-musl": "2.5.1",
|
||||
"@parcel/watcher-linux-arm-glibc": "2.5.1",
|
||||
"@parcel/watcher-linux-arm-musl": "2.5.1",
|
||||
"@parcel/watcher-android-arm64": "2.5.1",
|
||||
"@parcel/watcher-freebsd-x64": "2.5.1"
|
||||
}
|
||||
}
|
||||
13
node_modules/@parcel/watcher/scripts/build-from-source.js
generated
vendored
Normal file
13
node_modules/@parcel/watcher/scripts/build-from-source.js
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const {spawn} = require('child_process');
|
||||
|
||||
if (process.env.npm_config_build_from_source === 'true') {
|
||||
build();
|
||||
}
|
||||
|
||||
function build() {
|
||||
spawn('node-gyp', ['rebuild'], { stdio: 'inherit', shell: true }).on('exit', function (code) {
|
||||
process.exit(code);
|
||||
});
|
||||
}
|
||||
182
node_modules/@parcel/watcher/src/Backend.cc
generated
vendored
Normal file
182
node_modules/@parcel/watcher/src/Backend.cc
generated
vendored
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
#ifdef FS_EVENTS
|
||||
#include "macos/FSEventsBackend.hh"
|
||||
#endif
|
||||
#ifdef WATCHMAN
|
||||
#include "watchman/WatchmanBackend.hh"
|
||||
#endif
|
||||
#ifdef WINDOWS
|
||||
#include "windows/WindowsBackend.hh"
|
||||
#endif
|
||||
#ifdef INOTIFY
|
||||
#include "linux/InotifyBackend.hh"
|
||||
#endif
|
||||
#ifdef KQUEUE
|
||||
#include "kqueue/KqueueBackend.hh"
|
||||
#endif
|
||||
#ifdef __wasm32__
|
||||
#include "wasm/WasmBackend.hh"
|
||||
#endif
|
||||
#include "shared/BruteForceBackend.hh"
|
||||
|
||||
#include "Backend.hh"
|
||||
#include <unordered_map>
|
||||
|
||||
static std::unordered_map<std::string, std::shared_ptr<Backend>> sharedBackends;
|
||||
|
||||
std::shared_ptr<Backend> getBackend(std::string backend) {
|
||||
// Use FSEvents on macOS by default.
|
||||
// Use watchman by default if available on other platforms.
|
||||
// Fall back to brute force.
|
||||
#ifdef FS_EVENTS
|
||||
if (backend == "fs-events" || backend == "default") {
|
||||
return std::make_shared<FSEventsBackend>();
|
||||
}
|
||||
#endif
|
||||
#ifdef WATCHMAN
|
||||
if ((backend == "watchman" || backend == "default") && WatchmanBackend::checkAvailable()) {
|
||||
return std::make_shared<WatchmanBackend>();
|
||||
}
|
||||
#endif
|
||||
#ifdef WINDOWS
|
||||
if (backend == "windows" || backend == "default") {
|
||||
return std::make_shared<WindowsBackend>();
|
||||
}
|
||||
#endif
|
||||
#ifdef INOTIFY
|
||||
if (backend == "inotify" || backend == "default") {
|
||||
return std::make_shared<InotifyBackend>();
|
||||
}
|
||||
#endif
|
||||
#ifdef KQUEUE
|
||||
if (backend == "kqueue" || backend == "default") {
|
||||
return std::make_shared<KqueueBackend>();
|
||||
}
|
||||
#endif
|
||||
#ifdef __wasm32__
|
||||
if (backend == "wasm" || backend == "default") {
|
||||
return std::make_shared<WasmBackend>();
|
||||
}
|
||||
#endif
|
||||
if (backend == "brute-force" || backend == "default") {
|
||||
return std::make_shared<BruteForceBackend>();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<Backend> Backend::getShared(std::string backend) {
|
||||
auto found = sharedBackends.find(backend);
|
||||
if (found != sharedBackends.end()) {
|
||||
return found->second;
|
||||
}
|
||||
|
||||
auto result = getBackend(backend);
|
||||
if (!result) {
|
||||
return getShared("default");
|
||||
}
|
||||
|
||||
result->run();
|
||||
sharedBackends.emplace(backend, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void removeShared(Backend *backend) {
|
||||
for (auto it = sharedBackends.begin(); it != sharedBackends.end(); it++) {
|
||||
if (it->second.get() == backend) {
|
||||
sharedBackends.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Free up memory.
|
||||
if (sharedBackends.size() == 0) {
|
||||
sharedBackends.rehash(0);
|
||||
}
|
||||
}
|
||||
|
||||
void Backend::run() {
|
||||
#ifndef __wasm32__
|
||||
mThread = std::thread([this] () {
|
||||
try {
|
||||
start();
|
||||
} catch (std::exception &err) {
|
||||
handleError(err);
|
||||
}
|
||||
});
|
||||
|
||||
if (mThread.joinable()) {
|
||||
mStartedSignal.wait();
|
||||
}
|
||||
#else
|
||||
try {
|
||||
start();
|
||||
} catch (std::exception &err) {
|
||||
handleError(err);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Backend::notifyStarted() {
|
||||
mStartedSignal.notify();
|
||||
}
|
||||
|
||||
void Backend::start() {
|
||||
notifyStarted();
|
||||
}
|
||||
|
||||
Backend::~Backend() {
|
||||
#ifndef __wasm32__
|
||||
// Wait for thread to stop
|
||||
if (mThread.joinable()) {
|
||||
// If the backend is being destroyed from the thread itself, detach, otherwise join.
|
||||
if (mThread.get_id() == std::this_thread::get_id()) {
|
||||
mThread.detach();
|
||||
} else {
|
||||
mThread.join();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Backend::watch(WatcherRef watcher) {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
auto res = mSubscriptions.find(watcher);
|
||||
if (res == mSubscriptions.end()) {
|
||||
try {
|
||||
this->subscribe(watcher);
|
||||
mSubscriptions.insert(watcher);
|
||||
} catch (std::exception &err) {
|
||||
unref();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Backend::unwatch(WatcherRef watcher) {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
size_t deleted = mSubscriptions.erase(watcher);
|
||||
if (deleted > 0) {
|
||||
this->unsubscribe(watcher);
|
||||
unref();
|
||||
}
|
||||
}
|
||||
|
||||
void Backend::unref() {
|
||||
if (mSubscriptions.size() == 0) {
|
||||
removeShared(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Backend::handleWatcherError(WatcherError &err) {
|
||||
unwatch(err.mWatcher);
|
||||
err.mWatcher->notifyError(err);
|
||||
}
|
||||
|
||||
void Backend::handleError(std::exception &err) {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
for (auto it = mSubscriptions.begin(); it != mSubscriptions.end(); it++) {
|
||||
(*it)->notifyError(err);
|
||||
}
|
||||
|
||||
removeShared(this);
|
||||
}
|
||||
37
node_modules/@parcel/watcher/src/Backend.hh
generated
vendored
Normal file
37
node_modules/@parcel/watcher/src/Backend.hh
generated
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef BACKEND_H
|
||||
#define BACKEND_H
|
||||
|
||||
#include "Event.hh"
|
||||
#include "Watcher.hh"
|
||||
#include "Signal.hh"
|
||||
#include <thread>
|
||||
|
||||
class Backend {
|
||||
public:
|
||||
virtual ~Backend();
|
||||
void run();
|
||||
void notifyStarted();
|
||||
|
||||
virtual void start();
|
||||
virtual void writeSnapshot(WatcherRef watcher, std::string *snapshotPath) = 0;
|
||||
virtual void getEventsSince(WatcherRef watcher, std::string *snapshotPath) = 0;
|
||||
virtual void subscribe(WatcherRef watcher) = 0;
|
||||
virtual void unsubscribe(WatcherRef watcher) = 0;
|
||||
|
||||
static std::shared_ptr<Backend> getShared(std::string backend);
|
||||
|
||||
void watch(WatcherRef watcher);
|
||||
void unwatch(WatcherRef watcher);
|
||||
void unref();
|
||||
void handleWatcherError(WatcherError &err);
|
||||
|
||||
std::mutex mMutex;
|
||||
std::thread mThread;
|
||||
private:
|
||||
std::unordered_set<WatcherRef> mSubscriptions;
|
||||
Signal mStartedSignal;
|
||||
|
||||
void handleError(std::exception &err);
|
||||
};
|
||||
|
||||
#endif
|
||||
113
node_modules/@parcel/watcher/src/Debounce.cc
generated
vendored
Normal file
113
node_modules/@parcel/watcher/src/Debounce.cc
generated
vendored
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
#include "Debounce.hh"
|
||||
|
||||
#ifdef __wasm32__
|
||||
extern "C" void on_timeout(void *ctx) {
|
||||
Debounce *debounce = (Debounce *)ctx;
|
||||
debounce->notify();
|
||||
}
|
||||
#endif
|
||||
|
||||
std::shared_ptr<Debounce> Debounce::getShared() {
|
||||
static std::weak_ptr<Debounce> sharedInstance;
|
||||
std::shared_ptr<Debounce> shared = sharedInstance.lock();
|
||||
if (!shared) {
|
||||
shared = std::make_shared<Debounce>();
|
||||
sharedInstance = shared;
|
||||
}
|
||||
|
||||
return shared;
|
||||
}
|
||||
|
||||
Debounce::Debounce() {
|
||||
mRunning = true;
|
||||
#ifndef __wasm32__
|
||||
mThread = std::thread([this] () {
|
||||
loop();
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
Debounce::~Debounce() {
|
||||
mRunning = false;
|
||||
#ifndef __wasm32__
|
||||
mWaitSignal.notify();
|
||||
mThread.join();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Debounce::add(void *key, std::function<void()> cb) {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
mCallbacks.emplace(key, cb);
|
||||
}
|
||||
|
||||
void Debounce::remove(void *key) {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
mCallbacks.erase(key);
|
||||
}
|
||||
|
||||
void Debounce::trigger() {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
#ifdef __wasm32__
|
||||
notifyIfReady();
|
||||
#else
|
||||
mWaitSignal.notify();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef __wasm32__
|
||||
void Debounce::loop() {
|
||||
while (mRunning) {
|
||||
mWaitSignal.wait();
|
||||
if (!mRunning) {
|
||||
break;
|
||||
}
|
||||
|
||||
notifyIfReady();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void Debounce::notifyIfReady() {
|
||||
if (!mRunning) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we haven't seen an event in more than the maximum wait time, notify callbacks immediately
|
||||
// to ensure that we don't wait forever. Otherwise, wait for the minimum wait time and batch
|
||||
// subsequent fast changes. This also means the first file change in a batch is notified immediately,
|
||||
// separately from the rest of the batch. This seems like an acceptable tradeoff if the common case
|
||||
// is that only a single file was updated at a time.
|
||||
auto time = std::chrono::steady_clock::now();
|
||||
if ((time - mLastTime) > std::chrono::milliseconds(MAX_WAIT_TIME)) {
|
||||
mLastTime = time;
|
||||
notify();
|
||||
} else {
|
||||
wait();
|
||||
}
|
||||
}
|
||||
|
||||
void Debounce::wait() {
|
||||
#ifdef __wasm32__
|
||||
clear_timeout(mTimeout);
|
||||
mTimeout = set_timeout(MIN_WAIT_TIME, this);
|
||||
#else
|
||||
auto status = mWaitSignal.waitFor(std::chrono::milliseconds(MIN_WAIT_TIME));
|
||||
if (mRunning && (status == std::cv_status::timeout)) {
|
||||
notify();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Debounce::notify() {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
|
||||
mLastTime = std::chrono::steady_clock::now();
|
||||
for (auto it = mCallbacks.begin(); it != mCallbacks.end(); it++) {
|
||||
auto cb = it->second;
|
||||
cb();
|
||||
}
|
||||
|
||||
#ifndef __wasm32__
|
||||
mWaitSignal.reset();
|
||||
#endif
|
||||
}
|
||||
49
node_modules/@parcel/watcher/src/Debounce.hh
generated
vendored
Normal file
49
node_modules/@parcel/watcher/src/Debounce.hh
generated
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#ifndef DEBOUNCE_H
|
||||
#define DEBOUNCE_H
|
||||
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <functional>
|
||||
#include "Signal.hh"
|
||||
|
||||
#define MIN_WAIT_TIME 50
|
||||
#define MAX_WAIT_TIME 500
|
||||
|
||||
#ifdef __wasm32__
|
||||
extern "C" {
|
||||
int set_timeout(int ms, void *ctx);
|
||||
void clear_timeout(int timeout);
|
||||
void on_timeout(void *ctx);
|
||||
};
|
||||
#endif
|
||||
|
||||
class Debounce {
|
||||
public:
|
||||
static std::shared_ptr<Debounce> getShared();
|
||||
|
||||
Debounce();
|
||||
~Debounce();
|
||||
|
||||
void add(void *key, std::function<void()> cb);
|
||||
void remove(void *key);
|
||||
void trigger();
|
||||
void notify();
|
||||
|
||||
private:
|
||||
bool mRunning;
|
||||
std::mutex mMutex;
|
||||
#ifdef __wasm32__
|
||||
int mTimeout;
|
||||
#else
|
||||
Signal mWaitSignal;
|
||||
std::thread mThread;
|
||||
#endif
|
||||
std::unordered_map<void *, std::function<void()>> mCallbacks;
|
||||
std::chrono::time_point<std::chrono::steady_clock> mLastTime;
|
||||
|
||||
void loop();
|
||||
void notifyIfReady();
|
||||
void wait();
|
||||
};
|
||||
|
||||
#endif
|
||||
152
node_modules/@parcel/watcher/src/DirTree.cc
generated
vendored
Normal file
152
node_modules/@parcel/watcher/src/DirTree.cc
generated
vendored
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
#include "DirTree.hh"
|
||||
#include <inttypes.h>
|
||||
|
||||
static std::mutex mDirCacheMutex;
|
||||
static std::unordered_map<std::string, std::weak_ptr<DirTree>> dirTreeCache;
|
||||
|
||||
struct DirTreeDeleter {
|
||||
void operator()(DirTree *tree) {
|
||||
std::lock_guard<std::mutex> lock(mDirCacheMutex);
|
||||
dirTreeCache.erase(tree->root);
|
||||
delete tree;
|
||||
|
||||
// Free up memory.
|
||||
if (dirTreeCache.size() == 0) {
|
||||
dirTreeCache.rehash(0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
std::shared_ptr<DirTree> DirTree::getCached(std::string root) {
|
||||
std::lock_guard<std::mutex> lock(mDirCacheMutex);
|
||||
|
||||
auto found = dirTreeCache.find(root);
|
||||
std::shared_ptr<DirTree> tree;
|
||||
|
||||
// Use cached tree, or create an empty one.
|
||||
if (found != dirTreeCache.end()) {
|
||||
tree = found->second.lock();
|
||||
} else {
|
||||
tree = std::shared_ptr<DirTree>(new DirTree(root), DirTreeDeleter());
|
||||
dirTreeCache.emplace(root, tree);
|
||||
}
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
DirTree::DirTree(std::string root, FILE *f) : root(root), isComplete(true) {
|
||||
size_t size;
|
||||
if (fscanf(f, "%zu", &size)) {
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
DirEntry entry(f);
|
||||
entries.emplace(entry.path, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Internal find method that has no lock
|
||||
DirEntry *DirTree::_find(std::string path) {
|
||||
auto found = entries.find(path);
|
||||
if (found == entries.end()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &found->second;
|
||||
}
|
||||
|
||||
DirEntry *DirTree::add(std::string path, uint64_t mtime, bool isDir) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
|
||||
DirEntry entry(path, mtime, isDir);
|
||||
auto it = entries.emplace(entry.path, entry);
|
||||
return &it.first->second;
|
||||
}
|
||||
|
||||
DirEntry *DirTree::find(std::string path) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
return _find(path);
|
||||
}
|
||||
|
||||
DirEntry *DirTree::update(std::string path, uint64_t mtime) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
|
||||
DirEntry *found = _find(path);
|
||||
if (found) {
|
||||
found->mtime = mtime;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
void DirTree::remove(std::string path) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
|
||||
DirEntry *found = _find(path);
|
||||
|
||||
// Remove all sub-entries if this is a directory
|
||||
if (found && found->isDir) {
|
||||
std::string pathStart = path + DIR_SEP;
|
||||
for (auto it = entries.begin(); it != entries.end();) {
|
||||
if (it->first.rfind(pathStart, 0) == 0) {
|
||||
it = entries.erase(it);
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entries.erase(path);
|
||||
}
|
||||
|
||||
void DirTree::write(FILE *f) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
|
||||
fprintf(f, "%zu\n", entries.size());
|
||||
for (auto it = entries.begin(); it != entries.end(); it++) {
|
||||
it->second.write(f);
|
||||
}
|
||||
}
|
||||
|
||||
void DirTree::getChanges(DirTree *snapshot, EventList &events) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
std::lock_guard<std::mutex> snapshotLock(snapshot->mMutex);
|
||||
|
||||
for (auto it = entries.begin(); it != entries.end(); it++) {
|
||||
auto found = snapshot->entries.find(it->first);
|
||||
if (found == snapshot->entries.end()) {
|
||||
events.create(it->second.path);
|
||||
} else if (found->second.mtime != it->second.mtime && !found->second.isDir && !it->second.isDir) {
|
||||
events.update(it->second.path);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = snapshot->entries.begin(); it != snapshot->entries.end(); it++) {
|
||||
size_t count = entries.count(it->first);
|
||||
if (count == 0) {
|
||||
events.remove(it->second.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DirEntry::DirEntry(std::string p, uint64_t t, bool d) {
|
||||
path = p;
|
||||
mtime = t;
|
||||
isDir = d;
|
||||
state = NULL;
|
||||
}
|
||||
|
||||
DirEntry::DirEntry(FILE *f) {
|
||||
size_t size;
|
||||
if (fscanf(f, "%zu", &size)) {
|
||||
path.resize(size);
|
||||
if (fread(&path[0], sizeof(char), size, f)) {
|
||||
int d = 0;
|
||||
fscanf(f, "%" PRIu64 " %d\n", &mtime, &d);
|
||||
isDir = d == 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DirEntry::write(FILE *f) const {
|
||||
fprintf(f, "%zu%s%" PRIu64 " %d\n", path.size(), path.c_str(), mtime, isDir);
|
||||
}
|
||||
50
node_modules/@parcel/watcher/src/DirTree.hh
generated
vendored
Normal file
50
node_modules/@parcel/watcher/src/DirTree.hh
generated
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#ifndef DIR_TREE_H
|
||||
#define DIR_TREE_H
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include "Event.hh"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define DIR_SEP "\\"
|
||||
#else
|
||||
#define DIR_SEP "/"
|
||||
#endif
|
||||
|
||||
struct DirEntry {
|
||||
std::string path;
|
||||
uint64_t mtime;
|
||||
bool isDir;
|
||||
mutable void *state;
|
||||
|
||||
DirEntry(std::string p, uint64_t t, bool d);
|
||||
DirEntry(FILE *f);
|
||||
void write(FILE *f) const;
|
||||
bool operator==(const DirEntry &other) const {
|
||||
return path == other.path;
|
||||
}
|
||||
};
|
||||
|
||||
class DirTree {
|
||||
public:
|
||||
static std::shared_ptr<DirTree> getCached(std::string root);
|
||||
DirTree(std::string root) : root(root), isComplete(false) {}
|
||||
DirTree(std::string root, FILE *f);
|
||||
DirEntry *add(std::string path, uint64_t mtime, bool isDir);
|
||||
DirEntry *find(std::string path);
|
||||
DirEntry *update(std::string path, uint64_t mtime);
|
||||
void remove(std::string path);
|
||||
void write(FILE *f);
|
||||
void getChanges(DirTree *snapshot, EventList &events);
|
||||
|
||||
std::mutex mMutex;
|
||||
std::string root;
|
||||
bool isComplete;
|
||||
std::unordered_map<std::string, DirEntry> entries;
|
||||
|
||||
private:
|
||||
DirEntry *_find(std::string path);
|
||||
};
|
||||
|
||||
#endif
|
||||
109
node_modules/@parcel/watcher/src/Event.hh
generated
vendored
Normal file
109
node_modules/@parcel/watcher/src/Event.hh
generated
vendored
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
#ifndef EVENT_H
|
||||
#define EVENT_H
|
||||
|
||||
#include <string>
|
||||
#include <node_api.h>
|
||||
#include "wasm/include.h"
|
||||
#include <napi.h>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
|
||||
using namespace Napi;
|
||||
|
||||
struct Event {
|
||||
std::string path;
|
||||
bool isCreated;
|
||||
bool isDeleted;
|
||||
Event(std::string path) : path(path), isCreated(false), isDeleted(false) {}
|
||||
|
||||
Value toJS(const Env& env) {
|
||||
EscapableHandleScope scope(env);
|
||||
Object res = Object::New(env);
|
||||
std::string type = isCreated ? "create" : isDeleted ? "delete" : "update";
|
||||
res.Set(String::New(env, "path"), String::New(env, path.c_str()));
|
||||
res.Set(String::New(env, "type"), String::New(env, type.c_str()));
|
||||
return scope.Escape(res);
|
||||
}
|
||||
};
|
||||
|
||||
class EventList {
|
||||
public:
|
||||
void create(std::string path) {
|
||||
std::lock_guard<std::mutex> l(mMutex);
|
||||
Event *event = internalUpdate(path);
|
||||
if (event->isDeleted) {
|
||||
// Assume update event when rapidly removed and created
|
||||
// https://github.com/parcel-bundler/watcher/issues/72
|
||||
event->isDeleted = false;
|
||||
} else {
|
||||
event->isCreated = true;
|
||||
}
|
||||
}
|
||||
|
||||
Event *update(std::string path) {
|
||||
std::lock_guard<std::mutex> l(mMutex);
|
||||
return internalUpdate(path);
|
||||
}
|
||||
|
||||
void remove(std::string path) {
|
||||
std::lock_guard<std::mutex> l(mMutex);
|
||||
Event *event = internalUpdate(path);
|
||||
event->isDeleted = true;
|
||||
}
|
||||
|
||||
size_t size() {
|
||||
std::lock_guard<std::mutex> l(mMutex);
|
||||
return mEvents.size();
|
||||
}
|
||||
|
||||
std::vector<Event> getEvents() {
|
||||
std::lock_guard<std::mutex> l(mMutex);
|
||||
std::vector<Event> eventsCloneVector;
|
||||
for(auto it = mEvents.begin(); it != mEvents.end(); ++it) {
|
||||
if (!(it->second.isCreated && it->second.isDeleted)) {
|
||||
eventsCloneVector.push_back(it->second);
|
||||
}
|
||||
}
|
||||
return eventsCloneVector;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
std::lock_guard<std::mutex> l(mMutex);
|
||||
mEvents.clear();
|
||||
mError.reset();
|
||||
}
|
||||
|
||||
void error(std::string err) {
|
||||
std::lock_guard<std::mutex> l(mMutex);
|
||||
if (!mError.has_value()) {
|
||||
mError.emplace(err);
|
||||
}
|
||||
}
|
||||
|
||||
bool hasError() {
|
||||
std::lock_guard<std::mutex> l(mMutex);
|
||||
return mError.has_value();
|
||||
}
|
||||
|
||||
std::string getError() {
|
||||
std::lock_guard<std::mutex> l(mMutex);
|
||||
return mError.value_or("");
|
||||
}
|
||||
|
||||
private:
|
||||
mutable std::mutex mMutex;
|
||||
std::map<std::string, Event> mEvents;
|
||||
std::optional<std::string> mError;
|
||||
Event *internalUpdate(std::string path) {
|
||||
auto found = mEvents.find(path);
|
||||
if (found == mEvents.end()) {
|
||||
auto it = mEvents.emplace(path, Event(path));
|
||||
return &it.first->second;
|
||||
}
|
||||
|
||||
return &found->second;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
22
node_modules/@parcel/watcher/src/Glob.cc
generated
vendored
Normal file
22
node_modules/@parcel/watcher/src/Glob.cc
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include "Glob.hh"
|
||||
|
||||
#ifdef __wasm32__
|
||||
extern "C" bool wasm_regex_match(const char *s, const char *regex);
|
||||
#endif
|
||||
|
||||
Glob::Glob(std::string raw) {
|
||||
mRaw = raw;
|
||||
mHash = std::hash<std::string>()(raw);
|
||||
#ifndef __wasm32__
|
||||
mRegex = std::regex(raw);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Glob::isIgnored(std::string relative_path) const {
|
||||
// Use native JS regex engine for wasm to reduce binary size.
|
||||
#ifdef __wasm32__
|
||||
return wasm_regex_match(relative_path.c_str(), mRaw.c_str());
|
||||
#else
|
||||
return std::regex_match(relative_path, mRegex);
|
||||
#endif
|
||||
}
|
||||
34
node_modules/@parcel/watcher/src/Glob.hh
generated
vendored
Normal file
34
node_modules/@parcel/watcher/src/Glob.hh
generated
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef GLOB_H
|
||||
#define GLOB_H
|
||||
|
||||
#include <unordered_set>
|
||||
#include <regex>
|
||||
|
||||
struct Glob {
|
||||
std::size_t mHash;
|
||||
std::string mRaw;
|
||||
#ifndef __wasm32__
|
||||
std::regex mRegex;
|
||||
#endif
|
||||
|
||||
Glob(std::string raw);
|
||||
|
||||
bool operator==(const Glob &other) const {
|
||||
return mHash == other.mHash;
|
||||
}
|
||||
|
||||
bool isIgnored(std::string relative_path) const;
|
||||
};
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <>
|
||||
struct hash<Glob>
|
||||
{
|
||||
size_t operator()(const Glob& g) const {
|
||||
return g.mHash;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
101
node_modules/@parcel/watcher/src/PromiseRunner.hh
generated
vendored
Normal file
101
node_modules/@parcel/watcher/src/PromiseRunner.hh
generated
vendored
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
#ifndef PROMISE_RUNNER_H
|
||||
#define PROMISE_RUNNER_H
|
||||
|
||||
#include <node_api.h>
|
||||
#include "wasm/include.h"
|
||||
#include <napi.h>
|
||||
|
||||
using namespace Napi;
|
||||
|
||||
class PromiseRunner {
|
||||
public:
|
||||
const Env env;
|
||||
Promise::Deferred deferred;
|
||||
|
||||
PromiseRunner(Env env) : env(env), deferred(Promise::Deferred::New(env)) {
|
||||
napi_status status = napi_create_async_work(env, nullptr, env.Undefined(),
|
||||
onExecute, onWorkComplete, this, &work);
|
||||
if (status != napi_ok) {
|
||||
work = nullptr;
|
||||
const napi_extended_error_info *error_info = 0;
|
||||
napi_get_last_error_info(env, &error_info);
|
||||
if (error_info->error_message) {
|
||||
Error::New(env, error_info->error_message).ThrowAsJavaScriptException();
|
||||
} else {
|
||||
Error::New(env).ThrowAsJavaScriptException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~PromiseRunner() {}
|
||||
|
||||
Value queue() {
|
||||
if (work) {
|
||||
napi_status status = napi_queue_async_work(env, work);
|
||||
if (status != napi_ok) {
|
||||
onError(Error::New(env));
|
||||
}
|
||||
}
|
||||
|
||||
return deferred.Promise();
|
||||
}
|
||||
|
||||
private:
|
||||
napi_async_work work;
|
||||
std::string error;
|
||||
|
||||
static void onExecute(napi_env env, void *this_pointer) {
|
||||
PromiseRunner* self = (PromiseRunner*) this_pointer;
|
||||
try {
|
||||
self->execute();
|
||||
} catch (std::exception &err) {
|
||||
self->error = err.what();
|
||||
}
|
||||
}
|
||||
|
||||
static void onWorkComplete(napi_env env, napi_status status, void *this_pointer) {
|
||||
PromiseRunner* self = (PromiseRunner*) this_pointer;
|
||||
if (status != napi_cancelled) {
|
||||
HandleScope scope(self->env);
|
||||
if (status == napi_ok) {
|
||||
status = napi_delete_async_work(self->env, self->work);
|
||||
if (status == napi_ok) {
|
||||
if (self->error.size() == 0) {
|
||||
self->onOK();
|
||||
} else {
|
||||
self->onError(Error::New(self->env, self->error));
|
||||
}
|
||||
delete self;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fallthrough for error handling
|
||||
const napi_extended_error_info *error_info = 0;
|
||||
napi_get_last_error_info(env, &error_info);
|
||||
if (error_info->error_message){
|
||||
self->onError(Error::New(env, error_info->error_message));
|
||||
} else {
|
||||
self->onError(Error::New(env));
|
||||
}
|
||||
delete self;
|
||||
}
|
||||
|
||||
virtual void execute() {}
|
||||
virtual Value getResult() {
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
void onOK() {
|
||||
HandleScope scope(env);
|
||||
Value result = getResult();
|
||||
deferred.Resolve(result);
|
||||
}
|
||||
|
||||
void onError(const Error &e) {
|
||||
deferred.Reject(e.Value());
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
46
node_modules/@parcel/watcher/src/Signal.hh
generated
vendored
Normal file
46
node_modules/@parcel/watcher/src/Signal.hh
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef SIGNAL_H
|
||||
#define SIGNAL_H
|
||||
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
class Signal {
|
||||
public:
|
||||
Signal() : mFlag(false), mWaiting(false) {}
|
||||
void wait() {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
while (!mFlag) {
|
||||
mWaiting = true;
|
||||
mCond.wait(lock);
|
||||
}
|
||||
}
|
||||
|
||||
std::cv_status waitFor(std::chrono::milliseconds ms) {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
return mCond.wait_for(lock, ms);
|
||||
}
|
||||
|
||||
void notify() {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
mFlag = true;
|
||||
mCond.notify_all();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
mFlag = false;
|
||||
mWaiting = false;
|
||||
}
|
||||
|
||||
bool isWaiting() {
|
||||
return mWaiting;
|
||||
}
|
||||
|
||||
private:
|
||||
bool mFlag;
|
||||
bool mWaiting;
|
||||
std::mutex mMutex;
|
||||
std::condition_variable mCond;
|
||||
};
|
||||
|
||||
#endif
|
||||
237
node_modules/@parcel/watcher/src/Watcher.cc
generated
vendored
Normal file
237
node_modules/@parcel/watcher/src/Watcher.cc
generated
vendored
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
#include "Watcher.hh"
|
||||
#include <unordered_set>
|
||||
|
||||
using namespace Napi;
|
||||
|
||||
struct WatcherHash {
|
||||
std::size_t operator() (WatcherRef const &k) const {
|
||||
return std::hash<std::string>()(k->mDir);
|
||||
}
|
||||
};
|
||||
|
||||
struct WatcherCompare {
|
||||
size_t operator() (WatcherRef const &a, WatcherRef const &b) const {
|
||||
return *a == *b;
|
||||
}
|
||||
};
|
||||
|
||||
static std::unordered_set<WatcherRef , WatcherHash, WatcherCompare> sharedWatchers;
|
||||
|
||||
WatcherRef Watcher::getShared(std::string dir, std::unordered_set<std::string> ignorePaths, std::unordered_set<Glob> ignoreGlobs) {
|
||||
WatcherRef watcher = std::make_shared<Watcher>(dir, ignorePaths, ignoreGlobs);
|
||||
auto found = sharedWatchers.find(watcher);
|
||||
if (found != sharedWatchers.end()) {
|
||||
return *found;
|
||||
}
|
||||
|
||||
sharedWatchers.insert(watcher);
|
||||
return watcher;
|
||||
}
|
||||
|
||||
void removeShared(Watcher *watcher) {
|
||||
for (auto it = sharedWatchers.begin(); it != sharedWatchers.end(); it++) {
|
||||
if (it->get() == watcher) {
|
||||
sharedWatchers.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Free up memory.
|
||||
if (sharedWatchers.size() == 0) {
|
||||
sharedWatchers.rehash(0);
|
||||
}
|
||||
}
|
||||
|
||||
Watcher::Watcher(std::string dir, std::unordered_set<std::string> ignorePaths, std::unordered_set<Glob> ignoreGlobs)
|
||||
: mDir(dir),
|
||||
mIgnorePaths(ignorePaths),
|
||||
mIgnoreGlobs(ignoreGlobs) {
|
||||
mDebounce = Debounce::getShared();
|
||||
mDebounce->add(this, [this] () {
|
||||
triggerCallbacks();
|
||||
});
|
||||
}
|
||||
|
||||
Watcher::~Watcher() {
|
||||
mDebounce->remove(this);
|
||||
}
|
||||
|
||||
void Watcher::wait() {
|
||||
std::unique_lock<std::mutex> lk(mMutex);
|
||||
mCond.wait(lk);
|
||||
}
|
||||
|
||||
void Watcher::notify() {
|
||||
std::unique_lock<std::mutex> lk(mMutex);
|
||||
mCond.notify_all();
|
||||
|
||||
if (mCallbacks.size() > 0 && mEvents.size() > 0) {
|
||||
// We must release our lock before calling into the debouncer
|
||||
// to avoid a deadlock: the debouncer thread itself will require
|
||||
// our lock from its thread when calling into `triggerCallbacks`
|
||||
// while holding its own debouncer lock.
|
||||
lk.unlock();
|
||||
mDebounce->trigger();
|
||||
}
|
||||
}
|
||||
|
||||
struct CallbackData {
|
||||
std::string error;
|
||||
std::vector<Event> events;
|
||||
CallbackData(std::string error, std::vector<Event> events) : error(error), events(events) {}
|
||||
};
|
||||
|
||||
Value callbackEventsToJS(const Env &env, std::vector<Event> &events) {
|
||||
EscapableHandleScope scope(env);
|
||||
Array arr = Array::New(env, events.size());
|
||||
size_t currentEventIndex = 0;
|
||||
for (auto eventIterator = events.begin(); eventIterator != events.end(); eventIterator++) {
|
||||
arr.Set(currentEventIndex++, eventIterator->toJS(env));
|
||||
}
|
||||
return scope.Escape(arr);
|
||||
}
|
||||
|
||||
void callJSFunction(Napi::Env env, Function jsCallback, CallbackData *data) {
|
||||
HandleScope scope(env);
|
||||
auto err = data->error.size() > 0 ? Error::New(env, data->error).Value() : env.Null();
|
||||
auto events = callbackEventsToJS(env, data->events);
|
||||
jsCallback.Call({err, events});
|
||||
delete data;
|
||||
|
||||
// Throw errors from the callback as fatal exceptions
|
||||
// If we don't handle these node segfaults...
|
||||
if (env.IsExceptionPending()) {
|
||||
Napi::Error err = env.GetAndClearPendingException();
|
||||
napi_fatal_exception(env, err.Value());
|
||||
}
|
||||
}
|
||||
|
||||
void Watcher::notifyError(std::exception &err) {
|
||||
std::unique_lock<std::mutex> lk(mMutex);
|
||||
for (auto it = mCallbacks.begin(); it != mCallbacks.end(); it++) {
|
||||
CallbackData *data = new CallbackData(err.what(), {});
|
||||
it->tsfn.BlockingCall(data, callJSFunction);
|
||||
}
|
||||
|
||||
clearCallbacks();
|
||||
}
|
||||
|
||||
// This function is called from the debounce thread.
|
||||
void Watcher::triggerCallbacks() {
|
||||
std::unique_lock<std::mutex> lk(mMutex);
|
||||
if (mCallbacks.size() > 0 && (mEvents.size() > 0 || mEvents.hasError())) {
|
||||
auto error = mEvents.getError();
|
||||
auto events = mEvents.getEvents();
|
||||
mEvents.clear();
|
||||
|
||||
for (auto it = mCallbacks.begin(); it != mCallbacks.end(); it++) {
|
||||
it->tsfn.BlockingCall(new CallbackData(error, events), callJSFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This should be called from the JavaScript thread.
|
||||
bool Watcher::watch(Function callback) {
|
||||
std::unique_lock<std::mutex> lk(mMutex);
|
||||
|
||||
auto it = findCallback(callback);
|
||||
if (it != mCallbacks.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto tsfn = ThreadSafeFunction::New(
|
||||
callback.Env(),
|
||||
callback,
|
||||
"Watcher callback",
|
||||
0, // Unlimited queue
|
||||
1 // Initial thread count
|
||||
);
|
||||
|
||||
mCallbacks.push_back(Callback {
|
||||
tsfn,
|
||||
Napi::Persistent(callback),
|
||||
std::this_thread::get_id()
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// This should be called from the JavaScript thread.
|
||||
std::vector<Callback>::iterator Watcher::findCallback(Function callback) {
|
||||
for (auto it = mCallbacks.begin(); it != mCallbacks.end(); it++) {
|
||||
// Only consider callbacks created by the same thread, or V8 will panic.
|
||||
if (it->threadId == std::this_thread::get_id() && it->ref.Value() == callback) {
|
||||
return it;
|
||||
}
|
||||
}
|
||||
|
||||
return mCallbacks.end();
|
||||
}
|
||||
|
||||
// This should be called from the JavaScript thread.
|
||||
bool Watcher::unwatch(Function callback) {
|
||||
std::unique_lock<std::mutex> lk(mMutex);
|
||||
|
||||
bool removed = false;
|
||||
auto it = findCallback(callback);
|
||||
if (it != mCallbacks.end()) {
|
||||
it->tsfn.Release();
|
||||
it->ref.Unref();
|
||||
mCallbacks.erase(it);
|
||||
removed = true;
|
||||
}
|
||||
|
||||
if (removed && mCallbacks.size() == 0) {
|
||||
unref();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Watcher::unref() {
|
||||
if (mCallbacks.size() == 0) {
|
||||
removeShared(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Watcher::destroy() {
|
||||
std::unique_lock<std::mutex> lk(mMutex);
|
||||
clearCallbacks();
|
||||
}
|
||||
|
||||
// Private because it doesn't lock.
|
||||
void Watcher::clearCallbacks() {
|
||||
for (auto it = mCallbacks.begin(); it != mCallbacks.end(); it++) {
|
||||
it->tsfn.Release();
|
||||
it->ref.Unref();
|
||||
}
|
||||
|
||||
mCallbacks.clear();
|
||||
unref();
|
||||
}
|
||||
|
||||
bool Watcher::isIgnored(std::string path) {
|
||||
for (auto it = mIgnorePaths.begin(); it != mIgnorePaths.end(); it++) {
|
||||
auto dir = *it + DIR_SEP;
|
||||
if (*it == path || path.compare(0, dir.size(), dir) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
auto basePath = mDir + DIR_SEP;
|
||||
|
||||
if (path.rfind(basePath, 0) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto relativePath = path.substr(basePath.size());
|
||||
|
||||
for (auto it = mIgnoreGlobs.begin(); it != mIgnoreGlobs.end(); it++) {
|
||||
if (it->isIgnored(relativePath)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
73
node_modules/@parcel/watcher/src/Watcher.hh
generated
vendored
Normal file
73
node_modules/@parcel/watcher/src/Watcher.hh
generated
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
#ifndef WATCHER_H
|
||||
#define WATCHER_H
|
||||
|
||||
#include <condition_variable>
|
||||
#include <unordered_set>
|
||||
#include <set>
|
||||
#include <node_api.h>
|
||||
#include "Glob.hh"
|
||||
#include "Event.hh"
|
||||
#include "Debounce.hh"
|
||||
#include "DirTree.hh"
|
||||
#include "Signal.hh"
|
||||
|
||||
using namespace Napi;
|
||||
|
||||
struct Watcher;
|
||||
using WatcherRef = std::shared_ptr<Watcher>;
|
||||
|
||||
struct Callback {
|
||||
Napi::ThreadSafeFunction tsfn;
|
||||
Napi::FunctionReference ref;
|
||||
std::thread::id threadId;
|
||||
};
|
||||
|
||||
class WatcherState {
|
||||
public:
|
||||
virtual ~WatcherState() = default;
|
||||
};
|
||||
|
||||
struct Watcher {
|
||||
std::string mDir;
|
||||
std::unordered_set<std::string> mIgnorePaths;
|
||||
std::unordered_set<Glob> mIgnoreGlobs;
|
||||
EventList mEvents;
|
||||
std::shared_ptr<WatcherState> state;
|
||||
|
||||
Watcher(std::string dir, std::unordered_set<std::string> ignorePaths, std::unordered_set<Glob> ignoreGlobs);
|
||||
~Watcher();
|
||||
|
||||
bool operator==(const Watcher &other) const {
|
||||
return mDir == other.mDir && mIgnorePaths == other.mIgnorePaths && mIgnoreGlobs == other.mIgnoreGlobs;
|
||||
}
|
||||
|
||||
void wait();
|
||||
void notify();
|
||||
void notifyError(std::exception &err);
|
||||
bool watch(Function callback);
|
||||
bool unwatch(Function callback);
|
||||
void unref();
|
||||
bool isIgnored(std::string path);
|
||||
void destroy();
|
||||
|
||||
static WatcherRef getShared(std::string dir, std::unordered_set<std::string> ignorePaths, std::unordered_set<Glob> ignoreGlobs);
|
||||
|
||||
private:
|
||||
std::mutex mMutex;
|
||||
std::condition_variable mCond;
|
||||
std::vector<Callback> mCallbacks;
|
||||
std::shared_ptr<Debounce> mDebounce;
|
||||
|
||||
std::vector<Callback>::iterator findCallback(Function callback);
|
||||
void clearCallbacks();
|
||||
void triggerCallbacks();
|
||||
};
|
||||
|
||||
class WatcherError : public std::runtime_error {
|
||||
public:
|
||||
WatcherRef mWatcher;
|
||||
WatcherError(std::string msg, WatcherRef watcher) : std::runtime_error(msg), mWatcher(watcher) {}
|
||||
WatcherError(const char *msg, WatcherRef watcher) : std::runtime_error(msg), mWatcher(watcher) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
268
node_modules/@parcel/watcher/src/binding.cc
generated
vendored
Normal file
268
node_modules/@parcel/watcher/src/binding.cc
generated
vendored
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
#include <unordered_set>
|
||||
#include <node_api.h>
|
||||
#include "wasm/include.h"
|
||||
#include <napi.h>
|
||||
#include "Glob.hh"
|
||||
#include "Event.hh"
|
||||
#include "Backend.hh"
|
||||
#include "Watcher.hh"
|
||||
#include "PromiseRunner.hh"
|
||||
|
||||
using namespace Napi;
|
||||
|
||||
std::unordered_set<std::string> getIgnorePaths(Env env, Value opts) {
|
||||
std::unordered_set<std::string> result;
|
||||
|
||||
if (opts.IsObject()) {
|
||||
Value v = opts.As<Object>().Get(String::New(env, "ignorePaths"));
|
||||
if (v.IsArray()) {
|
||||
Array items = v.As<Array>();
|
||||
for (size_t i = 0; i < items.Length(); i++) {
|
||||
Value item = items.Get(Number::New(env, i));
|
||||
if (item.IsString()) {
|
||||
result.insert(std::string(item.As<String>().Utf8Value().c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::unordered_set<Glob> getIgnoreGlobs(Env env, Value opts) {
|
||||
std::unordered_set<Glob> result;
|
||||
|
||||
if (opts.IsObject()) {
|
||||
Value v = opts.As<Object>().Get(String::New(env, "ignoreGlobs"));
|
||||
if (v.IsArray()) {
|
||||
Array items = v.As<Array>();
|
||||
for (size_t i = 0; i < items.Length(); i++) {
|
||||
Value item = items.Get(Number::New(env, i));
|
||||
if (item.IsString()) {
|
||||
auto key = item.As<String>().Utf8Value();
|
||||
try {
|
||||
result.emplace(key);
|
||||
} catch (const std::regex_error& e) {
|
||||
Error::New(env, e.what()).ThrowAsJavaScriptException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::shared_ptr<Backend> getBackend(Env env, Value opts) {
|
||||
Value b = opts.As<Object>().Get(String::New(env, "backend"));
|
||||
std::string backendName;
|
||||
if (b.IsString()) {
|
||||
backendName = std::string(b.As<String>().Utf8Value().c_str());
|
||||
}
|
||||
|
||||
return Backend::getShared(backendName);
|
||||
}
|
||||
|
||||
class WriteSnapshotRunner : public PromiseRunner {
|
||||
public:
|
||||
WriteSnapshotRunner(Env env, Value dir, Value snap, Value opts)
|
||||
: PromiseRunner(env),
|
||||
snapshotPath(std::string(snap.As<String>().Utf8Value().c_str())) {
|
||||
watcher = Watcher::getShared(
|
||||
std::string(dir.As<String>().Utf8Value().c_str()),
|
||||
getIgnorePaths(env, opts),
|
||||
getIgnoreGlobs(env, opts)
|
||||
);
|
||||
|
||||
backend = getBackend(env, opts);
|
||||
}
|
||||
|
||||
~WriteSnapshotRunner() {
|
||||
watcher->unref();
|
||||
backend->unref();
|
||||
}
|
||||
private:
|
||||
std::shared_ptr<Backend> backend;
|
||||
WatcherRef watcher;
|
||||
std::string snapshotPath;
|
||||
|
||||
void execute() override {
|
||||
backend->writeSnapshot(watcher, &snapshotPath);
|
||||
}
|
||||
};
|
||||
|
||||
class GetEventsSinceRunner : public PromiseRunner {
|
||||
public:
|
||||
GetEventsSinceRunner(Env env, Value dir, Value snap, Value opts)
|
||||
: PromiseRunner(env),
|
||||
snapshotPath(std::string(snap.As<String>().Utf8Value().c_str())) {
|
||||
watcher = std::make_shared<Watcher>(
|
||||
std::string(dir.As<String>().Utf8Value().c_str()),
|
||||
getIgnorePaths(env, opts),
|
||||
getIgnoreGlobs(env, opts)
|
||||
);
|
||||
|
||||
backend = getBackend(env, opts);
|
||||
}
|
||||
|
||||
~GetEventsSinceRunner() {
|
||||
watcher->unref();
|
||||
backend->unref();
|
||||
}
|
||||
private:
|
||||
std::shared_ptr<Backend> backend;
|
||||
WatcherRef watcher;
|
||||
std::string snapshotPath;
|
||||
|
||||
void execute() override {
|
||||
backend->getEventsSince(watcher, &snapshotPath);
|
||||
if (watcher->mEvents.hasError()) {
|
||||
throw std::runtime_error(watcher->mEvents.getError());
|
||||
}
|
||||
}
|
||||
|
||||
Value getResult() override {
|
||||
std::vector<Event> events = watcher->mEvents.getEvents();
|
||||
Array eventsArray = Array::New(env, events.size());
|
||||
size_t i = 0;
|
||||
for (auto it = events.begin(); it != events.end(); it++) {
|
||||
eventsArray.Set(i++, it->toJS(env));
|
||||
}
|
||||
return eventsArray;
|
||||
}
|
||||
};
|
||||
|
||||
template<class Runner>
|
||||
Value queueSnapshotWork(const CallbackInfo& info) {
|
||||
Env env = info.Env();
|
||||
if (info.Length() < 1 || !info[0].IsString()) {
|
||||
TypeError::New(env, "Expected a string").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
if (info.Length() < 2 || !info[1].IsString()) {
|
||||
TypeError::New(env, "Expected a string").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
if (info.Length() >= 3 && !info[2].IsObject()) {
|
||||
TypeError::New(env, "Expected an object").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Runner *runner = new Runner(info.Env(), info[0], info[1], info[2]);
|
||||
return runner->queue();
|
||||
}
|
||||
|
||||
Value writeSnapshot(const CallbackInfo& info) {
|
||||
return queueSnapshotWork<WriteSnapshotRunner>(info);
|
||||
}
|
||||
|
||||
Value getEventsSince(const CallbackInfo& info) {
|
||||
return queueSnapshotWork<GetEventsSinceRunner>(info);
|
||||
}
|
||||
|
||||
class SubscribeRunner : public PromiseRunner {
|
||||
public:
|
||||
SubscribeRunner(Env env, Value dir, Value fn, Value opts) : PromiseRunner(env) {
|
||||
watcher = Watcher::getShared(
|
||||
std::string(dir.As<String>().Utf8Value().c_str()),
|
||||
getIgnorePaths(env, opts),
|
||||
getIgnoreGlobs(env, opts)
|
||||
);
|
||||
|
||||
backend = getBackend(env, opts);
|
||||
watcher->watch(fn.As<Function>());
|
||||
}
|
||||
|
||||
private:
|
||||
WatcherRef watcher;
|
||||
std::shared_ptr<Backend> backend;
|
||||
FunctionReference callback;
|
||||
|
||||
void execute() override {
|
||||
try {
|
||||
backend->watch(watcher);
|
||||
} catch (std::exception &err) {
|
||||
watcher->destroy();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class UnsubscribeRunner : public PromiseRunner {
|
||||
public:
|
||||
UnsubscribeRunner(Env env, Value dir, Value fn, Value opts) : PromiseRunner(env) {
|
||||
watcher = Watcher::getShared(
|
||||
std::string(dir.As<String>().Utf8Value().c_str()),
|
||||
getIgnorePaths(env, opts),
|
||||
getIgnoreGlobs(env, opts)
|
||||
);
|
||||
|
||||
backend = getBackend(env, opts);
|
||||
shouldUnwatch = watcher->unwatch(fn.As<Function>());
|
||||
}
|
||||
|
||||
private:
|
||||
WatcherRef watcher;
|
||||
std::shared_ptr<Backend> backend;
|
||||
bool shouldUnwatch;
|
||||
|
||||
void execute() override {
|
||||
if (shouldUnwatch) {
|
||||
backend->unwatch(watcher);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class Runner>
|
||||
Value queueSubscriptionWork(const CallbackInfo& info) {
|
||||
Env env = info.Env();
|
||||
if (info.Length() < 1 || !info[0].IsString()) {
|
||||
TypeError::New(env, "Expected a string").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
if (info.Length() < 2 || !info[1].IsFunction()) {
|
||||
TypeError::New(env, "Expected a function").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
if (info.Length() >= 3 && !info[2].IsObject()) {
|
||||
TypeError::New(env, "Expected an object").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Runner *runner = new Runner(info.Env(), info[0], info[1], info[2]);
|
||||
return runner->queue();
|
||||
}
|
||||
|
||||
Value subscribe(const CallbackInfo& info) {
|
||||
return queueSubscriptionWork<SubscribeRunner>(info);
|
||||
}
|
||||
|
||||
Value unsubscribe(const CallbackInfo& info) {
|
||||
return queueSubscriptionWork<UnsubscribeRunner>(info);
|
||||
}
|
||||
|
||||
Object Init(Env env, Object exports) {
|
||||
exports.Set(
|
||||
String::New(env, "writeSnapshot"),
|
||||
Function::New(env, writeSnapshot)
|
||||
);
|
||||
exports.Set(
|
||||
String::New(env, "getEventsSince"),
|
||||
Function::New(env, getEventsSince)
|
||||
);
|
||||
exports.Set(
|
||||
String::New(env, "subscribe"),
|
||||
Function::New(env, subscribe)
|
||||
);
|
||||
exports.Set(
|
||||
String::New(env, "unsubscribe"),
|
||||
Function::New(env, unsubscribe)
|
||||
);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NODE_API_MODULE(watcher, Init)
|
||||
306
node_modules/@parcel/watcher/src/kqueue/KqueueBackend.cc
generated
vendored
Normal file
306
node_modules/@parcel/watcher/src/kqueue/KqueueBackend.cc
generated
vendored
Normal file
|
|
@ -0,0 +1,306 @@
|
|||
#include <memory>
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
#include <libgen.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include "KqueueBackend.hh"
|
||||
|
||||
#if __APPLE__
|
||||
#define st_mtim st_mtimespec
|
||||
#endif
|
||||
|
||||
#if !defined(O_EVTONLY)
|
||||
#define O_EVTONLY O_RDONLY
|
||||
#endif
|
||||
|
||||
#define CONVERT_TIME(ts) ((uint64_t)ts.tv_sec * 1000000000 + ts.tv_nsec)
|
||||
|
||||
void KqueueBackend::start() {
|
||||
if ((mKqueue = kqueue()) < 0) {
|
||||
throw std::runtime_error(std::string("Unable to open kqueue: ") + strerror(errno));
|
||||
}
|
||||
|
||||
// Create a pipe that we will write to when we want to end the thread.
|
||||
int err = pipe(mPipe);
|
||||
if (err == -1) {
|
||||
throw std::runtime_error(std::string("Unable to open pipe: ") + strerror(errno));
|
||||
}
|
||||
|
||||
// Subscribe kqueue to this pipe.
|
||||
struct kevent ev;
|
||||
EV_SET(
|
||||
&ev,
|
||||
mPipe[0],
|
||||
EVFILT_READ,
|
||||
EV_ADD | EV_CLEAR,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
if (kevent(mKqueue, &ev, 1, NULL, 0, 0)) {
|
||||
close(mPipe[0]);
|
||||
close(mPipe[1]);
|
||||
throw std::runtime_error(std::string("Unable to watch pipe: ") + strerror(errno));
|
||||
}
|
||||
|
||||
notifyStarted();
|
||||
|
||||
struct kevent events[128];
|
||||
|
||||
while (true) {
|
||||
int event_count = kevent(mKqueue, NULL, 0, events, 128, 0);
|
||||
if (event_count < 0 || events[0].flags == EV_ERROR) {
|
||||
throw std::runtime_error(std::string("kevent error: ") + strerror(errno));
|
||||
}
|
||||
|
||||
// Track all of the watchers that are touched so we can notify them at the end of the events.
|
||||
std::unordered_set<WatcherRef> watchers;
|
||||
|
||||
for (int i = 0; i < event_count; i++) {
|
||||
int flags = events[i].fflags;
|
||||
int fd = events[i].ident;
|
||||
if (fd == mPipe[0]) {
|
||||
// pipe was written to. break out of the loop.
|
||||
goto done;
|
||||
}
|
||||
|
||||
auto it = mFdToEntry.find(fd);
|
||||
if (it == mFdToEntry.end()) {
|
||||
// If fd wasn't in our map, we may have already stopped watching it. Ignore the event.
|
||||
continue;
|
||||
}
|
||||
|
||||
DirEntry *entry = it->second;
|
||||
|
||||
if (flags & NOTE_WRITE && entry && entry->isDir) {
|
||||
// If a write occurred on a directory, we have to diff the contents of that
|
||||
// directory to determine what file was added/deleted.
|
||||
compareDir(fd, entry->path, watchers);
|
||||
} else {
|
||||
std::vector<KqueueSubscription *> subs = findSubscriptions(entry->path);
|
||||
for (auto it = subs.begin(); it != subs.end(); it++) {
|
||||
KqueueSubscription *sub = *it;
|
||||
watchers.insert(sub->watcher);
|
||||
if (flags & (NOTE_DELETE | NOTE_RENAME | NOTE_REVOKE)) {
|
||||
sub->watcher->mEvents.remove(sub->path);
|
||||
sub->tree->remove(sub->path);
|
||||
mFdToEntry.erase((int)(size_t)entry->state);
|
||||
mSubscriptions.erase(sub->path);
|
||||
} else if (flags & (NOTE_WRITE | NOTE_ATTRIB | NOTE_EXTEND)) {
|
||||
struct stat st;
|
||||
lstat(sub->path.c_str(), &st);
|
||||
if (entry->mtime != CONVERT_TIME(st.st_mtim)) {
|
||||
entry->mtime = CONVERT_TIME(st.st_mtim);
|
||||
sub->watcher->mEvents.update(sub->path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = watchers.begin(); it != watchers.end(); it++) {
|
||||
(*it)->notify();
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
close(mPipe[0]);
|
||||
close(mPipe[1]);
|
||||
mEndedSignal.notify();
|
||||
}
|
||||
|
||||
KqueueBackend::~KqueueBackend() {
|
||||
write(mPipe[1], "X", 1);
|
||||
mEndedSignal.wait();
|
||||
}
|
||||
|
||||
void KqueueBackend::subscribe(WatcherRef watcher) {
|
||||
// Build a full directory tree recursively, and watch each directory.
|
||||
std::shared_ptr<DirTree> tree = getTree(watcher);
|
||||
|
||||
for (auto it = tree->entries.begin(); it != tree->entries.end(); it++) {
|
||||
bool success = watchDir(watcher, it->second.path, tree);
|
||||
if (!success) {
|
||||
throw WatcherError(std::string("error watching " + watcher->mDir + ": " + strerror(errno)), watcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool KqueueBackend::watchDir(WatcherRef watcher, std::string path, std::shared_ptr<DirTree> tree) {
|
||||
if (watcher->isIgnored(path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DirEntry *entry = tree->find(path);
|
||||
if (!entry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
KqueueSubscription sub = {
|
||||
.watcher = watcher,
|
||||
.path = path,
|
||||
.tree = tree
|
||||
};
|
||||
|
||||
if (!entry->state) {
|
||||
int fd = open(path.c_str(), O_EVTONLY);
|
||||
if (fd <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct kevent event;
|
||||
EV_SET(
|
||||
&event,
|
||||
fd,
|
||||
EVFILT_VNODE,
|
||||
EV_ADD | EV_CLEAR | EV_ENABLE,
|
||||
NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | NOTE_RENAME | NOTE_REVOKE,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
if (kevent(mKqueue, &event, 1, NULL, 0, 0)) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
entry->state = (void *)(size_t)fd;
|
||||
mFdToEntry.emplace(fd, entry);
|
||||
}
|
||||
|
||||
sub.fd = (int)(size_t)entry->state;
|
||||
mSubscriptions.emplace(path, sub);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<KqueueSubscription *> KqueueBackend::findSubscriptions(std::string &path) {
|
||||
// Find the subscriptions affected by this path.
|
||||
// Copy pointers to them into a vector so that modifying mSubscriptions doesn't invalidate the iterator.
|
||||
auto range = mSubscriptions.equal_range(path);
|
||||
std::vector<KqueueSubscription *> subs;
|
||||
for (auto it = range.first; it != range.second; it++) {
|
||||
subs.push_back(&it->second);
|
||||
}
|
||||
|
||||
return subs;
|
||||
}
|
||||
|
||||
bool KqueueBackend::compareDir(int fd, std::string &path, std::unordered_set<WatcherRef> &watchers) {
|
||||
// macOS doesn't support fdclosedir, so we have to duplicate the file descriptor
|
||||
// to ensure the closedir doesn't also stop watching.
|
||||
#if __APPLE__
|
||||
fd = dup(fd);
|
||||
#endif
|
||||
|
||||
DIR *dir = fdopendir(fd);
|
||||
if (dir == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// fdopendir doesn't rewind to the beginning.
|
||||
rewinddir(dir);
|
||||
|
||||
std::vector<KqueueSubscription *> subs = findSubscriptions(path);
|
||||
std::string dirStart = path + DIR_SEP;
|
||||
|
||||
std::unordered_set<std::shared_ptr<DirTree>> trees;
|
||||
for (auto it = subs.begin(); it != subs.end(); it++) {
|
||||
trees.emplace((*it)->tree);
|
||||
}
|
||||
|
||||
std::unordered_set<std::string> entries;
|
||||
struct dirent *entry;
|
||||
while ((entry = readdir(dir))) {
|
||||
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string fullpath = dirStart + entry->d_name;
|
||||
entries.emplace(fullpath);
|
||||
|
||||
for (auto it = trees.begin(); it != trees.end(); it++) {
|
||||
std::shared_ptr<DirTree> tree = *it;
|
||||
if (!tree->find(fullpath)) {
|
||||
struct stat st;
|
||||
fstatat(fd, entry->d_name, &st, AT_SYMLINK_NOFOLLOW);
|
||||
tree->add(fullpath, CONVERT_TIME(st.st_mtim), S_ISDIR(st.st_mode));
|
||||
|
||||
// Notify all watchers with the same tree.
|
||||
for (auto i = subs.begin(); i != subs.end(); i++) {
|
||||
KqueueSubscription *sub = *i;
|
||||
if (sub->tree == tree) {
|
||||
if (sub->watcher->isIgnored(fullpath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sub->watcher->mEvents.create(fullpath);
|
||||
watchers.emplace(sub->watcher);
|
||||
|
||||
bool success = watchDir(sub->watcher, fullpath, sub->tree);
|
||||
if (!success) {
|
||||
sub->tree->remove(fullpath);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = trees.begin(); it != trees.end(); it++) {
|
||||
std::shared_ptr<DirTree> tree = *it;
|
||||
for (auto entry = tree->entries.begin(); entry != tree->entries.end();) {
|
||||
|
||||
if (
|
||||
entry->first.rfind(dirStart, 0) == 0 &&
|
||||
entry->first.find(DIR_SEP, dirStart.length()) == std::string::npos &&
|
||||
entries.count(entry->first) == 0
|
||||
) {
|
||||
// Notify all watchers with the same tree.
|
||||
for (auto i = subs.begin(); i != subs.end(); i++) {
|
||||
if ((*i)->tree == tree) {
|
||||
KqueueSubscription *sub = *i;
|
||||
if (!sub->watcher->isIgnored(entry->first)) {
|
||||
sub->watcher->mEvents.remove(entry->first);
|
||||
watchers.emplace(sub->watcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mFdToEntry.erase((int)(size_t)entry->second.state);
|
||||
mSubscriptions.erase(entry->first);
|
||||
entry = tree->entries.erase(entry);
|
||||
} else {
|
||||
entry++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if __APPLE__
|
||||
closedir(dir);
|
||||
#else
|
||||
fdclosedir(dir);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void KqueueBackend::unsubscribe(WatcherRef watcher) {
|
||||
// Find any subscriptions pointing to this watcher, and remove them.
|
||||
for (auto it = mSubscriptions.begin(); it != mSubscriptions.end();) {
|
||||
if (it->second.watcher.get() == watcher.get()) {
|
||||
if (mSubscriptions.count(it->first) == 1) {
|
||||
// Closing the file descriptor automatically unwatches it in the kqueue.
|
||||
close(it->second.fd);
|
||||
mFdToEntry.erase(it->second.fd);
|
||||
}
|
||||
|
||||
it = mSubscriptions.erase(it);
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
35
node_modules/@parcel/watcher/src/kqueue/KqueueBackend.hh
generated
vendored
Normal file
35
node_modules/@parcel/watcher/src/kqueue/KqueueBackend.hh
generated
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#ifndef KQUEUE_H
|
||||
#define KQUEUE_H
|
||||
|
||||
#include <unordered_map>
|
||||
#include <sys/event.h>
|
||||
#include "../shared/BruteForceBackend.hh"
|
||||
#include "../DirTree.hh"
|
||||
#include "../Signal.hh"
|
||||
|
||||
struct KqueueSubscription {
|
||||
WatcherRef watcher;
|
||||
std::string path;
|
||||
std::shared_ptr<DirTree> tree;
|
||||
int fd;
|
||||
};
|
||||
|
||||
class KqueueBackend : public BruteForceBackend {
|
||||
public:
|
||||
void start() override;
|
||||
~KqueueBackend();
|
||||
void subscribe(WatcherRef watcher) override;
|
||||
void unsubscribe(WatcherRef watcher) override;
|
||||
private:
|
||||
int mKqueue;
|
||||
int mPipe[2];
|
||||
std::unordered_multimap<std::string, KqueueSubscription> mSubscriptions;
|
||||
std::unordered_map<int, DirEntry *> mFdToEntry;
|
||||
Signal mEndedSignal;
|
||||
|
||||
bool watchDir(WatcherRef watcher, std::string path, std::shared_ptr<DirTree> tree);
|
||||
bool compareDir(int fd, std::string &dir, std::unordered_set<WatcherRef> &watchers);
|
||||
std::vector<KqueueSubscription *> findSubscriptions(std::string &path);
|
||||
};
|
||||
|
||||
#endif
|
||||
232
node_modules/@parcel/watcher/src/linux/InotifyBackend.cc
generated
vendored
Normal file
232
node_modules/@parcel/watcher/src/linux/InotifyBackend.cc
generated
vendored
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
#include <memory>
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include "InotifyBackend.hh"
|
||||
|
||||
#define INOTIFY_MASK \
|
||||
IN_ATTRIB | IN_CREATE | IN_DELETE | \
|
||||
IN_DELETE_SELF | IN_MODIFY | IN_MOVE_SELF | IN_MOVED_FROM | \
|
||||
IN_MOVED_TO | IN_DONT_FOLLOW | IN_ONLYDIR | IN_EXCL_UNLINK
|
||||
#define BUFFER_SIZE 8192
|
||||
#define CONVERT_TIME(ts) ((uint64_t)ts.tv_sec * 1000000000 + ts.tv_nsec)
|
||||
|
||||
void InotifyBackend::start() {
|
||||
// Create a pipe that we will write to when we want to end the thread.
|
||||
int err = pipe2(mPipe, O_CLOEXEC | O_NONBLOCK);
|
||||
if (err == -1) {
|
||||
throw std::runtime_error(std::string("Unable to open pipe: ") + strerror(errno));
|
||||
}
|
||||
|
||||
// Init inotify file descriptor.
|
||||
mInotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
|
||||
if (mInotify == -1) {
|
||||
throw std::runtime_error(std::string("Unable to initialize inotify: ") + strerror(errno));
|
||||
}
|
||||
|
||||
pollfd pollfds[2];
|
||||
pollfds[0].fd = mPipe[0];
|
||||
pollfds[0].events = POLLIN;
|
||||
pollfds[0].revents = 0;
|
||||
pollfds[1].fd = mInotify;
|
||||
pollfds[1].events = POLLIN;
|
||||
pollfds[1].revents = 0;
|
||||
|
||||
notifyStarted();
|
||||
|
||||
// Loop until we get an event from the pipe.
|
||||
while (true) {
|
||||
int result = poll(pollfds, 2, 500);
|
||||
if (result < 0) {
|
||||
throw std::runtime_error(std::string("Unable to poll: ") + strerror(errno));
|
||||
}
|
||||
|
||||
if (pollfds[0].revents) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (pollfds[1].revents) {
|
||||
handleEvents();
|
||||
}
|
||||
}
|
||||
|
||||
close(mPipe[0]);
|
||||
close(mPipe[1]);
|
||||
close(mInotify);
|
||||
|
||||
mEndedSignal.notify();
|
||||
}
|
||||
|
||||
InotifyBackend::~InotifyBackend() {
|
||||
write(mPipe[1], "X", 1);
|
||||
mEndedSignal.wait();
|
||||
}
|
||||
|
||||
// This function is called by Backend::watch which takes a lock on mMutex
|
||||
void InotifyBackend::subscribe(WatcherRef watcher) {
|
||||
// Build a full directory tree recursively, and watch each directory.
|
||||
std::shared_ptr<DirTree> tree = getTree(watcher);
|
||||
|
||||
for (auto it = tree->entries.begin(); it != tree->entries.end(); it++) {
|
||||
if (it->second.isDir) {
|
||||
bool success = watchDir(watcher, it->second.path, tree);
|
||||
if (!success) {
|
||||
throw WatcherError(std::string("inotify_add_watch on '") + it->second.path + std::string("' failed: ") + strerror(errno), watcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool InotifyBackend::watchDir(WatcherRef watcher, std::string path, std::shared_ptr<DirTree> tree) {
|
||||
int wd = inotify_add_watch(mInotify, path.c_str(), INOTIFY_MASK);
|
||||
if (wd == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<InotifySubscription> sub = std::make_shared<InotifySubscription>();
|
||||
sub->tree = tree;
|
||||
sub->path = path;
|
||||
sub->watcher = watcher;
|
||||
mSubscriptions.emplace(wd, sub);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InotifyBackend::handleEvents() {
|
||||
char buf[BUFFER_SIZE] __attribute__ ((aligned(__alignof__(struct inotify_event))));;
|
||||
struct inotify_event *event;
|
||||
|
||||
// Track all of the watchers that are touched so we can notify them at the end of the events.
|
||||
std::unordered_set<WatcherRef> watchers;
|
||||
|
||||
while (true) {
|
||||
int n = read(mInotify, &buf, BUFFER_SIZE);
|
||||
if (n < 0) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
break;
|
||||
}
|
||||
|
||||
throw std::runtime_error(std::string("Error reading from inotify: ") + strerror(errno));
|
||||
}
|
||||
|
||||
if (n == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
for (char *ptr = buf; ptr < buf + n; ptr += sizeof(*event) + event->len) {
|
||||
event = (struct inotify_event *)ptr;
|
||||
|
||||
if ((event->mask & IN_Q_OVERFLOW) == IN_Q_OVERFLOW) {
|
||||
// overflow
|
||||
continue;
|
||||
}
|
||||
|
||||
handleEvent(event, watchers);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = watchers.begin(); it != watchers.end(); it++) {
|
||||
(*it)->notify();
|
||||
}
|
||||
}
|
||||
|
||||
void InotifyBackend::handleEvent(struct inotify_event *event, std::unordered_set<WatcherRef> &watchers) {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
|
||||
// Find the subscriptions for this watch descriptor
|
||||
auto range = mSubscriptions.equal_range(event->wd);
|
||||
std::unordered_set<std::shared_ptr<InotifySubscription>> set;
|
||||
for (auto it = range.first; it != range.second; it++) {
|
||||
set.insert(it->second);
|
||||
}
|
||||
|
||||
for (auto it = set.begin(); it != set.end(); it++) {
|
||||
if (handleSubscription(event, *it)) {
|
||||
watchers.insert((*it)->watcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool InotifyBackend::handleSubscription(struct inotify_event *event, std::shared_ptr<InotifySubscription> sub) {
|
||||
// Build full path and check if its in our ignore list.
|
||||
std::shared_ptr<Watcher> watcher = sub->watcher;
|
||||
std::string path = std::string(sub->path);
|
||||
bool isDir = event->mask & IN_ISDIR;
|
||||
|
||||
if (event->len > 0) {
|
||||
path += "/" + std::string(event->name);
|
||||
}
|
||||
|
||||
if (watcher->isIgnored(path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If this is a create, check if it's a directory and start watching if it is.
|
||||
// In any case, keep the directory tree up to date.
|
||||
if (event->mask & (IN_CREATE | IN_MOVED_TO)) {
|
||||
watcher->mEvents.create(path);
|
||||
|
||||
struct stat st;
|
||||
// Use lstat to avoid resolving symbolic links that we cannot watch anyway
|
||||
// https://github.com/parcel-bundler/watcher/issues/76
|
||||
lstat(path.c_str(), &st);
|
||||
DirEntry *entry = sub->tree->add(path, CONVERT_TIME(st.st_mtim), S_ISDIR(st.st_mode));
|
||||
|
||||
if (entry->isDir) {
|
||||
bool success = watchDir(watcher, path, sub->tree);
|
||||
if (!success) {
|
||||
sub->tree->remove(path);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (event->mask & (IN_MODIFY | IN_ATTRIB)) {
|
||||
watcher->mEvents.update(path);
|
||||
|
||||
struct stat st;
|
||||
stat(path.c_str(), &st);
|
||||
sub->tree->update(path, CONVERT_TIME(st.st_mtim));
|
||||
} else if (event->mask & (IN_DELETE | IN_DELETE_SELF | IN_MOVED_FROM | IN_MOVE_SELF)) {
|
||||
bool isSelfEvent = (event->mask & (IN_DELETE_SELF | IN_MOVE_SELF));
|
||||
// Ignore delete/move self events unless this is the recursive watch root
|
||||
if (isSelfEvent && path != watcher->mDir) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the entry being deleted/moved is a directory, remove it from the list of subscriptions
|
||||
// XXX: self events don't have the IN_ISDIR mask
|
||||
if (isSelfEvent || isDir) {
|
||||
for (auto it = mSubscriptions.begin(); it != mSubscriptions.end();) {
|
||||
if (it->second->path == path) {
|
||||
it = mSubscriptions.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
watcher->mEvents.remove(path);
|
||||
sub->tree->remove(path);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// This function is called by Backend::unwatch which takes a lock on mMutex
|
||||
void InotifyBackend::unsubscribe(WatcherRef watcher) {
|
||||
// Find any subscriptions pointing to this watcher, and remove them.
|
||||
for (auto it = mSubscriptions.begin(); it != mSubscriptions.end();) {
|
||||
if (it->second->watcher.get() == watcher.get()) {
|
||||
if (mSubscriptions.count(it->first) == 1) {
|
||||
int err = inotify_rm_watch(mInotify, it->first);
|
||||
if (err == -1) {
|
||||
throw WatcherError(std::string("Unable to remove watcher: ") + strerror(errno), watcher);
|
||||
}
|
||||
}
|
||||
|
||||
it = mSubscriptions.erase(it);
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
node_modules/@parcel/watcher/src/linux/InotifyBackend.hh
generated
vendored
Normal file
34
node_modules/@parcel/watcher/src/linux/InotifyBackend.hh
generated
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef INOTIFY_H
|
||||
#define INOTIFY_H
|
||||
|
||||
#include <unordered_map>
|
||||
#include <sys/inotify.h>
|
||||
#include "../shared/BruteForceBackend.hh"
|
||||
#include "../DirTree.hh"
|
||||
#include "../Signal.hh"
|
||||
|
||||
struct InotifySubscription {
|
||||
std::shared_ptr<DirTree> tree;
|
||||
std::string path;
|
||||
WatcherRef watcher;
|
||||
};
|
||||
|
||||
class InotifyBackend : public BruteForceBackend {
|
||||
public:
|
||||
void start() override;
|
||||
~InotifyBackend();
|
||||
void subscribe(WatcherRef watcher) override;
|
||||
void unsubscribe(WatcherRef watcher) override;
|
||||
private:
|
||||
int mPipe[2];
|
||||
int mInotify;
|
||||
std::unordered_multimap<int, std::shared_ptr<InotifySubscription>> mSubscriptions;
|
||||
Signal mEndedSignal;
|
||||
|
||||
bool watchDir(WatcherRef watcher, std::string path, std::shared_ptr<DirTree> tree);
|
||||
void handleEvents();
|
||||
void handleEvent(struct inotify_event *event, std::unordered_set<WatcherRef> &watchers);
|
||||
bool handleSubscription(struct inotify_event *event, std::shared_ptr<InotifySubscription> sub);
|
||||
};
|
||||
|
||||
#endif
|
||||
338
node_modules/@parcel/watcher/src/macos/FSEventsBackend.cc
generated
vendored
Normal file
338
node_modules/@parcel/watcher/src/macos/FSEventsBackend.cc
generated
vendored
Normal file
|
|
@ -0,0 +1,338 @@
|
|||
#include <CoreServices/CoreServices.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <unordered_set>
|
||||
#include "../Event.hh"
|
||||
#include "../Backend.hh"
|
||||
#include "./FSEventsBackend.hh"
|
||||
#include "../Watcher.hh"
|
||||
|
||||
#define CONVERT_TIME(ts) ((uint64_t)ts.tv_sec * 1000000000 + ts.tv_nsec)
|
||||
#define IGNORED_FLAGS (kFSEventStreamEventFlagItemIsHardlink | kFSEventStreamEventFlagItemIsLastHardlink | kFSEventStreamEventFlagItemIsSymlink | kFSEventStreamEventFlagItemIsDir | kFSEventStreamEventFlagItemIsFile)
|
||||
|
||||
void stopStream(FSEventStreamRef stream, CFRunLoopRef runLoop) {
|
||||
FSEventStreamStop(stream);
|
||||
FSEventStreamUnscheduleFromRunLoop(stream, runLoop, kCFRunLoopDefaultMode);
|
||||
FSEventStreamInvalidate(stream);
|
||||
FSEventStreamRelease(stream);
|
||||
}
|
||||
|
||||
// macOS has a case insensitive file system by default. In order to detect
|
||||
// file renames that only affect case, we need to get the canonical path
|
||||
// and compare it with the input path to determine if a file was created or deleted.
|
||||
bool pathExists(char *path) {
|
||||
int fd = open(path, O_RDONLY | O_SYMLINK);
|
||||
if (fd == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char buf[PATH_MAX];
|
||||
if (fcntl(fd, F_GETPATH, buf) == -1) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool res = strncmp(path, buf, PATH_MAX) == 0;
|
||||
close(fd);
|
||||
return res;
|
||||
}
|
||||
|
||||
class State: public WatcherState {
|
||||
public:
|
||||
FSEventStreamRef stream;
|
||||
std::shared_ptr<DirTree> tree;
|
||||
uint64_t since;
|
||||
};
|
||||
|
||||
void FSEventsCallback(
|
||||
ConstFSEventStreamRef streamRef,
|
||||
void *clientCallBackInfo,
|
||||
size_t numEvents,
|
||||
void *eventPaths,
|
||||
const FSEventStreamEventFlags eventFlags[],
|
||||
const FSEventStreamEventId eventIds[]
|
||||
) {
|
||||
char **paths = (char **)eventPaths;
|
||||
std::shared_ptr<Watcher>& watcher = *static_cast<std::shared_ptr<Watcher> *>(clientCallBackInfo);
|
||||
|
||||
EventList& list = watcher->mEvents;
|
||||
if (watcher->state == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto stateGuard = watcher->state;
|
||||
auto* state = static_cast<State*>(stateGuard.get());
|
||||
uint64_t since = state->since;
|
||||
bool deletedRoot = false;
|
||||
|
||||
for (size_t i = 0; i < numEvents; ++i) {
|
||||
bool isCreated = (eventFlags[i] & kFSEventStreamEventFlagItemCreated) == kFSEventStreamEventFlagItemCreated;
|
||||
bool isRemoved = (eventFlags[i] & kFSEventStreamEventFlagItemRemoved) == kFSEventStreamEventFlagItemRemoved;
|
||||
bool isModified = (eventFlags[i] & kFSEventStreamEventFlagItemModified) == kFSEventStreamEventFlagItemModified ||
|
||||
(eventFlags[i] & kFSEventStreamEventFlagItemInodeMetaMod) == kFSEventStreamEventFlagItemInodeMetaMod ||
|
||||
(eventFlags[i] & kFSEventStreamEventFlagItemFinderInfoMod) == kFSEventStreamEventFlagItemFinderInfoMod ||
|
||||
(eventFlags[i] & kFSEventStreamEventFlagItemChangeOwner) == kFSEventStreamEventFlagItemChangeOwner ||
|
||||
(eventFlags[i] & kFSEventStreamEventFlagItemXattrMod) == kFSEventStreamEventFlagItemXattrMod;
|
||||
bool isRenamed = (eventFlags[i] & kFSEventStreamEventFlagItemRenamed) == kFSEventStreamEventFlagItemRenamed;
|
||||
bool isDone = (eventFlags[i] & kFSEventStreamEventFlagHistoryDone) == kFSEventStreamEventFlagHistoryDone;
|
||||
bool isDir = (eventFlags[i] & kFSEventStreamEventFlagItemIsDir) == kFSEventStreamEventFlagItemIsDir;
|
||||
|
||||
|
||||
if (eventFlags[i] & kFSEventStreamEventFlagMustScanSubDirs) {
|
||||
if (eventFlags[i] & kFSEventStreamEventFlagUserDropped) {
|
||||
list.error("Events were dropped by the FSEvents client. File system must be re-scanned.");
|
||||
} else if (eventFlags[i] & kFSEventStreamEventFlagKernelDropped) {
|
||||
list.error("Events were dropped by the kernel. File system must be re-scanned.");
|
||||
} else {
|
||||
list.error("Too many events. File system must be re-scanned.");
|
||||
}
|
||||
}
|
||||
|
||||
if (isDone) {
|
||||
watcher->notify();
|
||||
break;
|
||||
}
|
||||
|
||||
auto ignoredFlags = IGNORED_FLAGS;
|
||||
if (__builtin_available(macOS 10.13, *)) {
|
||||
ignoredFlags |= kFSEventStreamEventFlagItemCloned;
|
||||
}
|
||||
|
||||
// If we don't care about any of the flags that are set, ignore this event.
|
||||
if ((eventFlags[i] & ~ignoredFlags) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// FSEvents exclusion paths only apply to files, not directories.
|
||||
if (watcher->isIgnored(paths[i])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle unambiguous events first
|
||||
if (isCreated && !(isRemoved || isModified || isRenamed)) {
|
||||
state->tree->add(paths[i], 0, isDir);
|
||||
list.create(paths[i]);
|
||||
} else if (isRemoved && !(isCreated || isModified || isRenamed)) {
|
||||
state->tree->remove(paths[i]);
|
||||
list.remove(paths[i]);
|
||||
if (paths[i] == watcher->mDir) {
|
||||
deletedRoot = true;
|
||||
}
|
||||
} else if (isModified && !(isCreated || isRemoved || isRenamed)) {
|
||||
struct stat file;
|
||||
if (stat(paths[i], &file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore if mtime is the same as the last event.
|
||||
// This prevents duplicate events from being emitted.
|
||||
// If tv_nsec is zero, the file system probably only has second-level
|
||||
// granularity so allow the even through in that case.
|
||||
uint64_t mtime = CONVERT_TIME(file.st_mtimespec);
|
||||
DirEntry *entry = state->tree->find(paths[i]);
|
||||
if (entry && mtime == entry->mtime && file.st_mtimespec.tv_nsec != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry) {
|
||||
// Update mtime.
|
||||
entry->mtime = mtime;
|
||||
} else {
|
||||
// Add to tree if this path has not been discovered yet.
|
||||
state->tree->add(paths[i], mtime, S_ISDIR(file.st_mode));
|
||||
}
|
||||
|
||||
list.update(paths[i]);
|
||||
} else {
|
||||
// If multiple flags were set, then we need to call `stat` to determine if the file really exists.
|
||||
// This helps disambiguate creates, updates, and deletes.
|
||||
struct stat file;
|
||||
if (stat(paths[i], &file) || !pathExists(paths[i])) {
|
||||
// File does not exist, so we have to assume it was removed. This is not exact since the
|
||||
// flags set by fsevents get coalesced together (e.g. created & deleted), so there is no way to
|
||||
// know whether the create and delete both happened since our snapshot (in which case
|
||||
// we'd rather ignore this event completely). This will result in some extra delete events
|
||||
// being emitted for files we don't know about, but that is the best we can do.
|
||||
state->tree->remove(paths[i]);
|
||||
list.remove(paths[i]);
|
||||
if (paths[i] == watcher->mDir) {
|
||||
deletedRoot = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the file was modified, and existed before, then this is an update, otherwise a create.
|
||||
uint64_t ctime = CONVERT_TIME(file.st_birthtimespec);
|
||||
uint64_t mtime = CONVERT_TIME(file.st_mtimespec);
|
||||
DirEntry *entry = !since ? state->tree->find(paths[i]) : NULL;
|
||||
if (entry && entry->mtime == mtime && file.st_mtimespec.tv_nsec != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Some mounted file systems report a creation time of 0/unix epoch which we special case.
|
||||
if (isModified && (entry || (ctime <= since && ctime != 0))) {
|
||||
state->tree->update(paths[i], mtime);
|
||||
list.update(paths[i]);
|
||||
} else {
|
||||
state->tree->add(paths[i], mtime, S_ISDIR(file.st_mode));
|
||||
list.create(paths[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!since) {
|
||||
watcher->notify();
|
||||
}
|
||||
|
||||
// Stop watching if the root directory was deleted.
|
||||
if (deletedRoot) {
|
||||
stopStream((FSEventStreamRef)streamRef, CFRunLoopGetCurrent());
|
||||
watcher->state = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void checkWatcher(WatcherRef watcher) {
|
||||
struct stat file;
|
||||
if (stat(watcher->mDir.c_str(), &file)) {
|
||||
throw WatcherError(strerror(errno), watcher);
|
||||
}
|
||||
|
||||
if (!S_ISDIR(file.st_mode)) {
|
||||
throw WatcherError(strerror(ENOTDIR), watcher);
|
||||
}
|
||||
}
|
||||
|
||||
void FSEventsBackend::startStream(WatcherRef watcher, FSEventStreamEventId id) {
|
||||
checkWatcher(watcher);
|
||||
|
||||
CFAbsoluteTime latency = 0.001;
|
||||
CFStringRef fileWatchPath = CFStringCreateWithCString(
|
||||
NULL,
|
||||
watcher->mDir.c_str(),
|
||||
kCFStringEncodingUTF8
|
||||
);
|
||||
|
||||
CFArrayRef pathsToWatch = CFArrayCreate(
|
||||
NULL,
|
||||
(const void **)&fileWatchPath,
|
||||
1,
|
||||
NULL
|
||||
);
|
||||
|
||||
// Make a watcher reference we can pass into the callback. This ensures bumped ref-count.
|
||||
std::shared_ptr<Watcher>* callbackWatcher = new std::shared_ptr<Watcher> (watcher);
|
||||
FSEventStreamContext callbackInfo {0, static_cast<void*> (callbackWatcher), nullptr, nullptr, nullptr};
|
||||
FSEventStreamRef stream = FSEventStreamCreate(
|
||||
NULL,
|
||||
&FSEventsCallback,
|
||||
&callbackInfo,
|
||||
pathsToWatch,
|
||||
id,
|
||||
latency,
|
||||
kFSEventStreamCreateFlagFileEvents
|
||||
);
|
||||
|
||||
CFMutableArrayRef exclusions = CFArrayCreateMutable(NULL, watcher->mIgnorePaths.size(), NULL);
|
||||
for (auto it = watcher->mIgnorePaths.begin(); it != watcher->mIgnorePaths.end(); it++) {
|
||||
CFStringRef path = CFStringCreateWithCString(
|
||||
NULL,
|
||||
it->c_str(),
|
||||
kCFStringEncodingUTF8
|
||||
);
|
||||
|
||||
CFArrayAppendValue(exclusions, (const void *)path);
|
||||
}
|
||||
|
||||
FSEventStreamSetExclusionPaths(stream, exclusions);
|
||||
|
||||
FSEventStreamScheduleWithRunLoop(stream, mRunLoop, kCFRunLoopDefaultMode);
|
||||
bool started = FSEventStreamStart(stream);
|
||||
|
||||
CFRelease(pathsToWatch);
|
||||
CFRelease(fileWatchPath);
|
||||
|
||||
if (!started) {
|
||||
FSEventStreamRelease(stream);
|
||||
throw WatcherError("Error starting FSEvents stream", watcher);
|
||||
}
|
||||
|
||||
auto stateGuard = watcher->state;
|
||||
State* s = static_cast<State*>(stateGuard.get());
|
||||
s->tree = std::make_shared<DirTree>(watcher->mDir);
|
||||
s->stream = stream;
|
||||
}
|
||||
|
||||
void FSEventsBackend::start() {
|
||||
mRunLoop = CFRunLoopGetCurrent();
|
||||
CFRetain(mRunLoop);
|
||||
|
||||
// Unlock once run loop has started.
|
||||
CFRunLoopPerformBlock(mRunLoop, kCFRunLoopDefaultMode, ^ {
|
||||
notifyStarted();
|
||||
});
|
||||
|
||||
CFRunLoopWakeUp(mRunLoop);
|
||||
CFRunLoopRun();
|
||||
}
|
||||
|
||||
FSEventsBackend::~FSEventsBackend() {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
CFRunLoopStop(mRunLoop);
|
||||
CFRelease(mRunLoop);
|
||||
}
|
||||
|
||||
void FSEventsBackend::writeSnapshot(WatcherRef watcher, std::string *snapshotPath) {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
checkWatcher(watcher);
|
||||
|
||||
FSEventStreamEventId id = FSEventsGetCurrentEventId();
|
||||
std::ofstream ofs(*snapshotPath);
|
||||
ofs << id;
|
||||
ofs << "\n";
|
||||
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
ofs << CONVERT_TIME(now);
|
||||
}
|
||||
|
||||
void FSEventsBackend::getEventsSince(WatcherRef watcher, std::string *snapshotPath) {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
std::ifstream ifs(*snapshotPath);
|
||||
if (ifs.fail()) {
|
||||
return;
|
||||
}
|
||||
|
||||
FSEventStreamEventId id;
|
||||
uint64_t since;
|
||||
ifs >> id;
|
||||
ifs >> since;
|
||||
|
||||
auto s = std::make_shared<State>();
|
||||
s->since = since;
|
||||
watcher->state = s;
|
||||
|
||||
startStream(watcher, id);
|
||||
watcher->wait();
|
||||
stopStream(s->stream, mRunLoop);
|
||||
|
||||
watcher->state = nullptr;
|
||||
}
|
||||
|
||||
// This function is called by Backend::watch which takes a lock on mMutex
|
||||
void FSEventsBackend::subscribe(WatcherRef watcher) {
|
||||
auto s = std::make_shared<State>();
|
||||
s->since = 0;
|
||||
watcher->state = s;
|
||||
startStream(watcher, kFSEventStreamEventIdSinceNow);
|
||||
}
|
||||
|
||||
// This function is called by Backend::unwatch which takes a lock on mMutex
|
||||
void FSEventsBackend::unsubscribe(WatcherRef watcher) {
|
||||
auto stateGuard = watcher->state;
|
||||
State* s = static_cast<State*>(stateGuard.get());
|
||||
if (s != nullptr) {
|
||||
stopStream(s->stream, mRunLoop);
|
||||
watcher->state = nullptr;
|
||||
}
|
||||
}
|
||||
20
node_modules/@parcel/watcher/src/macos/FSEventsBackend.hh
generated
vendored
Normal file
20
node_modules/@parcel/watcher/src/macos/FSEventsBackend.hh
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef FS_EVENTS_H
|
||||
#define FS_EVENTS_H
|
||||
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include "../Backend.hh"
|
||||
|
||||
class FSEventsBackend : public Backend {
|
||||
public:
|
||||
void start() override;
|
||||
~FSEventsBackend();
|
||||
void writeSnapshot(WatcherRef watcher, std::string *snapshotPath) override;
|
||||
void getEventsSince(WatcherRef watcher, std::string *snapshotPath) override;
|
||||
void subscribe(WatcherRef watcher) override;
|
||||
void unsubscribe(WatcherRef watcher) override;
|
||||
private:
|
||||
void startStream(WatcherRef watcher, FSEventStreamEventId id);
|
||||
CFRunLoopRef mRunLoop;
|
||||
};
|
||||
|
||||
#endif
|
||||
41
node_modules/@parcel/watcher/src/shared/BruteForceBackend.cc
generated
vendored
Normal file
41
node_modules/@parcel/watcher/src/shared/BruteForceBackend.cc
generated
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#include <string>
|
||||
#include "../DirTree.hh"
|
||||
#include "../Event.hh"
|
||||
#include "./BruteForceBackend.hh"
|
||||
|
||||
std::shared_ptr<DirTree> BruteForceBackend::getTree(WatcherRef watcher, bool shouldRead) {
|
||||
auto tree = DirTree::getCached(watcher->mDir);
|
||||
|
||||
// If the tree is not complete, read it if needed.
|
||||
if (!tree->isComplete && shouldRead) {
|
||||
readTree(watcher, tree);
|
||||
tree->isComplete = true;
|
||||
}
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
void BruteForceBackend::writeSnapshot(WatcherRef watcher, std::string *snapshotPath) {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
auto tree = getTree(watcher);
|
||||
FILE *f = fopen(snapshotPath->c_str(), "w");
|
||||
if (!f) {
|
||||
throw std::runtime_error(std::string("Unable to open snapshot file: ") + strerror(errno));
|
||||
}
|
||||
|
||||
tree->write(f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void BruteForceBackend::getEventsSince(WatcherRef watcher, std::string *snapshotPath) {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
FILE *f = fopen(snapshotPath->c_str(), "r");
|
||||
if (!f) {
|
||||
throw std::runtime_error(std::string("Unable to open snapshot file: ") + strerror(errno));
|
||||
}
|
||||
|
||||
DirTree snapshot{watcher->mDir, f};
|
||||
auto now = getTree(watcher);
|
||||
now->getChanges(&snapshot, watcher->mEvents);
|
||||
fclose(f);
|
||||
}
|
||||
25
node_modules/@parcel/watcher/src/shared/BruteForceBackend.hh
generated
vendored
Normal file
25
node_modules/@parcel/watcher/src/shared/BruteForceBackend.hh
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef BRUTE_FORCE_H
|
||||
#define BRUTE_FORCE_H
|
||||
|
||||
#include "../Backend.hh"
|
||||
#include "../DirTree.hh"
|
||||
#include "../Watcher.hh"
|
||||
|
||||
class BruteForceBackend : public Backend {
|
||||
public:
|
||||
void writeSnapshot(WatcherRef watcher, std::string *snapshotPath) override;
|
||||
void getEventsSince(WatcherRef watcher, std::string *snapshotPath) override;
|
||||
void subscribe(WatcherRef watcher) override {
|
||||
throw "Brute force backend doesn't support subscriptions.";
|
||||
}
|
||||
|
||||
void unsubscribe(WatcherRef watcher) override {
|
||||
throw "Brute force backend doesn't support subscriptions.";
|
||||
}
|
||||
|
||||
std::shared_ptr<DirTree> getTree(WatcherRef watcher, bool shouldRead = true);
|
||||
private:
|
||||
void readTree(WatcherRef watcher, std::shared_ptr<DirTree> tree);
|
||||
};
|
||||
|
||||
#endif
|
||||
50
node_modules/@parcel/watcher/src/unix/fts.cc
generated
vendored
Normal file
50
node_modules/@parcel/watcher/src/unix/fts.cc
generated
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#include <string>
|
||||
|
||||
// weird error on linux
|
||||
#ifdef __THROW
|
||||
#undef __THROW
|
||||
#endif
|
||||
#define __THROW
|
||||
|
||||
#include <fts.h>
|
||||
#include <sys/stat.h>
|
||||
#include "../DirTree.hh"
|
||||
#include "../shared/BruteForceBackend.hh"
|
||||
|
||||
#define CONVERT_TIME(ts) ((uint64_t)ts.tv_sec * 1000000000 + ts.tv_nsec)
|
||||
#if __APPLE__
|
||||
#define st_mtim st_mtimespec
|
||||
#endif
|
||||
|
||||
void BruteForceBackend::readTree(WatcherRef watcher, std::shared_ptr<DirTree> tree) {
|
||||
char *paths[2] {(char *)watcher->mDir.c_str(), NULL};
|
||||
FTS *fts = fts_open(paths, FTS_NOCHDIR | FTS_PHYSICAL, NULL);
|
||||
if (!fts) {
|
||||
throw WatcherError(strerror(errno), watcher);
|
||||
}
|
||||
|
||||
FTSENT *node;
|
||||
bool isRoot = true;
|
||||
|
||||
while ((node = fts_read(fts)) != NULL) {
|
||||
if (node->fts_errno) {
|
||||
fts_close(fts);
|
||||
throw WatcherError(strerror(node->fts_errno), watcher);
|
||||
}
|
||||
|
||||
if (isRoot && !(node->fts_info & FTS_D)) {
|
||||
fts_close(fts);
|
||||
throw WatcherError(strerror(ENOTDIR), watcher);
|
||||
}
|
||||
|
||||
if (watcher->isIgnored(std::string(node->fts_path))) {
|
||||
fts_set(fts, node, FTS_SKIP);
|
||||
continue;
|
||||
}
|
||||
|
||||
tree->add(node->fts_path, CONVERT_TIME(node->fts_statp->st_mtim), (node->fts_info & FTS_D) == FTS_D);
|
||||
isRoot = false;
|
||||
}
|
||||
|
||||
fts_close(fts);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue