Remove sveltekit, and typescript with ts-ignore for now

This commit is contained in:
minimo-io 2024-04-26 12:28:03 -03:00
parent 776a2afe06
commit dbe86b8622
16 changed files with 218 additions and 130 deletions

24
nostr-followback/.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

View File

@ -11,7 +11,4 @@ Let promote some reciprocity here! 😹
- Configure Vite for the miniapp to be loaded in the article's url as base.
- Save followbackers and not followbackers in lists to see details.
- Create an UI/UX that's worth looking at.
## v2
- Upload a localStorage list of relays

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Svelte + TS</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

View File

@ -1,21 +1,24 @@
{
"name": "test-nostr-reciprocal",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"svelte": "^4.2.7",
"vite": "^5.0.3"
},
"type": "module",
"dependencies": {
"@nostr-dev-kit/ndk": "^2.7.1"
}
"name": "nostr-followback",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@tsconfig/svelte": "^5.0.2",
"svelte": "^4.2.12",
"svelte-check": "^3.6.7",
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"vite": "^5.2.0"
},
"dependencies": {
"@nostr-dev-kit/ndk": "^2.8.1"
}
}

View File

@ -1,15 +1,16 @@
<script>
<script lang="ts">
// @ts-nocheck
// Import the package
import NDK from "@nostr-dev-kit/ndk";
import { fetchUserProfile } from "$lib/fetchs";
import { relays } from "$lib/data/relays";
import { fetchUserProfile } from "./lib/fetchs";
import { relays } from "./lib/data/relays";
// let npubToQuery = "npub1wujhdsytm3w6g0mpsqh8v7ezx83jcm64dlkwuqgm5v8lv0pds55ssudkw0";
let npubToQuery = "";
let querying = false;
let userName = "";
let userThumb = "";
let followsCount;
let followsCount = 0;
let followBackCount = 0;
let notFollowBackCount = 0;
@ -128,18 +129,23 @@
User: {userName} |  Follows: {followsCount}
<br />
{npubToQuery}
<br /><br />
Unknown: {unknownFollowBack} | Follow_Back: {followBackCount} | <strong>Not_Follow_Back</strong>:
<br />
<br />
Unknown: {unknownFollowBack} | Follow_Back: {followBackCount} |
<strong>Not_Follow_Back</strong>
:
<span title="Actually Counted">{notFollowBackCount}</span>
/ <span title="Actualy counted">{notFollowersBack.length}</span>
/
<span title="Actualy counted">{notFollowersBack.length}</span>
<br />
{#if progress < 100}
<p>
Progress =
<strong>{progress}%</strong> - {totalCountOfContactsChecked} of {followsCount}
<strong>{progress}%</strong>
- {totalCountOfContactsChecked} of {followsCount}
<!-- - {totalCountOfContactsChecked} of {followBackCount +
notFollowBackCount +
unknownFollowBack} -->
notFollowBackCount +
unknownFollowBack} -->
</p>
{:else}
<p><strong>Completed!</strong></p>
@ -159,19 +165,19 @@
{/each}
</ul>
<!-- <br />
<strong>They don't follow you ({notFollowersBack.length}):</strong>
<br />
<strong>They don't follow you ({notFollowersBack.length}):</strong>
<br />
<ul>
{#each notFollowersBack as item, i (item)}
<li>
#{i + 1} - <a href="https://nostr.band/{item}" target="_blank noreferrer noopener">Nostr.Band</a>
/ <a href="https://primal.net/p/{item}" target="_blank noreferrer noopener">Primal</a>
:
{item}
</li>
{/each}
</ul> -->
<ul>
{#each notFollowersBack as item, i (item)}
<li>
#{i + 1} - <a href="https://nostr.band/{item}" target="_blank noreferrer noopener">Nostr.Band</a>
/ <a href="https://primal.net/p/{item}" target="_blank noreferrer noopener">Primal</a>
:
{item}
</li>
{/each}
</ul> -->
</div>
{:else if !querying}
<p>Let's find out who does not follow you back in Nostr!</p>

View File

@ -0,0 +1,79 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
.card {
padding: 2em;
}
#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}

View File

@ -1,12 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>

View File

@ -0,0 +1,8 @@
import './app.css'
import App from './App.svelte'
const app = new App({
target: document.getElementById('app')!,
})
export default app

View File

@ -1,56 +0,0 @@
<script>
import NDK from "@nostr-dev-kit/ndk";
import { fetchUserProfile } from "$lib/fetchs.js";
import { relays } from "$lib/data/relays";
let npubToQuery = "npub1fyjqppvxj9z8km5c9hmyfvvnrqj8qxcz82av3dse57v3lftvhz3q98p6ma";
let userName;
let userThumb;
let followsCount;
let listOfFollows = [];
async function init() {
try {
const ndk = new NDK({
explicitRelayUrls: relays,
});
await ndk.connect();
const user = await fetchUserProfile(npubToQuery, ndk);
userName = user.profile.name;
userThumb = user.profile.image;
if (userName) {
const follows = await user.follows();
followsCount = follows.size;
if (follows.size) {
follows.forEach((contact) => {
listOfFollows.push(contact.npub);
listOfFollows = listOfFollows;
});
}
}
} catch (error) {
console.error("Error fetching data:", error);
}
}
init();
</script>
<h3>This npub follows:</h3>
{#if userThumb}
<a target="_blank noreferrer noopener" href="https://primal.net/p/{npubToQuery}"
><img src={userThumb} width="50" style="border-radius:100%;" alt="user-thumb" /></a
>
User: <a target="_blank noreferrer noopener" href="https://primal.net/p/{npubToQuery}">{userName}</a> |  Follows: {followsCount}
{:else}
<div class="loader">Loading data for... {npubToQuery}</div>
{/if}
<br /><br />
<ul>
{#each listOfFollows as item}
<li>{item}</li>
{/each}
</ul>

2
nostr-followback/src/vite-env.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
/// <reference types="svelte" />
/// <reference types="vite/client" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -1,13 +1,7 @@
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter()
}
};
export default config;
export default {
// Consult https://svelte.dev/docs#compile-time-svelte-preprocess
// for more information about preprocessors
preprocess: vitePreprocess(),
}

View File

@ -0,0 +1,20 @@
{
"extends": "@tsconfig/svelte/tsconfig.json",
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"resolveJsonModule": true,
/**
* Typecheck JS in `.svelte` and `.js` files by default.
* Disable checkJs if you'd like to use dynamic types in JS.
* Note that setting allowJs false does not prevent the use
* of JS in `.svelte` files.
*/
"allowJs": true,
"checkJs": true,
"isolatedModules": true
},
"include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
"references": [{ "path": "./tsconfig.node.json" }]
}

View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true
},
"include": ["vite.config.ts"]
}

View File

@ -1,6 +0,0 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [sveltekit()]
});

View File

@ -0,0 +1,7 @@
import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [svelte()],
});