Use deno typescript instead of node. Fix compilation errors for updated typescript. update setup script to install deno. use tmux when running localling for all processes.

This commit is contained in:
2026-04-16 00:36:22 -07:00
parent 187d41e93f
commit 548ac39d19
17 changed files with 168 additions and 46 deletions

6
deno.json Normal file
View File

@@ -0,0 +1,6 @@
{
"tasks": {
"build": "deno run -A npm:typescript/bin/tsc",
"watch": "deno run -A npm:typescript/bin/tsc --watch"
}
}

68
deno.lock generated Normal file
View File

@@ -0,0 +1,68 @@
{
"version": "5",
"specifiers": {
"jsr:@deno-library/compress@*": "0.5.6",
"jsr:@deno-library/crc32@1.0.2": "1.0.2",
"jsr:@std/bytes@^1.0.2": "1.0.6",
"jsr:@std/fs@1.0.5": "1.0.5",
"jsr:@std/io@0.225.0": "0.225.0",
"jsr:@std/path@1.0.8": "1.0.8",
"jsr:@std/path@^1.0.7": "1.0.8",
"jsr:@std/streams@^1.0.7": "1.0.17",
"jsr:@std/tar@0.1.3": "0.1.3",
"jsr:@zip-js/zip-js@2.7.53": "2.7.53",
"npm:typescript@*": "6.0.2"
},
"jsr": {
"@deno-library/compress@0.5.6": {
"integrity": "9d76e37e7682fc8d3d99d5641a7af454ce4689b1df3fd3062141a1deb64453cd",
"dependencies": [
"jsr:@deno-library/crc32",
"jsr:@std/fs",
"jsr:@std/io",
"jsr:@std/path@1.0.8",
"jsr:@std/tar",
"jsr:@zip-js/zip-js"
]
},
"@deno-library/crc32@1.0.2": {
"integrity": "d2061bfee30c87c97f285dfca0fdc4458e632dc072a33ecfc73ca5177a5a39a0"
},
"@std/bytes@1.0.6": {
"integrity": "f6ac6adbd8ccd99314045f5703e23af0a68d7f7e58364b47d2c7f408aeb5820a"
},
"@std/fs@1.0.5": {
"integrity": "41806ad6823d0b5f275f9849a2640d87e4ef67c51ee1b8fb02426f55e02fd44e",
"dependencies": [
"jsr:@std/path@^1.0.7"
]
},
"@std/io@0.225.0": {
"integrity": "c1db7c5e5a231629b32d64b9a53139445b2ca640d828c26bf23e1c55f8c079b3",
"dependencies": [
"jsr:@std/bytes"
]
},
"@std/path@1.0.8": {
"integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be"
},
"@std/streams@1.0.17": {
"integrity": "7859f3d9deed83cf4b41f19223d4a67661b3d3819e9fc117698f493bf5992140"
},
"@std/tar@0.1.3": {
"integrity": "531270fc707b37ab9b5f051aa4943e7b16b86905e0398a4ebe062983b0c93115",
"dependencies": [
"jsr:@std/streams"
]
},
"@zip-js/zip-js@2.7.53": {
"integrity": "acea5bd8e01feb3fe4c242cfbde7d33dd5e006549a4eb1d15283bc0c778ed672"
}
},
"npm": {
"typescript@6.0.2": {
"integrity": "sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==",
"bin": true
}
}
}

27
dev.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
set -e
SESSION="dandelion"
ROOT="$(cd "$(dirname "$0")" && pwd)"
# Kill any existing session
tmux kill-session -t "$SESSION" 2>/dev/null || true
# Create session with tsc in the first pane
tmux new-session -d -s "$SESSION" -c "$ROOT"
tmux send-keys -t "$SESSION" 'deno task watch' Enter
# Split right: deno server
tmux split-window -h -t "$SESSION" -c "$ROOT/deno"
tmux send-keys -t "$SESSION" 'bash dev.sh' Enter
# Split right: ddln_cli
tmux split-window -h -t "$SESSION" -c "$ROOT/ddln_cli"
tmux send-keys -t "$SESSION" 'bash dev.sh' Enter
tmux select-layout -t "$SESSION" even-horizontal
# Open Chrome silently after a short delay
(sleep 3 && open -a "Google Chrome" "https://localhost:8443" &>/dev/null) &
tmux attach-session -t "$SESSION"

View File

@@ -1,5 +0,0 @@
{
"devDependencies": {
"typescript": "5.8.3"
}
}

View File

@@ -1,6 +1,29 @@
#!/bin/bash
set -e
# Install deno if needed
if ! command -v deno &>/dev/null; then
echo "Installing deno..."
curl -fsSL https://deno.land/install.sh | sh
export DENO_INSTALL="$HOME/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
fi
# Install node if needed
if ! command -v node &>/dev/null; then
echo "Installing node..."
brew install node
fi
# Install TypeScript dependencies
npm install
# Install tmux if needed
if ! command -v tmux &>/dev/null; then
echo "Installing tmux..."
brew install tmux
fi
# Install mkcert if needed
if ! command -v mkcert &>/dev/null; then
echo "Installing mkcert..."

View File

@@ -749,27 +749,23 @@ export class App {
this.render();
}
getPeerID() {
let id = localStorage.getItem("peer_id");
getPeerID(): string {
const existing = localStorage.getItem("peer_id");
if (existing) return existing;
if (!id) {
console.log.apply(null, log(`Didn't find a peer ID, generating one`));;
id = generateID();
console.log.apply(null, log(`Didn't find a peer ID, generating one`));
const id = generateID();
localStorage.setItem("peer_id", id);
}
return id;
}
getUserID() {
let id = localStorage.getItem("dandelion_id");
getUserID(): string {
const existing = localStorage.getItem("dandelion_id");
if (existing) return existing;
if (!id) {
console.log.apply(null, log(`Didn't find a user ID, generating one`));;
id = generateID();
console.log.apply(null, log(`Didn't find a user ID, generating one`));
const id = generateID();
localStorage.setItem("dandelion_id", id);
}
return id;
}

View File

@@ -2,7 +2,7 @@ import { openDatabase, getData, addData, addDataArray, clearData, deleteData, me
import { log, logID } from "log";
async function bytesToBase64DataUrl(bytes: Uint8Array, type = "application/octet-stream") {
async function bytesToBase64DataUrl(bytes: Uint8Array<ArrayBuffer>, type = "application/octet-stream") {
return await new Promise((resolve, reject) => {
const reader = Object.assign(new FileReader(), {
onload: () => resolve(reader.result),

View File

@@ -1,4 +1,4 @@
export async function bytesToBase64DataUrl(bytes: Uint8Array, type = "application/octet-stream") {
export async function bytesToBase64DataUrl(bytes: Uint8Array<ArrayBuffer>, type = "application/octet-stream") {
return await new Promise((resolve, reject) => {
const reader = Object.assign(new FileReader(), {
onload: () => resolve(reader.result),

View File

@@ -230,7 +230,7 @@ window.addEventListener('scroll', () => {
// }
// }
async function bytesToBase64DataUrl(bytes: Uint8Array, type = "application/octet-stream") {
async function bytesToBase64DataUrl(bytes: Uint8Array<ArrayBuffer>, type = "application/octet-stream") {
return await new Promise((resolve, reject) => {
const reader = Object.assign(new FileReader(), {
onload: () => resolve(reader.result),
@@ -918,7 +918,7 @@ class App {
}_${String(d.getSeconds()).padStart(2, '0')}`;
this.downloadBinary(compressedData, `ddln_${this.username}_export_${timestamp}.json.gz`);
this.downloadBinary(compressedData.buffer, `ddln_${this.username}_export_${timestamp}.json.gz`);
}
async importTweetArchive(userID: string, tweetArchive: any[]) {

View File

@@ -546,23 +546,21 @@ export class App {
this.render();
}
getPeerID() {
let id = localStorage.getItem("peer_id");
if (!id) {
const existing = localStorage.getItem("peer_id");
if (existing)
return existing;
console.log.apply(null, log(`Didn't find a peer ID, generating one`));
;
id = generateID();
const id = generateID();
localStorage.setItem("peer_id", id);
}
return id;
}
getUserID() {
let id = localStorage.getItem("dandelion_id");
if (!id) {
const existing = localStorage.getItem("dandelion_id");
if (existing)
return existing;
console.log.apply(null, log(`Didn't find a user ID, generating one`));
;
id = generateID();
const id = generateID();
localStorage.setItem("dandelion_id", id);
}
return id;
}
hashIdToIndices(id) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
{"version":3,"file":"dataUtils.js","sourceRoot":"","sources":["../src/dataUtils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,KAAiB,EAAE,IAAI,GAAG,0BAA0B;IAC7F,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,EAAE,EAAE;YAC7C,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;YACpC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;SACpC,CAAC,CAAC;QACH,MAAM,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,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KAAK,UAAU,cAAc,CAAC,KAAa;IAChD,qCAAqC;IACrC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;IACtC,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE7C,6BAA6B;IAC7B,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACxD,MAAM,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;IAEtD,sCAAsC;IACtC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACzB,MAAM,CAAC,KAAK,EAAE,CAAC;IAEf,2CAA2C;IAC3C,MAAM,eAAe,GAAG,MAAM,IAAI,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IAErF,8CAA8C;IAC9C,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,uBAAuB;AACvB,wFAAwF;AACxF,kBAAkB;AAClB,kBAAkB;AAClB,sDAAsD;AACtD,eAAe;AACf,wBAAwB;AAExB,iCAAiC;AACjC,oBAAoB;AACpB,gDAAgD;AAChD,iCAAiC;AACjC,gCAAgC;AAChC,wCAAwC;AACxC,QAAQ;AACR,0BAA0B;AAC1B,iCAAiC;AACjC,wCAAwC;AACxC,QAAQ;AACR,MAAM;AAEN,qBAAqB;AACrB,4CAA4C;AAC5C,wCAAwC;AACxC,MAAM;AAEN,iCAAiC;AACjC,iCAAiC;AACjC,2BAA2B;AAC3B,8CAA8C;AAC9C,eAAe;AACf,eAAe;AACf,QAAQ;AACR,MAAM;AAEN,mBAAmB;AACnB,IAAI;AAEJ,4BAA4B;AAC5B,gDAAgD;AAChD,qCAAqC;AACrC,gCAAgC;AAChC,IAAI"}

View File

@@ -689,7 +689,7 @@ class App {
let compressedData = await compressString(JSON.stringify(output));
const d = new Date();
const timestamp = `${d.getFullYear()}_${String(d.getMonth() + 1).padStart(2, '0')}_${String(d.getDate()).padStart(2, '0')}_${String(d.getHours()).padStart(2, '0')}_${String(d.getMinutes()).padStart(2, '0')}_${String(d.getSeconds()).padStart(2, '0')}`;
this.downloadBinary(compressedData, `ddln_${this.username}_export_${timestamp}.json.gz`);
this.downloadBinary(compressedData.buffer, `ddln_${this.username}_export_${timestamp}.json.gz`);
}
async importTweetArchive(userID, tweetArchive) {
log("Importing tweet archive");

File diff suppressed because one or more lines are too long

2
stop.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
tmux kill-session -t dandelion 2>/dev/null && echo "Stopped." || echo "Not running."

View File

@@ -45,8 +45,15 @@
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
"paths": {
"App": ["./src/App.ts"],
"IDUtils": ["./src/IDUtils.ts"],
"PeerManager": ["./src/PeerManager.ts"],
"Sync": ["./src/Sync.ts"],
"db": ["./src/db.ts"],
"dataUtils": ["./src/dataUtils.ts"],
"log": ["./src/log.ts"]
},
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */