Tweak some typescript things

This commit is contained in:
Jonathan Staab
2023-09-20 10:28:15 -07:00
parent 7c9039704c
commit 25adcc71ef
9 changed files with 689 additions and 39 deletions
+1
View File
@@ -1 +1,2 @@
--ignore-dir=dist --ignore-dir=dist
--ignore-file=match:yarn.lock
+1
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env sh #!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh" . "$(dirname -- "$0")/_/husky.sh"
npm run build
npm run lint npm run lint
+4 -4
View File
@@ -14,11 +14,9 @@
"require": "./dist/paravel.cjs" "require": "./dist/paravel.cjs"
}, },
"scripts": { "scripts": {
"build": "node build.js", "build": "tsc && node build.js",
"pub": "npm i && npm run lint && node build.js && npm publish", "pub": "npm i && npm run lint && node build.js && npm publish",
"lint:ts": "tsc", "lint": "eslint src/* --fix"
"lint:es": "eslint src/* --fix",
"lint": "run-p lint:*"
}, },
"keywords": [ "keywords": [
"nostr" "nostr"
@@ -39,6 +37,7 @@
"eslint-plugin-babel": "^5.3.1", "eslint-plugin-babel": "^5.3.1",
"esm-loader-import-relative-extension": "^1.0.8", "esm-loader-import-relative-extension": "^1.0.8",
"esm-loader-typescript": "^1.0.3", "esm-loader-typescript": "^1.0.3",
"gts": "^5.0.1",
"node-esm-loader": "^0.0.3", "node-esm-loader": "^0.0.3",
"prettier": "2.8.3", "prettier": "2.8.3",
"tsd": "^0.22.0", "tsd": "^0.22.0",
@@ -48,6 +47,7 @@
"events": "^3.3.0", "events": "^3.3.0",
"husky": "^8.0.3", "husky": "^8.0.3",
"isomorphic-ws": "^5.0.0", "isomorphic-ws": "^5.0.0",
"nostr-tools": "^1.15.0",
"npm-run-all": "^4.1.5" "npm-run-all": "^4.1.5"
} }
} }
+2 -1
View File
@@ -1,4 +1,5 @@
import type {Event, Filter} from './types' import type {Event} from 'nostr-tools/lib/event'
import type {Filter} from 'nostr-tools/lib/filter'
import type {Connection} from './Connection' import type {Connection} from './Connection'
export type PublishMeta = { export type PublishMeta = {
+4 -3
View File
@@ -1,4 +1,5 @@
import type {Event, Filter} from './types' import type {Event} from 'nostr-tools/lib/event'
import type {Filter} from 'nostr-tools/lib/filter'
import type {Connection} from './Connection' import type {Connection} from './Connection'
import type {Emitter} from './util/Emitter' import type {Emitter} from './util/Emitter'
import type {Message} from './util/Socket' import type {Message} from './util/Socket'
@@ -15,7 +16,7 @@ type AuthCallback = (url: string, challenge: string) => void
type OkCallback = (url: string, id: string, ...extra: any[]) => void type OkCallback = (url: string, id: string, ...extra: any[]) => void
type ErrorCallback = (url: string, id: string, ...extra: any[]) => void type ErrorCallback = (url: string, id: string, ...extra: any[]) => void
type CountCallback = (url: string, ...extra: any[]) => void type CountCallback = (url: string, ...extra: any[]) => void
type SubscribeOpts = {onEvent: EventCallback, onEose: EoseCallback} type SubscribeOpts = {onEvent?: EventCallback, onEose?: EoseCallback}
type PublishOpts = {verb: string, onOk: OkCallback, onError: ErrorCallback} type PublishOpts = {verb: string, onOk: OkCallback, onError: ErrorCallback}
type CountOpts = {onCount: CountCallback} type CountOpts = {onCount: CountCallback}
type AuthOpts = {onAuth: AuthCallback, onOk: OkCallback} type AuthOpts = {onAuth: AuthCallback, onOk: OkCallback}
@@ -26,7 +27,7 @@ export class Executor {
constructor(readonly target: Target) {} constructor(readonly target: Target) {}
subscribe(filters: Filter[], {onEvent, onEose}: SubscribeOpts) { subscribe(filters: Filter[], {onEvent, onEose}: SubscribeOpts = {}) {
let closed = false let closed = false
const id = createSubId('REQ') const id = createSubId('REQ')
+2 -2
View File
@@ -11,7 +11,7 @@ export class Pool extends Emitter {
has(url: string) { has(url: string) {
return this.data.has(url) return this.data.has(url)
} }
get(url: string, {autoConnect = true, reconnectAfter = 3000} = {}) { get(url: string, {autoConnect = true, reconnectAfter = 3000} = {}): Connection {
let connection = this.data.get(url) let connection = this.data.get(url)
if (autoConnect) { if (autoConnect) {
@@ -30,7 +30,7 @@ export class Pool extends Emitter {
}) })
} }
return connection return connection!
} }
remove(url: string) { remove(url: string) {
const connection = this.data.get(url) const connection = this.data.get(url)
-5
View File
@@ -1,5 +0,0 @@
export type Event = {
id: string
}
export type Filter = Record<string, any>
+4 -16
View File
@@ -1,22 +1,10 @@
{ {
"extends": "./node_modules/gts/tsconfig-google.json",
"compilerOptions": { "compilerOptions": {
"module": "esnext",
"target": "es2015",
"lib": ["dom", "dom.iterable", "esnext"],
"declaration": true,
"strict": true,
"moduleResolution": "node",
"skipLibCheck": true,
"esModuleInterop": true,
"emitDeclarationOnly": true,
"outDir": "dist",
"rootDir": ".", "rootDir": ".",
"useDefineForClassFields": true, "outDir": "build",
"allowSyntheticDefaultImports": true, "esModuleInterop": true,
"resolveJsonModule": true, "skipLibCheck": true
"isolatedModules": false,
"importsNotUsedAsValues": "preserve"
}, },
"include": ["src/**/*.ts"] "include": ["src/**/*.ts"]
} }
+671 -8
View File
File diff suppressed because it is too large Load Diff