workspace with decoupled nostr package

This commit is contained in:
ennmichael 2023-02-11 21:05:46 +01:00
parent 52e0809622
commit 2a211b78a1
No known key found for this signature in database
GPG Key ID: 6E6E183431A26AF7
260 changed files with 2363 additions and 714 deletions

26
.gitignore vendored
View File

@ -1,25 +1 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea
node_modules/

View File

@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
yarn workspace @snort/app lint-staged

View File

@ -1,10 +1,10 @@
FROM node:16 as build
FROM node:16 as build
WORKDIR /app
COPY package*.json yarn.lock .
RUN yarn install --network-timeout 1000000
COPY . .
RUN yarn build
RUN yarn install --network-timeout 1000000
RUN yarn workspace @snort/nostr build
RUN yarn workspace @snort/app build
FROM nginx:mainline-alpine
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/build /usr/share/nginx/html
COPY --from=build /app/packages/app/build /usr/share/nginx/html

View File

@ -1,95 +1,6 @@
{
"name": "snort",
"version": "0.1.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@jukben/emoji-search": "^2.0.1",
"@noble/hashes": "^1.2.0",
"@noble/secp256k1": "^1.7.0",
"@protobufjs/base64": "^1.1.2",
"@reduxjs/toolkit": "^1.9.1",
"@szhsin/react-menu": "^3.3.1",
"@types/jest": "^29.2.5",
"@types/node": "^18.11.18",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.10",
"@types/uuid": "^9.0.0",
"@types/webscopeio__react-textarea-autocomplete": "^4.7.2",
"@webscopeio/react-textarea-autocomplete": "^4.9.2",
"bech32": "^2.0.0",
"dexie": "^3.2.2",
"dexie-react-hooks": "^1.1.1",
"light-bolt11-decoder": "^2.1.0",
"qr-code-styling": "^1.6.0-rc.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-intersection-observer": "^9.4.1",
"react-intl": "^6.2.8",
"react-markdown": "^8.0.4",
"react-query": "^3.39.2",
"react-redux": "^8.0.5",
"react-router-dom": "^6.5.0",
"react-scripts": "5.0.1",
"react-textarea-autosize": "^8.4.0",
"react-twitter-embed": "^4.0.4",
"typescript": "^4.9.4",
"unist-util-visit": "^4.1.2",
"uuid": "^9.0.0",
"workbox-background-sync": "^6.4.2",
"workbox-broadcast-update": "^6.4.2",
"workbox-cacheable-response": "^6.4.2",
"workbox-core": "^6.4.2",
"workbox-expiration": "^6.4.2",
"workbox-google-analytics": "^6.4.2",
"workbox-navigation-preload": "^6.4.2",
"workbox-precaching": "^6.4.2",
"workbox-range-requests": "^6.4.2",
"workbox-routing": "^6.4.2",
"workbox-strategies": "^6.4.2",
"workbox-streams": "^6.4.2"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject",
"intl-extract": "formatjs extract 'src/**/*.ts*' --ignore='**/*.d.ts' --out-file src/lang.json --format transifex --flatten true",
"intl-compile": "formatjs compile src/lang.json --out-file src/translations/en.json --format transifex",
"transifex": "formatjs compile src/translations/$LNG.json --out-file src/translations/$LNG.json --format transifex",
"format": "prettier --write .",
"eslint": "eslint .",
"prepare": "husky install"
},
"eslintConfig": {
"extends": [
"react-app"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@formatjs/cli": "^6.0.1",
"babel-plugin-formatjs": "^10.3.36",
"customize-cra": "^1.0.0",
"husky": ">=6",
"lint-staged": ">=10",
"prettier": "2.8.3",
"react-app-rewired": "^2.2.1"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,css,md}": "prettier --write"
}
"workspaces": [
"packages/*"
]
}

25
packages/app/.gitignore vendored Normal file
View File

@ -0,0 +1,25 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea

96
packages/app/package.json Normal file
View File

@ -0,0 +1,96 @@
{
"name": "@snort/app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@jukben/emoji-search": "^2.0.1",
"@noble/hashes": "^1.2.0",
"@noble/secp256k1": "^1.7.0",
"@protobufjs/base64": "^1.1.2",
"@reduxjs/toolkit": "^1.9.1",
"@szhsin/react-menu": "^3.3.1",
"@types/jest": "^29.2.5",
"@types/node": "^18.11.18",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.10",
"@types/uuid": "^9.0.0",
"@types/webscopeio__react-textarea-autocomplete": "^4.7.2",
"@webscopeio/react-textarea-autocomplete": "^4.9.2",
"bech32": "^2.0.0",
"dexie": "^3.2.2",
"dexie-react-hooks": "^1.1.1",
"light-bolt11-decoder": "^2.1.0",
"qr-code-styling": "^1.6.0-rc.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-intersection-observer": "^9.4.1",
"react-intl": "^6.2.8",
"react-markdown": "^8.0.4",
"react-query": "^3.39.2",
"react-redux": "^8.0.5",
"react-router-dom": "^6.5.0",
"react-scripts": "5.0.1",
"react-textarea-autosize": "^8.4.0",
"react-twitter-embed": "^4.0.4",
"typescript": "^4.9.4",
"unist-util-visit": "^4.1.2",
"uuid": "^9.0.0",
"workbox-background-sync": "^6.4.2",
"workbox-broadcast-update": "^6.4.2",
"workbox-cacheable-response": "^6.4.2",
"workbox-core": "^6.4.2",
"workbox-expiration": "^6.4.2",
"workbox-google-analytics": "^6.4.2",
"workbox-navigation-preload": "^6.4.2",
"workbox-precaching": "^6.4.2",
"workbox-range-requests": "^6.4.2",
"workbox-routing": "^6.4.2",
"workbox-strategies": "^6.4.2",
"workbox-streams": "^6.4.2",
"@snort/nostr": "^1.0.0"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject",
"intl-extract": "formatjs extract 'src/**/*.ts*' --ignore='**/*.d.ts' --out-file src/lang.json --format transifex --flatten true",
"intl-compile": "formatjs compile src/lang.json --out-file src/translations/en.json --format transifex",
"transifex": "formatjs compile src/translations/$LNG.json --out-file src/translations/$LNG.json --format transifex",
"format": "prettier --write .",
"eslint": "eslint .",
"prepare": "cd ../.. && husky install"
},
"eslintConfig": {
"extends": [
"react-app"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@formatjs/cli": "^6.0.1",
"babel-plugin-formatjs": "^10.3.36",
"customize-cra": "^1.0.0",
"husky": ">=6",
"lint-staged": ">=10",
"prettier": "2.8.3",
"react-app-rewired": "^2.2.1"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,css,md}": "prettier --write"
}
}

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 146 KiB

After

Width:  |  Height:  |  Size: 146 KiB

View File

Before

Width:  |  Height:  |  Size: 528 KiB

After

Width:  |  Height:  |  Size: 528 KiB

View File

Before

Width:  |  Height:  |  Size: 771 KiB

After

Width:  |  Height:  |  Size: 771 KiB

View File

@ -1,4 +1,4 @@
import { RelaySettings } from "Nostr/Connection";
import { RelaySettings } from "@snort/nostr";
/**
* Add-on api for snort features

View File

@ -1,5 +1,5 @@
import Dexie, { Table } from "dexie";
import { TaggedRawEvent, u256 } from "Nostr";
import { TaggedRawEvent, u256 } from "@snort/nostr";
import { MetadataCache } from "State/Users";
import { hexToBech32 } from "Util";

View File

@ -1,7 +1,7 @@
import "./Avatar.css";
import Nostrich from "nostrich.webp";
import { CSSProperties, useEffect, useState } from "react";
import type { UserMetadata } from "Nostr";
import type { UserMetadata } from "@snort/nostr";
import useImgProxy from "Feed/ImgProxy";
const Avatar = ({ user, ...rest }: { user?: UserMetadata; onClick?: () => void }) => {

View File

@ -1,5 +1,5 @@
import { FormattedMessage } from "react-intl";
import { HexKey } from "Nostr";
import { HexKey } from "@snort/nostr";
import useModeration from "Hooks/useModeration";
import messages from "./messages";

View File

@ -5,12 +5,12 @@ import { useIntl } from "react-intl";
import { useInView } from "react-intersection-observer";
import useEventPublisher from "Feed/EventPublisher";
import Event from "Nostr/Event";
import { Event } from "@snort/nostr";
import NoteTime from "Element/NoteTime";
import Text from "Element/Text";
import { setLastReadDm } from "Pages/MessagesPage";
import { RootState } from "State/Store";
import { HexKey, TaggedRawEvent } from "Nostr";
import { HexKey, TaggedRawEvent } from "@snort/nostr";
import { incDmInteraction } from "State/Login";
import { unwrap } from "Util";

View File

@ -2,7 +2,7 @@ import "./FollowButton.css";
import { useSelector } from "react-redux";
import { FormattedMessage } from "react-intl";
import useEventPublisher from "Feed/EventPublisher";
import { HexKey } from "Nostr";
import { HexKey } from "@snort/nostr";
import { RootState } from "State/Store";
import { parseId } from "Util";

View File

@ -2,7 +2,7 @@ import { ReactNode } from "react";
import { FormattedMessage } from "react-intl";
import useEventPublisher from "Feed/EventPublisher";
import { HexKey } from "Nostr";
import { HexKey } from "@snort/nostr";
import ProfilePreview from "Element/ProfilePreview";
import messages from "./messages";

View File

@ -2,8 +2,8 @@ import { useMemo } from "react";
import { useIntl } from "react-intl";
import useFollowersFeed from "Feed/FollowersFeed";
import { HexKey } from "Nostr";
import EventKind from "Nostr/EventKind";
import { HexKey } from "@snort/nostr";
import { EventKind } from "@snort/nostr";
import FollowListBase from "Element/FollowListBase";
import messages from "./messages";

View File

@ -2,7 +2,7 @@ import { useMemo } from "react";
import { useIntl } from "react-intl";
import useFollowsFeed from "Feed/FollowsFeed";
import { HexKey } from "Nostr";
import { HexKey } from "@snort/nostr";
import FollowListBase from "Element/FollowListBase";
import { getFollowers } from "Feed/FollowsFeed";

View File

@ -3,7 +3,7 @@ import { useMemo } from "react";
import { useSelector } from "react-redux";
import { useIntl } from "react-intl";
import { HexKey } from "Nostr";
import { HexKey } from "@snort/nostr";
import { RootState } from "State/Store";
import useFollowsFeed from "Feed/FollowsFeed";
import { getFollowers } from "Feed/FollowsFeed";

View File

@ -19,7 +19,7 @@ import MixCloudEmbed from "Element/MixCloudEmbed";
import SpotifyEmbed from "Element/SpotifyEmbed";
import TidalEmbed from "Element/TidalEmbed";
import { ProxyImg } from "Element/ProxyImg";
import { HexKey } from "Nostr";
import { HexKey } from "@snort/nostr";
import TwitchEmbed from "./TwitchEmbed";
import AppleMusicEmbed from "./AppleMusicEmbed";

View File

@ -1,7 +1,7 @@
import { useMemo } from "react";
import { Link } from "react-router-dom";
import { useUserProfile } from "Feed/ProfileFeed";
import { HexKey } from "Nostr";
import { HexKey } from "@snort/nostr";
import { hexToBech32, profileLink } from "Util";
export default function Mention({ pubkey }: { pubkey: HexKey }) {

View File

@ -1,5 +1,5 @@
import { FormattedMessage } from "react-intl";
import { HexKey } from "Nostr";
import { HexKey } from "@snort/nostr";
import useModeration from "Hooks/useModeration";
import messages from "./messages";

View File

@ -1,6 +1,6 @@
import { useMemo } from "react";
import { FormattedMessage } from "react-intl";
import { HexKey } from "Nostr";
import { HexKey } from "@snort/nostr";
import MuteButton from "Element/MuteButton";
import ProfilePreview from "Element/ProfilePreview";
import useMutedFeed, { getMuted } from "Feed/MuteList";

View File

@ -4,7 +4,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faCircleCheck, faSpinner, faTriangleExclamation } from "@fortawesome/free-solid-svg-icons";
import "./Nip05.css";
import { HexKey } from "Nostr";
import { HexKey } from "@snort/nostr";
interface NostrJson {
names: Record<string, string>;

View File

@ -20,7 +20,7 @@ import Copy from "Element/Copy";
import { useUserProfile } from "Feed/ProfileFeed";
import useEventPublisher from "Feed/EventPublisher";
import { debounce } from "Util";
import { UserMetadata } from "Nostr";
import { UserMetadata } from "@snort/nostr";
import messages from "./messages";
import { RootState } from "State/Store";

View File

@ -8,15 +8,14 @@ import { useIntl, FormattedMessage } from "react-intl";
import useEventPublisher from "Feed/EventPublisher";
import Bookmark from "Icons/Bookmark";
import Pin from "Icons/Pin";
import { default as NEvent } from "Nostr/Event";
import { Event as NEvent, EventKind } from "@snort/nostr";
import ProfileImage from "Element/ProfileImage";
import Text from "Element/Text";
import { eventLink, getReactions, hexToBech32 } from "Util";
import NoteFooter, { Translation } from "Element/NoteFooter";
import NoteTime from "Element/NoteTime";
import EventKind from "Nostr/EventKind";
import { useUserProfiles } from "Feed/ProfileFeed";
import { TaggedRawEvent, u256, HexKey } from "Nostr";
import { TaggedRawEvent, u256, HexKey } from "@snort/nostr";
import useModeration from "Hooks/useModeration";
import { setPinned, setBookmarked } from "State/Login";
import type { RootState } from "State/Store";

View File

@ -8,7 +8,7 @@ import { openFile } from "Util";
import Textarea from "Element/Textarea";
import Modal from "Element/Modal";
import ProfileImage from "Element/ProfileImage";
import { default as NEvent } from "Nostr/Event";
import { Event as NEvent } from "@snort/nostr";
import useFileUpload from "Upload";
import messages from "./messages";

View File

@ -26,10 +26,8 @@ import Reactions from "Element/Reactions";
import SendSats from "Element/SendSats";
import { parseZap, ZapsSummary } from "Element/Zap";
import { useUserProfile } from "Feed/ProfileFeed";
import { default as NEvent } from "Nostr/Event";
import { Event as NEvent, EventKind, TaggedRawEvent } from "@snort/nostr";
import { RootState } from "State/Store";
import { HexKey, TaggedRawEvent } from "Nostr";
import EventKind from "Nostr/EventKind";
import { UserPreferences, setPinned, setBookmarked } from "State/Login";
import useModeration from "Hooks/useModeration";
import { TranslateHost } from "Const";

View File

@ -2,13 +2,12 @@ import "./NoteReaction.css";
import { Link } from "react-router-dom";
import { useMemo } from "react";
import EventKind from "Nostr/EventKind";
import { EventKind, Event as NEvent } from "@snort/nostr";
import Note from "Element/Note";
import ProfileImage from "Element/ProfileImage";
import { default as NEvent } from "Nostr/Event";
import { eventLink, hexToBech32 } from "Util";
import NoteTime from "Element/NoteTime";
import { RawEvent, TaggedRawEvent } from "Nostr";
import { RawEvent, TaggedRawEvent } from "@snort/nostr";
import useModeration from "Hooks/useModeration";
export interface NoteReactionProps {

View File

@ -6,7 +6,7 @@ import { useUserProfile } from "Feed/ProfileFeed";
import { hexToBech32, profileLink } from "Util";
import Avatar from "Element/Avatar";
import Nip05 from "Element/Nip05";
import { HexKey } from "Nostr";
import { HexKey } from "@snort/nostr";
import { MetadataCache } from "State/Users";
export interface ProfileImageProps {

View File

@ -4,7 +4,7 @@ import { ReactNode } from "react";
import ProfileImage from "Element/ProfileImage";
import FollowButton from "Element/FollowButton";
import { useUserProfile } from "Feed/ProfileFeed";
import { HexKey } from "Nostr";
import { HexKey } from "@snort/nostr";
import { useInView } from "react-intersection-observer";
export interface ProfilePreviewProps {

View File

@ -3,7 +3,7 @@ import "./Reactions.css";
import { useState, useMemo, useEffect } from "react";
import { useIntl, FormattedMessage } from "react-intl";
import { TaggedRawEvent } from "Nostr";
import { TaggedRawEvent } from "@snort/nostr";
import { formatShort } from "Number";
import Dislike from "Icons/Dislike";

View File

@ -15,7 +15,7 @@ import { useMemo } from "react";
import { useDispatch, useSelector } from "react-redux";
import { setRelays } from "State/Login";
import { RootState } from "State/Store";
import { RelaySettings } from "Nostr/Connection";
import { RelaySettings } from "@snort/nostr";
import messages from "./messages";

View File

@ -2,7 +2,7 @@ import "./RelaysMetadata.css";
import Nostrich from "nostrich.webp";
import { useState } from "react";
import { RelaySettings } from "Nostr";
import { FullRelaySettings } from "@snort/nostr";
import Read from "Icons/Read";
import Write from "Icons/Write";
@ -19,7 +19,7 @@ const RelayFavicon = ({ url }: { url: string }) => {
};
interface RelaysMetadataProps {
relays: RelaySettings[];
relays: FullRelaySettings[];
}
const RelaysMetadata = ({ relays }: RelaysMetadataProps) => {

View File

@ -4,7 +4,7 @@ import { useIntl, FormattedMessage } from "react-intl";
import { formatShort } from "Number";
import { bech32ToText } from "Util";
import { HexKey } from "Nostr";
import { HexKey } from "@snort/nostr";
import Check from "Icons/Check";
import Zap from "Icons/Zap";
import Close from "Icons/Close";

Some files were not shown because too many files have changed in this diff Show More