TangJieHao
TangJieHao
DDeno
Created by TangJieHao on 9/23/2024 in #help
Adding a lib/rep to deno's lsp
I'm looking for a way to improve search speed by caching or adding to Deno's LSP. At least in VSCode I doubled the GB limit but I still have the same issue. I was wondering how I could use a local files for this search.
1 replies
DDeno
Created by TangJieHao on 9/1/2024 in #help
WritableSteam not opening.
constructor() {
this.command = new Deno.Command(this.exec, {
args: ["analysis", "-model", this.model, "-config", this.config],
stdin: "piped",
stdout: "piped",
stderr: "piped",
});

this.AI = this.command.spawn();
this.stdin = this.AI.stdin.getWriter();
this.stdout = this.AI.stdout.getReader();
this.stderr = this.AI.stderr.getReader();
}

async writeToStdin(data: string): Promise<void> {
const encoder = new TextEncoder();
const encoded = encoder.encode(data);
await this.stdin.write(encoded);
}

async readFromStdout(): Promise<string> {
let buffer = "";
const decoder = new TextDecoder();
while (true) {
const { value, done } = await this.stdout.read();
if (done) {
return buffer.trim();
}

buffer += decoder.decode(value, { stream: true });

}
}
constructor() {
this.command = new Deno.Command(this.exec, {
args: ["analysis", "-model", this.model, "-config", this.config],
stdin: "piped",
stdout: "piped",
stderr: "piped",
});

this.AI = this.command.spawn();
this.stdin = this.AI.stdin.getWriter();
this.stdout = this.AI.stdout.getReader();
this.stderr = this.AI.stderr.getReader();
}

async writeToStdin(data: string): Promise<void> {
const encoder = new TextEncoder();
const encoded = encoder.encode(data);
await this.stdin.write(encoded);
}

async readFromStdout(): Promise<string> {
let buffer = "";
const decoder = new TextDecoder();
while (true) {
const { value, done } = await this.stdout.read();
if (done) {
return buffer.trim();
}

buffer += decoder.decode(value, { stream: true });

}
}
I seem to only be able to write to the stdin once. I have tried closing and getting a new getWriter with every new write call but I get same issue that stdin is closed or is closing
3 replies
DDeno
Created by TangJieHao on 9/1/2024 in #help
dwm hot reload
looking to hot reload dwm canvas when I update / save the file instead of having to restart the program
2 replies
DDeno
Created by TangJieHao on 7/6/2024 in #help
Deno + Puppeteer causing compiler issues.
I get an error that document cannot be found. It's asking if I am trying to change the library. but when running deno run -allow-all --unstable it works error: TS2584 [ERROR]: Cannot find name 'document'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'. const rows = document.querySelectorAll(".review-history-table tbody tr"); ~~~~
4 replies
DDeno
Created by TangJieHao on 6/26/2024 in #help
command.spawn() stdin and stdout
I am not sure if I am handling the writeable stream and readable stream correctly. I assigned getWrite and getReader to writer and reader in my class. I am slightly confused on what ready, releaseLock is as it's not well documented (from what sourced I can find)
private async stdin(query: Query): Promise<void> {
const data = this.encoder.encode(JSON.stringify(query) + "\n");
await this.writer.ready;
await this.writer.write(data);
this.writer.releaseLock();
}

private async stdout(): Promise<AIObject> {
const result = await this.reader.read();
if (result.done) {
throw new Error("Stream finished unexpectedly.");
}
const responseStr = this.decoder.decode(result.value);
return JSON.parse(responseStr) as AIObject;
}
private async stdin(query: Query): Promise<void> {
const data = this.encoder.encode(JSON.stringify(query) + "\n");
await this.writer.ready;
await this.writer.write(data);
this.writer.releaseLock();
}

private async stdout(): Promise<AIObject> {
const result = await this.reader.read();
if (result.done) {
throw new Error("Stream finished unexpectedly.");
}
const responseStr = this.decoder.decode(result.value);
return JSON.parse(responseStr) as AIObject;
}
9 replies
DDeno
Created by TangJieHao on 2/13/2024 in #help
deno command stdin, stdout continous reading
I am trying to spawn an AI (cpp code) however after launching the code it immediately exits. It also isn't providing any stdout either. relevant code:
async function load_kata_go(config) {
const command = new Deno.Command(config.EXE, {
args: ["analysis", "-model", config.MODEL, "-config", config.CONFIG],
stdin: "piped",
stdout: "piped",
stderr: "piped",
});

const process = command.spawn();
return process;
}

async function main() {
const cli_kata_config = await load_cli_config();
const katago = await load_kata_go(cli_kata_config);

const result = await katago.output();
console.log(new TextDecoder().decode(result.stdout));

//command args
//command settings
//AI
//analyze games
}

main();
async function load_kata_go(config) {
const command = new Deno.Command(config.EXE, {
args: ["analysis", "-model", config.MODEL, "-config", config.CONFIG],
stdin: "piped",
stdout: "piped",
stderr: "piped",
});

const process = command.spawn();
return process;
}

async function main() {
const cli_kata_config = await load_cli_config();
const katago = await load_kata_go(cli_kata_config);

const result = await katago.output();
console.log(new TextDecoder().decode(result.stdout));

//command args
//command settings
//AI
//analyze games
}

main();
4 replies
DDeno
Created by TangJieHao on 1/4/2024 in #help
compile to target, 'unzip' not found.
I am on linux ubuntu 22 I downloaded, uninstalled reinstalled, written to path unzip. however no matter what I do I get the error "cannot access unzip in path"
TJ@WGDC:~/webview_ogs$ deno compile -Ar --unstable --target x86_64-unknown-linux-gnu main.ts
Check file:///../webview_ogs/main.ts
Compile file:///../webview_ogs/main.ts to webview_ogs
error: Writing webview_ogs

Caused by:
`unzip` was not found in your PATH, please install `unzip`
TJ@WGDC:~/webview_ogs$ deno compile -Ar --unstable --target x86_64-unknown-linux-gnu main.ts
Check file:///../webview_ogs/main.ts
Compile file:///../webview_ogs/main.ts to webview_ogs
error: Writing webview_ogs

Caused by:
`unzip` was not found in your PATH, please install `unzip`
5 replies
DDeno
Created by TangJieHao on 11/29/2023 in #help
Deno.Command
I'm looking to run a child_process with readline and spawn. I've tried following examples and such. Would it be better to use spawn from non:child_process? For std thread? I need to be able start, read, write and exit to std spawn.
2 replies