Notification summary
This commit is contained in:
25
packages/system-web/package.json
Normal file
25
packages/system-web/package.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@snort/system-web",
|
||||
"version": "1.0.0",
|
||||
"description": "Web based components @snort/system",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"repository": "https://git.v0l.io/Kieran/snort",
|
||||
"author": "Kieran",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "rm -rf dist && tsc"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"@snort/shared": "^1.0.6",
|
||||
"@snort/system": "^1.0.21",
|
||||
"dexie": "^3.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.2.2"
|
||||
}
|
||||
}
|
40
packages/system-web/src/index.ts
Normal file
40
packages/system-web/src/index.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { NostrEvent, MetadataCache, RelayMetrics, UsersRelays } from "@snort/system";
|
||||
import Dexie, { Table } from "dexie";
|
||||
|
||||
const NAME = "snort-system";
|
||||
const VERSION = 2;
|
||||
|
||||
const STORES = {
|
||||
users: "++pubkey, name, display_name, picture, nip05, npub",
|
||||
relayMetrics: "++addr",
|
||||
userRelays: "++pubkey",
|
||||
events: "++id, pubkey, created_at",
|
||||
};
|
||||
|
||||
export class SnortSystemDb extends Dexie {
|
||||
ready = false;
|
||||
users!: Table<MetadataCache>;
|
||||
relayMetrics!: Table<RelayMetrics>;
|
||||
userRelays!: Table<UsersRelays>;
|
||||
events!: Table<NostrEvent>;
|
||||
|
||||
constructor() {
|
||||
super(NAME);
|
||||
this.version(VERSION).stores(STORES);
|
||||
}
|
||||
|
||||
isAvailable() {
|
||||
if ("indexedDB" in window) {
|
||||
return new Promise<boolean>(resolve => {
|
||||
const req = window.indexedDB.open("dummy", 1);
|
||||
req.onsuccess = () => {
|
||||
resolve(true);
|
||||
};
|
||||
req.onerror = () => {
|
||||
resolve(false);
|
||||
};
|
||||
});
|
||||
}
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
}
|
18
packages/system-web/tsconfig.json
Normal file
18
packages/system-web/tsconfig.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "src",
|
||||
"target": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"esModuleInterop": true,
|
||||
"noImplicitOverride": true,
|
||||
"jsx": "react-jsx",
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"inlineSourceMap": true,
|
||||
"outDir": "dist",
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"files": ["src/index.ts"]
|
||||
}
|
Reference in New Issue
Block a user