proper scrolls

This commit is contained in:
EatThePooh 2025-08-02 05:10:30 +07:00
parent d92bc3b437
commit 9df3f362fe
11 changed files with 146 additions and 36 deletions

10
shelf/deno/hjq/deno.json Normal file
View file

@ -0,0 +1,10 @@
{
"name": "hjq",
"exports": {
".": "./main.ts"
},
"imports": {
"hjson": "npm:hjson@^3.2.2",
"jq-web": "npm:jq-web@^0.6.2"
}
}

21
shelf/deno/hjq/deno.lock generated Normal file
View file

@ -0,0 +1,21 @@
{
"version": "4",
"specifiers": {
"npm:hjson@^3.2.2": "3.2.2",
"npm:jq-web@~0.6.2": "0.6.2"
},
"npm": {
"hjson@3.2.2": {
"integrity": "sha512-MkUeB0cTIlppeSsndgESkfFD21T2nXPRaBStLtf3cAYA2bVEFdXlodZB0TukwZiobPD1Ksax5DK4RTZeaXCI3Q=="
},
"jq-web@0.6.2": {
"integrity": "sha512-+7XvjBYwTx4vP5PYkf6Q6orubO/v+UgMU6By1GritrmShr9QpT3UKa4ANzXWQfhdqtBnQYXsm7ZNbdIHT6tYpQ=="
}
},
"workspace": {
"dependencies": [
"npm:hjson@^3.2.2",
"npm:jq-web@~0.6.2"
]
}
}

46
shelf/deno/hjq/main.ts Normal file
View file

@ -0,0 +1,46 @@
// a basic drop-in replacement for jq to handle HJSON
// tries to preserve comments but doesn't do a very good job :(
import Hjson from "hjson";
import jqModule from "jq-web";
import fs from "node:fs";
export const n = 42;
const jq = await jqModule;
var filter = process.argv[2];
if (!filter) {
filter = '.';
}
const input = fs.readFileSync(0, 'utf8');
try {
const data = Hjson.parse(input, { keepWsc: true });
const result = jq.json(data, filter);
// Only try to preserve comments if the result is an object or array
if (result !== null && typeof result === 'object') {
// Extract comments before transformation
const comments = Hjson.comments.extract(data);
// Merge comments back into the transformed result
if (comments) {
Hjson.comments.merge(comments, result);
}
const output = Hjson.stringify(result, {
keepWsc: true,
bracesSameLine: true
});
console.log(output);
} else {
console.log(JSON.stringify(result));
}
} catch (error) {
console.error(error);
process.exit(1);
}

View file

@ -0,0 +1,42 @@
{ pkgs, target }:
pkgs.stdenv.mkDerivation rec {
pname = "hjq";
version = "0.1.0";
src = ./.;
__noChroot = true;
dontStrip = true;
denort = pkgs.fetchurl {
url = "https://dl.deno.land/release/v${pkgs.deno.version}/denort-${target}.zip";
hash = "sha256-J2LfvHPbJvcOpbQOd6EmGxHDciez7tG10etK4bqQhLI=";
};
nativeBuildInputs = with pkgs; [ deno unzip ];
configurePhase = ''
export DENO_DIR=./.deno_cache;
mkdir -p $TMPDIR/denort
pushd $TMPDIR/denort
unzip ${denort}
chmod +x denort
popd
deno cache --reload main.ts
'';
buildPhase = ''
runHook preBuild
export DENORT_BIN="$TMPDIR/denort/denort"
deno compile --target=${target} --cached-only --output app main.ts
runHook postBuild
'';
installPhase = ''
mkdir -p $out/bin
cp app $out/bin/${pname}
'';
}

View file

@ -0,0 +1,3 @@
{
cache-command = "deno cache --reload main.ts";
}

View file

@ -0,0 +1,8 @@
{
"tasks": {
"start": "deno run --cached-only main.ts"
},
"patch": [
"../hjq"
]
}

15
shelf/deno/uses-hjq/deno.lock generated Normal file
View file

@ -0,0 +1,15 @@
{
"version": "4",
"specifiers": {
"npm:hjson@^3.2.2": "3.2.2",
"npm:jq-web@~0.6.2": "0.6.2"
},
"npm": {
"hjson@3.2.2": {
"integrity": "sha512-MkUeB0cTIlppeSsndgESkfFD21T2nXPRaBStLtf3cAYA2bVEFdXlodZB0TukwZiobPD1Ksax5DK4RTZeaXCI3Q=="
},
"jq-web@0.6.2": {
"integrity": "sha512-+7XvjBYwTx4vP5PYkf6Q6orubO/v+UgMU6By1GritrmShr9QpT3UKa4ANzXWQfhdqtBnQYXsm7ZNbdIHT6tYpQ=="
}
}
}

View file

@ -0,0 +1,3 @@
import {n} from 'hjq';
console.log("I use hjq:", n);

View file

@ -0,0 +1,3 @@
{
cache-command = "deno cache -I --reload main.ts";
}