This commit is contained in:
Shusui MOYATANI
2023-03-23 09:23:52 +09:00
parent 3348bba012
commit 04eaa5b0ad
10 changed files with 716 additions and 2815 deletions

3427
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -20,29 +20,27 @@
"checkLicense": "node -e 'import(\"./scripts/checkLicense.mjs\").then((m) => m.default())'"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/parser": "^5.48.1",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"autoprefixer": "^10.4.13",
"eslint": "^8.31.0",
"eslint": "^8.36.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.6.0",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-plugin-import": "^2.27.4",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-solid": "^0.9.2",
"eslint-plugin-tailwindcss": "^3.8.0",
"eslint-plugin-solid": "^0.11.0",
"eslint-plugin-tailwindcss": "^3.10.1",
"husky": "^8.0.3",
"license-checker": "^25.0.1",
"lint-staged": "^13.1.0",
"nyc": "^15.1.0",
"lint-staged": "^13.2.0",
"postcss": "^8.4.21",
"power-assert": "^1.6.1",
"prettier": "^2.8.3",
"typescript": "^4.9.4",
"vite": "^4.0.4",
"vite-plugin-solid": "^2.5.0",
"vite-plugin-solid-svg": "^0.6.0",
"prettier": "^2.8.6",
"typescript": "^5.0.1",
"vite": "^4.2.1",
"vite-plugin-solid": "^2.6.1",
"vite-plugin-solid-svg": "^0.6.1",
"vitest": "^0.29.5"
},
"dependencies": {
@@ -56,7 +54,7 @@
"@types/lodash": "^4.14.191",
"heroicons": "^2.0.15",
"lodash": "^4.17.21",
"nostr-tools": "^1.3.2",
"nostr-tools": "^1.7.5",
"solid-js": "^1.6.9",
"tailwindcss": "^3.2.4",
"zod": "^3.20.6"

View File

@@ -1,5 +1,7 @@
import { Component } from 'solid-js';
import { noteEncode } from 'nostr-tools/nip19';
import { nip19 } from 'nostr-tools';
const { noteEncode } = nip19;
type EventLinkProps = {
eventId: string;

View File

@@ -1,5 +1,4 @@
import { Switch, Match, type Component } from 'solid-js';
import { noteEncode } from 'nostr-tools/nip19';
import TextNoteDisplay, { type TextNoteDisplayProps } from '@/components/textNote/TextNoteDisplay';

View File

@@ -1,7 +1,11 @@
import type { Event as NostrEvent } from 'nostr-tools';
import { decode, type ProfilePointer, type EventPointer } from 'nostr-tools/nip19';
import { nip19, type Event as NostrEvent } from 'nostr-tools';
import eventWrapper from './event';
type ProfilePointer = nip19.ProfilePointer;
type EventPointer = nip19.EventPointer;
const { decode } = nip19;
export type PlainText = {
type: 'PlainText';
content: string;

View File

@@ -7,14 +7,11 @@ import {
type Signal,
} from 'solid-js';
import { type Event as NostrEvent, type Filter, Kind } from 'nostr-tools';
import { npubEncode } from 'nostr-tools/nip19';
import { createQuery, useQueryClient, type CreateQueryResult } from '@tanstack/solid-query';
import timeout from '@/utils/timeout';
import useBatch, { type Task } from '@/nostr/useBatch';
import eventWrapper from '@/core/event';
import useSubscription from '@/nostr/useSubscription';
import npubEncodeFallback from '@/utils/npubEncodeFallback';
import useConfig from './useConfig';
import usePool from './usePool';

View File

@@ -7,11 +7,13 @@ const [pubkey, setPubkey] = createSignal<string | undefined>(undefined);
// TODO 失敗したときに通知等を表示したい
const usePubkey = (): Accessor<string | undefined> => {
onMount(() => {
console.time('pubkey loaded');
let count = 0;
const intervalId = setInterval(() => {
if (count >= 5) {
let intervalId: ReturnType<typeof setInterval> | undefined;
const loadPubkey = () => {
if (count >= 20) {
clearInterval(intervalId);
if (pubkey() == null && !asking) {
if (pubkey() == null) {
if (window.nostr == null) {
throw new Error('Failed to obtain public key: Timeout. window.nostr is not defined.');
}
@@ -24,11 +26,19 @@ const usePubkey = (): Accessor<string | undefined> => {
asking = true;
window.nostr
.getPublicKey()
.then((key) => setPubkey(key))
.catch((err) => console.error('failed to obtain public key: ', err));
.then((key) => {
clearInterval(intervalId);
setPubkey(key);
console.timeEnd('pubkey loaded');
})
.catch((err) => console.error('failed to obtain public key: ', err))
.finally(() => {
asking = false;
});
}
count += 1;
}, 1000);
};
intervalId = setInterval(loadPubkey, 200);
});
return pubkey;

View File

@@ -54,10 +54,6 @@ const Home: Component = () => {
})),
);
createEffect(() => {
console.log(followingPubkeys());
});
const { events: followingsPosts } = useSubscription(() =>
ensureNonNull([pubkey()] as const)(([pubkeyNonNull]) => ({
relayUrls: config().relayUrls,
@@ -110,22 +106,20 @@ const Home: Component = () => {
})),
);
const { events: localTimeline } = useSubscription(() =>
ensureNonNull([pubkey()] as const)(([pubkeyNonNull]) => ({
relayUrls: [
'wss://relay-jp.nostr.wirednet.jp',
'wss://nostr.h3z.jp',
'wss://nostr.holybea.com',
],
filters: [
{
kinds: [1, 6],
limit: 25,
since: Math.floor(Date.now() / 1000) - 12 * 60 * 60,
},
],
})),
);
const { events: localTimeline } = useSubscription(() => ({
relayUrls: [
'wss://relay-jp.nostr.wirednet.jp',
'wss://nostr.h3z.jp',
'wss://nostr.holybea.com',
],
filters: [
{
kinds: [1, 6],
limit: 25,
since: Math.floor(Date.now() / 1000) - 12 * 60 * 60,
},
],
}));
/*
const { events: searchPosts } = useSubscription(() => ({

View File

@@ -1,4 +1,6 @@
import { npubEncode } from 'nostr-tools/nip19';
import { nip19 } from 'nostr-tools';
const { npubEncode } = nip19;
const npubEncodeFallback = (pubkey: string): string => {
try {

View File

@@ -13,7 +13,7 @@ export default defineConfig({
},
build: {
target: 'esnext',
sourcemap: 'inline',
sourcemap: true,
},
resolve: {
alias: {